| 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/crankshaft/hydrogen.h" | 5 #include "src/crankshaft/hydrogen.h" |
| 6 | 6 |
| 7 #include <sstream> | 7 #include <sstream> |
| 8 | 8 |
| 9 #include "src/allocation-site-scopes.h" | 9 #include "src/allocation-site-scopes.h" |
| 10 #include "src/ast/ast-numbering.h" | 10 #include "src/ast/ast-numbering.h" |
| (...skipping 12318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12329 | 12329 |
| 12330 void HOptimizedGraphBuilder::VisitDeclarations( | 12330 void HOptimizedGraphBuilder::VisitDeclarations( |
| 12331 ZoneList<Declaration*>* declarations) { | 12331 ZoneList<Declaration*>* declarations) { |
| 12332 DCHECK(globals_.is_empty()); | 12332 DCHECK(globals_.is_empty()); |
| 12333 AstVisitor::VisitDeclarations(declarations); | 12333 AstVisitor::VisitDeclarations(declarations); |
| 12334 if (!globals_.is_empty()) { | 12334 if (!globals_.is_empty()) { |
| 12335 Handle<FixedArray> array = | 12335 Handle<FixedArray> array = |
| 12336 isolate()->factory()->NewFixedArray(globals_.length(), TENURED); | 12336 isolate()->factory()->NewFixedArray(globals_.length(), TENURED); |
| 12337 for (int i = 0; i < globals_.length(); ++i) array->set(i, *globals_.at(i)); | 12337 for (int i = 0; i < globals_.length(); ++i) array->set(i, *globals_.at(i)); |
| 12338 int flags = current_info()->GetDeclareGlobalsFlags(); | 12338 int flags = current_info()->GetDeclareGlobalsFlags(); |
| 12339 Add<HDeclareGlobals>(array, flags); | 12339 Handle<TypeFeedbackVector> vector(current_feedback_vector(), isolate()); |
| 12340 Add<HDeclareGlobals>(array, flags, vector); |
| 12340 globals_.Rewind(0); | 12341 globals_.Rewind(0); |
| 12341 } | 12342 } |
| 12342 } | 12343 } |
| 12343 | 12344 |
| 12344 | 12345 |
| 12345 void HOptimizedGraphBuilder::VisitVariableDeclaration( | 12346 void HOptimizedGraphBuilder::VisitVariableDeclaration( |
| 12346 VariableDeclaration* declaration) { | 12347 VariableDeclaration* declaration) { |
| 12347 VariableProxy* proxy = declaration->proxy(); | 12348 VariableProxy* proxy = declaration->proxy(); |
| 12348 VariableMode mode = declaration->mode(); | 12349 VariableMode mode = declaration->mode(); |
| 12349 Variable* variable = proxy->var(); | 12350 Variable* variable = proxy->var(); |
| 12350 bool hole_init = mode == LET || mode == CONST; | 12351 bool hole_init = mode == LET || mode == CONST; |
| 12351 switch (variable->location()) { | 12352 switch (variable->location()) { |
| 12352 case VariableLocation::GLOBAL: | 12353 case VariableLocation::GLOBAL: |
| 12353 case VariableLocation::UNALLOCATED: | 12354 case VariableLocation::UNALLOCATED: { |
| 12354 DCHECK(!variable->binding_needs_init()); | 12355 DCHECK(!variable->binding_needs_init()); |
| 12355 globals_.Add(variable->name(), zone()); | 12356 FeedbackVectorSlot slot = proxy->VariableFeedbackSlot(); |
| 12357 DCHECK(!slot.IsInvalid()); |
| 12358 globals_.Add(handle(Smi::FromInt(slot.ToInt()), isolate()), zone()); |
| 12356 globals_.Add(isolate()->factory()->undefined_value(), zone()); | 12359 globals_.Add(isolate()->factory()->undefined_value(), zone()); |
| 12357 return; | 12360 return; |
| 12361 } |
| 12358 case VariableLocation::PARAMETER: | 12362 case VariableLocation::PARAMETER: |
| 12359 case VariableLocation::LOCAL: | 12363 case VariableLocation::LOCAL: |
| 12360 if (hole_init) { | 12364 if (hole_init) { |
| 12361 HValue* value = graph()->GetConstantHole(); | 12365 HValue* value = graph()->GetConstantHole(); |
| 12362 environment()->Bind(variable, value); | 12366 environment()->Bind(variable, value); |
| 12363 } | 12367 } |
| 12364 break; | 12368 break; |
| 12365 case VariableLocation::CONTEXT: | 12369 case VariableLocation::CONTEXT: |
| 12366 if (hole_init) { | 12370 if (hole_init) { |
| 12367 HValue* value = graph()->GetConstantHole(); | 12371 HValue* value = graph()->GetConstantHole(); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 12379 } | 12383 } |
| 12380 | 12384 |
| 12381 | 12385 |
| 12382 void HOptimizedGraphBuilder::VisitFunctionDeclaration( | 12386 void HOptimizedGraphBuilder::VisitFunctionDeclaration( |
| 12383 FunctionDeclaration* declaration) { | 12387 FunctionDeclaration* declaration) { |
| 12384 VariableProxy* proxy = declaration->proxy(); | 12388 VariableProxy* proxy = declaration->proxy(); |
| 12385 Variable* variable = proxy->var(); | 12389 Variable* variable = proxy->var(); |
| 12386 switch (variable->location()) { | 12390 switch (variable->location()) { |
| 12387 case VariableLocation::GLOBAL: | 12391 case VariableLocation::GLOBAL: |
| 12388 case VariableLocation::UNALLOCATED: { | 12392 case VariableLocation::UNALLOCATED: { |
| 12389 globals_.Add(variable->name(), zone()); | 12393 FeedbackVectorSlot slot = proxy->VariableFeedbackSlot(); |
| 12394 DCHECK(!slot.IsInvalid()); |
| 12395 globals_.Add(handle(Smi::FromInt(slot.ToInt()), isolate()), zone()); |
| 12390 Handle<SharedFunctionInfo> function = Compiler::GetSharedFunctionInfo( | 12396 Handle<SharedFunctionInfo> function = Compiler::GetSharedFunctionInfo( |
| 12391 declaration->fun(), current_info()->script(), top_info()); | 12397 declaration->fun(), current_info()->script(), top_info()); |
| 12392 // Check for stack-overflow exception. | 12398 // Check for stack-overflow exception. |
| 12393 if (function.is_null()) return SetStackOverflow(); | 12399 if (function.is_null()) return SetStackOverflow(); |
| 12394 globals_.Add(function, zone()); | 12400 globals_.Add(function, zone()); |
| 12395 return; | 12401 return; |
| 12396 } | 12402 } |
| 12397 case VariableLocation::PARAMETER: | 12403 case VariableLocation::PARAMETER: |
| 12398 case VariableLocation::LOCAL: { | 12404 case VariableLocation::LOCAL: { |
| 12399 CHECK_ALIVE(VisitForValue(declaration->fun())); | 12405 CHECK_ALIVE(VisitForValue(declaration->fun())); |
| (...skipping 1273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13673 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 13679 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
| 13674 } | 13680 } |
| 13675 | 13681 |
| 13676 #ifdef DEBUG | 13682 #ifdef DEBUG |
| 13677 graph_->Verify(false); // No full verify. | 13683 graph_->Verify(false); // No full verify. |
| 13678 #endif | 13684 #endif |
| 13679 } | 13685 } |
| 13680 | 13686 |
| 13681 } // namespace internal | 13687 } // namespace internal |
| 13682 } // namespace v8 | 13688 } // namespace v8 |
| OLD | NEW |