OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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_ARM64 | 5 #if V8_TARGET_ARCH_ARM64 |
6 | 6 |
7 #include "src/arm64/frames-arm64.h" | 7 #include "src/arm64/frames-arm64.h" |
8 #include "src/codegen.h" | 8 #include "src/codegen.h" |
9 #include "src/debug/debug.h" | 9 #include "src/debug/debug.h" |
10 #include "src/deoptimizer.h" | 10 #include "src/deoptimizer.h" |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 __ TailCallRuntime(Runtime::kSymbolDescriptiveString, 1, 1); | 202 __ TailCallRuntime(Runtime::kSymbolDescriptiveString, 1, 1); |
203 } | 203 } |
204 } | 204 } |
205 | 205 |
206 | 206 |
207 // static | 207 // static |
208 void Builtins::Generate_StringConstructor_ConstructStub(MacroAssembler* masm) { | 208 void Builtins::Generate_StringConstructor_ConstructStub(MacroAssembler* masm) { |
209 // ----------- S t a t e ------------- | 209 // ----------- S t a t e ------------- |
210 // -- x0 : number of arguments | 210 // -- x0 : number of arguments |
211 // -- x1 : constructor function | 211 // -- x1 : constructor function |
212 // -- x3 : original constructor | |
213 // -- lr : return address | 212 // -- lr : return address |
214 // -- sp[(argc - n - 1) * 8] : arg[n] (zero based) | 213 // -- sp[(argc - n - 1) * 8] : arg[n] (zero based) |
215 // -- sp[argc * 8] : receiver | 214 // -- sp[argc * 8] : receiver |
216 // ----------------------------------- | 215 // ----------------------------------- |
217 ASM_LOCATION("Builtins::Generate_StringConstructor_ConstructStub"); | 216 ASM_LOCATION("Builtins::Generate_StringConstructor_ConstructStub"); |
218 | 217 |
219 // 1. Load the first argument into x2 and get rid of the rest (including the | 218 // 1. Load the first argument into x2 and get rid of the rest (including the |
220 // receiver). | 219 // receiver). |
221 { | 220 { |
222 Label no_arguments, done; | 221 Label no_arguments, done; |
223 __ Cbz(x0, &no_arguments); | 222 __ Cbz(x0, &no_arguments); |
224 __ Sub(x0, x0, 1); | 223 __ Sub(x0, x0, 1); |
225 __ Drop(x0); | 224 __ Drop(x0); |
226 __ Ldr(x2, MemOperand(jssp, 2 * kPointerSize, PostIndex)); | 225 __ Ldr(x2, MemOperand(jssp, 2 * kPointerSize, PostIndex)); |
227 __ B(&done); | 226 __ B(&done); |
228 __ Bind(&no_arguments); | 227 __ Bind(&no_arguments); |
229 __ Drop(1); | 228 __ Drop(1); |
230 __ LoadRoot(x2, Heap::kempty_stringRootIndex); | 229 __ LoadRoot(x2, Heap::kempty_stringRootIndex); |
231 __ Bind(&done); | 230 __ Bind(&done); |
232 } | 231 } |
233 | 232 |
234 // 2. Make sure x2 is a string. | 233 // 2. Make sure x2 is a string. |
235 { | 234 { |
236 Label convert, done_convert; | 235 Label convert, done_convert; |
237 __ JumpIfSmi(x2, &convert); | 236 __ JumpIfSmi(x2, &convert); |
238 __ JumpIfObjectType(x2, x4, x4, FIRST_NONSTRING_TYPE, &done_convert, lo); | 237 __ JumpIfObjectType(x2, x3, x3, FIRST_NONSTRING_TYPE, &done_convert, lo); |
239 __ Bind(&convert); | 238 __ Bind(&convert); |
240 { | 239 { |
241 FrameScope scope(masm, StackFrame::INTERNAL); | 240 FrameScope scope(masm, StackFrame::INTERNAL); |
242 ToStringStub stub(masm->isolate()); | 241 ToStringStub stub(masm->isolate()); |
243 __ Push(x1, x3); | 242 __ Push(x1); |
244 __ Move(x0, x2); | 243 __ Move(x0, x2); |
245 __ CallStub(&stub); | 244 __ CallStub(&stub); |
246 __ Move(x2, x0); | 245 __ Move(x2, x0); |
247 __ Pop(x1, x3); | 246 __ Pop(x1); |
248 } | 247 } |
249 __ Bind(&done_convert); | 248 __ Bind(&done_convert); |
250 } | 249 } |
251 | 250 |
252 // 3. Allocate a JSValue wrapper for the string. | 251 // 3. Allocate a JSValue wrapper for the string. |
253 { | 252 { |
254 // ----------- S t a t e ------------- | 253 // ----------- S t a t e ------------- |
| 254 // -- x1 : constructor function |
255 // -- x2 : the first argument | 255 // -- x2 : the first argument |
256 // -- x1 : constructor function | |
257 // -- x3 : original constructor | |
258 // -- lr : return address | 256 // -- lr : return address |
259 // ----------------------------------- | 257 // ----------------------------------- |
260 | 258 |
261 Label allocate, done_allocate, rt_call; | 259 Label allocate, done_allocate; |
262 | |
263 // Fall back to runtime if the original constructor and function differ. | |
264 __ cmp(x1, x3); | |
265 __ B(ne, &rt_call); | |
266 | |
267 __ Allocate(JSValue::kSize, x0, x3, x4, &allocate, TAG_OBJECT); | 260 __ Allocate(JSValue::kSize, x0, x3, x4, &allocate, TAG_OBJECT); |
268 __ Bind(&done_allocate); | 261 __ Bind(&done_allocate); |
269 | 262 |
270 // Initialize the JSValue in eax. | 263 // Initialize the JSValue in eax. |
271 __ LoadGlobalFunctionInitialMap(x1, x3, x4); | 264 __ LoadGlobalFunctionInitialMap(x1, x3, x4); |
272 __ Str(x3, FieldMemOperand(x0, HeapObject::kMapOffset)); | 265 __ Str(x3, FieldMemOperand(x0, HeapObject::kMapOffset)); |
273 __ LoadRoot(x3, Heap::kEmptyFixedArrayRootIndex); | 266 __ LoadRoot(x3, Heap::kEmptyFixedArrayRootIndex); |
274 __ Str(x3, FieldMemOperand(x0, JSObject::kPropertiesOffset)); | 267 __ Str(x3, FieldMemOperand(x0, JSObject::kPropertiesOffset)); |
275 __ Str(x3, FieldMemOperand(x0, JSObject::kElementsOffset)); | 268 __ Str(x3, FieldMemOperand(x0, JSObject::kElementsOffset)); |
276 __ Str(x2, FieldMemOperand(x0, JSValue::kValueOffset)); | 269 __ Str(x2, FieldMemOperand(x0, JSValue::kValueOffset)); |
277 STATIC_ASSERT(JSValue::kSize == 4 * kPointerSize); | 270 STATIC_ASSERT(JSValue::kSize == 4 * kPointerSize); |
278 __ Ret(); | 271 __ Ret(); |
279 | 272 |
280 // Fallback to the runtime to allocate in new space. | 273 // Fallback to the runtime to allocate in new space. |
281 __ Bind(&allocate); | 274 __ Bind(&allocate); |
282 { | 275 { |
283 FrameScope scope(masm, StackFrame::INTERNAL); | 276 FrameScope scope(masm, StackFrame::INTERNAL); |
284 __ Push(x1, x2); | 277 __ Push(x1, x2); |
285 __ Push(Smi::FromInt(JSValue::kSize)); | 278 __ Push(Smi::FromInt(JSValue::kSize)); |
286 __ CallRuntime(Runtime::kAllocateInNewSpace, 1); | 279 __ CallRuntime(Runtime::kAllocateInNewSpace, 1); |
287 __ Pop(x2, x1); | 280 __ Pop(x2, x1); |
288 } | 281 } |
289 __ B(&done_allocate); | 282 __ B(&done_allocate); |
290 | |
291 // Fallback to the runtime to create new object. | |
292 __ bind(&rt_call); | |
293 { | |
294 FrameScope scope(masm, StackFrame::INTERNAL); | |
295 __ Push(x1, x2, x1, x3); // constructor function, original constructor | |
296 __ CallRuntime(Runtime::kNewObject, 2); | |
297 __ Pop(x2, x1); | |
298 } | |
299 __ Str(x2, FieldMemOperand(x0, JSValue::kValueOffset)); | |
300 __ Ret(); | |
301 } | 283 } |
302 } | 284 } |
303 | 285 |
304 | 286 |
305 static void CallRuntimePassFunction(MacroAssembler* masm, | 287 static void CallRuntimePassFunction(MacroAssembler* masm, |
306 Runtime::FunctionId function_id) { | 288 Runtime::FunctionId function_id) { |
307 FrameScope scope(masm, StackFrame::INTERNAL); | 289 FrameScope scope(masm, StackFrame::INTERNAL); |
308 // - Push a copy of the function onto the stack. | 290 // - Push a copy of the function onto the stack. |
309 // - Push another copy as a parameter to the runtime call. | 291 // - Push another copy as a parameter to the runtime call. |
310 __ Push(x1, x1); | 292 __ Push(x1, x1); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 GenerateTailCallToSharedCode(masm); | 329 GenerateTailCallToSharedCode(masm); |
348 } | 330 } |
349 | 331 |
350 | 332 |
351 static void Generate_JSConstructStubHelper(MacroAssembler* masm, | 333 static void Generate_JSConstructStubHelper(MacroAssembler* masm, |
352 bool is_api_function) { | 334 bool is_api_function) { |
353 // ----------- S t a t e ------------- | 335 // ----------- S t a t e ------------- |
354 // -- x0 : number of arguments | 336 // -- x0 : number of arguments |
355 // -- x1 : constructor function | 337 // -- x1 : constructor function |
356 // -- x2 : allocation site or undefined | 338 // -- x2 : allocation site or undefined |
357 // -- x3 : original constructor | 339 // -- x3 : original constructor |
358 // -- lr : return address | 340 // -- lr : return address |
359 // -- sp[...]: constructor arguments | 341 // -- sp[...]: constructor arguments |
360 // ----------------------------------- | 342 // ----------------------------------- |
361 | 343 |
362 ASM_LOCATION("Builtins::Generate_JSConstructStubHelper"); | 344 ASM_LOCATION("Builtins::Generate_JSConstructStubHelper"); |
363 | 345 |
364 Isolate* isolate = masm->isolate(); | 346 Isolate* isolate = masm->isolate(); |
365 | 347 |
366 // Enter a construct frame. | 348 // Enter a construct frame. |
367 { | 349 { |
(...skipping 1637 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2005 } | 1987 } |
2006 } | 1988 } |
2007 | 1989 |
2008 | 1990 |
2009 #undef __ | 1991 #undef __ |
2010 | 1992 |
2011 } // namespace internal | 1993 } // namespace internal |
2012 } // namespace v8 | 1994 } // namespace v8 |
2013 | 1995 |
2014 #endif // V8_TARGET_ARCH_ARM | 1996 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |