Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(403)

Side by Side Diff: src/parser.cc

Issue 633373003: Simplify AST ID generation. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: rebased Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/parser.h ('k') | src/preparser.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 860 matching lines...) Expand 10 before | Expand all | Expand 10 after
871 871
872 // Compute the parsing mode. 872 // Compute the parsing mode.
873 Mode mode = (FLAG_lazy && allow_lazy()) ? PARSE_LAZILY : PARSE_EAGERLY; 873 Mode mode = (FLAG_lazy && allow_lazy()) ? PARSE_LAZILY : PARSE_EAGERLY;
874 if (allow_natives_syntax() || extension_ != NULL || 874 if (allow_natives_syntax() || extension_ != NULL ||
875 (*scope)->is_eval_scope()) { 875 (*scope)->is_eval_scope()) {
876 mode = PARSE_EAGERLY; 876 mode = PARSE_EAGERLY;
877 } 877 }
878 ParsingModeScope parsing_mode(this, mode); 878 ParsingModeScope parsing_mode(this, mode);
879 879
880 // Enters 'scope'. 880 // Enters 'scope'.
881 FunctionState function_state(&function_state_, &scope_, *scope, zone(), 881 AstNodeFactory<AstConstructionVisitor> function_factory(
882 ast_value_factory(), info->ast_node_id_gen()); 882 zone(), ast_value_factory(), info->ast_node_id_gen());
883 FunctionState function_state(&function_state_, &scope_, *scope,
884 &function_factory);
883 885
884 scope_->SetStrictMode(info->strict_mode()); 886 scope_->SetStrictMode(info->strict_mode());
885 ZoneList<Statement*>* body = new(zone()) ZoneList<Statement*>(16, zone()); 887 ZoneList<Statement*>* body = new(zone()) ZoneList<Statement*>(16, zone());
886 bool ok = true; 888 bool ok = true;
887 int beg_pos = scanner()->location().beg_pos; 889 int beg_pos = scanner()->location().beg_pos;
888 ParseSourceElements(body, Token::EOS, info->is_eval(), true, eval_scope, 890 ParseSourceElements(body, Token::EOS, info->is_eval(), true, eval_scope,
889 &ok); 891 &ok);
890 892
891 if (ok && strict_mode() == STRICT) { 893 if (ok && strict_mode() == STRICT) {
892 CheckOctalLiteral(beg_pos, scanner()->location().end_pos, &ok); 894 CheckOctalLiteral(beg_pos, scanner()->location().end_pos, &ok);
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
984 986
985 { 987 {
986 // Parse the function literal. 988 // Parse the function literal.
987 Scope* scope = NewScope(scope_, GLOBAL_SCOPE); 989 Scope* scope = NewScope(scope_, GLOBAL_SCOPE);
988 info()->SetGlobalScope(scope); 990 info()->SetGlobalScope(scope);
989 if (!info()->closure().is_null()) { 991 if (!info()->closure().is_null()) {
990 scope = Scope::DeserializeScopeChain(info()->closure()->context(), scope, 992 scope = Scope::DeserializeScopeChain(info()->closure()->context(), scope,
991 zone()); 993 zone());
992 } 994 }
993 original_scope_ = scope; 995 original_scope_ = scope;
994 FunctionState function_state(&function_state_, &scope_, scope, zone(), 996 AstNodeFactory<AstConstructionVisitor> function_factory(
995 ast_value_factory(), 997 zone(), ast_value_factory(), info()->ast_node_id_gen());
996 info()->ast_node_id_gen()); 998 FunctionState function_state(&function_state_, &scope_, scope,
999 &function_factory);
997 DCHECK(scope->strict_mode() == SLOPPY || info()->strict_mode() == STRICT); 1000 DCHECK(scope->strict_mode() == SLOPPY || info()->strict_mode() == STRICT);
998 DCHECK(info()->strict_mode() == shared_info->strict_mode()); 1001 DCHECK(info()->strict_mode() == shared_info->strict_mode());
999 scope->SetStrictMode(shared_info->strict_mode()); 1002 scope->SetStrictMode(shared_info->strict_mode());
1000 FunctionLiteral::FunctionType function_type = shared_info->is_expression() 1003 FunctionLiteral::FunctionType function_type = shared_info->is_expression()
1001 ? (shared_info->is_anonymous() 1004 ? (shared_info->is_anonymous()
1002 ? FunctionLiteral::ANONYMOUS_EXPRESSION 1005 ? FunctionLiteral::ANONYMOUS_EXPRESSION
1003 : FunctionLiteral::NAMED_EXPRESSION) 1006 : FunctionLiteral::NAMED_EXPRESSION)
1004 : FunctionLiteral::DECLARATION; 1007 : FunctionLiteral::DECLARATION;
1005 bool ok = true; 1008 bool ok = true;
1006 1009
(...skipping 2478 matching lines...) Expand 10 before | Expand all | Expand 10 after
3485 int handler_count = 0; 3488 int handler_count = 0;
3486 FunctionLiteral::ParameterFlag duplicate_parameters = 3489 FunctionLiteral::ParameterFlag duplicate_parameters =
3487 FunctionLiteral::kNoDuplicateParameters; 3490 FunctionLiteral::kNoDuplicateParameters;
3488 FunctionLiteral::IsParenthesizedFlag parenthesized = parenthesized_function_ 3491 FunctionLiteral::IsParenthesizedFlag parenthesized = parenthesized_function_
3489 ? FunctionLiteral::kIsParenthesized 3492 ? FunctionLiteral::kIsParenthesized
3490 : FunctionLiteral::kNotParenthesized; 3493 : FunctionLiteral::kNotParenthesized;
3491 AstProperties ast_properties; 3494 AstProperties ast_properties;
3492 BailoutReason dont_optimize_reason = kNoReason; 3495 BailoutReason dont_optimize_reason = kNoReason;
3493 // Parse function body. 3496 // Parse function body.
3494 { 3497 {
3495 FunctionState function_state(&function_state_, &scope_, scope, zone(), 3498 AstNodeFactory<AstConstructionVisitor> function_factory(
3496 ast_value_factory(), 3499 zone(), ast_value_factory(), info()->ast_node_id_gen());
3497 info()->ast_node_id_gen()); 3500 FunctionState function_state(&function_state_, &scope_, scope,
3501 &function_factory);
3498 scope_->SetScopeName(function_name); 3502 scope_->SetScopeName(function_name);
3499 3503
3500 if (is_generator) { 3504 if (is_generator) {
3501 // For generators, allocating variables in contexts is currently a win 3505 // For generators, allocating variables in contexts is currently a win
3502 // because it minimizes the work needed to suspend and resume an 3506 // because it minimizes the work needed to suspend and resume an
3503 // activation. 3507 // activation.
3504 scope_->ForceContextAllocation(); 3508 scope_->ForceContextAllocation();
3505 3509
3506 // Calling a generator returns a generator object. That object is stored 3510 // Calling a generator returns a generator object. That object is stored
3507 // in a temporary variable, a definition that is used by "yield" 3511 // in a temporary variable, a definition that is used by "yield"
(...skipping 1439 matching lines...) Expand 10 before | Expand all | Expand 10 after
4947 4951
4948 // We cannot internalize on a background thread; a foreground task will take 4952 // We cannot internalize on a background thread; a foreground task will take
4949 // care of calling Parser::Internalize just before compilation. 4953 // care of calling Parser::Internalize just before compilation.
4950 4954
4951 if (compile_options() == ScriptCompiler::kProduceParserCache) { 4955 if (compile_options() == ScriptCompiler::kProduceParserCache) {
4952 if (result != NULL) *info_->cached_data() = recorder.GetScriptData(); 4956 if (result != NULL) *info_->cached_data() = recorder.GetScriptData();
4953 log_ = NULL; 4957 log_ = NULL;
4954 } 4958 }
4955 } 4959 }
4956 } } // namespace v8::internal 4960 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/parser.h ('k') | src/preparser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698