OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 2912 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2923 | 2923 |
2924 void HGraphBuilder::VisitVariableProxy(VariableProxy* expr) { | 2924 void HGraphBuilder::VisitVariableProxy(VariableProxy* expr) { |
2925 Variable* variable = expr->AsVariable(); | 2925 Variable* variable = expr->AsVariable(); |
2926 if (variable == NULL) { | 2926 if (variable == NULL) { |
2927 BAILOUT("reference to rewritten variable"); | 2927 BAILOUT("reference to rewritten variable"); |
2928 } else if (variable->IsStackAllocated()) { | 2928 } else if (variable->IsStackAllocated()) { |
2929 if (environment()->Lookup(variable)->CheckFlag(HValue::kIsArguments)) { | 2929 if (environment()->Lookup(variable)->CheckFlag(HValue::kIsArguments)) { |
2930 BAILOUT("unsupported context for arguments object"); | 2930 BAILOUT("unsupported context for arguments object"); |
2931 } | 2931 } |
2932 ast_context()->ReturnValue(environment()->Lookup(variable)); | 2932 ast_context()->ReturnValue(environment()->Lookup(variable)); |
| 2933 } else if (variable->AsSlot() != NULL && |
| 2934 variable->AsSlot()->type() == Slot::CONTEXT) { |
| 2935 if (variable->mode() == Variable::CONST) { |
| 2936 BAILOUT("reference to const context slot"); |
| 2937 } |
| 2938 Slot* slot = variable->AsSlot(); |
| 2939 CompilationInfo* info = graph()->info(); |
| 2940 int context_chain_length = info->function()->scope()-> |
| 2941 ContextChainLength(slot->var()->scope()); |
| 2942 ASSERT(context_chain_length >= 0); |
| 2943 // TODO(antonm): if slot's value is not modified by closures, instead |
| 2944 // of reading it out of context, we could just embed the value as |
| 2945 // a constant. |
| 2946 HLoadContextSlot* instr = |
| 2947 new HLoadContextSlot(context_chain_length, slot->index()); |
| 2948 ast_context()->ReturnInstruction(instr, expr->id()); |
2933 } else if (variable->is_global()) { | 2949 } else if (variable->is_global()) { |
2934 LookupResult lookup; | 2950 LookupResult lookup; |
2935 LookupGlobalPropertyCell(variable, &lookup, false); | 2951 LookupGlobalPropertyCell(variable, &lookup, false); |
2936 CHECK_BAILOUT; | 2952 CHECK_BAILOUT; |
2937 | 2953 |
2938 Handle<GlobalObject> global(graph()->info()->global_object()); | 2954 Handle<GlobalObject> global(graph()->info()->global_object()); |
2939 // TODO(3039103): Handle global property load through an IC call when access | 2955 // TODO(3039103): Handle global property load through an IC call when access |
2940 // checks are enabled. | 2956 // checks are enabled. |
2941 if (global->IsAccessCheckNeeded()) { | 2957 if (global->IsAccessCheckNeeded()) { |
2942 BAILOUT("global object requires access check"); | 2958 BAILOUT("global object requires access check"); |
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3437 | 3453 |
3438 if (expr->is_compound()) { | 3454 if (expr->is_compound()) { |
3439 HandleCompoundAssignment(expr); | 3455 HandleCompoundAssignment(expr); |
3440 return; | 3456 return; |
3441 } | 3457 } |
3442 | 3458 |
3443 if (var != NULL) { | 3459 if (var != NULL) { |
3444 if (proxy->IsArguments()) BAILOUT("assignment to arguments"); | 3460 if (proxy->IsArguments()) BAILOUT("assignment to arguments"); |
3445 | 3461 |
3446 // Handle the assignment. | 3462 // Handle the assignment. |
| 3463 if (var->AsSlot() != NULL && var->AsSlot()->type() == Slot::CONTEXT) { |
| 3464 BAILOUT("context slot assignment"); |
| 3465 } |
3447 if (var->is_global()) { | 3466 if (var->is_global()) { |
3448 VISIT_FOR_VALUE(expr->value()); | 3467 VISIT_FOR_VALUE(expr->value()); |
3449 HandleGlobalVariableAssignment(var, | 3468 HandleGlobalVariableAssignment(var, |
3450 Top(), | 3469 Top(), |
3451 expr->position(), | 3470 expr->position(), |
3452 expr->AssignmentId()); | 3471 expr->AssignmentId()); |
3453 } else { | 3472 } else { |
3454 // We allow reference to the arguments object only in assignemtns | 3473 // We allow reference to the arguments object only in assignemtns |
3455 // to local variables to make sure that the arguments object does | 3474 // to local variables to make sure that the arguments object does |
3456 // not escape and is not modified. | 3475 // not escape and is not modified. |
(...skipping 2214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5671 } | 5690 } |
5672 | 5691 |
5673 #ifdef DEBUG | 5692 #ifdef DEBUG |
5674 if (graph_ != NULL) graph_->Verify(); | 5693 if (graph_ != NULL) graph_->Verify(); |
5675 if (chunk_ != NULL) chunk_->Verify(); | 5694 if (chunk_ != NULL) chunk_->Verify(); |
5676 if (allocator_ != NULL) allocator_->Verify(); | 5695 if (allocator_ != NULL) allocator_->Verify(); |
5677 #endif | 5696 #endif |
5678 } | 5697 } |
5679 | 5698 |
5680 } } // namespace v8::internal | 5699 } } // namespace v8::internal |
OLD | NEW |