OLD | NEW |
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 5774 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5785 stack_space = argc() + FCA::kArgsLength + 1; | 5785 stack_space = argc() + FCA::kArgsLength + 1; |
5786 stack_space_operand = nullptr; | 5786 stack_space_operand = nullptr; |
5787 CallApiFunctionAndReturn(masm, api_function_address, thunk_ref, | 5787 CallApiFunctionAndReturn(masm, api_function_address, thunk_ref, |
5788 ApiParameterOperand(1), stack_space, | 5788 ApiParameterOperand(1), stack_space, |
5789 stack_space_operand, return_value_operand, | 5789 stack_space_operand, return_value_operand, |
5790 &context_restore_operand); | 5790 &context_restore_operand); |
5791 } | 5791 } |
5792 | 5792 |
5793 | 5793 |
5794 void CallApiGetterStub::Generate(MacroAssembler* masm) { | 5794 void CallApiGetterStub::Generate(MacroAssembler* masm) { |
5795 // Build v8::PropertyCallbackInfo::args_ array on the stack and push property | 5795 // ----------- S t a t e ------------- |
5796 // name below the exit frame to make GC aware of them. | 5796 // -- esp[0] : return address |
5797 STATIC_ASSERT(PropertyCallbackArguments::kShouldThrowOnErrorIndex == 0); | 5797 // -- esp[4] : name |
5798 STATIC_ASSERT(PropertyCallbackArguments::kHolderIndex == 1); | 5798 // -- esp[8 .. (8 + kArgsLength*4)] : v8::PropertyCallbackInfo::args_ |
5799 STATIC_ASSERT(PropertyCallbackArguments::kIsolateIndex == 2); | 5799 // -- ... |
5800 STATIC_ASSERT(PropertyCallbackArguments::kReturnValueDefaultValueIndex == 3); | 5800 // -- edx : api_function_address |
5801 STATIC_ASSERT(PropertyCallbackArguments::kReturnValueOffset == 4); | 5801 // ----------------------------------- |
5802 STATIC_ASSERT(PropertyCallbackArguments::kDataIndex == 5); | 5802 DCHECK(edx.is(ApiGetterDescriptor::function_address())); |
5803 STATIC_ASSERT(PropertyCallbackArguments::kThisIndex == 6); | |
5804 STATIC_ASSERT(PropertyCallbackArguments::kArgsLength == 7); | |
5805 | |
5806 Register receiver = ApiGetterDescriptor::ReceiverRegister(); | |
5807 Register holder = ApiGetterDescriptor::HolderRegister(); | |
5808 Register callback = ApiGetterDescriptor::CallbackRegister(); | |
5809 Register scratch = ebx; | |
5810 DCHECK(!AreAliased(receiver, holder, callback, scratch)); | |
5811 | |
5812 __ pop(scratch); // Pop return address to extend the frame. | |
5813 __ push(receiver); | |
5814 __ push(FieldOperand(callback, AccessorInfo::kDataOffset)); | |
5815 __ PushRoot(Heap::kUndefinedValueRootIndex); // ReturnValue | |
5816 // ReturnValue default value | |
5817 __ PushRoot(Heap::kUndefinedValueRootIndex); | |
5818 __ push(Immediate(ExternalReference::isolate_address(isolate()))); | |
5819 __ push(holder); | |
5820 __ push(Immediate(Smi::FromInt(0))); // should_throw_on_error -> false | |
5821 __ push(FieldOperand(callback, AccessorInfo::kNameOffset)); | |
5822 __ push(scratch); // Restore return address. | |
5823 | 5803 |
5824 // v8::PropertyCallbackInfo::args_ array and name handle. | 5804 // v8::PropertyCallbackInfo::args_ array and name handle. |
5825 const int kStackUnwindSpace = PropertyCallbackArguments::kArgsLength + 1; | 5805 const int kStackUnwindSpace = PropertyCallbackArguments::kArgsLength + 1; |
5826 | 5806 |
5827 // Allocate v8::PropertyCallbackInfo object, arguments for callback and | 5807 // Allocate v8::PropertyCallbackInfo object, arguments for callback and |
5828 // space for optional callback address parameter (in case CPU profiler is | 5808 // space for optional callback address parameter (in case CPU profiler is |
5829 // active) in non-GCed stack space. | 5809 // active) in non-GCed stack space. |
5830 const int kApiArgc = 3 + 1; | 5810 const int kApiArgc = 3 + 1; |
5831 | 5811 |
| 5812 Register api_function_address = edx; |
| 5813 Register scratch = ebx; |
| 5814 |
5832 // Load address of v8::PropertyAccessorInfo::args_ array. | 5815 // Load address of v8::PropertyAccessorInfo::args_ array. |
5833 __ lea(scratch, Operand(esp, 2 * kPointerSize)); | 5816 __ lea(scratch, Operand(esp, 2 * kPointerSize)); |
5834 | 5817 |
5835 PrepareCallApiFunction(masm, kApiArgc); | 5818 PrepareCallApiFunction(masm, kApiArgc); |
5836 // Create v8::PropertyCallbackInfo object on the stack and initialize | 5819 // Create v8::PropertyCallbackInfo object on the stack and initialize |
5837 // it's args_ field. | 5820 // it's args_ field. |
5838 Operand info_object = ApiParameterOperand(3); | 5821 Operand info_object = ApiParameterOperand(3); |
5839 __ mov(info_object, scratch); | 5822 __ mov(info_object, scratch); |
5840 | 5823 |
5841 // Name as handle. | |
5842 __ sub(scratch, Immediate(kPointerSize)); | 5824 __ sub(scratch, Immediate(kPointerSize)); |
5843 __ mov(ApiParameterOperand(0), scratch); | 5825 __ mov(ApiParameterOperand(0), scratch); // name. |
5844 // Arguments pointer. | |
5845 __ lea(scratch, info_object); | 5826 __ lea(scratch, info_object); |
5846 __ mov(ApiParameterOperand(1), scratch); | 5827 __ mov(ApiParameterOperand(1), scratch); // arguments pointer. |
5847 // Reserve space for optional callback address parameter. | 5828 // Reserve space for optional callback address parameter. |
5848 Operand thunk_last_arg = ApiParameterOperand(2); | 5829 Operand thunk_last_arg = ApiParameterOperand(2); |
5849 | 5830 |
5850 ExternalReference thunk_ref = | 5831 ExternalReference thunk_ref = |
5851 ExternalReference::invoke_accessor_getter_callback(isolate()); | 5832 ExternalReference::invoke_accessor_getter_callback(isolate()); |
5852 | 5833 |
5853 __ mov(scratch, FieldOperand(callback, AccessorInfo::kJsGetterOffset)); | |
5854 Register function_address = edx; | |
5855 __ mov(function_address, | |
5856 FieldOperand(scratch, Foreign::kForeignAddressOffset)); | |
5857 // +3 is to skip prolog, return address and name handle. | 5834 // +3 is to skip prolog, return address and name handle. |
5858 Operand return_value_operand( | 5835 Operand return_value_operand( |
5859 ebp, (PropertyCallbackArguments::kReturnValueOffset + 3) * kPointerSize); | 5836 ebp, (PropertyCallbackArguments::kReturnValueOffset + 3) * kPointerSize); |
5860 CallApiFunctionAndReturn(masm, function_address, thunk_ref, thunk_last_arg, | 5837 CallApiFunctionAndReturn(masm, api_function_address, thunk_ref, |
5861 kStackUnwindSpace, nullptr, return_value_operand, | 5838 thunk_last_arg, kStackUnwindSpace, nullptr, |
5862 NULL); | 5839 return_value_operand, NULL); |
5863 } | 5840 } |
5864 | 5841 |
5865 namespace { | 5842 namespace { |
5866 | 5843 |
5867 void GetTypedArrayBackingStore(MacroAssembler* masm, Register backing_store, | 5844 void GetTypedArrayBackingStore(MacroAssembler* masm, Register backing_store, |
5868 Register object, Register scratch) { | 5845 Register object, Register scratch) { |
5869 Label offset_is_not_smi, done; | 5846 Label offset_is_not_smi, done; |
5870 __ mov(scratch, FieldOperand(object, JSTypedArray::kBufferOffset)); | 5847 __ mov(scratch, FieldOperand(object, JSTypedArray::kBufferOffset)); |
5871 __ mov(backing_store, | 5848 __ mov(backing_store, |
5872 FieldOperand(scratch, JSArrayBuffer::kBackingStoreOffset)); | 5849 FieldOperand(scratch, JSArrayBuffer::kBackingStoreOffset)); |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6031 TypedArrayJumpTableEpilogue(masm, &table, &i8, &u8, &i16, &u16, &i32, &u32, | 6008 TypedArrayJumpTableEpilogue(masm, &table, &i8, &u8, &i16, &u16, &i32, &u32, |
6032 &u8); | 6009 &u8); |
6033 } | 6010 } |
6034 | 6011 |
6035 #undef __ | 6012 #undef __ |
6036 | 6013 |
6037 } // namespace internal | 6014 } // namespace internal |
6038 } // namespace v8 | 6015 } // namespace v8 |
6039 | 6016 |
6040 #endif // V8_TARGET_ARCH_IA32 | 6017 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |