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 3101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3112 // since the counter is bounded by the new space size. | 3112 // since the counter is bounded by the new space size. |
3113 memento_create_count->ClearFlag(HValue::kCanOverflow); | 3113 memento_create_count->ClearFlag(HValue::kCanOverflow); |
3114 Add<HStoreNamedField>( | 3114 Add<HStoreNamedField>( |
3115 allocation_site, HObjectAccess::ForAllocationSiteOffset( | 3115 allocation_site, HObjectAccess::ForAllocationSiteOffset( |
3116 AllocationSite::kPretenureCreateCountOffset), memento_create_count); | 3116 AllocationSite::kPretenureCreateCountOffset), memento_create_count); |
3117 } | 3117 } |
3118 } | 3118 } |
3119 | 3119 |
3120 | 3120 |
3121 HInstruction* HGraphBuilder::BuildGetNativeContext(HValue* closure) { | 3121 HInstruction* HGraphBuilder::BuildGetNativeContext(HValue* closure) { |
3122 // Get the global context, then the native context | 3122 // Get the global object, then the native context |
3123 HInstruction* context = | 3123 HInstruction* context = |
3124 Add<HLoadNamedField>(closure, static_cast<HValue*>(NULL), | 3124 Add<HLoadNamedField>(closure, static_cast<HValue*>(NULL), |
3125 HObjectAccess::ForFunctionContextPointer()); | 3125 HObjectAccess::ForFunctionContextPointer()); |
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) { | 3136 HInstruction* HGraphBuilder::BuildGetScriptContext(int context_index) { |
3137 HValue* native_context = BuildGetNativeContext(); | 3137 HValue* native_context = BuildGetNativeContext(); |
3138 HValue* global_context_table = Add<HLoadNamedField>( | 3138 HValue* script_context_table = Add<HLoadNamedField>( |
3139 native_context, static_cast<HValue*>(NULL), | 3139 native_context, static_cast<HValue*>(NULL), |
3140 HObjectAccess::ForContextSlot(Context::GLOBAL_CONTEXT_TABLE_INDEX)); | 3140 HObjectAccess::ForContextSlot(Context::SCRIPT_CONTEXT_TABLE_INDEX)); |
3141 return Add<HLoadNamedField>(global_context_table, static_cast<HValue*>(NULL), | 3141 return Add<HLoadNamedField>(script_context_table, static_cast<HValue*>(NULL), |
3142 HObjectAccess::ForGlobalContext(context_index)); | 3142 HObjectAccess::ForScriptContext(context_index)); |
3143 } | 3143 } |
3144 | 3144 |
3145 | 3145 |
3146 HInstruction* HGraphBuilder::BuildGetNativeContext() { | 3146 HInstruction* HGraphBuilder::BuildGetNativeContext() { |
3147 // Get the global context, then the native context | 3147 // Get the global object, then the native context |
3148 HValue* global_object = Add<HLoadNamedField>( | 3148 HValue* global_object = Add<HLoadNamedField>( |
3149 context(), static_cast<HValue*>(NULL), | 3149 context(), static_cast<HValue*>(NULL), |
3150 HObjectAccess::ForContextSlot(Context::GLOBAL_OBJECT_INDEX)); | 3150 HObjectAccess::ForContextSlot(Context::GLOBAL_OBJECT_INDEX)); |
3151 return Add<HLoadNamedField>( | 3151 return Add<HLoadNamedField>( |
3152 global_object, static_cast<HValue*>(NULL), | 3152 global_object, static_cast<HValue*>(NULL), |
3153 HObjectAccess::ForObservableJSObjectOffset( | 3153 HObjectAccess::ForObservableJSObjectOffset( |
3154 GlobalObject::kNativeContextOffset)); | 3154 GlobalObject::kNativeContextOffset)); |
3155 } | 3155 } |
3156 | 3156 |
3157 | 3157 |
(...skipping 1400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4558 Scope* outer_scope = scope(); | 4558 Scope* outer_scope = scope(); |
4559 Scope* scope = stmt->scope(); | 4559 Scope* scope = stmt->scope(); |
4560 BreakAndContinueInfo break_info(stmt, outer_scope); | 4560 BreakAndContinueInfo break_info(stmt, outer_scope); |
4561 | 4561 |
4562 { BreakAndContinueScope push(&break_info, this); | 4562 { BreakAndContinueScope push(&break_info, this); |
4563 if (scope != NULL) { | 4563 if (scope != NULL) { |
4564 // Load the function object. | 4564 // Load the function object. |
4565 Scope* declaration_scope = scope->DeclarationScope(); | 4565 Scope* declaration_scope = scope->DeclarationScope(); |
4566 HInstruction* function; | 4566 HInstruction* function; |
4567 HValue* outer_context = environment()->context(); | 4567 HValue* outer_context = environment()->context(); |
4568 if (declaration_scope->is_global_scope() || | 4568 if (declaration_scope->is_script_scope() || |
4569 declaration_scope->is_eval_scope()) { | 4569 declaration_scope->is_eval_scope()) { |
4570 function = new(zone()) HLoadContextSlot( | 4570 function = new(zone()) HLoadContextSlot( |
4571 outer_context, Context::CLOSURE_INDEX, HLoadContextSlot::kNoCheck); | 4571 outer_context, Context::CLOSURE_INDEX, HLoadContextSlot::kNoCheck); |
4572 } else { | 4572 } else { |
4573 function = New<HThisFunction>(); | 4573 function = New<HThisFunction>(); |
4574 } | 4574 } |
4575 AddInstruction(function); | 4575 AddInstruction(function); |
4576 // Allocate a block context and store it to the stack frame. | 4576 // Allocate a block context and store it to the stack frame. |
4577 HInstruction* inner_context = Add<HAllocateBlockContext>( | 4577 HInstruction* inner_context = Add<HAllocateBlockContext>( |
4578 outer_context, function, scope->GetScopeInfo()); | 4578 outer_context, function, scope->GetScopeInfo()); |
(...skipping 802 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5381 Handle<Object> constant_value = | 5381 Handle<Object> constant_value = |
5382 isolate()->factory()->GlobalConstantFor(variable->name()); | 5382 isolate()->factory()->GlobalConstantFor(variable->name()); |
5383 if (!constant_value.is_null()) { | 5383 if (!constant_value.is_null()) { |
5384 HConstant* instr = New<HConstant>(constant_value); | 5384 HConstant* instr = New<HConstant>(constant_value); |
5385 return ast_context()->ReturnInstruction(instr, expr->id()); | 5385 return ast_context()->ReturnInstruction(instr, expr->id()); |
5386 } | 5386 } |
5387 | 5387 |
5388 Handle<GlobalObject> global(current_info()->global_object()); | 5388 Handle<GlobalObject> global(current_info()->global_object()); |
5389 | 5389 |
5390 if (FLAG_harmony_scoping) { | 5390 if (FLAG_harmony_scoping) { |
5391 Handle<GlobalContextTable> global_contexts( | 5391 Handle<ScriptContextTable> script_contexts( |
5392 global->native_context()->global_context_table()); | 5392 global->native_context()->script_context_table()); |
5393 GlobalContextTable::LookupResult lookup; | 5393 ScriptContextTable::LookupResult lookup; |
5394 if (GlobalContextTable::Lookup(global_contexts, variable->name(), | 5394 if (ScriptContextTable::Lookup(script_contexts, variable->name(), |
5395 &lookup)) { | 5395 &lookup)) { |
5396 Handle<Context> global_context = GlobalContextTable::GetContext( | 5396 Handle<Context> script_context = ScriptContextTable::GetContext( |
5397 global_contexts, lookup.context_index); | 5397 script_contexts, lookup.context_index); |
5398 HInstruction* result = New<HLoadNamedField>( | 5398 HInstruction* result = New<HLoadNamedField>( |
5399 Add<HConstant>(global_context), static_cast<HValue*>(NULL), | 5399 Add<HConstant>(script_context), static_cast<HValue*>(NULL), |
5400 HObjectAccess::ForContextSlot(lookup.slot_index)); | 5400 HObjectAccess::ForContextSlot(lookup.slot_index)); |
5401 return ast_context()->ReturnInstruction(result, expr->id()); | 5401 return ast_context()->ReturnInstruction(result, expr->id()); |
5402 } | 5402 } |
5403 } | 5403 } |
5404 | 5404 |
5405 LookupIterator it(global, variable->name(), | 5405 LookupIterator it(global, variable->name(), |
5406 LookupIterator::OWN_SKIP_INTERCEPTOR); | 5406 LookupIterator::OWN_SKIP_INTERCEPTOR); |
5407 GlobalPropertyAccess type = LookupGlobalProperty(variable, &it, LOAD); | 5407 GlobalPropertyAccess type = LookupGlobalProperty(variable, &it, LOAD); |
5408 | 5408 |
5409 if (type == kUseCell) { | 5409 if (type == kUseCell) { |
(...skipping 1127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6537 // Because not every expression has a position and there is not common | 6537 // Because not every expression has a position and there is not common |
6538 // superclass of Assignment and CountOperation, we cannot just pass the | 6538 // superclass of Assignment and CountOperation, we cannot just pass the |
6539 // owning expression instead of position and ast_id separately. | 6539 // owning expression instead of position and ast_id separately. |
6540 void HOptimizedGraphBuilder::HandleGlobalVariableAssignment( | 6540 void HOptimizedGraphBuilder::HandleGlobalVariableAssignment( |
6541 Variable* var, | 6541 Variable* var, |
6542 HValue* value, | 6542 HValue* value, |
6543 BailoutId ast_id) { | 6543 BailoutId ast_id) { |
6544 Handle<GlobalObject> global(current_info()->global_object()); | 6544 Handle<GlobalObject> global(current_info()->global_object()); |
6545 | 6545 |
6546 if (FLAG_harmony_scoping) { | 6546 if (FLAG_harmony_scoping) { |
6547 Handle<GlobalContextTable> global_contexts( | 6547 Handle<ScriptContextTable> script_contexts( |
6548 global->native_context()->global_context_table()); | 6548 global->native_context()->script_context_table()); |
6549 GlobalContextTable::LookupResult lookup; | 6549 ScriptContextTable::LookupResult lookup; |
6550 if (GlobalContextTable::Lookup(global_contexts, var->name(), &lookup)) { | 6550 if (ScriptContextTable::Lookup(script_contexts, var->name(), &lookup)) { |
6551 Handle<Context> global_context = | 6551 Handle<Context> script_context = |
6552 GlobalContextTable::GetContext(global_contexts, lookup.context_index); | 6552 ScriptContextTable::GetContext(script_contexts, lookup.context_index); |
6553 HStoreNamedField* instr = Add<HStoreNamedField>( | 6553 HStoreNamedField* instr = Add<HStoreNamedField>( |
6554 Add<HConstant>(global_context), | 6554 Add<HConstant>(script_context), |
6555 HObjectAccess::ForContextSlot(lookup.slot_index), value); | 6555 HObjectAccess::ForContextSlot(lookup.slot_index), value); |
6556 USE(instr); | 6556 USE(instr); |
6557 DCHECK(instr->HasObservableSideEffects()); | 6557 DCHECK(instr->HasObservableSideEffects()); |
6558 Add<HSimulate>(ast_id, REMOVABLE_SIMULATE); | 6558 Add<HSimulate>(ast_id, REMOVABLE_SIMULATE); |
6559 return; | 6559 return; |
6560 } | 6560 } |
6561 } | 6561 } |
6562 | 6562 |
6563 LookupIterator it(global, var->name(), LookupIterator::OWN_SKIP_INTERCEPTOR); | 6563 LookupIterator it(global, var->name(), LookupIterator::OWN_SKIP_INTERCEPTOR); |
6564 GlobalPropertyAccess type = LookupGlobalProperty(var, &it, STORE); | 6564 GlobalPropertyAccess type = LookupGlobalProperty(var, &it, STORE); |
(...skipping 6174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12739 if (ShouldProduceTraceOutput()) { | 12739 if (ShouldProduceTraceOutput()) { |
12740 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 12740 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
12741 } | 12741 } |
12742 | 12742 |
12743 #ifdef DEBUG | 12743 #ifdef DEBUG |
12744 graph_->Verify(false); // No full verify. | 12744 graph_->Verify(false); // No full verify. |
12745 #endif | 12745 #endif |
12746 } | 12746 } |
12747 | 12747 |
12748 } } // namespace v8::internal | 12748 } } // namespace v8::internal |
OLD | NEW |