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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 __ bind(&ok); | 116 __ bind(&ok); |
117 GenerateTailCallToSharedCode(masm); | 117 GenerateTailCallToSharedCode(masm); |
118 } | 118 } |
119 | 119 |
120 static void Generate_JSConstructStubHelper(MacroAssembler* masm, | 120 static void Generate_JSConstructStubHelper(MacroAssembler* masm, |
121 bool is_api_function, | 121 bool is_api_function, |
122 bool create_implicit_receiver, | 122 bool create_implicit_receiver, |
123 bool check_derived_construct) { | 123 bool check_derived_construct) { |
124 // ----------- S t a t e ------------- | 124 // ----------- S t a t e ------------- |
125 // -- eax: number of arguments | 125 // -- eax: number of arguments |
| 126 // -- esi: context |
126 // -- edi: constructor function | 127 // -- edi: constructor function |
127 // -- ebx: allocation site or undefined | 128 // -- ebx: allocation site or undefined |
128 // -- edx: new target | 129 // -- edx: new target |
129 // ----------------------------------- | 130 // ----------------------------------- |
130 | 131 |
131 // Enter a construct frame. | 132 // Enter a construct frame. |
132 { | 133 { |
133 FrameScope scope(masm, StackFrame::CONSTRUCT); | 134 FrameScope scope(masm, StackFrame::CONSTRUCT); |
134 | 135 |
135 // Preserve the incoming parameters on the stack. | 136 // Preserve the incoming parameters on the stack. |
136 __ AssertUndefinedOrAllocationSite(ebx); | 137 __ AssertUndefinedOrAllocationSite(ebx); |
| 138 __ push(esi); |
137 __ push(ebx); | 139 __ push(ebx); |
138 __ SmiTag(eax); | 140 __ SmiTag(eax); |
139 __ push(eax); | 141 __ push(eax); |
140 | 142 |
141 if (create_implicit_receiver) { | 143 if (create_implicit_receiver) { |
142 // Allocate the new receiver object. | 144 // Allocate the new receiver object. |
143 __ Push(edi); | 145 __ Push(edi); |
144 __ Push(edx); | 146 __ Push(edx); |
145 FastNewObjectStub stub(masm->isolate()); | 147 FastNewObjectStub stub(masm->isolate()); |
146 __ CallStub(&stub); | 148 __ CallStub(&stub); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 __ InvokeFunction(edi, edx, actual, CALL_FUNCTION, | 196 __ InvokeFunction(edi, edx, actual, CALL_FUNCTION, |
195 CheckDebugStepCallWrapper()); | 197 CheckDebugStepCallWrapper()); |
196 } | 198 } |
197 | 199 |
198 // Store offset of return address for deoptimizer. | 200 // Store offset of return address for deoptimizer. |
199 if (create_implicit_receiver && !is_api_function) { | 201 if (create_implicit_receiver && !is_api_function) { |
200 masm->isolate()->heap()->SetConstructStubDeoptPCOffset(masm->pc_offset()); | 202 masm->isolate()->heap()->SetConstructStubDeoptPCOffset(masm->pc_offset()); |
201 } | 203 } |
202 | 204 |
203 // Restore context from the frame. | 205 // Restore context from the frame. |
204 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); | 206 __ mov(esi, Operand(ebp, ConstructFrameConstants::kContextOffset)); |
205 | 207 |
206 if (create_implicit_receiver) { | 208 if (create_implicit_receiver) { |
207 // If the result is an object (in the ECMA sense), we should get rid | 209 // If the result is an object (in the ECMA sense), we should get rid |
208 // of the receiver and use the result. | 210 // of the receiver and use the result. |
209 Label use_receiver, exit; | 211 Label use_receiver, exit; |
210 | 212 |
211 // If the result is a smi, it is *not* an object in the ECMA sense. | 213 // If the result is a smi, it is *not* an object in the ECMA sense. |
212 __ JumpIfSmi(eax, &use_receiver); | 214 __ JumpIfSmi(eax, &use_receiver); |
213 | 215 |
214 // If the type of the result (stored in its map) is less than | 216 // If the type of the result (stored in its map) is less than |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 __ CallRuntime(Runtime::kThrowStackOverflow); | 319 __ CallRuntime(Runtime::kThrowStackOverflow); |
318 | 320 |
319 __ bind(&okay); | 321 __ bind(&okay); |
320 } | 322 } |
321 | 323 |
322 | 324 |
323 static void Generate_JSEntryTrampolineHelper(MacroAssembler* masm, | 325 static void Generate_JSEntryTrampolineHelper(MacroAssembler* masm, |
324 bool is_construct) { | 326 bool is_construct) { |
325 ProfileEntryHookStub::MaybeCallEntryHook(masm); | 327 ProfileEntryHookStub::MaybeCallEntryHook(masm); |
326 | 328 |
327 // Clear the context before we push it when entering the internal frame. | |
328 __ Move(esi, Immediate(0)); | |
329 | |
330 { | 329 { |
331 FrameScope scope(masm, StackFrame::INTERNAL); | 330 FrameScope scope(masm, StackFrame::INTERNAL); |
332 | 331 |
333 // Setup the context (we need to use the caller context from the isolate). | 332 // Setup the context (we need to use the caller context from the isolate). |
334 ExternalReference context_address(Isolate::kContextAddress, | 333 ExternalReference context_address(Isolate::kContextAddress, |
335 masm->isolate()); | 334 masm->isolate()); |
336 __ mov(esi, Operand::StaticVariable(context_address)); | 335 __ mov(esi, Operand::StaticVariable(context_address)); |
337 | 336 |
338 // Load the previous frame pointer (ebx) to access C arguments | 337 // Load the previous frame pointer (ebx) to access C arguments |
339 __ mov(ebx, Operand(ebp, 0)); | 338 __ mov(ebx, Operand(ebp, 0)); |
(...skipping 1526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1866 Label done; | 1865 Label done; |
1867 ExternalReference debug_is_active = | 1866 ExternalReference debug_is_active = |
1868 ExternalReference::debug_is_active_address(masm->isolate()); | 1867 ExternalReference::debug_is_active_address(masm->isolate()); |
1869 __ movzx_b(scratch1, Operand::StaticVariable(debug_is_active)); | 1868 __ movzx_b(scratch1, Operand::StaticVariable(debug_is_active)); |
1870 __ cmp(scratch1, Immediate(0)); | 1869 __ cmp(scratch1, Immediate(0)); |
1871 __ j(not_equal, &done, Label::kNear); | 1870 __ j(not_equal, &done, Label::kNear); |
1872 | 1871 |
1873 // Drop possible interpreter handler/stub frame. | 1872 // Drop possible interpreter handler/stub frame. |
1874 { | 1873 { |
1875 Label no_interpreter_frame; | 1874 Label no_interpreter_frame; |
1876 __ cmp(Operand(ebp, StandardFrameConstants::kMarkerOffset), | 1875 __ cmp(Operand(ebp, CommonFrameConstants::kContextOrFrameTypeOffset), |
1877 Immediate(Smi::FromInt(StackFrame::STUB))); | 1876 Immediate(Smi::FromInt(StackFrame::STUB))); |
1878 __ j(not_equal, &no_interpreter_frame, Label::kNear); | 1877 __ j(not_equal, &no_interpreter_frame, Label::kNear); |
1879 __ mov(ebp, Operand(ebp, StandardFrameConstants::kCallerFPOffset)); | 1878 __ mov(ebp, Operand(ebp, StandardFrameConstants::kCallerFPOffset)); |
1880 __ bind(&no_interpreter_frame); | 1879 __ bind(&no_interpreter_frame); |
1881 } | 1880 } |
1882 | 1881 |
1883 // Check if next frame is an arguments adaptor frame. | 1882 // Check if next frame is an arguments adaptor frame. |
1884 Label no_arguments_adaptor, formal_parameter_count_loaded; | 1883 Label no_arguments_adaptor, formal_parameter_count_loaded; |
1885 __ mov(scratch2, Operand(ebp, StandardFrameConstants::kCallerFPOffset)); | 1884 __ mov(scratch2, Operand(ebp, StandardFrameConstants::kCallerFPOffset)); |
1886 __ cmp(Operand(scratch2, StandardFrameConstants::kContextOffset), | 1885 __ cmp(Operand(scratch2, CommonFrameConstants::kContextOrFrameTypeOffset), |
1887 Immediate(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR))); | 1886 Immediate(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR))); |
1888 __ j(not_equal, &no_arguments_adaptor, Label::kNear); | 1887 __ j(not_equal, &no_arguments_adaptor, Label::kNear); |
1889 | 1888 |
1890 // Drop arguments adaptor frame and load arguments count. | 1889 // Drop arguments adaptor frame and load arguments count. |
1891 __ mov(ebp, scratch2); | 1890 __ mov(ebp, scratch2); |
1892 __ mov(scratch1, Operand(ebp, ArgumentsAdaptorFrameConstants::kLengthOffset)); | 1891 __ mov(scratch1, Operand(ebp, ArgumentsAdaptorFrameConstants::kLengthOffset)); |
1893 __ SmiUntag(scratch1); | 1892 __ SmiUntag(scratch1); |
1894 __ jmp(&formal_parameter_count_loaded, Label::kNear); | 1893 __ jmp(&formal_parameter_count_loaded, Label::kNear); |
1895 | 1894 |
1896 __ bind(&no_arguments_adaptor); | 1895 __ bind(&no_arguments_adaptor); |
(...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2464 __ cmp(eax, ebx); | 2463 __ cmp(eax, ebx); |
2465 __ j(less, &fill); | 2464 __ j(less, &fill); |
2466 | 2465 |
2467 // Restore expected arguments. | 2466 // Restore expected arguments. |
2468 __ mov(eax, ecx); | 2467 __ mov(eax, ecx); |
2469 } | 2468 } |
2470 | 2469 |
2471 // Call the entry point. | 2470 // Call the entry point. |
2472 __ bind(&invoke); | 2471 __ bind(&invoke); |
2473 // Restore function pointer. | 2472 // Restore function pointer. |
2474 __ mov(edi, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); | 2473 __ mov(edi, Operand(ebp, ArgumentsAdaptorFrameConstants::kFunctionOffset)); |
2475 // eax : expected number of arguments | 2474 // eax : expected number of arguments |
2476 // edx : new target (passed through to callee) | 2475 // edx : new target (passed through to callee) |
2477 // edi : function (passed through to callee) | 2476 // edi : function (passed through to callee) |
2478 __ mov(ecx, FieldOperand(edi, JSFunction::kCodeEntryOffset)); | 2477 __ mov(ecx, FieldOperand(edi, JSFunction::kCodeEntryOffset)); |
2479 __ call(ecx); | 2478 __ call(ecx); |
2480 | 2479 |
2481 // Store offset of return address for deoptimizer. | 2480 // Store offset of return address for deoptimizer. |
2482 masm->isolate()->heap()->SetArgumentsAdaptorDeoptPCOffset(masm->pc_offset()); | 2481 masm->isolate()->heap()->SetArgumentsAdaptorDeoptPCOffset(masm->pc_offset()); |
2483 | 2482 |
2484 // Leave frame and return. | 2483 // Leave frame and return. |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2662 | 2661 |
2663 __ bind(&ok); | 2662 __ bind(&ok); |
2664 __ ret(0); | 2663 __ ret(0); |
2665 } | 2664 } |
2666 | 2665 |
2667 #undef __ | 2666 #undef __ |
2668 } // namespace internal | 2667 } // namespace internal |
2669 } // namespace v8 | 2668 } // namespace v8 |
2670 | 2669 |
2671 #endif // V8_TARGET_ARCH_IA32 | 2670 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |