| 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_X87 | 5 #if V8_TARGET_ARCH_X87 |
| 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 5442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5453 stack_space = argc() + FCA::kArgsLength + 1; | 5453 stack_space = argc() + FCA::kArgsLength + 1; |
| 5454 stack_space_operand = nullptr; | 5454 stack_space_operand = nullptr; |
| 5455 CallApiFunctionAndReturn(masm, api_function_address, thunk_ref, | 5455 CallApiFunctionAndReturn(masm, api_function_address, thunk_ref, |
| 5456 ApiParameterOperand(1), stack_space, | 5456 ApiParameterOperand(1), stack_space, |
| 5457 stack_space_operand, return_value_operand, | 5457 stack_space_operand, return_value_operand, |
| 5458 &context_restore_operand); | 5458 &context_restore_operand); |
| 5459 } | 5459 } |
| 5460 | 5460 |
| 5461 | 5461 |
| 5462 void CallApiGetterStub::Generate(MacroAssembler* masm) { | 5462 void CallApiGetterStub::Generate(MacroAssembler* masm) { |
| 5463 // ----------- S t a t e ------------- | 5463 // Build v8::PropertyCallbackInfo::args_ array on the stack and push property |
| 5464 // -- esp[0] : return address | 5464 // name below the exit frame to make GC aware of them. |
| 5465 // -- esp[4] : name | 5465 STATIC_ASSERT(PropertyCallbackArguments::kShouldThrowOnErrorIndex == 0); |
| 5466 // -- esp[8 .. (8 + kArgsLength*4)] : v8::PropertyCallbackInfo::args_ | 5466 STATIC_ASSERT(PropertyCallbackArguments::kHolderIndex == 1); |
| 5467 // -- ... | 5467 STATIC_ASSERT(PropertyCallbackArguments::kIsolateIndex == 2); |
| 5468 // -- edx : api_function_address | 5468 STATIC_ASSERT(PropertyCallbackArguments::kReturnValueDefaultValueIndex == 3); |
| 5469 // ----------------------------------- | 5469 STATIC_ASSERT(PropertyCallbackArguments::kReturnValueOffset == 4); |
| 5470 DCHECK(edx.is(ApiGetterDescriptor::function_address())); | 5470 STATIC_ASSERT(PropertyCallbackArguments::kDataIndex == 5); |
| 5471 STATIC_ASSERT(PropertyCallbackArguments::kThisIndex == 6); |
| 5472 STATIC_ASSERT(PropertyCallbackArguments::kArgsLength == 7); |
| 5473 |
| 5474 Register receiver = ApiGetterDescriptor::ReceiverRegister(); |
| 5475 Register holder = ApiGetterDescriptor::HolderRegister(); |
| 5476 Register callback = ApiGetterDescriptor::CallbackRegister(); |
| 5477 Register scratch = ebx; |
| 5478 DCHECK(!AreAliased(receiver, holder, callback, scratch)); |
| 5479 |
| 5480 __ pop(scratch); // Pop return address to extend the frame. |
| 5481 __ push(receiver); |
| 5482 __ push(FieldOperand(callback, AccessorInfo::kDataOffset)); |
| 5483 __ PushRoot(Heap::kUndefinedValueRootIndex); // ReturnValue |
| 5484 // ReturnValue default value |
| 5485 __ PushRoot(Heap::kUndefinedValueRootIndex); |
| 5486 __ push(Immediate(ExternalReference::isolate_address(isolate()))); |
| 5487 __ push(holder); |
| 5488 __ push(Immediate(Smi::FromInt(0))); // should_throw_on_error -> false |
| 5489 __ push(FieldOperand(callback, AccessorInfo::kNameOffset)); |
| 5490 __ push(scratch); // Restore return address. |
| 5471 | 5491 |
| 5472 // v8::PropertyCallbackInfo::args_ array and name handle. | 5492 // v8::PropertyCallbackInfo::args_ array and name handle. |
| 5473 const int kStackUnwindSpace = PropertyCallbackArguments::kArgsLength + 1; | 5493 const int kStackUnwindSpace = PropertyCallbackArguments::kArgsLength + 1; |
| 5474 | 5494 |
| 5475 // Allocate v8::PropertyCallbackInfo object, arguments for callback and | 5495 // Allocate v8::PropertyCallbackInfo object, arguments for callback and |
| 5476 // space for optional callback address parameter (in case CPU profiler is | 5496 // space for optional callback address parameter (in case CPU profiler is |
| 5477 // active) in non-GCed stack space. | 5497 // active) in non-GCed stack space. |
| 5478 const int kApiArgc = 3 + 1; | 5498 const int kApiArgc = 3 + 1; |
| 5479 | 5499 |
| 5480 Register api_function_address = edx; | |
| 5481 Register scratch = ebx; | |
| 5482 | |
| 5483 // Load address of v8::PropertyAccessorInfo::args_ array. | 5500 // Load address of v8::PropertyAccessorInfo::args_ array. |
| 5484 __ lea(scratch, Operand(esp, 2 * kPointerSize)); | 5501 __ lea(scratch, Operand(esp, 2 * kPointerSize)); |
| 5485 | 5502 |
| 5486 PrepareCallApiFunction(masm, kApiArgc); | 5503 PrepareCallApiFunction(masm, kApiArgc); |
| 5487 // Create v8::PropertyCallbackInfo object on the stack and initialize | 5504 // Create v8::PropertyCallbackInfo object on the stack and initialize |
| 5488 // it's args_ field. | 5505 // it's args_ field. |
| 5489 Operand info_object = ApiParameterOperand(3); | 5506 Operand info_object = ApiParameterOperand(3); |
| 5490 __ mov(info_object, scratch); | 5507 __ mov(info_object, scratch); |
| 5491 | 5508 |
| 5509 // Name as handle. |
| 5492 __ sub(scratch, Immediate(kPointerSize)); | 5510 __ sub(scratch, Immediate(kPointerSize)); |
| 5493 __ mov(ApiParameterOperand(0), scratch); // name. | 5511 __ mov(ApiParameterOperand(0), scratch); |
| 5512 // Arguments pointer. |
| 5494 __ lea(scratch, info_object); | 5513 __ lea(scratch, info_object); |
| 5495 __ mov(ApiParameterOperand(1), scratch); // arguments pointer. | 5514 __ mov(ApiParameterOperand(1), scratch); |
| 5496 // Reserve space for optional callback address parameter. | 5515 // Reserve space for optional callback address parameter. |
| 5497 Operand thunk_last_arg = ApiParameterOperand(2); | 5516 Operand thunk_last_arg = ApiParameterOperand(2); |
| 5498 | 5517 |
| 5499 ExternalReference thunk_ref = | 5518 ExternalReference thunk_ref = |
| 5500 ExternalReference::invoke_accessor_getter_callback(isolate()); | 5519 ExternalReference::invoke_accessor_getter_callback(isolate()); |
| 5501 | 5520 |
| 5521 __ mov(scratch, FieldOperand(callback, AccessorInfo::kJsGetterOffset)); |
| 5522 Register function_address = edx; |
| 5523 __ mov(function_address, |
| 5524 FieldOperand(scratch, Foreign::kForeignAddressOffset)); |
| 5502 // +3 is to skip prolog, return address and name handle. | 5525 // +3 is to skip prolog, return address and name handle. |
| 5503 Operand return_value_operand( | 5526 Operand return_value_operand( |
| 5504 ebp, (PropertyCallbackArguments::kReturnValueOffset + 3) * kPointerSize); | 5527 ebp, (PropertyCallbackArguments::kReturnValueOffset + 3) * kPointerSize); |
| 5505 CallApiFunctionAndReturn(masm, api_function_address, thunk_ref, | 5528 CallApiFunctionAndReturn(masm, function_address, thunk_ref, thunk_last_arg, |
| 5506 thunk_last_arg, kStackUnwindSpace, nullptr, | 5529 kStackUnwindSpace, nullptr, return_value_operand, |
| 5507 return_value_operand, NULL); | 5530 NULL); |
| 5508 } | 5531 } |
| 5509 | 5532 |
| 5510 #undef __ | 5533 #undef __ |
| 5511 | 5534 |
| 5512 } // namespace internal | 5535 } // namespace internal |
| 5513 } // namespace v8 | 5536 } // namespace v8 |
| 5514 | 5537 |
| 5515 #endif // V8_TARGET_ARCH_X87 | 5538 #endif // V8_TARGET_ARCH_X87 |
| OLD | NEW |