OLD | NEW |
---|---|
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_ARM64 | 5 #if V8_TARGET_ARCH_ARM64 |
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 5921 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5932 | 5932 |
5933 const int spill_offset = 1 + kApiStackSpace; | 5933 const int spill_offset = 1 + kApiStackSpace; |
5934 // +3 is to skip prolog, return address and name handle. | 5934 // +3 is to skip prolog, return address and name handle. |
5935 MemOperand return_value_operand( | 5935 MemOperand return_value_operand( |
5936 fp, (PropertyCallbackArguments::kReturnValueOffset + 3) * kPointerSize); | 5936 fp, (PropertyCallbackArguments::kReturnValueOffset + 3) * kPointerSize); |
5937 CallApiFunctionAndReturn(masm, api_function_address, thunk_ref, | 5937 CallApiFunctionAndReturn(masm, api_function_address, thunk_ref, |
5938 kStackUnwindSpace, NULL, spill_offset, | 5938 kStackUnwindSpace, NULL, spill_offset, |
5939 return_value_operand, NULL); | 5939 return_value_operand, NULL); |
5940 } | 5940 } |
5941 | 5941 |
5942 namespace { | |
5943 | |
5944 void GetTypedArrayBackingStore(MacroAssembler* masm, Register backing_store, | |
5945 Register object, Register scratch, | |
5946 FPRegister double_scratch) { | |
5947 Label offset_is_not_smi, done; | |
5948 __ ldr(scratch, FieldMemOperand(object, JSTypedArray::kBufferOffset)); | |
Rodolph Perfetta
2016/04/07 14:13:50
on arm64 the convention is to use the macro assemb
binji
2016/04/08 18:21:42
Done.
| |
5949 __ ldr(backing_store, | |
5950 FieldMemOperand(scratch, JSArrayBuffer::kBackingStoreOffset)); | |
5951 __ ldr(scratch, | |
5952 FieldMemOperand(object, JSArrayBufferView::kByteOffsetOffset)); | |
5953 __ JumpIfNotSmi(scratch, &offset_is_not_smi); | |
5954 // offset is smi | |
5955 __ SmiUntag(scratch); | |
Rodolph Perfetta
2016/04/07 14:13:50
you can combine this with the line below:
__ Ad
binji
2016/04/08 18:21:42
Done.
| |
5956 __ add(backing_store, backing_store, scratch); | |
5957 __ jmp(&done); | |
5958 | |
5959 // offset is a heap number | |
5960 __ bind(&offset_is_not_smi); | |
5961 __ Ldr(double_scratch, FieldMemOperand(scratch, HeapNumber::kValueOffset)); | |
5962 __ Fcvtzu(scratch, double_scratch); | |
5963 __ add(backing_store, backing_store, scratch); | |
5964 __ bind(&done); | |
5965 } | |
5966 | |
5967 void TypedArrayJumpTable(MacroAssembler* masm, Register object, | |
5968 Register scratch, Register scratch2, Label* i8, | |
5969 Label* u8, Label* i16, Label* u16, Label* i32, | |
5970 Label* u32, Label* u8c) { | |
5971 STATIC_ASSERT(FIXED_UINT8_ARRAY_TYPE == FIXED_INT8_ARRAY_TYPE + 1); | |
5972 STATIC_ASSERT(FIXED_INT16_ARRAY_TYPE == FIXED_INT8_ARRAY_TYPE + 2); | |
5973 STATIC_ASSERT(FIXED_UINT16_ARRAY_TYPE == FIXED_INT8_ARRAY_TYPE + 3); | |
5974 STATIC_ASSERT(FIXED_INT32_ARRAY_TYPE == FIXED_INT8_ARRAY_TYPE + 4); | |
5975 STATIC_ASSERT(FIXED_UINT32_ARRAY_TYPE == FIXED_INT8_ARRAY_TYPE + 5); | |
5976 STATIC_ASSERT(FIXED_FLOAT32_ARRAY_TYPE == FIXED_INT8_ARRAY_TYPE + 6); | |
5977 STATIC_ASSERT(FIXED_FLOAT64_ARRAY_TYPE == FIXED_INT8_ARRAY_TYPE + 7); | |
5978 STATIC_ASSERT(FIXED_UINT8_CLAMPED_ARRAY_TYPE == FIXED_INT8_ARRAY_TYPE + 8); | |
5979 | |
5980 __ ldr(scratch, FieldMemOperand(object, JSObject::kElementsOffset)); | |
5981 __ ldr(scratch, FieldMemOperand(scratch, HeapObject::kMapOffset)); | |
5982 __ ldrb(scratch, FieldMemOperand(scratch, Map::kInstanceTypeOffset)); | |
5983 __ Mov(scratch2, static_cast<uint8_t>(FIXED_INT8_ARRAY_TYPE)); | |
Rodolph Perfetta
2016/04/07 14:13:50
this can be merged in the sub below
binji
2016/04/08 18:21:42
Done.
| |
5984 __ subs(scratch, scratch, Operand(scratch2)); | |
5985 __ Assert(ge, kOffsetOutOfRange); | |
5986 | |
5987 Label abort; | |
5988 Label table; | |
5989 | |
5990 __ Mov(scratch2, scratch); | |
Rodolph Perfetta
2016/04/07 14:13:50
You don't need this, below simply adr into scratch
binji
2016/04/08 18:21:42
Done.
| |
5991 __ Adr(scratch, &table); | |
5992 __ Add(scratch, scratch, Operand(scratch2, UXTW, 2)); | |
5993 __ Br(scratch); | |
5994 | |
5995 __ StartBlockPools(); | |
5996 __ Bind(&table); | |
5997 __ b(i8); // Int8Array | |
5998 __ b(u8); // Uint8Array | |
5999 __ b(i16); // Int16Array | |
6000 __ b(u16); // Uint16Array | |
6001 __ b(i32); // Int32Array | |
6002 __ b(u32); // Uint32Array | |
6003 __ b(&abort); // Float32Array | |
6004 __ b(&abort); // Float64Array | |
6005 __ b(u8c); // Uint8ClampedArray | |
6006 __ EndBlockPools(); | |
6007 | |
6008 __ bind(&abort); | |
6009 __ Abort(kNoReason); | |
6010 } | |
6011 | |
6012 void ReturnUnsignedInteger32(MacroAssembler* masm, FPRegister dst, | |
6013 Register value, Register scratch, | |
6014 Register scratch2, Register scratch3) { | |
6015 Label not_smi, call_runtime; | |
6016 __ Mov(scratch, 0x40000000U); | |
Rodolph Perfetta
2016/04/07 14:13:50
on 64-bits platform Smi are signed 32-bits integer
binji
2016/04/08 18:21:42
Done.
| |
6017 __ Cmp(value, scratch); | |
6018 __ B(hs, ¬_smi); | |
6019 __ SmiTag(x0, value); | |
6020 __ Ret(); | |
6021 | |
6022 __ bind(¬_smi); | |
6023 __ ucvtf(dst, value); | |
6024 __ AllocateHeapNumber(x0, &call_runtime, scratch, scratch2, dst); | |
6025 __ Ret(); | |
6026 | |
6027 __ bind(&call_runtime); | |
6028 { | |
6029 FrameScope scope(masm, StackFrame::INTERNAL); | |
6030 __ CallRuntimeSaveDoubles(Runtime::kAllocateHeapNumber); | |
6031 __ Str(value, FieldMemOperand(x0, HeapNumber::kValueOffset)); | |
6032 } | |
6033 __ Ret(); | |
6034 } | |
6035 | |
6036 } // anonymous namespace | |
6037 | |
6038 void AtomicsLoadStub::Generate(MacroAssembler* masm) { | |
6039 Register object = x1; | |
6040 Register index = x0; // Index is an untagged word32. | |
6041 Register backing_store = x2; | |
6042 Label i8, u8, i16, u16, i32, u32; | |
6043 | |
6044 GetTypedArrayBackingStore(masm, backing_store, object, x3, d0); | |
6045 TypedArrayJumpTable(masm, object, x3, x4, &i8, &u8, &i16, &u16, &i32, &u32, | |
6046 &u8); | |
6047 | |
6048 __ bind(&i8); | |
6049 __ ldrsb(x0, MemOperand(backing_store, index)); | |
6050 __ dmb(InnerShareable, BarrierAll); | |
6051 __ SmiTag(x0); | |
6052 __ Ret(); | |
6053 | |
6054 __ bind(&u8); | |
6055 __ ldrb(x0, MemOperand(backing_store, index)); | |
6056 __ dmb(InnerShareable, BarrierAll); | |
6057 __ SmiTag(x0); | |
6058 __ Ret(); | |
6059 | |
6060 __ bind(&i16); | |
6061 __ ldrsh(x0, MemOperand(backing_store, index, UXTW, 1)); | |
6062 __ dmb(InnerShareable, BarrierAll); | |
6063 __ SmiTag(x0); | |
6064 __ Ret(); | |
6065 | |
6066 __ bind(&u16); | |
6067 __ ldrh(x0, MemOperand(backing_store, index, UXTW, 1)); | |
6068 __ dmb(InnerShareable, BarrierAll); | |
6069 __ SmiTag(x0); | |
6070 __ Ret(); | |
6071 | |
6072 __ bind(&i32); | |
6073 __ ldrsw(x0, MemOperand(backing_store, index, UXTW, 2)); | |
6074 __ dmb(InnerShareable, BarrierAll); | |
6075 DCHECK(SmiValuesAre32Bits()); | |
6076 __ SmiTag(x0); | |
6077 __ Ret(); | |
6078 | |
6079 __ bind(&u32); | |
6080 __ ldr(w0, MemOperand(backing_store, index, UXTW, 2)); | |
6081 __ dmb(InnerShareable, BarrierAll); | |
6082 __ uxtw(x0, x0); | |
6083 ReturnUnsignedInteger32(masm, d0, x0, x1, x2, x3); | |
6084 } | |
5942 | 6085 |
5943 #undef __ | 6086 #undef __ |
5944 | 6087 |
5945 } // namespace internal | 6088 } // namespace internal |
5946 } // namespace v8 | 6089 } // namespace v8 |
5947 | 6090 |
5948 #endif // V8_TARGET_ARCH_ARM64 | 6091 #endif // V8_TARGET_ARCH_ARM64 |
OLD | NEW |