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/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/api.h" | 7 #include "src/api.h" |
8 #include "src/ast.h" | 8 #include "src/ast.h" |
9 #include "src/bailout-reason.h" | 9 #include "src/bailout-reason.h" |
10 #include "src/base/platform/platform.h" | 10 #include "src/base/platform/platform.h" |
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
512 } | 512 } |
513 } | 513 } |
514 | 514 |
515 | 515 |
516 void ParserTraits::CheckPossibleEvalCall(Expression* expression, | 516 void ParserTraits::CheckPossibleEvalCall(Expression* expression, |
517 Scope* scope) { | 517 Scope* scope) { |
518 VariableProxy* callee = expression->AsVariableProxy(); | 518 VariableProxy* callee = expression->AsVariableProxy(); |
519 if (callee != NULL && | 519 if (callee != NULL && |
520 callee->raw_name() == parser_->ast_value_factory()->eval_string()) { | 520 callee->raw_name() == parser_->ast_value_factory()->eval_string()) { |
521 scope->DeclarationScope()->RecordEvalCall(); | 521 scope->DeclarationScope()->RecordEvalCall(); |
| 522 scope->RecordEvalCall(); |
522 } | 523 } |
523 } | 524 } |
524 | 525 |
525 | 526 |
526 Expression* ParserTraits::MarkExpressionAsAssigned(Expression* expression) { | 527 Expression* ParserTraits::MarkExpressionAsAssigned(Expression* expression) { |
527 VariableProxy* proxy = | 528 VariableProxy* proxy = |
528 expression != NULL ? expression->AsVariableProxy() : NULL; | 529 expression != NULL ? expression->AsVariableProxy() : NULL; |
529 if (proxy != NULL) proxy->set_is_assigned(); | 530 if (proxy != NULL) proxy->set_is_assigned(); |
530 return expression; | 531 return expression; |
531 } | 532 } |
(...skipping 2790 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3322 Statement* clear_first = NULL; | 3323 Statement* clear_first = NULL; |
3323 // Make statement: first = 0. | 3324 // Make statement: first = 0. |
3324 { | 3325 { |
3325 VariableProxy* first_proxy = factory()->NewVariableProxy(first); | 3326 VariableProxy* first_proxy = factory()->NewVariableProxy(first); |
3326 Expression* const0 = factory()->NewSmiLiteral(0, RelocInfo::kNoPosition); | 3327 Expression* const0 = factory()->NewSmiLiteral(0, RelocInfo::kNoPosition); |
3327 Assignment* assignment = factory()->NewAssignment( | 3328 Assignment* assignment = factory()->NewAssignment( |
3328 Token::ASSIGN, first_proxy, const0, RelocInfo::kNoPosition); | 3329 Token::ASSIGN, first_proxy, const0, RelocInfo::kNoPosition); |
3329 clear_first = | 3330 clear_first = |
3330 factory()->NewExpressionStatement(assignment, RelocInfo::kNoPosition); | 3331 factory()->NewExpressionStatement(assignment, RelocInfo::kNoPosition); |
3331 } | 3332 } |
3332 Statement* clear_first_or_next = | 3333 Statement* clear_first_or_next = factory()->NewIfStatement( |
3333 factory()->NewIfStatement(compare, clear_first, next, next->position()); | 3334 compare, clear_first, next, RelocInfo::kNoPosition); |
3334 inner_block->AddStatement(clear_first_or_next, zone()); | 3335 inner_block->AddStatement(clear_first_or_next, zone()); |
3335 } | 3336 } |
3336 | 3337 |
3337 Variable* flag = scope_->DeclarationScope()->NewTemporary(temp_name); | 3338 Variable* flag = scope_->DeclarationScope()->NewTemporary(temp_name); |
3338 // Make statement: flag = 1. | 3339 // Make statement: flag = 1. |
3339 { | 3340 { |
3340 VariableProxy* flag_proxy = factory()->NewVariableProxy(flag); | 3341 VariableProxy* flag_proxy = factory()->NewVariableProxy(flag); |
3341 Expression* const1 = factory()->NewSmiLiteral(1, RelocInfo::kNoPosition); | 3342 Expression* const1 = factory()->NewSmiLiteral(1, RelocInfo::kNoPosition); |
3342 Assignment* assignment = factory()->NewAssignment( | 3343 Assignment* assignment = factory()->NewAssignment( |
3343 Token::ASSIGN, flag_proxy, const1, RelocInfo::kNoPosition); | 3344 Token::ASSIGN, flag_proxy, const1, RelocInfo::kNoPosition); |
(...skipping 687 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4031 // that it will be compiled lazily. | 4032 // that it will be compiled lazily. |
4032 | 4033 |
4033 // To make this additional case work, both Parser and PreParser implement a | 4034 // To make this additional case work, both Parser and PreParser implement a |
4034 // logic where only top-level functions will be parsed lazily. | 4035 // logic where only top-level functions will be parsed lazily. |
4035 bool is_lazily_parsed = (mode() == PARSE_LAZILY && | 4036 bool is_lazily_parsed = (mode() == PARSE_LAZILY && |
4036 scope_->AllowsLazyCompilation() && | 4037 scope_->AllowsLazyCompilation() && |
4037 !parenthesized_function_); | 4038 !parenthesized_function_); |
4038 parenthesized_function_ = false; // The bit was set for this function only. | 4039 parenthesized_function_ = false; // The bit was set for this function only. |
4039 | 4040 |
4040 if (is_lazily_parsed) { | 4041 if (is_lazily_parsed) { |
| 4042 for (Scope* s = scope_->outer_scope(); |
| 4043 s != nullptr && (s != s->DeclarationScope()); s = s->outer_scope()) { |
| 4044 s->ForceContextAllocation(); |
| 4045 } |
4041 SkipLazyFunctionBody(&materialized_literal_count, | 4046 SkipLazyFunctionBody(&materialized_literal_count, |
4042 &expected_property_count, CHECK_OK); | 4047 &expected_property_count, CHECK_OK); |
4043 } else { | 4048 } else { |
4044 body = ParseEagerFunctionBody(function_name, pos, fvar, fvar_init_op, | 4049 body = ParseEagerFunctionBody(function_name, pos, fvar, fvar_init_op, |
4045 kind, CHECK_OK); | 4050 kind, CHECK_OK); |
4046 materialized_literal_count = function_state.materialized_literal_count(); | 4051 materialized_literal_count = function_state.materialized_literal_count(); |
4047 expected_property_count = function_state.expected_property_count(); | 4052 expected_property_count = function_state.expected_property_count(); |
4048 handler_count = function_state.handler_count(); | 4053 handler_count = function_state.handler_count(); |
4049 | 4054 |
4050 if (is_strong(language_mode()) && IsSubclassConstructor(kind)) { | 4055 if (is_strong(language_mode()) && IsSubclassConstructor(kind)) { |
(...skipping 1729 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5780 | 5785 |
5781 Expression* Parser::SpreadCallNew(Expression* function, | 5786 Expression* Parser::SpreadCallNew(Expression* function, |
5782 ZoneList<v8::internal::Expression*>* args, | 5787 ZoneList<v8::internal::Expression*>* args, |
5783 int pos) { | 5788 int pos) { |
5784 args->InsertAt(0, function, zone()); | 5789 args->InsertAt(0, function, zone()); |
5785 | 5790 |
5786 return factory()->NewCallRuntime( | 5791 return factory()->NewCallRuntime( |
5787 ast_value_factory()->reflect_construct_string(), NULL, args, pos); | 5792 ast_value_factory()->reflect_construct_string(), NULL, args, pos); |
5788 } | 5793 } |
5789 } } // namespace v8::internal | 5794 } } // namespace v8::internal |
OLD | NEW |