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