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

Side by Side Diff: src/parser.cc

Issue 974213002: Extract ParseInfo from CompilationInfo. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 9 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
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 ScriptData::ScriptData(const byte* data, int length)
27 : owns_data_(false), rejected_(false), data_(data), length_(length) {
28 if (!IsAligned(reinterpret_cast<intptr_t>(data), kPointerAlignment)) {
29 byte* copy = NewArray<byte>(length);
30 DCHECK(IsAligned(reinterpret_cast<intptr_t>(copy), kPointerAlignment));
31 CopyBytes(copy, data, length);
32 data_ = copy;
33 AcquireDataOwnership();
34 }
35 }
36
37
38 void ParseInfo::InitializeFromJSFunction(Handle<JSFunction> function) {
39 Handle<SharedFunctionInfo> shared(function->shared());
40 InitializeFromSharedFunctionInfo(shared);
41 set_closure(function);
42 set_context(Handle<Context>(function->context()));
43 }
44
45
46 void ParseInfo::InitializeFromSharedFunctionInfo(
47 Handle<SharedFunctionInfo> shared) {
48 isolate_ = shared->GetIsolate();
49
50 set_lazy();
51 set_this_has_uses();
52 set_hash_seed(isolate_->heap()->HashSeed());
53 set_stack_limit(isolate_->stack_guard()->real_climit());
54 set_unicode_cache(isolate_->unicode_cache());
55 set_language_mode(shared->language_mode());
56 set_shared_info(shared);
57
58 Handle<Script> script(Script::cast(shared->script()));
59 set_script(script);
60 if (!script.is_null() && script->type()->value() == Script::TYPE_NATIVE) {
61 set_native();
62 }
63 }
64
65
66 void ParseInfo::InitializeFromScript(Handle<Script> script) {
67 isolate_ = script->GetIsolate();
68
69 set_this_has_uses();
70 set_hash_seed(isolate_->heap()->HashSeed());
71 set_stack_limit(isolate_->stack_guard()->real_climit());
72 set_unicode_cache(isolate_->unicode_cache());
73 set_script(script);
74
75 if (script->type()->value() == Script::TYPE_NATIVE) {
76 set_native();
77 }
78 }
79
80
26 RegExpBuilder::RegExpBuilder(Zone* zone) 81 RegExpBuilder::RegExpBuilder(Zone* zone)
27 : zone_(zone), 82 : zone_(zone),
28 pending_empty_(false), 83 pending_empty_(false),
29 characters_(NULL), 84 characters_(NULL),
30 terms_(), 85 terms_(),
31 alternatives_() 86 alternatives_()
32 #ifdef DEBUG 87 #ifdef DEBUG
33 , last_added_(ADD_NONE) 88 , last_added_(ADD_NONE)
34 #endif 89 #endif
35 {} 90 {}
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 unsigned ParseData::Version() { 299 unsigned ParseData::Version() {
245 return Data()[PreparseDataConstants::kVersionOffset]; 300 return Data()[PreparseDataConstants::kVersionOffset];
246 } 301 }
247 302
248 303
249 int ParseData::FunctionsSize() { 304 int ParseData::FunctionsSize() {
250 return static_cast<int>(Data()[PreparseDataConstants::kFunctionsSizeOffset]); 305 return static_cast<int>(Data()[PreparseDataConstants::kFunctionsSizeOffset]);
251 } 306 }
252 307
253 308
254 void Parser::SetCachedData(CompilationInfo* info) { 309 void Parser::SetCachedData(ParseInfo* info) {
255 if (compile_options_ == ScriptCompiler::kNoCompileOptions) { 310 if (compile_options_ == ScriptCompiler::kNoCompileOptions) {
256 cached_parse_data_ = NULL; 311 cached_parse_data_ = NULL;
257 } else { 312 } else {
258 DCHECK(info->cached_data() != NULL); 313 DCHECK(info->cached_data() != NULL);
259 if (compile_options_ == ScriptCompiler::kConsumeParserCache) { 314 if (compile_options_ == ScriptCompiler::kConsumeParserCache) {
260 cached_parse_data_ = ParseData::FromCachedData(*info->cached_data()); 315 cached_parse_data_ = ParseData::FromCachedData(*info->cached_data());
261 } 316 }
262 } 317 }
263 } 318 }
264 319
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after
772 827
773 828
774 ClassLiteral* ParserTraits::ParseClassLiteral( 829 ClassLiteral* ParserTraits::ParseClassLiteral(
775 const AstRawString* name, Scanner::Location class_name_location, 830 const AstRawString* name, Scanner::Location class_name_location,
776 bool name_is_strict_reserved, int pos, bool* ok) { 831 bool name_is_strict_reserved, int pos, bool* ok) {
777 return parser_->ParseClassLiteral(name, class_name_location, 832 return parser_->ParseClassLiteral(name, class_name_location,
778 name_is_strict_reserved, pos, ok); 833 name_is_strict_reserved, pos, ok);
779 } 834 }
780 835
781 836
782 Parser::Parser(CompilationInfo* info, uintptr_t stack_limit, uint32_t hash_seed, 837 Parser::Parser(ParseInfo* info)
783 UnicodeCache* unicode_cache) 838 : ParserBase<ParserTraits>(info->zone(), &scanner_, info->stack_limit(),
784 : ParserBase<ParserTraits>(info->zone(), &scanner_, stack_limit,
785 info->extension(), info->ast_value_factory(), 839 info->extension(), info->ast_value_factory(),
786 NULL, this), 840 NULL, this),
787 scanner_(unicode_cache), 841 scanner_(info->unicode_cache()),
788 reusable_preparser_(NULL), 842 reusable_preparser_(NULL),
789 original_scope_(NULL), 843 original_scope_(NULL),
790 target_stack_(NULL), 844 target_stack_(NULL),
791 compile_options_(info->compile_options()), 845 compile_options_(info->compile_options()),
792 cached_parse_data_(NULL), 846 cached_parse_data_(NULL),
793 parsing_lazy_arrow_parameters_(false), 847 parsing_lazy_arrow_parameters_(false),
794 total_preparse_skipped_(0), 848 total_preparse_skipped_(0),
795 pre_parse_timer_(NULL), 849 pre_parse_timer_(NULL),
796 parsing_on_main_thread_(true) { 850 parsing_on_main_thread_(true) {
797 // Even though we were passed CompilationInfo, we should not store it in 851 // Even though we were passed ParseInfo, we should not store it in
798 // Parser - this makes sure that Isolate is not accidentally accessed via 852 // Parser - this makes sure that Isolate is not accidentally accessed via
799 // CompilationInfo during background parsing. 853 // ParseInfo during background parsing.
800 DCHECK(!info->script().is_null() || info->source_stream() != NULL); 854 DCHECK(!info->script().is_null() || info->source_stream() != NULL);
801 set_allow_lazy(false); // Must be explicitly enabled. 855 set_allow_lazy(false); // Must be explicitly enabled.
802 set_allow_natives(FLAG_allow_natives_syntax || info->is_native()); 856 set_allow_natives(FLAG_allow_natives_syntax || info->is_native());
803 set_allow_harmony_scoping(!info->is_native() && FLAG_harmony_scoping); 857 set_allow_harmony_scoping(!info->is_native() && FLAG_harmony_scoping);
804 set_allow_harmony_modules(!info->is_native() && FLAG_harmony_modules); 858 set_allow_harmony_modules(!info->is_native() && FLAG_harmony_modules);
805 set_allow_harmony_arrow_functions(FLAG_harmony_arrow_functions); 859 set_allow_harmony_arrow_functions(FLAG_harmony_arrow_functions);
806 set_allow_harmony_numeric_literals(FLAG_harmony_numeric_literals); 860 set_allow_harmony_numeric_literals(FLAG_harmony_numeric_literals);
807 set_allow_harmony_classes(FLAG_harmony_classes); 861 set_allow_harmony_classes(FLAG_harmony_classes);
808 set_allow_harmony_object_literals(FLAG_harmony_object_literals); 862 set_allow_harmony_object_literals(FLAG_harmony_object_literals);
809 set_allow_harmony_templates(FLAG_harmony_templates); 863 set_allow_harmony_templates(FLAG_harmony_templates);
810 set_allow_harmony_sloppy(FLAG_harmony_sloppy); 864 set_allow_harmony_sloppy(FLAG_harmony_sloppy);
811 set_allow_harmony_unicode(FLAG_harmony_unicode); 865 set_allow_harmony_unicode(FLAG_harmony_unicode);
812 set_allow_harmony_computed_property_names( 866 set_allow_harmony_computed_property_names(
813 FLAG_harmony_computed_property_names); 867 FLAG_harmony_computed_property_names);
814 set_allow_harmony_rest_params(FLAG_harmony_rest_parameters); 868 set_allow_harmony_rest_params(FLAG_harmony_rest_parameters);
815 set_allow_strong_mode(FLAG_strong_mode); 869 set_allow_strong_mode(FLAG_strong_mode);
816 for (int feature = 0; feature < v8::Isolate::kUseCounterFeatureCount; 870 for (int feature = 0; feature < v8::Isolate::kUseCounterFeatureCount;
817 ++feature) { 871 ++feature) {
818 use_counts_[feature] = 0; 872 use_counts_[feature] = 0;
819 } 873 }
820 if (info->ast_value_factory() == NULL) { 874 if (info->ast_value_factory() == NULL) {
821 // info takes ownership of AstValueFactory. 875 // info takes ownership of AstValueFactory.
822 info->SetAstValueFactory(new AstValueFactory(zone(), hash_seed)); 876 info->set_ast_value_factory(new AstValueFactory(zone(), info->hash_seed()));
877 info->set_ast_value_factory_owned();
823 ast_value_factory_ = info->ast_value_factory(); 878 ast_value_factory_ = info->ast_value_factory();
824 } 879 }
825 } 880 }
826 881
827 882
828 FunctionLiteral* Parser::ParseProgram(Isolate* isolate, CompilationInfo* info) { 883 FunctionLiteral* Parser::ParseProgram(Isolate* isolate, ParseInfo* info) {
829 // TODO(bmeurer): We temporarily need to pass allow_nesting = true here, 884 // TODO(bmeurer): We temporarily need to pass allow_nesting = true here,
830 // see comment for HistogramTimerScope class. 885 // see comment for HistogramTimerScope class.
831 886
832 // It's OK to use the Isolate & counters here, since this function is only 887 // It's OK to use the Isolate & counters here, since this function is only
833 // called in the main thread. 888 // called in the main thread.
834 DCHECK(parsing_on_main_thread_); 889 DCHECK(parsing_on_main_thread_);
835 890
836 HistogramTimerScope timer_scope(isolate->counters()->parse(), true); 891 HistogramTimerScope timer_scope(isolate->counters()->parse(), true);
837 Handle<String> source(String::cast(info->script()->source())); 892 Handle<String> source(String::cast(info->script()->source()));
838 isolate->counters()->total_parse_size()->Increment(source->length()); 893 isolate->counters()->total_parse_size()->Increment(source->length());
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
889 PrintF(" - took %0.3f ms]\n", ms); 944 PrintF(" - took %0.3f ms]\n", ms);
890 } 945 }
891 if (produce_cached_parse_data()) { 946 if (produce_cached_parse_data()) {
892 if (result != NULL) *info->cached_data() = recorder.GetScriptData(); 947 if (result != NULL) *info->cached_data() = recorder.GetScriptData();
893 log_ = NULL; 948 log_ = NULL;
894 } 949 }
895 return result; 950 return result;
896 } 951 }
897 952
898 953
899 FunctionLiteral* Parser::DoParseProgram(CompilationInfo* info, Scope** scope, 954 FunctionLiteral* Parser::DoParseProgram(ParseInfo* info, Scope** scope,
900 Scope** eval_scope) { 955 Scope** eval_scope) {
901 // Note that this function can be called from the main thread or from a 956 // Note that this function can be called from the main thread or from a
902 // background thread. We should not access anything Isolate / heap dependent 957 // background thread. We should not access anything Isolate / heap dependent
903 // via CompilationInfo, and also not pass it forward. 958 // via ParseInfo, and also not pass it forward.
904 DCHECK(scope_ == NULL); 959 DCHECK(scope_ == NULL);
905 DCHECK(target_stack_ == NULL); 960 DCHECK(target_stack_ == NULL);
906 961
907 FunctionLiteral* result = NULL; 962 FunctionLiteral* result = NULL;
908 { 963 {
909 *scope = NewScope(scope_, SCRIPT_SCOPE); 964 *scope = NewScope(scope_, SCRIPT_SCOPE);
910 info->SetScriptScope(*scope); 965 info->set_script_scope(*scope);
911 if (!info->context().is_null() && !info->context()->IsNativeContext()) { 966 if (!info->context().is_null() && !info->context()->IsNativeContext()) {
912 *scope = Scope::DeserializeScopeChain(info->isolate(), zone(), 967 *scope = Scope::DeserializeScopeChain(info->isolate(), zone(),
913 *info->context(), *scope); 968 *info->context(), *scope);
914 // The Scope is backed up by ScopeInfo (which is in the V8 heap); this 969 // The Scope is backed up by ScopeInfo (which is in the V8 heap); this
915 // means the Parser cannot operate independent of the V8 heap. Tell the 970 // means the Parser cannot operate independent of the V8 heap. Tell the
916 // string table to internalize strings and values right after they're 971 // string table to internalize strings and values right after they're
917 // created. This kind of parsing can only be done in the main thread. 972 // created. This kind of parsing can only be done in the main thread.
918 DCHECK(parsing_on_main_thread_); 973 DCHECK(parsing_on_main_thread_);
919 ast_value_factory()->Internalize(info->isolate()); 974 ast_value_factory()->Internalize(info->isolate());
920 } 975 }
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
985 } 1040 }
986 } 1041 }
987 1042
988 // Make sure the target stack is empty. 1043 // Make sure the target stack is empty.
989 DCHECK(target_stack_ == NULL); 1044 DCHECK(target_stack_ == NULL);
990 1045
991 return result; 1046 return result;
992 } 1047 }
993 1048
994 1049
995 FunctionLiteral* Parser::ParseLazy(Isolate* isolate, CompilationInfo* info) { 1050 FunctionLiteral* Parser::ParseLazy(Isolate* isolate, ParseInfo* info) {
996 // It's OK to use the Isolate & counters here, since this function is only 1051 // It's OK to use the Isolate & counters here, since this function is only
997 // called in the main thread. 1052 // called in the main thread.
998 DCHECK(parsing_on_main_thread_); 1053 DCHECK(parsing_on_main_thread_);
999 HistogramTimerScope timer_scope(isolate->counters()->parse_lazy()); 1054 HistogramTimerScope timer_scope(isolate->counters()->parse_lazy());
1000 Handle<String> source(String::cast(info->script()->source())); 1055 Handle<String> source(String::cast(info->script()->source()));
1001 isolate->counters()->total_parse_size()->Increment(source->length()); 1056 isolate->counters()->total_parse_size()->Increment(source->length());
1002 base::ElapsedTimer timer; 1057 base::ElapsedTimer timer;
1003 if (FLAG_trace_parse) { 1058 if (FLAG_trace_parse) {
1004 timer.Start(); 1059 timer.Start();
1005 } 1060 }
(...skipping 17 matching lines...) Expand all
1023 1078
1024 if (FLAG_trace_parse && result != NULL) { 1079 if (FLAG_trace_parse && result != NULL) {
1025 double ms = timer.Elapsed().InMillisecondsF(); 1080 double ms = timer.Elapsed().InMillisecondsF();
1026 SmartArrayPointer<char> name_chars = result->debug_name()->ToCString(); 1081 SmartArrayPointer<char> name_chars = result->debug_name()->ToCString();
1027 PrintF("[parsing function: %s - took %0.3f ms]\n", name_chars.get(), ms); 1082 PrintF("[parsing function: %s - took %0.3f ms]\n", name_chars.get(), ms);
1028 } 1083 }
1029 return result; 1084 return result;
1030 } 1085 }
1031 1086
1032 1087
1033 FunctionLiteral* Parser::ParseLazy(Isolate* isolate, CompilationInfo* info, 1088 FunctionLiteral* Parser::ParseLazy(Isolate* isolate, ParseInfo* info,
1034 Utf16CharacterStream* source) { 1089 Utf16CharacterStream* source) {
1035 Handle<SharedFunctionInfo> shared_info = info->shared_info(); 1090 Handle<SharedFunctionInfo> shared_info = info->shared_info();
1036 scanner_.Initialize(source); 1091 scanner_.Initialize(source);
1037 DCHECK(scope_ == NULL); 1092 DCHECK(scope_ == NULL);
1038 DCHECK(target_stack_ == NULL); 1093 DCHECK(target_stack_ == NULL);
1039 1094
1040 Handle<String> name(String::cast(shared_info->name())); 1095 Handle<String> name(String::cast(shared_info->name()));
1041 DCHECK(ast_value_factory()); 1096 DCHECK(ast_value_factory());
1042 fni_ = new (zone()) FuncNameInferrer(ast_value_factory(), zone()); 1097 fni_ = new (zone()) FuncNameInferrer(ast_value_factory(), zone());
1043 const AstRawString* raw_name = ast_value_factory()->GetString(name); 1098 const AstRawString* raw_name = ast_value_factory()->GetString(name);
1044 fni_->PushEnclosingName(raw_name); 1099 fni_->PushEnclosingName(raw_name);
1045 1100
1046 ParsingModeScope parsing_mode(this, PARSE_EAGERLY); 1101 ParsingModeScope parsing_mode(this, PARSE_EAGERLY);
1047 1102
1048 // Place holder for the result. 1103 // Place holder for the result.
1049 FunctionLiteral* result = NULL; 1104 FunctionLiteral* result = NULL;
1050 1105
1051 { 1106 {
1052 // Parse the function literal. 1107 // Parse the function literal.
1053 Scope* scope = NewScope(scope_, SCRIPT_SCOPE); 1108 Scope* scope = NewScope(scope_, SCRIPT_SCOPE);
1054 info->SetScriptScope(scope); 1109 info->set_script_scope(scope);
1055 if (!info->closure().is_null()) { 1110 if (!info->closure().is_null()) {
1056 // Ok to use Isolate here, since lazy function parsing is only done in the 1111 // Ok to use Isolate here, since lazy function parsing is only done in the
1057 // main thread. 1112 // main thread.
1058 DCHECK(parsing_on_main_thread_); 1113 DCHECK(parsing_on_main_thread_);
1059 scope = Scope::DeserializeScopeChain(isolate, zone(), 1114 scope = Scope::DeserializeScopeChain(isolate, zone(),
1060 info->closure()->context(), scope); 1115 info->closure()->context(), scope);
1061 } 1116 }
1062 original_scope_ = scope; 1117 original_scope_ = scope;
1063 AstNodeFactory function_factory(ast_value_factory()); 1118 AstNodeFactory function_factory(ast_value_factory());
1064 FunctionState function_state(&function_state_, &scope_, scope, 1119 FunctionState function_state(&function_state_, &scope_, scope,
(...skipping 4175 matching lines...) Expand 10 before | Expand all | Expand 10 after
5240 result->tree = tree; 5295 result->tree = tree;
5241 int capture_count = parser.captures_started(); 5296 int capture_count = parser.captures_started();
5242 result->simple = tree->IsAtom() && parser.simple() && capture_count == 0; 5297 result->simple = tree->IsAtom() && parser.simple() && capture_count == 0;
5243 result->contains_anchor = parser.contains_anchor(); 5298 result->contains_anchor = parser.contains_anchor();
5244 result->capture_count = capture_count; 5299 result->capture_count = capture_count;
5245 } 5300 }
5246 return !parser.failed(); 5301 return !parser.failed();
5247 } 5302 }
5248 5303
5249 5304
5250 bool Parser::ParseStatic(CompilationInfo* info, bool allow_lazy) { 5305 bool Parser::ParseStatic(ParseInfo* info, bool allow_lazy) {
5251 Parser parser(info, info->isolate()->stack_guard()->real_climit(), 5306 Parser parser(info);
5252 info->isolate()->heap()->HashSeed(),
5253 info->isolate()->unicode_cache());
5254 parser.set_allow_lazy(allow_lazy); 5307 parser.set_allow_lazy(allow_lazy);
5255 if (parser.Parse(info)) { 5308 if (parser.Parse(info)) {
5256 info->SetLanguageMode(info->function()->language_mode()); 5309 info->set_language_mode(info->function()->language_mode());
5257 return true; 5310 return true;
5258 } 5311 }
5259 return false; 5312 return false;
5260 } 5313 }
5261 5314
5262 5315
5263 bool Parser::Parse(CompilationInfo* info) { 5316 bool Parser::Parse(ParseInfo* info) {
5264 DCHECK(info->function() == NULL); 5317 DCHECK(info->function() == NULL);
5265 FunctionLiteral* result = NULL; 5318 FunctionLiteral* result = NULL;
5266 // Ok to use Isolate here; this function is only called in the main thread. 5319 // Ok to use Isolate here; this function is only called in the main thread.
5267 DCHECK(parsing_on_main_thread_); 5320 DCHECK(parsing_on_main_thread_);
5268 Isolate* isolate = info->isolate(); 5321 Isolate* isolate = info->isolate();
5269 pre_parse_timer_ = isolate->counters()->pre_parse(); 5322 pre_parse_timer_ = isolate->counters()->pre_parse();
5270 if (FLAG_trace_parse || allow_natives() || extension_ != NULL) { 5323 if (FLAG_trace_parse || allow_natives() || extension_ != NULL) {
5271 // If intrinsics are allowed, the Parser cannot operate independent of the 5324 // If intrinsics are allowed, the Parser cannot operate independent of the
5272 // V8 heap because of Runtime. Tell the string table to internalize strings 5325 // V8 heap because of Runtime. Tell the string table to internalize strings
5273 // and values right after they're created. 5326 // and values right after they're created.
5274 ast_value_factory()->Internalize(isolate); 5327 ast_value_factory()->Internalize(isolate);
5275 } 5328 }
5276 5329
5277 if (info->is_lazy()) { 5330 if (info->is_lazy()) {
5278 DCHECK(!info->is_eval()); 5331 DCHECK(!info->is_eval());
5279 if (info->shared_info()->is_function()) { 5332 if (info->shared_info()->is_function()) {
5280 result = ParseLazy(isolate, info); 5333 result = ParseLazy(isolate, info);
5281 } else { 5334 } else {
5282 result = ParseProgram(isolate, info); 5335 result = ParseProgram(isolate, info);
5283 } 5336 }
5284 } else { 5337 } else {
5285 SetCachedData(info); 5338 SetCachedData(info);
5286 result = ParseProgram(isolate, info); 5339 result = ParseProgram(isolate, info);
5287 } 5340 }
5288 info->SetFunction(result); 5341 info->set_literal(result);
5289 5342
5290 Internalize(isolate, info->script(), result == NULL); 5343 Internalize(isolate, info->script(), result == NULL);
5291 DCHECK(ast_value_factory()->IsInternalized()); 5344 DCHECK(ast_value_factory()->IsInternalized());
5292 return (result != NULL); 5345 return (result != NULL);
5293 } 5346 }
5294 5347
5295 5348
5296 void Parser::ParseOnBackground(CompilationInfo* info) { 5349 void Parser::ParseOnBackground(ParseInfo* info) {
5297 parsing_on_main_thread_ = false; 5350 parsing_on_main_thread_ = false;
5298 5351
5299 DCHECK(info->function() == NULL); 5352 DCHECK(info->function() == NULL);
5300 FunctionLiteral* result = NULL; 5353 FunctionLiteral* result = NULL;
5301 fni_ = new (zone()) FuncNameInferrer(ast_value_factory(), zone()); 5354 fni_ = new (zone()) FuncNameInferrer(ast_value_factory(), zone());
5302 5355
5303 CompleteParserRecorder recorder; 5356 CompleteParserRecorder recorder;
5304 if (produce_cached_parse_data()) log_ = &recorder; 5357 if (produce_cached_parse_data()) log_ = &recorder;
5305 5358
5306 DCHECK(info->source_stream() != NULL); 5359 DCHECK(info->source_stream() != NULL);
(...skipping 10 matching lines...) Expand all
5317 // scopes) and set their end position after we know the script length. 5370 // scopes) and set their end position after we know the script length.
5318 Scope* top_scope = NULL; 5371 Scope* top_scope = NULL;
5319 Scope* eval_scope = NULL; 5372 Scope* eval_scope = NULL;
5320 result = DoParseProgram(info, &top_scope, &eval_scope); 5373 result = DoParseProgram(info, &top_scope, &eval_scope);
5321 5374
5322 top_scope->set_end_position(scanner()->location().end_pos); 5375 top_scope->set_end_position(scanner()->location().end_pos);
5323 if (eval_scope != NULL) { 5376 if (eval_scope != NULL) {
5324 eval_scope->set_end_position(scanner()->location().end_pos); 5377 eval_scope->set_end_position(scanner()->location().end_pos);
5325 } 5378 }
5326 5379
5327 info->SetFunction(result); 5380 info->set_literal(result);
5328 5381
5329 // We cannot internalize on a background thread; a foreground task will take 5382 // We cannot internalize on a background thread; a foreground task will take
5330 // care of calling Parser::Internalize just before compilation. 5383 // care of calling Parser::Internalize just before compilation.
5331 5384
5332 if (produce_cached_parse_data()) { 5385 if (produce_cached_parse_data()) {
5333 if (result != NULL) *info->cached_data() = recorder.GetScriptData(); 5386 if (result != NULL) *info->cached_data() = recorder.GetScriptData();
5334 log_ = NULL; 5387 log_ = NULL;
5335 } 5388 }
5336 } 5389 }
5337 5390
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
5450 } else { 5503 } else {
5451 const uc16* data = reinterpret_cast<const uc16*>(raw_string->raw_data()); 5504 const uc16* data = reinterpret_cast<const uc16*>(raw_string->raw_data());
5452 running_hash = StringHasher::ComputeRunningHash(running_hash, data, 5505 running_hash = StringHasher::ComputeRunningHash(running_hash, data,
5453 raw_string->length()); 5506 raw_string->length());
5454 } 5507 }
5455 } 5508 }
5456 5509
5457 return running_hash; 5510 return running_hash;
5458 } 5511 }
5459 } } // namespace v8::internal 5512 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698