| 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 669 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 680 break; | 680 break; |
| 681 | 681 |
| 682 case Slot::CONTEXT: | 682 case Slot::CONTEXT: |
| 683 // We bypass the general EmitSlotSearch because we know more about | 683 // We bypass the general EmitSlotSearch because we know more about |
| 684 // this specific context. | 684 // this specific context. |
| 685 | 685 |
| 686 // The variable in the decl always resides in the current function | 686 // The variable in the decl always resides in the current function |
| 687 // context. | 687 // context. |
| 688 ASSERT_EQ(0, scope()->ContextChainLength(variable->scope())); | 688 ASSERT_EQ(0, scope()->ContextChainLength(variable->scope())); |
| 689 if (FLAG_debug_code) { | 689 if (FLAG_debug_code) { |
| 690 // Check that we're not inside a 'with'. | 690 // Check that we're not inside a with or catch context. |
| 691 __ mov(ebx, ContextOperand(esi, Context::FCONTEXT_INDEX)); | 691 __ mov(ebx, FieldOperand(esi, HeapObject::kMapOffset)); |
| 692 __ cmp(ebx, Operand(esi)); | 692 __ cmp(ebx, isolate()->factory()->with_context_map()); |
| 693 __ Check(equal, "Unexpected declaration in current context."); | 693 __ Check(not_equal, "Declaration in with context."); |
| 694 __ cmp(ebx, isolate()->factory()->catch_context_map()); |
| 695 __ Check(not_equal, "Declaration in catch context."); |
| 694 } | 696 } |
| 695 if (mode == Variable::CONST) { | 697 if (mode == Variable::CONST) { |
| 696 __ mov(ContextOperand(esi, slot->index()), | 698 __ mov(ContextOperand(esi, slot->index()), |
| 697 Immediate(isolate()->factory()->the_hole_value())); | 699 Immediate(isolate()->factory()->the_hole_value())); |
| 698 // No write barrier since the hole value is in old space. | 700 // No write barrier since the hole value is in old space. |
| 699 } else if (function != NULL) { | 701 } else if (function != NULL) { |
| 700 VisitForAccumulatorValue(function); | 702 VisitForAccumulatorValue(function); |
| 701 __ mov(ContextOperand(esi, slot->index()), result_register()); | 703 __ mov(ContextOperand(esi, slot->index()), result_register()); |
| 702 int offset = Context::SlotOffset(slot->index()); | 704 int offset = Context::SlotOffset(slot->index()); |
| 703 __ mov(ebx, esi); | 705 __ mov(ebx, esi); |
| (...skipping 1107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1811 case Slot::PARAMETER: | 1813 case Slot::PARAMETER: |
| 1812 // No const parameters. | 1814 // No const parameters. |
| 1813 UNREACHABLE(); | 1815 UNREACHABLE(); |
| 1814 break; | 1816 break; |
| 1815 case Slot::LOCAL: | 1817 case Slot::LOCAL: |
| 1816 __ mov(edx, Operand(ebp, SlotOffset(slot))); | 1818 __ mov(edx, Operand(ebp, SlotOffset(slot))); |
| 1817 __ cmp(edx, isolate()->factory()->the_hole_value()); | 1819 __ cmp(edx, isolate()->factory()->the_hole_value()); |
| 1818 __ j(not_equal, &skip); | 1820 __ j(not_equal, &skip); |
| 1819 __ mov(Operand(ebp, SlotOffset(slot)), eax); | 1821 __ mov(Operand(ebp, SlotOffset(slot)), eax); |
| 1820 break; | 1822 break; |
| 1821 case Slot::CONTEXT: { | 1823 case Slot::CONTEXT: |
| 1822 __ mov(ecx, ContextOperand(esi, Context::FCONTEXT_INDEX)); | |
| 1823 __ mov(edx, ContextOperand(ecx, slot->index())); | |
| 1824 __ cmp(edx, isolate()->factory()->the_hole_value()); | |
| 1825 __ j(not_equal, &skip); | |
| 1826 __ mov(ContextOperand(ecx, slot->index()), eax); | |
| 1827 int offset = Context::SlotOffset(slot->index()); | |
| 1828 __ mov(edx, eax); // Preserve the stored value in eax. | |
| 1829 __ RecordWrite(ecx, offset, edx, ebx); | |
| 1830 break; | |
| 1831 } | |
| 1832 case Slot::LOOKUP: | 1824 case Slot::LOOKUP: |
| 1833 __ push(eax); | 1825 __ push(eax); |
| 1834 __ push(esi); | 1826 __ push(esi); |
| 1835 __ push(Immediate(var->name())); | 1827 __ push(Immediate(var->name())); |
| 1836 __ CallRuntime(Runtime::kInitializeConstContextSlot, 3); | 1828 __ CallRuntime(Runtime::kInitializeConstContextSlot, 3); |
| 1837 break; | 1829 break; |
| 1838 } | 1830 } |
| 1839 __ bind(&skip); | 1831 __ bind(&skip); |
| 1840 | 1832 |
| 1841 } else if (var->mode() != Variable::CONST) { | 1833 } else if (var->mode() != Variable::CONST) { |
| (...skipping 1855 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3697 // TODO(svenpanne): Allowing format strings in Comment would be nice here... | 3689 // TODO(svenpanne): Allowing format strings in Comment would be nice here... |
| 3698 Comment cmt(masm_, comment); | 3690 Comment cmt(masm_, comment); |
| 3699 bool can_overwrite = expr->expression()->ResultOverwriteAllowed(); | 3691 bool can_overwrite = expr->expression()->ResultOverwriteAllowed(); |
| 3700 UnaryOverwriteMode overwrite = | 3692 UnaryOverwriteMode overwrite = |
| 3701 can_overwrite ? UNARY_OVERWRITE : UNARY_NO_OVERWRITE; | 3693 can_overwrite ? UNARY_OVERWRITE : UNARY_NO_OVERWRITE; |
| 3702 UnaryOpStub stub(expr->op(), overwrite); | 3694 UnaryOpStub stub(expr->op(), overwrite); |
| 3703 // UnaryOpStub expects the argument to be in the | 3695 // UnaryOpStub expects the argument to be in the |
| 3704 // accumulator register eax. | 3696 // accumulator register eax. |
| 3705 VisitForAccumulatorValue(expr->expression()); | 3697 VisitForAccumulatorValue(expr->expression()); |
| 3706 SetSourcePosition(expr->position()); | 3698 SetSourcePosition(expr->position()); |
| 3707 EmitCallIC(stub.GetCode(), NULL, expr->id()); | 3699 EmitCallIC(stub.GetCode(), RelocInfo::CODE_TARGET, expr->id()); |
| 3708 context()->Plug(eax); | 3700 context()->Plug(eax); |
| 3709 } | 3701 } |
| 3710 | 3702 |
| 3711 | 3703 |
| 3712 void FullCodeGenerator::VisitCountOperation(CountOperation* expr) { | 3704 void FullCodeGenerator::VisitCountOperation(CountOperation* expr) { |
| 3713 Comment cmnt(masm_, "[ CountOperation"); | 3705 Comment cmnt(masm_, "[ CountOperation"); |
| 3714 SetSourcePosition(expr->position()); | 3706 SetSourcePosition(expr->position()); |
| 3715 | 3707 |
| 3716 // Invalid left-hand sides are rewritten to have a 'throw ReferenceError' | 3708 // Invalid left-hand sides are rewritten to have a 'throw ReferenceError' |
| 3717 // as the left-hand side. | 3709 // as the left-hand side. |
| (...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4212 ASSERT_EQ(POINTER_SIZE_ALIGN(frame_offset), frame_offset); | 4204 ASSERT_EQ(POINTER_SIZE_ALIGN(frame_offset), frame_offset); |
| 4213 __ mov(Operand(ebp, frame_offset), value); | 4205 __ mov(Operand(ebp, frame_offset), value); |
| 4214 } | 4206 } |
| 4215 | 4207 |
| 4216 | 4208 |
| 4217 void FullCodeGenerator::LoadContextField(Register dst, int context_index) { | 4209 void FullCodeGenerator::LoadContextField(Register dst, int context_index) { |
| 4218 __ mov(dst, ContextOperand(esi, context_index)); | 4210 __ mov(dst, ContextOperand(esi, context_index)); |
| 4219 } | 4211 } |
| 4220 | 4212 |
| 4221 | 4213 |
| 4214 void FullCodeGenerator::PushFunctionArgumentForContextAllocation() { |
| 4215 if (scope()->is_global_scope()) { |
| 4216 // Contexts nested in the global context have a canonical empty function |
| 4217 // as their closure, not the anonymous closure containing the global |
| 4218 // code. Pass a smi sentinel and let the runtime look up the empty |
| 4219 // function. |
| 4220 __ push(Immediate(Smi::FromInt(0))); |
| 4221 } else if (scope()->is_eval_scope()) { |
| 4222 // Contexts created by a call to eval have the same closure as the |
| 4223 // context calling eval, not the anonymous closure containing the eval |
| 4224 // code. Fetch it from the context. |
| 4225 __ push(ContextOperand(esi, Context::CLOSURE_INDEX)); |
| 4226 } else { |
| 4227 ASSERT(scope()->is_function_scope()); |
| 4228 __ push(Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); |
| 4229 } |
| 4230 } |
| 4231 |
| 4232 |
| 4222 // ---------------------------------------------------------------------------- | 4233 // ---------------------------------------------------------------------------- |
| 4223 // Non-local control flow support. | 4234 // Non-local control flow support. |
| 4224 | 4235 |
| 4225 void FullCodeGenerator::EnterFinallyBlock() { | 4236 void FullCodeGenerator::EnterFinallyBlock() { |
| 4226 // Cook return address on top of stack (smi encoded Code* delta) | 4237 // Cook return address on top of stack (smi encoded Code* delta) |
| 4227 ASSERT(!result_register().is(edx)); | 4238 ASSERT(!result_register().is(edx)); |
| 4228 __ mov(edx, Operand(esp, 0)); | 4239 __ mov(edx, Operand(esp, 0)); |
| 4229 __ sub(Operand(edx), Immediate(masm_->CodeObject())); | 4240 __ sub(Operand(edx), Immediate(masm_->CodeObject())); |
| 4230 ASSERT_EQ(1, kSmiTagSize + kSmiShiftSize); | 4241 ASSERT_EQ(1, kSmiTagSize + kSmiShiftSize); |
| 4231 ASSERT_EQ(0, kSmiTag); | 4242 ASSERT_EQ(0, kSmiTag); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 4248 // And return. | 4259 // And return. |
| 4249 __ ret(0); | 4260 __ ret(0); |
| 4250 } | 4261 } |
| 4251 | 4262 |
| 4252 | 4263 |
| 4253 #undef __ | 4264 #undef __ |
| 4254 | 4265 |
| 4255 } } // namespace v8::internal | 4266 } } // namespace v8::internal |
| 4256 | 4267 |
| 4257 #endif // V8_TARGET_ARCH_IA32 | 4268 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |