| 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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 ExternalReference::address_of_stack_limit(masm->isolate()); | 103 ExternalReference::address_of_stack_limit(masm->isolate()); |
| 104 __ cmp(esp, Operand::StaticVariable(stack_limit)); | 104 __ cmp(esp, Operand::StaticVariable(stack_limit)); |
| 105 __ j(above_equal, &ok, Label::kNear); | 105 __ j(above_equal, &ok, Label::kNear); |
| 106 | 106 |
| 107 GenerateTailCallToReturnedCode(masm, Runtime::kTryInstallOptimizedCode); | 107 GenerateTailCallToReturnedCode(masm, Runtime::kTryInstallOptimizedCode); |
| 108 | 108 |
| 109 __ bind(&ok); | 109 __ bind(&ok); |
| 110 GenerateTailCallToSharedCode(masm); | 110 GenerateTailCallToSharedCode(masm); |
| 111 } | 111 } |
| 112 | 112 |
| 113 static void Generate_JSConstructStubHelper(MacroAssembler* masm, | 113 namespace { |
| 114 bool is_api_function, | 114 |
| 115 bool create_implicit_receiver, | 115 void Generate_JSConstructStubHelper(MacroAssembler* masm, bool is_api_function, |
| 116 bool check_derived_construct) { | 116 bool create_implicit_receiver, |
| 117 bool check_derived_construct) { |
| 117 // ----------- S t a t e ------------- | 118 // ----------- S t a t e ------------- |
| 118 // -- eax: number of arguments | 119 // -- eax: number of arguments |
| 119 // -- esi: context | 120 // -- esi: context |
| 120 // -- edi: constructor function | 121 // -- edi: constructor function |
| 121 // -- ebx: allocation site or undefined | |
| 122 // -- edx: new target | 122 // -- edx: new target |
| 123 // ----------------------------------- | 123 // ----------------------------------- |
| 124 | 124 |
| 125 // Enter a construct frame. | 125 // Enter a construct frame. |
| 126 { | 126 { |
| 127 FrameScope scope(masm, StackFrame::CONSTRUCT); | 127 FrameScope scope(masm, StackFrame::CONSTRUCT); |
| 128 | 128 |
| 129 // Preserve the incoming parameters on the stack. | 129 // Preserve the incoming parameters on the stack. |
| 130 __ AssertUndefinedOrAllocationSite(ebx); | 130 __ SmiTag(eax); |
| 131 __ push(esi); | 131 __ push(esi); |
| 132 __ push(ebx); | |
| 133 __ SmiTag(eax); | |
| 134 __ push(eax); | 132 __ push(eax); |
| 135 | 133 |
| 136 if (create_implicit_receiver) { | 134 if (create_implicit_receiver) { |
| 137 // Allocate the new receiver object. | 135 // Allocate the new receiver object. |
| 138 __ Push(edi); | 136 __ Push(edi); |
| 139 __ Push(edx); | 137 __ Push(edx); |
| 140 FastNewObjectStub stub(masm->isolate()); | 138 FastNewObjectStub stub(masm->isolate()); |
| 141 __ CallStub(&stub); | 139 __ CallStub(&stub); |
| 142 __ mov(ebx, eax); | 140 __ mov(ebx, eax); |
| 143 __ Pop(edx); | 141 __ Pop(edx); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 | 188 |
| 191 // Restore context from the frame. | 189 // Restore context from the frame. |
| 192 __ mov(esi, Operand(ebp, ConstructFrameConstants::kContextOffset)); | 190 __ mov(esi, Operand(ebp, ConstructFrameConstants::kContextOffset)); |
| 193 | 191 |
| 194 if (create_implicit_receiver) { | 192 if (create_implicit_receiver) { |
| 195 // If the result is an object (in the ECMA sense), we should get rid | 193 // If the result is an object (in the ECMA sense), we should get rid |
| 196 // of the receiver and use the result. | 194 // of the receiver and use the result. |
| 197 Label use_receiver, exit; | 195 Label use_receiver, exit; |
| 198 | 196 |
| 199 // If the result is a smi, it is *not* an object in the ECMA sense. | 197 // If the result is a smi, it is *not* an object in the ECMA sense. |
| 200 __ JumpIfSmi(eax, &use_receiver); | 198 __ JumpIfSmi(eax, &use_receiver, Label::kNear); |
| 201 | 199 |
| 202 // If the type of the result (stored in its map) is less than | 200 // If the type of the result (stored in its map) is less than |
| 203 // FIRST_JS_RECEIVER_TYPE, it is not an object in the ECMA sense. | 201 // FIRST_JS_RECEIVER_TYPE, it is not an object in the ECMA sense. |
| 204 __ CmpObjectType(eax, FIRST_JS_RECEIVER_TYPE, ecx); | 202 __ CmpObjectType(eax, FIRST_JS_RECEIVER_TYPE, ecx); |
| 205 __ j(above_equal, &exit); | 203 __ j(above_equal, &exit, Label::kNear); |
| 206 | 204 |
| 207 // Throw away the result of the constructor invocation and use the | 205 // Throw away the result of the constructor invocation and use the |
| 208 // on-stack receiver as the result. | 206 // on-stack receiver as the result. |
| 209 __ bind(&use_receiver); | 207 __ bind(&use_receiver); |
| 210 __ mov(eax, Operand(esp, 0)); | 208 __ mov(eax, Operand(esp, 0)); |
| 211 | 209 |
| 212 // Restore the arguments count and leave the construct frame. The | 210 // Restore the arguments count and leave the construct frame. The |
| 213 // arguments count is stored below the receiver. | 211 // arguments count is stored below the receiver. |
| 214 __ bind(&exit); | 212 __ bind(&exit); |
| 215 __ mov(ebx, Operand(esp, 1 * kPointerSize)); | 213 __ mov(ebx, Operand(esp, 1 * kPointerSize)); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 237 STATIC_ASSERT(kSmiTagSize == 1 && kSmiTag == 0); | 235 STATIC_ASSERT(kSmiTagSize == 1 && kSmiTag == 0); |
| 238 __ pop(ecx); | 236 __ pop(ecx); |
| 239 __ lea(esp, Operand(esp, ebx, times_2, 1 * kPointerSize)); // 1 ~ receiver | 237 __ lea(esp, Operand(esp, ebx, times_2, 1 * kPointerSize)); // 1 ~ receiver |
| 240 __ push(ecx); | 238 __ push(ecx); |
| 241 if (create_implicit_receiver) { | 239 if (create_implicit_receiver) { |
| 242 __ IncrementCounter(masm->isolate()->counters()->constructed_objects(), 1); | 240 __ IncrementCounter(masm->isolate()->counters()->constructed_objects(), 1); |
| 243 } | 241 } |
| 244 __ ret(0); | 242 __ ret(0); |
| 245 } | 243 } |
| 246 | 244 |
| 245 } // namespace |
| 246 |
| 247 void Builtins::Generate_JSConstructStubGeneric(MacroAssembler* masm) { | 247 void Builtins::Generate_JSConstructStubGeneric(MacroAssembler* masm) { |
| 248 Generate_JSConstructStubHelper(masm, false, true, false); | 248 Generate_JSConstructStubHelper(masm, false, true, false); |
| 249 } | 249 } |
| 250 | 250 |
| 251 void Builtins::Generate_JSConstructStubApi(MacroAssembler* masm) { | 251 void Builtins::Generate_JSConstructStubApi(MacroAssembler* masm) { |
| 252 Generate_JSConstructStubHelper(masm, true, false, false); | 252 Generate_JSConstructStubHelper(masm, true, false, false); |
| 253 } | 253 } |
| 254 | 254 |
| 255 void Builtins::Generate_JSBuiltinsConstructStub(MacroAssembler* masm) { | 255 void Builtins::Generate_JSBuiltinsConstructStub(MacroAssembler* masm) { |
| 256 Generate_JSConstructStubHelper(masm, false, false, false); | 256 Generate_JSConstructStubHelper(masm, false, false, false); |
| (...skipping 2869 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3126 | 3126 |
| 3127 void Builtins::Generate_InterpreterOnStackReplacement(MacroAssembler* masm) { | 3127 void Builtins::Generate_InterpreterOnStackReplacement(MacroAssembler* masm) { |
| 3128 Generate_OnStackReplacementHelper(masm, true); | 3128 Generate_OnStackReplacementHelper(masm, true); |
| 3129 } | 3129 } |
| 3130 | 3130 |
| 3131 #undef __ | 3131 #undef __ |
| 3132 } // namespace internal | 3132 } // namespace internal |
| 3133 } // namespace v8 | 3133 } // namespace v8 |
| 3134 | 3134 |
| 3135 #endif // V8_TARGET_ARCH_IA32 | 3135 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |