Chromium Code Reviews

Side by Side Diff: src/builtins/builtins-sharedarraybuffer.cc

Issue 2649703002: [Atomics] Make Atomics.compareExchange a builtin using TF (Closed)
Patch Set: PPC and S390 Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
« no previous file with comments | « src/builtins/builtins.h ('k') | src/compiler/arm/code-generator-arm.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 275 matching lines...)
286 Node* index_word32 = 286 Node* index_word32 =
287 ConvertTaggedAtomicIndexToWord32(&a, index, context, &index_integer); 287 ConvertTaggedAtomicIndexToWord32(&a, index, context, &index_integer);
288 Node* array_length_word32 = a.TruncateTaggedToWord32( 288 Node* array_length_word32 = a.TruncateTaggedToWord32(
289 context, a.LoadObjectField(array, JSTypedArray::kLengthOffset)); 289 context, a.LoadObjectField(array, JSTypedArray::kLengthOffset));
290 ValidateAtomicIndex(&a, index_word32, array_length_word32, context); 290 ValidateAtomicIndex(&a, index_word32, array_length_word32, context);
291 291
292 Node* value_integer = a.ToInteger(context, value); 292 Node* value_integer = a.ToInteger(context, value);
293 293
294 #if V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_PPC64 || \ 294 #if V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_PPC64 || \
295 V8_TARGET_ARCH_PPC || V8_TARGET_ARCH_S390 || V8_TARGET_ARCH_S390X 295 V8_TARGET_ARCH_PPC || V8_TARGET_ARCH_S390 || V8_TARGET_ARCH_S390X
296 // Node* index_integer = a.ToInteger(context, index);
297 a.Return(a.CallRuntime(Runtime::kAtomicsExchange, context, array, 296 a.Return(a.CallRuntime(Runtime::kAtomicsExchange, context, array,
298 index_integer, value_integer)); 297 index_integer, value_integer));
299 #else 298 #else
300 Node* index_word = a.ChangeUint32ToWord(index_word32); 299 Node* index_word = a.ChangeUint32ToWord(index_word32);
301 300
302 Node* value_word32 = a.TruncateTaggedToWord32(context, value_integer); 301 Node* value_word32 = a.TruncateTaggedToWord32(context, value_integer);
303 302
304 CodeStubAssembler::Label i8(&a), u8(&a), i16(&a), u16(&a), i32(&a), u32(&a), 303 CodeStubAssembler::Label i8(&a), u8(&a), i16(&a), u16(&a), i32(&a), u32(&a),
305 other(&a); 304 other(&a);
306 int32_t case_values[] = { 305 int32_t case_values[] = {
(...skipping 34 matching lines...)
341 a.AtomicExchange(MachineType::Uint32(), backing_store, 340 a.AtomicExchange(MachineType::Uint32(), backing_store,
342 a.WordShl(index_word, 2), value_word32))); 341 a.WordShl(index_word, 2), value_word32)));
343 342
344 // This shouldn't happen, we've already validated the type. 343 // This shouldn't happen, we've already validated the type.
345 a.Bind(&other); 344 a.Bind(&other);
346 a.Return(a.SmiConstant(0)); 345 a.Return(a.SmiConstant(0));
347 #endif // V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_PPC64 346 #endif // V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_PPC64
348 // || V8_TARGET_ARCH_PPC || V8_TARGET_ARCH_S390 || V8_TARGET_ARCH_S390X 347 // || V8_TARGET_ARCH_PPC || V8_TARGET_ARCH_S390 || V8_TARGET_ARCH_S390X
349 } 348 }
350 349
350 void Builtins::Generate_AtomicsCompareExchange(
Jakob Kummerow 2017/03/09 13:43:42 please use the TF_BUILTIN macro to drop a bunch of
aseemgarg 2017/03/10 19:55:22 Done.
351 compiler::CodeAssemblerState* state) {
352 using compiler::Node;
353 CodeStubAssembler a(state);
354 Node* array = a.Parameter(1);
355 Node* index = a.Parameter(2);
356 Node* old_value = a.Parameter(3);
357 Node* new_value = a.Parameter(4);
358 Node* context = a.Parameter(5 + 2);
359
360 Node* instance_type;
361 Node* backing_store;
362 ValidateSharedTypedArray(&a, array, context, &instance_type, &backing_store);
363
364 Node* index_integer;
365 Node* index_word32 =
366 ConvertTaggedAtomicIndexToWord32(&a, index, context, &index_integer);
367 Node* array_length_word32 = a.TruncateTaggedToWord32(
368 context, a.LoadObjectField(array, JSTypedArray::kLengthOffset));
369 ValidateAtomicIndex(&a, index_word32, array_length_word32, context);
370
371 Node* old_value_integer = a.ToInteger(context, old_value);
372
373 Node* new_value_integer = a.ToInteger(context, new_value);
374
375 #if V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_PPC64 || \
376 V8_TARGET_ARCH_PPC || V8_TARGET_ARCH_S390 || V8_TARGET_ARCH_S390X
377 a.Return(a.CallRuntime(Runtime::kAtomicsCompareExchange, context, array,
378 index_integer, old_value_integer, new_value_integer));
379 #else
380 Node* index_word = a.ChangeUint32ToWord(index_word32);
381
382 Node* old_value_word32 = a.TruncateTaggedToWord32(context, old_value_integer);
383
384 Node* new_value_word32 = a.TruncateTaggedToWord32(context, new_value_integer);
385
386 CodeStubAssembler::Label i8(&a), u8(&a), i16(&a), u16(&a), i32(&a), u32(&a),
387 other(&a);
388 int32_t case_values[] = {
389 FIXED_INT8_ARRAY_TYPE, FIXED_UINT8_ARRAY_TYPE, FIXED_INT16_ARRAY_TYPE,
390 FIXED_UINT16_ARRAY_TYPE, FIXED_INT32_ARRAY_TYPE, FIXED_UINT32_ARRAY_TYPE,
391 };
392 CodeStubAssembler::Label* case_labels[] = {
393 &i8, &u8, &i16, &u16, &i32, &u32,
394 };
395 a.Switch(instance_type, &other, case_values, case_labels,
396 arraysize(case_labels));
397
398 a.Bind(&i8);
399 a.Return(a.SmiFromWord32(
400 a.AtomicCompareExchange(MachineType::Int8(), backing_store, index_word,
401 old_value_word32, new_value_word32)));
402
403 a.Bind(&u8);
404 a.Return(a.SmiFromWord32(
405 a.AtomicCompareExchange(MachineType::Uint8(), backing_store, index_word,
406 old_value_word32, new_value_word32)));
407
408 a.Bind(&i16);
409 a.Return(a.SmiFromWord32(a.AtomicCompareExchange(
410 MachineType::Int16(), backing_store, a.WordShl(index_word, 1),
411 old_value_word32, new_value_word32)));
412
413 a.Bind(&u16);
414 a.Return(a.SmiFromWord32(a.AtomicCompareExchange(
415 MachineType::Uint16(), backing_store, a.WordShl(index_word, 1),
416 old_value_word32, new_value_word32)));
417
418 a.Bind(&i32);
419 a.Return(a.ChangeInt32ToTagged(a.AtomicCompareExchange(
420 MachineType::Int32(), backing_store, a.WordShl(index_word, 2),
421 old_value_word32, new_value_word32)));
422
423 a.Bind(&u32);
424 a.Return(a.ChangeUint32ToTagged(a.AtomicCompareExchange(
425 MachineType::Uint32(), backing_store, a.WordShl(index_word, 2),
426 old_value_word32, new_value_word32)));
427
428 // This shouldn't happen, we've already validated the type.
429 a.Bind(&other);
430 a.Return(a.SmiConstant(0));
Jakob Kummerow 2017/03/09 13:43:42 how about "Unreachable();" instead?
aseemgarg 2017/03/10 19:55:22 Done.
431 #endif // V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_PPC64
432 // || V8_TARGET_ARCH_PPC || V8_TARGET_ARCH_S390 || V8_TARGET_ARCH_S390X
433 }
434
351 } // namespace internal 435 } // namespace internal
352 } // namespace v8 436 } // namespace v8
OLDNEW
« no previous file with comments | « src/builtins/builtins.h ('k') | src/compiler/arm/code-generator-arm.cc » ('j') | no next file with comments »

Powered by Google App Engine