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 868883002: Remove the dependency of Zone on Isolate (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix compilation issues Created 5 years, 11 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
« 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 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 DCHECK(info_->cached_data() != NULL); 258 DCHECK(info_->cached_data() != NULL);
259 if (compile_options() == ScriptCompiler::kConsumeParserCache) { 259 if (compile_options() == ScriptCompiler::kConsumeParserCache) {
260 cached_parse_data_ = ParseData::FromCachedData(*info_->cached_data()); 260 cached_parse_data_ = ParseData::FromCachedData(*info_->cached_data());
261 } 261 }
262 } 262 }
263 } 263 }
264 264
265 265
266 Scope* Parser::NewScope(Scope* parent, ScopeType scope_type) { 266 Scope* Parser::NewScope(Scope* parent, ScopeType scope_type) {
267 DCHECK(ast_value_factory()); 267 DCHECK(ast_value_factory());
268 Scope* result = 268 Scope* result = new (zone())
269 new (zone()) Scope(parent, scope_type, ast_value_factory(), zone()); 269 Scope(isolate(), zone(), parent, scope_type, ast_value_factory());
270 result->Initialize(); 270 result->Initialize();
271 return result; 271 return result;
272 } 272 }
273 273
274 274
275 FunctionLiteral* Parser::DefaultConstructor(bool call_super, Scope* scope, 275 FunctionLiteral* Parser::DefaultConstructor(bool call_super, Scope* scope,
276 int pos, int end_pos) { 276 int pos, int end_pos) {
277 int materialized_literal_count = -1; 277 int materialized_literal_count = -1;
278 int expected_property_count = -1; 278 int expected_property_count = -1;
279 int handler_count = 0; 279 int handler_count = 0;
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after
771 771
772 ClassLiteral* ParserTraits::ParseClassLiteral( 772 ClassLiteral* ParserTraits::ParseClassLiteral(
773 const AstRawString* name, Scanner::Location class_name_location, 773 const AstRawString* name, Scanner::Location class_name_location,
774 bool name_is_strict_reserved, int pos, bool* ok) { 774 bool name_is_strict_reserved, int pos, bool* ok) {
775 return parser_->ParseClassLiteral(name, class_name_location, 775 return parser_->ParseClassLiteral(name, class_name_location,
776 name_is_strict_reserved, pos, ok); 776 name_is_strict_reserved, pos, ok);
777 } 777 }
778 778
779 779
780 Parser::Parser(CompilationInfo* info, ParseInfo* parse_info) 780 Parser::Parser(CompilationInfo* info, ParseInfo* parse_info)
781 : ParserBase<ParserTraits>(&scanner_, parse_info->stack_limit, 781 : ParserBase<ParserTraits>(info->isolate(), info->zone(), &scanner_,
782 info->extension(), NULL, info->zone(), this), 782 parse_info->stack_limit, info->extension(), NULL,
783 this),
783 scanner_(parse_info->unicode_cache), 784 scanner_(parse_info->unicode_cache),
784 reusable_preparser_(NULL), 785 reusable_preparser_(NULL),
785 original_scope_(NULL), 786 original_scope_(NULL),
786 target_stack_(NULL), 787 target_stack_(NULL),
787 cached_parse_data_(NULL), 788 cached_parse_data_(NULL),
788 info_(info), 789 info_(info),
789 has_pending_error_(false), 790 has_pending_error_(false),
790 pending_error_message_(NULL), 791 pending_error_message_(NULL),
791 pending_error_arg_(NULL), 792 pending_error_arg_(NULL),
792 pending_error_char_arg_(NULL), 793 pending_error_char_arg_(NULL),
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
890 FunctionLiteral* Parser::DoParseProgram(CompilationInfo* info, Scope** scope, 891 FunctionLiteral* Parser::DoParseProgram(CompilationInfo* info, Scope** scope,
891 Scope** eval_scope) { 892 Scope** eval_scope) {
892 DCHECK(scope_ == NULL); 893 DCHECK(scope_ == NULL);
893 DCHECK(target_stack_ == NULL); 894 DCHECK(target_stack_ == NULL);
894 895
895 FunctionLiteral* result = NULL; 896 FunctionLiteral* result = NULL;
896 { 897 {
897 *scope = NewScope(scope_, SCRIPT_SCOPE); 898 *scope = NewScope(scope_, SCRIPT_SCOPE);
898 info->SetScriptScope(*scope); 899 info->SetScriptScope(*scope);
899 if (!info->context().is_null() && !info->context()->IsNativeContext()) { 900 if (!info->context().is_null() && !info->context()->IsNativeContext()) {
900 *scope = Scope::DeserializeScopeChain(*info->context(), *scope, zone()); 901 *scope = Scope::DeserializeScopeChain(info->isolate(), zone(),
902 *info->context(), *scope);
901 // The Scope is backed up by ScopeInfo (which is in the V8 heap); this 903 // The Scope is backed up by ScopeInfo (which is in the V8 heap); this
902 // means the Parser cannot operate independent of the V8 heap. Tell the 904 // means the Parser cannot operate independent of the V8 heap. Tell the
903 // string table to internalize strings and values right after they're 905 // string table to internalize strings and values right after they're
904 // created. 906 // created.
905 ast_value_factory()->Internalize(isolate()); 907 ast_value_factory()->Internalize(isolate());
906 } 908 }
907 original_scope_ = *scope; 909 original_scope_ = *scope;
908 if (info->is_eval()) { 910 if (info->is_eval()) {
909 if (!(*scope)->is_script_scope() || info->strict_mode() == STRICT) { 911 if (!(*scope)->is_script_scope() || info->strict_mode() == STRICT) {
910 *scope = NewScope(*scope, EVAL_SCOPE); 912 *scope = NewScope(*scope, EVAL_SCOPE);
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
1024 ParsingModeScope parsing_mode(this, PARSE_EAGERLY); 1026 ParsingModeScope parsing_mode(this, PARSE_EAGERLY);
1025 1027
1026 // Place holder for the result. 1028 // Place holder for the result.
1027 FunctionLiteral* result = NULL; 1029 FunctionLiteral* result = NULL;
1028 1030
1029 { 1031 {
1030 // Parse the function literal. 1032 // Parse the function literal.
1031 Scope* scope = NewScope(scope_, SCRIPT_SCOPE); 1033 Scope* scope = NewScope(scope_, SCRIPT_SCOPE);
1032 info()->SetScriptScope(scope); 1034 info()->SetScriptScope(scope);
1033 if (!info()->closure().is_null()) { 1035 if (!info()->closure().is_null()) {
1034 scope = Scope::DeserializeScopeChain(info()->closure()->context(), scope, 1036 scope = Scope::DeserializeScopeChain(isolate(), zone(),
1035 zone()); 1037 info()->closure()->context(), scope);
1036 } 1038 }
1037 original_scope_ = scope; 1039 original_scope_ = scope;
1038 AstNodeFactory function_factory(ast_value_factory()); 1040 AstNodeFactory function_factory(ast_value_factory());
1039 FunctionState function_state(&function_state_, &scope_, scope, 1041 FunctionState function_state(&function_state_, &scope_, scope,
1040 &function_factory); 1042 &function_factory);
1041 DCHECK(scope->strict_mode() == SLOPPY || info()->strict_mode() == STRICT); 1043 DCHECK(scope->strict_mode() == SLOPPY || info()->strict_mode() == STRICT);
1042 DCHECK(info()->strict_mode() == shared_info->strict_mode()); 1044 DCHECK(info()->strict_mode() == shared_info->strict_mode());
1043 scope->SetStrictMode(shared_info->strict_mode()); 1045 scope->SetStrictMode(shared_info->strict_mode());
1044 FunctionLiteral::FunctionType function_type = shared_info->is_expression() 1046 FunctionLiteral::FunctionType function_type = shared_info->is_expression()
1045 ? (shared_info->is_anonymous() 1047 ? (shared_info->is_anonymous()
(...skipping 2888 matching lines...) Expand 10 before | Expand all | Expand 10 after
3934 PreParser::PreParseResult Parser::ParseLazyFunctionBodyWithPreParser( 3936 PreParser::PreParseResult Parser::ParseLazyFunctionBodyWithPreParser(
3935 SingletonLogger* logger) { 3937 SingletonLogger* logger) {
3936 // This function may be called on a background thread too; record only the 3938 // This function may be called on a background thread too; record only the
3937 // main thread preparse times. 3939 // main thread preparse times.
3938 if (pre_parse_timer_ != NULL) { 3940 if (pre_parse_timer_ != NULL) {
3939 pre_parse_timer_->Start(); 3941 pre_parse_timer_->Start();
3940 } 3942 }
3941 DCHECK_EQ(Token::LBRACE, scanner()->current_token()); 3943 DCHECK_EQ(Token::LBRACE, scanner()->current_token());
3942 3944
3943 if (reusable_preparser_ == NULL) { 3945 if (reusable_preparser_ == NULL) {
3944 reusable_preparser_ = new PreParser(&scanner_, NULL, stack_limit_); 3946 reusable_preparser_ =
3947 new PreParser(isolate(), &scanner_, NULL, stack_limit_);
3945 reusable_preparser_->set_allow_lazy(true); 3948 reusable_preparser_->set_allow_lazy(true);
3946 reusable_preparser_->set_allow_natives(allow_natives()); 3949 reusable_preparser_->set_allow_natives(allow_natives());
3947 reusable_preparser_->set_allow_harmony_scoping(allow_harmony_scoping()); 3950 reusable_preparser_->set_allow_harmony_scoping(allow_harmony_scoping());
3948 reusable_preparser_->set_allow_harmony_modules(allow_harmony_modules()); 3951 reusable_preparser_->set_allow_harmony_modules(allow_harmony_modules());
3949 reusable_preparser_->set_allow_harmony_arrow_functions( 3952 reusable_preparser_->set_allow_harmony_arrow_functions(
3950 allow_harmony_arrow_functions()); 3953 allow_harmony_arrow_functions());
3951 reusable_preparser_->set_allow_harmony_numeric_literals( 3954 reusable_preparser_->set_allow_harmony_numeric_literals(
3952 allow_harmony_numeric_literals()); 3955 allow_harmony_numeric_literals());
3953 reusable_preparser_->set_allow_harmony_classes(allow_harmony_classes()); 3956 reusable_preparser_->set_allow_harmony_classes(allow_harmony_classes());
3954 reusable_preparser_->set_allow_harmony_object_literals( 3957 reusable_preparser_->set_allow_harmony_object_literals(
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
4243 isolate()->counters()->total_preparse_skipped()->Increment( 4246 isolate()->counters()->total_preparse_skipped()->Increment(
4244 total_preparse_skipped_); 4247 total_preparse_skipped_);
4245 } 4248 }
4246 4249
4247 4250
4248 // ---------------------------------------------------------------------------- 4251 // ----------------------------------------------------------------------------
4249 // Regular expressions 4252 // Regular expressions
4250 4253
4251 4254
4252 RegExpParser::RegExpParser(FlatStringReader* in, Handle<String>* error, 4255 RegExpParser::RegExpParser(FlatStringReader* in, Handle<String>* error,
4253 bool multiline, bool unicode, Zone* zone) 4256 bool multiline, bool unicode, Isolate* isolate,
4254 : isolate_(zone->isolate()), 4257 Zone* zone)
4258 : isolate_(isolate),
4255 zone_(zone), 4259 zone_(zone),
4256 error_(error), 4260 error_(error),
4257 captures_(NULL), 4261 captures_(NULL),
4258 in_(in), 4262 in_(in),
4259 current_(kEndMarker), 4263 current_(kEndMarker),
4260 next_pos_(0), 4264 next_pos_(0),
4261 capture_count_(0), 4265 capture_count_(0),
4262 has_more_(true), 4266 has_more_(true),
4263 multiline_(multiline), 4267 multiline_(multiline),
4264 unicode_(unicode), 4268 unicode_(unicode),
(...skipping 862 matching lines...) Expand 10 before | Expand all | Expand 10 after
5127 ranges->Add(CharacterRange::Everything(), zone()); 5131 ranges->Add(CharacterRange::Everything(), zone());
5128 is_negated = !is_negated; 5132 is_negated = !is_negated;
5129 } 5133 }
5130 return new(zone()) RegExpCharacterClass(ranges, is_negated); 5134 return new(zone()) RegExpCharacterClass(ranges, is_negated);
5131 } 5135 }
5132 5136
5133 5137
5134 // ---------------------------------------------------------------------------- 5138 // ----------------------------------------------------------------------------
5135 // The Parser interface. 5139 // The Parser interface.
5136 5140
5137 bool RegExpParser::ParseRegExp(FlatStringReader* input, bool multiline, 5141 bool RegExpParser::ParseRegExp(Isolate* isolate, Zone* zone,
5138 bool unicode, RegExpCompileData* result, 5142 FlatStringReader* input, bool multiline,
5139 Zone* zone) { 5143 bool unicode, RegExpCompileData* result) {
5140 DCHECK(result != NULL); 5144 DCHECK(result != NULL);
5141 RegExpParser parser(input, &result->error, multiline, unicode, zone); 5145 RegExpParser parser(input, &result->error, multiline, unicode, isolate, zone);
5142 RegExpTree* tree = parser.ParsePattern(); 5146 RegExpTree* tree = parser.ParsePattern();
5143 if (parser.failed()) { 5147 if (parser.failed()) {
5144 DCHECK(tree == NULL); 5148 DCHECK(tree == NULL);
5145 DCHECK(!result->error.is_null()); 5149 DCHECK(!result->error.is_null());
5146 } else { 5150 } else {
5147 DCHECK(tree != NULL); 5151 DCHECK(tree != NULL);
5148 DCHECK(result->error.is_null()); 5152 DCHECK(result->error.is_null());
5149 result->tree = tree; 5153 result->tree = tree;
5150 int capture_count = parser.captures_started(); 5154 int capture_count = parser.captures_started();
5151 result->simple = tree->IsAtom() && parser.simple() && capture_count == 0; 5155 result->simple = tree->IsAtom() && parser.simple() && capture_count == 0;
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
5341 } else { 5345 } else {
5342 const uc16* data = reinterpret_cast<const uc16*>(raw_string->raw_data()); 5346 const uc16* data = reinterpret_cast<const uc16*>(raw_string->raw_data());
5343 running_hash = StringHasher::ComputeRunningHash(running_hash, data, 5347 running_hash = StringHasher::ComputeRunningHash(running_hash, data,
5344 raw_string->length()); 5348 raw_string->length());
5345 } 5349 }
5346 } 5350 }
5347 5351
5348 return running_hash; 5352 return running_hash;
5349 } 5353 }
5350 } } // namespace v8::internal 5354 } } // 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