OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
664 return static_cast<int>(offset); | 664 return static_cast<int>(offset); |
665 } | 665 } |
666 | 666 |
667 | 667 |
668 void MacroAssembler::PrepareCallApiFunction(int arg_stack_space) { | 668 void MacroAssembler::PrepareCallApiFunction(int arg_stack_space) { |
669 EnterApiExitFrame(arg_stack_space); | 669 EnterApiExitFrame(arg_stack_space); |
670 } | 670 } |
671 | 671 |
672 | 672 |
673 void MacroAssembler::CallApiFunctionAndReturn( | 673 void MacroAssembler::CallApiFunctionAndReturn( |
674 Address function_address, | 674 Register function_address, |
675 Address thunk_address, | 675 Address thunk_address, |
676 Register thunk_last_arg, | 676 Register thunk_last_arg, |
677 int stack_space, | 677 int stack_space, |
678 Operand return_value_operand, | 678 Operand return_value_operand, |
679 Operand* context_restore_operand) { | 679 Operand* context_restore_operand) { |
680 Label prologue; | 680 Label prologue; |
681 Label promote_scheduled_exception; | 681 Label promote_scheduled_exception; |
682 Label exception_handled; | 682 Label exception_handled; |
683 Label delete_allocated_handles; | 683 Label delete_allocated_handles; |
684 Label leave_exit_frame; | 684 Label leave_exit_frame; |
685 Label write_back; | 685 Label write_back; |
686 | 686 |
687 Factory* factory = isolate()->factory(); | 687 Factory* factory = isolate()->factory(); |
688 ExternalReference next_address = | 688 ExternalReference next_address = |
689 ExternalReference::handle_scope_next_address(isolate()); | 689 ExternalReference::handle_scope_next_address(isolate()); |
690 const int kNextOffset = 0; | 690 const int kNextOffset = 0; |
691 const int kLimitOffset = Offset( | 691 const int kLimitOffset = Offset( |
692 ExternalReference::handle_scope_limit_address(isolate()), | 692 ExternalReference::handle_scope_limit_address(isolate()), |
693 next_address); | 693 next_address); |
694 const int kLevelOffset = Offset( | 694 const int kLevelOffset = Offset( |
695 ExternalReference::handle_scope_level_address(isolate()), | 695 ExternalReference::handle_scope_level_address(isolate()), |
696 next_address); | 696 next_address); |
697 ExternalReference scheduled_exception_address = | 697 ExternalReference scheduled_exception_address = |
698 ExternalReference::scheduled_exception_address(isolate()); | 698 ExternalReference::scheduled_exception_address(isolate()); |
699 | 699 |
| 700 ASSERT(rdx.is(function_address)); |
700 // Allocate HandleScope in callee-save registers. | 701 // Allocate HandleScope in callee-save registers. |
701 Register prev_next_address_reg = r14; | 702 Register prev_next_address_reg = r14; |
702 Register prev_limit_reg = rbx; | 703 Register prev_limit_reg = rbx; |
703 Register base_reg = r15; | 704 Register base_reg = r15; |
704 Move(base_reg, next_address); | 705 Move(base_reg, next_address); |
705 movp(prev_next_address_reg, Operand(base_reg, kNextOffset)); | 706 movp(prev_next_address_reg, Operand(base_reg, kNextOffset)); |
706 movp(prev_limit_reg, Operand(base_reg, kLimitOffset)); | 707 movp(prev_limit_reg, Operand(base_reg, kLimitOffset)); |
707 addl(Operand(base_reg, kLevelOffset), Immediate(1)); | 708 addl(Operand(base_reg, kLevelOffset), Immediate(1)); |
708 | 709 |
709 if (FLAG_log_timer_events) { | 710 if (FLAG_log_timer_events) { |
710 FrameScope frame(this, StackFrame::MANUAL); | 711 FrameScope frame(this, StackFrame::MANUAL); |
711 PushSafepointRegisters(); | 712 PushSafepointRegisters(); |
712 PrepareCallCFunction(1); | 713 PrepareCallCFunction(1); |
713 LoadAddress(arg_reg_1, ExternalReference::isolate_address(isolate())); | 714 LoadAddress(arg_reg_1, ExternalReference::isolate_address(isolate())); |
714 CallCFunction(ExternalReference::log_enter_external_function(isolate()), 1); | 715 CallCFunction(ExternalReference::log_enter_external_function(isolate()), 1); |
715 PopSafepointRegisters(); | 716 PopSafepointRegisters(); |
716 } | 717 } |
717 | 718 |
718 | 719 |
719 Label profiler_disabled; | 720 Label profiler_disabled; |
720 Label end_profiler_check; | 721 Label end_profiler_check; |
721 bool* is_profiling_flag = | 722 bool* is_profiling_flag = |
722 isolate()->cpu_profiler()->is_profiling_address(); | 723 isolate()->cpu_profiler()->is_profiling_address(); |
723 STATIC_ASSERT(sizeof(*is_profiling_flag) == 1); | 724 STATIC_ASSERT(sizeof(*is_profiling_flag) == 1); |
724 Move(rax, is_profiling_flag, RelocInfo::EXTERNAL_REFERENCE); | 725 Move(rax, is_profiling_flag, RelocInfo::EXTERNAL_REFERENCE); |
725 cmpb(Operand(rax, 0), Immediate(0)); | 726 cmpb(Operand(rax, 0), Immediate(0)); |
726 j(zero, &profiler_disabled); | 727 j(zero, &profiler_disabled); |
727 | 728 |
728 // Third parameter is the address of the actual getter function. | 729 // Third parameter is the address of the actual getter function. |
729 Move(thunk_last_arg, function_address, RelocInfo::EXTERNAL_REFERENCE); | 730 Move(thunk_last_arg, function_address); |
730 Move(rax, thunk_address, RelocInfo::EXTERNAL_REFERENCE); | 731 Move(rax, thunk_address, RelocInfo::EXTERNAL_REFERENCE); |
731 jmp(&end_profiler_check); | 732 jmp(&end_profiler_check); |
732 | 733 |
733 bind(&profiler_disabled); | 734 bind(&profiler_disabled); |
734 // Call the api function! | 735 // Call the api function! |
735 Move(rax, reinterpret_cast<Address>(function_address), | 736 Move(rax, function_address); |
736 RelocInfo::EXTERNAL_REFERENCE); | |
737 | 737 |
738 bind(&end_profiler_check); | 738 bind(&end_profiler_check); |
739 | 739 |
740 // Call the api function! | 740 // Call the api function! |
741 call(rax); | 741 call(rax); |
742 | 742 |
743 if (FLAG_log_timer_events) { | 743 if (FLAG_log_timer_events) { |
744 FrameScope frame(this, StackFrame::MANUAL); | 744 FrameScope frame(this, StackFrame::MANUAL); |
745 PushSafepointRegisters(); | 745 PushSafepointRegisters(); |
746 PrepareCallCFunction(1); | 746 PrepareCallCFunction(1); |
(...skipping 4246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4993 j(equal, found); | 4993 j(equal, found); |
4994 movp(current, FieldOperand(current, Map::kPrototypeOffset)); | 4994 movp(current, FieldOperand(current, Map::kPrototypeOffset)); |
4995 CompareRoot(current, Heap::kNullValueRootIndex); | 4995 CompareRoot(current, Heap::kNullValueRootIndex); |
4996 j(not_equal, &loop_again); | 4996 j(not_equal, &loop_again); |
4997 } | 4997 } |
4998 | 4998 |
4999 | 4999 |
5000 } } // namespace v8::internal | 5000 } } // namespace v8::internal |
5001 | 5001 |
5002 #endif // V8_TARGET_ARCH_X64 | 5002 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |