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 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
483 // r3: new target | 483 // r3: new target |
484 // r4: JSObject | 484 // r4: JSObject |
485 __ bind(&allocated); | 485 __ bind(&allocated); |
486 | 486 |
487 // Retrieve smi-tagged arguments count from the stack. | 487 // Retrieve smi-tagged arguments count from the stack. |
488 __ ldr(r0, MemOperand(sp)); | 488 __ ldr(r0, MemOperand(sp)); |
489 } | 489 } |
490 | 490 |
491 __ SmiUntag(r0); | 491 __ SmiUntag(r0); |
492 | 492 |
493 // Push new.target onto the construct frame. This is stored just below the | |
494 // receiver on the stack. | |
495 __ push(r3); | |
496 | |
497 if (create_implicit_receiver) { | 493 if (create_implicit_receiver) { |
498 // Push the allocated receiver to the stack. We need two copies | 494 // Push the allocated receiver to the stack. We need two copies |
499 // because we may have to return the original one and the calling | 495 // because we may have to return the original one and the calling |
500 // conventions dictate that the called function pops the receiver. | 496 // conventions dictate that the called function pops the receiver. |
501 __ push(r4); | 497 __ push(r4); |
502 __ push(r4); | 498 __ push(r4); |
503 } else { | 499 } else { |
504 __ PushRoot(Heap::kTheHoleValueRootIndex); | 500 __ PushRoot(Heap::kTheHoleValueRootIndex); |
505 } | 501 } |
506 | 502 |
507 // Set up pointer to last argument. | 503 // Set up pointer to last argument. |
508 __ add(r2, fp, Operand(StandardFrameConstants::kCallerSPOffset)); | 504 __ add(r2, fp, Operand(StandardFrameConstants::kCallerSPOffset)); |
509 | 505 |
510 // Copy arguments and receiver to the expression stack. | 506 // Copy arguments and receiver to the expression stack. |
511 // r0: number of arguments | 507 // r0: number of arguments |
512 // r1: constructor function | 508 // r1: constructor function |
513 // r2: address of last argument (caller sp) | 509 // r2: address of last argument (caller sp) |
514 // r3: new target | 510 // r3: new target |
515 // r4: number of arguments (smi-tagged) | 511 // r4: number of arguments (smi-tagged) |
516 // sp[0]: receiver | 512 // sp[0]: receiver |
517 // sp[1]: receiver | 513 // sp[1]: receiver |
518 // sp[2]: new.target | 514 // sp[2]: number of arguments (smi-tagged) |
519 // sp[3]: number of arguments (smi-tagged) | |
520 Label loop, entry; | 515 Label loop, entry; |
521 __ SmiTag(r4, r0); | 516 __ SmiTag(r4, r0); |
522 __ b(&entry); | 517 __ b(&entry); |
523 __ bind(&loop); | 518 __ bind(&loop); |
524 __ ldr(ip, MemOperand(r2, r4, LSL, kPointerSizeLog2 - 1)); | 519 __ ldr(ip, MemOperand(r2, r4, LSL, kPointerSizeLog2 - 1)); |
525 __ push(ip); | 520 __ push(ip); |
526 __ bind(&entry); | 521 __ bind(&entry); |
527 __ sub(r4, r4, Operand(2), SetCC); | 522 __ sub(r4, r4, Operand(2), SetCC); |
528 __ b(ge, &loop); | 523 __ b(ge, &loop); |
529 | 524 |
(...skipping 13 matching lines...) Expand all Loading... |
543 } | 538 } |
544 | 539 |
545 // Store offset of return address for deoptimizer. | 540 // Store offset of return address for deoptimizer. |
546 if (create_implicit_receiver && !is_api_function) { | 541 if (create_implicit_receiver && !is_api_function) { |
547 masm->isolate()->heap()->SetConstructStubDeoptPCOffset(masm->pc_offset()); | 542 masm->isolate()->heap()->SetConstructStubDeoptPCOffset(masm->pc_offset()); |
548 } | 543 } |
549 | 544 |
550 // Restore context from the frame. | 545 // Restore context from the frame. |
551 // r0: result | 546 // r0: result |
552 // sp[0]: receiver | 547 // sp[0]: receiver |
553 // sp[1]: new.target | 548 // sp[1]: number of arguments (smi-tagged) |
554 // sp[2]: number of arguments (smi-tagged) | |
555 __ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); | 549 __ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
556 | 550 |
557 if (create_implicit_receiver) { | 551 if (create_implicit_receiver) { |
558 // If the result is an object (in the ECMA sense), we should get rid | 552 // If the result is an object (in the ECMA sense), we should get rid |
559 // of the receiver and use the result; see ECMA-262 section 13.2.2-7 | 553 // of the receiver and use the result; see ECMA-262 section 13.2.2-7 |
560 // on page 74. | 554 // on page 74. |
561 Label use_receiver, exit; | 555 Label use_receiver, exit; |
562 | 556 |
563 // If the result is a smi, it is *not* an object in the ECMA sense. | 557 // If the result is a smi, it is *not* an object in the ECMA sense. |
564 // r0: result | 558 // r0: result |
565 // sp[0]: receiver | 559 // sp[0]: receiver |
566 // sp[1]: new.target | 560 // sp[1]: number of arguments (smi-tagged) |
567 // sp[2]: number of arguments (smi-tagged) | |
568 __ JumpIfSmi(r0, &use_receiver); | 561 __ JumpIfSmi(r0, &use_receiver); |
569 | 562 |
570 // If the type of the result (stored in its map) is less than | 563 // If the type of the result (stored in its map) is less than |
571 // FIRST_JS_RECEIVER_TYPE, it is not an object in the ECMA sense. | 564 // FIRST_JS_RECEIVER_TYPE, it is not an object in the ECMA sense. |
572 __ CompareObjectType(r0, r1, r3, FIRST_JS_RECEIVER_TYPE); | 565 __ CompareObjectType(r0, r1, r3, FIRST_JS_RECEIVER_TYPE); |
573 __ b(ge, &exit); | 566 __ b(ge, &exit); |
574 | 567 |
575 // Throw away the result of the constructor invocation and use the | 568 // Throw away the result of the constructor invocation and use the |
576 // on-stack receiver as the result. | 569 // on-stack receiver as the result. |
577 __ bind(&use_receiver); | 570 __ bind(&use_receiver); |
578 __ ldr(r0, MemOperand(sp)); | 571 __ ldr(r0, MemOperand(sp)); |
579 | 572 |
580 // Remove receiver from the stack, remove caller arguments, and | 573 // Remove receiver from the stack, remove caller arguments, and |
581 // return. | 574 // return. |
582 __ bind(&exit); | 575 __ bind(&exit); |
583 // r0: result | 576 // r0: result |
584 // sp[0]: receiver (newly allocated object) | 577 // sp[0]: receiver (newly allocated object) |
585 // sp[1]: new target | 578 // sp[1]: number of arguments (smi-tagged) |
586 // sp[2]: number of arguments (smi-tagged) | 579 __ ldr(r1, MemOperand(sp, 1 * kPointerSize)); |
587 __ ldr(r1, MemOperand(sp, 2 * kPointerSize)); | |
588 } else { | 580 } else { |
589 __ ldr(r1, MemOperand(sp, kPointerSize)); | 581 __ ldr(r1, MemOperand(sp)); |
590 } | 582 } |
591 | 583 |
592 // Leave construct frame. | 584 // Leave construct frame. |
593 } | 585 } |
594 | 586 |
595 __ add(sp, sp, Operand(r1, LSL, kPointerSizeLog2 - 1)); | 587 __ add(sp, sp, Operand(r1, LSL, kPointerSizeLog2 - 1)); |
596 __ add(sp, sp, Operand(kPointerSize)); | 588 __ add(sp, sp, Operand(kPointerSize)); |
597 if (create_implicit_receiver) { | 589 if (create_implicit_receiver) { |
598 __ IncrementCounter(isolate->counters()->constructed_objects(), 1, r1, r2); | 590 __ IncrementCounter(isolate->counters()->constructed_objects(), 1, r1, r2); |
599 } | 591 } |
(...skipping 1340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1940 } | 1932 } |
1941 } | 1933 } |
1942 | 1934 |
1943 | 1935 |
1944 #undef __ | 1936 #undef __ |
1945 | 1937 |
1946 } // namespace internal | 1938 } // namespace internal |
1947 } // namespace v8 | 1939 } // namespace v8 |
1948 | 1940 |
1949 #endif // V8_TARGET_ARCH_ARM | 1941 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |