| 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 673 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 684 // Emit the write barrier code if the location is in the heap. | 684 // Emit the write barrier code if the location is in the heap. |
| 685 if (dst->type() == Slot::CONTEXT) { | 685 if (dst->type() == Slot::CONTEXT) { |
| 686 __ RecordWrite(scratch1, | 686 __ RecordWrite(scratch1, |
| 687 Operand(Context::SlotOffset(dst->index())), | 687 Operand(Context::SlotOffset(dst->index())), |
| 688 scratch2, | 688 scratch2, |
| 689 src); | 689 src); |
| 690 } | 690 } |
| 691 } | 691 } |
| 692 | 692 |
| 693 | 693 |
| 694 void FullCodeGenerator::EmitDeclaration(Variable* variable, | 694 void FullCodeGenerator::EmitDeclaration(VariableProxy* proxy, |
| 695 Variable::Mode mode, | 695 Variable::Mode mode, |
| 696 FunctionLiteral* function) { | 696 FunctionLiteral* function) { |
| 697 Comment cmnt(masm_, "[ Declaration"); | 697 Comment cmnt(masm_, "[ Declaration"); |
| 698 Variable* variable = proxy->var(); |
| 698 ASSERT(variable != NULL); // Must have been resolved. | 699 ASSERT(variable != NULL); // Must have been resolved. |
| 699 Slot* slot = variable->AsSlot(); | 700 Slot* slot = variable->AsSlot(); |
| 700 ASSERT(slot != NULL); | 701 ASSERT(slot != NULL); |
| 701 switch (slot->type()) { | 702 switch (slot->type()) { |
| 702 case Slot::PARAMETER: | 703 case Slot::PARAMETER: |
| 703 case Slot::LOCAL: | 704 case Slot::LOCAL: |
| 704 if (function != NULL) { | 705 if (function != NULL) { |
| 705 VisitForAccumulatorValue(function); | 706 VisitForAccumulatorValue(function); |
| 706 __ sw(result_register(), MemOperand(fp, SlotOffset(slot))); | 707 __ sw(result_register(), MemOperand(fp, SlotOffset(slot))); |
| 707 } else if (mode == Variable::CONST || mode == Variable::LET) { | 708 } else if (mode == Variable::CONST || mode == Variable::LET) { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 727 __ Check(ne, "Declaration in catch context.", | 728 __ Check(ne, "Declaration in catch context.", |
| 728 a1, Operand(t0)); | 729 a1, Operand(t0)); |
| 729 } | 730 } |
| 730 if (function != NULL) { | 731 if (function != NULL) { |
| 731 VisitForAccumulatorValue(function); | 732 VisitForAccumulatorValue(function); |
| 732 __ sw(result_register(), ContextOperand(cp, slot->index())); | 733 __ sw(result_register(), ContextOperand(cp, slot->index())); |
| 733 int offset = Context::SlotOffset(slot->index()); | 734 int offset = Context::SlotOffset(slot->index()); |
| 734 // We know that we have written a function, which is not a smi. | 735 // We know that we have written a function, which is not a smi. |
| 735 __ mov(a1, cp); | 736 __ mov(a1, cp); |
| 736 __ RecordWrite(a1, Operand(offset), a2, result_register()); | 737 __ RecordWrite(a1, Operand(offset), a2, result_register()); |
| 738 PrepareForBailoutForId(proxy->id(), NO_REGISTERS); |
| 737 } else if (mode == Variable::CONST || mode == Variable::LET) { | 739 } else if (mode == Variable::CONST || mode == Variable::LET) { |
| 738 __ LoadRoot(at, Heap::kTheHoleValueRootIndex); | 740 __ LoadRoot(at, Heap::kTheHoleValueRootIndex); |
| 739 __ sw(at, ContextOperand(cp, slot->index())); | 741 __ sw(at, ContextOperand(cp, slot->index())); |
| 740 // No write barrier since the_hole_value is in old space. | 742 // No write barrier since the_hole_value is in old space. |
| 743 PrepareForBailoutForId(proxy->id(), NO_REGISTERS); |
| 741 } | 744 } |
| 742 break; | 745 break; |
| 743 | 746 |
| 744 case Slot::LOOKUP: { | 747 case Slot::LOOKUP: { |
| 745 __ li(a2, Operand(variable->name())); | 748 __ li(a2, Operand(variable->name())); |
| 746 // Declaration nodes are always introduced in one of two modes. | 749 // Declaration nodes are always introduced in one of two modes. |
| 747 ASSERT(mode == Variable::VAR || | 750 ASSERT(mode == Variable::VAR || |
| 748 mode == Variable::CONST || | 751 mode == Variable::CONST || |
| 749 mode == Variable::LET); | 752 mode == Variable::LET); |
| 750 PropertyAttributes attr = (mode == Variable::CONST) ? READ_ONLY : NONE; | 753 PropertyAttributes attr = (mode == Variable::CONST) ? READ_ONLY : NONE; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 767 __ Push(cp, a2, a1, a0); | 770 __ Push(cp, a2, a1, a0); |
| 768 } | 771 } |
| 769 __ CallRuntime(Runtime::kDeclareContextSlot, 4); | 772 __ CallRuntime(Runtime::kDeclareContextSlot, 4); |
| 770 break; | 773 break; |
| 771 } | 774 } |
| 772 } | 775 } |
| 773 } | 776 } |
| 774 | 777 |
| 775 | 778 |
| 776 void FullCodeGenerator::VisitDeclaration(Declaration* decl) { | 779 void FullCodeGenerator::VisitDeclaration(Declaration* decl) { |
| 777 EmitDeclaration(decl->proxy()->var(), decl->mode(), decl->fun()); | 780 EmitDeclaration(decl->proxy(), decl->mode(), decl->fun()); |
| 778 } | 781 } |
| 779 | 782 |
| 780 | 783 |
| 781 void FullCodeGenerator::DeclareGlobals(Handle<FixedArray> pairs) { | 784 void FullCodeGenerator::DeclareGlobals(Handle<FixedArray> pairs) { |
| 782 // Call the runtime to declare the globals. | 785 // Call the runtime to declare the globals. |
| 783 // The context is the first argument. | 786 // The context is the first argument. |
| 784 __ li(a1, Operand(pairs)); | 787 __ li(a1, Operand(pairs)); |
| 785 __ li(a0, Operand(Smi::FromInt(DeclareGlobalsFlags()))); | 788 __ li(a0, Operand(Smi::FromInt(DeclareGlobalsFlags()))); |
| 786 __ Push(cp, a1, a0); | 789 __ Push(cp, a1, a0); |
| 787 __ CallRuntime(Runtime::kDeclareGlobals, 3); | 790 __ CallRuntime(Runtime::kDeclareGlobals, 3); |
| (...skipping 3498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4286 __ Addu(at, a1, Operand(masm_->CodeObject())); | 4289 __ Addu(at, a1, Operand(masm_->CodeObject())); |
| 4287 __ Jump(at); | 4290 __ Jump(at); |
| 4288 } | 4291 } |
| 4289 | 4292 |
| 4290 | 4293 |
| 4291 #undef __ | 4294 #undef __ |
| 4292 | 4295 |
| 4293 } } // namespace v8::internal | 4296 } } // namespace v8::internal |
| 4294 | 4297 |
| 4295 #endif // V8_TARGET_ARCH_MIPS | 4298 #endif // V8_TARGET_ARCH_MIPS |
| OLD | NEW |