| 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 662 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 673 } else if (function != NULL) { | 673 } else if (function != NULL) { |
| 674 VisitForAccumulatorValue(function); | 674 VisitForAccumulatorValue(function); |
| 675 __ movq(Operand(rbp, SlotOffset(slot)), result_register()); | 675 __ movq(Operand(rbp, SlotOffset(slot)), result_register()); |
| 676 } | 676 } |
| 677 break; | 677 break; |
| 678 | 678 |
| 679 case Slot::CONTEXT: | 679 case Slot::CONTEXT: |
| 680 // We bypass the general EmitSlotSearch because we know more about | 680 // We bypass the general EmitSlotSearch because we know more about |
| 681 // this specific context. | 681 // this specific context. |
| 682 | 682 |
| 683 // The variable in the decl always resides in the current context. | 683 // The variable in the decl always resides in the current function |
| 684 // context. |
| 684 ASSERT_EQ(0, scope()->ContextChainLength(variable->scope())); | 685 ASSERT_EQ(0, scope()->ContextChainLength(variable->scope())); |
| 685 if (FLAG_debug_code) { | 686 if (FLAG_debug_code) { |
| 686 // Check if we have the correct context pointer. | 687 // Check that we're not inside a with or catch context. |
| 687 __ movq(rbx, ContextOperand(rsi, Context::FCONTEXT_INDEX)); | 688 __ movq(rbx, FieldOperand(rsi, HeapObject::kMapOffset)); |
| 688 __ cmpq(rbx, rsi); | 689 __ CompareRoot(rbx, Heap::kWithContextMapRootIndex); |
| 689 __ Check(equal, "Unexpected declaration in current context."); | 690 __ Check(not_equal, "Declaration in with context."); |
| 691 __ CompareRoot(rbx, Heap::kCatchContextMapRootIndex); |
| 692 __ Check(not_equal, "Declaration in catch context."); |
| 690 } | 693 } |
| 691 if (mode == Variable::CONST) { | 694 if (mode == Variable::CONST) { |
| 692 __ LoadRoot(kScratchRegister, Heap::kTheHoleValueRootIndex); | 695 __ LoadRoot(kScratchRegister, Heap::kTheHoleValueRootIndex); |
| 693 __ movq(ContextOperand(rsi, slot->index()), kScratchRegister); | 696 __ movq(ContextOperand(rsi, slot->index()), kScratchRegister); |
| 694 // No write barrier since the hole value is in old space. | 697 // No write barrier since the hole value is in old space. |
| 695 } else if (function != NULL) { | 698 } else if (function != NULL) { |
| 696 VisitForAccumulatorValue(function); | 699 VisitForAccumulatorValue(function); |
| 697 __ movq(ContextOperand(rsi, slot->index()), result_register()); | 700 __ movq(ContextOperand(rsi, slot->index()), result_register()); |
| 698 int offset = Context::SlotOffset(slot->index()); | 701 int offset = Context::SlotOffset(slot->index()); |
| 699 __ movq(rbx, rsi); | 702 __ movq(rbx, rsi); |
| (...skipping 1071 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1771 case Slot::PARAMETER: | 1774 case Slot::PARAMETER: |
| 1772 // No const parameters. | 1775 // No const parameters. |
| 1773 UNREACHABLE(); | 1776 UNREACHABLE(); |
| 1774 break; | 1777 break; |
| 1775 case Slot::LOCAL: | 1778 case Slot::LOCAL: |
| 1776 __ movq(rdx, Operand(rbp, SlotOffset(slot))); | 1779 __ movq(rdx, Operand(rbp, SlotOffset(slot))); |
| 1777 __ CompareRoot(rdx, Heap::kTheHoleValueRootIndex); | 1780 __ CompareRoot(rdx, Heap::kTheHoleValueRootIndex); |
| 1778 __ j(not_equal, &skip); | 1781 __ j(not_equal, &skip); |
| 1779 __ movq(Operand(rbp, SlotOffset(slot)), rax); | 1782 __ movq(Operand(rbp, SlotOffset(slot)), rax); |
| 1780 break; | 1783 break; |
| 1781 case Slot::CONTEXT: { | 1784 case Slot::CONTEXT: |
| 1782 __ movq(rcx, ContextOperand(rsi, Context::FCONTEXT_INDEX)); | |
| 1783 __ movq(rdx, ContextOperand(rcx, slot->index())); | |
| 1784 __ CompareRoot(rdx, Heap::kTheHoleValueRootIndex); | |
| 1785 __ j(not_equal, &skip); | |
| 1786 __ movq(ContextOperand(rcx, slot->index()), rax); | |
| 1787 int offset = Context::SlotOffset(slot->index()); | |
| 1788 __ movq(rdx, rax); // Preserve the stored value in eax. | |
| 1789 __ RecordWrite(rcx, offset, rdx, rbx); | |
| 1790 break; | |
| 1791 } | |
| 1792 case Slot::LOOKUP: | 1785 case Slot::LOOKUP: |
| 1793 __ push(rax); | 1786 __ push(rax); |
| 1794 __ push(rsi); | 1787 __ push(rsi); |
| 1795 __ Push(var->name()); | 1788 __ Push(var->name()); |
| 1796 __ CallRuntime(Runtime::kInitializeConstContextSlot, 3); | 1789 __ CallRuntime(Runtime::kInitializeConstContextSlot, 3); |
| 1797 break; | 1790 break; |
| 1798 } | 1791 } |
| 1799 __ bind(&skip); | 1792 __ bind(&skip); |
| 1800 | 1793 |
| 1801 } else if (var->mode() != Variable::CONST) { | 1794 } else if (var->mode() != Variable::CONST) { |
| (...skipping 1872 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3674 // TODO(svenpanne): Allowing format strings in Comment would be nice here... | 3667 // TODO(svenpanne): Allowing format strings in Comment would be nice here... |
| 3675 Comment cmt(masm_, comment); | 3668 Comment cmt(masm_, comment); |
| 3676 bool can_overwrite = expr->expression()->ResultOverwriteAllowed(); | 3669 bool can_overwrite = expr->expression()->ResultOverwriteAllowed(); |
| 3677 UnaryOverwriteMode overwrite = | 3670 UnaryOverwriteMode overwrite = |
| 3678 can_overwrite ? UNARY_OVERWRITE : UNARY_NO_OVERWRITE; | 3671 can_overwrite ? UNARY_OVERWRITE : UNARY_NO_OVERWRITE; |
| 3679 UnaryOpStub stub(expr->op(), overwrite); | 3672 UnaryOpStub stub(expr->op(), overwrite); |
| 3680 // UnaryOpStub expects the argument to be in the | 3673 // UnaryOpStub expects the argument to be in the |
| 3681 // accumulator register rax. | 3674 // accumulator register rax. |
| 3682 VisitForAccumulatorValue(expr->expression()); | 3675 VisitForAccumulatorValue(expr->expression()); |
| 3683 SetSourcePosition(expr->position()); | 3676 SetSourcePosition(expr->position()); |
| 3684 EmitCallIC(stub.GetCode(), NULL, expr->id()); | 3677 EmitCallIC(stub.GetCode(), RelocInfo::CODE_TARGET, expr->id()); |
| 3685 context()->Plug(rax); | 3678 context()->Plug(rax); |
| 3686 } | 3679 } |
| 3687 | 3680 |
| 3688 | 3681 |
| 3689 void FullCodeGenerator::VisitCountOperation(CountOperation* expr) { | 3682 void FullCodeGenerator::VisitCountOperation(CountOperation* expr) { |
| 3690 Comment cmnt(masm_, "[ CountOperation"); | 3683 Comment cmnt(masm_, "[ CountOperation"); |
| 3691 SetSourcePosition(expr->position()); | 3684 SetSourcePosition(expr->position()); |
| 3692 | 3685 |
| 3693 // Invalid left-hand-sides are rewritten to have a 'throw | 3686 // Invalid left-hand-sides are rewritten to have a 'throw |
| 3694 // ReferenceError' as the left-hand side. | 3687 // ReferenceError' as the left-hand side. |
| (...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4190 ASSERT(IsAligned(frame_offset, kPointerSize)); | 4183 ASSERT(IsAligned(frame_offset, kPointerSize)); |
| 4191 __ movq(Operand(rbp, frame_offset), value); | 4184 __ movq(Operand(rbp, frame_offset), value); |
| 4192 } | 4185 } |
| 4193 | 4186 |
| 4194 | 4187 |
| 4195 void FullCodeGenerator::LoadContextField(Register dst, int context_index) { | 4188 void FullCodeGenerator::LoadContextField(Register dst, int context_index) { |
| 4196 __ movq(dst, ContextOperand(rsi, context_index)); | 4189 __ movq(dst, ContextOperand(rsi, context_index)); |
| 4197 } | 4190 } |
| 4198 | 4191 |
| 4199 | 4192 |
| 4193 void FullCodeGenerator::PushFunctionArgumentForContextAllocation() { |
| 4194 if (scope()->is_global_scope()) { |
| 4195 // Contexts nested in the global context have a canonical empty function |
| 4196 // as their closure, not the anonymous closure containing the global |
| 4197 // code. Pass a smi sentinel and let the runtime look up the empty |
| 4198 // function. |
| 4199 __ Push(Smi::FromInt(0)); |
| 4200 } else if (scope()->is_eval_scope()) { |
| 4201 // Contexts created by a call to eval have the same closure as the |
| 4202 // context calling eval, not the anonymous closure containing the eval |
| 4203 // code. Fetch it from the context. |
| 4204 __ push(ContextOperand(rsi, Context::CLOSURE_INDEX)); |
| 4205 } else { |
| 4206 ASSERT(scope()->is_function_scope()); |
| 4207 __ push(Operand(rbp, JavaScriptFrameConstants::kFunctionOffset)); |
| 4208 } |
| 4209 } |
| 4210 |
| 4211 |
| 4200 // ---------------------------------------------------------------------------- | 4212 // ---------------------------------------------------------------------------- |
| 4201 // Non-local control flow support. | 4213 // Non-local control flow support. |
| 4202 | 4214 |
| 4203 | 4215 |
| 4204 void FullCodeGenerator::EnterFinallyBlock() { | 4216 void FullCodeGenerator::EnterFinallyBlock() { |
| 4205 ASSERT(!result_register().is(rdx)); | 4217 ASSERT(!result_register().is(rdx)); |
| 4206 ASSERT(!result_register().is(rcx)); | 4218 ASSERT(!result_register().is(rcx)); |
| 4207 // Cook return address on top of stack (smi encoded Code* delta) | 4219 // Cook return address on top of stack (smi encoded Code* delta) |
| 4208 __ movq(rdx, Operand(rsp, 0)); | 4220 __ movq(rdx, Operand(rsp, 0)); |
| 4209 __ Move(rcx, masm_->CodeObject()); | 4221 __ Move(rcx, masm_->CodeObject()); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 4230 __ ret(0); | 4242 __ ret(0); |
| 4231 } | 4243 } |
| 4232 | 4244 |
| 4233 | 4245 |
| 4234 #undef __ | 4246 #undef __ |
| 4235 | 4247 |
| 4236 | 4248 |
| 4237 } } // namespace v8::internal | 4249 } } // namespace v8::internal |
| 4238 | 4250 |
| 4239 #endif // V8_TARGET_ARCH_X64 | 4251 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |