OLD | NEW |
1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
565 TestAndBranch(r0, &discard, false_label_); | 565 TestAndBranch(r0, &discard, false_label_); |
566 __ bind(&discard); | 566 __ bind(&discard); |
567 __ pop(); | 567 __ pop(); |
568 __ jmp(true_label_); | 568 __ jmp(true_label_); |
569 break; | 569 break; |
570 } | 570 } |
571 } | 571 } |
572 } | 572 } |
573 | 573 |
574 | 574 |
575 void FastCodeGenerator::EmitVariableAssignment(Expression::Context context, | 575 void FastCodeGenerator::EmitVariableAssignment(Assignment* expr) { |
576 Variable* var) { | 576 Variable* var = expr->target()->AsVariableProxy()->AsVariable(); |
| 577 ASSERT(var != NULL); |
| 578 |
577 if (var->is_global()) { | 579 if (var->is_global()) { |
578 // Assignment to a global variable, use inline caching. Right-hand-side | 580 // Assignment to a global variable. Use inline caching for the |
579 // value is passed in r0, variable name in r2, and the global object | 581 // assignment. Right-hand-side value is passed in r0, variable name in |
580 // on the stack. | 582 // r2, and the global object on the stack. |
581 __ pop(r0); | 583 __ pop(r0); |
582 __ mov(r2, Operand(var->name())); | 584 __ mov(r2, Operand(var->name())); |
583 __ ldr(ip, CodeGenerator::GlobalObject()); | 585 __ ldr(ip, CodeGenerator::GlobalObject()); |
584 __ push(ip); | 586 __ push(ip); |
585 Handle<Code> ic(Builtins::builtin(Builtins::StoreIC_Initialize)); | 587 Handle<Code> ic(Builtins::builtin(Builtins::StoreIC_Initialize)); |
586 __ Call(ic, RelocInfo::CODE_TARGET); | 588 __ Call(ic, RelocInfo::CODE_TARGET); |
587 // Overwrite the global object on the stack with the result if needed. | 589 // Overwrite the global object on the stack with the result if needed. |
588 DropAndMove(context, r0); | 590 DropAndMove(expr->context(), r0); |
| 591 |
589 } else { | 592 } else { |
590 switch (context) { | 593 switch (expr->context()) { |
591 case Expression::kUninitialized: | 594 case Expression::kUninitialized: |
592 UNREACHABLE(); | 595 UNREACHABLE(); |
593 case Expression::kEffect: | 596 case Expression::kEffect: |
594 // Perform assignment and discard value. | 597 // Perform assignment and discard value. |
595 __ pop(r0); | 598 __ pop(r0); |
596 __ str(r0, MemOperand(fp, SlotOffset(var->slot()))); | 599 __ str(r0, MemOperand(fp, SlotOffset(var->slot()))); |
597 break; | 600 break; |
598 case Expression::kValue: | 601 case Expression::kValue: |
599 // Perform assignment and preserve value. | 602 // Perform assignment and preserve value. |
600 __ ldr(r0, MemOperand(sp)); | 603 __ ldr(r0, MemOperand(sp)); |
(...skipping 23 matching lines...) Expand all Loading... |
624 __ bind(&discard); | 627 __ bind(&discard); |
625 __ pop(); | 628 __ pop(); |
626 __ jmp(true_label_); | 629 __ jmp(true_label_); |
627 break; | 630 break; |
628 } | 631 } |
629 } | 632 } |
630 } | 633 } |
631 } | 634 } |
632 | 635 |
633 | 636 |
634 void FastCodeGenerator::EmitNamedPropertyAssignment( | 637 void FastCodeGenerator::EmitNamedPropertyAssignment(Assignment* expr) { |
635 Expression::Context context, | 638 // Assignment to a property, using a named store IC. |
636 Handle<Object> name) { | 639 Property* prop = expr->target()->AsProperty(); |
| 640 ASSERT(prop != NULL); |
| 641 ASSERT(prop->key()->AsLiteral() != NULL); |
| 642 |
| 643 // If the assignment starts a block of assignments to the same object, |
| 644 // change to slow case to avoid the quadratic behavior of repeatedly |
| 645 // adding fast properties. |
| 646 if (expr->starts_initialization_block()) { |
| 647 __ ldr(ip, MemOperand(sp, kPointerSize)); // Receiver is under value. |
| 648 __ push(ip); |
| 649 __ CallRuntime(Runtime::kToSlowProperties, 1); |
| 650 } |
| 651 |
637 __ pop(r0); | 652 __ pop(r0); |
638 __ mov(r2, Operand(name)); | 653 __ mov(r2, Operand(prop->key()->AsLiteral()->handle())); |
639 Handle<Code> ic(Builtins::builtin(Builtins::StoreIC_Initialize)); | 654 Handle<Code> ic(Builtins::builtin(Builtins::StoreIC_Initialize)); |
640 __ Call(ic, RelocInfo::CODE_TARGET); | 655 __ Call(ic, RelocInfo::CODE_TARGET); |
641 DropAndMove(context, r0); | 656 |
| 657 // If the assignment ends an initialization block, revert to fast case. |
| 658 if (expr->ends_initialization_block()) { |
| 659 __ push(r0); // Result of assignment, saved even if not needed. |
| 660 __ ldr(ip, MemOperand(sp, kPointerSize)); // Receiver is under value. |
| 661 __ push(ip); |
| 662 __ CallRuntime(Runtime::kToFastProperties, 1); |
| 663 __ pop(r0); |
| 664 } |
| 665 |
| 666 DropAndMove(expr->context(), r0); |
642 } | 667 } |
643 | 668 |
644 | 669 |
645 void FastCodeGenerator::EmitKeyedPropertyAssignment( | 670 void FastCodeGenerator::EmitKeyedPropertyAssignment(Assignment* expr) { |
646 Expression::Context context) { | 671 // Assignment to a property, using a keyed store IC. |
| 672 |
| 673 // If the assignment starts a block of assignments to the same object, |
| 674 // change to slow case to avoid the quadratic behavior of repeatedly |
| 675 // adding fast properties. |
| 676 if (expr->starts_initialization_block()) { |
| 677 // Reciever is under the key and value. |
| 678 __ ldr(ip, MemOperand(sp, 2 * kPointerSize)); |
| 679 __ push(ip); |
| 680 __ CallRuntime(Runtime::kToSlowProperties, 1); |
| 681 } |
| 682 |
647 __ pop(r0); | 683 __ pop(r0); |
648 Handle<Code> ic(Builtins::builtin(Builtins::KeyedStoreIC_Initialize)); | 684 Handle<Code> ic(Builtins::builtin(Builtins::KeyedStoreIC_Initialize)); |
649 __ Call(ic, RelocInfo::CODE_TARGET); | 685 __ Call(ic, RelocInfo::CODE_TARGET); |
| 686 |
| 687 // If the assignment ends an initialization block, revert to fast case. |
| 688 if (expr->ends_initialization_block()) { |
| 689 __ push(r0); // Result of assignment, saved even if not needed. |
| 690 // Reciever is under the key and value. |
| 691 __ ldr(ip, MemOperand(sp, 2 * kPointerSize)); |
| 692 __ push(ip); |
| 693 __ CallRuntime(Runtime::kToFastProperties, 1); |
| 694 __ pop(r0); |
| 695 } |
| 696 |
650 // Receiver and key are still on stack. | 697 // Receiver and key are still on stack. |
651 __ add(sp, sp, Operand(2 * kPointerSize)); | 698 __ add(sp, sp, Operand(2 * kPointerSize)); |
652 Move(context, r0); | 699 Move(expr->context(), r0); |
653 } | 700 } |
654 | 701 |
655 | 702 |
656 void FastCodeGenerator::VisitProperty(Property* expr) { | 703 void FastCodeGenerator::VisitProperty(Property* expr) { |
657 Comment cmnt(masm_, "[ Property"); | 704 Comment cmnt(masm_, "[ Property"); |
658 Expression* key = expr->key(); | 705 Expression* key = expr->key(); |
659 uint32_t dummy; | 706 uint32_t dummy; |
660 | 707 |
661 // Record the source position for the property load. | 708 // Record the source position for the property load. |
662 SetSourcePosition(expr->position()); | 709 SetSourcePosition(expr->position()); |
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1044 | 1091 |
1045 break; | 1092 break; |
1046 } | 1093 } |
1047 default: | 1094 default: |
1048 UNREACHABLE(); | 1095 UNREACHABLE(); |
1049 } | 1096 } |
1050 } | 1097 } |
1051 | 1098 |
1052 | 1099 |
1053 } } // namespace v8::internal | 1100 } } // namespace v8::internal |
OLD | NEW |