Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/builtins/builtins-utils.h" | 5 #include "src/builtins/builtins-utils.h" |
| 6 #include "src/builtins/builtins.h" | 6 #include "src/builtins/builtins.h" |
| 7 #include "src/code-factory.h" | 7 #include "src/code-factory.h" |
| 8 #include "src/code-stub-assembler.h" | 8 #include "src/code-stub-assembler.h" |
| 9 | 9 |
| 10 namespace v8 { | 10 namespace v8 { |
| (...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 330 AtomicExchange(MachineType::Uint32(), backing_store, | 330 AtomicExchange(MachineType::Uint32(), backing_store, |
| 331 WordShl(index_word, 2), value_word32))); | 331 WordShl(index_word, 2), value_word32))); |
| 332 | 332 |
| 333 // This shouldn't happen, we've already validated the type. | 333 // This shouldn't happen, we've already validated the type. |
| 334 Bind(&other); | 334 Bind(&other); |
| 335 Unreachable(); | 335 Unreachable(); |
| 336 #endif // V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_PPC64 | 336 #endif // V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_PPC64 |
| 337 // || V8_TARGET_ARCH_PPC || V8_TARGET_ARCH_S390 || V8_TARGET_ARCH_S390X | 337 // || V8_TARGET_ARCH_PPC || V8_TARGET_ARCH_S390 || V8_TARGET_ARCH_S390X |
| 338 } | 338 } |
| 339 | 339 |
| 340 TF_BUILTIN(AtomicsCompareExchange, SharedArrayBufferBuiltinsAssembler) { | |
| 341 Node* array = Parameter(1); | |
| 342 Node* index = Parameter(2); | |
| 343 Node* old_value = Parameter(3); | |
| 344 Node* new_value = Parameter(4); | |
| 345 Node* context = Parameter(5 + 2); | |
| 346 | |
| 347 Node* instance_type; | |
| 348 Node* backing_store; | |
| 349 ValidateSharedTypedArray(array, context, &instance_type, &backing_store); | |
| 350 | |
| 351 Node* index_integer; | |
| 352 Node* index_word32 = | |
| 353 ConvertTaggedAtomicIndexToWord32(index, context, &index_integer); | |
| 354 Node* array_length_word32 = TruncateTaggedToWord32( | |
| 355 context, LoadObjectField(array, JSTypedArray::kLengthOffset)); | |
| 356 ValidateAtomicIndex(index_word32, array_length_word32, context); | |
| 357 | |
| 358 Node* old_value_integer = ToInteger(context, old_value); | |
| 359 | |
| 360 Node* new_value_integer = ToInteger(context, new_value); | |
| 361 | |
| 362 #if V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_PPC64 || \ | |
| 363 V8_TARGET_ARCH_PPC || V8_TARGET_ARCH_S390 || V8_TARGET_ARCH_S390X | |
| 364 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.
| |
| 365 index_integer, old_value_integer, new_value_integer)); | |
| 366 #else | |
| 367 Node* index_word = ChangeUint32ToWord(index_word32); | |
| 368 | |
| 369 Node* old_value_word32 = TruncateTaggedToWord32(context, old_value_integer); | |
| 370 | |
| 371 Node* new_value_word32 = TruncateTaggedToWord32(context, new_value_integer); | |
| 372 | |
| 373 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.
| |
| 374 u32(this), other(this); | |
| 375 int32_t case_values[] = { | |
| 376 FIXED_INT8_ARRAY_TYPE, FIXED_UINT8_ARRAY_TYPE, FIXED_INT16_ARRAY_TYPE, | |
| 377 FIXED_UINT16_ARRAY_TYPE, FIXED_INT32_ARRAY_TYPE, FIXED_UINT32_ARRAY_TYPE, | |
| 378 }; | |
| 379 CodeStubAssembler::Label* case_labels[] = { | |
|
Jakob Kummerow
2017/03/10 21:05:39
s/CodeStubAssembler:://
aseemgarg
2017/03/10 21:09:54
Done.
| |
| 380 &i8, &u8, &i16, &u16, &i32, &u32, | |
| 381 }; | |
| 382 Switch(instance_type, &other, case_values, case_labels, | |
| 383 arraysize(case_labels)); | |
| 384 | |
| 385 Bind(&i8); | |
| 386 Return(SmiFromWord32(AtomicCompareExchange(MachineType::Int8(), backing_store, | |
| 387 index_word, old_value_word32, | |
| 388 new_value_word32))); | |
| 389 | |
| 390 Bind(&u8); | |
| 391 Return(SmiFromWord32( | |
| 392 AtomicCompareExchange(MachineType::Uint8(), backing_store, index_word, | |
| 393 old_value_word32, new_value_word32))); | |
| 394 | |
| 395 Bind(&i16); | |
| 396 Return(SmiFromWord32(AtomicCompareExchange( | |
| 397 MachineType::Int16(), backing_store, WordShl(index_word, 1), | |
| 398 old_value_word32, new_value_word32))); | |
| 399 | |
| 400 Bind(&u16); | |
| 401 Return(SmiFromWord32(AtomicCompareExchange( | |
| 402 MachineType::Uint16(), backing_store, WordShl(index_word, 1), | |
| 403 old_value_word32, new_value_word32))); | |
| 404 | |
| 405 Bind(&i32); | |
| 406 Return(ChangeInt32ToTagged(AtomicCompareExchange( | |
| 407 MachineType::Int32(), backing_store, WordShl(index_word, 2), | |
| 408 old_value_word32, new_value_word32))); | |
| 409 | |
| 410 Bind(&u32); | |
| 411 Return(ChangeUint32ToTagged(AtomicCompareExchange( | |
| 412 MachineType::Uint32(), backing_store, WordShl(index_word, 2), | |
| 413 old_value_word32, new_value_word32))); | |
| 414 | |
| 415 // This shouldn't happen, we've already validated the type. | |
| 416 Bind(&other); | |
| 417 Unreachable(); | |
| 418 #endif // V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_PPC64 | |
| 419 // || V8_TARGET_ARCH_PPC || V8_TARGET_ARCH_S390 || V8_TARGET_ARCH_S390X | |
| 420 } | |
| 421 | |
| 340 } // namespace internal | 422 } // namespace internal |
| 341 } // namespace v8 | 423 } // namespace v8 |
| OLD | NEW |