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

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

Issue 949623006: Attach snapshot data blob to the isolate. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: 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
Index: test/cctest/test-serialize.cc
diff --git a/test/cctest/test-serialize.cc b/test/cctest/test-serialize.cc
index 9a348ad434d8fac5a7b02e20071ae86b2a674585..4b2f17428eb4ea89d49cecfbe2460384dd2fcbf1 100644
--- a/test/cctest/test-serialize.cc
+++ b/test/cctest/test-serialize.cc
@@ -175,7 +175,7 @@ Vector<const uint8_t> ConstructSource(Vector<const uint8_t> head,
// Test that the whole heap can be serialized.
UNINITIALIZED_TEST(Serialize) {
- if (!Snapshot::HaveASnapshotToStartFrom()) {
+ if (!Snapshot::HaveASnapshotToStartFrom(CcTest::i_isolate())) {
v8::Isolate::CreateParams params;
params.enable_serializer = true;
v8::Isolate* isolate = v8::Isolate::New(params);
@@ -186,7 +186,7 @@ UNINITIALIZED_TEST(Serialize) {
// Test that heap serialization is non-destructive.
UNINITIALIZED_TEST(SerializeTwice) {
- if (!Snapshot::HaveASnapshotToStartFrom()) {
+ if (!Snapshot::HaveASnapshotToStartFrom(CcTest::i_isolate())) {
v8::Isolate::CreateParams params;
params.enable_serializer = true;
v8::Isolate* isolate = v8::Isolate::New(params);
@@ -241,7 +241,7 @@ UNINITIALIZED_DEPENDENT_TEST(Deserialize, Serialize) {
// The serialize-deserialize tests only work if the VM is built without
// serialization. That doesn't matter. We don't need to be able to
// serialize a snapshot in a VM that is booted from a snapshot.
- if (!Snapshot::HaveASnapshotToStartFrom()) {
+ if (!Snapshot::HaveASnapshotToStartFrom(CcTest::i_isolate())) {
v8::Isolate* isolate = Deserialize();
{
v8::HandleScope handle_scope(isolate);
@@ -259,7 +259,7 @@ UNINITIALIZED_DEPENDENT_TEST(Deserialize, Serialize) {
UNINITIALIZED_DEPENDENT_TEST(DeserializeFromSecondSerialization,
SerializeTwice) {
- if (!Snapshot::HaveASnapshotToStartFrom()) {
+ if (!Snapshot::HaveASnapshotToStartFrom(CcTest::i_isolate())) {
v8::Isolate* isolate = Deserialize();
{
v8::Isolate::Scope isolate_scope(isolate);
@@ -276,7 +276,7 @@ UNINITIALIZED_DEPENDENT_TEST(DeserializeFromSecondSerialization,
UNINITIALIZED_DEPENDENT_TEST(DeserializeAndRunScript2, Serialize) {
- if (!Snapshot::HaveASnapshotToStartFrom()) {
+ if (!Snapshot::HaveASnapshotToStartFrom(CcTest::i_isolate())) {
v8::Isolate* isolate = Deserialize();
{
v8::Isolate::Scope isolate_scope(isolate);
@@ -298,7 +298,7 @@ UNINITIALIZED_DEPENDENT_TEST(DeserializeAndRunScript2, Serialize) {
UNINITIALIZED_DEPENDENT_TEST(DeserializeFromSecondSerializationAndRunScript2,
SerializeTwice) {
- if (!Snapshot::HaveASnapshotToStartFrom()) {
+ if (!Snapshot::HaveASnapshotToStartFrom(CcTest::i_isolate())) {
v8::Isolate* isolate = Deserialize();
{
v8::Isolate::Scope isolate_scope(isolate);
@@ -318,7 +318,7 @@ UNINITIALIZED_DEPENDENT_TEST(DeserializeFromSecondSerializationAndRunScript2,
UNINITIALIZED_TEST(PartialSerialization) {
- if (!Snapshot::HaveASnapshotToStartFrom()) {
+ if (!Snapshot::HaveASnapshotToStartFrom(CcTest::i_isolate())) {
v8::Isolate::CreateParams params;
params.enable_serializer = true;
v8::Isolate* v8_isolate = v8::Isolate::New(params);
@@ -391,7 +391,7 @@ UNINITIALIZED_TEST(PartialSerialization) {
UNINITIALIZED_DEPENDENT_TEST(PartialDeserialization, PartialSerialization) {
- if (!Snapshot::HaveASnapshotToStartFrom()) {
+ if (!Snapshot::HaveASnapshotToStartFrom(CcTest::i_isolate())) {
int file_name_length = StrLength(FLAG_testing_serialization_file) + 10;
Vector<char> startup_name = Vector<char>::New(file_name_length + 1);
SNPrintF(startup_name, "%s.startup", FLAG_testing_serialization_file);
@@ -441,7 +441,7 @@ UNINITIALIZED_DEPENDENT_TEST(PartialDeserialization, PartialSerialization) {
UNINITIALIZED_TEST(ContextSerialization) {
- if (!Snapshot::HaveASnapshotToStartFrom()) {
+ if (!Snapshot::HaveASnapshotToStartFrom(CcTest::i_isolate())) {
v8::Isolate::CreateParams params;
params.enable_serializer = true;
v8::Isolate* v8_isolate = v8::Isolate::New(params);
@@ -508,7 +508,7 @@ UNINITIALIZED_TEST(ContextSerialization) {
UNINITIALIZED_DEPENDENT_TEST(ContextDeserialization, ContextSerialization) {
- if (!Snapshot::HaveASnapshotToStartFrom()) {
+ if (!Snapshot::HaveASnapshotToStartFrom(CcTest::i_isolate())) {
int file_name_length = StrLength(FLAG_testing_serialization_file) + 10;
Vector<char> startup_name = Vector<char>::New(file_name_length + 1);
SNPrintF(startup_name, "%s.startup", FLAG_testing_serialization_file);
@@ -558,7 +558,7 @@ UNINITIALIZED_DEPENDENT_TEST(ContextDeserialization, ContextSerialization) {
UNINITIALIZED_TEST(CustomContextSerialization) {
- if (!Snapshot::HaveASnapshotToStartFrom()) {
+ if (!Snapshot::HaveASnapshotToStartFrom(CcTest::i_isolate())) {
v8::Isolate::CreateParams params;
params.enable_serializer = true;
v8::Isolate* v8_isolate = v8::Isolate::New(params);
@@ -646,7 +646,7 @@ UNINITIALIZED_TEST(CustomContextSerialization) {
UNINITIALIZED_DEPENDENT_TEST(CustomContextDeserialization,
CustomContextSerialization) {
FLAG_crankshaft = false;
- if (!Snapshot::HaveASnapshotToStartFrom()) {
+ if (!Snapshot::HaveASnapshotToStartFrom(CcTest::i_isolate())) {
int file_name_length = StrLength(FLAG_testing_serialization_file) + 10;
Vector<char> startup_name = Vector<char>::New(file_name_length + 1);
SNPrintF(startup_name, "%s.startup", FLAG_testing_serialization_file);
@@ -704,6 +704,49 @@ UNINITIALIZED_DEPENDENT_TEST(CustomContextDeserialization,
}
+TEST(PerIsolateSnapshotBlobs) {
+ // Disable experimental natives that are loaded after desrialization.
vogelheim 2015/02/24 15:16:31 nitpick: desrialization => deserialization
Yang 2015/02/25 08:19:20 Done.
+ FLAG_harmony_shipping = false;
+ FlagList::EnforceFlagImplications();
+
+ const char* source1 = "function f() { return 42; }";
+ const char* source2 =
+ "function f() { return g() * 2; }"
+ "function g() { return 43; }";
+
+ v8::StartupData data1 = v8::V8::CreateSnapshotDataBlob(source1);
+ v8::StartupData data2 = v8::V8::CreateSnapshotDataBlob(source2);
+
+ v8::Isolate::CreateParams params1;
+ params1.snapshot_blob = &data1;
+ v8::Isolate* isolate1 = v8::Isolate::New(params1);
+ {
+ v8::Isolate::Scope i_scope(isolate1);
+ v8::HandleScope h_scope(isolate1);
+ v8::Local<v8::Context> context = v8::Context::New(isolate1);
+ delete data1.data; // We can dispose of the snapshot blob now.
+ v8::Context::Scope c_scope(context);
+ CHECK_EQ(42, CompileRun("f()")->ToInt32(isolate1)->Int32Value());
+ CHECK(CompileRun("this.g")->IsUndefined());
+ }
+ isolate1->Dispose();
+
+ v8::Isolate::CreateParams params2;
+ params2.snapshot_blob = &data2;
+ v8::Isolate* isolate2 = v8::Isolate::New(params2);
+ {
+ v8::Isolate::Scope i_scope(isolate2);
+ v8::HandleScope h_scope(isolate2);
+ v8::Local<v8::Context> context = v8::Context::New(isolate2);
+ delete data2.data; // We can dispose of the snapshot blob now.
+ v8::Context::Scope c_scope(context);
+ CHECK_EQ(86, CompileRun("f()")->ToInt32(isolate2)->Int32Value());
+ CHECK_EQ(43, CompileRun("g()")->ToInt32(isolate2)->Int32Value());
+ }
+ isolate2->Dispose();
+}
+
+
TEST(TestThatAlwaysSucceeds) {
}
« src/snapshot.h ('K') | « test/cctest/test-heap.cc ('k') | test/cctest/test-spaces.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698