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

Unified Diff: test/unittests/compiler-dispatcher/compiler-dispatcher-job-unittest.cc

Issue 2220463002: Hook up compiler dispatcher jobs to lazy parser. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: rebase Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/parsing/parser.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 d3beaeb3896828b8da67caf010f468978e1d7598..99272f000e306618463189ab48793ceb173b21e4 100644
--- a/test/unittests/compiler-dispatcher/compiler-dispatcher-job-unittest.cc
+++ b/test/unittests/compiler-dispatcher/compiler-dispatcher-job-unittest.cc
@@ -4,9 +4,13 @@
#include <memory>
+#include "include/v8.h"
+#include "src/api.h"
+#include "src/ast/scopes.h"
#include "src/compiler-dispatcher/compiler-dispatcher-job.h"
#include "src/flags.h"
#include "src/isolate-inl.h"
+#include "src/parsing/parser.h"
#include "test/unittests/test-utils.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -17,7 +21,7 @@ typedef TestWithContext CompilerDispatcherJobTest;
namespace {
-const char test_script[] = "x*x";
+const char test_script[] = "(x) { x*x; }";
class ScriptResource : public v8::String::ExternalOneByteStringResource {
public:
@@ -108,6 +112,44 @@ TEST_F(CompilerDispatcherJobTest, SyntaxError) {
job->ReportErrorsOnMainThread();
ASSERT_TRUE(job->status() == CompileJobStatus::kDone);
ASSERT_TRUE(i_isolate()->has_pending_exception());
+ i_isolate()->clear_pending_exception();
+}
+
+TEST_F(CompilerDispatcherJobTest, ScopeChain) {
+ const char script[] =
+ "function g() { var g = 1; function f(x) { return x * g }; return f; } "
+ "g();";
+ Handle<JSFunction> f = Handle<JSFunction>::cast(Utils::OpenHandle(
+ *v8::Script::Compile(isolate()->GetCurrentContext(),
+ v8::String::NewFromUtf8(isolate(), script,
+ v8::NewStringType::kNormal)
+ .ToLocalChecked())
+ .ToLocalChecked()
+ ->Run(isolate()->GetCurrentContext())
+ .ToLocalChecked()));
+
+ std::unique_ptr<CompilerDispatcherJob> job(
+ new CompilerDispatcherJob(i_isolate(), f, FLAG_stack_size));
+
+ job->PrepareToParseOnMainThread();
+ job->Parse();
+ job->FinalizeParsingOnMainThread();
+ ASSERT_TRUE(job->status() == CompileJobStatus::kReadyToCompile);
+
+ const AstRawString* var_x =
+ job->parse_info_->ast_value_factory()->GetOneByteString("x");
+ Variable* var = job->parse_info_->literal()->scope()->Lookup(var_x);
+ ASSERT_TRUE(var);
+ ASSERT_TRUE(var->IsUnallocated());
+
+ const AstRawString* var_g =
+ job->parse_info_->ast_value_factory()->GetOneByteString("g");
+ var = job->parse_info_->literal()->scope()->Lookup(var_g);
+ ASSERT_TRUE(var);
+ ASSERT_TRUE(var->IsContextSlot());
+
+ job->ResetOnMainThread();
+ ASSERT_TRUE(job->status() == CompileJobStatus::kInitial);
}
} // namespace internal
« no previous file with comments | « src/parsing/parser.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698