Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(562)

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

Issue 2649703002: [Atomics] Make Atomics.compareExchange a builtin using TF (Closed)
Patch Set: rebase and move cmpxchg to builtins-sharedarraybuffer-gen.cc Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2017 the V8 project authors. All rights reserved. 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 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-gen.h" 5 #include "src/builtins/builtins-utils-gen.h"
6 #include "src/builtins/builtins.h" 6 #include "src/builtins/builtins.h"
7 #include "src/code-stub-assembler.h" 7 #include "src/code-stub-assembler.h"
8 #include "src/objects.h" 8 #include "src/objects.h"
9 9
10 namespace v8 { 10 namespace v8 {
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 312
313 Bind(&u32); 313 Bind(&u32);
314 Return(ChangeUint32ToTagged( 314 Return(ChangeUint32ToTagged(
315 AtomicExchange(MachineType::Uint32(), backing_store, 315 AtomicExchange(MachineType::Uint32(), backing_store,
316 WordShl(index_word, 2), value_word32))); 316 WordShl(index_word, 2), value_word32)));
317 317
318 // This shouldn't happen, we've already validated the type. 318 // This shouldn't happen, we've already validated the type.
319 Bind(&other); 319 Bind(&other);
320 Unreachable(); 320 Unreachable();
321 #endif // V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_PPC64 321 #endif // V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_PPC64
322 // || V8_TARGET_ARCH_PPC
323 }
324
325 TF_BUILTIN(AtomicsCompareExchange, SharedArrayBufferBuiltinsAssembler) {
326 Node* array = Parameter(1);
327 Node* index = Parameter(2);
328 Node* old_value = Parameter(3);
329 Node* new_value = Parameter(4);
330 Node* context = Parameter(5 + 2);
331
332 Node* instance_type;
333 Node* backing_store;
334 ValidateSharedTypedArray(array, context, &instance_type, &backing_store);
335
336 Node* index_integer;
337 Node* index_word32 =
338 ConvertTaggedAtomicIndexToWord32(index, context, &index_integer);
339 Node* array_length_word32 = TruncateTaggedToWord32(
340 context, LoadObjectField(array, JSTypedArray::kLengthOffset));
341 ValidateAtomicIndex(index_word32, array_length_word32, context);
342
343 Node* old_value_integer = ToInteger(context, old_value);
344
345 Node* new_value_integer = ToInteger(context, new_value);
346
347 #if 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
349 Return(CallRuntime(Runtime::kAtomicsCompareExchange, context, array,
350 index_integer, old_value_integer, new_value_integer));
351 #else
352 Node* index_word = ChangeUint32ToWord(index_word32);
353
354 Node* old_value_word32 = TruncateTaggedToWord32(context, old_value_integer);
355
356 Node* new_value_word32 = TruncateTaggedToWord32(context, new_value_integer);
357
358 Label i8(this), u8(this), i16(this), u16(this), i32(this), u32(this),
359 other(this);
360 int32_t case_values[] = {
361 FIXED_INT8_ARRAY_TYPE, FIXED_UINT8_ARRAY_TYPE, FIXED_INT16_ARRAY_TYPE,
362 FIXED_UINT16_ARRAY_TYPE, FIXED_INT32_ARRAY_TYPE, FIXED_UINT32_ARRAY_TYPE,
363 };
364 Label* case_labels[] = {
365 &i8, &u8, &i16, &u16, &i32, &u32,
366 };
367 Switch(instance_type, &other, case_values, case_labels,
368 arraysize(case_labels));
369
370 Bind(&i8);
371 Return(SmiFromWord32(AtomicCompareExchange(MachineType::Int8(), backing_store,
372 index_word, old_value_word32,
373 new_value_word32)));
374
375 Bind(&u8);
376 Return(SmiFromWord32(
377 AtomicCompareExchange(MachineType::Uint8(), backing_store, index_word,
378 old_value_word32, new_value_word32)));
379
380 Bind(&i16);
381 Return(SmiFromWord32(AtomicCompareExchange(
382 MachineType::Int16(), backing_store, WordShl(index_word, 1),
383 old_value_word32, new_value_word32)));
384
385 Bind(&u16);
386 Return(SmiFromWord32(AtomicCompareExchange(
387 MachineType::Uint16(), backing_store, WordShl(index_word, 1),
388 old_value_word32, new_value_word32)));
389
390 Bind(&i32);
391 Return(ChangeInt32ToTagged(AtomicCompareExchange(
392 MachineType::Int32(), backing_store, WordShl(index_word, 2),
393 old_value_word32, new_value_word32)));
394
395 Bind(&u32);
396 Return(ChangeUint32ToTagged(AtomicCompareExchange(
397 MachineType::Uint32(), backing_store, WordShl(index_word, 2),
398 old_value_word32, new_value_word32)));
399
400 // This shouldn't happen, we've already validated the type.
401 Bind(&other);
402 Unreachable();
403 #endif // V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_PPC64
322 // || V8_TARGET_ARCH_PPC || V8_TARGET_ARCH_S390 || V8_TARGET_ARCH_S390X 404 // || V8_TARGET_ARCH_PPC || V8_TARGET_ARCH_S390 || V8_TARGET_ARCH_S390X
323 } 405 }
324 406
325 } // namespace internal 407 } // namespace internal
326 } // namespace v8 408 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698