Index: test/unittests/compiler-dispatcher/compiler-dispatcher-job-unittest.cc |
diff --git a/test/unittests/compiler-dispatcher/compiler-dispatcher-job-unittest.cc b/test/unittests/compiler-dispatcher/compiler-dispatcher-job-unittest.cc |
index 67eb9e2cef8b362f57e08d5d1c69c838891498f1..d8fde2b1400b2f0cac9026c946f01c0e3bb59436 100644 |
--- a/test/unittests/compiler-dispatcher/compiler-dispatcher-job-unittest.cc |
+++ b/test/unittests/compiler-dispatcher/compiler-dispatcher-job-unittest.cc |
@@ -10,19 +10,32 @@ |
#include "src/ast/scopes.h" |
#include "src/base/platform/semaphore.h" |
#include "src/compiler-dispatcher/compiler-dispatcher-job.h" |
+#include "src/compiler-dispatcher/compiler-dispatcher-tracer.h" |
#include "src/flags.h" |
#include "src/isolate-inl.h" |
#include "src/parsing/parse-info.h" |
#include "src/v8.h" |
+#include "test/unittests/compiler-dispatcher/compiler-dispatcher-helper.h" |
#include "test/unittests/test-utils.h" |
#include "testing/gtest/include/gtest/gtest.h" |
namespace v8 { |
namespace internal { |
-typedef TestWithContext CompilerDispatcherJobTest; |
+class CompilerDispatcherJobTest : public TestWithContext { |
+ public: |
+ CompilerDispatcherJobTest() : tracer_(i_isolate()) {} |
+ ~CompilerDispatcherJobTest() override {} |
+ |
+ CompilerDispatcherTracer* tracer() { return &tracer_; } |
+ |
+ private: |
+ CompilerDispatcherTracer tracer_; |
-class IgnitionCompilerDispatcherJobTest : public TestWithContext { |
+ DISALLOW_COPY_AND_ASSIGN(CompilerDispatcherJobTest); |
+}; |
+ |
+class IgnitionCompilerDispatcherJobTest : public CompilerDispatcherJobTest { |
public: |
IgnitionCompilerDispatcherJobTest() {} |
~IgnitionCompilerDispatcherJobTest() override {} |
@@ -90,36 +103,25 @@ Handle<SharedFunctionInfo> CreateSharedFunctionInfo( |
return scope.CloseAndEscape(shared); |
} |
-Handle<Object> RunJS(v8::Isolate* isolate, const char* script) { |
- return Utils::OpenHandle( |
- *v8::Script::Compile( |
- isolate->GetCurrentContext(), |
- v8::String::NewFromUtf8(isolate, script, v8::NewStringType::kNormal) |
- .ToLocalChecked()) |
- .ToLocalChecked() |
- ->Run(isolate->GetCurrentContext()) |
- .ToLocalChecked()); |
-} |
- |
} // namespace |
TEST_F(CompilerDispatcherJobTest, Construct) { |
std::unique_ptr<CompilerDispatcherJob> job(new CompilerDispatcherJob( |
- i_isolate(), CreateSharedFunctionInfo(i_isolate(), nullptr), |
+ i_isolate(), tracer(), CreateSharedFunctionInfo(i_isolate(), nullptr), |
FLAG_stack_size)); |
} |
TEST_F(CompilerDispatcherJobTest, CanParseOnBackgroundThread) { |
{ |
std::unique_ptr<CompilerDispatcherJob> job(new CompilerDispatcherJob( |
- i_isolate(), CreateSharedFunctionInfo(i_isolate(), nullptr), |
+ i_isolate(), tracer(), CreateSharedFunctionInfo(i_isolate(), nullptr), |
FLAG_stack_size)); |
ASSERT_FALSE(job->can_parse_on_background_thread()); |
} |
{ |
ScriptResource script(test_script, strlen(test_script)); |
std::unique_ptr<CompilerDispatcherJob> job(new CompilerDispatcherJob( |
- i_isolate(), CreateSharedFunctionInfo(i_isolate(), &script), |
+ i_isolate(), tracer(), CreateSharedFunctionInfo(i_isolate(), &script), |
FLAG_stack_size)); |
ASSERT_TRUE(job->can_parse_on_background_thread()); |
} |
@@ -127,7 +129,7 @@ TEST_F(CompilerDispatcherJobTest, CanParseOnBackgroundThread) { |
TEST_F(CompilerDispatcherJobTest, StateTransitions) { |
std::unique_ptr<CompilerDispatcherJob> job(new CompilerDispatcherJob( |
- i_isolate(), CreateSharedFunctionInfo(i_isolate(), nullptr), |
+ i_isolate(), tracer(), CreateSharedFunctionInfo(i_isolate(), nullptr), |
FLAG_stack_size)); |
ASSERT_TRUE(job->status() == CompileJobStatus::kInitial); |
@@ -150,7 +152,7 @@ TEST_F(CompilerDispatcherJobTest, StateTransitions) { |
TEST_F(CompilerDispatcherJobTest, SyntaxError) { |
ScriptResource script("^^^", strlen("^^^")); |
std::unique_ptr<CompilerDispatcherJob> job(new CompilerDispatcherJob( |
- i_isolate(), CreateSharedFunctionInfo(i_isolate(), &script), |
+ i_isolate(), tracer(), CreateSharedFunctionInfo(i_isolate(), &script), |
FLAG_stack_size)); |
job->PrepareToParseOnMainThread(); |
@@ -172,7 +174,7 @@ TEST_F(CompilerDispatcherJobTest, ScopeChain) { |
Handle<JSFunction> f = Handle<JSFunction>::cast(RunJS(isolate(), script)); |
std::unique_ptr<CompilerDispatcherJob> job(new CompilerDispatcherJob( |
- i_isolate(), handle(f->shared()), FLAG_stack_size)); |
+ i_isolate(), tracer(), handle(f->shared()), FLAG_stack_size)); |
job->PrepareToParseOnMainThread(); |
job->Parse(); |
@@ -208,7 +210,7 @@ TEST_F(CompilerDispatcherJobTest, CompileAndRun) { |
"g();"; |
Handle<JSFunction> f = Handle<JSFunction>::cast(RunJS(isolate(), script)); |
std::unique_ptr<CompilerDispatcherJob> job(new CompilerDispatcherJob( |
- i_isolate(), handle(f->shared()), FLAG_stack_size)); |
+ i_isolate(), tracer(), handle(f->shared()), FLAG_stack_size)); |
job->PrepareToParseOnMainThread(); |
job->Parse(); |
@@ -233,7 +235,8 @@ TEST_F(CompilerDispatcherJobTest, CompileFailureToPrepare) { |
raw_script += " 'x'; }"; |
ScriptResource script(raw_script.c_str(), strlen(raw_script.c_str())); |
std::unique_ptr<CompilerDispatcherJob> job(new CompilerDispatcherJob( |
- i_isolate(), CreateSharedFunctionInfo(i_isolate(), &script), 100)); |
+ i_isolate(), tracer(), CreateSharedFunctionInfo(i_isolate(), &script), |
+ 100)); |
job->PrepareToParseOnMainThread(); |
job->Parse(); |
@@ -255,7 +258,8 @@ TEST_F(CompilerDispatcherJobTest, CompileFailureToFinalize) { |
raw_script += " 'x'; }"; |
ScriptResource script(raw_script.c_str(), strlen(raw_script.c_str())); |
std::unique_ptr<CompilerDispatcherJob> job(new CompilerDispatcherJob( |
- i_isolate(), CreateSharedFunctionInfo(i_isolate(), &script), 50)); |
+ i_isolate(), tracer(), CreateSharedFunctionInfo(i_isolate(), &script), |
+ 50)); |
job->PrepareToParseOnMainThread(); |
job->Parse(); |
@@ -298,7 +302,8 @@ TEST_F(IgnitionCompilerDispatcherJobTest, CompileOnBackgroundThread) { |
"}"; |
ScriptResource script(raw_script, strlen(raw_script)); |
std::unique_ptr<CompilerDispatcherJob> job(new CompilerDispatcherJob( |
- i_isolate(), CreateSharedFunctionInfo(i_isolate(), &script), 100)); |
+ i_isolate(), tracer(), CreateSharedFunctionInfo(i_isolate(), &script), |
+ 100)); |
job->PrepareToParseOnMainThread(); |
job->Parse(); |