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

Side by Side Diff: src/compiler-dispatcher/compiler-dispatcher-job.cc

Issue 2683733002: Revert of Reland: [Parse] ParseInfo owns the parsing Zone. (Closed)
Patch Set: Created 3 years, 10 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/compiler-dispatcher/compiler-dispatcher-job.h ('k') | src/compiler/js-inlining.cc » ('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 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 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/compiler-dispatcher/compiler-dispatcher-job.h" 5 #include "src/compiler-dispatcher/compiler-dispatcher-job.h"
6 6
7 #include "src/assert-scope.h" 7 #include "src/assert-scope.h"
8 #include "src/compilation-info.h" 8 #include "src/compilation-info.h"
9 #include "src/compiler-dispatcher/compiler-dispatcher-tracer.h" 9 #include "src/compiler-dispatcher/compiler-dispatcher-tracer.h"
10 #include "src/compiler.h" 10 #include "src/compiler.h"
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 CompilerDispatcherTracer* tracer, 88 CompilerDispatcherTracer* tracer,
89 Handle<SharedFunctionInfo> shared, 89 Handle<SharedFunctionInfo> shared,
90 FunctionLiteral* literal, 90 FunctionLiteral* literal,
91 size_t max_stack_size) 91 size_t max_stack_size)
92 : status_(CompileJobStatus::kAnalyzed), 92 : status_(CompileJobStatus::kAnalyzed),
93 isolate_(isolate), 93 isolate_(isolate),
94 tracer_(tracer), 94 tracer_(tracer),
95 shared_(Handle<SharedFunctionInfo>::cast( 95 shared_(Handle<SharedFunctionInfo>::cast(
96 isolate_->global_handles()->Create(*shared))), 96 isolate_->global_handles()->Create(*shared))),
97 max_stack_size_(max_stack_size), 97 max_stack_size_(max_stack_size),
98 parse_info_( 98 zone_(new Zone(isolate->allocator(), ZONE_NAME)),
99 new ParseInfo(Handle<Script>(Script::cast(shared->script())))), 99 parse_info_(new ParseInfo(
100 zone_.get(), Handle<Script>(Script::cast(shared->script())))),
100 compile_info_( 101 compile_info_(
101 new CompilationInfo(parse_info_.get(), Handle<JSFunction>::null())), 102 new CompilationInfo(parse_info_.get(), Handle<JSFunction>::null())),
102 trace_compiler_dispatcher_jobs_(FLAG_trace_compiler_dispatcher_jobs) { 103 trace_compiler_dispatcher_jobs_(FLAG_trace_compiler_dispatcher_jobs) {
103 parse_info_->set_literal(literal); 104 parse_info_->set_literal(literal);
104 parse_info_->set_shared_info(shared); 105 parse_info_->set_shared_info(shared);
105 parse_info_->set_function_literal_id(shared->function_literal_id()); 106 parse_info_->set_function_literal_id(shared->function_literal_id());
106 parse_info_->set_language_mode(literal->scope()->language_mode()); 107 parse_info_->set_language_mode(literal->scope()->language_mode());
107 if (trace_compiler_dispatcher_jobs_) { 108 if (trace_compiler_dispatcher_jobs_) {
108 PrintF("CompilerDispatcherJob[%p] created for ", static_cast<void*>(this)); 109 PrintF("CompilerDispatcherJob[%p] created for ", static_cast<void*>(this));
109 shared_->ShortPrint(); 110 shared_->ShortPrint();
(...skipping 16 matching lines...) Expand all
126 void CompilerDispatcherJob::PrepareToParseOnMainThread() { 127 void CompilerDispatcherJob::PrepareToParseOnMainThread() {
127 DCHECK(ThreadId::Current().Equals(isolate_->thread_id())); 128 DCHECK(ThreadId::Current().Equals(isolate_->thread_id()));
128 DCHECK(status() == CompileJobStatus::kInitial); 129 DCHECK(status() == CompileJobStatus::kInitial);
129 COMPILER_DISPATCHER_TRACE_SCOPE(tracer_, kPrepareToParse); 130 COMPILER_DISPATCHER_TRACE_SCOPE(tracer_, kPrepareToParse);
130 if (trace_compiler_dispatcher_jobs_) { 131 if (trace_compiler_dispatcher_jobs_) {
131 PrintF("CompilerDispatcherJob[%p]: Preparing to parse\n", 132 PrintF("CompilerDispatcherJob[%p]: Preparing to parse\n",
132 static_cast<void*>(this)); 133 static_cast<void*>(this));
133 } 134 }
134 HandleScope scope(isolate_); 135 HandleScope scope(isolate_);
135 unicode_cache_.reset(new UnicodeCache()); 136 unicode_cache_.reset(new UnicodeCache());
137 zone_.reset(new Zone(isolate_->allocator(), ZONE_NAME));
136 Handle<Script> script(Script::cast(shared_->script()), isolate_); 138 Handle<Script> script(Script::cast(shared_->script()), isolate_);
137 DCHECK(script->type() != Script::TYPE_NATIVE); 139 DCHECK(script->type() != Script::TYPE_NATIVE);
138 140
139 Handle<String> source(String::cast(script->source()), isolate_); 141 Handle<String> source(String::cast(script->source()), isolate_);
140 parse_info_.reset(new ParseInfo(isolate_->allocator()));
141 if (source->IsExternalTwoByteString() || source->IsExternalOneByteString()) { 142 if (source->IsExternalTwoByteString() || source->IsExternalOneByteString()) {
142 character_stream_.reset(ScannerStream::For( 143 character_stream_.reset(ScannerStream::For(
143 source, shared_->start_position(), shared_->end_position())); 144 source, shared_->start_position(), shared_->end_position()));
144 } else { 145 } else {
145 source = String::Flatten(source); 146 source = String::Flatten(source);
146 const void* data; 147 const void* data;
147 int offset = 0; 148 int offset = 0;
148 int length = source->length(); 149 int length = source->length();
149 150
150 // Objects in lo_space don't move, so we can just read the contents from 151 // Objects in lo_space don't move, so we can just read the contents from
(...skipping 10 matching lines...) Expand all
161 content.IsOneByte() 162 content.IsOneByte()
162 ? reinterpret_cast<const void*>(content.ToOneByteVector().start()) 163 ? reinterpret_cast<const void*>(content.ToOneByteVector().start())
163 : reinterpret_cast<const void*>(content.ToUC16Vector().start()); 164 : reinterpret_cast<const void*>(content.ToUC16Vector().start());
164 } else { 165 } else {
165 // Otherwise, create a copy of the part of the string we'll parse in the 166 // Otherwise, create a copy of the part of the string we'll parse in the
166 // zone. 167 // zone.
167 length = (shared_->end_position() - shared_->start_position()); 168 length = (shared_->end_position() - shared_->start_position());
168 offset = shared_->start_position(); 169 offset = shared_->start_position();
169 170
170 int byte_len = length * (source->IsOneByteRepresentation() ? 1 : 2); 171 int byte_len = length * (source->IsOneByteRepresentation() ? 1 : 2);
171 data = parse_info_->zone()->New(byte_len); 172 data = zone_->New(byte_len);
172 173
173 DisallowHeapAllocation no_allocation; 174 DisallowHeapAllocation no_allocation;
174 String::FlatContent content = source->GetFlatContent(); 175 String::FlatContent content = source->GetFlatContent();
175 DCHECK(content.IsFlat()); 176 DCHECK(content.IsFlat());
176 if (content.IsOneByte()) { 177 if (content.IsOneByte()) {
177 MemCopy(const_cast<void*>(data), 178 MemCopy(const_cast<void*>(data),
178 &content.ToOneByteVector().at(shared_->start_position()), 179 &content.ToOneByteVector().at(shared_->start_position()),
179 byte_len); 180 byte_len);
180 } else { 181 } else {
181 MemCopy(const_cast<void*>(data), 182 MemCopy(const_cast<void*>(data),
(...skipping 17 matching lines...) Expand all
199 ->NewExternalStringFromTwoByte(resource) 200 ->NewExternalStringFromTwoByte(resource)
200 .ToHandleChecked(); 201 .ToHandleChecked();
201 } 202 }
202 wrapper_ = 203 wrapper_ =
203 Handle<String>::cast(isolate_->global_handles()->Create(*wrapper)); 204 Handle<String>::cast(isolate_->global_handles()->Create(*wrapper));
204 205
205 character_stream_.reset( 206 character_stream_.reset(
206 ScannerStream::For(wrapper_, shared_->start_position() - offset, 207 ScannerStream::For(wrapper_, shared_->start_position() - offset,
207 shared_->end_position() - offset)); 208 shared_->end_position() - offset));
208 } 209 }
210 parse_info_.reset(new ParseInfo(zone_.get()));
209 parse_info_->set_isolate(isolate_); 211 parse_info_->set_isolate(isolate_);
210 parse_info_->set_character_stream(character_stream_.get()); 212 parse_info_->set_character_stream(character_stream_.get());
211 parse_info_->set_hash_seed(isolate_->heap()->HashSeed()); 213 parse_info_->set_hash_seed(isolate_->heap()->HashSeed());
212 parse_info_->set_is_named_expression(shared_->is_named_expression()); 214 parse_info_->set_is_named_expression(shared_->is_named_expression());
213 parse_info_->set_compiler_hints(shared_->compiler_hints()); 215 parse_info_->set_compiler_hints(shared_->compiler_hints());
214 parse_info_->set_start_position(shared_->start_position()); 216 parse_info_->set_start_position(shared_->start_position());
215 parse_info_->set_end_position(shared_->end_position()); 217 parse_info_->set_end_position(shared_->end_position());
216 parse_info_->set_unicode_cache(unicode_cache_.get()); 218 parse_info_->set_unicode_cache(unicode_cache_.get());
217 parse_info_->set_language_mode(shared_->language_mode()); 219 parse_info_->set_language_mode(shared_->language_mode());
218 parse_info_->set_function_literal_id(shared_->function_literal_id()); 220 parse_info_->set_function_literal_id(shared_->function_literal_id());
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 static_cast<void*>(this)); 386 static_cast<void*>(this));
385 } 387 }
386 388
387 if (compile_job_->state() == CompilationJob::State::kFailed || 389 if (compile_job_->state() == CompilationJob::State::kFailed ||
388 !Compiler::FinalizeCompilationJob(compile_job_.release())) { 390 !Compiler::FinalizeCompilationJob(compile_job_.release())) {
389 if (!isolate_->has_pending_exception()) isolate_->StackOverflow(); 391 if (!isolate_->has_pending_exception()) isolate_->StackOverflow();
390 status_ = CompileJobStatus::kFailed; 392 status_ = CompileJobStatus::kFailed;
391 return false; 393 return false;
392 } 394 }
393 395
396 zone_.reset();
394 compile_job_.reset(); 397 compile_job_.reset();
395 compile_info_.reset(); 398 compile_info_.reset();
396 handles_from_parsing_.reset(); 399 handles_from_parsing_.reset();
397 parse_info_.reset(); 400 parse_info_.reset();
398 401
399 status_ = CompileJobStatus::kDone; 402 status_ = CompileJobStatus::kDone;
400 return true; 403 return true;
401 } 404 }
402 405
403 void CompilerDispatcherJob::ResetOnMainThread() { 406 void CompilerDispatcherJob::ResetOnMainThread() {
404 DCHECK(ThreadId::Current().Equals(isolate_->thread_id())); 407 DCHECK(ThreadId::Current().Equals(isolate_->thread_id()));
405 408
406 if (trace_compiler_dispatcher_jobs_) { 409 if (trace_compiler_dispatcher_jobs_) {
407 PrintF("CompilerDispatcherJob[%p]: Resetting\n", static_cast<void*>(this)); 410 PrintF("CompilerDispatcherJob[%p]: Resetting\n", static_cast<void*>(this));
408 } 411 }
409 412
410 compile_job_.reset(); 413 compile_job_.reset();
411 compile_info_.reset(); 414 compile_info_.reset();
412 parser_.reset(); 415 parser_.reset();
413 unicode_cache_.reset(); 416 unicode_cache_.reset();
414 character_stream_.reset(); 417 character_stream_.reset();
415 handles_from_parsing_.reset(); 418 handles_from_parsing_.reset();
416 parse_info_.reset(); 419 parse_info_.reset();
420 zone_.reset();
417 421
418 if (!source_.is_null()) { 422 if (!source_.is_null()) {
419 i::GlobalHandles::Destroy(Handle<Object>::cast(source_).location()); 423 i::GlobalHandles::Destroy(Handle<Object>::cast(source_).location());
420 source_ = Handle<String>::null(); 424 source_ = Handle<String>::null();
421 } 425 }
422 if (!wrapper_.is_null()) { 426 if (!wrapper_.is_null()) {
423 i::GlobalHandles::Destroy(Handle<Object>::cast(wrapper_).location()); 427 i::GlobalHandles::Destroy(Handle<Object>::cast(wrapper_).location());
424 wrapper_ = Handle<String>::null(); 428 wrapper_ = Handle<String>::null();
425 } 429 }
426 430
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 return 0.0; 465 return 0.0;
462 } 466 }
463 467
464 void CompilerDispatcherJob::ShortPrint() { 468 void CompilerDispatcherJob::ShortPrint() {
465 DCHECK(ThreadId::Current().Equals(isolate_->thread_id())); 469 DCHECK(ThreadId::Current().Equals(isolate_->thread_id()));
466 shared_->ShortPrint(); 470 shared_->ShortPrint();
467 } 471 }
468 472
469 } // namespace internal 473 } // namespace internal
470 } // namespace v8 474 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler-dispatcher/compiler-dispatcher-job.h ('k') | src/compiler/js-inlining.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698