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

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: Format 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 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 v8::HandleScope scope(v8_isolate); 190 v8::HandleScope scope(v8_isolate);
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 UNINITIALIZED_TEST(Deserialize) {
201 UNINITIALIZED_DEPENDENT_TEST(Deserialize, Serialize) {
202 // The serialize-deserialize tests only work if the VM is built without 201 // 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 202 // 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. 203 // serialize a snapshot in a VM that is booted from a snapshot.
205 DisableTurbofan(); 204 DisableTurbofan();
206 if (DefaultSnapshotAvailable()) return; 205 if (DefaultSnapshotAvailable()) return;
207 v8::Isolate* isolate = Deserialize(); 206 v8::Isolate* isolate = TestIsolate::NewInitialized(true);
207 Serialize(isolate);
208 isolate = Deserialize();
208 { 209 {
209 v8::HandleScope handle_scope(isolate); 210 v8::HandleScope handle_scope(isolate);
210 v8::Isolate::Scope isolate_scope(isolate); 211 v8::Isolate::Scope isolate_scope(isolate);
211 212
212 v8::Local<v8::Context> env = v8::Context::New(isolate); 213 v8::Local<v8::Context> env = v8::Context::New(isolate);
213 env->Enter(); 214 env->Enter();
214 215
215 SanityCheck(isolate); 216 SanityCheck(isolate);
216 } 217 }
217 isolate->Dispose(); 218 isolate->Dispose();
218 } 219 }
219 220
220 221 UNINITIALIZED_TEST(DeserializeFromSecondSerialization) {
221 UNINITIALIZED_DEPENDENT_TEST(DeserializeFromSecondSerialization,
222 SerializeTwice) {
223 DisableTurbofan(); 222 DisableTurbofan();
224 if (DefaultSnapshotAvailable()) return; 223 if (DefaultSnapshotAvailable()) return;
225 v8::Isolate* isolate = Deserialize(); 224 v8::Isolate* isolate = TestIsolate::NewInitialized(true);
225 Serialize(isolate);
226 Serialize(isolate);
227 isolate = Deserialize();
226 { 228 {
227 v8::Isolate::Scope isolate_scope(isolate); 229 v8::Isolate::Scope isolate_scope(isolate);
228 v8::HandleScope handle_scope(isolate); 230 v8::HandleScope handle_scope(isolate);
229 231
230 v8::Local<v8::Context> env = v8::Context::New(isolate); 232 v8::Local<v8::Context> env = v8::Context::New(isolate);
231 env->Enter(); 233 env->Enter();
232 234
233 SanityCheck(isolate); 235 SanityCheck(isolate);
234 } 236 }
235 isolate->Dispose(); 237 isolate->Dispose();
236 } 238 }
237 239
238 240 UNINITIALIZED_TEST(DeserializeAndRunScript2) {
239 UNINITIALIZED_DEPENDENT_TEST(DeserializeAndRunScript2, Serialize) {
240 DisableTurbofan(); 241 DisableTurbofan();
241 if (DefaultSnapshotAvailable()) return; 242 if (DefaultSnapshotAvailable()) return;
242 v8::Isolate* isolate = Deserialize(); 243 v8::Isolate* isolate = TestIsolate::NewInitialized(true);
244 Serialize(isolate);
245 isolate = Deserialize();
243 { 246 {
244 v8::Isolate::Scope isolate_scope(isolate); 247 v8::Isolate::Scope isolate_scope(isolate);
245 v8::HandleScope handle_scope(isolate); 248 v8::HandleScope handle_scope(isolate);
246 249
247 250
248 v8::Local<v8::Context> env = v8::Context::New(isolate); 251 v8::Local<v8::Context> env = v8::Context::New(isolate);
249 env->Enter(); 252 env->Enter();
250 253
251 const char* c_source = "\"1234\".length"; 254 const char* c_source = "\"1234\".length";
252 v8::Local<v8::Script> script = v8_compile(c_source); 255 v8::Local<v8::Script> script = v8_compile(c_source);
253 v8::Maybe<int32_t> result = script->Run(isolate->GetCurrentContext()) 256 v8::Maybe<int32_t> result = script->Run(isolate->GetCurrentContext())
254 .ToLocalChecked() 257 .ToLocalChecked()
255 ->Int32Value(isolate->GetCurrentContext()); 258 ->Int32Value(isolate->GetCurrentContext());
256 CHECK_EQ(4, result.FromJust()); 259 CHECK_EQ(4, result.FromJust());
257 } 260 }
258 isolate->Dispose(); 261 isolate->Dispose();
259 } 262 }
260 263
261 264 UNINITIALIZED_TEST(DeserializeFromSecondSerializationAndRunScript2) {
262 UNINITIALIZED_DEPENDENT_TEST(DeserializeFromSecondSerializationAndRunScript2,
263 SerializeTwice) {
264 DisableTurbofan(); 265 DisableTurbofan();
265 if (DefaultSnapshotAvailable()) return; 266 if (DefaultSnapshotAvailable()) return;
266 v8::Isolate* isolate = Deserialize(); 267 v8::Isolate* isolate = TestIsolate::NewInitialized(true);
268 Serialize(isolate);
269 Serialize(isolate);
270 isolate = Deserialize();
267 { 271 {
268 v8::Isolate::Scope isolate_scope(isolate); 272 v8::Isolate::Scope isolate_scope(isolate);
269 v8::HandleScope handle_scope(isolate); 273 v8::HandleScope handle_scope(isolate);
270 274
271 v8::Local<v8::Context> env = v8::Context::New(isolate); 275 v8::Local<v8::Context> env = v8::Context::New(isolate);
272 env->Enter(); 276 env->Enter();
273 277
274 const char* c_source = "\"1234\".length"; 278 const char* c_source = "\"1234\".length";
275 v8::Local<v8::Script> script = v8_compile(c_source); 279 v8::Local<v8::Script> script = v8_compile(c_source);
276 v8::Maybe<int32_t> result = script->Run(isolate->GetCurrentContext()) 280 v8::Maybe<int32_t> result = script->Run(isolate->GetCurrentContext())
277 .ToLocalChecked() 281 .ToLocalChecked()
278 ->Int32Value(isolate->GetCurrentContext()); 282 ->Int32Value(isolate->GetCurrentContext());
279 CHECK_EQ(4, result.FromJust()); 283 CHECK_EQ(4, result.FromJust());
280 } 284 }
281 isolate->Dispose(); 285 isolate->Dispose();
282 } 286 }
283 287
284 288 static void PartiallySerialize() {
285 UNINITIALIZED_TEST(PartialSerialization) {
286 DisableTurbofan();
287 if (DefaultSnapshotAvailable()) return;
288 v8::Isolate* v8_isolate = TestIsolate::NewInitialized(true); 289 v8::Isolate* v8_isolate = TestIsolate::NewInitialized(true);
289 Isolate* isolate = reinterpret_cast<Isolate*>(v8_isolate); 290 Isolate* isolate = reinterpret_cast<Isolate*>(v8_isolate);
290 v8_isolate->Enter(); 291 v8_isolate->Enter();
291 { 292 {
292 Heap* heap = isolate->heap(); 293 Heap* heap = isolate->heap();
293 294
294 v8::Persistent<v8::Context> env; 295 v8::Persistent<v8::Context> env;
295 { 296 {
296 HandleScope scope(isolate); 297 HandleScope scope(isolate);
297 env.Reset(v8_isolate, v8::Context::New(v8_isolate)); 298 env.Reset(v8_isolate, v8::Context::New(v8_isolate));
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 346
346 WritePayload(partial_snapshot.RawData(), FLAG_testing_serialization_file); 347 WritePayload(partial_snapshot.RawData(), FLAG_testing_serialization_file);
347 WritePayload(startup_snapshot.RawData(), startup_name.start()); 348 WritePayload(startup_snapshot.RawData(), startup_name.start());
348 349
349 startup_name.Dispose(); 350 startup_name.Dispose();
350 } 351 }
351 v8_isolate->Exit(); 352 v8_isolate->Exit();
352 v8_isolate->Dispose(); 353 v8_isolate->Dispose();
353 } 354 }
354 355
355 356 UNINITIALIZED_TEST(PartialSerialization) {
356 UNINITIALIZED_DEPENDENT_TEST(PartialDeserialization, PartialSerialization) {
357 DisableTurbofan(); 357 DisableTurbofan();
358 if (DefaultSnapshotAvailable()) return; 358 if (DefaultSnapshotAvailable()) return;
359 PartiallySerialize();
360 }
361
362 UNINITIALIZED_TEST(PartialDeserialization) {
363 DisableTurbofan();
364 if (DefaultSnapshotAvailable()) return;
365 PartiallySerialize();
359 int file_name_length = StrLength(FLAG_testing_serialization_file) + 10; 366 int file_name_length = StrLength(FLAG_testing_serialization_file) + 10;
360 Vector<char> startup_name = Vector<char>::New(file_name_length + 1); 367 Vector<char> startup_name = Vector<char>::New(file_name_length + 1);
361 SNPrintF(startup_name, "%s.startup", FLAG_testing_serialization_file); 368 SNPrintF(startup_name, "%s.startup", FLAG_testing_serialization_file);
362 369
363 v8::Isolate* v8_isolate = InitializeFromFile(startup_name.start()); 370 v8::Isolate* v8_isolate = InitializeFromFile(startup_name.start());
364 CHECK(v8_isolate); 371 CHECK(v8_isolate);
365 startup_name.Dispose(); 372 startup_name.Dispose();
366 { 373 {
367 v8::Isolate::Scope isolate_scope(v8_isolate); 374 v8::Isolate::Scope isolate_scope(v8_isolate);
368 375
(...skipping 24 matching lines...) Expand all
393 .ToHandleChecked(); 400 .ToHandleChecked();
394 CHECK(root2->IsString()); 401 CHECK(root2->IsString());
395 CHECK(root.is_identical_to(root2)); 402 CHECK(root.is_identical_to(root2));
396 } 403 }
397 404
398 DeleteArray(snapshot); 405 DeleteArray(snapshot);
399 } 406 }
400 v8_isolate->Dispose(); 407 v8_isolate->Dispose();
401 } 408 }
402 409
403 410 static void SerializeContext() {
404 UNINITIALIZED_TEST(ContextSerialization) {
405 DisableTurbofan();
406 if (DefaultSnapshotAvailable()) return;
407 v8::Isolate* v8_isolate = TestIsolate::NewInitialized(true); 411 v8::Isolate* v8_isolate = TestIsolate::NewInitialized(true);
408 Isolate* isolate = reinterpret_cast<Isolate*>(v8_isolate); 412 Isolate* isolate = reinterpret_cast<Isolate*>(v8_isolate);
409 Heap* heap = isolate->heap(); 413 Heap* heap = isolate->heap();
410 { 414 {
411 v8::Isolate::Scope isolate_scope(v8_isolate); 415 v8::Isolate::Scope isolate_scope(v8_isolate);
412 416
413 v8::Persistent<v8::Context> env; 417 v8::Persistent<v8::Context> env;
414 { 418 {
415 HandleScope scope(isolate); 419 HandleScope scope(isolate);
416 env.Reset(v8_isolate, v8::Context::New(v8_isolate)); 420 env.Reset(v8_isolate, v8::Context::New(v8_isolate));
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 SnapshotData partial_snapshot(partial_serializer); 462 SnapshotData partial_snapshot(partial_serializer);
459 463
460 WritePayload(partial_snapshot.RawData(), FLAG_testing_serialization_file); 464 WritePayload(partial_snapshot.RawData(), FLAG_testing_serialization_file);
461 WritePayload(startup_snapshot.RawData(), startup_name.start()); 465 WritePayload(startup_snapshot.RawData(), startup_name.start());
462 466
463 startup_name.Dispose(); 467 startup_name.Dispose();
464 } 468 }
465 v8_isolate->Dispose(); 469 v8_isolate->Dispose();
466 } 470 }
467 471
468 472 UNINITIALIZED_TEST(ContextSerialization) {
469 UNINITIALIZED_DEPENDENT_TEST(ContextDeserialization, ContextSerialization) {
470 DisableTurbofan(); 473 DisableTurbofan();
471 if (DefaultSnapshotAvailable()) return; 474 if (DefaultSnapshotAvailable()) return;
475 SerializeContext();
476 }
477
478 UNINITIALIZED_TEST(ContextDeserialization) {
479 DisableTurbofan();
480 if (DefaultSnapshotAvailable()) return;
481 SerializeContext();
472 int file_name_length = StrLength(FLAG_testing_serialization_file) + 10; 482 int file_name_length = StrLength(FLAG_testing_serialization_file) + 10;
473 Vector<char> startup_name = Vector<char>::New(file_name_length + 1); 483 Vector<char> startup_name = Vector<char>::New(file_name_length + 1);
474 SNPrintF(startup_name, "%s.startup", FLAG_testing_serialization_file); 484 SNPrintF(startup_name, "%s.startup", FLAG_testing_serialization_file);
475 485
476 v8::Isolate* v8_isolate = InitializeFromFile(startup_name.start()); 486 v8::Isolate* v8_isolate = InitializeFromFile(startup_name.start());
477 CHECK(v8_isolate); 487 CHECK(v8_isolate);
478 startup_name.Dispose(); 488 startup_name.Dispose();
479 { 489 {
480 v8::Isolate::Scope isolate_scope(v8_isolate); 490 v8::Isolate::Scope isolate_scope(v8_isolate);
481 491
(...skipping 23 matching lines...) Expand all
505 root2 = deserializer.DeserializePartial(isolate, global_proxy) 515 root2 = deserializer.DeserializePartial(isolate, global_proxy)
506 .ToHandleChecked(); 516 .ToHandleChecked();
507 CHECK(root2->IsContext()); 517 CHECK(root2->IsContext());
508 CHECK(!root.is_identical_to(root2)); 518 CHECK(!root.is_identical_to(root2));
509 } 519 }
510 DeleteArray(snapshot); 520 DeleteArray(snapshot);
511 } 521 }
512 v8_isolate->Dispose(); 522 v8_isolate->Dispose();
513 } 523 }
514 524
515 525 static void SerializeCustomContext() {
516 UNINITIALIZED_TEST(CustomContextSerialization) {
517 DisableTurbofan();
518 if (DefaultSnapshotAvailable()) return;
519 v8::Isolate* v8_isolate = TestIsolate::NewInitialized(true); 526 v8::Isolate* v8_isolate = TestIsolate::NewInitialized(true);
520 Isolate* isolate = reinterpret_cast<Isolate*>(v8_isolate); 527 Isolate* isolate = reinterpret_cast<Isolate*>(v8_isolate);
521 { 528 {
522 v8::Isolate::Scope isolate_scope(v8_isolate); 529 v8::Isolate::Scope isolate_scope(v8_isolate);
523 530
524 v8::Persistent<v8::Context> env; 531 v8::Persistent<v8::Context> env;
525 { 532 {
526 HandleScope scope(isolate); 533 HandleScope scope(isolate);
527 env.Reset(v8_isolate, v8::Context::New(v8_isolate)); 534 env.Reset(v8_isolate, v8::Context::New(v8_isolate));
528 } 535 }
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
589 SnapshotData partial_snapshot(partial_serializer); 596 SnapshotData partial_snapshot(partial_serializer);
590 597
591 WritePayload(partial_snapshot.RawData(), FLAG_testing_serialization_file); 598 WritePayload(partial_snapshot.RawData(), FLAG_testing_serialization_file);
592 WritePayload(startup_snapshot.RawData(), startup_name.start()); 599 WritePayload(startup_snapshot.RawData(), startup_name.start());
593 600
594 startup_name.Dispose(); 601 startup_name.Dispose();
595 } 602 }
596 v8_isolate->Dispose(); 603 v8_isolate->Dispose();
597 } 604 }
598 605
606 UNINITIALIZED_TEST(CustomContextSerialization) {
607 DisableTurbofan();
608 if (DefaultSnapshotAvailable()) return;
609 SerializeCustomContext();
610 }
599 611
600 UNINITIALIZED_DEPENDENT_TEST(CustomContextDeserialization, 612 UNINITIALIZED_TEST(CustomContextDeserialization) {
601 CustomContextSerialization) {
602 DisableTurbofan(); 613 DisableTurbofan();
603 FLAG_crankshaft = false; 614 FLAG_crankshaft = false;
604 if (DefaultSnapshotAvailable()) return; 615 if (DefaultSnapshotAvailable()) return;
616 SerializeCustomContext();
605 int file_name_length = StrLength(FLAG_testing_serialization_file) + 10; 617 int file_name_length = StrLength(FLAG_testing_serialization_file) + 10;
606 Vector<char> startup_name = Vector<char>::New(file_name_length + 1); 618 Vector<char> startup_name = Vector<char>::New(file_name_length + 1);
607 SNPrintF(startup_name, "%s.startup", FLAG_testing_serialization_file); 619 SNPrintF(startup_name, "%s.startup", FLAG_testing_serialization_file);
608 620
609 v8::Isolate* v8_isolate = InitializeFromFile(startup_name.start()); 621 v8::Isolate* v8_isolate = InitializeFromFile(startup_name.start());
610 CHECK(v8_isolate); 622 CHECK(v8_isolate);
611 startup_name.Dispose(); 623 startup_name.Dispose();
612 { 624 {
613 v8::Isolate::Scope isolate_scope(v8_isolate); 625 v8::Isolate::Scope isolate_scope(v8_isolate);
614 626
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
862 TEST(TestThatAlwaysSucceeds) { 874 TEST(TestThatAlwaysSucceeds) {
863 } 875 }
864 876
865 877
866 TEST(TestThatAlwaysFails) { 878 TEST(TestThatAlwaysFails) {
867 bool ArtificialFailure = false; 879 bool ArtificialFailure = false;
868 CHECK(ArtificialFailure); 880 CHECK(ArtificialFailure);
869 } 881 }
870 882
871 883
872 DEPENDENT_TEST(DependentTestThatAlwaysFails, TestThatAlwaysSucceeds) {
873 bool ArtificialFailure2 = false;
874 CHECK(ArtificialFailure2);
875 }
876
877
878 int CountBuiltins() { 884 int CountBuiltins() {
879 // Check that we have not deserialized any additional builtin. 885 // Check that we have not deserialized any additional builtin.
880 HeapIterator iterator(CcTest::heap()); 886 HeapIterator iterator(CcTest::heap());
881 DisallowHeapAllocation no_allocation; 887 DisallowHeapAllocation no_allocation;
882 int counter = 0; 888 int counter = 0;
883 for (HeapObject* obj = iterator.next(); obj != NULL; obj = iterator.next()) { 889 for (HeapObject* obj = iterator.next(); obj != NULL; obj = iterator.next()) {
884 if (obj->IsCode() && Code::cast(obj)->kind() == Code::BUILTIN) counter++; 890 if (obj->IsCode() && Code::cast(obj)->kind() == Code::BUILTIN) counter++;
885 } 891 }
886 return counter; 892 return counter;
887 } 893 }
(...skipping 880 matching lines...) Expand 10 before | Expand all | Expand 10 after
1768 delete script_data; 1774 delete script_data;
1769 } 1775 }
1770 1776
1771 1777
1772 TEST(SerializationMemoryStats) { 1778 TEST(SerializationMemoryStats) {
1773 FLAG_profile_deserialization = true; 1779 FLAG_profile_deserialization = true;
1774 FLAG_always_opt = false; 1780 FLAG_always_opt = false;
1775 v8::StartupData blob = v8::V8::CreateSnapshotDataBlob(); 1781 v8::StartupData blob = v8::V8::CreateSnapshotDataBlob();
1776 delete[] blob.data; 1782 delete[] blob.data;
1777 } 1783 }
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