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 3559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3570 if (expr->is_compound()) { | 3570 if (expr->is_compound()) { |
3571 HandleCompoundAssignment(expr); | 3571 HandleCompoundAssignment(expr); |
3572 return; | 3572 return; |
3573 } | 3573 } |
3574 | 3574 |
3575 if (var != NULL) { | 3575 if (var != NULL) { |
3576 if (var->mode() == Variable::CONST) { | 3576 if (var->mode() == Variable::CONST) { |
3577 if (expr->op() != Token::INIT_CONST) { | 3577 if (expr->op() != Token::INIT_CONST) { |
3578 return Bailout("non-initializer assignment to const"); | 3578 return Bailout("non-initializer assignment to const"); |
3579 } | 3579 } |
| 3580 if (!var->IsStackAllocated()) { |
| 3581 return Bailout("assignment to const context slot"); |
| 3582 } |
3580 // We insert a use of the old value to detect unsupported uses of const | 3583 // We insert a use of the old value to detect unsupported uses of const |
3581 // variables (e.g. initialization inside a loop). | 3584 // variables (e.g. initialization inside a loop). |
3582 HValue* old_value = environment()->Lookup(var); | 3585 HValue* old_value = environment()->Lookup(var); |
3583 AddInstruction(new HUseConst(old_value)); | 3586 AddInstruction(new HUseConst(old_value)); |
3584 } | 3587 } |
3585 | 3588 |
3586 if (proxy->IsArguments()) return Bailout("assignment to arguments"); | 3589 if (proxy->IsArguments()) return Bailout("assignment to arguments"); |
3587 | 3590 |
3588 // Handle the assignment. | 3591 // Handle the assignment. |
3589 if (var->IsStackAllocated()) { | 3592 if (var->IsStackAllocated()) { |
3590 // We do not allow the arguments object to occur in a context where it | 3593 // We do not allow the arguments object to occur in a context where it |
3591 // may escape, but assignments to stack-allocated locals are | 3594 // may escape, but assignments to stack-allocated locals are |
3592 // permitted. | 3595 // permitted. |
3593 CHECK_ALIVE(VisitForValue(expr->value(), ARGUMENTS_ALLOWED)); | 3596 CHECK_ALIVE(VisitForValue(expr->value(), ARGUMENTS_ALLOWED)); |
3594 HValue* value = Pop(); | 3597 HValue* value = Pop(); |
3595 Bind(var, value); | 3598 Bind(var, value); |
3596 ast_context()->ReturnValue(value); | 3599 ast_context()->ReturnValue(value); |
3597 | 3600 |
3598 } else if (var->IsContextSlot() && var->mode() != Variable::CONST) { | 3601 } else if (var->IsContextSlot()) { |
| 3602 ASSERT(var->mode() != Variable::CONST); |
3599 CHECK_ALIVE(VisitForValue(expr->value())); | 3603 CHECK_ALIVE(VisitForValue(expr->value())); |
3600 HValue* context = BuildContextChainWalk(var); | 3604 HValue* context = BuildContextChainWalk(var); |
3601 int index = var->AsSlot()->index(); | 3605 int index = var->AsSlot()->index(); |
3602 HStoreContextSlot* instr = | 3606 HStoreContextSlot* instr = |
3603 new(zone()) HStoreContextSlot(context, index, Top()); | 3607 new(zone()) HStoreContextSlot(context, index, Top()); |
3604 AddInstruction(instr); | 3608 AddInstruction(instr); |
3605 if (instr->HasSideEffects()) AddSimulate(expr->AssignmentId()); | 3609 if (instr->HasSideEffects()) AddSimulate(expr->AssignmentId()); |
3606 ast_context()->ReturnValue(Pop()); | 3610 ast_context()->ReturnValue(Pop()); |
3607 | 3611 |
3608 } else if (var->is_global()) { | 3612 } else if (var->is_global()) { |
(...skipping 1765 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5374 Variable* var = decl->proxy()->var(); | 5378 Variable* var = decl->proxy()->var(); |
5375 Slot* slot = var->AsSlot(); | 5379 Slot* slot = var->AsSlot(); |
5376 if (var->is_global() || | 5380 if (var->is_global() || |
5377 !var->IsStackAllocated() || | 5381 !var->IsStackAllocated() || |
5378 (slot != NULL && slot->type() == Slot::LOOKUP) || | 5382 (slot != NULL && slot->type() == Slot::LOOKUP) || |
5379 decl->fun() != NULL) { | 5383 decl->fun() != NULL) { |
5380 return Bailout("unsupported declaration"); | 5384 return Bailout("unsupported declaration"); |
5381 } | 5385 } |
5382 | 5386 |
5383 if (decl->mode() == Variable::CONST) { | 5387 if (decl->mode() == Variable::CONST) { |
| 5388 ASSERT(var->IsStackAllocated()); |
5384 environment()->Bind(var, graph()->GetConstantHole()); | 5389 environment()->Bind(var, graph()->GetConstantHole()); |
5385 } | 5390 } |
5386 } | 5391 } |
5387 | 5392 |
5388 | 5393 |
5389 // Generators for inline runtime functions. | 5394 // Generators for inline runtime functions. |
5390 // Support for types. | 5395 // Support for types. |
5391 void HGraphBuilder::GenerateIsSmi(CallRuntime* call) { | 5396 void HGraphBuilder::GenerateIsSmi(CallRuntime* call) { |
5392 ASSERT(call->arguments()->length() == 1); | 5397 ASSERT(call->arguments()->length() == 1); |
5393 CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); | 5398 CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); |
(...skipping 916 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6310 } | 6315 } |
6311 } | 6316 } |
6312 | 6317 |
6313 #ifdef DEBUG | 6318 #ifdef DEBUG |
6314 if (graph_ != NULL) graph_->Verify(); | 6319 if (graph_ != NULL) graph_->Verify(); |
6315 if (allocator_ != NULL) allocator_->Verify(); | 6320 if (allocator_ != NULL) allocator_->Verify(); |
6316 #endif | 6321 #endif |
6317 } | 6322 } |
6318 | 6323 |
6319 } } // namespace v8::internal | 6324 } } // namespace v8::internal |
OLD | NEW |