| 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_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 5386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5397 | 5397 |
| 5398 typedef FunctionCallbackArguments FCA; | 5398 typedef FunctionCallbackArguments FCA; |
| 5399 | 5399 |
| 5400 STATIC_ASSERT(FCA::kContextSaveIndex == 6); | 5400 STATIC_ASSERT(FCA::kContextSaveIndex == 6); |
| 5401 STATIC_ASSERT(FCA::kCalleeIndex == 5); | 5401 STATIC_ASSERT(FCA::kCalleeIndex == 5); |
| 5402 STATIC_ASSERT(FCA::kDataIndex == 4); | 5402 STATIC_ASSERT(FCA::kDataIndex == 4); |
| 5403 STATIC_ASSERT(FCA::kReturnValueOffset == 3); | 5403 STATIC_ASSERT(FCA::kReturnValueOffset == 3); |
| 5404 STATIC_ASSERT(FCA::kReturnValueDefaultValueIndex == 2); | 5404 STATIC_ASSERT(FCA::kReturnValueDefaultValueIndex == 2); |
| 5405 STATIC_ASSERT(FCA::kIsolateIndex == 1); | 5405 STATIC_ASSERT(FCA::kIsolateIndex == 1); |
| 5406 STATIC_ASSERT(FCA::kHolderIndex == 0); | 5406 STATIC_ASSERT(FCA::kHolderIndex == 0); |
| 5407 STATIC_ASSERT(FCA::kArgsLength == 7); | 5407 STATIC_ASSERT(FCA::kNewTargetIndex == 7); |
| 5408 STATIC_ASSERT(FCA::kArgsLength == 8); |
| 5408 | 5409 |
| 5409 __ PopReturnAddressTo(return_address); | 5410 __ PopReturnAddressTo(return_address); |
| 5410 | 5411 |
| 5412 // new target |
| 5413 __ PushRoot(Heap::kUndefinedValueRootIndex); |
| 5414 |
| 5411 // context save | 5415 // context save |
| 5412 __ Push(context); | 5416 __ Push(context); |
| 5413 | 5417 |
| 5414 // callee | 5418 // callee |
| 5415 __ Push(callee); | 5419 __ Push(callee); |
| 5416 | 5420 |
| 5417 // call data | 5421 // call data |
| 5418 __ Push(call_data); | 5422 __ Push(call_data); |
| 5419 Register scratch = call_data; | 5423 Register scratch = call_data; |
| 5420 if (!this->call_data_undefined()) { | 5424 if (!this->call_data_undefined()) { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 5434 // Push return address back on stack. | 5438 // Push return address back on stack. |
| 5435 __ PushReturnAddressFrom(return_address); | 5439 __ PushReturnAddressFrom(return_address); |
| 5436 | 5440 |
| 5437 if (!this->is_lazy()) { | 5441 if (!this->is_lazy()) { |
| 5438 // load context from callee | 5442 // load context from callee |
| 5439 __ movp(context, FieldOperand(callee, JSFunction::kContextOffset)); | 5443 __ movp(context, FieldOperand(callee, JSFunction::kContextOffset)); |
| 5440 } | 5444 } |
| 5441 | 5445 |
| 5442 // Allocate the v8::Arguments structure in the arguments' space since | 5446 // Allocate the v8::Arguments structure in the arguments' space since |
| 5443 // it's not controlled by GC. | 5447 // it's not controlled by GC. |
| 5444 const int kApiStackSpace = 4; | 5448 const int kApiStackSpace = 3; |
| 5445 | 5449 |
| 5446 PrepareCallApiFunction(masm, kApiStackSpace); | 5450 PrepareCallApiFunction(masm, kApiStackSpace); |
| 5447 | 5451 |
| 5448 // FunctionCallbackInfo::implicit_args_. | 5452 // FunctionCallbackInfo::implicit_args_. |
| 5449 int argc = this->argc(); | 5453 int argc = this->argc(); |
| 5450 __ movp(StackSpaceOperand(0), scratch); | 5454 __ movp(StackSpaceOperand(0), scratch); |
| 5451 __ addp(scratch, Immediate((argc + FCA::kArgsLength - 1) * kPointerSize)); | 5455 __ addp(scratch, Immediate((argc + FCA::kArgsLength - 1) * kPointerSize)); |
| 5452 // FunctionCallbackInfo::values_. | 5456 // FunctionCallbackInfo::values_. |
| 5453 __ movp(StackSpaceOperand(1), scratch); | 5457 __ movp(StackSpaceOperand(1), scratch); |
| 5454 // FunctionCallbackInfo::length_. | 5458 // FunctionCallbackInfo::length_. |
| 5455 __ Set(StackSpaceOperand(2), argc); | 5459 __ Set(StackSpaceOperand(2), argc); |
| 5456 // FunctionCallbackInfo::is_construct_call_. | |
| 5457 __ Set(StackSpaceOperand(3), 0); | |
| 5458 | 5460 |
| 5459 #if defined(__MINGW64__) || defined(_WIN64) | 5461 #if defined(__MINGW64__) || defined(_WIN64) |
| 5460 Register arguments_arg = rcx; | 5462 Register arguments_arg = rcx; |
| 5461 Register callback_arg = rdx; | 5463 Register callback_arg = rdx; |
| 5462 #else | 5464 #else |
| 5463 Register arguments_arg = rdi; | 5465 Register arguments_arg = rdi; |
| 5464 Register callback_arg = rsi; | 5466 Register callback_arg = rsi; |
| 5465 #endif | 5467 #endif |
| 5466 | 5468 |
| 5467 // It's okay if api_function_address == callback_arg | 5469 // It's okay if api_function_address == callback_arg |
| 5468 // but not arguments_arg | 5470 // but not arguments_arg |
| 5469 DCHECK(!api_function_address.is(arguments_arg)); | 5471 DCHECK(!api_function_address.is(arguments_arg)); |
| 5470 | 5472 |
| 5471 // v8::InvocationCallback's argument. | 5473 // v8::InvocationCallback's argument. |
| 5472 __ leap(arguments_arg, StackSpaceOperand(0)); | 5474 __ leap(arguments_arg, StackSpaceOperand(0)); |
| 5473 | 5475 |
| 5474 ExternalReference thunk_ref = | 5476 ExternalReference thunk_ref = |
| 5475 ExternalReference::invoke_function_callback(masm->isolate()); | 5477 ExternalReference::invoke_function_callback(masm->isolate()); |
| 5476 | 5478 |
| 5477 // Accessor for FunctionCallbackInfo and first js arg. | 5479 // Accessor for FunctionCallbackInfo and first js arg. |
| 5478 StackArgumentsAccessor args_from_rbp(rbp, FCA::kArgsLength + 1, | 5480 StackArgumentsAccessor args_from_rbp(rbp, FCA::kArgsLength + 1, |
| 5479 ARGUMENTS_DONT_CONTAIN_RECEIVER); | 5481 ARGUMENTS_DONT_CONTAIN_RECEIVER); |
| 5480 Operand context_restore_operand = args_from_rbp.GetArgumentOperand( | 5482 Operand context_restore_operand = args_from_rbp.GetArgumentOperand( |
| 5481 FCA::kArgsLength - FCA::kContextSaveIndex); | 5483 FCA::kArgsLength - FCA::kContextSaveIndex); |
| 5482 Operand is_construct_call_operand = StackSpaceOperand(3); | 5484 Operand length_operand = StackSpaceOperand(2); |
| 5483 Operand return_value_operand = args_from_rbp.GetArgumentOperand( | 5485 Operand return_value_operand = args_from_rbp.GetArgumentOperand( |
| 5484 this->is_store() ? 0 : FCA::kArgsLength - FCA::kReturnValueOffset); | 5486 this->is_store() ? 0 : FCA::kArgsLength - FCA::kReturnValueOffset); |
| 5485 int stack_space = 0; | 5487 int stack_space = 0; |
| 5486 Operand* stack_space_operand = &is_construct_call_operand; | 5488 Operand* stack_space_operand = &length_operand; |
| 5487 stack_space = argc + FCA::kArgsLength + 1; | 5489 stack_space = argc + FCA::kArgsLength + 1; |
| 5488 stack_space_operand = nullptr; | 5490 stack_space_operand = nullptr; |
| 5489 CallApiFunctionAndReturn(masm, api_function_address, thunk_ref, callback_arg, | 5491 CallApiFunctionAndReturn(masm, api_function_address, thunk_ref, callback_arg, |
| 5490 stack_space, stack_space_operand, | 5492 stack_space, stack_space_operand, |
| 5491 return_value_operand, &context_restore_operand); | 5493 return_value_operand, &context_restore_operand); |
| 5492 } | 5494 } |
| 5493 | 5495 |
| 5494 | 5496 |
| 5495 void CallApiGetterStub::Generate(MacroAssembler* masm) { | 5497 void CallApiGetterStub::Generate(MacroAssembler* masm) { |
| 5496 #if defined(__MINGW64__) || defined(_WIN64) | 5498 #if defined(__MINGW64__) || defined(_WIN64) |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5571 kStackUnwindSpace, nullptr, return_value_operand, | 5573 kStackUnwindSpace, nullptr, return_value_operand, |
| 5572 NULL); | 5574 NULL); |
| 5573 } | 5575 } |
| 5574 | 5576 |
| 5575 #undef __ | 5577 #undef __ |
| 5576 | 5578 |
| 5577 } // namespace internal | 5579 } // namespace internal |
| 5578 } // namespace v8 | 5580 } // namespace v8 |
| 5579 | 5581 |
| 5580 #endif // V8_TARGET_ARCH_X64 | 5582 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |