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

Side by Side Diff: src/parsing/parser.cc

Issue 2211393003: Revert of Hook up compiler dispatcher jobs to lazy parser. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 4 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/parsing/parser.h" 5 #include "src/parsing/parser.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "src/api.h" 9 #include "src/api.h"
10 #include "src/ast/ast.h" 10 #include "src/ast/ast.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 script_scope_(nullptr), 51 script_scope_(nullptr),
52 unicode_cache_(nullptr), 52 unicode_cache_(nullptr),
53 stack_limit_(0), 53 stack_limit_(0),
54 hash_seed_(0), 54 hash_seed_(0),
55 compiler_hints_(0), 55 compiler_hints_(0),
56 start_position_(0), 56 start_position_(0),
57 end_position_(0), 57 end_position_(0),
58 isolate_(nullptr), 58 isolate_(nullptr),
59 cached_data_(nullptr), 59 cached_data_(nullptr),
60 ast_value_factory_(nullptr), 60 ast_value_factory_(nullptr),
61 function_name_(nullptr),
62 literal_(nullptr) {} 61 literal_(nullptr) {}
63 62
64 ParseInfo::ParseInfo(Zone* zone, Handle<JSFunction> function) 63 ParseInfo::ParseInfo(Zone* zone, Handle<JSFunction> function)
65 : ParseInfo(zone, Handle<SharedFunctionInfo>(function->shared())) { 64 : ParseInfo(zone, Handle<SharedFunctionInfo>(function->shared())) {
66 set_context(Handle<Context>(function->context())); 65 set_context(Handle<Context>(function->context()));
67 } 66 }
68 67
69 68
70 ParseInfo::ParseInfo(Zone* zone, Handle<SharedFunctionInfo> shared) 69 ParseInfo::ParseInfo(Zone* zone, Handle<SharedFunctionInfo> shared)
71 : ParseInfo(zone) { 70 : ParseInfo(zone) {
(...skipping 1042 matching lines...) Expand 10 before | Expand all | Expand 10 after
1114 shared_info->start_position(), shared_info->end_position())); 1113 shared_info->start_position(), shared_info->end_position()));
1115 } else if (source->IsExternalOneByteString()) { 1114 } else if (source->IsExternalOneByteString()) {
1116 stream.reset(new ExternalOneByteStringUtf16CharacterStream( 1115 stream.reset(new ExternalOneByteStringUtf16CharacterStream(
1117 Handle<ExternalOneByteString>::cast(source), 1116 Handle<ExternalOneByteString>::cast(source),
1118 shared_info->start_position(), shared_info->end_position())); 1117 shared_info->start_position(), shared_info->end_position()));
1119 } else { 1118 } else {
1120 stream.reset(new GenericStringUtf16CharacterStream( 1119 stream.reset(new GenericStringUtf16CharacterStream(
1121 source, shared_info->start_position(), shared_info->end_position())); 1120 source, shared_info->start_position(), shared_info->end_position()));
1122 } 1121 }
1123 Handle<String> name(String::cast(shared_info->name())); 1122 Handle<String> name(String::cast(shared_info->name()));
1124 result = 1123 result = DoParseLazy(isolate, info, ast_value_factory()->GetString(name),
1125 DoParseLazy(info, ast_value_factory()->GetString(name), stream.get()); 1124 stream.get());
1126 if (result != nullptr) { 1125 if (result != nullptr) {
1127 Handle<String> inferred_name(shared_info->inferred_name()); 1126 Handle<String> inferred_name(shared_info->inferred_name());
1128 result->set_inferred_name(inferred_name); 1127 result->set_inferred_name(inferred_name);
1129 } 1128 }
1130 } 1129 }
1131 1130
1132 if (FLAG_trace_parse && result != NULL) { 1131 if (FLAG_trace_parse && result != NULL) {
1133 double ms = timer.Elapsed().InMillisecondsF(); 1132 double ms = timer.Elapsed().InMillisecondsF();
1134 std::unique_ptr<char[]> name_chars = result->debug_name()->ToCString(); 1133 std::unique_ptr<char[]> name_chars = result->debug_name()->ToCString();
1135 PrintF("[parsing function: %s - took %0.3f ms]\n", name_chars.get(), ms); 1134 PrintF("[parsing function: %s - took %0.3f ms]\n", name_chars.get(), ms);
1136 } 1135 }
1137 return result; 1136 return result;
1138 } 1137 }
1139 1138
1140 static FunctionLiteral::FunctionType ComputeFunctionType(ParseInfo* info) { 1139 static FunctionLiteral::FunctionType ComputeFunctionType(ParseInfo* info) {
1141 if (info->is_declaration()) { 1140 if (info->is_declaration()) {
1142 return FunctionLiteral::kDeclaration; 1141 return FunctionLiteral::kDeclaration;
1143 } else if (info->is_named_expression()) { 1142 } else if (info->is_named_expression()) {
1144 return FunctionLiteral::kNamedExpression; 1143 return FunctionLiteral::kNamedExpression;
1145 } else if (IsConciseMethod(info->function_kind()) || 1144 } else if (IsConciseMethod(info->function_kind()) ||
1146 IsAccessorFunction(info->function_kind())) { 1145 IsAccessorFunction(info->function_kind())) {
1147 return FunctionLiteral::kAccessorOrMethod; 1146 return FunctionLiteral::kAccessorOrMethod;
1148 } 1147 }
1149 return FunctionLiteral::kAnonymousExpression; 1148 return FunctionLiteral::kAnonymousExpression;
1150 } 1149 }
1151 1150
1152 FunctionLiteral* Parser::DoParseLazy(ParseInfo* info, 1151 FunctionLiteral* Parser::DoParseLazy(Isolate* isolate, ParseInfo* info,
1153 const AstRawString* raw_name, 1152 const AstRawString* raw_name,
1154 Utf16CharacterStream* source) { 1153 Utf16CharacterStream* source) {
1155 scanner_.Initialize(source); 1154 scanner_.Initialize(source);
1156 DCHECK_NULL(scope_state_); 1155 DCHECK_NULL(scope_state_);
1157 DCHECK_NULL(target_stack_); 1156 DCHECK_NULL(target_stack_);
1158 1157
1159 DCHECK(ast_value_factory()); 1158 DCHECK(ast_value_factory());
1160 fni_ = new (zone()) FuncNameInferrer(ast_value_factory(), zone()); 1159 fni_ = new (zone()) FuncNameInferrer(ast_value_factory(), zone());
1161 fni_->PushEnclosingName(raw_name); 1160 fni_->PushEnclosingName(raw_name);
1162 1161
(...skipping 4351 matching lines...) Expand 10 before | Expand all | Expand 10 after
5514 DCHECK(ast_value_factory()->IsInternalized()); 5513 DCHECK(ast_value_factory()->IsInternalized());
5515 return (result != NULL); 5514 return (result != NULL);
5516 } 5515 }
5517 5516
5518 5517
5519 void Parser::ParseOnBackground(ParseInfo* info) { 5518 void Parser::ParseOnBackground(ParseInfo* info) {
5520 parsing_on_main_thread_ = false; 5519 parsing_on_main_thread_ = false;
5521 5520
5522 DCHECK(info->literal() == NULL); 5521 DCHECK(info->literal() == NULL);
5523 FunctionLiteral* result = NULL; 5522 FunctionLiteral* result = NULL;
5523 fni_ = new (zone()) FuncNameInferrer(ast_value_factory(), zone());
5524 5524
5525 CompleteParserRecorder recorder; 5525 CompleteParserRecorder recorder;
5526 if (produce_cached_parse_data()) log_ = &recorder; 5526 if (produce_cached_parse_data()) log_ = &recorder;
5527 5527
5528 std::unique_ptr<Utf16CharacterStream> stream; 5528 std::unique_ptr<Utf16CharacterStream> stream;
5529 Utf16CharacterStream* stream_ptr; 5529 Utf16CharacterStream* stream_ptr;
5530 if (info->character_stream()) { 5530 if (info->character_stream()) {
5531 DCHECK(info->source_stream() == nullptr); 5531 DCHECK(info->source_stream() == nullptr);
5532 stream_ptr = info->character_stream(); 5532 stream_ptr = info->character_stream();
5533 } else { 5533 } else {
5534 DCHECK(info->character_stream() == nullptr); 5534 DCHECK(info->character_stream() == nullptr);
5535 stream.reset(new ExternalStreamingStream(info->source_stream(), 5535 stream.reset(new ExternalStreamingStream(info->source_stream(),
5536 info->source_stream_encoding())); 5536 info->source_stream_encoding()));
5537 stream_ptr = stream.get(); 5537 stream_ptr = stream.get();
5538 } 5538 }
5539 scanner_.Initialize(stream_ptr);
5539 DCHECK(info->context().is_null() || info->context()->IsNativeContext()); 5540 DCHECK(info->context().is_null() || info->context()->IsNativeContext());
5540 5541
5541 DCHECK(original_scope_); 5542 DCHECK(original_scope_);
5542 5543
5543 // When streaming, we don't know the length of the source until we have parsed 5544 // When streaming, we don't know the length of the source until we have parsed
5544 // it. The raw data can be UTF-8, so we wouldn't know the source length until 5545 // it. The raw data can be UTF-8, so we wouldn't know the source length until
5545 // we have decoded it anyway even if we knew the raw data length (which we 5546 // we have decoded it anyway even if we knew the raw data length (which we
5546 // don't). We work around this by storing all the scopes which need their end 5547 // don't). We work around this by storing all the scopes which need their end
5547 // position set at the end of the script (the top scope and possible eval 5548 // position set at the end of the script (the top scope and possible eval
5548 // scopes) and set their end position after we know the script length. 5549 // scopes) and set their end position after we know the script length.
5549 if (info->is_lazy()) { 5550 result = DoParseProgram(info);
5550 result = DoParseLazy(info, info->function_name(), stream_ptr);
5551 } else {
5552 fni_ = new (zone()) FuncNameInferrer(ast_value_factory(), zone());
5553 scanner_.Initialize(stream_ptr);
5554 result = DoParseProgram(info);
5555 }
5556 5551
5557 info->set_literal(result); 5552 info->set_literal(result);
5558 5553
5559 // We cannot internalize on a background thread; a foreground task will take 5554 // We cannot internalize on a background thread; a foreground task will take
5560 // care of calling Parser::Internalize just before compilation. 5555 // care of calling Parser::Internalize just before compilation.
5561 5556
5562 if (produce_cached_parse_data()) { 5557 if (produce_cached_parse_data()) {
5563 if (result != NULL) *info->cached_data() = recorder.GetScriptData(); 5558 if (result != NULL) *info->cached_data() = recorder.GetScriptData();
5564 log_ = NULL; 5559 log_ = NULL;
5565 } 5560 }
(...skipping 1598 matching lines...) Expand 10 before | Expand all | Expand 10 after
7164 node->Print(Isolate::Current()); 7159 node->Print(Isolate::Current());
7165 } 7160 }
7166 #endif // DEBUG 7161 #endif // DEBUG
7167 7162
7168 #undef CHECK_OK 7163 #undef CHECK_OK
7169 #undef CHECK_OK_VOID 7164 #undef CHECK_OK_VOID
7170 #undef CHECK_FAILED 7165 #undef CHECK_FAILED
7171 7166
7172 } // namespace internal 7167 } // namespace internal
7173 } // namespace v8 7168 } // namespace v8
OLDNEW
« no previous file with comments | « src/parsing/parser.h ('k') | test/unittests/compiler-dispatcher/compiler-dispatcher-job-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698