| 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_X87 | 5 #if V8_TARGET_ARCH_X87 |
| 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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; see ECMA-262 section 13.2.2-7 | 194 // of the receiver and use the result; see ECMA-262 section 13.2.2-7 |
| 197 // on page 74. | 195 // on page 74. |
| 198 Label use_receiver, exit; | 196 Label use_receiver, exit; |
| 199 | 197 |
| 200 // If the result is a smi, it is *not* an object in the ECMA sense. | 198 // If the result is a smi, it is *not* an object in the ECMA sense. |
| 201 __ JumpIfSmi(eax, &use_receiver); | 199 __ JumpIfSmi(eax, &use_receiver, Label::kNear); |
| 202 | 200 |
| 203 // If the type of the result (stored in its map) is less than | 201 // If the type of the result (stored in its map) is less than |
| 204 // FIRST_JS_RECEIVER_TYPE, it is not an object in the ECMA sense. | 202 // FIRST_JS_RECEIVER_TYPE, it is not an object in the ECMA sense. |
| 205 __ CmpObjectType(eax, FIRST_JS_RECEIVER_TYPE, ecx); | 203 __ CmpObjectType(eax, FIRST_JS_RECEIVER_TYPE, ecx); |
| 206 __ j(above_equal, &exit); | 204 __ j(above_equal, &exit, Label::kNear); |
| 207 | 205 |
| 208 // Throw away the result of the constructor invocation and use the | 206 // Throw away the result of the constructor invocation and use the |
| 209 // on-stack receiver as the result. | 207 // on-stack receiver as the result. |
| 210 __ bind(&use_receiver); | 208 __ bind(&use_receiver); |
| 211 __ mov(eax, Operand(esp, 0)); | 209 __ mov(eax, Operand(esp, 0)); |
| 212 | 210 |
| 213 // Restore the arguments count and leave the construct frame. The | 211 // Restore the arguments count and leave the construct frame. The |
| 214 // arguments count is stored below the receiver. | 212 // arguments count is stored below the receiver. |
| 215 __ bind(&exit); | 213 __ bind(&exit); |
| 216 __ mov(ebx, Operand(esp, 1 * kPointerSize)); | 214 __ mov(ebx, Operand(esp, 1 * kPointerSize)); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 238 STATIC_ASSERT(kSmiTagSize == 1 && kSmiTag == 0); | 236 STATIC_ASSERT(kSmiTagSize == 1 && kSmiTag == 0); |
| 239 __ pop(ecx); | 237 __ pop(ecx); |
| 240 __ lea(esp, Operand(esp, ebx, times_2, 1 * kPointerSize)); // 1 ~ receiver | 238 __ lea(esp, Operand(esp, ebx, times_2, 1 * kPointerSize)); // 1 ~ receiver |
| 241 __ push(ecx); | 239 __ push(ecx); |
| 242 if (create_implicit_receiver) { | 240 if (create_implicit_receiver) { |
| 243 __ IncrementCounter(masm->isolate()->counters()->constructed_objects(), 1); | 241 __ IncrementCounter(masm->isolate()->counters()->constructed_objects(), 1); |
| 244 } | 242 } |
| 245 __ ret(0); | 243 __ ret(0); |
| 246 } | 244 } |
| 247 | 245 |
| 246 } // namespace |
| 247 |
| 248 void Builtins::Generate_JSConstructStubGeneric(MacroAssembler* masm) { | 248 void Builtins::Generate_JSConstructStubGeneric(MacroAssembler* masm) { |
| 249 Generate_JSConstructStubHelper(masm, false, true, false); | 249 Generate_JSConstructStubHelper(masm, false, true, false); |
| 250 } | 250 } |
| 251 | 251 |
| 252 void Builtins::Generate_JSConstructStubApi(MacroAssembler* masm) { | 252 void Builtins::Generate_JSConstructStubApi(MacroAssembler* masm) { |
| 253 Generate_JSConstructStubHelper(masm, true, false, false); | 253 Generate_JSConstructStubHelper(masm, true, false, false); |
| 254 } | 254 } |
| 255 | 255 |
| 256 void Builtins::Generate_JSBuiltinsConstructStub(MacroAssembler* masm) { | 256 void Builtins::Generate_JSBuiltinsConstructStub(MacroAssembler* masm) { |
| 257 Generate_JSConstructStubHelper(masm, false, false, false); | 257 Generate_JSConstructStubHelper(masm, false, false, false); |
| (...skipping 2892 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3150 | 3150 |
| 3151 void Builtins::Generate_InterpreterOnStackReplacement(MacroAssembler* masm) { | 3151 void Builtins::Generate_InterpreterOnStackReplacement(MacroAssembler* masm) { |
| 3152 Generate_OnStackReplacementHelper(masm, true); | 3152 Generate_OnStackReplacementHelper(masm, true); |
| 3153 } | 3153 } |
| 3154 | 3154 |
| 3155 #undef __ | 3155 #undef __ |
| 3156 } // namespace internal | 3156 } // namespace internal |
| 3157 } // namespace v8 | 3157 } // namespace v8 |
| 3158 | 3158 |
| 3159 #endif // V8_TARGET_ARCH_X87 | 3159 #endif // V8_TARGET_ARCH_X87 |
| OLD | NEW |