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

Side by Side Diff: src/parser.cc

Issue 636403003: Assign bailout and type feedback IDs in a post-pass (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: 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
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"
11 #include "src/bootstrapper.h" 11 #include "src/bootstrapper.h"
12 #include "src/char-predicates-inl.h" 12 #include "src/char-predicates-inl.h"
13 #include "src/codegen.h" 13 #include "src/codegen.h"
14 #include "src/compiler.h" 14 #include "src/compiler.h"
15 #include "src/messages.h" 15 #include "src/messages.h"
16 #include "src/parser.h" 16 #include "src/parser.h"
17 #include "src/preparser.h" 17 #include "src/preparser.h"
18 #include "src/runtime/runtime.h" 18 #include "src/runtime/runtime.h"
19 #include "src/scanner-character-streams.h" 19 #include "src/scanner-character-streams.h"
20 #include "src/scopeinfo.h" 20 #include "src/scopeinfo.h"
21 #include "src/string-stream.h" 21 #include "src/string-stream.h"
22 22
23 namespace v8 { 23 namespace v8 {
24 namespace internal { 24 namespace internal {
25 25
26
26 RegExpBuilder::RegExpBuilder(Zone* zone) 27 RegExpBuilder::RegExpBuilder(Zone* zone)
27 : zone_(zone), 28 : zone_(zone),
28 pending_empty_(false), 29 pending_empty_(false),
29 characters_(NULL), 30 characters_(NULL),
30 terms_(), 31 terms_(),
31 alternatives_() 32 alternatives_()
32 #ifdef DEBUG 33 #ifdef DEBUG
33 , last_added_(ADD_NONE) 34 , last_added_(ADD_NONE)
34 #endif 35 #endif
35 {} 36 {}
(...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after
729 int function_token_position, FunctionLiteral::FunctionType type, 730 int function_token_position, FunctionLiteral::FunctionType type,
730 FunctionLiteral::ArityRestriction arity_restriction, bool* ok) { 731 FunctionLiteral::ArityRestriction arity_restriction, bool* ok) {
731 return parser_->ParseFunctionLiteral( 732 return parser_->ParseFunctionLiteral(
732 name, function_name_location, name_is_strict_reserved, kind, 733 name, function_name_location, name_is_strict_reserved, kind,
733 function_token_position, type, arity_restriction, ok); 734 function_token_position, type, arity_restriction, ok);
734 } 735 }
735 736
736 737
737 Parser::Parser(CompilationInfo* info, ParseInfo* parse_info) 738 Parser::Parser(CompilationInfo* info, ParseInfo* parse_info)
738 : ParserBase<ParserTraits>(&scanner_, parse_info->stack_limit, 739 : ParserBase<ParserTraits>(&scanner_, parse_info->stack_limit,
739 info->extension(), NULL, info->zone(), 740 info->extension(), NULL, info->zone(), this),
740 info->ast_node_id_gen(), this),
741 scanner_(parse_info->unicode_cache), 741 scanner_(parse_info->unicode_cache),
742 reusable_preparser_(NULL), 742 reusable_preparser_(NULL),
743 original_scope_(NULL), 743 original_scope_(NULL),
744 target_stack_(NULL), 744 target_stack_(NULL),
745 cached_parse_data_(NULL), 745 cached_parse_data_(NULL),
746 info_(info), 746 info_(info),
747 has_pending_error_(false), 747 has_pending_error_(false),
748 pending_error_message_(NULL), 748 pending_error_message_(NULL),
749 pending_error_arg_(NULL), 749 pending_error_arg_(NULL),
750 pending_error_char_arg_(NULL), 750 pending_error_char_arg_(NULL),
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 AstNodeFactory<AstConstructionVisitor> function_factory( 881 AstNodeFactory<AstConstructionVisitor> function_factory(
882 zone(), ast_value_factory(), info->ast_node_id_gen()); 882 zone(), ast_value_factory());
883 FunctionState function_state(&function_state_, &scope_, *scope, 883 FunctionState function_state(&function_state_, &scope_, *scope,
884 &function_factory); 884 &function_factory);
885 885
886 scope_->SetStrictMode(info->strict_mode()); 886 scope_->SetStrictMode(info->strict_mode());
887 ZoneList<Statement*>* body = new(zone()) ZoneList<Statement*>(16, zone()); 887 ZoneList<Statement*>* body = new(zone()) ZoneList<Statement*>(16, zone());
888 bool ok = true; 888 bool ok = true;
889 int beg_pos = scanner()->location().beg_pos; 889 int beg_pos = scanner()->location().beg_pos;
890 ParseSourceElements(body, Token::EOS, info->is_eval(), true, eval_scope, 890 ParseSourceElements(body, Token::EOS, info->is_eval(), true, eval_scope,
891 &ok); 891 &ok);
892 892
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
987 { 987 {
988 // Parse the function literal. 988 // Parse the function literal.
989 Scope* scope = NewScope(scope_, GLOBAL_SCOPE); 989 Scope* scope = NewScope(scope_, GLOBAL_SCOPE);
990 info()->SetGlobalScope(scope); 990 info()->SetGlobalScope(scope);
991 if (!info()->closure().is_null()) { 991 if (!info()->closure().is_null()) {
992 scope = Scope::DeserializeScopeChain(info()->closure()->context(), scope, 992 scope = Scope::DeserializeScopeChain(info()->closure()->context(), scope,
993 zone()); 993 zone());
994 } 994 }
995 original_scope_ = scope; 995 original_scope_ = scope;
996 AstNodeFactory<AstConstructionVisitor> function_factory( 996 AstNodeFactory<AstConstructionVisitor> function_factory(
997 zone(), ast_value_factory(), info()->ast_node_id_gen()); 997 zone(), ast_value_factory());
998 FunctionState function_state(&function_state_, &scope_, scope, 998 FunctionState function_state(&function_state_, &scope_, scope,
999 &function_factory); 999 &function_factory);
1000 DCHECK(scope->strict_mode() == SLOPPY || info()->strict_mode() == STRICT); 1000 DCHECK(scope->strict_mode() == SLOPPY || info()->strict_mode() == STRICT);
1001 DCHECK(info()->strict_mode() == shared_info->strict_mode()); 1001 DCHECK(info()->strict_mode() == shared_info->strict_mode());
1002 scope->SetStrictMode(shared_info->strict_mode()); 1002 scope->SetStrictMode(shared_info->strict_mode());
1003 FunctionLiteral::FunctionType function_type = shared_info->is_expression() 1003 FunctionLiteral::FunctionType function_type = shared_info->is_expression()
1004 ? (shared_info->is_anonymous() 1004 ? (shared_info->is_anonymous()
1005 ? FunctionLiteral::ANONYMOUS_EXPRESSION 1005 ? FunctionLiteral::ANONYMOUS_EXPRESSION
1006 : FunctionLiteral::NAMED_EXPRESSION) 1006 : FunctionLiteral::NAMED_EXPRESSION)
1007 : FunctionLiteral::DECLARATION; 1007 : FunctionLiteral::DECLARATION;
(...skipping 2481 matching lines...) Expand 10 before | Expand all | Expand 10 after
3489 FunctionLiteral::ParameterFlag duplicate_parameters = 3489 FunctionLiteral::ParameterFlag duplicate_parameters =
3490 FunctionLiteral::kNoDuplicateParameters; 3490 FunctionLiteral::kNoDuplicateParameters;
3491 FunctionLiteral::IsParenthesizedFlag parenthesized = parenthesized_function_ 3491 FunctionLiteral::IsParenthesizedFlag parenthesized = parenthesized_function_
3492 ? FunctionLiteral::kIsParenthesized 3492 ? FunctionLiteral::kIsParenthesized
3493 : FunctionLiteral::kNotParenthesized; 3493 : FunctionLiteral::kNotParenthesized;
3494 AstProperties ast_properties; 3494 AstProperties ast_properties;
3495 BailoutReason dont_optimize_reason = kNoReason; 3495 BailoutReason dont_optimize_reason = kNoReason;
3496 // Parse function body. 3496 // Parse function body.
3497 { 3497 {
3498 AstNodeFactory<AstConstructionVisitor> function_factory( 3498 AstNodeFactory<AstConstructionVisitor> function_factory(
3499 zone(), ast_value_factory(), info()->ast_node_id_gen()); 3499 zone(), ast_value_factory());
3500 FunctionState function_state(&function_state_, &scope_, scope, 3500 FunctionState function_state(&function_state_, &scope_, scope,
3501 &function_factory); 3501 &function_factory);
3502 scope_->SetScopeName(function_name); 3502 scope_->SetScopeName(function_name);
3503 3503
3504 if (is_generator) { 3504 if (is_generator) {
3505 // For generators, allocating variables in contexts is currently a win 3505 // For generators, allocating variables in contexts is currently a win
3506 // because it minimizes the work needed to suspend and resume an 3506 // because it minimizes the work needed to suspend and resume an
3507 // activation. 3507 // activation.
3508 scope_->ForceContextAllocation(); 3508 scope_->ForceContextAllocation();
3509 3509
(...skipping 1441 matching lines...) Expand 10 before | Expand all | Expand 10 after
4951 4951
4952 // 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
4953 // care of calling Parser::Internalize just before compilation. 4953 // care of calling Parser::Internalize just before compilation.
4954 4954
4955 if (compile_options() == ScriptCompiler::kProduceParserCache) { 4955 if (compile_options() == ScriptCompiler::kProduceParserCache) {
4956 if (result != NULL) *info_->cached_data() = recorder.GetScriptData(); 4956 if (result != NULL) *info_->cached_data() = recorder.GetScriptData();
4957 log_ = NULL; 4957 log_ = NULL;
4958 } 4958 }
4959 } 4959 }
4960 } } // namespace v8::internal 4960 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698