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

Side by Side Diff: src/arm/code-stubs-arm.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 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_ARM 5 #if V8_TARGET_ARCH_ARM
6 6
7 #include "src/base/bits.h" 7 #include "src/base/bits.h"
8 #include "src/bootstrapper.h" 8 #include "src/bootstrapper.h"
9 #include "src/code-stubs.h" 9 #include "src/code-stubs.h"
10 #include "src/codegen.h" 10 #include "src/codegen.h"
(...skipping 5388 matching lines...) Expand 10 before | Expand all | Expand 10 after
5399 __ str(r5, MemOperand(r9, kLimitOffset)); 5399 __ str(r5, MemOperand(r9, kLimitOffset));
5400 __ mov(r4, r0); 5400 __ mov(r4, r0);
5401 __ PrepareCallCFunction(1, r5); 5401 __ PrepareCallCFunction(1, r5);
5402 __ mov(r0, Operand(ExternalReference::isolate_address(isolate))); 5402 __ mov(r0, Operand(ExternalReference::isolate_address(isolate)));
5403 __ CallCFunction(ExternalReference::delete_handle_scope_extensions(isolate), 5403 __ CallCFunction(ExternalReference::delete_handle_scope_extensions(isolate),
5404 1); 5404 1);
5405 __ mov(r0, r4); 5405 __ mov(r0, r4);
5406 __ jmp(&leave_exit_frame); 5406 __ jmp(&leave_exit_frame);
5407 } 5407 }
5408 5408
5409 static void CallApiFunctionStubHelper(MacroAssembler* masm, 5409 void CallApiCallbackStub::Generate(MacroAssembler* masm) {
5410 const ParameterCount& argc,
5411 bool return_first_arg,
5412 bool call_data_undefined, bool is_lazy) {
5413 // ----------- S t a t e ------------- 5410 // ----------- S t a t e -------------
5414 // -- r0 : callee 5411 // -- r0 : callee
5415 // -- r4 : call_data 5412 // -- r4 : call_data
5416 // -- r2 : holder 5413 // -- r2 : holder
5417 // -- r1 : api_function_address 5414 // -- r1 : api_function_address
5418 // -- r3 : number of arguments if argc is a register
5419 // -- cp : context 5415 // -- cp : context
5420 // -- 5416 // --
5421 // -- sp[0] : last argument 5417 // -- sp[0] : last argument
5422 // -- ... 5418 // -- ...
5423 // -- sp[(argc - 1)* 4] : first argument 5419 // -- sp[(argc - 1)* 4] : first argument
5424 // -- sp[argc * 4] : receiver 5420 // -- sp[argc * 4] : receiver
5425 // ----------------------------------- 5421 // -----------------------------------
5426 5422
5427 Register callee = r0; 5423 Register callee = r0;
5428 Register call_data = r4; 5424 Register call_data = r4;
5429 Register holder = r2; 5425 Register holder = r2;
5430 Register api_function_address = r1; 5426 Register api_function_address = r1;
5431 Register context = cp; 5427 Register context = cp;
5432 5428
5433 typedef FunctionCallbackArguments FCA; 5429 typedef FunctionCallbackArguments FCA;
5434 5430
5435 STATIC_ASSERT(FCA::kContextSaveIndex == 6); 5431 STATIC_ASSERT(FCA::kContextSaveIndex == 6);
5436 STATIC_ASSERT(FCA::kCalleeIndex == 5); 5432 STATIC_ASSERT(FCA::kCalleeIndex == 5);
5437 STATIC_ASSERT(FCA::kDataIndex == 4); 5433 STATIC_ASSERT(FCA::kDataIndex == 4);
5438 STATIC_ASSERT(FCA::kReturnValueOffset == 3); 5434 STATIC_ASSERT(FCA::kReturnValueOffset == 3);
5439 STATIC_ASSERT(FCA::kReturnValueDefaultValueIndex == 2); 5435 STATIC_ASSERT(FCA::kReturnValueDefaultValueIndex == 2);
5440 STATIC_ASSERT(FCA::kIsolateIndex == 1); 5436 STATIC_ASSERT(FCA::kIsolateIndex == 1);
5441 STATIC_ASSERT(FCA::kHolderIndex == 0); 5437 STATIC_ASSERT(FCA::kHolderIndex == 0);
5442 STATIC_ASSERT(FCA::kArgsLength == 7); 5438 STATIC_ASSERT(FCA::kArgsLength == 7);
5443 5439
5444 DCHECK(argc.is_immediate() || r3.is(argc.reg()));
5445
5446 // context save 5440 // context save
5447 __ push(context); 5441 __ push(context);
5448 if (!is_lazy) { 5442 if (!is_lazy()) {
5449 // load context from callee 5443 // load context from callee
5450 __ ldr(context, FieldMemOperand(callee, JSFunction::kContextOffset)); 5444 __ ldr(context, FieldMemOperand(callee, JSFunction::kContextOffset));
5451 } 5445 }
5452 5446
5453 // callee 5447 // callee
5454 __ push(callee); 5448 __ push(callee);
5455 5449
5456 // call data 5450 // call data
5457 __ push(call_data); 5451 __ push(call_data);
5458 5452
5459 Register scratch = call_data; 5453 Register scratch = call_data;
5460 if (!call_data_undefined) { 5454 if (!call_data_undefined()) {
5461 __ LoadRoot(scratch, Heap::kUndefinedValueRootIndex); 5455 __ LoadRoot(scratch, Heap::kUndefinedValueRootIndex);
5462 } 5456 }
5463 // return value 5457 // return value
5464 __ push(scratch); 5458 __ push(scratch);
5465 // return value default 5459 // return value default
5466 __ push(scratch); 5460 __ push(scratch);
5467 // isolate 5461 // isolate
5468 __ mov(scratch, Operand(ExternalReference::isolate_address(masm->isolate()))); 5462 __ mov(scratch, Operand(ExternalReference::isolate_address(masm->isolate())));
5469 __ push(scratch); 5463 __ push(scratch);
5470 // holder 5464 // holder
5471 __ push(holder); 5465 __ push(holder);
5472 5466
5473 // Prepare arguments. 5467 // Prepare arguments.
5474 __ mov(scratch, sp); 5468 __ mov(scratch, sp);
5475 5469
5476 // Allocate the v8::Arguments structure in the arguments' space since 5470 // Allocate the v8::Arguments structure in the arguments' space since
5477 // it's not controlled by GC. 5471 // it's not controlled by GC.
5478 const int kApiStackSpace = 4; 5472 const int kApiStackSpace = 4;
5479 5473
5480 FrameScope frame_scope(masm, StackFrame::MANUAL); 5474 FrameScope frame_scope(masm, StackFrame::MANUAL);
5481 __ EnterExitFrame(false, kApiStackSpace); 5475 __ EnterExitFrame(false, kApiStackSpace);
5482 5476
5483 DCHECK(!api_function_address.is(r0) && !scratch.is(r0)); 5477 DCHECK(!api_function_address.is(r0) && !scratch.is(r0));
5484 // r0 = FunctionCallbackInfo& 5478 // r0 = FunctionCallbackInfo&
5485 // Arguments is after the return address. 5479 // Arguments is after the return address.
5486 __ add(r0, sp, Operand(1 * kPointerSize)); 5480 __ add(r0, sp, Operand(1 * kPointerSize));
5487 // FunctionCallbackInfo::implicit_args_ 5481 // FunctionCallbackInfo::implicit_args_
5488 __ str(scratch, MemOperand(r0, 0 * kPointerSize)); 5482 __ str(scratch, MemOperand(r0, 0 * kPointerSize));
5489 if (argc.is_immediate()) { 5483 // FunctionCallbackInfo::values_
5490 // FunctionCallbackInfo::values_ 5484 __ add(ip, scratch, Operand((FCA::kArgsLength - 1 + argc()) * kPointerSize));
5491 __ add(ip, scratch, 5485 __ str(ip, MemOperand(r0, 1 * kPointerSize));
5492 Operand((FCA::kArgsLength - 1 + argc.immediate()) * kPointerSize)); 5486 // FunctionCallbackInfo::length_ = argc
5493 __ str(ip, MemOperand(r0, 1 * kPointerSize)); 5487 __ mov(ip, Operand(argc()));
5494 // FunctionCallbackInfo::length_ = argc 5488 __ str(ip, MemOperand(r0, 2 * kPointerSize));
5495 __ mov(ip, Operand(argc.immediate())); 5489 // FunctionCallbackInfo::is_construct_call_ = 0
5496 __ str(ip, MemOperand(r0, 2 * kPointerSize)); 5490 __ mov(ip, Operand::Zero());
5497 // FunctionCallbackInfo::is_construct_call_ = 0 5491 __ str(ip, MemOperand(r0, 3 * kPointerSize));
5498 __ mov(ip, Operand::Zero());
5499 __ str(ip, MemOperand(r0, 3 * kPointerSize));
5500 } else {
5501 // FunctionCallbackInfo::values_
5502 __ add(ip, scratch, Operand(argc.reg(), LSL, kPointerSizeLog2));
5503 __ add(ip, ip, Operand((FCA::kArgsLength - 1) * kPointerSize));
5504 __ str(ip, MemOperand(r0, 1 * kPointerSize));
5505 // FunctionCallbackInfo::length_ = argc
5506 __ str(argc.reg(), MemOperand(r0, 2 * kPointerSize));
5507 // FunctionCallbackInfo::is_construct_call_
5508 __ add(argc.reg(), argc.reg(), Operand(FCA::kArgsLength + 1));
5509 __ mov(ip, Operand(argc.reg(), LSL, kPointerSizeLog2));
5510 __ str(ip, MemOperand(r0, 3 * kPointerSize));
5511 }
5512 5492
5513 ExternalReference thunk_ref = 5493 ExternalReference thunk_ref =
5514 ExternalReference::invoke_function_callback(masm->isolate()); 5494 ExternalReference::invoke_function_callback(masm->isolate());
5515 5495
5516 AllowExternalCallThatCantCauseGC scope(masm); 5496 AllowExternalCallThatCantCauseGC scope(masm);
5517 MemOperand context_restore_operand( 5497 MemOperand context_restore_operand(
5518 fp, (2 + FCA::kContextSaveIndex) * kPointerSize); 5498 fp, (2 + FCA::kContextSaveIndex) * kPointerSize);
5519 // Stores return the first js argument 5499 // Stores return the first js argument
5520 int return_value_offset = 0; 5500 int return_value_offset = 0;
5521 if (return_first_arg) { 5501 if (is_store()) {
5522 return_value_offset = 2 + FCA::kArgsLength; 5502 return_value_offset = 2 + FCA::kArgsLength;
5523 } else { 5503 } else {
5524 return_value_offset = 2 + FCA::kReturnValueOffset; 5504 return_value_offset = 2 + FCA::kReturnValueOffset;
5525 } 5505 }
5526 MemOperand return_value_operand(fp, return_value_offset * kPointerSize); 5506 MemOperand return_value_operand(fp, return_value_offset * kPointerSize);
5527 int stack_space = 0; 5507 int stack_space = 0;
5528 MemOperand is_construct_call_operand = MemOperand(sp, 4 * kPointerSize); 5508 MemOperand is_construct_call_operand = MemOperand(sp, 4 * kPointerSize);
5529 MemOperand* stack_space_operand = &is_construct_call_operand; 5509 MemOperand* stack_space_operand = &is_construct_call_operand;
5530 if (argc.is_immediate()) { 5510 stack_space = argc() + FCA::kArgsLength + 1;
5531 stack_space = argc.immediate() + FCA::kArgsLength + 1; 5511 stack_space_operand = NULL;
5532 stack_space_operand = NULL; 5512
5533 }
5534 CallApiFunctionAndReturn(masm, api_function_address, thunk_ref, stack_space, 5513 CallApiFunctionAndReturn(masm, api_function_address, thunk_ref, stack_space,
5535 stack_space_operand, return_value_operand, 5514 stack_space_operand, return_value_operand,
5536 &context_restore_operand); 5515 &context_restore_operand);
5537 } 5516 }
5538 5517
5539 5518
5540 void CallApiFunctionStub::Generate(MacroAssembler* masm) {
5541 bool call_data_undefined = this->call_data_undefined();
5542 CallApiFunctionStubHelper(masm, ParameterCount(r3), false,
5543 call_data_undefined, false);
5544 }
5545
5546
5547 void CallApiAccessorStub::Generate(MacroAssembler* masm) {
5548 bool is_store = this->is_store();
5549 int argc = this->argc();
5550 bool call_data_undefined = this->call_data_undefined();
5551 bool is_lazy = this->is_lazy();
5552 CallApiFunctionStubHelper(masm, ParameterCount(argc), is_store,
5553 call_data_undefined, is_lazy);
5554 }
5555
5556
5557 void CallApiGetterStub::Generate(MacroAssembler* masm) { 5519 void CallApiGetterStub::Generate(MacroAssembler* masm) {
5558 // ----------- S t a t e ------------- 5520 // ----------- S t a t e -------------
5559 // -- sp[0] : name 5521 // -- sp[0] : name
5560 // -- sp[4 .. (4 + kArgsLength*4)] : v8::PropertyCallbackInfo::args_ 5522 // -- sp[4 .. (4 + kArgsLength*4)] : v8::PropertyCallbackInfo::args_
5561 // -- ... 5523 // -- ...
5562 // -- r2 : api_function_address 5524 // -- r2 : api_function_address
5563 // ----------------------------------- 5525 // -----------------------------------
5564 5526
5565 Register api_function_address = ApiGetterDescriptor::function_address(); 5527 Register api_function_address = ApiGetterDescriptor::function_address();
5566 DCHECK(api_function_address.is(r2)); 5528 DCHECK(api_function_address.is(r2));
(...skipping 24 matching lines...) Expand all
5591 kStackUnwindSpace, NULL, return_value_operand, NULL); 5553 kStackUnwindSpace, NULL, return_value_operand, NULL);
5592 } 5554 }
5593 5555
5594 5556
5595 #undef __ 5557 #undef __
5596 5558
5597 } // namespace internal 5559 } // namespace internal
5598 } // namespace v8 5560 } // namespace v8
5599 5561
5600 #endif // V8_TARGET_ARCH_ARM 5562 #endif // V8_TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « no previous file | src/arm/interface-descriptors-arm.cc » ('j') | src/compiler/fast-accessor-assembler.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698