Chromium Code Reviews| Index: src/builtins/builtins-sharedarraybuffer.cc |
| diff --git a/src/builtins/builtins-sharedarraybuffer.cc b/src/builtins/builtins-sharedarraybuffer.cc |
| index d2b9f1efa96b4bbfc2315986f9f793205b0b3869..ed6444d0ad488af9ade4c266992d6b4bf36c894b 100644 |
| --- a/src/builtins/builtins-sharedarraybuffer.cc |
| +++ b/src/builtins/builtins-sharedarraybuffer.cc |
| @@ -337,5 +337,87 @@ TF_BUILTIN(AtomicsExchange, SharedArrayBufferBuiltinsAssembler) { |
| // || V8_TARGET_ARCH_PPC || V8_TARGET_ARCH_S390 || V8_TARGET_ARCH_S390X |
| } |
| +TF_BUILTIN(AtomicsCompareExchange, SharedArrayBufferBuiltinsAssembler) { |
| + Node* array = Parameter(1); |
| + Node* index = Parameter(2); |
| + Node* old_value = Parameter(3); |
| + Node* new_value = Parameter(4); |
| + Node* context = Parameter(5 + 2); |
| + |
| + Node* instance_type; |
| + Node* backing_store; |
| + ValidateSharedTypedArray(array, context, &instance_type, &backing_store); |
| + |
| + Node* index_integer; |
| + Node* index_word32 = |
| + ConvertTaggedAtomicIndexToWord32(index, context, &index_integer); |
| + Node* array_length_word32 = TruncateTaggedToWord32( |
| + context, LoadObjectField(array, JSTypedArray::kLengthOffset)); |
| + ValidateAtomicIndex(index_word32, array_length_word32, context); |
| + |
| + Node* old_value_integer = ToInteger(context, old_value); |
| + |
| + Node* new_value_integer = ToInteger(context, new_value); |
| + |
| +#if V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_PPC64 || \ |
| + V8_TARGET_ARCH_PPC || V8_TARGET_ARCH_S390 || V8_TARGET_ARCH_S390X |
| + a.Return(a.CallRuntime(Runtime::kAtomicsCompareExchange, context, array, |
|
Jakob Kummerow
2017/03/10 21:05:39
s/a.//g
aseemgarg
2017/03/10 21:09:54
Done.
|
| + index_integer, old_value_integer, new_value_integer)); |
| +#else |
| + Node* index_word = ChangeUint32ToWord(index_word32); |
| + |
| + Node* old_value_word32 = TruncateTaggedToWord32(context, old_value_integer); |
| + |
| + Node* new_value_word32 = TruncateTaggedToWord32(context, new_value_integer); |
| + |
| + CodeStubAssembler::Label i8(this), u8(this), i16(this), u16(this), i32(this), |
|
Jakob Kummerow
2017/03/10 21:05:39
s/CodeStubAssembler:://
aseemgarg
2017/03/10 21:09:54
Done.
|
| + u32(this), other(this); |
| + int32_t case_values[] = { |
| + FIXED_INT8_ARRAY_TYPE, FIXED_UINT8_ARRAY_TYPE, FIXED_INT16_ARRAY_TYPE, |
| + FIXED_UINT16_ARRAY_TYPE, FIXED_INT32_ARRAY_TYPE, FIXED_UINT32_ARRAY_TYPE, |
| + }; |
| + CodeStubAssembler::Label* case_labels[] = { |
|
Jakob Kummerow
2017/03/10 21:05:39
s/CodeStubAssembler:://
aseemgarg
2017/03/10 21:09:54
Done.
|
| + &i8, &u8, &i16, &u16, &i32, &u32, |
| + }; |
| + Switch(instance_type, &other, case_values, case_labels, |
| + arraysize(case_labels)); |
| + |
| + Bind(&i8); |
| + Return(SmiFromWord32(AtomicCompareExchange(MachineType::Int8(), backing_store, |
| + index_word, old_value_word32, |
| + new_value_word32))); |
| + |
| + Bind(&u8); |
| + Return(SmiFromWord32( |
| + AtomicCompareExchange(MachineType::Uint8(), backing_store, index_word, |
| + old_value_word32, new_value_word32))); |
| + |
| + Bind(&i16); |
| + Return(SmiFromWord32(AtomicCompareExchange( |
| + MachineType::Int16(), backing_store, WordShl(index_word, 1), |
| + old_value_word32, new_value_word32))); |
| + |
| + Bind(&u16); |
| + Return(SmiFromWord32(AtomicCompareExchange( |
| + MachineType::Uint16(), backing_store, WordShl(index_word, 1), |
| + old_value_word32, new_value_word32))); |
| + |
| + Bind(&i32); |
| + Return(ChangeInt32ToTagged(AtomicCompareExchange( |
| + MachineType::Int32(), backing_store, WordShl(index_word, 2), |
| + old_value_word32, new_value_word32))); |
| + |
| + Bind(&u32); |
| + Return(ChangeUint32ToTagged(AtomicCompareExchange( |
| + MachineType::Uint32(), backing_store, WordShl(index_word, 2), |
| + old_value_word32, new_value_word32))); |
| + |
| + // This shouldn't happen, we've already validated the type. |
| + Bind(&other); |
| + Unreachable(); |
| +#endif // V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_PPC64 |
| + // || V8_TARGET_ARCH_PPC || V8_TARGET_ARCH_S390 || V8_TARGET_ARCH_S390X |
| +} |
| + |
| } // namespace internal |
| } // namespace v8 |