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

Side by Side Diff: test/cctest/test-serialize.cc

Issue 791723004: Reland "Use same blob format for internal and external snapshots." (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix Created 6 years 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 unified diff | Download patch
OLDNEW
1 // Copyright 2007-2010 the V8 project authors. All rights reserved. 1 // Copyright 2007-2010 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 181
182 //---------------------------------------------------------------------------- 182 //----------------------------------------------------------------------------
183 // Tests that the heap can be deserialized. 183 // Tests that the heap can be deserialized.
184 184
185 v8::Isolate* InitializeFromFile(const char* snapshot_file) { 185 v8::Isolate* InitializeFromFile(const char* snapshot_file) {
186 int len; 186 int len;
187 byte* str = ReadBytes(snapshot_file, &len); 187 byte* str = ReadBytes(snapshot_file, &len);
188 if (!str) return NULL; 188 if (!str) return NULL;
189 v8::Isolate* v8_isolate = NULL; 189 v8::Isolate* v8_isolate = NULL;
190 { 190 {
191 SnapshotData snapshot_data(str, len); 191 SnapshotData snapshot_data(Vector<const byte>(str, len));
192 Deserializer deserializer(&snapshot_data); 192 Deserializer deserializer(&snapshot_data);
193 Isolate* isolate = Isolate::NewForTesting(); 193 Isolate* isolate = Isolate::NewForTesting();
194 v8_isolate = reinterpret_cast<v8::Isolate*>(isolate); 194 v8_isolate = reinterpret_cast<v8::Isolate*>(isolate);
195 v8::Isolate::Scope isolate_scope(v8_isolate); 195 v8::Isolate::Scope isolate_scope(v8_isolate);
196 isolate->Init(&deserializer); 196 isolate->Init(&deserializer);
197 } 197 }
198 DeleteArray(str); 198 DeleteArray(str);
199 return v8_isolate; 199 return v8_isolate;
200 } 200 }
201 201
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 v8::Isolate::Scope isolate_scope(v8_isolate); 386 v8::Isolate::Scope isolate_scope(v8_isolate);
387 387
388 const char* file_name = FLAG_testing_serialization_file; 388 const char* file_name = FLAG_testing_serialization_file;
389 389
390 int snapshot_size = 0; 390 int snapshot_size = 0;
391 byte* snapshot = ReadBytes(file_name, &snapshot_size); 391 byte* snapshot = ReadBytes(file_name, &snapshot_size);
392 392
393 Isolate* isolate = reinterpret_cast<Isolate*>(v8_isolate); 393 Isolate* isolate = reinterpret_cast<Isolate*>(v8_isolate);
394 Object* root; 394 Object* root;
395 { 395 {
396 SnapshotData snapshot_data(snapshot, snapshot_size); 396 SnapshotData snapshot_data(Vector<const byte>(snapshot, snapshot_size));
397 Deserializer deserializer(&snapshot_data); 397 Deserializer deserializer(&snapshot_data);
398 deserializer.DeserializePartial(isolate, &root); 398 deserializer.DeserializePartial(isolate, &root);
399 CHECK(root->IsString()); 399 CHECK(root->IsString());
400 } 400 }
401 HandleScope handle_scope(isolate); 401 HandleScope handle_scope(isolate);
402 Handle<Object> root_handle(root, isolate); 402 Handle<Object> root_handle(root, isolate);
403 403
404 404
405 Object* root2; 405 Object* root2;
406 { 406 {
407 SnapshotData snapshot_data(snapshot, snapshot_size); 407 SnapshotData snapshot_data(Vector<const byte>(snapshot, snapshot_size));
408 Deserializer deserializer(&snapshot_data); 408 Deserializer deserializer(&snapshot_data);
409 deserializer.DeserializePartial(isolate, &root2); 409 deserializer.DeserializePartial(isolate, &root2);
410 CHECK(root2->IsString()); 410 CHECK(root2->IsString());
411 CHECK(*root_handle == root2); 411 CHECK(*root_handle == root2);
412 } 412 }
413 } 413 }
414 v8_isolate->Dispose(); 414 v8_isolate->Dispose();
415 } 415 }
416 } 416 }
417 417
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 v8::Isolate::Scope isolate_scope(v8_isolate); 496 v8::Isolate::Scope isolate_scope(v8_isolate);
497 497
498 const char* file_name = FLAG_testing_serialization_file; 498 const char* file_name = FLAG_testing_serialization_file;
499 499
500 int snapshot_size = 0; 500 int snapshot_size = 0;
501 byte* snapshot = ReadBytes(file_name, &snapshot_size); 501 byte* snapshot = ReadBytes(file_name, &snapshot_size);
502 502
503 Isolate* isolate = reinterpret_cast<Isolate*>(v8_isolate); 503 Isolate* isolate = reinterpret_cast<Isolate*>(v8_isolate);
504 Object* root; 504 Object* root;
505 { 505 {
506 SnapshotData snapshot_data(snapshot, snapshot_size); 506 SnapshotData snapshot_data(Vector<const byte>(snapshot, snapshot_size));
507 Deserializer deserializer(&snapshot_data); 507 Deserializer deserializer(&snapshot_data);
508 deserializer.DeserializePartial(isolate, &root); 508 deserializer.DeserializePartial(isolate, &root);
509 CHECK(root->IsContext()); 509 CHECK(root->IsContext());
510 } 510 }
511 HandleScope handle_scope(isolate); 511 HandleScope handle_scope(isolate);
512 Handle<Object> root_handle(root, isolate); 512 Handle<Object> root_handle(root, isolate);
513 513
514 514
515 Object* root2; 515 Object* root2;
516 { 516 {
517 SnapshotData snapshot_data(snapshot, snapshot_size); 517 SnapshotData snapshot_data(Vector<const byte>(snapshot, snapshot_size));
518 Deserializer deserializer(&snapshot_data); 518 Deserializer deserializer(&snapshot_data);
519 deserializer.DeserializePartial(isolate, &root2); 519 deserializer.DeserializePartial(isolate, &root2);
520 CHECK(root2->IsContext()); 520 CHECK(root2->IsContext());
521 CHECK(*root_handle != root2); 521 CHECK(*root_handle != root2);
522 } 522 }
523 } 523 }
524 v8_isolate->Dispose(); 524 v8_isolate->Dispose();
525 } 525 }
526 } 526 }
527 527
(...skipping 684 matching lines...) Expand 10 before | Expand all | Expand 10 after
1212 { 1212 {
1213 DisallowCompilation no_compile(reinterpret_cast<Isolate*>(isolate2)); 1213 DisallowCompilation no_compile(reinterpret_cast<Isolate*>(isolate2));
1214 script = v8::ScriptCompiler::CompileUnbound( 1214 script = v8::ScriptCompiler::CompileUnbound(
1215 isolate2, &source, v8::ScriptCompiler::kConsumeCodeCache); 1215 isolate2, &source, v8::ScriptCompiler::kConsumeCodeCache);
1216 } 1216 }
1217 v8::Local<v8::Value> result = script->BindToCurrentContext()->Run(); 1217 v8::Local<v8::Value> result = script->BindToCurrentContext()->Run();
1218 CHECK(result->ToString(isolate2)->Equals(v8_str("XY"))); 1218 CHECK(result->ToString(isolate2)->Equals(v8_str("XY")));
1219 } 1219 }
1220 isolate2->Dispose(); 1220 isolate2->Dispose();
1221 } 1221 }
OLDNEW
« src/snapshot-external.cc ('K') | « src/snapshot-source-sink.h ('k') | tools/gyp/v8.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698