Revert "[compiler-dispatcher] Use an integer job id."
This reverts commit 4bca9dc701
.
Reason for revert: Breaks mips builder:
https://build.chromium.org/p/client.v8.ports/builders/V8%20Mips%20-%20builder/builds/8600
Original change's description:
> [compiler-dispatcher] Use an integer job id.
>
> It enables jobs without a SharedFunctionInfo.
>
> BUG=v8:6093
>
> Change-Id: Icc5f01512c270a55349087d418b6be82ad5c6cb4
> Reviewed-on: https://chromium-review.googlesource.com/467148
> Commit-Queue: Wiktor Garbacz <wiktorg@google.com>
> Reviewed-by: Ross McIlroy <rmcilroy@chromium.org>
> Reviewed-by: Jochen Eisinger <jochen@chromium.org>
> Reviewed-by: Marja Hölttä <marja@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#44402}
TBR=rmcilroy@chromium.org,marja@chromium.org,jochen@chromium.org,rmcilroy@google.com,wiktorg@google.com
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=v8:6093
Change-Id: Ie8d26f4e2d42f67a1cfa91269e80e407ed3f0799
Reviewed-on: https://chromium-review.googlesource.com/468887
Reviewed-by: Michael Achenbach <machenbach@chromium.org>
Commit-Queue: Michael Achenbach <machenbach@chromium.org>
Cr-Commit-Position: refs/heads/master@{#44404}
This commit is contained in:
parent
32f096667e
commit
0ed2f1784d
@ -63,8 +63,6 @@ class V8_EXPORT_PRIVATE CompilerDispatcherJob {
|
||||
|
||||
Context* context() { return *context_; }
|
||||
|
||||
Handle<SharedFunctionInfo> shared() const { return shared_; }
|
||||
|
||||
// Returns true if this CompilerDispatcherJob was created for the given
|
||||
// function.
|
||||
bool IsAssociatedWith(Handle<SharedFunctionInfo> shared) const;
|
||||
|
@ -221,8 +221,6 @@ CompilerDispatcher::CompilerDispatcher(Isolate* isolate, Platform* platform,
|
||||
trace_compiler_dispatcher_(FLAG_trace_compiler_dispatcher),
|
||||
tracer_(new CompilerDispatcherTracer(isolate_)),
|
||||
task_manager_(new CancelableTaskManager()),
|
||||
next_job_id_(0),
|
||||
shared_to_job_id_(isolate->heap()),
|
||||
memory_pressure_level_(MemoryPressureLevel::kNone),
|
||||
abort_(false),
|
||||
idle_task_scheduled_(false),
|
||||
@ -265,22 +263,6 @@ bool CompilerDispatcher::CanEnqueue(Handle<SharedFunctionInfo> function) {
|
||||
return true;
|
||||
}
|
||||
|
||||
CompilerDispatcher::JobId CompilerDispatcher::Enqueue(
|
||||
std::unique_ptr<CompilerDispatcherJob> job) {
|
||||
DCHECK(!IsFinished(job.get()));
|
||||
bool added;
|
||||
JobMap::const_iterator it;
|
||||
std::tie(it, added) =
|
||||
jobs_.insert(std::make_pair(next_job_id_++, std::move(job)));
|
||||
DCHECK(added);
|
||||
if (!it->second->shared().is_null()) {
|
||||
shared_to_job_id_.Set(it->second->shared(), it->first);
|
||||
}
|
||||
ConsiderJobForBackgroundProcessing(it->second.get());
|
||||
ScheduleIdleTaskIfNeeded();
|
||||
return it->first;
|
||||
}
|
||||
|
||||
bool CompilerDispatcher::Enqueue(Handle<SharedFunctionInfo> function) {
|
||||
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.compile"),
|
||||
"V8.CompilerDispatcherEnqueue");
|
||||
@ -295,7 +277,10 @@ bool CompilerDispatcher::Enqueue(Handle<SharedFunctionInfo> function) {
|
||||
|
||||
std::unique_ptr<CompilerDispatcherJob> job(new CompilerDispatcherJob(
|
||||
isolate_, tracer_.get(), function, max_stack_size_));
|
||||
Enqueue(std::move(job));
|
||||
std::pair<int, int> key(Script::cast(function->script())->id(),
|
||||
function->function_literal_id());
|
||||
jobs_.insert(std::make_pair(key, std::move(job)));
|
||||
ScheduleIdleTaskIfNeeded();
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -336,7 +321,10 @@ bool CompilerDispatcher::Enqueue(
|
||||
std::unique_ptr<CompilerDispatcherJob> job(new CompilerDispatcherJob(
|
||||
isolate_, tracer_.get(), script, function, literal, parse_zone,
|
||||
parse_handles, compile_handles, max_stack_size_));
|
||||
Enqueue(std::move(job));
|
||||
std::pair<int, int> key(Script::cast(function->script())->id(),
|
||||
function->function_literal_id());
|
||||
jobs_.insert(std::make_pair(key, std::move(job)));
|
||||
ScheduleIdleTaskIfNeeded();
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -420,9 +408,6 @@ bool CompilerDispatcher::FinishNow(Handle<SharedFunctionInfo> function) {
|
||||
}
|
||||
|
||||
job->second->ResetOnMainThread();
|
||||
if (!job->second->shared().is_null()) {
|
||||
shared_to_job_id_.Delete(job->second->shared());
|
||||
}
|
||||
jobs_.erase(job);
|
||||
if (jobs_.empty()) {
|
||||
base::LockGuard<base::Mutex> lock(&mutex_);
|
||||
@ -445,7 +430,6 @@ void CompilerDispatcher::AbortAll(BlockingBehavior blocking) {
|
||||
it.second->ResetOnMainThread();
|
||||
}
|
||||
jobs_.clear();
|
||||
shared_to_job_id_.Clear();
|
||||
{
|
||||
base::LockGuard<base::Mutex> lock(&mutex_);
|
||||
DCHECK(pending_background_jobs_.empty());
|
||||
@ -491,9 +475,6 @@ void CompilerDispatcher::AbortInactiveJobs() {
|
||||
PrintF("\n");
|
||||
}
|
||||
job->second->ResetOnMainThread();
|
||||
if (!job->second->shared().is_null()) {
|
||||
shared_to_job_id_.Delete(job->second->shared());
|
||||
}
|
||||
jobs_.erase(job);
|
||||
}
|
||||
if (jobs_.empty()) {
|
||||
@ -535,13 +516,14 @@ void CompilerDispatcher::MemoryPressureNotification(
|
||||
|
||||
CompilerDispatcher::JobMap::const_iterator CompilerDispatcher::GetJobFor(
|
||||
Handle<SharedFunctionInfo> shared) const {
|
||||
JobId* job_id_ptr = shared_to_job_id_.Find(shared);
|
||||
JobMap::const_iterator job = jobs_.end();
|
||||
if (job_id_ptr) {
|
||||
job = jobs_.find(*job_id_ptr);
|
||||
DCHECK(job == jobs_.end() || job->second->IsAssociatedWith(shared));
|
||||
if (!shared->script()->IsScript()) return jobs_.end();
|
||||
std::pair<int, int> key(Script::cast(shared->script())->id(),
|
||||
shared->function_literal_id());
|
||||
auto range = jobs_.equal_range(key);
|
||||
for (auto job = range.first; job != range.second; ++job) {
|
||||
if (job->second->IsAssociatedWith(shared)) return job;
|
||||
}
|
||||
return job;
|
||||
return jobs_.end();
|
||||
}
|
||||
|
||||
void CompilerDispatcher::ScheduleIdleTaskFromAnyThread() {
|
||||
@ -715,9 +697,6 @@ void CompilerDispatcher::DoIdleWork(double deadline_in_seconds) {
|
||||
tracer_->DumpStatistics();
|
||||
}
|
||||
job->second->ResetOnMainThread();
|
||||
if (!job->second->shared().is_null()) {
|
||||
shared_to_job_id_.Delete(job->second->shared());
|
||||
}
|
||||
job = jobs_.erase(job);
|
||||
continue;
|
||||
} else {
|
||||
|
@ -5,7 +5,6 @@
|
||||
#ifndef V8_COMPILER_DISPATCHER_COMPILER_DISPATCHER_H_
|
||||
#define V8_COMPILER_DISPATCHER_COMPILER_DISPATCHER_H_
|
||||
|
||||
#include <cstdint>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <unordered_set>
|
||||
@ -17,7 +16,6 @@
|
||||
#include "src/base/platform/mutex.h"
|
||||
#include "src/base/platform/semaphore.h"
|
||||
#include "src/globals.h"
|
||||
#include "src/identity-map.h"
|
||||
#include "testing/gtest/include/gtest/gtest_prod.h"
|
||||
|
||||
namespace v8 {
|
||||
@ -67,8 +65,6 @@ class Handle;
|
||||
// thread.
|
||||
class V8_EXPORT_PRIVATE CompilerDispatcher {
|
||||
public:
|
||||
typedef uintptr_t JobId;
|
||||
|
||||
enum class BlockingBehavior { kBlock, kDontBlock };
|
||||
|
||||
CompilerDispatcher(Isolate* isolate, Platform* platform,
|
||||
@ -121,7 +117,6 @@ class V8_EXPORT_PRIVATE CompilerDispatcher {
|
||||
bool is_isolate_locked);
|
||||
|
||||
private:
|
||||
FRIEND_TEST(CompilerDispatcherTest, EnqueueJob);
|
||||
FRIEND_TEST(CompilerDispatcherTest, EnqueueAndStep);
|
||||
FRIEND_TEST(CompilerDispatcherTest, EnqueueAndStepTwice);
|
||||
FRIEND_TEST(CompilerDispatcherTest, EnqueueParsed);
|
||||
@ -134,8 +129,9 @@ class V8_EXPORT_PRIVATE CompilerDispatcher {
|
||||
FRIEND_TEST(CompilerDispatcherTest, FinishNowDuringAbortAll);
|
||||
FRIEND_TEST(CompilerDispatcherTest, CompileMultipleOnBackgroundThread);
|
||||
|
||||
typedef std::map<JobId, std::unique_ptr<CompilerDispatcherJob>> JobMap;
|
||||
typedef IdentityMap<JobId, FreeStoreAllocationPolicy> SharedToJobIdMap;
|
||||
typedef std::multimap<std::pair<int, int>,
|
||||
std::unique_ptr<CompilerDispatcherJob>>
|
||||
JobMap;
|
||||
class AbortTask;
|
||||
class BackgroundTask;
|
||||
class IdleTask;
|
||||
@ -151,7 +147,6 @@ class V8_EXPORT_PRIVATE CompilerDispatcher {
|
||||
void ScheduleAbortTask();
|
||||
void DoBackgroundWork();
|
||||
void DoIdleWork(double deadline_in_seconds);
|
||||
JobId Enqueue(std::unique_ptr<CompilerDispatcherJob> job);
|
||||
|
||||
Isolate* isolate_;
|
||||
Platform* platform_;
|
||||
@ -164,15 +159,10 @@ class V8_EXPORT_PRIVATE CompilerDispatcher {
|
||||
|
||||
std::unique_ptr<CancelableTaskManager> task_manager_;
|
||||
|
||||
// Id for next job to be added
|
||||
JobId next_job_id_;
|
||||
|
||||
// Mapping from job_id to job.
|
||||
// Mapping from (script id, function literal id) to job. We use a multimap,
|
||||
// as script id is not necessarily unique.
|
||||
JobMap jobs_;
|
||||
|
||||
// Mapping from SharedFunctionInfo to corresponding JobId;
|
||||
SharedToJobIdMap shared_to_job_id_;
|
||||
|
||||
base::AtomicValue<v8::MemoryPressureLevel> memory_pressure_level_;
|
||||
|
||||
// The following members can be accessed from any thread. Methods need to hold
|
||||
|
@ -112,10 +112,7 @@ class IdentityMap : public IdentityMapBase {
|
||||
void Set(Object* key, V v) { *(reinterpret_cast<V*>(GetEntry(key))) = v; }
|
||||
|
||||
V Delete(Handle<Object> key) { return Delete(*key); }
|
||||
V Delete(Object* key) {
|
||||
void* val = DeleteEntry(key);
|
||||
return *reinterpret_cast<V*>(&val);
|
||||
}
|
||||
V Delete(Object* key) { return reinterpret_cast<V>(DeleteEntry(key)); }
|
||||
|
||||
// Removes all elements from the map.
|
||||
void Clear() { IdentityMapBase::Clear(); }
|
||||
|
@ -20,17 +20,6 @@
|
||||
#include "test/unittests/test-utils.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
|
||||
// V8 is smart enough to know something was already compiled and return compiled
|
||||
// code straight away. We need a unique name for each test function so that V8
|
||||
// returns an empty SharedFunctionInfo.
|
||||
#define _STR(x) #x
|
||||
#define STR(x) _STR(x)
|
||||
#define _SCRIPT(fn, a, b, c) a fn b fn c
|
||||
#define SCRIPT(a, b, c) _SCRIPT("f" STR(__LINE__), a, b, c)
|
||||
#define TEST_SCRIPT() \
|
||||
SCRIPT("function g() { var y = 1; function ", \
|
||||
"(x) { return x * y }; return ", "; } g();")
|
||||
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
|
||||
@ -281,7 +270,9 @@ TEST_F(CompilerDispatcherTest, IsEnqueued) {
|
||||
MockPlatform platform;
|
||||
CompilerDispatcher dispatcher(i_isolate(), &platform, FLAG_stack_size);
|
||||
|
||||
const char script[] = TEST_SCRIPT();
|
||||
const char script[] =
|
||||
"function g() { var y = 1; function f1(x) { return x * y }; return f1; } "
|
||||
"g();";
|
||||
Handle<JSFunction> f = Handle<JSFunction>::cast(RunJS(isolate(), script));
|
||||
Handle<SharedFunctionInfo> shared(f->shared(), i_isolate());
|
||||
|
||||
@ -298,7 +289,9 @@ TEST_F(CompilerDispatcherTest, FinishNow) {
|
||||
MockPlatform platform;
|
||||
CompilerDispatcher dispatcher(i_isolate(), &platform, FLAG_stack_size);
|
||||
|
||||
const char script[] = TEST_SCRIPT();
|
||||
const char script[] =
|
||||
"function g() { var y = 1; function f2(x) { return x * y }; return f2; } "
|
||||
"g();";
|
||||
Handle<JSFunction> f = Handle<JSFunction>::cast(RunJS(isolate(), script));
|
||||
Handle<SharedFunctionInfo> shared(f->shared(), i_isolate());
|
||||
|
||||
@ -316,7 +309,9 @@ TEST_F(CompilerDispatcherTest, IdleTask) {
|
||||
MockPlatform platform;
|
||||
CompilerDispatcher dispatcher(i_isolate(), &platform, FLAG_stack_size);
|
||||
|
||||
const char script[] = TEST_SCRIPT();
|
||||
const char script[] =
|
||||
"function g() { var y = 1; function f3(x) { return x * y }; return f3; } "
|
||||
"g();";
|
||||
Handle<JSFunction> f = Handle<JSFunction>::cast(RunJS(isolate(), script));
|
||||
Handle<SharedFunctionInfo> shared(f->shared(), i_isolate());
|
||||
|
||||
@ -336,7 +331,9 @@ TEST_F(CompilerDispatcherTest, IdleTaskSmallIdleTime) {
|
||||
MockPlatform platform;
|
||||
CompilerDispatcher dispatcher(i_isolate(), &platform, FLAG_stack_size);
|
||||
|
||||
const char script[] = TEST_SCRIPT();
|
||||
const char script[] =
|
||||
"function g() { var y = 1; function f4(x) { return x * y }; return f4; } "
|
||||
"g();";
|
||||
Handle<JSFunction> f = Handle<JSFunction>::cast(RunJS(isolate(), script));
|
||||
Handle<SharedFunctionInfo> shared(f->shared(), i_isolate());
|
||||
|
||||
@ -374,12 +371,11 @@ TEST_F(CompilerDispatcherTest, IdleTaskException) {
|
||||
MockPlatform platform;
|
||||
CompilerDispatcher dispatcher(i_isolate(), &platform, 50);
|
||||
|
||||
std::string func_name("f" STR(__LINE__));
|
||||
std::string script("function g() { function " + func_name + "(x) { var a = ");
|
||||
std::string script("function g() { function f5(x) { var a = ");
|
||||
for (int i = 0; i < 1000; i++) {
|
||||
script += "'x' + ";
|
||||
}
|
||||
script += " 'x'; }; return " + func_name + "; } g();";
|
||||
script += " 'x'; }; return f5; } g();";
|
||||
Handle<JSFunction> f =
|
||||
Handle<JSFunction>::cast(RunJS(isolate(), script.c_str()));
|
||||
Handle<SharedFunctionInfo> shared(f->shared(), i_isolate());
|
||||
@ -401,7 +397,9 @@ TEST_F(CompilerDispatcherTest, CompileOnBackgroundThread) {
|
||||
MockPlatform platform;
|
||||
CompilerDispatcher dispatcher(i_isolate(), &platform, FLAG_stack_size);
|
||||
|
||||
const char script[] = TEST_SCRIPT();
|
||||
const char script[] =
|
||||
"function g() { var y = 1; function f6(x) { return x * y }; return f6; } "
|
||||
"g();";
|
||||
Handle<JSFunction> f = Handle<JSFunction>::cast(RunJS(isolate(), script));
|
||||
Handle<SharedFunctionInfo> shared(f->shared(), i_isolate());
|
||||
|
||||
@ -444,7 +442,9 @@ TEST_F(CompilerDispatcherTest, FinishNowWithBackgroundTask) {
|
||||
MockPlatform platform;
|
||||
CompilerDispatcher dispatcher(i_isolate(), &platform, FLAG_stack_size);
|
||||
|
||||
const char script[] = TEST_SCRIPT();
|
||||
const char script[] =
|
||||
"function g() { var y = 1; function f7(x) { return x * y }; return f7; } "
|
||||
"g();";
|
||||
Handle<JSFunction> f = Handle<JSFunction>::cast(RunJS(isolate(), script));
|
||||
Handle<SharedFunctionInfo> shared(f->shared(), i_isolate());
|
||||
|
||||
@ -483,11 +483,15 @@ TEST_F(CompilerDispatcherTest, IdleTaskMultipleJobs) {
|
||||
MockPlatform platform;
|
||||
CompilerDispatcher dispatcher(i_isolate(), &platform, FLAG_stack_size);
|
||||
|
||||
const char script1[] = TEST_SCRIPT();
|
||||
const char script1[] =
|
||||
"function g() { var y = 1; function f8(x) { return x * y }; return f8; } "
|
||||
"g();";
|
||||
Handle<JSFunction> f1 = Handle<JSFunction>::cast(RunJS(isolate(), script1));
|
||||
Handle<SharedFunctionInfo> shared1(f1->shared(), i_isolate());
|
||||
|
||||
const char script2[] = TEST_SCRIPT();
|
||||
const char script2[] =
|
||||
"function g() { var y = 1; function f9(x) { return x * y }; return f9; } "
|
||||
"g();";
|
||||
Handle<JSFunction> f2 = Handle<JSFunction>::cast(RunJS(isolate(), script2));
|
||||
Handle<SharedFunctionInfo> shared2(f2->shared(), i_isolate());
|
||||
|
||||
@ -510,12 +514,11 @@ TEST_F(CompilerDispatcherTest, FinishNowException) {
|
||||
MockPlatform platform;
|
||||
CompilerDispatcher dispatcher(i_isolate(), &platform, 50);
|
||||
|
||||
std::string func_name("f" STR(__LINE__));
|
||||
std::string script("function g() { function " + func_name + "(x) { var a = ");
|
||||
std::string script("function g() { function f10(x) { var a = ");
|
||||
for (int i = 0; i < 1000; i++) {
|
||||
script += "'x' + ";
|
||||
}
|
||||
script += " 'x'; }; return " + func_name + "; } g();";
|
||||
script += " 'x'; }; return f10; } g();";
|
||||
Handle<JSFunction> f =
|
||||
Handle<JSFunction>::cast(RunJS(isolate(), script.c_str()));
|
||||
Handle<SharedFunctionInfo> shared(f->shared(), i_isolate());
|
||||
@ -538,7 +541,9 @@ TEST_F(CompilerDispatcherTest, AsyncAbortAllPendingBackgroundTask) {
|
||||
MockPlatform platform;
|
||||
CompilerDispatcher dispatcher(i_isolate(), &platform, FLAG_stack_size);
|
||||
|
||||
const char script[] = TEST_SCRIPT();
|
||||
const char script[] =
|
||||
"function g() { var y = 1; function f11(x) { return x * y }; return f11; "
|
||||
"} g();";
|
||||
Handle<JSFunction> f = Handle<JSFunction>::cast(RunJS(isolate(), script));
|
||||
Handle<SharedFunctionInfo> shared(f->shared(), i_isolate());
|
||||
|
||||
@ -580,11 +585,15 @@ TEST_F(CompilerDispatcherTest, AsyncAbortAllRunningBackgroundTask) {
|
||||
MockPlatform platform;
|
||||
CompilerDispatcher dispatcher(i_isolate(), &platform, FLAG_stack_size);
|
||||
|
||||
const char script1[] = TEST_SCRIPT();
|
||||
const char script1[] =
|
||||
"function g() { var y = 1; function f11(x) { return x * y }; return f11; "
|
||||
"} g();";
|
||||
Handle<JSFunction> f1 = Handle<JSFunction>::cast(RunJS(isolate(), script1));
|
||||
Handle<SharedFunctionInfo> shared1(f1->shared(), i_isolate());
|
||||
|
||||
const char script2[] = TEST_SCRIPT();
|
||||
const char script2[] =
|
||||
"function g() { var y = 1; function f12(x) { return x * y }; return f12; "
|
||||
"} g();";
|
||||
Handle<JSFunction> f2 = Handle<JSFunction>::cast(RunJS(isolate(), script2));
|
||||
Handle<SharedFunctionInfo> shared2(f2->shared(), i_isolate());
|
||||
|
||||
@ -660,7 +669,9 @@ TEST_F(CompilerDispatcherTest, FinishNowDuringAbortAll) {
|
||||
MockPlatform platform;
|
||||
CompilerDispatcher dispatcher(i_isolate(), &platform, FLAG_stack_size);
|
||||
|
||||
const char script[] = TEST_SCRIPT();
|
||||
const char script[] =
|
||||
"function g() { var y = 1; function f13(x) { return x * y }; return f13; "
|
||||
"} g();";
|
||||
Handle<JSFunction> f = Handle<JSFunction>::cast(RunJS(isolate(), script));
|
||||
Handle<SharedFunctionInfo> shared(f->shared(), i_isolate());
|
||||
|
||||
@ -738,7 +749,9 @@ TEST_F(CompilerDispatcherTest, MemoryPressure) {
|
||||
MockPlatform platform;
|
||||
CompilerDispatcher dispatcher(i_isolate(), &platform, FLAG_stack_size);
|
||||
|
||||
const char script[] = TEST_SCRIPT();
|
||||
const char script[] =
|
||||
"function g() { var y = 1; function f14(x) { return x * y }; return f14; "
|
||||
"} g();";
|
||||
Handle<JSFunction> f = Handle<JSFunction>::cast(RunJS(isolate(), script));
|
||||
Handle<SharedFunctionInfo> shared(f->shared(), i_isolate());
|
||||
|
||||
@ -785,7 +798,9 @@ TEST_F(CompilerDispatcherTest, MemoryPressureFromBackground) {
|
||||
MockPlatform platform;
|
||||
CompilerDispatcher dispatcher(i_isolate(), &platform, FLAG_stack_size);
|
||||
|
||||
const char script[] = TEST_SCRIPT();
|
||||
const char script[] =
|
||||
"function g() { var y = 1; function f15(x) { return x * y }; return f15; "
|
||||
"} g();";
|
||||
Handle<JSFunction> f = Handle<JSFunction>::cast(RunJS(isolate(), script));
|
||||
Handle<SharedFunctionInfo> shared(f->shared(), i_isolate());
|
||||
|
||||
@ -813,29 +828,13 @@ TEST_F(CompilerDispatcherTest, MemoryPressureFromBackground) {
|
||||
platform.ClearIdleTask();
|
||||
}
|
||||
|
||||
TEST_F(CompilerDispatcherTest, EnqueueJob) {
|
||||
MockPlatform platform;
|
||||
CompilerDispatcher dispatcher(i_isolate(), &platform, FLAG_stack_size);
|
||||
const char script[] = TEST_SCRIPT();
|
||||
Handle<JSFunction> f = Handle<JSFunction>::cast(RunJS(isolate(), script));
|
||||
Handle<SharedFunctionInfo> shared(f->shared(), i_isolate());
|
||||
std::unique_ptr<CompilerDispatcherJob> job(
|
||||
new CompilerDispatcherJob(i_isolate(), dispatcher.tracer_.get(), shared,
|
||||
dispatcher.max_stack_size_));
|
||||
ASSERT_FALSE(dispatcher.IsEnqueued(shared));
|
||||
dispatcher.Enqueue(std::move(job));
|
||||
ASSERT_TRUE(dispatcher.IsEnqueued(shared));
|
||||
|
||||
ASSERT_TRUE(platform.IdleTaskPending());
|
||||
platform.ClearIdleTask();
|
||||
ASSERT_FALSE(platform.BackgroundTasksPending());
|
||||
}
|
||||
|
||||
TEST_F(CompilerDispatcherTest, EnqueueAndStep) {
|
||||
MockPlatform platform;
|
||||
CompilerDispatcher dispatcher(i_isolate(), &platform, FLAG_stack_size);
|
||||
|
||||
const char script[] = TEST_SCRIPT();
|
||||
const char script[] =
|
||||
"function g() { var y = 1; function f16(x) { return x * y }; return f16; "
|
||||
"} g();";
|
||||
Handle<JSFunction> f = Handle<JSFunction>::cast(RunJS(isolate(), script));
|
||||
Handle<SharedFunctionInfo> shared(f->shared(), i_isolate());
|
||||
|
||||
@ -856,7 +855,9 @@ TEST_F(CompilerDispatcherTest, EnqueueParsed) {
|
||||
MockPlatform platform;
|
||||
CompilerDispatcher dispatcher(i_isolate(), &platform, FLAG_stack_size);
|
||||
|
||||
const char source[] = TEST_SCRIPT();
|
||||
const char source[] =
|
||||
"function g() { var y = 1; function f17(x) { return x * y }; return f17; "
|
||||
"} g();";
|
||||
Handle<JSFunction> f = Handle<JSFunction>::cast(RunJS(isolate(), source));
|
||||
Handle<SharedFunctionInfo> shared(f->shared(), i_isolate());
|
||||
Handle<Script> script(Script::cast(shared->script()), i_isolate());
|
||||
@ -882,7 +883,9 @@ TEST_F(CompilerDispatcherTest, EnqueueAndStepParsed) {
|
||||
MockPlatform platform;
|
||||
CompilerDispatcher dispatcher(i_isolate(), &platform, FLAG_stack_size);
|
||||
|
||||
const char source[] = TEST_SCRIPT();
|
||||
const char source[] =
|
||||
"function g() { var y = 1; function f18(x) { return x * y }; return f18; "
|
||||
"} g();";
|
||||
Handle<JSFunction> f = Handle<JSFunction>::cast(RunJS(isolate(), source));
|
||||
Handle<SharedFunctionInfo> shared(f->shared(), i_isolate());
|
||||
Handle<Script> script(Script::cast(shared->script()), i_isolate());
|
||||
@ -910,7 +913,9 @@ TEST_F(CompilerDispatcherTest, CompileParsedOutOfScope) {
|
||||
MockPlatform platform;
|
||||
CompilerDispatcher dispatcher(i_isolate(), &platform, FLAG_stack_size);
|
||||
|
||||
const char source[] = TEST_SCRIPT();
|
||||
const char source[] =
|
||||
"function g() { var y = 1; function f20(x) { return x + y }; return f20; "
|
||||
"} g();";
|
||||
Handle<JSFunction> f = Handle<JSFunction>::cast(RunJS(isolate(), source));
|
||||
Handle<SharedFunctionInfo> shared(f->shared(), i_isolate());
|
||||
Handle<Script> script(Script::cast(shared->script()), i_isolate());
|
||||
@ -1022,7 +1027,9 @@ TEST_F(CompilerDispatcherTest, CompileLazyFinishesDispatcherJob) {
|
||||
// enqueued functions.
|
||||
CompilerDispatcher* dispatcher = i_isolate()->compiler_dispatcher();
|
||||
|
||||
const char source[] = TEST_SCRIPT();
|
||||
const char source[] =
|
||||
"function g() { var y = 1; function f16(x) { return x * y }; return f16; "
|
||||
"} g();";
|
||||
Handle<JSFunction> f = Handle<JSFunction>::cast(RunJS(isolate(), source));
|
||||
Handle<SharedFunctionInfo> shared(f->shared(), i_isolate());
|
||||
|
||||
@ -1069,7 +1076,9 @@ TEST_F(CompilerDispatcherTest, EnqueueAndStepTwice) {
|
||||
MockPlatform platform;
|
||||
CompilerDispatcher dispatcher(i_isolate(), &platform, FLAG_stack_size);
|
||||
|
||||
const char source[] = TEST_SCRIPT();
|
||||
const char source[] =
|
||||
"function g() { var y = 1; function f18(x) { return x * y }; return f18; "
|
||||
"} g();";
|
||||
Handle<JSFunction> f = Handle<JSFunction>::cast(RunJS(isolate(), source));
|
||||
Handle<SharedFunctionInfo> shared(f->shared(), i_isolate());
|
||||
Handle<Script> script(Script::cast(shared->script()), i_isolate());
|
||||
@ -1109,10 +1118,14 @@ TEST_F(CompilerDispatcherTest, CompileMultipleOnBackgroundThread) {
|
||||
MockPlatform platform;
|
||||
CompilerDispatcher dispatcher(i_isolate(), &platform, FLAG_stack_size);
|
||||
|
||||
const char script1[] = TEST_SCRIPT();
|
||||
const char script1[] =
|
||||
"function g() { var y = 1; function f19(x) { return x * y }; "
|
||||
"return f19; } g();";
|
||||
Handle<JSFunction> f1 = Handle<JSFunction>::cast(RunJS(isolate(), script1));
|
||||
Handle<SharedFunctionInfo> shared1(f1->shared(), i_isolate());
|
||||
const char script2[] = TEST_SCRIPT();
|
||||
const char script2[] =
|
||||
"function g() { var y = 1; function f20(x) { return x * y }; "
|
||||
"return f20; } g();";
|
||||
Handle<JSFunction> f2 = Handle<JSFunction>::cast(RunJS(isolate(), script2));
|
||||
Handle<SharedFunctionInfo> shared2(f2->shared(), i_isolate());
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user