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

Unified Diff: test/cctest/test-serialize.cc

Issue 976623002: Serializer: correctly deal with internal references. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: argh I keep making mistakes. Created 5 years, 10 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/x87/assembler-x87-inl.h ('k') | test/mjsunit/mjsunit.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-serialize.cc
diff --git a/test/cctest/test-serialize.cc b/test/cctest/test-serialize.cc
index e16be9775c582d925ec5c6c6e43fe116c46672f4..82ddcbce0dfe8ae26f2333c76972f86632019008 100644
--- a/test/cctest/test-serialize.cc
+++ b/test/cctest/test-serialize.cc
@@ -706,10 +706,14 @@ UNINITIALIZED_DEPENDENT_TEST(CustomContextDeserialization,
TEST(PerIsolateSnapshotBlobs) {
+ const char* flag = "--turbo-filter=\"\"";
+ FlagList::SetFlagsFromString(flag, StrLength(flag));
+
const char* source1 = "function f() { return 42; }";
const char* source2 =
"function f() { return g() * 2; }"
- "function g() { return 43; }";
+ "function g() { return 43; }"
+ "/./.test('a')";
v8::StartupData data1 = v8::V8::CreateSnapshotDataBlob(source1);
v8::StartupData data2 = v8::V8::CreateSnapshotDataBlob(source2);
@@ -1495,3 +1499,52 @@ TEST(SerializeWithHarmonyScoping) {
}
isolate2->Dispose();
}
+
+
+TEST(SerializeInternalReference) {
+ // Disable experimental natives that are loaded after deserialization.
+ FLAG_turbo_deoptimization = false;
+ FLAG_context_specialization = false;
+ FLAG_always_opt = true;
+ const char* flag = "--turbo-filter=foo";
+ FlagList::SetFlagsFromString(flag, StrLength(flag));
+
+ const char* source =
+ "var foo = (function(stdlib, foreign, heap) {"
+ " function foo(i) {"
+ " i = i|0;"
+ " var j = 0;"
+ " switch (i) {"
+ " case 0:"
+ " case 1: j = 1; break;"
+ " case 2:"
+ " case 3: j = 2; break;"
+ " case 4:"
+ " case 5: j = 3; break;"
+ " default: j = 0; break;"
+ " }"
+ " return j|0;"
+ " }"
+ " return { foo: foo };"
+ "})(this, {}, undefined).foo;"
+ "foo(1);";
+
+ v8::StartupData data = v8::V8::CreateSnapshotDataBlob(source);
+ CHECK(data.data);
+
+ v8::Isolate::CreateParams params;
+ params.snapshot_blob = &data;
+ v8::Isolate* isolate = v8::Isolate::New(params);
+ {
+ v8::Isolate::Scope i_scope(isolate);
+ v8::HandleScope h_scope(isolate);
+ v8::Local<v8::Context> context = v8::Context::New(isolate);
+ delete[] data.data; // We can dispose of the snapshot blob now.
+ v8::Context::Scope c_scope(context);
+ v8::Handle<v8::Function> foo =
+ v8::Handle<v8::Function>::Cast(CompileRun("foo"));
+ CHECK(v8::Utils::OpenHandle(*foo)->code()->is_turbofanned());
+ CHECK_EQ(3, CompileRun("foo(4)")->ToInt32(isolate)->Int32Value());
+ }
+ isolate->Dispose();
+}
« no previous file with comments | « src/x87/assembler-x87-inl.h ('k') | test/mjsunit/mjsunit.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698