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

Side by Side Diff: src/x64/code-stubs-x64.cc

Issue 1883903002: [Atomics] Handle conversion to SMI in builtin, not code stub. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: properly handle signed vs. unsigned Created 4 years, 8 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
« src/builtins.cc ('K') | « src/ia32/code-stubs-ia32.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 #if V8_TARGET_ARCH_X64 5 #if V8_TARGET_ARCH_X64
6 6
7 #include "src/code-stubs.h" 7 #include "src/code-stubs.h"
8 #include "src/api-arguments.h" 8 #include "src/api-arguments.h"
9 #include "src/bootstrapper.h" 9 #include "src/bootstrapper.h"
10 #include "src/codegen.h" 10 #include "src/codegen.h"
(...skipping 5610 matching lines...) Expand 10 before | Expand all | Expand 10 after
5621 __ dq(i32); // Int32Array 5621 __ dq(i32); // Int32Array
5622 __ dq(u32); // Uint32Array 5622 __ dq(u32); // Uint32Array
5623 __ dq(&abort); // Float32Array 5623 __ dq(&abort); // Float32Array
5624 __ dq(&abort); // Float64Array 5624 __ dq(&abort); // Float64Array
5625 __ dq(u8c); // Uint8ClampedArray 5625 __ dq(u8c); // Uint8ClampedArray
5626 5626
5627 __ bind(&abort); 5627 __ bind(&abort);
5628 __ Abort(kNoReason); 5628 __ Abort(kNoReason);
5629 } 5629 }
5630 5630
5631 void ReturnInteger32(MacroAssembler* masm, XMMRegister dst, Register value,
5632 Label* use_heap_number) {
5633 Label not_smi;
5634 if (!value.is(rax)) {
5635 __ movp(rax, value);
5636 }
5637 __ JumpIfNotValidSmiValue(rax, &not_smi, Label::kNear);
5638 __ Integer32ToSmi(rax, rax);
5639 __ Ret();
5640
5641 __ bind(&not_smi);
5642 __ Cvtlsi2sd(dst, rax);
5643 __ jmp(use_heap_number);
5644 }
5645
5646 void ReturnUnsignedInteger32(MacroAssembler* masm, XMMRegister dst,
5647 Register value, Label* use_heap_number) {
5648 Label not_smi;
5649 if (!value.is(rax)) {
5650 __ movp(rax, value);
5651 }
5652 __ JumpIfUIntNotValidSmiValue(rax, &not_smi, Label::kNear);
5653 __ Integer32ToSmi(rax, rax);
5654 __ Ret();
5655
5656 __ bind(&not_smi);
5657 __ Cvtqsi2sd(dst, rax);
5658 __ jmp(use_heap_number);
5659 }
5660
5661 void ReturnAllocatedHeapNumber(MacroAssembler* masm, XMMRegister value,
5662 Register scratch) {
5663 Label call_runtime;
5664 __ AllocateHeapNumber(rax, scratch, &call_runtime);
5665 __ Movsd(FieldOperand(rax, HeapNumber::kValueOffset), value);
5666 __ Ret();
5667
5668 __ bind(&call_runtime);
5669 {
5670 FrameScope scope(masm, StackFrame::INTERNAL);
5671 __ CallRuntimeSaveDoubles(Runtime::kAllocateHeapNumber);
5672 __ Movsd(FieldOperand(rax, HeapNumber::kValueOffset), value);
5673 }
5674 __ Ret();
5675 }
5676
5677 } // anonymous namespace 5631 } // anonymous namespace
5678 5632
5679 void AtomicsLoadStub::Generate(MacroAssembler* masm) { 5633 void AtomicsLoadStub::Generate(MacroAssembler* masm) {
5680 Register object = rdx; 5634 Register object = rdx;
5681 Register index = rax; // Index is an untagged word32. 5635 Register index = rax; // Index is an untagged word32.
5682 Register backing_store = rbx; 5636 Register backing_store = rbx;
5683 Label table; 5637 Label table;
5684 5638
5685 GetTypedArrayBackingStore(masm, backing_store, object, kScratchRegister); 5639 GetTypedArrayBackingStore(masm, backing_store, object, kScratchRegister);
5686 TypedArrayJumpTablePrologue(masm, object, rcx, kScratchRegister, &table); 5640 TypedArrayJumpTablePrologue(masm, object, rcx, kScratchRegister, &table);
5687 5641
5688 Label i8, u8, i16, u16, i32, u32; 5642 Label i8, u8, i16, u16, i32, u32;
5689 5643
5690 __ bind(&i8); 5644 __ bind(&i8);
5691 __ movb(rax, Operand(backing_store, index, times_1, 0)); 5645 __ movb(rax, Operand(backing_store, index, times_1, 0));
5692 __ movsxbl(rax, rax); 5646 __ movsxbl(rax, rax);
5693 __ Integer32ToSmi(rax, rax);
5694 __ Ret(); 5647 __ Ret();
5695 5648
5696 __ bind(&u8); 5649 __ bind(&u8);
5697 __ movb(rax, Operand(backing_store, index, times_1, 0)); 5650 __ movb(rax, Operand(backing_store, index, times_1, 0));
5698 __ movzxbl(rax, rax); 5651 __ movzxbl(rax, rax);
5699 __ Integer32ToSmi(rax, rax);
5700 __ Ret(); 5652 __ Ret();
5701 5653
5702 __ bind(&i16); 5654 __ bind(&i16);
5703 __ movw(rax, Operand(backing_store, index, times_2, 0)); 5655 __ movw(rax, Operand(backing_store, index, times_2, 0));
5704 __ movsxwl(rax, rax); 5656 __ movsxwl(rax, rax);
5705 __ Integer32ToSmi(rax, rax);
5706 __ Ret(); 5657 __ Ret();
5707 5658
5708 __ bind(&u16); 5659 __ bind(&u16);
5709 __ movw(rax, Operand(backing_store, index, times_2, 0)); 5660 __ movw(rax, Operand(backing_store, index, times_2, 0));
5710 __ movzxwl(rax, rax); 5661 __ movzxwl(rax, rax);
5711 __ Integer32ToSmi(rax, rax);
5712 __ Ret(); 5662 __ Ret();
5713 5663
5714 Label use_heap_number;
5715
5716 __ bind(&i32); 5664 __ bind(&i32);
5717 __ movl(rax, Operand(backing_store, index, times_4, 0)); 5665 __ movl(rax, Operand(backing_store, index, times_4, 0));
5718 ReturnInteger32(masm, xmm0, rax, &use_heap_number); 5666 __ Ret();
5719 5667
5720 __ bind(&u32); 5668 __ bind(&u32);
5721 __ movl(rax, Operand(backing_store, index, times_4, 0)); 5669 __ movl(rax, Operand(backing_store, index, times_4, 0));
5722 ReturnUnsignedInteger32(masm, xmm0, rax, &use_heap_number); 5670 __ Ret();
5723
5724 __ bind(&use_heap_number);
5725 ReturnAllocatedHeapNumber(masm, xmm0, rcx);
5726 5671
5727 TypedArrayJumpTableEpilogue(masm, &table, &i8, &u8, &i16, &u16, &i32, &u32, 5672 TypedArrayJumpTableEpilogue(masm, &table, &i8, &u8, &i16, &u16, &i32, &u32,
5728 &u8); 5673 &u8);
5729 } 5674 }
5730 5675
5731 #undef __ 5676 #undef __
5732 5677
5733 } // namespace internal 5678 } // namespace internal
5734 } // namespace v8 5679 } // namespace v8
5735 5680
5736 #endif // V8_TARGET_ARCH_X64 5681 #endif // V8_TARGET_ARCH_X64
OLDNEW
« src/builtins.cc ('K') | « src/ia32/code-stubs-ia32.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698