OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/hydrogen.h" | 5 #include "src/hydrogen.h" |
6 | 6 |
7 #include <sstream> | 7 #include <sstream> |
8 | 8 |
9 #include "src/v8.h" | 9 #include "src/v8.h" |
10 | 10 |
(...skipping 3115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3126 HInstruction* global_object = Add<HLoadNamedField>( | 3126 HInstruction* global_object = Add<HLoadNamedField>( |
3127 context, static_cast<HValue*>(NULL), | 3127 context, static_cast<HValue*>(NULL), |
3128 HObjectAccess::ForContextSlot(Context::GLOBAL_OBJECT_INDEX)); | 3128 HObjectAccess::ForContextSlot(Context::GLOBAL_OBJECT_INDEX)); |
3129 HObjectAccess access = HObjectAccess::ForObservableJSObjectOffset( | 3129 HObjectAccess access = HObjectAccess::ForObservableJSObjectOffset( |
3130 GlobalObject::kNativeContextOffset); | 3130 GlobalObject::kNativeContextOffset); |
3131 return Add<HLoadNamedField>( | 3131 return Add<HLoadNamedField>( |
3132 global_object, static_cast<HValue*>(NULL), access); | 3132 global_object, static_cast<HValue*>(NULL), access); |
3133 } | 3133 } |
3134 | 3134 |
3135 | 3135 |
| 3136 HInstruction* HGraphBuilder::BuildGetGlobalContext(int context_index) { |
| 3137 HValue* native_context = BuildGetNativeContext(); |
| 3138 HValue* global_context_table = Add<HLoadNamedField>( |
| 3139 native_context, static_cast<HValue*>(NULL), |
| 3140 HObjectAccess::ForContextSlot(Context::GLOBAL_CONTEXT_TABLE_INDEX)); |
| 3141 return Add<HLoadNamedField>(global_context_table, static_cast<HValue*>(NULL), |
| 3142 HObjectAccess::ForGlobalContext(context_index)); |
| 3143 } |
| 3144 |
| 3145 |
3136 HInstruction* HGraphBuilder::BuildGetNativeContext() { | 3146 HInstruction* HGraphBuilder::BuildGetNativeContext() { |
3137 // Get the global context, then the native context | 3147 // Get the global context, then the native context |
3138 HValue* global_object = Add<HLoadNamedField>( | 3148 HValue* global_object = Add<HLoadNamedField>( |
3139 context(), static_cast<HValue*>(NULL), | 3149 context(), static_cast<HValue*>(NULL), |
3140 HObjectAccess::ForContextSlot(Context::GLOBAL_OBJECT_INDEX)); | 3150 HObjectAccess::ForContextSlot(Context::GLOBAL_OBJECT_INDEX)); |
3141 return Add<HLoadNamedField>( | 3151 return Add<HLoadNamedField>( |
3142 global_object, static_cast<HValue*>(NULL), | 3152 global_object, static_cast<HValue*>(NULL), |
3143 HObjectAccess::ForObservableJSObjectOffset( | 3153 HObjectAccess::ForObservableJSObjectOffset( |
3144 GlobalObject::kNativeContextOffset)); | 3154 GlobalObject::kNativeContextOffset)); |
3145 } | 3155 } |
(...skipping 3369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6515 | 6525 |
6516 | 6526 |
6517 // Because not every expression has a position and there is not common | 6527 // Because not every expression has a position and there is not common |
6518 // superclass of Assignment and CountOperation, we cannot just pass the | 6528 // superclass of Assignment and CountOperation, we cannot just pass the |
6519 // owning expression instead of position and ast_id separately. | 6529 // owning expression instead of position and ast_id separately. |
6520 void HOptimizedGraphBuilder::HandleGlobalVariableAssignment( | 6530 void HOptimizedGraphBuilder::HandleGlobalVariableAssignment( |
6521 Variable* var, | 6531 Variable* var, |
6522 HValue* value, | 6532 HValue* value, |
6523 BailoutId ast_id) { | 6533 BailoutId ast_id) { |
6524 Handle<GlobalObject> global(current_info()->global_object()); | 6534 Handle<GlobalObject> global(current_info()->global_object()); |
| 6535 |
| 6536 if (FLAG_harmony_scoping) { |
| 6537 Handle<GlobalContextTable> global_contexts( |
| 6538 global->native_context()->global_context_table()); |
| 6539 GlobalContextTable::LookupResult lookup; |
| 6540 if (GlobalContextTable::Lookup(global_contexts, var->name(), &lookup)) { |
| 6541 Handle<Context> global_context = |
| 6542 GlobalContextTable::GetContext(global_contexts, lookup.context_index); |
| 6543 HStoreNamedField* instr = Add<HStoreNamedField>( |
| 6544 Add<HConstant>(global_context), |
| 6545 HObjectAccess::ForContextSlot(lookup.slot_index), value); |
| 6546 USE(instr); |
| 6547 DCHECK(instr->HasObservableSideEffects()); |
| 6548 Add<HSimulate>(ast_id, REMOVABLE_SIMULATE); |
| 6549 return; |
| 6550 } |
| 6551 } |
| 6552 |
6525 LookupIterator it(global, var->name(), LookupIterator::OWN_SKIP_INTERCEPTOR); | 6553 LookupIterator it(global, var->name(), LookupIterator::OWN_SKIP_INTERCEPTOR); |
6526 GlobalPropertyAccess type = LookupGlobalProperty(var, &it, STORE); | 6554 GlobalPropertyAccess type = LookupGlobalProperty(var, &it, STORE); |
6527 if (type == kUseCell) { | 6555 if (type == kUseCell) { |
6528 Handle<PropertyCell> cell = it.GetPropertyCell(); | 6556 Handle<PropertyCell> cell = it.GetPropertyCell(); |
6529 if (cell->type()->IsConstant()) { | 6557 if (cell->type()->IsConstant()) { |
6530 Handle<Object> constant = cell->type()->AsConstant()->Value(); | 6558 Handle<Object> constant = cell->type()->AsConstant()->Value(); |
6531 if (value->IsConstant()) { | 6559 if (value->IsConstant()) { |
6532 HConstant* c_value = HConstant::cast(value); | 6560 HConstant* c_value = HConstant::cast(value); |
6533 if (!constant.is_identical_to(c_value->handle(isolate()))) { | 6561 if (!constant.is_identical_to(c_value->handle(isolate()))) { |
6534 Add<HDeoptimize>("Constant global variable assignment", | 6562 Add<HDeoptimize>("Constant global variable assignment", |
(...skipping 6166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12701 if (ShouldProduceTraceOutput()) { | 12729 if (ShouldProduceTraceOutput()) { |
12702 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 12730 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
12703 } | 12731 } |
12704 | 12732 |
12705 #ifdef DEBUG | 12733 #ifdef DEBUG |
12706 graph_->Verify(false); // No full verify. | 12734 graph_->Verify(false); // No full verify. |
12707 #endif | 12735 #endif |
12708 } | 12736 } |
12709 | 12737 |
12710 } } // namespace v8::internal | 12738 } } // namespace v8::internal |
OLD | NEW |