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

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

Issue 2558293004: Add a basic compiler dispatcher (Closed)
Patch Set: play it safe Created 4 years 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 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"
11 #include "src/global-handles.h" 11 #include "src/global-handles.h"
12 #include "src/isolate.h" 12 #include "src/isolate.h"
13 #include "src/objects-inl.h" 13 #include "src/objects-inl.h"
14 #include "src/parsing/parse-info.h" 14 #include "src/parsing/parse-info.h"
15 #include "src/parsing/parser.h" 15 #include "src/parsing/parser.h"
16 #include "src/parsing/scanner-character-streams.h" 16 #include "src/parsing/scanner-character-streams.h"
17 #include "src/unicode-cache.h" 17 #include "src/unicode-cache.h"
18 #include "src/zone/zone.h" 18 #include "src/zone/zone.h"
19 19
20 namespace v8 { 20 namespace v8 {
21 namespace internal { 21 namespace internal {
22 22
23 CompilerDispatcherJob::CompilerDispatcherJob(Isolate* isolate, 23 CompilerDispatcherJob::CompilerDispatcherJob(Isolate* isolate,
24 CompilerDispatcherTracer* tracer,
24 Handle<SharedFunctionInfo> shared, 25 Handle<SharedFunctionInfo> shared,
25 size_t max_stack_size) 26 size_t max_stack_size)
26 : isolate_(isolate), 27 : isolate_(isolate),
27 tracer_(isolate_->compiler_dispatcher_tracer()), 28 tracer_(tracer),
28 shared_(Handle<SharedFunctionInfo>::cast( 29 shared_(Handle<SharedFunctionInfo>::cast(
29 isolate_->global_handles()->Create(*shared))), 30 isolate_->global_handles()->Create(*shared))),
30 max_stack_size_(max_stack_size), 31 max_stack_size_(max_stack_size),
31 can_compile_on_background_thread_(false) { 32 can_compile_on_background_thread_(false) {
32 HandleScope scope(isolate_); 33 HandleScope scope(isolate_);
33 DCHECK(!shared_->outer_scope_info()->IsTheHole(isolate_)); 34 DCHECK(!shared_->outer_scope_info()->IsTheHole(isolate_));
34 Handle<Script> script(Script::cast(shared_->script()), isolate_); 35 Handle<Script> script(Script::cast(shared_->script()), isolate_);
35 Handle<String> source(String::cast(script->source()), isolate_); 36 Handle<String> source(String::cast(script->source()), isolate_);
36 can_parse_on_background_thread_ = 37 can_parse_on_background_thread_ =
37 source->IsExternalTwoByteString() || source->IsExternalOneByteString(); 38 source->IsExternalTwoByteString() || source->IsExternalOneByteString();
38 } 39 }
39 40
40 CompilerDispatcherJob::~CompilerDispatcherJob() { 41 CompilerDispatcherJob::~CompilerDispatcherJob() {
41 DCHECK(ThreadId::Current().Equals(isolate_->thread_id())); 42 DCHECK(ThreadId::Current().Equals(isolate_->thread_id()));
42 DCHECK(status_ == CompileJobStatus::kInitial || 43 DCHECK(status_ == CompileJobStatus::kInitial ||
43 status_ == CompileJobStatus::kDone); 44 status_ == CompileJobStatus::kDone);
44 i::GlobalHandles::Destroy(Handle<Object>::cast(shared_).location()); 45 i::GlobalHandles::Destroy(Handle<Object>::cast(shared_).location());
45 } 46 }
46 47
48 bool CompilerDispatcherJob::IsProcessing(
49 Handle<SharedFunctionInfo> shared) const {
50 return *shared_ == *shared;
51 }
52
47 void CompilerDispatcherJob::PrepareToParseOnMainThread() { 53 void CompilerDispatcherJob::PrepareToParseOnMainThread() {
48 DCHECK(ThreadId::Current().Equals(isolate_->thread_id())); 54 DCHECK(ThreadId::Current().Equals(isolate_->thread_id()));
49 DCHECK(status() == CompileJobStatus::kInitial); 55 DCHECK(status() == CompileJobStatus::kInitial);
50 COMPILER_DISPATCHER_TRACE_SCOPE(tracer_, kPrepareToParse); 56 COMPILER_DISPATCHER_TRACE_SCOPE(tracer_, kPrepareToParse);
51 HandleScope scope(isolate_); 57 HandleScope scope(isolate_);
52 unicode_cache_.reset(new UnicodeCache()); 58 unicode_cache_.reset(new UnicodeCache());
53 zone_.reset(new Zone(isolate_->allocator(), ZONE_NAME)); 59 zone_.reset(new Zone(isolate_->allocator(), ZONE_NAME));
54 Handle<Script> script(Script::cast(shared_->script()), isolate_); 60 Handle<Script> script(Script::cast(shared_->script()), isolate_);
55 DCHECK(script->type() != Script::TYPE_NATIVE); 61 DCHECK(script->type() != Script::TYPE_NATIVE);
56 62
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 if (!source_.is_null()) { 258 if (!source_.is_null()) {
253 i::GlobalHandles::Destroy(Handle<Object>::cast(source_).location()); 259 i::GlobalHandles::Destroy(Handle<Object>::cast(source_).location());
254 source_ = Handle<String>::null(); 260 source_ = Handle<String>::null();
255 } 261 }
256 262
257 status_ = CompileJobStatus::kInitial; 263 status_ = CompileJobStatus::kInitial;
258 } 264 }
259 265
260 } // namespace internal 266 } // namespace internal
261 } // namespace v8 267 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698