| OLD | NEW |
| 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 #include "src/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #if V8_TARGET_ARCH_X87 | 7 #if V8_TARGET_ARCH_X87 |
| 8 | 8 |
| 9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
| 10 #include "src/bootstrapper.h" | 10 #include "src/bootstrapper.h" |
| (...skipping 4525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4536 __ mov(eax, edi); | 4536 __ mov(eax, edi); |
| 4537 __ jmp(&leave_exit_frame); | 4537 __ jmp(&leave_exit_frame); |
| 4538 } | 4538 } |
| 4539 | 4539 |
| 4540 | 4540 |
| 4541 static void CallApiFunctionStubHelper(MacroAssembler* masm, | 4541 static void CallApiFunctionStubHelper(MacroAssembler* masm, |
| 4542 const ParameterCount& argc, | 4542 const ParameterCount& argc, |
| 4543 bool return_first_arg, | 4543 bool return_first_arg, |
| 4544 bool call_data_undefined) { | 4544 bool call_data_undefined) { |
| 4545 // ----------- S t a t e ------------- | 4545 // ----------- S t a t e ------------- |
| 4546 // -- eax : callee | 4546 // -- edi : callee |
| 4547 // -- ebx : call_data | 4547 // -- ebx : call_data |
| 4548 // -- ecx : holder | 4548 // -- ecx : holder |
| 4549 // -- edx : api_function_address | 4549 // -- edx : api_function_address |
| 4550 // -- esi : context | 4550 // -- esi : context |
| 4551 // -- edi : number of arguments if argc is a register | 4551 // -- eax : number of arguments if argc is a register |
| 4552 // -- | 4552 // -- |
| 4553 // -- esp[0] : return address | 4553 // -- esp[0] : return address |
| 4554 // -- esp[4] : last argument | 4554 // -- esp[4] : last argument |
| 4555 // -- ... | 4555 // -- ... |
| 4556 // -- esp[argc * 4] : first argument | 4556 // -- esp[argc * 4] : first argument |
| 4557 // -- esp[(argc + 1) * 4] : receiver | 4557 // -- esp[(argc + 1) * 4] : receiver |
| 4558 // ----------------------------------- | 4558 // ----------------------------------- |
| 4559 | 4559 |
| 4560 Register callee = eax; | 4560 Register callee = edi; |
| 4561 Register call_data = ebx; | 4561 Register call_data = ebx; |
| 4562 Register holder = ecx; | 4562 Register holder = ecx; |
| 4563 Register api_function_address = edx; | 4563 Register api_function_address = edx; |
| 4564 Register context = esi; | 4564 Register context = esi; |
| 4565 Register return_address = eax; |
| 4565 | 4566 |
| 4566 typedef FunctionCallbackArguments FCA; | 4567 typedef FunctionCallbackArguments FCA; |
| 4567 | 4568 |
| 4568 STATIC_ASSERT(FCA::kContextSaveIndex == 6); | 4569 STATIC_ASSERT(FCA::kContextSaveIndex == 6); |
| 4569 STATIC_ASSERT(FCA::kCalleeIndex == 5); | 4570 STATIC_ASSERT(FCA::kCalleeIndex == 5); |
| 4570 STATIC_ASSERT(FCA::kDataIndex == 4); | 4571 STATIC_ASSERT(FCA::kDataIndex == 4); |
| 4571 STATIC_ASSERT(FCA::kReturnValueOffset == 3); | 4572 STATIC_ASSERT(FCA::kReturnValueOffset == 3); |
| 4572 STATIC_ASSERT(FCA::kReturnValueDefaultValueIndex == 2); | 4573 STATIC_ASSERT(FCA::kReturnValueDefaultValueIndex == 2); |
| 4573 STATIC_ASSERT(FCA::kIsolateIndex == 1); | 4574 STATIC_ASSERT(FCA::kIsolateIndex == 1); |
| 4574 STATIC_ASSERT(FCA::kHolderIndex == 0); | 4575 STATIC_ASSERT(FCA::kHolderIndex == 0); |
| 4575 STATIC_ASSERT(FCA::kArgsLength == 7); | 4576 STATIC_ASSERT(FCA::kArgsLength == 7); |
| 4576 | 4577 |
| 4577 DCHECK(argc.is_immediate() || edi.is(argc.reg())); | 4578 DCHECK(argc.is_immediate() || eax.is(argc.reg())); |
| 4578 | 4579 |
| 4579 // pop return address and save context | 4580 if (argc.is_immediate()) { |
| 4580 __ xchg(context, Operand(esp, 0)); | 4581 __ pop(return_address); |
| 4582 // context save. |
| 4583 __ push(context); |
| 4584 } else { |
| 4585 // pop return address and save context |
| 4586 __ xchg(context, Operand(esp, 0)); |
| 4587 return_address = context; |
| 4588 } |
| 4581 | 4589 |
| 4582 // callee | 4590 // callee |
| 4583 __ push(callee); | 4591 __ push(callee); |
| 4584 | 4592 |
| 4585 // call data | 4593 // call data |
| 4586 __ push(call_data); | 4594 __ push(call_data); |
| 4587 | 4595 |
| 4588 Register scratch = call_data; | 4596 Register scratch = call_data; |
| 4589 if (!call_data_undefined) { | 4597 if (!call_data_undefined) { |
| 4590 // return value | 4598 // return value |
| 4591 __ push(Immediate(masm->isolate()->factory()->undefined_value())); | 4599 __ push(Immediate(masm->isolate()->factory()->undefined_value())); |
| 4592 // return value default | 4600 // return value default |
| 4593 __ push(Immediate(masm->isolate()->factory()->undefined_value())); | 4601 __ push(Immediate(masm->isolate()->factory()->undefined_value())); |
| 4594 } else { | 4602 } else { |
| 4595 // return value | 4603 // return value |
| 4596 __ push(scratch); | 4604 __ push(scratch); |
| 4597 // return value default | 4605 // return value default |
| 4598 __ push(scratch); | 4606 __ push(scratch); |
| 4599 } | 4607 } |
| 4600 // isolate | 4608 // isolate |
| 4601 __ push(Immediate(reinterpret_cast<int>(masm->isolate()))); | 4609 __ push(Immediate(reinterpret_cast<int>(masm->isolate()))); |
| 4602 // holder | 4610 // holder |
| 4603 __ push(holder); | 4611 __ push(holder); |
| 4604 | 4612 |
| 4605 __ mov(scratch, esp); | 4613 __ mov(scratch, esp); |
| 4606 | 4614 |
| 4607 // push return address | 4615 // push return address |
| 4608 __ push(context); | 4616 __ push(return_address); |
| 4609 | 4617 |
| 4610 // load context from callee | 4618 // load context from callee |
| 4611 __ mov(context, FieldOperand(callee, JSFunction::kContextOffset)); | 4619 __ mov(context, FieldOperand(callee, JSFunction::kContextOffset)); |
| 4612 | 4620 |
| 4613 // API function gets reference to the v8::Arguments. If CPU profiler | 4621 // API function gets reference to the v8::Arguments. If CPU profiler |
| 4614 // is enabled wrapper function will be called and we need to pass | 4622 // is enabled wrapper function will be called and we need to pass |
| 4615 // address of the callback as additional parameter, always allocate | 4623 // address of the callback as additional parameter, always allocate |
| 4616 // space for it. | 4624 // space for it. |
| 4617 const int kApiArgc = 1 + 1; | 4625 const int kApiArgc = 1 + 1; |
| 4618 | 4626 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4671 stack_space_operand = nullptr; | 4679 stack_space_operand = nullptr; |
| 4672 } | 4680 } |
| 4673 CallApiFunctionAndReturn(masm, api_function_address, thunk_ref, | 4681 CallApiFunctionAndReturn(masm, api_function_address, thunk_ref, |
| 4674 ApiParameterOperand(1), stack_space, | 4682 ApiParameterOperand(1), stack_space, |
| 4675 stack_space_operand, return_value_operand, | 4683 stack_space_operand, return_value_operand, |
| 4676 &context_restore_operand); | 4684 &context_restore_operand); |
| 4677 } | 4685 } |
| 4678 | 4686 |
| 4679 | 4687 |
| 4680 void CallApiFunctionStub::Generate(MacroAssembler* masm) { | 4688 void CallApiFunctionStub::Generate(MacroAssembler* masm) { |
| 4681 // TODO(dcarney): make eax contain the function address. | |
| 4682 bool call_data_undefined = this->call_data_undefined(); | 4689 bool call_data_undefined = this->call_data_undefined(); |
| 4683 CallApiFunctionStubHelper(masm, ParameterCount(edi), false, | 4690 CallApiFunctionStubHelper(masm, ParameterCount(eax), false, |
| 4684 call_data_undefined); | 4691 call_data_undefined); |
| 4685 } | 4692 } |
| 4686 | 4693 |
| 4687 | 4694 |
| 4688 void CallApiAccessorStub::Generate(MacroAssembler* masm) { | 4695 void CallApiAccessorStub::Generate(MacroAssembler* masm) { |
| 4689 bool is_store = this->is_store(); | 4696 bool is_store = this->is_store(); |
| 4690 int argc = this->argc(); | 4697 int argc = this->argc(); |
| 4691 bool call_data_undefined = this->call_data_undefined(); | 4698 bool call_data_undefined = this->call_data_undefined(); |
| 4692 CallApiFunctionStubHelper(masm, ParameterCount(argc), is_store, | 4699 CallApiFunctionStubHelper(masm, ParameterCount(argc), is_store, |
| 4693 call_data_undefined); | 4700 call_data_undefined); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4729 ApiParameterOperand(2), kStackSpace, nullptr, | 4736 ApiParameterOperand(2), kStackSpace, nullptr, |
| 4730 Operand(ebp, 7 * kPointerSize), NULL); | 4737 Operand(ebp, 7 * kPointerSize), NULL); |
| 4731 } | 4738 } |
| 4732 | 4739 |
| 4733 | 4740 |
| 4734 #undef __ | 4741 #undef __ |
| 4735 | 4742 |
| 4736 } } // namespace v8::internal | 4743 } } // namespace v8::internal |
| 4737 | 4744 |
| 4738 #endif // V8_TARGET_ARCH_X87 | 4745 #endif // V8_TARGET_ARCH_X87 |
| OLD | NEW |