OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
652 } | 652 } |
653 | 653 |
654 if (should_normalize) { | 654 if (should_normalize) { |
655 __ CompareRoot(rax, Heap::kTrueValueRootIndex); | 655 __ CompareRoot(rax, Heap::kTrueValueRootIndex); |
656 Split(equal, if_true, if_false, NULL); | 656 Split(equal, if_true, if_false, NULL); |
657 __ bind(&skip); | 657 __ bind(&skip); |
658 } | 658 } |
659 } | 659 } |
660 | 660 |
661 | 661 |
662 void FullCodeGenerator::EmitDeclaration(Variable* variable, | 662 void FullCodeGenerator::EmitDeclaration(VariableProxy* proxy, |
663 Variable::Mode mode, | 663 Variable::Mode mode, |
664 FunctionLiteral* function) { | 664 FunctionLiteral* function) { |
665 Comment cmnt(masm_, "[ Declaration"); | 665 Comment cmnt(masm_, "[ Declaration"); |
| 666 Variable* variable = proxy->var(); |
666 ASSERT(variable != NULL); // Must have been resolved. | 667 ASSERT(variable != NULL); // Must have been resolved. |
667 Slot* slot = variable->AsSlot(); | 668 Slot* slot = variable->AsSlot(); |
668 ASSERT(slot != NULL); | 669 ASSERT(slot != NULL); |
669 switch (slot->type()) { | 670 switch (slot->type()) { |
670 case Slot::PARAMETER: | 671 case Slot::PARAMETER: |
671 case Slot::LOCAL: | 672 case Slot::LOCAL: |
672 if (function != NULL) { | 673 if (function != NULL) { |
673 VisitForAccumulatorValue(function); | 674 VisitForAccumulatorValue(function); |
674 __ movq(Operand(rbp, SlotOffset(slot)), result_register()); | 675 __ movq(Operand(rbp, SlotOffset(slot)), result_register()); |
675 } else if (mode == Variable::CONST || mode == Variable::LET) { | 676 } else if (mode == Variable::CONST || mode == Variable::LET) { |
(...skipping 16 matching lines...) Expand all Loading... |
692 __ Check(not_equal, "Declaration in with context."); | 693 __ Check(not_equal, "Declaration in with context."); |
693 __ CompareRoot(rbx, Heap::kCatchContextMapRootIndex); | 694 __ CompareRoot(rbx, Heap::kCatchContextMapRootIndex); |
694 __ Check(not_equal, "Declaration in catch context."); | 695 __ Check(not_equal, "Declaration in catch context."); |
695 } | 696 } |
696 if (function != NULL) { | 697 if (function != NULL) { |
697 VisitForAccumulatorValue(function); | 698 VisitForAccumulatorValue(function); |
698 __ movq(ContextOperand(rsi, slot->index()), result_register()); | 699 __ movq(ContextOperand(rsi, slot->index()), result_register()); |
699 int offset = Context::SlotOffset(slot->index()); | 700 int offset = Context::SlotOffset(slot->index()); |
700 __ movq(rbx, rsi); | 701 __ movq(rbx, rsi); |
701 __ RecordWrite(rbx, offset, result_register(), rcx); | 702 __ RecordWrite(rbx, offset, result_register(), rcx); |
| 703 PrepareForBailoutForId(proxy->id(), NO_REGISTERS); |
702 } else if (mode == Variable::CONST || mode == Variable::LET) { | 704 } else if (mode == Variable::CONST || mode == Variable::LET) { |
703 __ LoadRoot(kScratchRegister, Heap::kTheHoleValueRootIndex); | 705 __ LoadRoot(kScratchRegister, Heap::kTheHoleValueRootIndex); |
704 __ movq(ContextOperand(rsi, slot->index()), kScratchRegister); | 706 __ movq(ContextOperand(rsi, slot->index()), kScratchRegister); |
705 // No write barrier since the hole value is in old space. | 707 // No write barrier since the hole value is in old space. |
| 708 PrepareForBailoutForId(proxy->id(), NO_REGISTERS); |
706 } | 709 } |
707 break; | 710 break; |
708 | 711 |
709 case Slot::LOOKUP: { | 712 case Slot::LOOKUP: { |
710 __ push(rsi); | 713 __ push(rsi); |
711 __ Push(variable->name()); | 714 __ Push(variable->name()); |
712 // Declaration nodes are always introduced in one of two modes. | 715 // Declaration nodes are always introduced in one of two modes. |
713 ASSERT(mode == Variable::VAR || | 716 ASSERT(mode == Variable::VAR || |
714 mode == Variable::CONST || | 717 mode == Variable::CONST || |
715 mode == Variable::LET); | 718 mode == Variable::LET); |
(...skipping 11 matching lines...) Expand all Loading... |
727 __ Push(Smi::FromInt(0)); // no initial value! | 730 __ Push(Smi::FromInt(0)); // no initial value! |
728 } | 731 } |
729 __ CallRuntime(Runtime::kDeclareContextSlot, 4); | 732 __ CallRuntime(Runtime::kDeclareContextSlot, 4); |
730 break; | 733 break; |
731 } | 734 } |
732 } | 735 } |
733 } | 736 } |
734 | 737 |
735 | 738 |
736 void FullCodeGenerator::VisitDeclaration(Declaration* decl) { | 739 void FullCodeGenerator::VisitDeclaration(Declaration* decl) { |
737 EmitDeclaration(decl->proxy()->var(), decl->mode(), decl->fun()); | 740 EmitDeclaration(decl->proxy(), decl->mode(), decl->fun()); |
738 } | 741 } |
739 | 742 |
740 | 743 |
741 void FullCodeGenerator::DeclareGlobals(Handle<FixedArray> pairs) { | 744 void FullCodeGenerator::DeclareGlobals(Handle<FixedArray> pairs) { |
742 // Call the runtime to declare the globals. | 745 // Call the runtime to declare the globals. |
743 __ push(rsi); // The context is the first argument. | 746 __ push(rsi); // The context is the first argument. |
744 __ Push(pairs); | 747 __ Push(pairs); |
745 __ Push(Smi::FromInt(DeclareGlobalsFlags())); | 748 __ Push(Smi::FromInt(DeclareGlobalsFlags())); |
746 __ CallRuntime(Runtime::kDeclareGlobals, 3); | 749 __ CallRuntime(Runtime::kDeclareGlobals, 3); |
747 // Return value is ignored. | 750 // Return value is ignored. |
(...skipping 3461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4209 __ jmp(rdx); | 4212 __ jmp(rdx); |
4210 } | 4213 } |
4211 | 4214 |
4212 | 4215 |
4213 #undef __ | 4216 #undef __ |
4214 | 4217 |
4215 | 4218 |
4216 } } // namespace v8::internal | 4219 } } // namespace v8::internal |
4217 | 4220 |
4218 #endif // V8_TARGET_ARCH_X64 | 4221 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |