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

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

Issue 1775933005: Revert of Rework CallApi*Stubs. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: 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
« no previous file with comments | « src/s390/interface-descriptors-s390.cc ('k') | src/x64/interface-descriptors-x64.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 void CallApiCallbackStub::Generate(MacroAssembler* masm) { 5399 static void CallApiFunctionStubHelper(MacroAssembler* masm,
5400 const ParameterCount& argc,
5401 bool return_first_arg,
5402 bool call_data_undefined, bool is_lazy) {
5400 // ----------- S t a t e ------------- 5403 // ----------- S t a t e -------------
5401 // -- rdi : callee 5404 // -- rdi : callee
5402 // -- rbx : call_data 5405 // -- rbx : call_data
5403 // -- rcx : holder 5406 // -- rcx : holder
5404 // -- rdx : api_function_address 5407 // -- rdx : api_function_address
5405 // -- rsi : context 5408 // -- rsi : context
5406 // -- rax : number of arguments if argc is a register 5409 // -- rax : number of arguments if argc is a register
5407 // -- rsp[0] : return address 5410 // -- rsp[0] : return address
5408 // -- rsp[8] : last argument 5411 // -- rsp[8] : last argument
5409 // -- ... 5412 // -- ...
(...skipping 12 matching lines...) Expand all
5422 5425
5423 STATIC_ASSERT(FCA::kContextSaveIndex == 6); 5426 STATIC_ASSERT(FCA::kContextSaveIndex == 6);
5424 STATIC_ASSERT(FCA::kCalleeIndex == 5); 5427 STATIC_ASSERT(FCA::kCalleeIndex == 5);
5425 STATIC_ASSERT(FCA::kDataIndex == 4); 5428 STATIC_ASSERT(FCA::kDataIndex == 4);
5426 STATIC_ASSERT(FCA::kReturnValueOffset == 3); 5429 STATIC_ASSERT(FCA::kReturnValueOffset == 3);
5427 STATIC_ASSERT(FCA::kReturnValueDefaultValueIndex == 2); 5430 STATIC_ASSERT(FCA::kReturnValueDefaultValueIndex == 2);
5428 STATIC_ASSERT(FCA::kIsolateIndex == 1); 5431 STATIC_ASSERT(FCA::kIsolateIndex == 1);
5429 STATIC_ASSERT(FCA::kHolderIndex == 0); 5432 STATIC_ASSERT(FCA::kHolderIndex == 0);
5430 STATIC_ASSERT(FCA::kArgsLength == 7); 5433 STATIC_ASSERT(FCA::kArgsLength == 7);
5431 5434
5435 DCHECK(argc.is_immediate() || rax.is(argc.reg()));
5436
5432 __ PopReturnAddressTo(return_address); 5437 __ PopReturnAddressTo(return_address);
5433 5438
5434 // context save 5439 // context save
5435 __ Push(context); 5440 __ Push(context);
5436 5441
5437 // callee 5442 // callee
5438 __ Push(callee); 5443 __ Push(callee);
5439 5444
5440 // call data 5445 // call data
5441 __ Push(call_data); 5446 __ Push(call_data);
5442 Register scratch = call_data; 5447 Register scratch = call_data;
5443 if (!this->call_data_undefined()) { 5448 if (!call_data_undefined) {
5444 __ LoadRoot(scratch, Heap::kUndefinedValueRootIndex); 5449 __ LoadRoot(scratch, Heap::kUndefinedValueRootIndex);
5445 } 5450 }
5446 // return value 5451 // return value
5447 __ Push(scratch); 5452 __ Push(scratch);
5448 // return value default 5453 // return value default
5449 __ Push(scratch); 5454 __ Push(scratch);
5450 // isolate 5455 // isolate
5451 __ Move(scratch, ExternalReference::isolate_address(masm->isolate())); 5456 __ Move(scratch, ExternalReference::isolate_address(masm->isolate()));
5452 __ Push(scratch); 5457 __ Push(scratch);
5453 // holder 5458 // holder
5454 __ Push(holder); 5459 __ Push(holder);
5455 5460
5456 __ movp(scratch, rsp); 5461 __ movp(scratch, rsp);
5457 // Push return address back on stack. 5462 // Push return address back on stack.
5458 __ PushReturnAddressFrom(return_address); 5463 __ PushReturnAddressFrom(return_address);
5459 5464
5460 if (!this->is_lazy()) { 5465 if (!is_lazy) {
5461 // load context from callee 5466 // load context from callee
5462 __ movp(context, FieldOperand(callee, JSFunction::kContextOffset)); 5467 __ movp(context, FieldOperand(callee, JSFunction::kContextOffset));
5463 } 5468 }
5464 5469
5465 // Allocate the v8::Arguments structure in the arguments' space since 5470 // Allocate the v8::Arguments structure in the arguments' space since
5466 // it's not controlled by GC. 5471 // it's not controlled by GC.
5467 const int kApiStackSpace = 4; 5472 const int kApiStackSpace = 4;
5468 5473
5469 PrepareCallApiFunction(masm, kApiStackSpace); 5474 PrepareCallApiFunction(masm, kApiStackSpace);
5470 5475
5471 // FunctionCallbackInfo::implicit_args_. 5476 // FunctionCallbackInfo::implicit_args_.
5472 int argc = this->argc();
5473 __ movp(StackSpaceOperand(0), scratch); 5477 __ movp(StackSpaceOperand(0), scratch);
5474 __ addp(scratch, Immediate((argc + FCA::kArgsLength - 1) * kPointerSize)); 5478 if (argc.is_immediate()) {
5475 // FunctionCallbackInfo::values_. 5479 __ addp(scratch, Immediate((argc.immediate() + FCA::kArgsLength - 1) *
5476 __ movp(StackSpaceOperand(1), scratch); 5480 kPointerSize));
5477 // FunctionCallbackInfo::length_. 5481 // FunctionCallbackInfo::values_.
5478 __ Set(StackSpaceOperand(2), argc); 5482 __ movp(StackSpaceOperand(1), scratch);
5479 // FunctionCallbackInfo::is_construct_call_. 5483 // FunctionCallbackInfo::length_.
5480 __ Set(StackSpaceOperand(3), 0); 5484 __ Set(StackSpaceOperand(2), argc.immediate());
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 }
5481 5499
5482 #if defined(__MINGW64__) || defined(_WIN64) 5500 #if defined(__MINGW64__) || defined(_WIN64)
5483 Register arguments_arg = rcx; 5501 Register arguments_arg = rcx;
5484 Register callback_arg = rdx; 5502 Register callback_arg = rdx;
5485 #else 5503 #else
5486 Register arguments_arg = rdi; 5504 Register arguments_arg = rdi;
5487 Register callback_arg = rsi; 5505 Register callback_arg = rsi;
5488 #endif 5506 #endif
5489 5507
5490 // It's okay if api_function_address == callback_arg 5508 // It's okay if api_function_address == callback_arg
5491 // but not arguments_arg 5509 // but not arguments_arg
5492 DCHECK(!api_function_address.is(arguments_arg)); 5510 DCHECK(!api_function_address.is(arguments_arg));
5493 5511
5494 // v8::InvocationCallback's argument. 5512 // v8::InvocationCallback's argument.
5495 __ leap(arguments_arg, StackSpaceOperand(0)); 5513 __ leap(arguments_arg, StackSpaceOperand(0));
5496 5514
5497 ExternalReference thunk_ref = 5515 ExternalReference thunk_ref =
5498 ExternalReference::invoke_function_callback(masm->isolate()); 5516 ExternalReference::invoke_function_callback(masm->isolate());
5499 5517
5500 // Accessor for FunctionCallbackInfo and first js arg. 5518 // Accessor for FunctionCallbackInfo and first js arg.
5501 StackArgumentsAccessor args_from_rbp(rbp, FCA::kArgsLength + 1, 5519 StackArgumentsAccessor args_from_rbp(rbp, FCA::kArgsLength + 1,
5502 ARGUMENTS_DONT_CONTAIN_RECEIVER); 5520 ARGUMENTS_DONT_CONTAIN_RECEIVER);
5503 Operand context_restore_operand = args_from_rbp.GetArgumentOperand( 5521 Operand context_restore_operand = args_from_rbp.GetArgumentOperand(
5504 FCA::kArgsLength - FCA::kContextSaveIndex); 5522 FCA::kArgsLength - FCA::kContextSaveIndex);
5505 Operand is_construct_call_operand = StackSpaceOperand(3); 5523 Operand is_construct_call_operand = StackSpaceOperand(3);
5506 Operand return_value_operand = args_from_rbp.GetArgumentOperand( 5524 Operand return_value_operand = args_from_rbp.GetArgumentOperand(
5507 this->is_store() ? 0 : FCA::kArgsLength - FCA::kReturnValueOffset); 5525 return_first_arg ? 0 : FCA::kArgsLength - FCA::kReturnValueOffset);
5508 int stack_space = 0; 5526 int stack_space = 0;
5509 Operand* stack_space_operand = &is_construct_call_operand; 5527 Operand* stack_space_operand = &is_construct_call_operand;
5510 stack_space = argc + FCA::kArgsLength + 1; 5528 if (argc.is_immediate()) {
5511 stack_space_operand = nullptr; 5529 stack_space = argc.immediate() + FCA::kArgsLength + 1;
5530 stack_space_operand = nullptr;
5531 }
5512 CallApiFunctionAndReturn(masm, api_function_address, thunk_ref, callback_arg, 5532 CallApiFunctionAndReturn(masm, api_function_address, thunk_ref, callback_arg,
5513 stack_space, stack_space_operand, 5533 stack_space, stack_space_operand,
5514 return_value_operand, &context_restore_operand); 5534 return_value_operand, &context_restore_operand);
5515 } 5535 }
5516 5536
5517 5537
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
5518 void CallApiGetterStub::Generate(MacroAssembler* masm) { 5555 void CallApiGetterStub::Generate(MacroAssembler* masm) {
5519 // ----------- S t a t e ------------- 5556 // ----------- S t a t e -------------
5520 // -- rsp[0] : return address 5557 // -- rsp[0] : return address
5521 // -- rsp[8] : name 5558 // -- rsp[8] : name
5522 // -- rsp[16 .. (16 + kArgsLength*8)] : v8::PropertyCallbackInfo::args_ 5559 // -- rsp[16 .. (16 + kArgsLength*8)] : v8::PropertyCallbackInfo::args_
5523 // -- ... 5560 // -- ...
5524 // -- r8 : api_function_address 5561 // -- r8 : api_function_address
5525 // ----------------------------------- 5562 // -----------------------------------
5526 5563
5527 #if defined(__MINGW64__) || defined(_WIN64) 5564 #if defined(__MINGW64__) || defined(_WIN64)
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
5573 NULL); 5610 NULL);
5574 } 5611 }
5575 5612
5576 5613
5577 #undef __ 5614 #undef __
5578 5615
5579 } // namespace internal 5616 } // namespace internal
5580 } // namespace v8 5617 } // namespace v8
5581 5618
5582 #endif // V8_TARGET_ARCH_X64 5619 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/s390/interface-descriptors-s390.cc ('k') | src/x64/interface-descriptors-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698