Reviewers: vogelheim,
Message:
vogelheim, ptal at this easy cached data related fix.
Description:
Script streaming: don't produce (empty) cached data when debugger forces
eagerness.
See CompileTopLevel for similar logic which suppresses producing parser
cache
when the debugger is active.
BUG=441130
LOG=n
Please review this at https://codereview.chromium.org/845643005/
Base URL: https://chromium.googlesource.com/v8/v8.git@master
Affected files (+44, -0 lines):
M src/background-parsing-task.cc
M test/cctest/test-api.cc
Index: src/background-parsing-task.cc
diff --git a/src/background-parsing-task.cc b/src/background-parsing-task.cc
index
c7602a7defd7b698f7268b4d4b3ada4c1c4f3e71..6ac743e1e52322422eb3190e79879236551496ad
100644
--- a/src/background-parsing-task.cc
+++ b/src/background-parsing-task.cc
@@ -25,6 +25,11 @@ BackgroundParsingTask::BackgroundParsingTask(
options == ScriptCompiler::kNoCompileOptions);
source->allow_lazy =
!i::Compiler::DebuggerWantsEagerCompilation(source->info.get());
+
+ if (!source->allow_lazy && options_ ==
ScriptCompiler::kProduceParserCache) {
+ // Producing cached data while parsing eagerly is not supported.
+ options_ = ScriptCompiler::kNoCompileOptions;
+ }
source->hash_seed = isolate->heap()->HashSeed();
}
Index: test/cctest/test-api.cc
diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc
index
dbf1493034d469f726229e160fb6a090e6f4985b..5c8356ece6c1fe3465bd367eb360882888ca07a4
100644
--- a/test/cctest/test-api.cc
+++ b/test/cctest/test-api.cc
@@ -24422,6 +24422,45 @@ TEST(StreamingProducesParserCache) {
}
+TEST(StreamingWithDebuggingDoesNotProduceParserCache) {
+ // If the debugger is active, we should just not produce parser cache at
+ // all. This is a regeression test: We used to produce a parser cache
without
+ // any data in it (just headers).
+ i::FLAG_min_preparse_length = 0;
+ const char* chunks[] = {"function foo() { ret", "urn 13; } f", "oo(); ",
+ NULL};
+
+ LocalContext env;
+ v8::Isolate* isolate = env->GetIsolate();
+ v8::HandleScope scope(isolate);
+
+ // Make the debugger active by setting a breakpoint.
+ CompileRun("function break_here() { }");
+ i::Handle<i::JSFunction> func = i::Handle<i::JSFunction>::cast(
+ v8::Utils::OpenHandle(*env->Global()->Get(v8_str("break_here"))));
+ v8::internal::Debug* debug = CcTest::i_isolate()->debug();
+ int position;
+ debug->SetBreakPoint(func,
i::Handle<i::Object>(v8::internal::Smi::FromInt(1),
+ CcTest::i_isolate()),
+ &position);
+
+ v8::ScriptCompiler::StreamedSource source(
+ new TestSourceStream(chunks),
+ v8::ScriptCompiler::StreamedSource::ONE_BYTE);
+ v8::ScriptCompiler::ScriptStreamingTask* task =
+ v8::ScriptCompiler::StartStreamingScript(
+ isolate, &source, v8::ScriptCompiler::kProduceParserCache);
+
+ // TestSourceStream::GetMoreData won't block, so it's OK to just run the
+ // task here in the main thread.
+ task->Run();
+ delete task;
+
+ // Check that we got no cached data.
+ CHECK(source.GetCachedData() == NULL);
+}
+
+
TEST(StreamingScriptWithInvalidUtf8) {
// Regression test for a crash: test that invalid UTF-8 bytes in the end
of a
// chunk don't produce a crash.
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.