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 5898 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5909 } | 5909 } |
5910 | 5910 |
5911 case VariableLocation::CONTEXT: { | 5911 case VariableLocation::CONTEXT: { |
5912 HValue* context = BuildContextChainWalk(variable); | 5912 HValue* context = BuildContextChainWalk(variable); |
5913 HLoadContextSlot::Mode mode; | 5913 HLoadContextSlot::Mode mode; |
5914 switch (variable->mode()) { | 5914 switch (variable->mode()) { |
5915 case LET: | 5915 case LET: |
5916 case CONST: | 5916 case CONST: |
5917 mode = HLoadContextSlot::kCheckDeoptimize; | 5917 mode = HLoadContextSlot::kCheckDeoptimize; |
5918 break; | 5918 break; |
5919 case CONST_LEGACY: | |
5920 mode = HLoadContextSlot::kCheckReturnUndefined; | |
5921 break; | |
5922 default: | 5919 default: |
5923 mode = HLoadContextSlot::kNoCheck; | 5920 mode = HLoadContextSlot::kNoCheck; |
5924 break; | 5921 break; |
5925 } | 5922 } |
5926 HLoadContextSlot* instr = | 5923 HLoadContextSlot* instr = |
5927 new(zone()) HLoadContextSlot(context, variable->index(), mode); | 5924 new(zone()) HLoadContextSlot(context, variable->index(), mode); |
5928 return ast_context()->ReturnInstruction(instr, expr->id()); | 5925 return ast_context()->ReturnInstruction(instr, expr->id()); |
5929 } | 5926 } |
5930 | 5927 |
5931 case VariableLocation::LOOKUP: | 5928 case VariableLocation::LOOKUP: |
(...skipping 1305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7237 if (prop != NULL) { | 7234 if (prop != NULL) { |
7238 HandlePropertyAssignment(expr); | 7235 HandlePropertyAssignment(expr); |
7239 } else if (proxy != NULL) { | 7236 } else if (proxy != NULL) { |
7240 Variable* var = proxy->var(); | 7237 Variable* var = proxy->var(); |
7241 | 7238 |
7242 if (var->mode() == CONST) { | 7239 if (var->mode() == CONST) { |
7243 if (expr->op() != Token::INIT) { | 7240 if (expr->op() != Token::INIT) { |
7244 return Bailout(kNonInitializerAssignmentToConst); | 7241 return Bailout(kNonInitializerAssignmentToConst); |
7245 } | 7242 } |
7246 } else if (var->mode() == CONST_LEGACY) { | 7243 } else if (var->mode() == CONST_LEGACY) { |
7247 if (expr->op() != Token::INIT && is_strict(function_language_mode())) { | 7244 if (expr->op() != Token::INIT) { |
7248 return Bailout(kNonInitializerAssignmentToConst); | 7245 if (is_strict(function_language_mode())) { |
7249 } else if (expr->op() != Token::INIT) { | 7246 return Bailout(kNonInitializerAssignmentToConst); |
7250 CHECK_ALIVE(VisitForValue(expr->value())); | 7247 } else { |
7251 return ast_context()->ReturnValue(Pop()); | 7248 CHECK_ALIVE(VisitForValue(expr->value())); |
| 7249 return ast_context()->ReturnValue(Pop()); |
| 7250 } |
7252 } | 7251 } |
7253 | 7252 |
| 7253 // TODO(adamk): Is this required? Legacy const variables are always |
| 7254 // initialized before use. |
7254 if (var->IsStackAllocated()) { | 7255 if (var->IsStackAllocated()) { |
7255 // We insert a use of the old value to detect unsupported uses of const | 7256 // We insert a use of the old value to detect unsupported uses of const |
7256 // variables (e.g. initialization inside a loop). | 7257 // variables (e.g. initialization inside a loop). |
7257 HValue* old_value = environment()->Lookup(var); | 7258 HValue* old_value = environment()->Lookup(var); |
7258 Add<HUseConst>(old_value); | 7259 Add<HUseConst>(old_value); |
7259 } | 7260 } |
7260 } | 7261 } |
7261 | 7262 |
7262 if (proxy->IsArguments()) return Bailout(kAssignmentToArguments); | 7263 if (proxy->IsArguments()) return Bailout(kAssignmentToArguments); |
7263 | 7264 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7315 // This case is checked statically so no need to | 7316 // This case is checked statically so no need to |
7316 // perform checks here | 7317 // perform checks here |
7317 UNREACHABLE(); | 7318 UNREACHABLE(); |
7318 case CONST_LEGACY: | 7319 case CONST_LEGACY: |
7319 return ast_context()->ReturnValue(Pop()); | 7320 return ast_context()->ReturnValue(Pop()); |
7320 default: | 7321 default: |
7321 mode = HStoreContextSlot::kNoCheck; | 7322 mode = HStoreContextSlot::kNoCheck; |
7322 } | 7323 } |
7323 } else { | 7324 } else { |
7324 DCHECK_EQ(Token::INIT, expr->op()); | 7325 DCHECK_EQ(Token::INIT, expr->op()); |
7325 if (var->mode() == CONST_LEGACY) { | 7326 mode = HStoreContextSlot::kNoCheck; |
7326 mode = HStoreContextSlot::kCheckIgnoreAssignment; | |
7327 } else { | |
7328 mode = HStoreContextSlot::kNoCheck; | |
7329 } | |
7330 } | 7327 } |
7331 | 7328 |
7332 HValue* context = BuildContextChainWalk(var); | 7329 HValue* context = BuildContextChainWalk(var); |
7333 HStoreContextSlot* instr = Add<HStoreContextSlot>( | 7330 HStoreContextSlot* instr = Add<HStoreContextSlot>( |
7334 context, var->index(), mode, Top()); | 7331 context, var->index(), mode, Top()); |
7335 if (instr->HasObservableSideEffects()) { | 7332 if (instr->HasObservableSideEffects()) { |
7336 Add<HSimulate>(expr->AssignmentId(), REMOVABLE_SIMULATE); | 7333 Add<HSimulate>(expr->AssignmentId(), REMOVABLE_SIMULATE); |
7337 } | 7334 } |
7338 return ast_context()->ReturnValue(Pop()); | 7335 return ast_context()->ReturnValue(Pop()); |
7339 } | 7336 } |
(...skipping 4941 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12281 globals_.Rewind(0); | 12278 globals_.Rewind(0); |
12282 } | 12279 } |
12283 } | 12280 } |
12284 | 12281 |
12285 | 12282 |
12286 void HOptimizedGraphBuilder::VisitVariableDeclaration( | 12283 void HOptimizedGraphBuilder::VisitVariableDeclaration( |
12287 VariableDeclaration* declaration) { | 12284 VariableDeclaration* declaration) { |
12288 VariableProxy* proxy = declaration->proxy(); | 12285 VariableProxy* proxy = declaration->proxy(); |
12289 VariableMode mode = declaration->mode(); | 12286 VariableMode mode = declaration->mode(); |
12290 Variable* variable = proxy->var(); | 12287 Variable* variable = proxy->var(); |
12291 bool hole_init = mode == LET || mode == CONST || mode == CONST_LEGACY; | 12288 bool hole_init = mode == LET || mode == CONST; |
12292 switch (variable->location()) { | 12289 switch (variable->location()) { |
12293 case VariableLocation::GLOBAL: | 12290 case VariableLocation::GLOBAL: |
12294 case VariableLocation::UNALLOCATED: | 12291 case VariableLocation::UNALLOCATED: |
12295 globals_.Add(variable->name(), zone()); | 12292 globals_.Add(variable->name(), zone()); |
12296 globals_.Add(variable->binding_needs_init() | 12293 globals_.Add(variable->binding_needs_init() |
12297 ? isolate()->factory()->the_hole_value() | 12294 ? isolate()->factory()->the_hole_value() |
12298 : isolate()->factory()->undefined_value(), zone()); | 12295 : isolate()->factory()->undefined_value(), zone()); |
12299 return; | 12296 return; |
12300 case VariableLocation::PARAMETER: | 12297 case VariableLocation::PARAMETER: |
12301 case VariableLocation::LOCAL: | 12298 case VariableLocation::LOCAL: |
(...skipping 1433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13735 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 13732 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
13736 } | 13733 } |
13737 | 13734 |
13738 #ifdef DEBUG | 13735 #ifdef DEBUG |
13739 graph_->Verify(false); // No full verify. | 13736 graph_->Verify(false); // No full verify. |
13740 #endif | 13737 #endif |
13741 } | 13738 } |
13742 | 13739 |
13743 } // namespace internal | 13740 } // namespace internal |
13744 } // namespace v8 | 13741 } // namespace v8 |
OLD | NEW |