| 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 Register caller_args_count_reg = scratch1; | 1883 Register caller_args_count_reg = scratch1; |
| 1885 Label no_arguments_adaptor, formal_parameter_count_loaded; | 1884 Label no_arguments_adaptor, formal_parameter_count_loaded; |
| 1886 __ mov(scratch2, Operand(ebp, StandardFrameConstants::kCallerFPOffset)); | 1885 __ mov(scratch2, Operand(ebp, StandardFrameConstants::kCallerFPOffset)); |
| 1887 __ cmp(Operand(scratch2, StandardFrameConstants::kContextOffset), | 1886 __ cmp(Operand(scratch2, CommonFrameConstants::kContextOrFrameTypeOffset), |
| 1888 Immediate(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR))); | 1887 Immediate(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR))); |
| 1889 __ j(not_equal, &no_arguments_adaptor, Label::kNear); | 1888 __ j(not_equal, &no_arguments_adaptor, Label::kNear); |
| 1890 | 1889 |
| 1891 // Drop current frame and load arguments count from arguments adaptor frame. | 1890 // Drop current frame and load arguments count from arguments adaptor frame. |
| 1892 __ mov(ebp, scratch2); | 1891 __ mov(ebp, scratch2); |
| 1893 __ mov(caller_args_count_reg, | 1892 __ mov(caller_args_count_reg, |
| 1894 Operand(ebp, ArgumentsAdaptorFrameConstants::kLengthOffset)); | 1893 Operand(ebp, ArgumentsAdaptorFrameConstants::kLengthOffset)); |
| 1895 __ SmiUntag(caller_args_count_reg); | 1894 __ SmiUntag(caller_args_count_reg); |
| 1896 __ jmp(&formal_parameter_count_loaded, Label::kNear); | 1895 __ jmp(&formal_parameter_count_loaded, Label::kNear); |
| 1897 | 1896 |
| (...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2424 __ cmp(eax, ebx); | 2423 __ cmp(eax, ebx); |
| 2425 __ j(less, &fill); | 2424 __ j(less, &fill); |
| 2426 | 2425 |
| 2427 // Restore expected arguments. | 2426 // Restore expected arguments. |
| 2428 __ mov(eax, ecx); | 2427 __ mov(eax, ecx); |
| 2429 } | 2428 } |
| 2430 | 2429 |
| 2431 // Call the entry point. | 2430 // Call the entry point. |
| 2432 __ bind(&invoke); | 2431 __ bind(&invoke); |
| 2433 // Restore function pointer. | 2432 // Restore function pointer. |
| 2434 __ mov(edi, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); | 2433 __ mov(edi, Operand(ebp, ArgumentsAdaptorFrameConstants::kFunctionOffset)); |
| 2435 // eax : expected number of arguments | 2434 // eax : expected number of arguments |
| 2436 // edx : new target (passed through to callee) | 2435 // edx : new target (passed through to callee) |
| 2437 // edi : function (passed through to callee) | 2436 // edi : function (passed through to callee) |
| 2438 __ mov(ecx, FieldOperand(edi, JSFunction::kCodeEntryOffset)); | 2437 __ mov(ecx, FieldOperand(edi, JSFunction::kCodeEntryOffset)); |
| 2439 __ call(ecx); | 2438 __ call(ecx); |
| 2440 | 2439 |
| 2441 // Store offset of return address for deoptimizer. | 2440 // Store offset of return address for deoptimizer. |
| 2442 masm->isolate()->heap()->SetArgumentsAdaptorDeoptPCOffset(masm->pc_offset()); | 2441 masm->isolate()->heap()->SetArgumentsAdaptorDeoptPCOffset(masm->pc_offset()); |
| 2443 | 2442 |
| 2444 // Leave frame and return. | 2443 // Leave frame and return. |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2622 | 2621 |
| 2623 __ bind(&ok); | 2622 __ bind(&ok); |
| 2624 __ ret(0); | 2623 __ ret(0); |
| 2625 } | 2624 } |
| 2626 | 2625 |
| 2627 #undef __ | 2626 #undef __ |
| 2628 } // namespace internal | 2627 } // namespace internal |
| 2629 } // namespace v8 | 2628 } // namespace v8 |
| 2630 | 2629 |
| 2631 #endif // V8_TARGET_ARCH_IA32 | 2630 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |