| 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 #if V8_TARGET_ARCH_IA32 | 5 #if V8_TARGET_ARCH_IA32 |
| 6 | 6 |
| 7 #include "src/code-factory.h" | 7 #include "src/code-factory.h" |
| 8 #include "src/codegen.h" | 8 #include "src/codegen.h" |
| 9 #include "src/deoptimizer.h" | 9 #include "src/deoptimizer.h" |
| 10 #include "src/full-codegen/full-codegen.h" | 10 #include "src/full-codegen/full-codegen.h" |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 __ PushReturnAddressFrom(ecx); | 53 __ PushReturnAddressFrom(ecx); |
| 54 } | 54 } |
| 55 | 55 |
| 56 // JumpToExternalReference expects eax to contain the number of arguments | 56 // JumpToExternalReference expects eax to contain the number of arguments |
| 57 // including the receiver and the extra arguments. | 57 // including the receiver and the extra arguments. |
| 58 __ add(eax, Immediate(num_extra_args + 1)); | 58 __ add(eax, Immediate(num_extra_args + 1)); |
| 59 | 59 |
| 60 __ JumpToExternalReference(ExternalReference(id, masm->isolate())); | 60 __ JumpToExternalReference(ExternalReference(id, masm->isolate())); |
| 61 } | 61 } |
| 62 | 62 |
| 63 | 63 static void GenerateTailCallToReturnedCode(MacroAssembler* masm, |
| 64 static void CallRuntimePassFunction( | 64 Runtime::FunctionId function_id) { |
| 65 MacroAssembler* masm, Runtime::FunctionId function_id) { | |
| 66 // ----------- S t a t e ------------- | 65 // ----------- S t a t e ------------- |
| 66 // -- eax : argument count (preserved for callee) |
| 67 // -- edx : new target (preserved for callee) | 67 // -- edx : new target (preserved for callee) |
| 68 // -- edi : target function (preserved for callee) | 68 // -- edi : target function (preserved for callee) |
| 69 // ----------------------------------- | 69 // ----------------------------------- |
| 70 { |
| 71 FrameScope scope(masm, StackFrame::INTERNAL); |
| 72 // Push the number of arguments to the callee. |
| 73 __ SmiTag(eax); |
| 74 __ push(eax); |
| 75 // Push a copy of the target function and the new target. |
| 76 __ push(edi); |
| 77 __ push(edx); |
| 78 // Function is also the parameter to the runtime call. |
| 79 __ push(edi); |
| 70 | 80 |
| 71 FrameScope scope(masm, StackFrame::INTERNAL); | 81 __ CallRuntime(function_id, 1); |
| 72 // Push a copy of the target function and the new target. | 82 __ mov(ebx, eax); |
| 73 __ push(edi); | |
| 74 __ push(edx); | |
| 75 // Function is also the parameter to the runtime call. | |
| 76 __ push(edi); | |
| 77 | 83 |
| 78 __ CallRuntime(function_id, 1); | 84 // Restore target function and new target. |
| 79 // Restore target function and new target. | 85 __ pop(edx); |
| 80 __ pop(edx); | 86 __ pop(edi); |
| 81 __ pop(edi); | 87 __ pop(eax); |
| 88 __ SmiUntag(eax); |
| 89 } |
| 90 |
| 91 __ lea(ebx, FieldOperand(ebx, Code::kHeaderSize)); |
| 92 __ jmp(ebx); |
| 82 } | 93 } |
| 83 | 94 |
| 84 | |
| 85 static void GenerateTailCallToSharedCode(MacroAssembler* masm) { | 95 static void GenerateTailCallToSharedCode(MacroAssembler* masm) { |
| 86 __ mov(eax, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset)); | 96 __ mov(ebx, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset)); |
| 87 __ mov(eax, FieldOperand(eax, SharedFunctionInfo::kCodeOffset)); | 97 __ mov(ebx, FieldOperand(ebx, SharedFunctionInfo::kCodeOffset)); |
| 88 __ lea(eax, FieldOperand(eax, Code::kHeaderSize)); | 98 __ lea(ebx, FieldOperand(ebx, Code::kHeaderSize)); |
| 89 __ jmp(eax); | 99 __ jmp(ebx); |
| 90 } | 100 } |
| 91 | 101 |
| 92 | |
| 93 static void GenerateTailCallToReturnedCode(MacroAssembler* masm) { | |
| 94 __ lea(eax, FieldOperand(eax, Code::kHeaderSize)); | |
| 95 __ jmp(eax); | |
| 96 } | |
| 97 | |
| 98 | |
| 99 void Builtins::Generate_InOptimizationQueue(MacroAssembler* masm) { | 102 void Builtins::Generate_InOptimizationQueue(MacroAssembler* masm) { |
| 100 // Checking whether the queued function is ready for install is optional, | 103 // Checking whether the queued function is ready for install is optional, |
| 101 // since we come across interrupts and stack checks elsewhere. However, | 104 // since we come across interrupts and stack checks elsewhere. However, |
| 102 // not checking may delay installing ready functions, and always checking | 105 // not checking may delay installing ready functions, and always checking |
| 103 // would be quite expensive. A good compromise is to first check against | 106 // would be quite expensive. A good compromise is to first check against |
| 104 // stack limit as a cue for an interrupt signal. | 107 // stack limit as a cue for an interrupt signal. |
| 105 Label ok; | 108 Label ok; |
| 106 ExternalReference stack_limit = | 109 ExternalReference stack_limit = |
| 107 ExternalReference::address_of_stack_limit(masm->isolate()); | 110 ExternalReference::address_of_stack_limit(masm->isolate()); |
| 108 __ cmp(esp, Operand::StaticVariable(stack_limit)); | 111 __ cmp(esp, Operand::StaticVariable(stack_limit)); |
| 109 __ j(above_equal, &ok, Label::kNear); | 112 __ j(above_equal, &ok, Label::kNear); |
| 110 | 113 |
| 111 CallRuntimePassFunction(masm, Runtime::kTryInstallOptimizedCode); | 114 GenerateTailCallToReturnedCode(masm, Runtime::kTryInstallOptimizedCode); |
| 112 GenerateTailCallToReturnedCode(masm); | |
| 113 | 115 |
| 114 __ bind(&ok); | 116 __ bind(&ok); |
| 115 GenerateTailCallToSharedCode(masm); | 117 GenerateTailCallToSharedCode(masm); |
| 116 } | 118 } |
| 117 | 119 |
| 118 | |
| 119 static void Generate_JSConstructStubHelper(MacroAssembler* masm, | 120 static void Generate_JSConstructStubHelper(MacroAssembler* masm, |
| 120 bool is_api_function, | 121 bool is_api_function, |
| 121 bool create_implicit_receiver, | 122 bool create_implicit_receiver, |
| 122 bool check_derived_construct) { | 123 bool check_derived_construct) { |
| 123 // ----------- S t a t e ------------- | 124 // ----------- S t a t e ------------- |
| 124 // -- eax: number of arguments | 125 // -- eax: number of arguments |
| 125 // -- edi: constructor function | 126 // -- edi: constructor function |
| 126 // -- ebx: allocation site or undefined | 127 // -- ebx: allocation site or undefined |
| 127 // -- edx: new target | 128 // -- edx: new target |
| 128 // ----------------------------------- | 129 // ----------------------------------- |
| (...skipping 712 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 841 // This simulates the initial call to bytecode handlers in interpreter entry | 842 // This simulates the initial call to bytecode handlers in interpreter entry |
| 842 // trampoline. The return will never actually be taken, but our stack walker | 843 // trampoline. The return will never actually be taken, but our stack walker |
| 843 // uses this address to determine whether a frame is interpreted. | 844 // uses this address to determine whether a frame is interpreted. |
| 844 __ Push(masm->isolate()->builtins()->InterpreterEntryTrampoline()); | 845 __ Push(masm->isolate()->builtins()->InterpreterEntryTrampoline()); |
| 845 | 846 |
| 846 Generate_EnterBytecodeDispatch(masm); | 847 Generate_EnterBytecodeDispatch(masm); |
| 847 } | 848 } |
| 848 | 849 |
| 849 | 850 |
| 850 void Builtins::Generate_CompileLazy(MacroAssembler* masm) { | 851 void Builtins::Generate_CompileLazy(MacroAssembler* masm) { |
| 851 CallRuntimePassFunction(masm, Runtime::kCompileLazy); | 852 GenerateTailCallToReturnedCode(masm, Runtime::kCompileLazy); |
| 852 GenerateTailCallToReturnedCode(masm); | |
| 853 } | 853 } |
| 854 | 854 |
| 855 | 855 |
| 856 void Builtins::Generate_CompileOptimized(MacroAssembler* masm) { | 856 void Builtins::Generate_CompileOptimized(MacroAssembler* masm) { |
| 857 CallRuntimePassFunction(masm, Runtime::kCompileOptimized_NotConcurrent); | 857 GenerateTailCallToReturnedCode(masm, |
| 858 GenerateTailCallToReturnedCode(masm); | 858 Runtime::kCompileOptimized_NotConcurrent); |
| 859 } | 859 } |
| 860 | 860 |
| 861 | 861 |
| 862 void Builtins::Generate_CompileOptimizedConcurrent(MacroAssembler* masm) { | 862 void Builtins::Generate_CompileOptimizedConcurrent(MacroAssembler* masm) { |
| 863 CallRuntimePassFunction(masm, Runtime::kCompileOptimized_Concurrent); | 863 GenerateTailCallToReturnedCode(masm, Runtime::kCompileOptimized_Concurrent); |
| 864 GenerateTailCallToReturnedCode(masm); | |
| 865 } | 864 } |
| 866 | 865 |
| 867 | 866 |
| 868 static void GenerateMakeCodeYoungAgainCommon(MacroAssembler* masm) { | 867 static void GenerateMakeCodeYoungAgainCommon(MacroAssembler* masm) { |
| 869 // For now, we are relying on the fact that make_code_young doesn't do any | 868 // For now, we are relying on the fact that make_code_young doesn't do any |
| 870 // garbage collection which allows us to save/restore the registers without | 869 // garbage collection which allows us to save/restore the registers without |
| 871 // worrying about which of them contain pointers. We also don't build an | 870 // worrying about which of them contain pointers. We also don't build an |
| 872 // internal frame to make the code faster, since we shouldn't have to do stack | 871 // internal frame to make the code faster, since we shouldn't have to do stack |
| 873 // crawls in MakeCodeYoung. This seems a bit fragile. | 872 // crawls in MakeCodeYoung. This seems a bit fragile. |
| 874 | 873 |
| (...skipping 1897 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2772 | 2771 |
| 2773 __ bind(&ok); | 2772 __ bind(&ok); |
| 2774 __ ret(0); | 2773 __ ret(0); |
| 2775 } | 2774 } |
| 2776 | 2775 |
| 2777 #undef __ | 2776 #undef __ |
| 2778 } // namespace internal | 2777 } // namespace internal |
| 2779 } // namespace v8 | 2778 } // namespace v8 |
| 2780 | 2779 |
| 2781 #endif // V8_TARGET_ARCH_IA32 | 2780 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |