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

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

Issue 1256503004: Version 4.4.63.24 (cherry-pick) (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@4.4
Patch Set: Created 5 years, 5 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/snapshot/serialize.cc ('k') | no next file » | 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 1ed43ac338aa78b294b52412e33e9131bc0855b1..938178efb96107375772cf3d9a92d06a936840df 100644
--- a/test/cctest/test-serialize.cc
+++ b/test/cctest/test-serialize.cc
@@ -329,7 +329,7 @@ UNINITIALIZED_TEST(PartialSerialization) {
&partial_sink);
partial_serializer.Serialize(&raw_foo);
- startup_serializer.SerializeWeakReferences();
+ startup_serializer.SerializeWeakReferencesAndDeferred();
SnapshotData startup_snapshot(startup_serializer);
SnapshotData partial_snapshot(partial_serializer);
@@ -447,7 +447,7 @@ UNINITIALIZED_TEST(ContextSerialization) {
PartialSerializer partial_serializer(isolate, &startup_serializer,
&partial_sink);
partial_serializer.Serialize(&raw_context);
- startup_serializer.SerializeWeakReferences();
+ startup_serializer.SerializeWeakReferencesAndDeferred();
SnapshotData startup_snapshot(startup_serializer);
SnapshotData partial_snapshot(partial_serializer);
@@ -582,7 +582,7 @@ UNINITIALIZED_TEST(CustomContextSerialization) {
PartialSerializer partial_serializer(isolate, &startup_serializer,
&partial_sink);
partial_serializer.Serialize(&raw_context);
- startup_serializer.SerializeWeakReferences();
+ startup_serializer.SerializeWeakReferencesAndDeferred();
SnapshotData startup_snapshot(startup_serializer);
SnapshotData partial_snapshot(partial_serializer);
@@ -702,6 +702,57 @@ TEST(PerIsolateSnapshotBlobs) {
}
+static void SerializationFunctionTemplate(
+ const v8::FunctionCallbackInfo<v8::Value>& args) {
+ args.GetReturnValue().Set(args[0]);
+}
+
+
+TEST(PerIsolateSnapshotBlobsOutdatedContextWithOverflow) {
+ DisableTurbofan();
+
+ const char* source1 =
+ "var o = {};"
+ "(function() {"
+ " function f1(x) { return f2(x) instanceof Array; }"
+ " function f2(x) { return foo.bar(x); }"
+ " o.a = f2.bind(null);"
+ " o.b = 1;"
+ " o.c = 2;"
+ " o.d = 3;"
+ " o.e = 4;"
+ "})();\n";
+
+ const char* source2 = "o.a(42)";
+
+ v8::StartupData data = v8::V8::CreateSnapshotDataBlob(source1);
+
+ v8::Isolate::CreateParams params;
+ params.snapshot_blob = &data;
+ params.array_buffer_allocator = CcTest::array_buffer_allocator();
+
+ v8::Isolate* isolate = v8::Isolate::New(params);
+ {
+ v8::Isolate::Scope i_scope(isolate);
+ v8::HandleScope h_scope(isolate);
+
+ v8::Local<v8::ObjectTemplate> global = v8::ObjectTemplate::New(isolate);
+ v8::Local<v8::ObjectTemplate> property = v8::ObjectTemplate::New(isolate);
+ v8::Local<v8::FunctionTemplate> function =
+ v8::FunctionTemplate::New(isolate, SerializationFunctionTemplate);
+ property->Set(isolate, "bar", function);
+ global->Set(isolate, "foo", property);
+
+ v8::Local<v8::Context> context = v8::Context::New(isolate, NULL, global);
+ delete[] data.data; // We can dispose of the snapshot blob now.
+ v8::Context::Scope c_scope(context);
+ v8::Local<v8::Value> result = CompileRun(source2);
+ CHECK(v8_str("42")->Equals(result));
+ }
+ isolate->Dispose();
+}
+
+
TEST(PerIsolateSnapshotBlobsWithLocker) {
DisableTurbofan();
v8::Isolate::CreateParams create_params;
@@ -738,6 +789,44 @@ TEST(PerIsolateSnapshotBlobsWithLocker) {
}
+TEST(SnapshotBlobsStackOverflow) {
+ DisableTurbofan();
+ const char* source =
+ "var a = [0];"
+ "var b = a;"
+ "for (var i = 0; i < 10000; i++) {"
+ " var c = [i];"
+ " b.push(c);"
+ " b.push(c);"
+ " b = c;"
+ "}";
+
+ v8::StartupData data = v8::V8::CreateSnapshotDataBlob(source);
+
+ v8::Isolate::CreateParams params;
+ params.snapshot_blob = &data;
+ params.array_buffer_allocator = CcTest::array_buffer_allocator();
+
+ 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);
+ const char* test =
+ "var sum = 0;"
+ "while (a) {"
+ " sum += a[0];"
+ " a = a[1];"
+ "}"
+ "sum";
+ CHECK_EQ(9999 * 5000, CompileRun(test)->ToInt32(isolate)->Int32Value());
+ }
+ isolate->Dispose();
+}
+
+
TEST(TestThatAlwaysSucceeds) {
}
« no previous file with comments | « src/snapshot/serialize.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698