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_ARM | 5 #if V8_TARGET_ARCH_ARM |
6 | 6 |
7 #include "src/codegen.h" | 7 #include "src/codegen.h" |
8 #include "src/debug/debug.h" | 8 #include "src/debug/debug.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 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 | 311 |
312 CallRuntimePassFunction(masm, Runtime::kTryInstallOptimizedCode); | 312 CallRuntimePassFunction(masm, Runtime::kTryInstallOptimizedCode); |
313 GenerateTailCallToReturnedCode(masm); | 313 GenerateTailCallToReturnedCode(masm); |
314 | 314 |
315 __ bind(&ok); | 315 __ bind(&ok); |
316 GenerateTailCallToSharedCode(masm); | 316 GenerateTailCallToSharedCode(masm); |
317 } | 317 } |
318 | 318 |
319 | 319 |
320 static void Generate_JSConstructStubHelper(MacroAssembler* masm, | 320 static void Generate_JSConstructStubHelper(MacroAssembler* masm, |
321 bool is_api_function, | 321 bool is_api_function) { |
322 bool create_memento) { | |
323 // ----------- S t a t e ------------- | 322 // ----------- S t a t e ------------- |
324 // -- r0 : number of arguments | 323 // -- r0 : number of arguments |
325 // -- r1 : constructor function | 324 // -- r1 : constructor function |
326 // -- r2 : allocation site or undefined | 325 // -- r2 : allocation site or undefined |
327 // -- r3 : original constructor | 326 // -- r3 : original constructor |
328 // -- lr : return address | 327 // -- lr : return address |
329 // -- sp[...]: constructor arguments | 328 // -- sp[...]: constructor arguments |
330 // ----------------------------------- | 329 // ----------------------------------- |
331 | 330 |
332 // Should never create mementos for api functions. | |
333 DCHECK(!is_api_function || !create_memento); | |
334 | |
335 Isolate* isolate = masm->isolate(); | 331 Isolate* isolate = masm->isolate(); |
336 | 332 |
337 // Enter a construct frame. | 333 // Enter a construct frame. |
338 { | 334 { |
339 FrameAndConstantPoolScope scope(masm, StackFrame::CONSTRUCT); | 335 FrameAndConstantPoolScope scope(masm, StackFrame::CONSTRUCT); |
340 | 336 |
341 // Preserve the incoming parameters on the stack. | 337 // Preserve the incoming parameters on the stack. |
342 __ AssertUndefinedOrAllocationSite(r2, r4); | 338 __ AssertUndefinedOrAllocationSite(r2, r4); |
343 __ push(r2); | 339 __ push(r2); |
344 __ SmiTag(r0); | 340 __ SmiTag(r0); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 __ pop(r1); | 395 __ pop(r1); |
400 | 396 |
401 __ bind(&allocate); | 397 __ bind(&allocate); |
402 } | 398 } |
403 | 399 |
404 // Now allocate the JSObject on the heap. | 400 // Now allocate the JSObject on the heap. |
405 // r1: constructor function | 401 // r1: constructor function |
406 // r2: initial map | 402 // r2: initial map |
407 Label rt_call_reload_new_target; | 403 Label rt_call_reload_new_target; |
408 __ ldrb(r3, FieldMemOperand(r2, Map::kInstanceSizeOffset)); | 404 __ ldrb(r3, FieldMemOperand(r2, Map::kInstanceSizeOffset)); |
409 if (create_memento) { | |
410 __ add(r3, r3, Operand(AllocationMemento::kSize / kPointerSize)); | |
411 } | |
412 | 405 |
413 __ Allocate(r3, r4, r5, r6, &rt_call_reload_new_target, SIZE_IN_WORDS); | 406 __ Allocate(r3, r4, r5, r6, &rt_call_reload_new_target, SIZE_IN_WORDS); |
414 | 407 |
415 // Allocated the JSObject, now initialize the fields. Map is set to | 408 // Allocated the JSObject, now initialize the fields. Map is set to |
416 // initial map and properties and elements are set to empty fixed array. | 409 // initial map and properties and elements are set to empty fixed array. |
417 // r1: constructor function | 410 // r1: constructor function |
418 // r2: initial map | 411 // r2: initial map |
419 // r3: object size (including memento if create_memento) | 412 // r3: object size |
420 // r4: JSObject (not tagged) | 413 // r4: JSObject (not tagged) |
421 __ LoadRoot(r6, Heap::kEmptyFixedArrayRootIndex); | 414 __ LoadRoot(r6, Heap::kEmptyFixedArrayRootIndex); |
422 __ mov(r5, r4); | 415 __ mov(r5, r4); |
423 DCHECK_EQ(0 * kPointerSize, JSObject::kMapOffset); | 416 DCHECK_EQ(0 * kPointerSize, JSObject::kMapOffset); |
424 __ str(r2, MemOperand(r5, kPointerSize, PostIndex)); | 417 __ str(r2, MemOperand(r5, kPointerSize, PostIndex)); |
425 DCHECK_EQ(1 * kPointerSize, JSObject::kPropertiesOffset); | 418 DCHECK_EQ(1 * kPointerSize, JSObject::kPropertiesOffset); |
426 __ str(r6, MemOperand(r5, kPointerSize, PostIndex)); | 419 __ str(r6, MemOperand(r5, kPointerSize, PostIndex)); |
427 DCHECK_EQ(2 * kPointerSize, JSObject::kElementsOffset); | 420 DCHECK_EQ(2 * kPointerSize, JSObject::kElementsOffset); |
428 __ str(r6, MemOperand(r5, kPointerSize, PostIndex)); | 421 __ str(r6, MemOperand(r5, kPointerSize, PostIndex)); |
429 | 422 |
430 // Fill all the in-object properties with the appropriate filler. | 423 // Fill all the in-object properties with the appropriate filler. |
431 // r1: constructor function | 424 // r1: constructor function |
432 // r2: initial map | 425 // r2: initial map |
433 // r3: object size (in words, including memento if create_memento) | 426 // r3: object size |
434 // r4: JSObject (not tagged) | 427 // r4: JSObject (not tagged) |
435 // r5: First in-object property of JSObject (not tagged) | 428 // r5: First in-object property of JSObject (not tagged) |
436 DCHECK_EQ(3 * kPointerSize, JSObject::kHeaderSize); | 429 DCHECK_EQ(3 * kPointerSize, JSObject::kHeaderSize); |
437 __ LoadRoot(r6, Heap::kUndefinedValueRootIndex); | 430 __ LoadRoot(r6, Heap::kUndefinedValueRootIndex); |
438 | 431 |
439 if (!is_api_function) { | 432 if (!is_api_function) { |
440 Label no_inobject_slack_tracking; | 433 Label no_inobject_slack_tracking; |
441 | 434 |
442 // Check if slack tracking is enabled. | 435 // Check if slack tracking is enabled. |
443 __ ldr(ip, FieldMemOperand(r2, Map::kBitField3Offset)); | 436 __ ldr(ip, FieldMemOperand(r2, Map::kBitField3Offset)); |
(...skipping 18 matching lines...) Expand all Loading... |
462 __ Assert(le, kUnexpectedNumberOfPreAllocatedPropertyFields); | 455 __ Assert(le, kUnexpectedNumberOfPreAllocatedPropertyFields); |
463 } | 456 } |
464 __ InitializeFieldsWithFiller(r5, r0, r6); | 457 __ InitializeFieldsWithFiller(r5, r0, r6); |
465 // To allow for truncation. | 458 // To allow for truncation. |
466 __ LoadRoot(r6, Heap::kOnePointerFillerMapRootIndex); | 459 __ LoadRoot(r6, Heap::kOnePointerFillerMapRootIndex); |
467 // Fill the remaining fields with one pointer filler map. | 460 // Fill the remaining fields with one pointer filler map. |
468 | 461 |
469 __ bind(&no_inobject_slack_tracking); | 462 __ bind(&no_inobject_slack_tracking); |
470 } | 463 } |
471 | 464 |
472 if (create_memento) { | 465 __ add(r0, r4, Operand(r3, LSL, kPointerSizeLog2)); // End of object. |
473 __ sub(ip, r3, Operand(AllocationMemento::kSize / kPointerSize)); | 466 __ InitializeFieldsWithFiller(r5, r0, r6); |
474 __ add(r0, r4, Operand(ip, LSL, kPointerSizeLog2)); // End of object. | |
475 __ InitializeFieldsWithFiller(r5, r0, r6); | |
476 | |
477 // Fill in memento fields. | |
478 // r5: points to the allocated but uninitialized memento. | |
479 __ LoadRoot(r6, Heap::kAllocationMementoMapRootIndex); | |
480 DCHECK_EQ(0 * kPointerSize, AllocationMemento::kMapOffset); | |
481 __ str(r6, MemOperand(r5, kPointerSize, PostIndex)); | |
482 // Load the AllocationSite | |
483 __ ldr(r6, MemOperand(sp, 3 * kPointerSize)); | |
484 __ AssertUndefinedOrAllocationSite(r6, r0); | |
485 DCHECK_EQ(1 * kPointerSize, AllocationMemento::kAllocationSiteOffset); | |
486 __ str(r6, MemOperand(r5, kPointerSize, PostIndex)); | |
487 } else { | |
488 __ add(r0, r4, Operand(r3, LSL, kPointerSizeLog2)); // End of object. | |
489 __ InitializeFieldsWithFiller(r5, r0, r6); | |
490 } | |
491 | 467 |
492 // Add the object tag to make the JSObject real, so that we can continue | 468 // Add the object tag to make the JSObject real, so that we can continue |
493 // and jump into the continuation code at any time from now on. | 469 // and jump into the continuation code at any time from now on. |
494 __ add(r4, r4, Operand(kHeapObjectTag)); | 470 __ add(r4, r4, Operand(kHeapObjectTag)); |
495 | 471 |
496 // Continue with JSObject being successfully allocated | 472 // Continue with JSObject being successfully allocated |
497 // r4: JSObject | 473 // r4: JSObject |
498 __ jmp(&allocated); | 474 __ jmp(&allocated); |
499 | 475 |
500 // Reload the original constructor and fall-through. | 476 // Reload the original constructor and fall-through. |
501 __ bind(&rt_call_reload_new_target); | 477 __ bind(&rt_call_reload_new_target); |
502 __ ldr(r3, MemOperand(sp, 0 * kPointerSize)); | 478 __ ldr(r3, MemOperand(sp, 0 * kPointerSize)); |
503 } | 479 } |
504 | 480 |
505 // Allocate the new receiver object using the runtime call. | 481 // Allocate the new receiver object using the runtime call. |
506 // r1: constructor function | 482 // r1: constructor function |
507 // r3: original constructor | 483 // r3: original constructor |
508 __ bind(&rt_call); | 484 __ bind(&rt_call); |
509 if (create_memento) { | |
510 // Get the cell or allocation site. | |
511 __ ldr(r2, MemOperand(sp, 3 * kPointerSize)); | |
512 __ push(r2); // argument 1: allocation site | |
513 } | |
514 | 485 |
515 __ push(r1); // argument 2/1: constructor function | 486 __ push(r1); // argument 2/1: constructor function |
516 __ push(r3); // argument 3/2: original constructor | 487 __ push(r3); // argument 3/2: original constructor |
517 if (create_memento) { | 488 __ CallRuntime(Runtime::kNewObject, 2); |
518 __ CallRuntime(Runtime::kNewObjectWithAllocationSite, 3); | |
519 } else { | |
520 __ CallRuntime(Runtime::kNewObject, 2); | |
521 } | |
522 __ mov(r4, r0); | 489 __ mov(r4, r0); |
523 | 490 |
524 // Runtime_NewObjectWithAllocationSite increments allocation count. | |
525 // Skip the increment. | |
526 Label count_incremented; | |
527 if (create_memento) { | |
528 __ jmp(&count_incremented); | |
529 } | |
530 | |
531 // Receiver for constructor call allocated. | 491 // Receiver for constructor call allocated. |
532 // r4: JSObject | 492 // r4: JSObject |
533 __ bind(&allocated); | 493 __ bind(&allocated); |
534 | 494 |
535 if (create_memento) { | |
536 __ ldr(r2, MemOperand(sp, 3 * kPointerSize)); | |
537 __ LoadRoot(r5, Heap::kUndefinedValueRootIndex); | |
538 __ cmp(r2, r5); | |
539 __ b(eq, &count_incremented); | |
540 // r2 is an AllocationSite. We are creating a memento from it, so we | |
541 // need to increment the memento create count. | |
542 __ ldr(r3, FieldMemOperand(r2, | |
543 AllocationSite::kPretenureCreateCountOffset)); | |
544 __ add(r3, r3, Operand(Smi::FromInt(1))); | |
545 __ str(r3, FieldMemOperand(r2, | |
546 AllocationSite::kPretenureCreateCountOffset)); | |
547 __ bind(&count_incremented); | |
548 } | |
549 | |
550 // Restore the parameters. | 495 // Restore the parameters. |
551 __ pop(r3); | 496 __ pop(r3); |
552 __ pop(r1); | 497 __ pop(r1); |
553 | 498 |
554 // Retrieve smi-tagged arguments count from the stack. | 499 // Retrieve smi-tagged arguments count from the stack. |
555 __ ldr(r0, MemOperand(sp)); | 500 __ ldr(r0, MemOperand(sp)); |
556 __ SmiUntag(r0); | 501 __ SmiUntag(r0); |
557 | 502 |
558 // Push new.target onto the construct frame. This is stored just below the | 503 // Push new.target onto the construct frame. This is stored just below the |
559 // receiver on the stack. | 504 // receiver on the stack. |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
643 } | 588 } |
644 | 589 |
645 __ add(sp, sp, Operand(r1, LSL, kPointerSizeLog2 - 1)); | 590 __ add(sp, sp, Operand(r1, LSL, kPointerSizeLog2 - 1)); |
646 __ add(sp, sp, Operand(kPointerSize)); | 591 __ add(sp, sp, Operand(kPointerSize)); |
647 __ IncrementCounter(isolate->counters()->constructed_objects(), 1, r1, r2); | 592 __ IncrementCounter(isolate->counters()->constructed_objects(), 1, r1, r2); |
648 __ Jump(lr); | 593 __ Jump(lr); |
649 } | 594 } |
650 | 595 |
651 | 596 |
652 void Builtins::Generate_JSConstructStubGeneric(MacroAssembler* masm) { | 597 void Builtins::Generate_JSConstructStubGeneric(MacroAssembler* masm) { |
653 Generate_JSConstructStubHelper(masm, false, FLAG_pretenuring_call_new); | 598 Generate_JSConstructStubHelper(masm, false); |
654 } | 599 } |
655 | 600 |
656 | 601 |
657 void Builtins::Generate_JSConstructStubApi(MacroAssembler* masm) { | 602 void Builtins::Generate_JSConstructStubApi(MacroAssembler* masm) { |
658 Generate_JSConstructStubHelper(masm, true, false); | 603 Generate_JSConstructStubHelper(masm, true); |
659 } | 604 } |
660 | 605 |
661 | 606 |
662 void Builtins::Generate_JSConstructStubForDerived(MacroAssembler* masm) { | 607 void Builtins::Generate_JSConstructStubForDerived(MacroAssembler* masm) { |
663 // ----------- S t a t e ------------- | 608 // ----------- S t a t e ------------- |
664 // -- r0 : number of arguments | 609 // -- r0 : number of arguments |
665 // -- r1 : constructor function | 610 // -- r1 : constructor function |
666 // -- r2 : allocation site or undefined | 611 // -- r2 : allocation site or undefined |
667 // -- r3 : original constructor | 612 // -- r3 : original constructor |
668 // -- lr : return address | 613 // -- lr : return address |
(...skipping 1174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1843 } | 1788 } |
1844 } | 1789 } |
1845 | 1790 |
1846 | 1791 |
1847 #undef __ | 1792 #undef __ |
1848 | 1793 |
1849 } // namespace internal | 1794 } // namespace internal |
1850 } // namespace v8 | 1795 } // namespace v8 |
1851 | 1796 |
1852 #endif // V8_TARGET_ARCH_ARM | 1797 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |