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

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

Issue 1753803003: [test] Remove dependent commands. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Coding Created 4 years, 9 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 unified diff | Download patch
« no previous file with comments | « test/cctest/heap/heap-tester.h ('k') | test/cctest/testcfg.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 #ifdef VERIFY_HEAP 191 #ifdef VERIFY_HEAP
192 isolate->heap()->Verify(); 192 isolate->heap()->Verify();
193 #endif 193 #endif
194 CHECK(isolate->global_object()->IsJSObject()); 194 CHECK(isolate->global_object()->IsJSObject());
195 CHECK(isolate->native_context()->IsContext()); 195 CHECK(isolate->native_context()->IsContext());
196 CHECK(isolate->heap()->string_table()->IsStringTable()); 196 CHECK(isolate->heap()->string_table()->IsStringTable());
197 isolate->factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR("Empty")); 197 isolate->factory()->InternalizeOneByteString(STATIC_CHAR_VECTOR("Empty"));
198 } 198 }
199 199
200 200
201 UNINITIALIZED_DEPENDENT_TEST(Deserialize, Serialize) { 201 UNINITIALIZED_TEST(Deserialize) {
202 // The serialize-deserialize tests only work if the VM is built without 202 // The serialize-deserialize tests only work if the VM is built without
203 // serialization. That doesn't matter. We don't need to be able to 203 // serialization. That doesn't matter. We don't need to be able to
204 // serialize a snapshot in a VM that is booted from a snapshot. 204 // serialize a snapshot in a VM that is booted from a snapshot.
205 DisableTurbofan(); 205 DisableTurbofan();
206 if (DefaultSnapshotAvailable()) return; 206 if (DefaultSnapshotAvailable()) return;
207 v8::Isolate* isolate = Deserialize(); 207 v8::Isolate* isolate = TestIsolate::NewInitialized(true);
208 Serialize(isolate);
209 isolate = Deserialize();
208 { 210 {
209 v8::HandleScope handle_scope(isolate); 211 v8::HandleScope handle_scope(isolate);
210 v8::Isolate::Scope isolate_scope(isolate); 212 v8::Isolate::Scope isolate_scope(isolate);
211 213
212 v8::Local<v8::Context> env = v8::Context::New(isolate); 214 v8::Local<v8::Context> env = v8::Context::New(isolate);
213 env->Enter(); 215 env->Enter();
214 216
215 SanityCheck(isolate); 217 SanityCheck(isolate);
216 } 218 }
217 isolate->Dispose(); 219 isolate->Dispose();
218 } 220 }
219 221
220 222
221 UNINITIALIZED_DEPENDENT_TEST(DeserializeFromSecondSerialization, 223 UNINITIALIZED_TEST(DeserializeFromSecondSerialization) {
222 SerializeTwice) {
223 DisableTurbofan(); 224 DisableTurbofan();
224 if (DefaultSnapshotAvailable()) return; 225 if (DefaultSnapshotAvailable()) return;
225 v8::Isolate* isolate = Deserialize(); 226 v8::Isolate* isolate = TestIsolate::NewInitialized(true);
227 Serialize(isolate);
228 Serialize(isolate);
229 isolate = Deserialize();
226 { 230 {
227 v8::Isolate::Scope isolate_scope(isolate); 231 v8::Isolate::Scope isolate_scope(isolate);
228 v8::HandleScope handle_scope(isolate); 232 v8::HandleScope handle_scope(isolate);
229 233
230 v8::Local<v8::Context> env = v8::Context::New(isolate); 234 v8::Local<v8::Context> env = v8::Context::New(isolate);
231 env->Enter(); 235 env->Enter();
232 236
233 SanityCheck(isolate); 237 SanityCheck(isolate);
234 } 238 }
235 isolate->Dispose(); 239 isolate->Dispose();
236 } 240 }
237 241
238 242
239 UNINITIALIZED_DEPENDENT_TEST(DeserializeAndRunScript2, Serialize) { 243 UNINITIALIZED_TEST(DeserializeAndRunScript2) {
240 DisableTurbofan(); 244 DisableTurbofan();
241 if (DefaultSnapshotAvailable()) return; 245 if (DefaultSnapshotAvailable()) return;
242 v8::Isolate* isolate = Deserialize(); 246 v8::Isolate* isolate = TestIsolate::NewInitialized(true);
247 Serialize(isolate);
Michael Achenbach 2016/03/02 11:22:47 FYI: The old "Serialize" test doesn't call isolate
248 isolate = Deserialize();
243 { 249 {
244 v8::Isolate::Scope isolate_scope(isolate); 250 v8::Isolate::Scope isolate_scope(isolate);
245 v8::HandleScope handle_scope(isolate); 251 v8::HandleScope handle_scope(isolate);
246 252
247 253
248 v8::Local<v8::Context> env = v8::Context::New(isolate); 254 v8::Local<v8::Context> env = v8::Context::New(isolate);
249 env->Enter(); 255 env->Enter();
250 256
251 const char* c_source = "\"1234\".length"; 257 const char* c_source = "\"1234\".length";
252 v8::Local<v8::Script> script = v8_compile(c_source); 258 v8::Local<v8::Script> script = v8_compile(c_source);
253 v8::Maybe<int32_t> result = script->Run(isolate->GetCurrentContext()) 259 v8::Maybe<int32_t> result = script->Run(isolate->GetCurrentContext())
254 .ToLocalChecked() 260 .ToLocalChecked()
255 ->Int32Value(isolate->GetCurrentContext()); 261 ->Int32Value(isolate->GetCurrentContext());
256 CHECK_EQ(4, result.FromJust()); 262 CHECK_EQ(4, result.FromJust());
257 } 263 }
258 isolate->Dispose(); 264 isolate->Dispose();
259 } 265 }
260 266
261 267
262 UNINITIALIZED_DEPENDENT_TEST(DeserializeFromSecondSerializationAndRunScript2, 268 UNINITIALIZED_TEST(DeserializeFromSecondSerializationAndRunScript2) {
263 SerializeTwice) {
264 DisableTurbofan(); 269 DisableTurbofan();
265 if (DefaultSnapshotAvailable()) return; 270 if (DefaultSnapshotAvailable()) return;
266 v8::Isolate* isolate = Deserialize(); 271 v8::Isolate* isolate = TestIsolate::NewInitialized(true);
272 Serialize(isolate);
273 Serialize(isolate);
274 isolate = Deserialize();
267 { 275 {
268 v8::Isolate::Scope isolate_scope(isolate); 276 v8::Isolate::Scope isolate_scope(isolate);
269 v8::HandleScope handle_scope(isolate); 277 v8::HandleScope handle_scope(isolate);
270 278
271 v8::Local<v8::Context> env = v8::Context::New(isolate); 279 v8::Local<v8::Context> env = v8::Context::New(isolate);
272 env->Enter(); 280 env->Enter();
273 281
274 const char* c_source = "\"1234\".length"; 282 const char* c_source = "\"1234\".length";
275 v8::Local<v8::Script> script = v8_compile(c_source); 283 v8::Local<v8::Script> script = v8_compile(c_source);
276 v8::Maybe<int32_t> result = script->Run(isolate->GetCurrentContext()) 284 v8::Maybe<int32_t> result = script->Run(isolate->GetCurrentContext())
277 .ToLocalChecked() 285 .ToLocalChecked()
278 ->Int32Value(isolate->GetCurrentContext()); 286 ->Int32Value(isolate->GetCurrentContext());
279 CHECK_EQ(4, result.FromJust()); 287 CHECK_EQ(4, result.FromJust());
280 } 288 }
281 isolate->Dispose(); 289 isolate->Dispose();
282 } 290 }
283 291
284 292 static void PartiallySerialize() {
285 UNINITIALIZED_TEST(PartialSerialization) {
286 DisableTurbofan();
287 if (DefaultSnapshotAvailable()) return;
288 v8::Isolate* v8_isolate = TestIsolate::NewInitialized(true); 293 v8::Isolate* v8_isolate = TestIsolate::NewInitialized(true);
289 Isolate* isolate = reinterpret_cast<Isolate*>(v8_isolate); 294 Isolate* isolate = reinterpret_cast<Isolate*>(v8_isolate);
290 v8_isolate->Enter(); 295 v8_isolate->Enter();
291 { 296 {
292 Heap* heap = isolate->heap(); 297 Heap* heap = isolate->heap();
293 298
294 v8::Persistent<v8::Context> env; 299 v8::Persistent<v8::Context> env;
295 { 300 {
296 HandleScope scope(isolate); 301 HandleScope scope(isolate);
297 env.Reset(v8_isolate, v8::Context::New(v8_isolate)); 302 env.Reset(v8_isolate, v8::Context::New(v8_isolate));
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 WritePayload(partial_snapshot.RawData(), FLAG_testing_serialization_file); 351 WritePayload(partial_snapshot.RawData(), FLAG_testing_serialization_file);
347 WritePayload(startup_snapshot.RawData(), startup_name.start()); 352 WritePayload(startup_snapshot.RawData(), startup_name.start());
348 353
349 startup_name.Dispose(); 354 startup_name.Dispose();
350 } 355 }
351 v8_isolate->Exit(); 356 v8_isolate->Exit();
352 v8_isolate->Dispose(); 357 v8_isolate->Dispose();
353 } 358 }
354 359
355 360
356 UNINITIALIZED_DEPENDENT_TEST(PartialDeserialization, PartialSerialization) { 361 UNINITIALIZED_TEST(PartialSerialization) {
357 DisableTurbofan(); 362 DisableTurbofan();
358 if (DefaultSnapshotAvailable()) return; 363 if (DefaultSnapshotAvailable()) return;
364 PartiallySerialize();
Michael Achenbach 2016/03/02 11:22:47 For all serialize/deserialize pairs: Do we want th
365 }
366
367
368 UNINITIALIZED_TEST(PartialDeserialization) {
369 DisableTurbofan();
370 if (DefaultSnapshotAvailable()) return;
371 PartiallySerialize();
359 int file_name_length = StrLength(FLAG_testing_serialization_file) + 10; 372 int file_name_length = StrLength(FLAG_testing_serialization_file) + 10;
360 Vector<char> startup_name = Vector<char>::New(file_name_length + 1); 373 Vector<char> startup_name = Vector<char>::New(file_name_length + 1);
361 SNPrintF(startup_name, "%s.startup", FLAG_testing_serialization_file); 374 SNPrintF(startup_name, "%s.startup", FLAG_testing_serialization_file);
362 375
363 v8::Isolate* v8_isolate = InitializeFromFile(startup_name.start()); 376 v8::Isolate* v8_isolate = InitializeFromFile(startup_name.start());
364 CHECK(v8_isolate); 377 CHECK(v8_isolate);
365 startup_name.Dispose(); 378 startup_name.Dispose();
366 { 379 {
367 v8::Isolate::Scope isolate_scope(v8_isolate); 380 v8::Isolate::Scope isolate_scope(v8_isolate);
368 381
(...skipping 24 matching lines...) Expand all
393 .ToHandleChecked(); 406 .ToHandleChecked();
394 CHECK(root2->IsString()); 407 CHECK(root2->IsString());
395 CHECK(root.is_identical_to(root2)); 408 CHECK(root.is_identical_to(root2));
396 } 409 }
397 410
398 DeleteArray(snapshot); 411 DeleteArray(snapshot);
399 } 412 }
400 v8_isolate->Dispose(); 413 v8_isolate->Dispose();
401 } 414 }
402 415
403 416 static void SerializeContext() {
404 UNINITIALIZED_TEST(ContextSerialization) {
405 DisableTurbofan();
406 if (DefaultSnapshotAvailable()) return;
407 v8::Isolate* v8_isolate = TestIsolate::NewInitialized(true); 417 v8::Isolate* v8_isolate = TestIsolate::NewInitialized(true);
408 Isolate* isolate = reinterpret_cast<Isolate*>(v8_isolate); 418 Isolate* isolate = reinterpret_cast<Isolate*>(v8_isolate);
409 Heap* heap = isolate->heap(); 419 Heap* heap = isolate->heap();
410 { 420 {
411 v8::Isolate::Scope isolate_scope(v8_isolate); 421 v8::Isolate::Scope isolate_scope(v8_isolate);
412 422
413 v8::Persistent<v8::Context> env; 423 v8::Persistent<v8::Context> env;
414 { 424 {
415 HandleScope scope(isolate); 425 HandleScope scope(isolate);
416 env.Reset(v8_isolate, v8::Context::New(v8_isolate)); 426 env.Reset(v8_isolate, v8::Context::New(v8_isolate));
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 469
460 WritePayload(partial_snapshot.RawData(), FLAG_testing_serialization_file); 470 WritePayload(partial_snapshot.RawData(), FLAG_testing_serialization_file);
461 WritePayload(startup_snapshot.RawData(), startup_name.start()); 471 WritePayload(startup_snapshot.RawData(), startup_name.start());
462 472
463 startup_name.Dispose(); 473 startup_name.Dispose();
464 } 474 }
465 v8_isolate->Dispose(); 475 v8_isolate->Dispose();
466 } 476 }
467 477
468 478
469 UNINITIALIZED_DEPENDENT_TEST(ContextDeserialization, ContextSerialization) { 479 UNINITIALIZED_TEST(ContextSerialization) {
470 DisableTurbofan(); 480 DisableTurbofan();
471 if (DefaultSnapshotAvailable()) return; 481 if (DefaultSnapshotAvailable()) return;
482 SerializeContext();
483 }
484
485
486 UNINITIALIZED_TEST(ContextDeserialization) {
487 DisableTurbofan();
488 if (DefaultSnapshotAvailable()) return;
489 SerializeContext();
472 int file_name_length = StrLength(FLAG_testing_serialization_file) + 10; 490 int file_name_length = StrLength(FLAG_testing_serialization_file) + 10;
473 Vector<char> startup_name = Vector<char>::New(file_name_length + 1); 491 Vector<char> startup_name = Vector<char>::New(file_name_length + 1);
474 SNPrintF(startup_name, "%s.startup", FLAG_testing_serialization_file); 492 SNPrintF(startup_name, "%s.startup", FLAG_testing_serialization_file);
475 493
476 v8::Isolate* v8_isolate = InitializeFromFile(startup_name.start()); 494 v8::Isolate* v8_isolate = InitializeFromFile(startup_name.start());
477 CHECK(v8_isolate); 495 CHECK(v8_isolate);
478 startup_name.Dispose(); 496 startup_name.Dispose();
479 { 497 {
480 v8::Isolate::Scope isolate_scope(v8_isolate); 498 v8::Isolate::Scope isolate_scope(v8_isolate);
481 499
(...skipping 24 matching lines...) Expand all
506 .ToHandleChecked(); 524 .ToHandleChecked();
507 CHECK(root2->IsContext()); 525 CHECK(root2->IsContext());
508 CHECK(!root.is_identical_to(root2)); 526 CHECK(!root.is_identical_to(root2));
509 } 527 }
510 DeleteArray(snapshot); 528 DeleteArray(snapshot);
511 } 529 }
512 v8_isolate->Dispose(); 530 v8_isolate->Dispose();
513 } 531 }
514 532
515 533
516 UNINITIALIZED_TEST(CustomContextSerialization) { 534 static void SerializeCustomContext() {
517 DisableTurbofan();
518 if (DefaultSnapshotAvailable()) return;
519 v8::Isolate* v8_isolate = TestIsolate::NewInitialized(true); 535 v8::Isolate* v8_isolate = TestIsolate::NewInitialized(true);
520 Isolate* isolate = reinterpret_cast<Isolate*>(v8_isolate); 536 Isolate* isolate = reinterpret_cast<Isolate*>(v8_isolate);
521 { 537 {
522 v8::Isolate::Scope isolate_scope(v8_isolate); 538 v8::Isolate::Scope isolate_scope(v8_isolate);
523 539
524 v8::Persistent<v8::Context> env; 540 v8::Persistent<v8::Context> env;
525 { 541 {
526 HandleScope scope(isolate); 542 HandleScope scope(isolate);
527 env.Reset(v8_isolate, v8::Context::New(v8_isolate)); 543 env.Reset(v8_isolate, v8::Context::New(v8_isolate));
528 } 544 }
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
590 606
591 WritePayload(partial_snapshot.RawData(), FLAG_testing_serialization_file); 607 WritePayload(partial_snapshot.RawData(), FLAG_testing_serialization_file);
592 WritePayload(startup_snapshot.RawData(), startup_name.start()); 608 WritePayload(startup_snapshot.RawData(), startup_name.start());
593 609
594 startup_name.Dispose(); 610 startup_name.Dispose();
595 } 611 }
596 v8_isolate->Dispose(); 612 v8_isolate->Dispose();
597 } 613 }
598 614
599 615
600 UNINITIALIZED_DEPENDENT_TEST(CustomContextDeserialization, 616
601 CustomContextSerialization) { 617 UNINITIALIZED_TEST(CustomContextSerialization) {
618 DisableTurbofan();
619 if (DefaultSnapshotAvailable()) return;
620 SerializeCustomContext();
621 }
622
623
624 UNINITIALIZED_TEST(CustomContextDeserialization) {
602 DisableTurbofan(); 625 DisableTurbofan();
603 FLAG_crankshaft = false; 626 FLAG_crankshaft = false;
604 if (DefaultSnapshotAvailable()) return; 627 if (DefaultSnapshotAvailable()) return;
628 SerializeCustomContext();
605 int file_name_length = StrLength(FLAG_testing_serialization_file) + 10; 629 int file_name_length = StrLength(FLAG_testing_serialization_file) + 10;
606 Vector<char> startup_name = Vector<char>::New(file_name_length + 1); 630 Vector<char> startup_name = Vector<char>::New(file_name_length + 1);
607 SNPrintF(startup_name, "%s.startup", FLAG_testing_serialization_file); 631 SNPrintF(startup_name, "%s.startup", FLAG_testing_serialization_file);
608 632
609 v8::Isolate* v8_isolate = InitializeFromFile(startup_name.start()); 633 v8::Isolate* v8_isolate = InitializeFromFile(startup_name.start());
610 CHECK(v8_isolate); 634 CHECK(v8_isolate);
611 startup_name.Dispose(); 635 startup_name.Dispose();
612 { 636 {
613 v8::Isolate::Scope isolate_scope(v8_isolate); 637 v8::Isolate::Scope isolate_scope(v8_isolate);
614 638
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
862 TEST(TestThatAlwaysSucceeds) { 886 TEST(TestThatAlwaysSucceeds) {
863 } 887 }
864 888
865 889
866 TEST(TestThatAlwaysFails) { 890 TEST(TestThatAlwaysFails) {
867 bool ArtificialFailure = false; 891 bool ArtificialFailure = false;
868 CHECK(ArtificialFailure); 892 CHECK(ArtificialFailure);
869 } 893 }
870 894
871 895
872 DEPENDENT_TEST(DependentTestThatAlwaysFails, TestThatAlwaysSucceeds) {
873 bool ArtificialFailure2 = false;
874 CHECK(ArtificialFailure2);
875 }
876
877
878 int CountBuiltins() { 896 int CountBuiltins() {
879 // Check that we have not deserialized any additional builtin. 897 // Check that we have not deserialized any additional builtin.
880 HeapIterator iterator(CcTest::heap()); 898 HeapIterator iterator(CcTest::heap());
881 DisallowHeapAllocation no_allocation; 899 DisallowHeapAllocation no_allocation;
882 int counter = 0; 900 int counter = 0;
883 for (HeapObject* obj = iterator.next(); obj != NULL; obj = iterator.next()) { 901 for (HeapObject* obj = iterator.next(); obj != NULL; obj = iterator.next()) {
884 if (obj->IsCode() && Code::cast(obj)->kind() == Code::BUILTIN) counter++; 902 if (obj->IsCode() && Code::cast(obj)->kind() == Code::BUILTIN) counter++;
885 } 903 }
886 return counter; 904 return counter;
887 } 905 }
(...skipping 880 matching lines...) Expand 10 before | Expand all | Expand 10 after
1768 delete script_data; 1786 delete script_data;
1769 } 1787 }
1770 1788
1771 1789
1772 TEST(SerializationMemoryStats) { 1790 TEST(SerializationMemoryStats) {
1773 FLAG_profile_deserialization = true; 1791 FLAG_profile_deserialization = true;
1774 FLAG_always_opt = false; 1792 FLAG_always_opt = false;
1775 v8::StartupData blob = v8::V8::CreateSnapshotDataBlob(); 1793 v8::StartupData blob = v8::V8::CreateSnapshotDataBlob();
1776 delete[] blob.data; 1794 delete[] blob.data;
1777 } 1795 }
OLDNEW
« no previous file with comments | « test/cctest/heap/heap-tester.h ('k') | test/cctest/testcfg.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698