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

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

Issue 2645613008: Revert of [Parse] ParseInfo owns the parsing Zone. (Closed)
Patch Set: Created 3 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/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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 void CompilerDispatcherJob::PrepareToParseOnMainThread() { 98 void CompilerDispatcherJob::PrepareToParseOnMainThread() {
99 DCHECK(ThreadId::Current().Equals(isolate_->thread_id())); 99 DCHECK(ThreadId::Current().Equals(isolate_->thread_id()));
100 DCHECK(status() == CompileJobStatus::kInitial); 100 DCHECK(status() == CompileJobStatus::kInitial);
101 COMPILER_DISPATCHER_TRACE_SCOPE(tracer_, kPrepareToParse); 101 COMPILER_DISPATCHER_TRACE_SCOPE(tracer_, kPrepareToParse);
102 if (trace_compiler_dispatcher_jobs_) { 102 if (trace_compiler_dispatcher_jobs_) {
103 PrintF("CompilerDispatcherJob[%p]: Preparing to parse\n", 103 PrintF("CompilerDispatcherJob[%p]: Preparing to parse\n",
104 static_cast<void*>(this)); 104 static_cast<void*>(this));
105 } 105 }
106 HandleScope scope(isolate_); 106 HandleScope scope(isolate_);
107 unicode_cache_.reset(new UnicodeCache()); 107 unicode_cache_.reset(new UnicodeCache());
108 zone_.reset(new Zone(isolate_->allocator(), ZONE_NAME));
108 Handle<Script> script(Script::cast(shared_->script()), isolate_); 109 Handle<Script> script(Script::cast(shared_->script()), isolate_);
109 DCHECK(script->type() != Script::TYPE_NATIVE); 110 DCHECK(script->type() != Script::TYPE_NATIVE);
110 111
111 Handle<String> source(String::cast(script->source()), isolate_); 112 Handle<String> source(String::cast(script->source()), isolate_);
112 parse_info_.reset(new ParseInfo(isolate_->allocator()));
113 if (source->IsExternalTwoByteString() || source->IsExternalOneByteString()) { 113 if (source->IsExternalTwoByteString() || source->IsExternalOneByteString()) {
114 character_stream_.reset(ScannerStream::For( 114 character_stream_.reset(ScannerStream::For(
115 source, shared_->start_position(), shared_->end_position())); 115 source, shared_->start_position(), shared_->end_position()));
116 } else { 116 } else {
117 source = String::Flatten(source); 117 source = String::Flatten(source);
118 const void* data; 118 const void* data;
119 int offset = 0; 119 int offset = 0;
120 int length = source->length(); 120 int length = source->length();
121 121
122 // Objects in lo_space don't move, so we can just read the contents from 122 // Objects in lo_space don't move, so we can just read the contents from
(...skipping 10 matching lines...) Expand all
133 content.IsOneByte() 133 content.IsOneByte()
134 ? reinterpret_cast<const void*>(content.ToOneByteVector().start()) 134 ? reinterpret_cast<const void*>(content.ToOneByteVector().start())
135 : reinterpret_cast<const void*>(content.ToUC16Vector().start()); 135 : reinterpret_cast<const void*>(content.ToUC16Vector().start());
136 } else { 136 } else {
137 // Otherwise, create a copy of the part of the string we'll parse in the 137 // Otherwise, create a copy of the part of the string we'll parse in the
138 // zone. 138 // zone.
139 length = (shared_->end_position() - shared_->start_position()); 139 length = (shared_->end_position() - shared_->start_position());
140 offset = shared_->start_position(); 140 offset = shared_->start_position();
141 141
142 int byte_len = length * (source->IsOneByteRepresentation() ? 1 : 2); 142 int byte_len = length * (source->IsOneByteRepresentation() ? 1 : 2);
143 data = parse_info_->zone()->New(byte_len); 143 data = zone_->New(byte_len);
144 144
145 DisallowHeapAllocation no_allocation; 145 DisallowHeapAllocation no_allocation;
146 String::FlatContent content = source->GetFlatContent(); 146 String::FlatContent content = source->GetFlatContent();
147 DCHECK(content.IsFlat()); 147 DCHECK(content.IsFlat());
148 if (content.IsOneByte()) { 148 if (content.IsOneByte()) {
149 MemCopy(const_cast<void*>(data), 149 MemCopy(const_cast<void*>(data),
150 &content.ToOneByteVector().at(shared_->start_position()), 150 &content.ToOneByteVector().at(shared_->start_position()),
151 byte_len); 151 byte_len);
152 } else { 152 } else {
153 MemCopy(const_cast<void*>(data), 153 MemCopy(const_cast<void*>(data),
(...skipping 17 matching lines...) Expand all
171 ->NewExternalStringFromTwoByte(resource) 171 ->NewExternalStringFromTwoByte(resource)
172 .ToHandleChecked(); 172 .ToHandleChecked();
173 } 173 }
174 wrapper_ = 174 wrapper_ =
175 Handle<String>::cast(isolate_->global_handles()->Create(*wrapper)); 175 Handle<String>::cast(isolate_->global_handles()->Create(*wrapper));
176 176
177 character_stream_.reset( 177 character_stream_.reset(
178 ScannerStream::For(wrapper_, shared_->start_position() - offset, 178 ScannerStream::For(wrapper_, shared_->start_position() - offset,
179 shared_->end_position() - offset)); 179 shared_->end_position() - offset));
180 } 180 }
181 parse_info_.reset(new ParseInfo(zone_.get()));
181 parse_info_->set_isolate(isolate_); 182 parse_info_->set_isolate(isolate_);
182 parse_info_->set_character_stream(character_stream_.get()); 183 parse_info_->set_character_stream(character_stream_.get());
183 parse_info_->set_hash_seed(isolate_->heap()->HashSeed()); 184 parse_info_->set_hash_seed(isolate_->heap()->HashSeed());
184 parse_info_->set_is_named_expression(shared_->is_named_expression()); 185 parse_info_->set_is_named_expression(shared_->is_named_expression());
185 parse_info_->set_compiler_hints(shared_->compiler_hints()); 186 parse_info_->set_compiler_hints(shared_->compiler_hints());
186 parse_info_->set_start_position(shared_->start_position()); 187 parse_info_->set_start_position(shared_->start_position());
187 parse_info_->set_end_position(shared_->end_position()); 188 parse_info_->set_end_position(shared_->end_position());
188 parse_info_->set_unicode_cache(unicode_cache_.get()); 189 parse_info_->set_unicode_cache(unicode_cache_.get());
189 parse_info_->set_language_mode(shared_->language_mode()); 190 parse_info_->set_language_mode(shared_->language_mode());
190 parse_info_->set_function_literal_id(shared_->function_literal_id()); 191 parse_info_->set_function_literal_id(shared_->function_literal_id());
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 static_cast<void*>(this)); 344 static_cast<void*>(this));
344 } 345 }
345 346
346 if (compile_job_->state() == CompilationJob::State::kFailed || 347 if (compile_job_->state() == CompilationJob::State::kFailed ||
347 !Compiler::FinalizeCompilationJob(compile_job_.release())) { 348 !Compiler::FinalizeCompilationJob(compile_job_.release())) {
348 if (!isolate_->has_pending_exception()) isolate_->StackOverflow(); 349 if (!isolate_->has_pending_exception()) isolate_->StackOverflow();
349 status_ = CompileJobStatus::kFailed; 350 status_ = CompileJobStatus::kFailed;
350 return false; 351 return false;
351 } 352 }
352 353
354 zone_.reset();
353 parse_info_.reset(); 355 parse_info_.reset();
354 compile_info_.reset(); 356 compile_info_.reset();
355 compile_job_.reset(); 357 compile_job_.reset();
356 handles_from_parsing_.reset(); 358 handles_from_parsing_.reset();
357 359
358 status_ = CompileJobStatus::kDone; 360 status_ = CompileJobStatus::kDone;
359 return true; 361 return true;
360 } 362 }
361 363
362 void CompilerDispatcherJob::ResetOnMainThread() { 364 void CompilerDispatcherJob::ResetOnMainThread() {
363 DCHECK(ThreadId::Current().Equals(isolate_->thread_id())); 365 DCHECK(ThreadId::Current().Equals(isolate_->thread_id()));
364 366
365 if (trace_compiler_dispatcher_jobs_) { 367 if (trace_compiler_dispatcher_jobs_) {
366 PrintF("CompilerDispatcherJob[%p]: Resetting\n", static_cast<void*>(this)); 368 PrintF("CompilerDispatcherJob[%p]: Resetting\n", static_cast<void*>(this));
367 } 369 }
368 370
369 parser_.reset(); 371 parser_.reset();
370 unicode_cache_.reset(); 372 unicode_cache_.reset();
371 character_stream_.reset(); 373 character_stream_.reset();
372 parse_info_.reset(); 374 parse_info_.reset();
373 handles_from_parsing_.reset(); 375 handles_from_parsing_.reset();
374 compile_info_.reset(); 376 compile_info_.reset();
375 compile_job_.reset(); 377 compile_job_.reset();
378 zone_.reset();
376 379
377 if (!source_.is_null()) { 380 if (!source_.is_null()) {
378 i::GlobalHandles::Destroy(Handle<Object>::cast(source_).location()); 381 i::GlobalHandles::Destroy(Handle<Object>::cast(source_).location());
379 source_ = Handle<String>::null(); 382 source_ = Handle<String>::null();
380 } 383 }
381 if (!wrapper_.is_null()) { 384 if (!wrapper_.is_null()) {
382 i::GlobalHandles::Destroy(Handle<Object>::cast(wrapper_).location()); 385 i::GlobalHandles::Destroy(Handle<Object>::cast(wrapper_).location());
383 wrapper_ = Handle<String>::null(); 386 wrapper_ = Handle<String>::null();
384 } 387 }
385 388
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 return 0.0; 420 return 0.0;
418 } 421 }
419 422
420 void CompilerDispatcherJob::ShortPrint() { 423 void CompilerDispatcherJob::ShortPrint() {
421 DCHECK(ThreadId::Current().Equals(isolate_->thread_id())); 424 DCHECK(ThreadId::Current().Equals(isolate_->thread_id()));
422 shared_->ShortPrint(); 425 shared_->ShortPrint();
423 } 426 }
424 427
425 } // namespace internal 428 } // namespace internal
426 } // namespace v8 429 } // 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