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_X64 | 5 #if V8_TARGET_ARCH_X64 |
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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 Label ok; | 105 Label ok; |
106 __ CompareRoot(rsp, Heap::kStackLimitRootIndex); | 106 __ CompareRoot(rsp, Heap::kStackLimitRootIndex); |
107 __ j(above_equal, &ok); | 107 __ j(above_equal, &ok); |
108 | 108 |
109 GenerateTailCallToReturnedCode(masm, Runtime::kTryInstallOptimizedCode); | 109 GenerateTailCallToReturnedCode(masm, Runtime::kTryInstallOptimizedCode); |
110 | 110 |
111 __ bind(&ok); | 111 __ bind(&ok); |
112 GenerateTailCallToSharedCode(masm); | 112 GenerateTailCallToSharedCode(masm); |
113 } | 113 } |
114 | 114 |
115 static void Generate_JSConstructStubHelper(MacroAssembler* masm, | 115 namespace { |
116 bool is_api_function, | 116 |
117 bool create_implicit_receiver, | 117 void Generate_JSConstructStubHelper(MacroAssembler* masm, bool is_api_function, |
118 bool check_derived_construct) { | 118 bool create_implicit_receiver, |
| 119 bool check_derived_construct) { |
119 // ----------- S t a t e ------------- | 120 // ----------- S t a t e ------------- |
120 // -- rax: number of arguments | 121 // -- rax: number of arguments |
121 // -- rsi: context | 122 // -- rsi: context |
122 // -- rdi: constructor function | 123 // -- rdi: constructor function |
123 // -- rbx: allocation site or undefined | |
124 // -- rdx: new target | 124 // -- rdx: new target |
125 // ----------------------------------- | 125 // ----------------------------------- |
126 | 126 |
127 // Enter a construct frame. | 127 // Enter a construct frame. |
128 { | 128 { |
129 FrameScope scope(masm, StackFrame::CONSTRUCT); | 129 FrameScope scope(masm, StackFrame::CONSTRUCT); |
130 | 130 |
131 // Preserve the incoming parameters on the stack. | 131 // Preserve the incoming parameters on the stack. |
132 __ AssertUndefinedOrAllocationSite(rbx); | 132 __ Integer32ToSmi(rcx, rax); |
133 __ Push(rsi); | 133 __ Push(rsi); |
134 __ Push(rbx); | |
135 __ Integer32ToSmi(rcx, rax); | |
136 __ Push(rcx); | 134 __ Push(rcx); |
137 | 135 |
138 if (create_implicit_receiver) { | 136 if (create_implicit_receiver) { |
139 // Allocate the new receiver object. | 137 // Allocate the new receiver object. |
140 __ Push(rdi); | 138 __ Push(rdi); |
141 __ Push(rdx); | 139 __ Push(rdx); |
142 FastNewObjectStub stub(masm->isolate()); | 140 FastNewObjectStub stub(masm->isolate()); |
143 __ CallStub(&stub); | 141 __ CallStub(&stub); |
144 __ movp(rbx, rax); | 142 __ movp(rbx, rax); |
145 __ Pop(rdx); | 143 __ Pop(rdx); |
(...skipping 44 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 __ movp(rsi, Operand(rbp, ConstructFrameConstants::kContextOffset)); | 190 __ movp(rsi, Operand(rbp, 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 // 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(rax, &use_receiver); | 198 __ JumpIfSmi(rax, &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 STATIC_ASSERT(LAST_JS_RECEIVER_TYPE == LAST_TYPE); | 202 STATIC_ASSERT(LAST_JS_RECEIVER_TYPE == LAST_TYPE); |
205 __ CmpObjectType(rax, FIRST_JS_RECEIVER_TYPE, rcx); | 203 __ CmpObjectType(rax, FIRST_JS_RECEIVER_TYPE, rcx); |
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 __ movp(rax, Operand(rsp, 0)); | 209 __ movp(rax, Operand(rsp, 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 __ movp(rbx, Operand(rsp, 1 * kPointerSize)); | 214 __ movp(rbx, Operand(rsp, 1 * kPointerSize)); |
(...skipping 22 matching lines...) Expand all Loading... |
239 SmiIndex index = masm->SmiToIndex(rbx, rbx, kPointerSizeLog2); | 237 SmiIndex index = masm->SmiToIndex(rbx, rbx, kPointerSizeLog2); |
240 __ leap(rsp, Operand(rsp, index.reg, index.scale, 1 * kPointerSize)); | 238 __ leap(rsp, Operand(rsp, index.reg, index.scale, 1 * kPointerSize)); |
241 __ PushReturnAddressFrom(rcx); | 239 __ PushReturnAddressFrom(rcx); |
242 if (create_implicit_receiver) { | 240 if (create_implicit_receiver) { |
243 Counters* counters = masm->isolate()->counters(); | 241 Counters* counters = masm->isolate()->counters(); |
244 __ IncrementCounter(counters->constructed_objects(), 1); | 242 __ IncrementCounter(counters->constructed_objects(), 1); |
245 } | 243 } |
246 __ ret(0); | 244 __ ret(0); |
247 } | 245 } |
248 | 246 |
| 247 } // namespace |
| 248 |
249 void Builtins::Generate_JSConstructStubGeneric(MacroAssembler* masm) { | 249 void Builtins::Generate_JSConstructStubGeneric(MacroAssembler* masm) { |
250 Generate_JSConstructStubHelper(masm, false, true, false); | 250 Generate_JSConstructStubHelper(masm, false, true, false); |
251 } | 251 } |
252 | 252 |
253 void Builtins::Generate_JSConstructStubApi(MacroAssembler* masm) { | 253 void Builtins::Generate_JSConstructStubApi(MacroAssembler* masm) { |
254 Generate_JSConstructStubHelper(masm, true, false, false); | 254 Generate_JSConstructStubHelper(masm, true, false, false); |
255 } | 255 } |
256 | 256 |
257 void Builtins::Generate_JSBuiltinsConstructStub(MacroAssembler* masm) { | 257 void Builtins::Generate_JSBuiltinsConstructStub(MacroAssembler* masm) { |
258 Generate_JSConstructStubHelper(masm, false, false, false); | 258 Generate_JSConstructStubHelper(masm, false, false, false); |
(...skipping 2814 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3073 void Builtins::Generate_InterpreterOnStackReplacement(MacroAssembler* masm) { | 3073 void Builtins::Generate_InterpreterOnStackReplacement(MacroAssembler* masm) { |
3074 Generate_OnStackReplacementHelper(masm, true); | 3074 Generate_OnStackReplacementHelper(masm, true); |
3075 } | 3075 } |
3076 | 3076 |
3077 #undef __ | 3077 #undef __ |
3078 | 3078 |
3079 } // namespace internal | 3079 } // namespace internal |
3080 } // namespace v8 | 3080 } // namespace v8 |
3081 | 3081 |
3082 #endif // V8_TARGET_ARCH_X64 | 3082 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |