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

Side by Side Diff: src/ia32/code-stubs-ia32.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
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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_IA32 5 #if V8_TARGET_ARCH_IA32
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/base/bits.h" 9 #include "src/base/bits.h"
10 #include "src/bootstrapper.h" 10 #include "src/bootstrapper.h"
(...skipping 5884 matching lines...) Expand 10 before | Expand all | Expand 10 after
5895 __ dd(i32); // Int32Array 5895 __ dd(i32); // Int32Array
5896 __ dd(u32); // Uint32Array 5896 __ dd(u32); // Uint32Array
5897 __ dd(&abort); // Float32Array 5897 __ dd(&abort); // Float32Array
5898 __ dd(&abort); // Float64Array 5898 __ dd(&abort); // Float64Array
5899 __ dd(u8c); // Uint8ClampedArray 5899 __ dd(u8c); // Uint8ClampedArray
5900 5900
5901 __ bind(&abort); 5901 __ bind(&abort);
5902 __ Abort(kNoReason); 5902 __ Abort(kNoReason);
5903 } 5903 }
5904 5904
5905 void ReturnInteger32(MacroAssembler* masm, XMMRegister dst, Register value,
5906 Register scratch, Label* use_heap_number) {
5907 Label not_smi;
5908 if (!value.is(eax)) {
5909 __ mov(eax, value);
5910 }
5911 __ JumpIfNotValidSmiValue(eax, scratch, &not_smi, Label::kNear);
5912 __ SmiTag(eax);
5913 __ Ret();
5914
5915 __ bind(&not_smi);
5916 __ Cvtsi2sd(dst, eax);
5917 __ jmp(use_heap_number);
5918 }
5919
5920 void ReturnUnsignedInteger32(MacroAssembler* masm, XMMRegister dst,
5921 Register value, XMMRegister scratch,
5922 Label* use_heap_number) {
5923 Label not_smi;
5924 if (!value.is(eax)) {
5925 __ mov(eax, value);
5926 }
5927 __ JumpIfUIntNotValidSmiValue(eax, &not_smi, Label::kNear);
5928 __ SmiTag(eax);
5929 __ Ret();
5930
5931 __ bind(&not_smi);
5932 // Convert [0, 2**32-1] -> [-2**31, 2**31-1].
5933 __ add(eax, Immediate(-0x7fffffff - 1)); // -0x80000000 parses incorrectly.
5934 __ Cvtsi2sd(dst, eax);
5935 __ mov(eax, Immediate(0x4f000000)); // 2**31 as IEEE float
5936 __ movd(scratch, eax);
5937 __ cvtss2sd(scratch, scratch);
5938 __ addsd(dst, scratch);
5939 __ jmp(use_heap_number);
5940 }
5941
5942 void ReturnAllocatedHeapNumber(MacroAssembler* masm, XMMRegister value,
5943 Register scratch, Register scratch2) {
5944 Label call_runtime;
5945 __ AllocateHeapNumber(eax, scratch, scratch2, &call_runtime);
5946 __ movsd(FieldOperand(eax, HeapNumber::kValueOffset), value);
5947 __ Ret();
5948
5949 __ bind(&call_runtime);
5950 {
5951 FrameScope scope(masm, StackFrame::INTERNAL);
5952 __ CallRuntimeSaveDoubles(Runtime::kAllocateHeapNumber);
5953 __ movsd(FieldOperand(eax, HeapNumber::kValueOffset), value);
5954 }
5955 __ Ret();
5956 }
5957
5958 } // anonymous namespace 5905 } // anonymous namespace
5959 5906
5960 void AtomicsLoadStub::Generate(MacroAssembler* masm) { 5907 void AtomicsLoadStub::Generate(MacroAssembler* masm) {
5961 Register object = edx; 5908 Register object = edx;
5962 Register index = eax; // Index is an untagged word32. 5909 Register index = eax; // Index is an untagged word32.
5963 Register backing_store = ebx; 5910 Register backing_store = ebx;
5964 Label table; 5911 Label table;
5965 5912
5966 GetTypedArrayBackingStore(masm, backing_store, object, ecx); 5913 GetTypedArrayBackingStore(masm, backing_store, object, ecx);
5967 TypedArrayJumpTablePrologue(masm, object, ecx, esi, &table); 5914 TypedArrayJumpTablePrologue(masm, object, ecx, esi, &table);
5968 5915
5969 Label i8, u8, i16, u16, i32, u32; 5916 Label i8, u8, i16, u16, i32, u32;
5970 5917
5971 __ bind(&i8); 5918 __ bind(&i8);
5972 __ mov_b(eax, Operand(backing_store, index, times_1, 0)); 5919 __ mov_b(eax, Operand(backing_store, index, times_1, 0));
5973 __ movsx_b(eax, eax); 5920 __ movsx_b(eax, eax);
5974 __ SmiTag(eax);
5975 __ Ret(); 5921 __ Ret();
5976 5922
5977 __ bind(&u8); 5923 __ bind(&u8);
5978 __ mov_b(eax, Operand(backing_store, index, times_1, 0)); 5924 __ mov_b(eax, Operand(backing_store, index, times_1, 0));
5979 __ movzx_b(eax, eax); 5925 __ movzx_b(eax, eax);
5980 __ SmiTag(eax);
5981 __ Ret(); 5926 __ Ret();
5982 5927
5983 __ bind(&i16); 5928 __ bind(&i16);
5984 __ mov_w(eax, Operand(backing_store, index, times_2, 0)); 5929 __ mov_w(eax, Operand(backing_store, index, times_2, 0));
5985 __ movsx_w(eax, eax); 5930 __ movsx_w(eax, eax);
5986 __ SmiTag(eax);
5987 __ Ret(); 5931 __ Ret();
5988 5932
5989 __ bind(&u16); 5933 __ bind(&u16);
5990 __ mov_w(eax, Operand(backing_store, index, times_2, 0)); 5934 __ mov_w(eax, Operand(backing_store, index, times_2, 0));
5991 __ movzx_w(eax, eax); 5935 __ movzx_w(eax, eax);
5992 __ SmiTag(eax);
5993 __ Ret(); 5936 __ Ret();
5994 5937
5995 Label use_heap_number;
5996
5997 __ bind(&i32); 5938 __ bind(&i32);
5998 __ mov(eax, Operand(backing_store, index, times_4, 0)); 5939 __ mov(eax, Operand(backing_store, index, times_4, 0));
5999 ReturnInteger32(masm, xmm0, eax, ecx, &use_heap_number); 5940 __ Ret();
6000 5941
6001 __ bind(&u32); 5942 __ bind(&u32);
6002 __ mov(eax, Operand(backing_store, index, times_4, 0)); 5943 __ mov(eax, Operand(backing_store, index, times_4, 0));
6003 ReturnUnsignedInteger32(masm, xmm0, eax, xmm1, &use_heap_number); 5944 __ Ret();
6004
6005 __ bind(&use_heap_number);
6006 ReturnAllocatedHeapNumber(masm, xmm0, ecx, edx);
6007 5945
6008 TypedArrayJumpTableEpilogue(masm, &table, &i8, &u8, &i16, &u16, &i32, &u32, 5946 TypedArrayJumpTableEpilogue(masm, &table, &i8, &u8, &i16, &u16, &i32, &u32,
6009 &u8); 5947 &u8);
6010 } 5948 }
6011 5949
6012 #undef __ 5950 #undef __
6013 5951
6014 } // namespace internal 5952 } // namespace internal
6015 } // namespace v8 5953 } // namespace v8
6016 5954
6017 #endif // V8_TARGET_ARCH_IA32 5955 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« src/builtins.cc ('K') | « src/builtins.cc ('k') | src/x64/code-stubs-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698