LCOV - code coverage report
Current view: top level - src/builtins - builtins-sharedarraybuffer-gen.cc (source / functions) Hit Total Coverage
Test: app.info Lines: 174 174 100.0 %
Date: 2017-04-26 Functions: 22 22 100.0 %

          Line data    Source code
       1             : // Copyright 2017 the V8 project authors. All rights reserved.
       2             : // Use of this source code is governed by a BSD-style license that can be
       3             : // found in the LICENSE file.
       4             : 
       5             : #include "src/builtins/builtins-utils-gen.h"
       6             : #include "src/builtins/builtins.h"
       7             : #include "src/code-stub-assembler.h"
       8             : #include "src/objects.h"
       9             : 
      10             : namespace v8 {
      11             : namespace internal {
      12             : 
      13             : using compiler::Node;
      14             : 
      15             : class SharedArrayBufferBuiltinsAssembler : public CodeStubAssembler {
      16             :  public:
      17             :   explicit SharedArrayBufferBuiltinsAssembler(
      18             :       compiler::CodeAssemblerState* state)
      19         387 :       : CodeStubAssembler(state) {}
      20             : 
      21             :  protected:
      22             :   typedef Node* (CodeAssembler::*AssemblerFunction)(MachineType type,
      23             :                                                     Node* base, Node* offset,
      24             :                                                     Node* value);
      25             :   void ValidateSharedTypedArray(Node* tagged, Node* context,
      26             :                                 Node** out_instance_type,
      27             :                                 Node** out_backing_store);
      28             :   Node* ConvertTaggedAtomicIndexToWord32(Node* tagged, Node* context,
      29             :                                          Node** number_index);
      30             :   void ValidateAtomicIndex(Node* array, Node* index_word, Node* context);
      31             : #if DEBUG
      32             :   void DebugSanityCheckAtomicIndex(Node* array, Node* index_word,
      33             :                                    Node* context);
      34             : #endif
      35             :   void AtomicBinopBuiltinCommon(Node* array, Node* index, Node* value,
      36             :                                 Node* context, AssemblerFunction function,
      37             :                                 Runtime::FunctionId runtime_function);
      38             : };
      39             : 
      40         387 : void SharedArrayBufferBuiltinsAssembler::ValidateSharedTypedArray(
      41             :     Node* tagged, Node* context, Node** out_instance_type,
      42             :     Node** out_backing_store) {
      43         774 :   Label not_float_or_clamped(this), invalid(this);
      44             : 
      45             :   // Fail if it is not a heap object.
      46         387 :   GotoIf(TaggedIsSmi(tagged), &invalid);
      47             : 
      48             :   // Fail if the array's instance type is not JSTypedArray.
      49             :   GotoIf(Word32NotEqual(LoadInstanceType(tagged),
      50             :                         Int32Constant(JS_TYPED_ARRAY_TYPE)),
      51         387 :          &invalid);
      52             : 
      53             :   // Fail if the array's JSArrayBuffer is not shared.
      54         387 :   Node* array_buffer = LoadObjectField(tagged, JSTypedArray::kBufferOffset);
      55             :   Node* bitfield = LoadObjectField(array_buffer, JSArrayBuffer::kBitFieldOffset,
      56         387 :                                    MachineType::Uint32());
      57         387 :   GotoIfNot(IsSetWord32<JSArrayBuffer::IsShared>(bitfield), &invalid);
      58             : 
      59             :   // Fail if the array's element type is float32, float64 or clamped.
      60             :   Node* elements_instance_type =
      61         387 :       LoadInstanceType(LoadObjectField(tagged, JSObject::kElementsOffset));
      62             :   STATIC_ASSERT(FIXED_INT8_ARRAY_TYPE < FIXED_FLOAT32_ARRAY_TYPE);
      63             :   STATIC_ASSERT(FIXED_INT16_ARRAY_TYPE < FIXED_FLOAT32_ARRAY_TYPE);
      64             :   STATIC_ASSERT(FIXED_INT32_ARRAY_TYPE < FIXED_FLOAT32_ARRAY_TYPE);
      65             :   STATIC_ASSERT(FIXED_UINT8_ARRAY_TYPE < FIXED_FLOAT32_ARRAY_TYPE);
      66             :   STATIC_ASSERT(FIXED_UINT16_ARRAY_TYPE < FIXED_FLOAT32_ARRAY_TYPE);
      67             :   STATIC_ASSERT(FIXED_UINT32_ARRAY_TYPE < FIXED_FLOAT32_ARRAY_TYPE);
      68             :   Branch(Int32LessThan(elements_instance_type,
      69             :                        Int32Constant(FIXED_FLOAT32_ARRAY_TYPE)),
      70         387 :          &not_float_or_clamped, &invalid);
      71             : 
      72         387 :   BIND(&invalid);
      73             :   {
      74             :     CallRuntime(Runtime::kThrowNotIntegerSharedTypedArrayError, context,
      75         387 :                 tagged);
      76         387 :     Unreachable();
      77             :   }
      78             : 
      79         387 :   BIND(&not_float_or_clamped);
      80         387 :   *out_instance_type = elements_instance_type;
      81             : 
      82             :   Node* backing_store =
      83         387 :       LoadObjectField(array_buffer, JSArrayBuffer::kBackingStoreOffset);
      84             :   Node* byte_offset = ChangeUint32ToWord(TruncateTaggedToWord32(
      85         387 :       context, LoadObjectField(tagged, JSArrayBufferView::kByteOffsetOffset)));
      86             :   *out_backing_store =
      87         774 :       IntPtrAdd(BitcastTaggedToWord(backing_store), byte_offset);
      88         387 : }
      89             : 
      90             : // https://tc39.github.io/ecmascript_sharedmem/shmem.html#Atomics.ValidateAtomicAccess
      91         387 : Node* SharedArrayBufferBuiltinsAssembler::ConvertTaggedAtomicIndexToWord32(
      92             :     Node* tagged, Node* context, Node** number_index) {
      93         387 :   VARIABLE(var_result, MachineRepresentation::kWord32);
      94         387 :   Label done(this), range_error(this);
      95             : 
      96             :   // Returns word32 since index cannot be longer than a TypedArray length,
      97             :   // which has a uint32 maximum.
      98             :   // The |number_index| output parameter is used only for architectures that
      99             :   // don't currently have a TF implementation and forward to runtime functions
     100             :   // instead; they expect the value has already been coerced to an integer.
     101         387 :   *number_index = ToSmiIndex(tagged, context, &range_error);
     102         387 :   var_result.Bind(SmiToWord32(*number_index));
     103         387 :   Goto(&done);
     104             : 
     105         387 :   BIND(&range_error);
     106             :   {
     107         387 :     CallRuntime(Runtime::kThrowInvalidAtomicAccessIndexError, context);
     108         387 :     Unreachable();
     109             :   }
     110             : 
     111         387 :   BIND(&done);
     112         774 :   return var_result.value();
     113             : }
     114             : 
     115         387 : void SharedArrayBufferBuiltinsAssembler::ValidateAtomicIndex(Node* array,
     116             :                                                              Node* index_word,
     117             :                                                              Node* context) {
     118             :   // Check if the index is in bounds. If not, throw RangeError.
     119         387 :   Label check_passed(this);
     120             :   Node* array_length_word32 = TruncateTaggedToWord32(
     121         387 :       context, LoadObjectField(array, JSTypedArray::kLengthOffset));
     122         387 :   GotoIf(Uint32LessThan(index_word, array_length_word32), &check_passed);
     123             : 
     124         387 :   CallRuntime(Runtime::kThrowInvalidAtomicAccessIndexError, context);
     125         387 :   Unreachable();
     126             : 
     127         387 :   BIND(&check_passed);
     128         387 : }
     129             : 
     130             : #if DEBUG
     131             : void SharedArrayBufferBuiltinsAssembler::DebugSanityCheckAtomicIndex(
     132             :     Node* array, Node* index_word, Node* context) {
     133             :   // In Debug mode, we re-validate the index as a sanity check because
     134             :   // ToInteger above calls out to JavaScript. A SharedArrayBuffer can't be
     135             :   // neutered and the TypedArray length can't change either, so skipping this
     136             :   // check in Release mode is safe.
     137             :   CSA_ASSERT(
     138             :       this,
     139             :       Uint32LessThan(
     140             :           index_word,
     141             :           TruncateTaggedToWord32(
     142             :               context, LoadObjectField(array, JSTypedArray::kLengthOffset))));
     143             : }
     144             : #endif
     145             : 
     146         172 : TF_BUILTIN(AtomicsLoad, SharedArrayBufferBuiltinsAssembler) {
     147             :   Node* array = Parameter(Descriptor::kArray);
     148             :   Node* index = Parameter(Descriptor::kIndex);
     149             :   Node* context = Parameter(Descriptor::kContext);
     150             : 
     151             :   Node* instance_type;
     152             :   Node* backing_store;
     153          43 :   ValidateSharedTypedArray(array, context, &instance_type, &backing_store);
     154             : 
     155             :   Node* index_integer;
     156             :   Node* index_word32 =
     157          43 :       ConvertTaggedAtomicIndexToWord32(index, context, &index_integer);
     158          43 :   ValidateAtomicIndex(array, index_word32, context);
     159          43 :   Node* index_word = ChangeUint32ToWord(index_word32);
     160             : 
     161          43 :   Label i8(this), u8(this), i16(this), u16(this), i32(this), u32(this),
     162          43 :       other(this);
     163             :   int32_t case_values[] = {
     164             :       FIXED_INT8_ARRAY_TYPE,   FIXED_UINT8_ARRAY_TYPE, FIXED_INT16_ARRAY_TYPE,
     165             :       FIXED_UINT16_ARRAY_TYPE, FIXED_INT32_ARRAY_TYPE, FIXED_UINT32_ARRAY_TYPE,
     166          43 :   };
     167             :   Label* case_labels[] = {
     168             :       &i8, &u8, &i16, &u16, &i32, &u32,
     169          43 :   };
     170             :   Switch(instance_type, &other, case_values, case_labels,
     171          43 :          arraysize(case_labels));
     172             : 
     173          43 :   BIND(&i8);
     174             :   Return(SmiFromWord32(
     175          43 :       AtomicLoad(MachineType::Int8(), backing_store, index_word)));
     176             : 
     177          43 :   BIND(&u8);
     178             :   Return(SmiFromWord32(
     179          43 :       AtomicLoad(MachineType::Uint8(), backing_store, index_word)));
     180             : 
     181          43 :   BIND(&i16);
     182             :   Return(SmiFromWord32(
     183          43 :       AtomicLoad(MachineType::Int16(), backing_store, WordShl(index_word, 1))));
     184             : 
     185          43 :   BIND(&u16);
     186             :   Return(SmiFromWord32(AtomicLoad(MachineType::Uint16(), backing_store,
     187          43 :                                   WordShl(index_word, 1))));
     188             : 
     189          43 :   BIND(&i32);
     190             :   Return(ChangeInt32ToTagged(
     191          43 :       AtomicLoad(MachineType::Int32(), backing_store, WordShl(index_word, 2))));
     192             : 
     193          43 :   BIND(&u32);
     194             :   Return(ChangeUint32ToTagged(AtomicLoad(MachineType::Uint32(), backing_store,
     195          43 :                                          WordShl(index_word, 2))));
     196             : 
     197             :   // This shouldn't happen, we've already validated the type.
     198          43 :   BIND(&other);
     199          86 :   Unreachable();
     200          43 : }
     201             : 
     202         172 : TF_BUILTIN(AtomicsStore, SharedArrayBufferBuiltinsAssembler) {
     203             :   Node* array = Parameter(Descriptor::kArray);
     204             :   Node* index = Parameter(Descriptor::kIndex);
     205             :   Node* value = Parameter(Descriptor::kValue);
     206             :   Node* context = Parameter(Descriptor::kContext);
     207             : 
     208             :   Node* instance_type;
     209             :   Node* backing_store;
     210          43 :   ValidateSharedTypedArray(array, context, &instance_type, &backing_store);
     211             : 
     212             :   Node* index_integer;
     213             :   Node* index_word32 =
     214          43 :       ConvertTaggedAtomicIndexToWord32(index, context, &index_integer);
     215          43 :   ValidateAtomicIndex(array, index_word32, context);
     216          43 :   Node* index_word = ChangeUint32ToWord(index_word32);
     217             : 
     218          43 :   Node* value_integer = ToInteger(context, value);
     219          43 :   Node* value_word32 = TruncateTaggedToWord32(context, value_integer);
     220             : 
     221             : #if DEBUG
     222             :   DebugSanityCheckAtomicIndex(array, index_word32, context);
     223             : #endif
     224             : 
     225          43 :   Label u8(this), u16(this), u32(this), other(this);
     226             :   int32_t case_values[] = {
     227             :       FIXED_INT8_ARRAY_TYPE,   FIXED_UINT8_ARRAY_TYPE, FIXED_INT16_ARRAY_TYPE,
     228             :       FIXED_UINT16_ARRAY_TYPE, FIXED_INT32_ARRAY_TYPE, FIXED_UINT32_ARRAY_TYPE,
     229          43 :   };
     230             :   Label* case_labels[] = {
     231             :       &u8, &u8, &u16, &u16, &u32, &u32,
     232          43 :   };
     233             :   Switch(instance_type, &other, case_values, case_labels,
     234          43 :          arraysize(case_labels));
     235             : 
     236          43 :   BIND(&u8);
     237             :   AtomicStore(MachineRepresentation::kWord8, backing_store, index_word,
     238          43 :               value_word32);
     239          43 :   Return(value_integer);
     240             : 
     241          43 :   BIND(&u16);
     242             :   AtomicStore(MachineRepresentation::kWord16, backing_store,
     243          43 :               WordShl(index_word, 1), value_word32);
     244          43 :   Return(value_integer);
     245             : 
     246          43 :   BIND(&u32);
     247             :   AtomicStore(MachineRepresentation::kWord32, backing_store,
     248          43 :               WordShl(index_word, 2), value_word32);
     249          43 :   Return(value_integer);
     250             : 
     251             :   // This shouldn't happen, we've already validated the type.
     252          43 :   BIND(&other);
     253          86 :   Unreachable();
     254          43 : }
     255             : 
     256         172 : TF_BUILTIN(AtomicsExchange, SharedArrayBufferBuiltinsAssembler) {
     257             :   Node* array = Parameter(Descriptor::kArray);
     258             :   Node* index = Parameter(Descriptor::kIndex);
     259             :   Node* value = Parameter(Descriptor::kValue);
     260             :   Node* context = Parameter(Descriptor::kContext);
     261             : 
     262             :   Node* instance_type;
     263             :   Node* backing_store;
     264          43 :   ValidateSharedTypedArray(array, context, &instance_type, &backing_store);
     265             : 
     266             :   Node* index_integer;
     267             :   Node* index_word32 =
     268          43 :       ConvertTaggedAtomicIndexToWord32(index, context, &index_integer);
     269          43 :   ValidateAtomicIndex(array, index_word32, context);
     270             : 
     271          43 :   Node* value_integer = ToInteger(context, value);
     272             : 
     273             : #if DEBUG
     274             :   DebugSanityCheckAtomicIndex(array, index_word32, context);
     275             : #endif
     276             : 
     277             : #if V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64
     278             :   Return(CallRuntime(Runtime::kAtomicsExchange, context, array, index_integer,
     279             :                      value_integer));
     280             : #else
     281          43 :   Node* index_word = ChangeUint32ToWord(index_word32);
     282             : 
     283          43 :   Node* value_word32 = TruncateTaggedToWord32(context, value_integer);
     284             : 
     285          43 :   Label i8(this), u8(this), i16(this), u16(this), i32(this), u32(this),
     286          43 :       other(this);
     287             :   int32_t case_values[] = {
     288             :       FIXED_INT8_ARRAY_TYPE,   FIXED_UINT8_ARRAY_TYPE, FIXED_INT16_ARRAY_TYPE,
     289             :       FIXED_UINT16_ARRAY_TYPE, FIXED_INT32_ARRAY_TYPE, FIXED_UINT32_ARRAY_TYPE,
     290          43 :   };
     291             :   Label* case_labels[] = {
     292             :       &i8, &u8, &i16, &u16, &i32, &u32,
     293          43 :   };
     294             :   Switch(instance_type, &other, case_values, case_labels,
     295          43 :          arraysize(case_labels));
     296             : 
     297          43 :   BIND(&i8);
     298             :   Return(SmiFromWord32(AtomicExchange(MachineType::Int8(), backing_store,
     299          43 :                                       index_word, value_word32)));
     300             : 
     301          43 :   BIND(&u8);
     302             :   Return(SmiFromWord32(AtomicExchange(MachineType::Uint8(), backing_store,
     303          43 :                                       index_word, value_word32)));
     304             : 
     305          43 :   BIND(&i16);
     306             :   Return(SmiFromWord32(AtomicExchange(MachineType::Int16(), backing_store,
     307          43 :                                       WordShl(index_word, 1), value_word32)));
     308             : 
     309          43 :   BIND(&u16);
     310             :   Return(SmiFromWord32(AtomicExchange(MachineType::Uint16(), backing_store,
     311          43 :                                       WordShl(index_word, 1), value_word32)));
     312             : 
     313          43 :   BIND(&i32);
     314             :   Return(ChangeInt32ToTagged(AtomicExchange(MachineType::Int32(), backing_store,
     315             :                                             WordShl(index_word, 2),
     316          43 :                                             value_word32)));
     317             : 
     318          43 :   BIND(&u32);
     319             :   Return(ChangeUint32ToTagged(
     320             :       AtomicExchange(MachineType::Uint32(), backing_store,
     321          43 :                      WordShl(index_word, 2), value_word32)));
     322             : 
     323             :   // This shouldn't happen, we've already validated the type.
     324          43 :   BIND(&other);
     325          86 :   Unreachable();
     326             : #endif  // V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64
     327          43 : }
     328             : 
     329         172 : TF_BUILTIN(AtomicsCompareExchange, SharedArrayBufferBuiltinsAssembler) {
     330             :   Node* array = Parameter(Descriptor::kArray);
     331             :   Node* index = Parameter(Descriptor::kIndex);
     332             :   Node* old_value = Parameter(Descriptor::kOldValue);
     333             :   Node* new_value = Parameter(Descriptor::kNewValue);
     334             :   Node* context = Parameter(Descriptor::kContext);
     335             : 
     336             :   Node* instance_type;
     337             :   Node* backing_store;
     338          43 :   ValidateSharedTypedArray(array, context, &instance_type, &backing_store);
     339             : 
     340             :   Node* index_integer;
     341             :   Node* index_word32 =
     342          43 :       ConvertTaggedAtomicIndexToWord32(index, context, &index_integer);
     343          43 :   ValidateAtomicIndex(array, index_word32, context);
     344             : 
     345          43 :   Node* old_value_integer = ToInteger(context, old_value);
     346          43 :   Node* new_value_integer = ToInteger(context, new_value);
     347             : 
     348             : #if DEBUG
     349             :   DebugSanityCheckAtomicIndex(array, index_word32, context);
     350             : #endif
     351             : 
     352             : #if V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_PPC64 || \
     353             :     V8_TARGET_ARCH_PPC || V8_TARGET_ARCH_S390 || V8_TARGET_ARCH_S390X
     354             :   Return(CallRuntime(Runtime::kAtomicsCompareExchange, context, array,
     355             :                      index_integer, old_value_integer, new_value_integer));
     356             : #else
     357          43 :   Node* index_word = ChangeUint32ToWord(index_word32);
     358             : 
     359          43 :   Node* old_value_word32 = TruncateTaggedToWord32(context, old_value_integer);
     360             : 
     361          43 :   Node* new_value_word32 = TruncateTaggedToWord32(context, new_value_integer);
     362             : 
     363          43 :   Label i8(this), u8(this), i16(this), u16(this), i32(this), u32(this),
     364          43 :       other(this);
     365             :   int32_t case_values[] = {
     366             :       FIXED_INT8_ARRAY_TYPE,   FIXED_UINT8_ARRAY_TYPE, FIXED_INT16_ARRAY_TYPE,
     367             :       FIXED_UINT16_ARRAY_TYPE, FIXED_INT32_ARRAY_TYPE, FIXED_UINT32_ARRAY_TYPE,
     368          43 :   };
     369             :   Label* case_labels[] = {
     370             :       &i8, &u8, &i16, &u16, &i32, &u32,
     371          43 :   };
     372             :   Switch(instance_type, &other, case_values, case_labels,
     373          43 :          arraysize(case_labels));
     374             : 
     375          43 :   BIND(&i8);
     376             :   Return(SmiFromWord32(AtomicCompareExchange(MachineType::Int8(), backing_store,
     377             :                                              index_word, old_value_word32,
     378          43 :                                              new_value_word32)));
     379             : 
     380          43 :   BIND(&u8);
     381             :   Return(SmiFromWord32(
     382             :       AtomicCompareExchange(MachineType::Uint8(), backing_store, index_word,
     383          43 :                             old_value_word32, new_value_word32)));
     384             : 
     385          43 :   BIND(&i16);
     386             :   Return(SmiFromWord32(AtomicCompareExchange(
     387             :       MachineType::Int16(), backing_store, WordShl(index_word, 1),
     388          43 :       old_value_word32, new_value_word32)));
     389             : 
     390          43 :   BIND(&u16);
     391             :   Return(SmiFromWord32(AtomicCompareExchange(
     392             :       MachineType::Uint16(), backing_store, WordShl(index_word, 1),
     393          43 :       old_value_word32, new_value_word32)));
     394             : 
     395          43 :   BIND(&i32);
     396             :   Return(ChangeInt32ToTagged(AtomicCompareExchange(
     397             :       MachineType::Int32(), backing_store, WordShl(index_word, 2),
     398          43 :       old_value_word32, new_value_word32)));
     399             : 
     400          43 :   BIND(&u32);
     401             :   Return(ChangeUint32ToTagged(AtomicCompareExchange(
     402             :       MachineType::Uint32(), backing_store, WordShl(index_word, 2),
     403          43 :       old_value_word32, new_value_word32)));
     404             : 
     405             :   // This shouldn't happen, we've already validated the type.
     406          43 :   BIND(&other);
     407          86 :   Unreachable();
     408             : #endif  // V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_PPC64
     409             :         // || V8_TARGET_ARCH_PPC || V8_TARGET_ARCH_S390 || V8_TARGET_ARCH_S390X
     410          43 : }
     411             : 
     412             : #define BINOP_BUILTIN(op)                                       \
     413             :   TF_BUILTIN(Atomics##op, SharedArrayBufferBuiltinsAssembler) { \
     414             :     Node* array = Parameter(Descriptor::kArray);                \
     415             :     Node* index = Parameter(Descriptor::kIndex);                \
     416             :     Node* value = Parameter(Descriptor::kValue);                \
     417             :     Node* context = Parameter(Descriptor::kContext);            \
     418             :     AtomicBinopBuiltinCommon(array, index, value, context,      \
     419             :                              &CodeAssembler::Atomic##op,        \
     420             :                              Runtime::kAtomics##op);            \
     421             :   }
     422         172 : BINOP_BUILTIN(Add)
     423         172 : BINOP_BUILTIN(Sub)
     424         172 : BINOP_BUILTIN(And)
     425         172 : BINOP_BUILTIN(Or)
     426         172 : BINOP_BUILTIN(Xor)
     427             : #undef BINOP_BUILTIN
     428             : 
     429         215 : void SharedArrayBufferBuiltinsAssembler::AtomicBinopBuiltinCommon(
     430             :     Node* array, Node* index, Node* value, Node* context,
     431             :     AssemblerFunction function, Runtime::FunctionId runtime_function) {
     432             :   Node* instance_type;
     433             :   Node* backing_store;
     434         215 :   ValidateSharedTypedArray(array, context, &instance_type, &backing_store);
     435             : 
     436             :   Node* index_integer;
     437             :   Node* index_word32 =
     438         215 :       ConvertTaggedAtomicIndexToWord32(index, context, &index_integer);
     439         215 :   ValidateAtomicIndex(array, index_word32, context);
     440             : 
     441         215 :   Node* value_integer = ToInteger(context, value);
     442             : 
     443             : #if DEBUG
     444             :   // In Debug mode, we re-validate the index as a sanity check because
     445             :   // ToInteger above calls out to JavaScript. A SharedArrayBuffer can't be
     446             :   // neutered and the TypedArray length can't change either, so skipping this
     447             :   // check in Release mode is safe.
     448             :   ValidateAtomicIndex(array, index_word32, context);
     449             : #endif
     450             : 
     451             : #if V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_PPC64 || \
     452             :     V8_TARGET_ARCH_PPC || V8_TARGET_ARCH_S390 || V8_TARGET_ARCH_S390X
     453             :   Return(CallRuntime(runtime_function, context, array, index_integer,
     454             :                      value_integer));
     455             : #else
     456         215 :   Node* index_word = ChangeUint32ToWord(index_word32);
     457             : 
     458         215 :   Node* value_word32 = TruncateTaggedToWord32(context, value_integer);
     459             : 
     460         215 :   Label i8(this), u8(this), i16(this), u16(this), i32(this), u32(this),
     461         215 :       other(this);
     462             :   int32_t case_values[] = {
     463             :       FIXED_INT8_ARRAY_TYPE,   FIXED_UINT8_ARRAY_TYPE, FIXED_INT16_ARRAY_TYPE,
     464             :       FIXED_UINT16_ARRAY_TYPE, FIXED_INT32_ARRAY_TYPE, FIXED_UINT32_ARRAY_TYPE,
     465         215 :   };
     466             :   Label* case_labels[] = {
     467             :       &i8, &u8, &i16, &u16, &i32, &u32,
     468         215 :   };
     469             :   Switch(instance_type, &other, case_values, case_labels,
     470         215 :          arraysize(case_labels));
     471             : 
     472         215 :   Bind(&i8);
     473             :   Return(SmiFromWord32((this->*function)(MachineType::Int8(), backing_store,
     474         215 :                                          index_word, value_word32)));
     475             : 
     476         215 :   Bind(&u8);
     477             :   Return(SmiFromWord32((this->*function)(MachineType::Uint8(), backing_store,
     478         215 :                                          index_word, value_word32)));
     479             : 
     480         215 :   Bind(&i16);
     481             :   Return(
     482             :       SmiFromWord32((this->*function)(MachineType::Int16(), backing_store,
     483         215 :                                       WordShl(index_word, 1), value_word32)));
     484             : 
     485         215 :   Bind(&u16);
     486             :   Return(
     487             :       SmiFromWord32((this->*function)(MachineType::Uint16(), backing_store,
     488         215 :                                       WordShl(index_word, 1), value_word32)));
     489             : 
     490         215 :   Bind(&i32);
     491             :   Return(ChangeInt32ToTagged(
     492             :       (this->*function)(MachineType::Int32(), backing_store,
     493         215 :                         WordShl(index_word, 2), value_word32)));
     494             : 
     495         215 :   Bind(&u32);
     496             :   Return(ChangeUint32ToTagged(
     497             :       (this->*function)(MachineType::Uint32(), backing_store,
     498         215 :                         WordShl(index_word, 2), value_word32)));
     499             : 
     500             :   // This shouldn't happen, we've already validated the type.
     501         215 :   Bind(&other);
     502         430 :   Unreachable();
     503             : #endif  // V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_PPC64
     504             :         // || V8_TARGET_ARCH_PPC || V8_TARGET_ARCH_S390 || V8_TARGET_ARCH_S390X
     505         215 : }
     506             : 
     507             : }  // namespace internal
     508             : }  // namespace v8

Generated by: LCOV version 1.10