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/bootstrapper.h" | 7 #include "src/bootstrapper.h" |
8 #include "src/code-stubs.h" | 8 #include "src/code-stubs.h" |
9 #include "src/codegen.h" | 9 #include "src/codegen.h" |
10 #include "src/ic/handler-compiler.h" | 10 #include "src/ic/handler-compiler.h" |
(...skipping 5350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5361 bool is_store = this->is_store(); | 5361 bool is_store = this->is_store(); |
5362 int argc = this->argc(); | 5362 int argc = this->argc(); |
5363 bool call_data_undefined = this->call_data_undefined(); | 5363 bool call_data_undefined = this->call_data_undefined(); |
5364 CallApiFunctionStubHelper(masm, ParameterCount(argc), is_store, | 5364 CallApiFunctionStubHelper(masm, ParameterCount(argc), is_store, |
5365 call_data_undefined); | 5365 call_data_undefined); |
5366 } | 5366 } |
5367 | 5367 |
5368 | 5368 |
5369 void CallApiGetterStub::Generate(MacroAssembler* masm) { | 5369 void CallApiGetterStub::Generate(MacroAssembler* masm) { |
5370 // ----------- S t a t e ------------- | 5370 // ----------- S t a t e ------------- |
5371 // -- rsp[0] : return address | 5371 // -- rsp[0] : return address |
5372 // -- rsp[8] : name | 5372 // -- rsp[8] : name |
5373 // -- rsp[16 .. (16 + kArgsLength*8)] : v8::PropertyCallbackInfo::args_ | 5373 // -- rsp[16 - kArgsLength*8] : PropertyCallbackArguments object |
5374 // -- ... | 5374 // -- ... |
5375 // -- r8 : api_function_address | 5375 // -- r8 : api_function_address |
5376 // ----------------------------------- | 5376 // ----------------------------------- |
5377 | 5377 |
5378 #if defined(__MINGW64__) || defined(_WIN64) | 5378 #if defined(__MINGW64__) || defined(_WIN64) |
5379 Register getter_arg = r8; | 5379 Register getter_arg = r8; |
5380 Register accessor_info_arg = rdx; | 5380 Register accessor_info_arg = rdx; |
5381 Register name_arg = rcx; | 5381 Register name_arg = rcx; |
5382 #else | 5382 #else |
5383 Register getter_arg = rdx; | 5383 Register getter_arg = rdx; |
5384 Register accessor_info_arg = rsi; | 5384 Register accessor_info_arg = rsi; |
5385 Register name_arg = rdi; | 5385 Register name_arg = rdi; |
5386 #endif | 5386 #endif |
5387 Register api_function_address = ApiGetterDescriptor::function_address(); | 5387 Register api_function_address = ApiGetterDescriptor::function_address(); |
5388 DCHECK(api_function_address.is(r8)); | 5388 DCHECK(api_function_address.is(r8)); |
5389 Register scratch = rax; | 5389 Register scratch = rax; |
5390 | 5390 |
5391 // v8::PropertyCallbackInfo::args_ array and name handle. | 5391 // v8::Arguments::values_ and handler for name. |
5392 const int kStackUnwindSpace = PropertyCallbackArguments::kArgsLength + 1; | 5392 const int kStackSpace = PropertyCallbackArguments::kArgsLength + 1; |
5393 | 5393 |
5394 // Allocate v8::PropertyCallbackInfo in non-GCed stack space. | 5394 // Allocate v8::AccessorInfo in non-GCed stack space. |
5395 const int kArgStackSpace = 1; | 5395 const int kArgStackSpace = 1; |
5396 | 5396 |
5397 // Load address of v8::PropertyAccessorInfo::args_ array. | 5397 __ leap(name_arg, Operand(rsp, kPCOnStackSize)); |
5398 __ leap(scratch, Operand(rsp, 2 * kPointerSize)); | |
5399 | 5398 |
5400 PrepareCallApiFunction(masm, kArgStackSpace); | 5399 PrepareCallApiFunction(masm, kArgStackSpace); |
5401 // Create v8::PropertyCallbackInfo object on the stack and initialize | 5400 __ leap(scratch, Operand(name_arg, 1 * kPointerSize)); |
5402 // it's args_ field. | |
5403 Operand info_object = StackSpaceOperand(0); | |
5404 __ movp(info_object, scratch); | |
5405 | 5401 |
5406 __ leap(name_arg, Operand(scratch, -kPointerSize)); | 5402 // v8::PropertyAccessorInfo::args_. |
| 5403 __ movp(StackSpaceOperand(0), scratch); |
| 5404 |
5407 // The context register (rsi) has been saved in PrepareCallApiFunction and | 5405 // The context register (rsi) has been saved in PrepareCallApiFunction and |
5408 // could be used to pass arguments. | 5406 // could be used to pass arguments. |
5409 __ leap(accessor_info_arg, info_object); | 5407 __ leap(accessor_info_arg, StackSpaceOperand(0)); |
5410 | 5408 |
5411 ExternalReference thunk_ref = | 5409 ExternalReference thunk_ref = |
5412 ExternalReference::invoke_accessor_getter_callback(isolate()); | 5410 ExternalReference::invoke_accessor_getter_callback(isolate()); |
5413 | 5411 |
5414 // It's okay if api_function_address == getter_arg | 5412 // It's okay if api_function_address == getter_arg |
5415 // but not accessor_info_arg or name_arg | 5413 // but not accessor_info_arg or name_arg |
5416 DCHECK(!api_function_address.is(accessor_info_arg) && | 5414 DCHECK(!api_function_address.is(accessor_info_arg) && |
5417 !api_function_address.is(name_arg)); | 5415 !api_function_address.is(name_arg)); |
5418 | 5416 |
5419 // +3 is to skip prolog, return address and name handle. | 5417 // The name handler is counted as an argument. |
5420 Operand return_value_operand( | 5418 StackArgumentsAccessor args(rbp, PropertyCallbackArguments::kArgsLength); |
5421 rbp, (PropertyCallbackArguments::kReturnValueOffset + 3) * kPointerSize); | 5419 Operand return_value_operand = args.GetArgumentOperand( |
| 5420 PropertyCallbackArguments::kArgsLength - 1 - |
| 5421 PropertyCallbackArguments::kReturnValueOffset); |
5422 CallApiFunctionAndReturn(masm, api_function_address, thunk_ref, getter_arg, | 5422 CallApiFunctionAndReturn(masm, api_function_address, thunk_ref, getter_arg, |
5423 kStackUnwindSpace, nullptr, return_value_operand, | 5423 kStackSpace, nullptr, return_value_operand, NULL); |
5424 NULL); | |
5425 } | 5424 } |
5426 | 5425 |
5427 | 5426 |
5428 #undef __ | 5427 #undef __ |
5429 | 5428 |
5430 } // namespace internal | 5429 } // namespace internal |
5431 } // namespace v8 | 5430 } // namespace v8 |
5432 | 5431 |
5433 #endif // V8_TARGET_ARCH_X64 | 5432 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |