Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: src/x64/code-stubs-x64.cc

Issue 1748123003: Rework CallApi*Stubs. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Minor fixes and make Win compiler happy. Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 5378 matching lines...) Expand 10 before | Expand all | Expand 10 after
5389 __ movp(Operand(base_reg, kLimitOffset), prev_limit_reg); 5389 __ movp(Operand(base_reg, kLimitOffset), prev_limit_reg);
5390 __ movp(prev_limit_reg, rax); 5390 __ movp(prev_limit_reg, rax);
5391 __ LoadAddress(arg_reg_1, ExternalReference::isolate_address(isolate)); 5391 __ LoadAddress(arg_reg_1, ExternalReference::isolate_address(isolate));
5392 __ LoadAddress(rax, 5392 __ LoadAddress(rax,
5393 ExternalReference::delete_handle_scope_extensions(isolate)); 5393 ExternalReference::delete_handle_scope_extensions(isolate));
5394 __ call(rax); 5394 __ call(rax);
5395 __ movp(rax, prev_limit_reg); 5395 __ movp(rax, prev_limit_reg);
5396 __ jmp(&leave_exit_frame); 5396 __ jmp(&leave_exit_frame);
5397 } 5397 }
5398 5398
5399 static void CallApiFunctionStubHelper(MacroAssembler* masm, 5399 void CallApiCallbackStub::Generate(MacroAssembler* masm) {
5400 const ParameterCount& argc,
5401 bool return_first_arg,
5402 bool call_data_undefined, bool is_lazy) {
5403 // ----------- S t a t e ------------- 5400 // ----------- S t a t e -------------
5404 // -- rdi : callee 5401 // -- rdi : callee
5405 // -- rbx : call_data 5402 // -- rbx : call_data
5406 // -- rcx : holder 5403 // -- rcx : holder
5407 // -- rdx : api_function_address 5404 // -- rdx : api_function_address
5408 // -- rsi : context 5405 // -- rsi : context
5409 // -- rax : number of arguments if argc is a register 5406 // -- rax : number of arguments if argc is a register
5410 // -- rsp[0] : return address 5407 // -- rsp[0] : return address
5411 // -- rsp[8] : last argument 5408 // -- rsp[8] : last argument
5412 // -- ... 5409 // -- ...
(...skipping 12 matching lines...) Expand all
5425 5422
5426 STATIC_ASSERT(FCA::kContextSaveIndex == 6); 5423 STATIC_ASSERT(FCA::kContextSaveIndex == 6);
5427 STATIC_ASSERT(FCA::kCalleeIndex == 5); 5424 STATIC_ASSERT(FCA::kCalleeIndex == 5);
5428 STATIC_ASSERT(FCA::kDataIndex == 4); 5425 STATIC_ASSERT(FCA::kDataIndex == 4);
5429 STATIC_ASSERT(FCA::kReturnValueOffset == 3); 5426 STATIC_ASSERT(FCA::kReturnValueOffset == 3);
5430 STATIC_ASSERT(FCA::kReturnValueDefaultValueIndex == 2); 5427 STATIC_ASSERT(FCA::kReturnValueDefaultValueIndex == 2);
5431 STATIC_ASSERT(FCA::kIsolateIndex == 1); 5428 STATIC_ASSERT(FCA::kIsolateIndex == 1);
5432 STATIC_ASSERT(FCA::kHolderIndex == 0); 5429 STATIC_ASSERT(FCA::kHolderIndex == 0);
5433 STATIC_ASSERT(FCA::kArgsLength == 7); 5430 STATIC_ASSERT(FCA::kArgsLength == 7);
5434 5431
5435 DCHECK(argc.is_immediate() || rax.is(argc.reg()));
5436
5437 __ PopReturnAddressTo(return_address); 5432 __ PopReturnAddressTo(return_address);
5438 5433
5439 // context save 5434 // context save
5440 __ Push(context); 5435 __ Push(context);
5441 5436
5442 // callee 5437 // callee
5443 __ Push(callee); 5438 __ Push(callee);
5444 5439
5445 // call data 5440 // call data
5446 __ Push(call_data); 5441 __ Push(call_data);
5447 Register scratch = call_data; 5442 Register scratch = call_data;
5448 if (!call_data_undefined) { 5443 if (!this->call_data_undefined()) {
5449 __ LoadRoot(scratch, Heap::kUndefinedValueRootIndex); 5444 __ LoadRoot(scratch, Heap::kUndefinedValueRootIndex);
5450 } 5445 }
5451 // return value 5446 // return value
5452 __ Push(scratch); 5447 __ Push(scratch);
5453 // return value default 5448 // return value default
5454 __ Push(scratch); 5449 __ Push(scratch);
5455 // isolate 5450 // isolate
5456 __ Move(scratch, ExternalReference::isolate_address(masm->isolate())); 5451 __ Move(scratch, ExternalReference::isolate_address(masm->isolate()));
5457 __ Push(scratch); 5452 __ Push(scratch);
5458 // holder 5453 // holder
5459 __ Push(holder); 5454 __ Push(holder);
5460 5455
5461 __ movp(scratch, rsp); 5456 __ movp(scratch, rsp);
5462 // Push return address back on stack. 5457 // Push return address back on stack.
5463 __ PushReturnAddressFrom(return_address); 5458 __ PushReturnAddressFrom(return_address);
5464 5459
5465 if (!is_lazy) { 5460 if (!this->is_lazy()) {
5466 // load context from callee 5461 // load context from callee
5467 __ movp(context, FieldOperand(callee, JSFunction::kContextOffset)); 5462 __ movp(context, FieldOperand(callee, JSFunction::kContextOffset));
5468 } 5463 }
5469 5464
5470 // Allocate the v8::Arguments structure in the arguments' space since 5465 // Allocate the v8::Arguments structure in the arguments' space since
5471 // it's not controlled by GC. 5466 // it's not controlled by GC.
5472 const int kApiStackSpace = 4; 5467 const int kApiStackSpace = 4;
5473 5468
5474 PrepareCallApiFunction(masm, kApiStackSpace); 5469 PrepareCallApiFunction(masm, kApiStackSpace);
5475 5470
5476 // FunctionCallbackInfo::implicit_args_. 5471 // FunctionCallbackInfo::implicit_args_.
5472 int argc = this->argc();
5477 __ movp(StackSpaceOperand(0), scratch); 5473 __ movp(StackSpaceOperand(0), scratch);
5478 if (argc.is_immediate()) { 5474 __ addp(scratch, Immediate((argc + FCA::kArgsLength - 1) * kPointerSize));
5479 __ addp(scratch, Immediate((argc.immediate() + FCA::kArgsLength - 1) * 5475 // FunctionCallbackInfo::values_.
5480 kPointerSize)); 5476 __ movp(StackSpaceOperand(1), scratch);
5481 // FunctionCallbackInfo::values_. 5477 // FunctionCallbackInfo::length_.
5482 __ movp(StackSpaceOperand(1), scratch); 5478 __ Set(StackSpaceOperand(2), argc);
5483 // FunctionCallbackInfo::length_. 5479 // FunctionCallbackInfo::is_construct_call_.
5484 __ Set(StackSpaceOperand(2), argc.immediate()); 5480 __ Set(StackSpaceOperand(3), 0);
5485 // FunctionCallbackInfo::is_construct_call_.
5486 __ Set(StackSpaceOperand(3), 0);
5487 } else {
5488 __ leap(scratch, Operand(scratch, argc.reg(), times_pointer_size,
5489 (FCA::kArgsLength - 1) * kPointerSize));
5490 // FunctionCallbackInfo::values_.
5491 __ movp(StackSpaceOperand(1), scratch);
5492 // FunctionCallbackInfo::length_.
5493 __ movp(StackSpaceOperand(2), argc.reg());
5494 // FunctionCallbackInfo::is_construct_call_.
5495 __ leap(argc.reg(), Operand(argc.reg(), times_pointer_size,
5496 (FCA::kArgsLength + 1) * kPointerSize));
5497 __ movp(StackSpaceOperand(3), argc.reg());
5498 }
5499 5481
5500 #if defined(__MINGW64__) || defined(_WIN64) 5482 #if defined(__MINGW64__) || defined(_WIN64)
5501 Register arguments_arg = rcx; 5483 Register arguments_arg = rcx;
5502 Register callback_arg = rdx; 5484 Register callback_arg = rdx;
5503 #else 5485 #else
5504 Register arguments_arg = rdi; 5486 Register arguments_arg = rdi;
5505 Register callback_arg = rsi; 5487 Register callback_arg = rsi;
5506 #endif 5488 #endif
5507 5489
5508 // It's okay if api_function_address == callback_arg 5490 // It's okay if api_function_address == callback_arg
5509 // but not arguments_arg 5491 // but not arguments_arg
5510 DCHECK(!api_function_address.is(arguments_arg)); 5492 DCHECK(!api_function_address.is(arguments_arg));
5511 5493
5512 // v8::InvocationCallback's argument. 5494 // v8::InvocationCallback's argument.
5513 __ leap(arguments_arg, StackSpaceOperand(0)); 5495 __ leap(arguments_arg, StackSpaceOperand(0));
5514 5496
5515 ExternalReference thunk_ref = 5497 ExternalReference thunk_ref =
5516 ExternalReference::invoke_function_callback(masm->isolate()); 5498 ExternalReference::invoke_function_callback(masm->isolate());
5517 5499
5518 // Accessor for FunctionCallbackInfo and first js arg. 5500 // Accessor for FunctionCallbackInfo and first js arg.
5519 StackArgumentsAccessor args_from_rbp(rbp, FCA::kArgsLength + 1, 5501 StackArgumentsAccessor args_from_rbp(rbp, FCA::kArgsLength + 1,
5520 ARGUMENTS_DONT_CONTAIN_RECEIVER); 5502 ARGUMENTS_DONT_CONTAIN_RECEIVER);
5521 Operand context_restore_operand = args_from_rbp.GetArgumentOperand( 5503 Operand context_restore_operand = args_from_rbp.GetArgumentOperand(
5522 FCA::kArgsLength - FCA::kContextSaveIndex); 5504 FCA::kArgsLength - FCA::kContextSaveIndex);
5523 Operand is_construct_call_operand = StackSpaceOperand(3); 5505 Operand is_construct_call_operand = StackSpaceOperand(3);
5524 Operand return_value_operand = args_from_rbp.GetArgumentOperand( 5506 Operand return_value_operand = args_from_rbp.GetArgumentOperand(
5525 return_first_arg ? 0 : FCA::kArgsLength - FCA::kReturnValueOffset); 5507 this->is_store() ? 0 : FCA::kArgsLength - FCA::kReturnValueOffset);
5526 int stack_space = 0; 5508 int stack_space = 0;
5527 Operand* stack_space_operand = &is_construct_call_operand; 5509 Operand* stack_space_operand = &is_construct_call_operand;
5528 if (argc.is_immediate()) { 5510 stack_space = argc + FCA::kArgsLength + 1;
5529 stack_space = argc.immediate() + FCA::kArgsLength + 1; 5511 stack_space_operand = nullptr;
5530 stack_space_operand = nullptr;
5531 }
5532 CallApiFunctionAndReturn(masm, api_function_address, thunk_ref, callback_arg, 5512 CallApiFunctionAndReturn(masm, api_function_address, thunk_ref, callback_arg,
5533 stack_space, stack_space_operand, 5513 stack_space, stack_space_operand,
5534 return_value_operand, &context_restore_operand); 5514 return_value_operand, &context_restore_operand);
5535 } 5515 }
5536 5516
5537 5517
5538 void CallApiFunctionStub::Generate(MacroAssembler* masm) {
5539 bool call_data_undefined = this->call_data_undefined();
5540 CallApiFunctionStubHelper(masm, ParameterCount(rax), false,
5541 call_data_undefined, false);
5542 }
5543
5544
5545 void CallApiAccessorStub::Generate(MacroAssembler* masm) {
5546 bool is_store = this->is_store();
5547 int argc = this->argc();
5548 bool call_data_undefined = this->call_data_undefined();
5549 bool is_lazy = this->is_lazy();
5550 CallApiFunctionStubHelper(masm, ParameterCount(argc), is_store,
5551 call_data_undefined, is_lazy);
5552 }
5553
5554
5555 void CallApiGetterStub::Generate(MacroAssembler* masm) { 5518 void CallApiGetterStub::Generate(MacroAssembler* masm) {
5556 // ----------- S t a t e ------------- 5519 // ----------- S t a t e -------------
5557 // -- rsp[0] : return address 5520 // -- rsp[0] : return address
5558 // -- rsp[8] : name 5521 // -- rsp[8] : name
5559 // -- rsp[16 .. (16 + kArgsLength*8)] : v8::PropertyCallbackInfo::args_ 5522 // -- rsp[16 .. (16 + kArgsLength*8)] : v8::PropertyCallbackInfo::args_
5560 // -- ... 5523 // -- ...
5561 // -- r8 : api_function_address 5524 // -- r8 : api_function_address
5562 // ----------------------------------- 5525 // -----------------------------------
5563 5526
5564 #if defined(__MINGW64__) || defined(_WIN64) 5527 #if defined(__MINGW64__) || defined(_WIN64)
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
5610 NULL); 5573 NULL);
5611 } 5574 }
5612 5575
5613 5576
5614 #undef __ 5577 #undef __
5615 5578
5616 } // namespace internal 5579 } // namespace internal
5617 } // namespace v8 5580 } // namespace v8
5618 5581
5619 #endif // V8_TARGET_ARCH_X64 5582 #endif // V8_TARGET_ARCH_X64
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698