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 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #if V8_TARGET_ARCH_ARM | 7 #if V8_TARGET_ARCH_ARM |
8 | 8 |
9 #include "src/codegen.h" | 9 #include "src/codegen.h" |
10 #include "src/debug.h" | 10 #include "src/debug.h" |
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 } | 310 } |
311 | 311 |
312 | 312 |
313 static void Generate_JSConstructStubHelper(MacroAssembler* masm, | 313 static void Generate_JSConstructStubHelper(MacroAssembler* masm, |
314 bool is_api_function, | 314 bool is_api_function, |
315 bool create_memento) { | 315 bool create_memento) { |
316 // ----------- S t a t e ------------- | 316 // ----------- S t a t e ------------- |
317 // -- r0 : number of arguments | 317 // -- r0 : number of arguments |
318 // -- r1 : constructor function | 318 // -- r1 : constructor function |
319 // -- r2 : allocation site or undefined | 319 // -- r2 : allocation site or undefined |
| 320 // -- r3 : original constructor |
320 // -- lr : return address | 321 // -- lr : return address |
321 // -- sp[...]: constructor arguments | 322 // -- sp[...]: constructor arguments |
322 // ----------------------------------- | 323 // ----------------------------------- |
323 | 324 |
324 // Should never create mementos for api functions. | 325 // Should never create mementos for api functions. |
325 DCHECK(!is_api_function || !create_memento); | 326 DCHECK(!is_api_function || !create_memento); |
326 | 327 |
327 Isolate* isolate = masm->isolate(); | 328 Isolate* isolate = masm->isolate(); |
328 | 329 |
329 // Enter a construct frame. | 330 // Enter a construct frame. |
330 { | 331 { |
331 FrameAndConstantPoolScope scope(masm, StackFrame::CONSTRUCT); | 332 FrameAndConstantPoolScope scope(masm, StackFrame::CONSTRUCT); |
332 | 333 |
333 if (create_memento) { | 334 if (create_memento) { |
334 __ AssertUndefinedOrAllocationSite(r2, r3); | 335 __ AssertUndefinedOrAllocationSite(r2, r4); |
335 __ push(r2); | 336 __ push(r2); |
336 } | 337 } |
337 | 338 |
338 // Preserve the two incoming parameters on the stack. | 339 // Preserve the two incoming parameters on the stack. |
339 __ SmiTag(r0); | 340 __ SmiTag(r0); |
340 __ push(r0); // Smi-tagged arguments count. | 341 __ push(r0); // Smi-tagged arguments count. |
341 __ push(r1); // Constructor function. | 342 __ push(r1); // Constructor function. |
342 | 343 |
| 344 Label rt_call, allocated, normal_new, count_incremented; |
| 345 __ cmp(r1, r3); |
| 346 __ b(eq, &normal_new); |
| 347 |
| 348 // Original constructor and function are different. |
| 349 { |
| 350 if (create_memento) { |
| 351 // Get the cell or allocation site. |
| 352 __ ldr(r2, MemOperand(sp, 2 * kPointerSize)); |
| 353 __ push(r2); |
| 354 } |
| 355 |
| 356 __ push(r1); // argument for Runtime_NewObject |
| 357 __ push(r3); // original constructor |
| 358 if (create_memento) { |
| 359 __ CallRuntime(Runtime::kNewObjectWithAllocationSite, 3); |
| 360 } else { |
| 361 __ CallRuntime(Runtime::kNewObject, 2); |
| 362 } |
| 363 __ mov(r4, r0); |
| 364 |
| 365 // If we ended up using the runtime, and we want a memento, then the |
| 366 // runtime call made it for us, and we shouldn't do create count |
| 367 // increment. |
| 368 if (create_memento) { |
| 369 __ jmp(&count_incremented); |
| 370 } else { |
| 371 __ jmp(&allocated); |
| 372 } |
| 373 } |
| 374 __ bind(&normal_new); |
| 375 |
343 // Try to allocate the object without transitioning into C code. If any of | 376 // Try to allocate the object without transitioning into C code. If any of |
344 // the preconditions is not met, the code bails out to the runtime call. | 377 // the preconditions is not met, the code bails out to the runtime call. |
345 Label rt_call, allocated; | |
346 if (FLAG_inline_new) { | 378 if (FLAG_inline_new) { |
347 Label undo_allocation; | 379 Label undo_allocation; |
348 ExternalReference debug_step_in_fp = | 380 ExternalReference debug_step_in_fp = |
349 ExternalReference::debug_step_in_fp_address(isolate); | 381 ExternalReference::debug_step_in_fp_address(isolate); |
350 __ mov(r2, Operand(debug_step_in_fp)); | 382 __ mov(r2, Operand(debug_step_in_fp)); |
351 __ ldr(r2, MemOperand(r2)); | 383 __ ldr(r2, MemOperand(r2)); |
352 __ tst(r2, r2); | 384 __ tst(r2, r2); |
353 __ b(ne, &rt_call); | 385 __ b(ne, &rt_call); |
354 | 386 |
355 // Load the initial map and verify that it is in fact a map. | 387 // Load the initial map and verify that it is in fact a map. |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
569 // Allocate the new receiver object using the runtime call. | 601 // Allocate the new receiver object using the runtime call. |
570 // r1: constructor function | 602 // r1: constructor function |
571 __ bind(&rt_call); | 603 __ bind(&rt_call); |
572 if (create_memento) { | 604 if (create_memento) { |
573 // Get the cell or allocation site. | 605 // Get the cell or allocation site. |
574 __ ldr(r2, MemOperand(sp, 2 * kPointerSize)); | 606 __ ldr(r2, MemOperand(sp, 2 * kPointerSize)); |
575 __ push(r2); | 607 __ push(r2); |
576 } | 608 } |
577 | 609 |
578 __ push(r1); // argument for Runtime_NewObject | 610 __ push(r1); // argument for Runtime_NewObject |
| 611 __ push(r1); // original constructor |
579 if (create_memento) { | 612 if (create_memento) { |
580 __ CallRuntime(Runtime::kNewObjectWithAllocationSite, 2); | 613 __ CallRuntime(Runtime::kNewObjectWithAllocationSite, 3); |
581 } else { | 614 } else { |
582 __ CallRuntime(Runtime::kNewObject, 1); | 615 __ CallRuntime(Runtime::kNewObject, 2); |
583 } | 616 } |
584 __ mov(r4, r0); | 617 __ mov(r4, r0); |
585 | 618 |
586 // If we ended up using the runtime, and we want a memento, then the | 619 // If we ended up using the runtime, and we want a memento, then the |
587 // runtime call made it for us, and we shouldn't do create count | 620 // runtime call made it for us, and we shouldn't do create count |
588 // increment. | 621 // increment. |
589 Label count_incremented; | |
590 if (create_memento) { | 622 if (create_memento) { |
591 __ jmp(&count_incremented); | 623 __ jmp(&count_incremented); |
592 } | 624 } |
593 | 625 |
594 // Receiver for constructor call allocated. | 626 // Receiver for constructor call allocated. |
595 // r4: JSObject | 627 // r4: JSObject |
596 __ bind(&allocated); | 628 __ bind(&allocated); |
597 | 629 |
598 if (create_memento) { | 630 if (create_memento) { |
599 __ ldr(r2, MemOperand(sp, kPointerSize * 2)); | 631 __ ldr(r2, MemOperand(sp, kPointerSize * 2)); |
(...skipping 944 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1544 __ bkpt(0); | 1576 __ bkpt(0); |
1545 } | 1577 } |
1546 } | 1578 } |
1547 | 1579 |
1548 | 1580 |
1549 #undef __ | 1581 #undef __ |
1550 | 1582 |
1551 } } // namespace v8::internal | 1583 } } // namespace v8::internal |
1552 | 1584 |
1553 #endif // V8_TARGET_ARCH_ARM | 1585 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |