| OLD | NEW |
| 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 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 v8::Isolate::Scope isolate_scope(v8_isolate); | 365 v8::Isolate::Scope isolate_scope(v8_isolate); |
| 366 | 366 |
| 367 const char* file_name = FLAG_testing_serialization_file; | 367 const char* file_name = FLAG_testing_serialization_file; |
| 368 | 368 |
| 369 int snapshot_size = 0; | 369 int snapshot_size = 0; |
| 370 byte* snapshot = ReadBytes(file_name, &snapshot_size); | 370 byte* snapshot = ReadBytes(file_name, &snapshot_size); |
| 371 | 371 |
| 372 Isolate* isolate = reinterpret_cast<Isolate*>(v8_isolate); | 372 Isolate* isolate = reinterpret_cast<Isolate*>(v8_isolate); |
| 373 HandleScope handle_scope(isolate); | 373 HandleScope handle_scope(isolate); |
| 374 Handle<Object> root; | 374 Handle<Object> root; |
| 375 Handle<FixedArray> outdated_contexts; | |
| 376 // Intentionally empty handle. The deserializer should not come across | 375 // Intentionally empty handle. The deserializer should not come across |
| 377 // any references to the global proxy in this test. | 376 // any references to the global proxy in this test. |
| 378 Handle<JSGlobalProxy> global_proxy = Handle<JSGlobalProxy>::null(); | 377 Handle<JSGlobalProxy> global_proxy = Handle<JSGlobalProxy>::null(); |
| 379 { | 378 { |
| 380 SnapshotData snapshot_data(Vector<const byte>(snapshot, snapshot_size)); | 379 SnapshotData snapshot_data(Vector<const byte>(snapshot, snapshot_size)); |
| 381 Deserializer deserializer(&snapshot_data); | 380 Deserializer deserializer(&snapshot_data); |
| 382 root = | 381 root = deserializer.DeserializePartial(isolate, global_proxy) |
| 383 deserializer.DeserializePartial(isolate, global_proxy, | 382 .ToHandleChecked(); |
| 384 &outdated_contexts).ToHandleChecked(); | |
| 385 CHECK_EQ(0, outdated_contexts->length()); | |
| 386 CHECK(root->IsString()); | 383 CHECK(root->IsString()); |
| 387 } | 384 } |
| 388 | 385 |
| 389 Handle<Object> root2; | 386 Handle<Object> root2; |
| 390 { | 387 { |
| 391 SnapshotData snapshot_data(Vector<const byte>(snapshot, snapshot_size)); | 388 SnapshotData snapshot_data(Vector<const byte>(snapshot, snapshot_size)); |
| 392 Deserializer deserializer(&snapshot_data); | 389 Deserializer deserializer(&snapshot_data); |
| 393 root2 = | 390 root2 = deserializer.DeserializePartial(isolate, global_proxy) |
| 394 deserializer.DeserializePartial(isolate, global_proxy, | 391 .ToHandleChecked(); |
| 395 &outdated_contexts).ToHandleChecked(); | |
| 396 CHECK(root2->IsString()); | 392 CHECK(root2->IsString()); |
| 397 CHECK(root.is_identical_to(root2)); | 393 CHECK(root.is_identical_to(root2)); |
| 398 } | 394 } |
| 399 | 395 |
| 400 DeleteArray(snapshot); | 396 DeleteArray(snapshot); |
| 401 } | 397 } |
| 402 v8_isolate->Dispose(); | 398 v8_isolate->Dispose(); |
| 403 } | 399 } |
| 404 | 400 |
| 405 | 401 |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 482 v8::Isolate::Scope isolate_scope(v8_isolate); | 478 v8::Isolate::Scope isolate_scope(v8_isolate); |
| 483 | 479 |
| 484 const char* file_name = FLAG_testing_serialization_file; | 480 const char* file_name = FLAG_testing_serialization_file; |
| 485 | 481 |
| 486 int snapshot_size = 0; | 482 int snapshot_size = 0; |
| 487 byte* snapshot = ReadBytes(file_name, &snapshot_size); | 483 byte* snapshot = ReadBytes(file_name, &snapshot_size); |
| 488 | 484 |
| 489 Isolate* isolate = reinterpret_cast<Isolate*>(v8_isolate); | 485 Isolate* isolate = reinterpret_cast<Isolate*>(v8_isolate); |
| 490 HandleScope handle_scope(isolate); | 486 HandleScope handle_scope(isolate); |
| 491 Handle<Object> root; | 487 Handle<Object> root; |
| 492 Handle<FixedArray> outdated_contexts; | |
| 493 Handle<JSGlobalProxy> global_proxy = | 488 Handle<JSGlobalProxy> global_proxy = |
| 494 isolate->factory()->NewUninitializedJSGlobalProxy(); | 489 isolate->factory()->NewUninitializedJSGlobalProxy(); |
| 495 { | 490 { |
| 496 SnapshotData snapshot_data(Vector<const byte>(snapshot, snapshot_size)); | 491 SnapshotData snapshot_data(Vector<const byte>(snapshot, snapshot_size)); |
| 497 Deserializer deserializer(&snapshot_data); | 492 Deserializer deserializer(&snapshot_data); |
| 498 root = | 493 root = deserializer.DeserializePartial(isolate, global_proxy) |
| 499 deserializer.DeserializePartial(isolate, global_proxy, | 494 .ToHandleChecked(); |
| 500 &outdated_contexts).ToHandleChecked(); | |
| 501 CHECK(root->IsContext()); | 495 CHECK(root->IsContext()); |
| 502 CHECK(Handle<Context>::cast(root)->global_proxy() == *global_proxy); | 496 CHECK(Handle<Context>::cast(root)->global_proxy() == *global_proxy); |
| 503 // TODO(yangguo): Introduce proper test once there's a story for the | |
| 504 // outdated_contexts (should only be about ScriptContexts IMHO). | |
| 505 // CHECK_EQ(2, outdated_contexts->length()); | |
| 506 } | 497 } |
| 507 | 498 |
| 508 Handle<Object> root2; | 499 Handle<Object> root2; |
| 509 { | 500 { |
| 510 SnapshotData snapshot_data(Vector<const byte>(snapshot, snapshot_size)); | 501 SnapshotData snapshot_data(Vector<const byte>(snapshot, snapshot_size)); |
| 511 Deserializer deserializer(&snapshot_data); | 502 Deserializer deserializer(&snapshot_data); |
| 512 root2 = | 503 root2 = deserializer.DeserializePartial(isolate, global_proxy) |
| 513 deserializer.DeserializePartial(isolate, global_proxy, | 504 .ToHandleChecked(); |
| 514 &outdated_contexts).ToHandleChecked(); | |
| 515 CHECK(root2->IsContext()); | 505 CHECK(root2->IsContext()); |
| 516 CHECK(!root.is_identical_to(root2)); | 506 CHECK(!root.is_identical_to(root2)); |
| 517 } | 507 } |
| 518 DeleteArray(snapshot); | 508 DeleteArray(snapshot); |
| 519 } | 509 } |
| 520 v8_isolate->Dispose(); | 510 v8_isolate->Dispose(); |
| 521 } | 511 } |
| 522 | 512 |
| 523 | 513 |
| 524 UNINITIALIZED_TEST(CustomContextSerialization) { | 514 UNINITIALIZED_TEST(CustomContextSerialization) { |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 621 v8::Isolate::Scope isolate_scope(v8_isolate); | 611 v8::Isolate::Scope isolate_scope(v8_isolate); |
| 622 | 612 |
| 623 const char* file_name = FLAG_testing_serialization_file; | 613 const char* file_name = FLAG_testing_serialization_file; |
| 624 | 614 |
| 625 int snapshot_size = 0; | 615 int snapshot_size = 0; |
| 626 byte* snapshot = ReadBytes(file_name, &snapshot_size); | 616 byte* snapshot = ReadBytes(file_name, &snapshot_size); |
| 627 | 617 |
| 628 Isolate* isolate = reinterpret_cast<Isolate*>(v8_isolate); | 618 Isolate* isolate = reinterpret_cast<Isolate*>(v8_isolate); |
| 629 HandleScope handle_scope(isolate); | 619 HandleScope handle_scope(isolate); |
| 630 Handle<Object> root; | 620 Handle<Object> root; |
| 631 Handle<FixedArray> outdated_contexts; | |
| 632 Handle<JSGlobalProxy> global_proxy = | 621 Handle<JSGlobalProxy> global_proxy = |
| 633 isolate->factory()->NewUninitializedJSGlobalProxy(); | 622 isolate->factory()->NewUninitializedJSGlobalProxy(); |
| 634 { | 623 { |
| 635 SnapshotData snapshot_data(Vector<const byte>(snapshot, snapshot_size)); | 624 SnapshotData snapshot_data(Vector<const byte>(snapshot, snapshot_size)); |
| 636 Deserializer deserializer(&snapshot_data); | 625 Deserializer deserializer(&snapshot_data); |
| 637 root = | 626 root = deserializer.DeserializePartial(isolate, global_proxy) |
| 638 deserializer.DeserializePartial(isolate, global_proxy, | 627 .ToHandleChecked(); |
| 639 &outdated_contexts).ToHandleChecked(); | |
| 640 // TODO(yangguo): Introduce proper test once there's a story for the | |
| 641 // outdated_contexts (should only be about ScriptContexts IMHO). | |
| 642 // if (FLAG_global_var_shortcuts) { | |
| 643 // CHECK_EQ(5, outdated_contexts->length()); | |
| 644 // } else { | |
| 645 // CHECK_EQ(3, outdated_contexts->length()); | |
| 646 // } | |
| 647 CHECK(root->IsContext()); | 628 CHECK(root->IsContext()); |
| 648 Handle<Context> context = Handle<Context>::cast(root); | 629 Handle<Context> context = Handle<Context>::cast(root); |
| 649 CHECK(context->global_proxy() == *global_proxy); | 630 CHECK(context->global_proxy() == *global_proxy); |
| 650 Handle<String> o = isolate->factory()->NewStringFromAsciiChecked("o"); | 631 Handle<String> o = isolate->factory()->NewStringFromAsciiChecked("o"); |
| 651 Handle<JSObject> global_object(context->global_object(), isolate); | 632 Handle<JSObject> global_object(context->global_object(), isolate); |
| 652 Handle<Object> property = JSReceiver::GetDataProperty(global_object, o); | 633 Handle<Object> property = JSReceiver::GetDataProperty(global_object, o); |
| 653 CHECK(property.is_identical_to(global_proxy)); | 634 CHECK(property.is_identical_to(global_proxy)); |
| 654 | 635 |
| 655 v8::Local<v8::Context> v8_context = v8::Utils::ToLocal(context); | 636 v8::Local<v8::Context> v8_context = v8::Utils::ToLocal(context); |
| 656 v8::Context::Scope context_scope(v8_context); | 637 v8::Context::Scope context_scope(v8_context); |
| (...skipping 1128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1785 delete script_data; | 1766 delete script_data; |
| 1786 } | 1767 } |
| 1787 | 1768 |
| 1788 | 1769 |
| 1789 TEST(SerializationMemoryStats) { | 1770 TEST(SerializationMemoryStats) { |
| 1790 FLAG_profile_deserialization = true; | 1771 FLAG_profile_deserialization = true; |
| 1791 FLAG_always_opt = false; | 1772 FLAG_always_opt = false; |
| 1792 v8::StartupData blob = v8::V8::CreateSnapshotDataBlob(); | 1773 v8::StartupData blob = v8::V8::CreateSnapshotDataBlob(); |
| 1793 delete[] blob.data; | 1774 delete[] blob.data; |
| 1794 } | 1775 } |
| OLD | NEW |