Commit 3ca98851 authored by jochen's avatar jochen Committed by Commit bot

Add a prepare to parse step to CompilerDispatcherJob

R=marja@chromium.org
BUG=v8:5215

Review-Url: https://codereview.chromium.org/2191443003
Cr-Commit-Position: refs/heads/master@{#38114}
parent 784a636f
......@@ -7,6 +7,9 @@
#include "src/global-handles.h"
#include "src/isolate.h"
#include "src/objects-inl.h"
#include "src/parsing/parser.h"
#include "src/unicode-cache.h"
#include "src/zone.h"
namespace v8 {
namespace internal {
......@@ -18,8 +21,22 @@ CompilerDispatcherJob::CompilerDispatcherJob(Isolate* isolate,
isolate_->global_handles()->Create(*function))) {}
CompilerDispatcherJob::~CompilerDispatcherJob() {
DCHECK(ThreadId::Current().Equals(isolate_->thread_id()));
i::GlobalHandles::Destroy(Handle<Object>::cast(function_).location());
}
void CompilerDispatcherJob::PrepareToParseOnMainThread() {
DCHECK(ThreadId::Current().Equals(isolate_->thread_id()));
DCHECK(status_ == CompileJobStatus::kInitial);
unicode_cache_.reset(new UnicodeCache());
zone_.reset(new Zone(isolate_->allocator()));
parse_info_.reset(new ParseInfo(zone_.get()));
parse_info_->set_isolate(isolate_);
// TODO(jochen): We need to hook up a fake source stream here.
parse_info_->set_hash_seed(isolate_->heap()->HashSeed());
parse_info_->set_unicode_cache(unicode_cache_.get());
status_ = CompileJobStatus::kReadyToParse;
}
} // namespace internal
} // namespace v8
......@@ -5,8 +5,9 @@
#ifndef V8_COMPILER_DISPATCHER_COMPILER_DISPATCHER_JOB_H_
#define V8_COMPILER_DISPATCHER_COMPILER_DISPATCHER_JOB_H_
#include "src/base/macros.h"
#include <memory>
#include "src/base/macros.h"
#include "src/handles.h"
namespace v8 {
......@@ -15,9 +16,13 @@ namespace internal {
class CompilationInfo;
class Isolate;
class JSFunction;
class ParseInfo;
class UnicodeCache;
class Zone;
enum class CompileJobStatus {
kInitial,
kReadyToParse,
};
class CompilerDispatcherJob {
......@@ -27,11 +32,19 @@ class CompilerDispatcherJob {
CompileJobStatus status() const { return status_; }
// Transition from kInitial to kReadyToParse.
void PrepareToParseOnMainThread();
private:
CompileJobStatus status_ = CompileJobStatus::kInitial;
Isolate* isolate_;
Handle<JSFunction> function_; // Global handle.
// Members required for parsing.
std::unique_ptr<UnicodeCache> unicode_cache_;
std::unique_ptr<Zone> zone_;
std::unique_ptr<ParseInfo> parse_info_;
DISALLOW_COPY_AND_ASSIGN(CompilerDispatcherJob);
};
......
......@@ -20,5 +20,15 @@ TEST_F(CompilerDispatcherJobTest, Construct) {
new CompilerDispatcherJob(i_isolate, i_isolate->object_function()));
}
TEST_F(CompilerDispatcherJobTest, PrepareToParse) {
Isolate* i_isolate = reinterpret_cast<Isolate*>(isolate());
std::unique_ptr<CompilerDispatcherJob> job(
new CompilerDispatcherJob(i_isolate, i_isolate->object_function()));
ASSERT_TRUE(job->status() == CompileJobStatus::kInitial);
job->PrepareToParseOnMainThread();
ASSERT_TRUE(job->status() == CompileJobStatus::kReadyToParse);
}
} // namespace internal
} // namespace v8
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment