OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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/parsing/parser.h" | 5 #include "src/parsing/parser.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "src/api.h" | 9 #include "src/api.h" |
10 #include "src/ast/ast-expression-rewriter.h" | 10 #include "src/ast/ast-expression-rewriter.h" |
(...skipping 2485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2496 for (const auto p : parameters.params) { | 2496 for (const auto p : parameters.params) { |
2497 if (p.pattern != nullptr) reindexer.Reindex(p.pattern); | 2497 if (p.pattern != nullptr) reindexer.Reindex(p.pattern); |
2498 if (p.initializer != nullptr) reindexer.Reindex(p.initializer); | 2498 if (p.initializer != nullptr) reindexer.Reindex(p.initializer); |
2499 } | 2499 } |
2500 | 2500 |
2501 DCHECK(reindexer.count() <= function_state_->materialized_literal_count()); | 2501 DCHECK(reindexer.count() <= function_state_->materialized_literal_count()); |
2502 } | 2502 } |
2503 } | 2503 } |
2504 | 2504 |
2505 void Parser::PrepareGeneratorVariables(FunctionState* function_state) { | 2505 void Parser::PrepareGeneratorVariables(FunctionState* function_state) { |
2506 // For generators, allocating variables in contexts is currently a win | 2506 // For generators, allocating variables in contexts is currently a win because |
2507 // because it minimizes the work needed to suspend and resume an | 2507 // it minimizes the work needed to suspend and resume an activation. The |
2508 // activation. The machine code produced for generators (by full-codegen) | 2508 // code produced for generators relies on this forced context allocation, but |
2509 // relies on this forced context allocation, but not in an essential way. | 2509 // not in an essential way. |
2510 scope()->ForceContextAllocation(); | 2510 scope()->ForceContextAllocation(); |
2511 | 2511 |
2512 // Calling a generator returns a generator object. That object is stored | 2512 // Calling a generator returns a generator object. That object is stored |
2513 // in a temporary variable, a definition that is used by "yield" | 2513 // in a temporary variable, a definition that is used by "yield" |
2514 // expressions. | 2514 // expressions. |
2515 Variable* temp = | 2515 Variable* temp = |
2516 NewTemporary(ast_value_factory()->dot_generator_object_string()); | 2516 NewTemporary(ast_value_factory()->dot_generator_object_string()); |
2517 function_state->set_generator_object_variable(temp); | 2517 function_state->set_generator_object_variable(temp); |
2518 } | 2518 } |
2519 | 2519 |
(...skipping 2940 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5460 | 5460 |
5461 return final_loop; | 5461 return final_loop; |
5462 } | 5462 } |
5463 | 5463 |
5464 #undef CHECK_OK | 5464 #undef CHECK_OK |
5465 #undef CHECK_OK_VOID | 5465 #undef CHECK_OK_VOID |
5466 #undef CHECK_FAILED | 5466 #undef CHECK_FAILED |
5467 | 5467 |
5468 } // namespace internal | 5468 } // namespace internal |
5469 } // namespace v8 | 5469 } // namespace v8 |
OLD | NEW |