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

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

Issue 2318653002: [Interpreter] Localize the CanonicalHandleScope to parsing and renumbering. (Closed)
Patch Set: Rebase Created 4 years, 3 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.cc ('k') | no next file » | 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.h" 9 #include "src/compiler.h"
10 #include "src/global-handles.h" 10 #include "src/global-handles.h"
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 } 131 }
132 132
133 if (parse_info_->literal() == nullptr) { 133 if (parse_info_->literal() == nullptr) {
134 status_ = CompileJobStatus::kFailed; 134 status_ = CompileJobStatus::kFailed;
135 } else { 135 } else {
136 status_ = CompileJobStatus::kReadyToAnalyse; 136 status_ = CompileJobStatus::kReadyToAnalyse;
137 } 137 }
138 138
139 DeferredHandleScope scope(isolate_); 139 DeferredHandleScope scope(isolate_);
140 { 140 {
141 // Create a canonical handle scope before internalizing parsed values if
142 // compiling bytecode. This is required for off-thread bytecode generation.
143 std::unique_ptr<CanonicalHandleScope> canonical;
144 if (FLAG_ignition) canonical.reset(new CanonicalHandleScope(isolate_));
145
146 Handle<SharedFunctionInfo> shared(function_->shared(), isolate_); 141 Handle<SharedFunctionInfo> shared(function_->shared(), isolate_);
147 Handle<Script> script(Script::cast(shared->script()), isolate_); 142 Handle<Script> script(Script::cast(shared->script()), isolate_);
148 143
149 parse_info_->set_script(script); 144 parse_info_->set_script(script);
150 parse_info_->set_context(handle(function_->context(), isolate_)); 145 parse_info_->set_context(handle(function_->context(), isolate_));
151 parse_info_->set_shared_info(handle(function_->shared(), isolate_)); 146 parse_info_->set_shared_info(handle(function_->shared(), isolate_));
152 147
153 // Do the parsing tasks which need to be done on the main thread. This will 148 {
154 // also handle parse errors. 149 // Create a canonical handle scope if compiling ignition bytecode. This is
155 parser_->Internalize(isolate_, script, parse_info_->literal() == nullptr); 150 // required by the constant array builder to de-duplicate objects without
151 // dereferencing handles.
152 std::unique_ptr<CanonicalHandleScope> canonical;
153 if (FLAG_ignition) canonical.reset(new CanonicalHandleScope(isolate_));
154
155 // Do the parsing tasks which need to be done on the main thread. This
156 // will also handle parse errors.
157 parser_->Internalize(isolate_, script, parse_info_->literal() == nullptr);
158 }
156 parser_->HandleSourceURLComments(isolate_, script); 159 parser_->HandleSourceURLComments(isolate_, script);
157 160
158 parse_info_->set_character_stream(nullptr); 161 parse_info_->set_character_stream(nullptr);
159 parse_info_->set_unicode_cache(nullptr); 162 parse_info_->set_unicode_cache(nullptr);
160 parser_.reset(); 163 parser_.reset();
161 unicode_cache_.reset(); 164 unicode_cache_.reset();
162 character_stream_.reset(); 165 character_stream_.reset();
163 } 166 }
164 handles_from_parsing_.reset(scope.Detach()); 167 handles_from_parsing_.reset(scope.Detach());
165 168
166 return status_ != CompileJobStatus::kFailed; 169 return status_ != CompileJobStatus::kFailed;
167 } 170 }
168 171
169 bool CompilerDispatcherJob::PrepareToCompileOnMainThread() { 172 bool CompilerDispatcherJob::PrepareToCompileOnMainThread() {
170 DCHECK(ThreadId::Current().Equals(isolate_->thread_id())); 173 DCHECK(ThreadId::Current().Equals(isolate_->thread_id()));
171 DCHECK(status() == CompileJobStatus::kReadyToAnalyse); 174 DCHECK(status() == CompileJobStatus::kReadyToAnalyse);
172 175
173 compile_info_.reset(new CompilationInfo(parse_info_.get(), function_)); 176 compile_info_.reset(new CompilationInfo(parse_info_.get(), function_));
174 177
175 DeferredHandleScope scope(isolate_); 178 DeferredHandleScope scope(isolate_);
176 { 179 if (Compiler::Analyze(parse_info_.get())) {
177 // Create a canonical handle scope before ast numbering if compiling 180 compile_job_.reset(
178 // bytecode. This is required for off-thread bytecode generation. 181 Compiler::PrepareUnoptimizedCompilationJob(compile_info_.get()));
179 std::unique_ptr<CanonicalHandleScope> canonical;
180 if (FLAG_ignition) canonical.reset(new CanonicalHandleScope(isolate_));
181
182 if (Compiler::Analyze(parse_info_.get())) {
183 compile_job_.reset(
184 Compiler::PrepareUnoptimizedCompilationJob(compile_info_.get()));
185 }
186 } 182 }
187 compile_info_->set_deferred_handles(scope.Detach()); 183 compile_info_->set_deferred_handles(scope.Detach());
188 184
189 if (!compile_job_.get()) { 185 if (!compile_job_.get()) {
190 if (!isolate_->has_pending_exception()) isolate_->StackOverflow(); 186 if (!isolate_->has_pending_exception()) isolate_->StackOverflow();
191 status_ = CompileJobStatus::kFailed; 187 status_ = CompileJobStatus::kFailed;
192 return false; 188 return false;
193 } 189 }
194 190
195 can_compile_on_background_thread_ = 191 can_compile_on_background_thread_ =
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 if (!source_.is_null()) { 249 if (!source_.is_null()) {
254 i::GlobalHandles::Destroy(Handle<Object>::cast(source_).location()); 250 i::GlobalHandles::Destroy(Handle<Object>::cast(source_).location());
255 source_ = Handle<String>::null(); 251 source_ = Handle<String>::null();
256 } 252 }
257 253
258 status_ = CompileJobStatus::kInitial; 254 status_ = CompileJobStatus::kInitial;
259 } 255 }
260 256
261 } // namespace internal 257 } // namespace internal
262 } // namespace v8 258 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698