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

Side by Side Diff: src/s390/code-stubs-s390.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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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_S390 5 #if V8_TARGET_ARCH_S390
6 6
7 #include "src/code-stubs.h" 7 #include "src/code-stubs.h"
8 #include "src/base/bits.h" 8 #include "src/base/bits.h"
9 #include "src/bootstrapper.h" 9 #include "src/bootstrapper.h"
10 #include "src/codegen.h" 10 #include "src/codegen.h"
(...skipping 5525 matching lines...) Expand 10 before | Expand all | Expand 10 after
5536 __ StoreP(r7, MemOperand(r9, kLimitOffset)); 5536 __ StoreP(r7, MemOperand(r9, kLimitOffset));
5537 __ LoadRR(r6, r2); 5537 __ LoadRR(r6, r2);
5538 __ PrepareCallCFunction(1, r7); 5538 __ PrepareCallCFunction(1, r7);
5539 __ mov(r2, Operand(ExternalReference::isolate_address(isolate))); 5539 __ mov(r2, Operand(ExternalReference::isolate_address(isolate)));
5540 __ CallCFunction(ExternalReference::delete_handle_scope_extensions(isolate), 5540 __ CallCFunction(ExternalReference::delete_handle_scope_extensions(isolate),
5541 1); 5541 1);
5542 __ LoadRR(r2, r6); 5542 __ LoadRR(r2, r6);
5543 __ b(&leave_exit_frame, Label::kNear); 5543 __ b(&leave_exit_frame, Label::kNear);
5544 } 5544 }
5545 5545
5546 static void CallApiFunctionStubHelper(MacroAssembler* masm, 5546 void CallApiCallbackStub::Generate(MacroAssembler* masm) {
5547 const ParameterCount& argc,
5548 bool return_first_arg,
5549 bool call_data_undefined, bool is_lazy) {
5550 // ----------- S t a t e ------------- 5547 // ----------- S t a t e -------------
5551 // -- r2 : callee 5548 // -- r2 : callee
5552 // -- r6 : call_data 5549 // -- r6 : call_data
5553 // -- r4 : holder 5550 // -- r4 : holder
5554 // -- r3 : api_function_address 5551 // -- r3 : api_function_address
5555 // -- r5 : number of arguments if argc is a register
5556 // -- cp : context 5552 // -- cp : context
5557 // -- 5553 // --
5558 // -- sp[0] : last argument 5554 // -- sp[0] : last argument
5559 // -- ... 5555 // -- ...
5560 // -- sp[(argc - 1)* 4] : first argument 5556 // -- sp[(argc - 1)* 4] : first argument
5561 // -- sp[argc * 4] : receiver 5557 // -- sp[argc * 4] : receiver
5562 // ----------------------------------- 5558 // -----------------------------------
5563 5559
5564 Register callee = r2; 5560 Register callee = r2;
5565 Register call_data = r6; 5561 Register call_data = r6;
5566 Register holder = r4; 5562 Register holder = r4;
5567 Register api_function_address = r3; 5563 Register api_function_address = r3;
5568 Register context = cp; 5564 Register context = cp;
5569 5565
5570 typedef FunctionCallbackArguments FCA; 5566 typedef FunctionCallbackArguments FCA;
5571 5567
5572 STATIC_ASSERT(FCA::kContextSaveIndex == 6); 5568 STATIC_ASSERT(FCA::kContextSaveIndex == 6);
5573 STATIC_ASSERT(FCA::kCalleeIndex == 5); 5569 STATIC_ASSERT(FCA::kCalleeIndex == 5);
5574 STATIC_ASSERT(FCA::kDataIndex == 4); 5570 STATIC_ASSERT(FCA::kDataIndex == 4);
5575 STATIC_ASSERT(FCA::kReturnValueOffset == 3); 5571 STATIC_ASSERT(FCA::kReturnValueOffset == 3);
5576 STATIC_ASSERT(FCA::kReturnValueDefaultValueIndex == 2); 5572 STATIC_ASSERT(FCA::kReturnValueDefaultValueIndex == 2);
5577 STATIC_ASSERT(FCA::kIsolateIndex == 1); 5573 STATIC_ASSERT(FCA::kIsolateIndex == 1);
5578 STATIC_ASSERT(FCA::kHolderIndex == 0); 5574 STATIC_ASSERT(FCA::kHolderIndex == 0);
5579 STATIC_ASSERT(FCA::kArgsLength == 7); 5575 STATIC_ASSERT(FCA::kArgsLength == 7);
5580 5576
5581 DCHECK(argc.is_immediate() || r2.is(argc.reg()));
5582
5583 // context save 5577 // context save
5584 __ push(context); 5578 __ push(context);
5585 if (!is_lazy) { 5579 if (!is_lazy) {
5586 // load context from callee 5580 // load context from callee
5587 __ LoadP(context, FieldMemOperand(callee, JSFunction::kContextOffset)); 5581 __ LoadP(context, FieldMemOperand(callee, JSFunction::kContextOffset));
5588 } 5582 }
5589 5583
5590 // callee 5584 // callee
5591 __ push(callee); 5585 __ push(callee);
5592 5586
5593 // call data 5587 // call data
5594 __ push(call_data); 5588 __ push(call_data);
5595 5589
5596 Register scratch = call_data; 5590 Register scratch = call_data;
5597 if (!call_data_undefined) { 5591 if (!call_data_undefined()) {
5598 __ LoadRoot(scratch, Heap::kUndefinedValueRootIndex); 5592 __ LoadRoot(scratch, Heap::kUndefinedValueRootIndex);
5599 } 5593 }
5600 // return value 5594 // return value
5601 __ push(scratch); 5595 __ push(scratch);
5602 // return value default 5596 // return value default
5603 __ push(scratch); 5597 __ push(scratch);
5604 // isolate 5598 // isolate
5605 __ mov(scratch, Operand(ExternalReference::isolate_address(masm->isolate()))); 5599 __ mov(scratch, Operand(ExternalReference::isolate_address(masm->isolate())));
5606 __ push(scratch); 5600 __ push(scratch);
5607 // holder 5601 // holder
(...skipping 15 matching lines...) Expand all
5623 5617
5624 FrameScope frame_scope(masm, StackFrame::MANUAL); 5618 FrameScope frame_scope(masm, StackFrame::MANUAL);
5625 __ EnterExitFrame(false, kApiStackSpace); 5619 __ EnterExitFrame(false, kApiStackSpace);
5626 5620
5627 DCHECK(!api_function_address.is(r2) && !scratch.is(r2)); 5621 DCHECK(!api_function_address.is(r2) && !scratch.is(r2));
5628 // r2 = FunctionCallbackInfo& 5622 // r2 = FunctionCallbackInfo&
5629 // Arguments is after the return address. 5623 // Arguments is after the return address.
5630 __ AddP(r2, sp, Operand(kFunctionCallbackInfoOffset)); 5624 __ AddP(r2, sp, Operand(kFunctionCallbackInfoOffset));
5631 // FunctionCallbackInfo::implicit_args_ 5625 // FunctionCallbackInfo::implicit_args_
5632 __ StoreP(scratch, MemOperand(r2, 0 * kPointerSize)); 5626 __ StoreP(scratch, MemOperand(r2, 0 * kPointerSize));
5633 if (argc.is_immediate()) { 5627 // FunctionCallbackInfo::values_
5634 // FunctionCallbackInfo::values_ 5628 __ AddP(ip, scratch, Operand((FCA::kArgsLength - 1 + argc()) * kPointerSize));
5635 __ AddP(ip, scratch, 5629 __ StoreP(ip, MemOperand(r2, 1 * kPointerSize));
5636 Operand((FCA::kArgsLength - 1 + argc.immediate()) * kPointerSize)); 5630 // FunctionCallbackInfo::length_ = argc
5637 __ StoreP(ip, MemOperand(r2, 1 * kPointerSize)); 5631 __ LoadImmP(ip, Operand(argc()));
5638 // FunctionCallbackInfo::length_ = argc 5632 __ StoreW(ip, MemOperand(r2, 2 * kPointerSize));
5639 __ LoadImmP(ip, Operand(argc.immediate())); 5633 // FunctionCallbackInfo::is_construct_call_ = 0
5640 __ StoreW(ip, MemOperand(r2, 2 * kPointerSize)); 5634 __ LoadImmP(ip, Operand::Zero());
5641 // FunctionCallbackInfo::is_construct_call_ = 0 5635 __ StoreW(ip, MemOperand(r2, 2 * kPointerSize + kIntSize));
5642 __ LoadImmP(ip, Operand::Zero());
5643 __ StoreW(ip, MemOperand(r2, 2 * kPointerSize + kIntSize));
5644 } else {
5645 __ ShiftLeftP(ip, argc.reg(), Operand(kPointerSizeLog2));
5646 __ AddP(ip, ip, Operand((FCA::kArgsLength - 1) * kPointerSize));
5647 // FunctionCallbackInfo::values_
5648 __ AddP(r0, scratch, ip);
5649 __ StoreP(r0, MemOperand(r2, 1 * kPointerSize));
5650 // FunctionCallbackInfo::length_ = argc
5651 __ StoreW(argc.reg(), MemOperand(r2, 2 * kPointerSize));
5652 // FunctionCallbackInfo::is_construct_call_
5653 __ StoreW(ip, MemOperand(r2, 2 * kPointerSize + kIntSize));
5654 }
5655 5636
5656 ExternalReference thunk_ref = 5637 ExternalReference thunk_ref =
5657 ExternalReference::invoke_function_callback(masm->isolate()); 5638 ExternalReference::invoke_function_callback(masm->isolate());
5658 5639
5659 AllowExternalCallThatCantCauseGC scope(masm); 5640 AllowExternalCallThatCantCauseGC scope(masm);
5660 MemOperand context_restore_operand( 5641 MemOperand context_restore_operand(
5661 fp, (2 + FCA::kContextSaveIndex) * kPointerSize); 5642 fp, (2 + FCA::kContextSaveIndex) * kPointerSize);
5662 // Stores return the first js argument 5643 // Stores return the first js argument
5663 int return_value_offset = 0; 5644 int return_value_offset = 0;
5664 if (return_first_arg) { 5645 if (is_store()) {
5665 return_value_offset = 2 + FCA::kArgsLength; 5646 return_value_offset = 2 + FCA::kArgsLength;
5666 } else { 5647 } else {
5667 return_value_offset = 2 + FCA::kReturnValueOffset; 5648 return_value_offset = 2 + FCA::kReturnValueOffset;
5668 } 5649 }
5669 MemOperand return_value_operand(fp, return_value_offset * kPointerSize); 5650 MemOperand return_value_operand(fp, return_value_offset * kPointerSize);
5670 int stack_space = 0; 5651 int stack_space = 0;
5671 MemOperand is_construct_call_operand = 5652 MemOperand is_construct_call_operand =
5672 MemOperand(sp, kFunctionCallbackInfoOffset + 2 * kPointerSize + kIntSize); 5653 MemOperand(sp, kFunctionCallbackInfoOffset + 2 * kPointerSize + kIntSize);
5673 MemOperand* stack_space_operand = &is_construct_call_operand; 5654 MemOperand* stack_space_operand = &is_construct_call_operand;
5674 if (argc.is_immediate()) { 5655 stack_space = argc() + FCA::kArgsLength + 1;
5675 stack_space = argc.immediate() + FCA::kArgsLength + 1; 5656 stack_space_operand = NULL;
5676 stack_space_operand = NULL;
5677 }
5678 CallApiFunctionAndReturn(masm, api_function_address, thunk_ref, stack_space, 5657 CallApiFunctionAndReturn(masm, api_function_address, thunk_ref, stack_space,
5679 stack_space_operand, return_value_operand, 5658 stack_space_operand, return_value_operand,
5680 &context_restore_operand); 5659 &context_restore_operand);
5681 } 5660 }
5682 5661
5683 void CallApiFunctionStub::Generate(MacroAssembler* masm) {
5684 bool call_data_undefined = this->call_data_undefined();
5685 CallApiFunctionStubHelper(masm, ParameterCount(r6), false,
5686 call_data_undefined, false);
5687 }
5688
5689 void CallApiAccessorStub::Generate(MacroAssembler* masm) {
5690 bool is_store = this->is_store();
5691 int argc = this->argc();
5692 bool call_data_undefined = this->call_data_undefined();
5693 bool is_lazy = this->is_lazy();
5694 CallApiFunctionStubHelper(masm, ParameterCount(argc), is_store,
5695 call_data_undefined, is_lazy);
5696 }
5697
5698 void CallApiGetterStub::Generate(MacroAssembler* masm) { 5662 void CallApiGetterStub::Generate(MacroAssembler* masm) {
5699 // ----------- S t a t e ------------- 5663 // ----------- S t a t e -------------
5700 // -- sp[0] : name 5664 // -- sp[0] : name
5701 // -- sp[4 .. (4 + kArgsLength*4)] : v8::PropertyCallbackInfo::args_ 5665 // -- sp[4 .. (4 + kArgsLength*4)] : v8::PropertyCallbackInfo::args_
5702 // -- ... 5666 // -- ...
5703 // -- r4 : api_function_address 5667 // -- r4 : api_function_address
5704 // ----------------------------------- 5668 // -----------------------------------
5705 5669
5706 Register api_function_address = ApiGetterDescriptor::function_address(); 5670 Register api_function_address = ApiGetterDescriptor::function_address();
5707 int arg0Slot = 0; 5671 int arg0Slot = 0;
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
5761 CallApiFunctionAndReturn(masm, api_function_address, thunk_ref, 5725 CallApiFunctionAndReturn(masm, api_function_address, thunk_ref,
5762 kStackUnwindSpace, NULL, return_value_operand, NULL); 5726 kStackUnwindSpace, NULL, return_value_operand, NULL);
5763 } 5727 }
5764 5728
5765 #undef __ 5729 #undef __
5766 5730
5767 } // namespace internal 5731 } // namespace internal
5768 } // namespace v8 5732 } // namespace v8
5769 5733
5770 #endif // V8_TARGET_ARCH_S390 5734 #endif // V8_TARGET_ARCH_S390
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698