| OLD | NEW | 
|---|
| 1 // Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors.  Please see the AUTHORS file | 
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a | 
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. | 
| 4 | 4 | 
| 5 #include "platform/globals.h" | 5 #include "platform/globals.h" | 
| 6 | 6 | 
| 7 #include "include/dart_tools_api.h" | 7 #include "include/dart_tools_api.h" | 
| 8 #include "platform/assert.h" | 8 #include "platform/assert.h" | 
| 9 #include "vm/class_finalizer.h" | 9 #include "vm/class_finalizer.h" | 
| 10 #include "vm/dart_api_impl.h" | 10 #include "vm/dart_api_impl.h" | 
| 11 #include "vm/dart_api_message.h" | 11 #include "vm/dart_api_message.h" | 
| 12 #include "vm/dart_api_state.h" | 12 #include "vm/dart_api_state.h" | 
| 13 #include "vm/flags.h" | 13 #include "vm/flags.h" | 
| 14 #include "vm/snapshot.h" | 14 #include "vm/snapshot.h" | 
| 15 #include "vm/symbols.h" | 15 #include "vm/symbols.h" | 
| 16 #include "vm/unicode.h" | 16 #include "vm/unicode.h" | 
| 17 #include "vm/unit_test.h" | 17 #include "vm/unit_test.h" | 
| 18 | 18 | 
| 19 namespace dart { | 19 namespace dart { | 
| 20 | 20 | 
| 21 DECLARE_FLAG(bool, enable_type_checks); |  | 
| 22 DECLARE_FLAG(bool, concurrent_sweep); | 21 DECLARE_FLAG(bool, concurrent_sweep); | 
| 23 | 22 | 
| 24 // Check if serialized and deserialized objects are equal. | 23 // Check if serialized and deserialized objects are equal. | 
| 25 static bool Equals(const Object& expected, const Object& actual) { | 24 static bool Equals(const Object& expected, const Object& actual) { | 
| 26   if (expected.IsNull()) { | 25   if (expected.IsNull()) { | 
| 27     return actual.IsNull(); | 26     return actual.IsNull(); | 
| 28   } | 27   } | 
| 29   if (expected.IsSmi()) { | 28   if (expected.IsSmi()) { | 
| 30     if (actual.IsSmi()) { | 29     if (actual.IsSmi()) { | 
| 31       return expected.raw() == actual.raw(); | 30       return expected.raw() == actual.raw(); | 
| (...skipping 1540 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1572   uint8_t* buffer; | 1571   uint8_t* buffer; | 
| 1573   intptr_t size; | 1572   intptr_t size; | 
| 1574   intptr_t vm_isolate_snapshot_size; | 1573   intptr_t vm_isolate_snapshot_size; | 
| 1575   uint8_t* isolate_snapshot = NULL; | 1574   uint8_t* isolate_snapshot = NULL; | 
| 1576   intptr_t isolate_snapshot_size; | 1575   intptr_t isolate_snapshot_size; | 
| 1577   uint8_t* full_snapshot = NULL; | 1576   uint8_t* full_snapshot = NULL; | 
| 1578   uint8_t* script_snapshot = NULL; | 1577   uint8_t* script_snapshot = NULL; | 
| 1579 | 1578 | 
| 1580   // Force creation of snapshot in production mode. | 1579   // Force creation of snapshot in production mode. | 
| 1581   bool saved_enable_type_checks_mode = FLAG_enable_type_checks; | 1580   bool saved_enable_type_checks_mode = FLAG_enable_type_checks; | 
| 1582   FLAG_enable_type_checks = false; | 1581   NOT_IN_PRODUCT(FLAG_enable_type_checks = false); | 
| 1583   bool saved_load_deferred_eagerly_mode = FLAG_load_deferred_eagerly; | 1582   bool saved_load_deferred_eagerly_mode = FLAG_load_deferred_eagerly; | 
| 1584   FLAG_load_deferred_eagerly = true; | 1583   FLAG_load_deferred_eagerly = true; | 
| 1585   bool saved_concurrent_sweep_mode = FLAG_concurrent_sweep; | 1584   bool saved_concurrent_sweep_mode = FLAG_concurrent_sweep; | 
| 1586   FLAG_concurrent_sweep = false; | 1585   FLAG_concurrent_sweep = false; | 
| 1587   { | 1586   { | 
| 1588     // Start an Isolate, and create a full snapshot of it. | 1587     // Start an Isolate, and create a full snapshot of it. | 
| 1589     TestIsolateScope __test_isolate__; | 1588     TestIsolateScope __test_isolate__; | 
| 1590     Dart_EnterScope();  // Start a Dart API scope for invoking API functions. | 1589     Dart_EnterScope();  // Start a Dart API scope for invoking API functions. | 
| 1591 | 1590 | 
| 1592     // Write out the script snapshot. | 1591     // Write out the script snapshot. | 
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1624     // Write out the script snapshot. | 1623     // Write out the script snapshot. | 
| 1625     result = Dart_CreateScriptSnapshot(&buffer, &size); | 1624     result = Dart_CreateScriptSnapshot(&buffer, &size); | 
| 1626     EXPECT_VALID(result); | 1625     EXPECT_VALID(result); | 
| 1627     script_snapshot = reinterpret_cast<uint8_t*>(malloc(size)); | 1626     script_snapshot = reinterpret_cast<uint8_t*>(malloc(size)); | 
| 1628     memmove(script_snapshot, buffer, size); | 1627     memmove(script_snapshot, buffer, size); | 
| 1629     Dart_ExitScope(); | 1628     Dart_ExitScope(); | 
| 1630     Dart_ShutdownIsolate(); | 1629     Dart_ShutdownIsolate(); | 
| 1631   } | 1630   } | 
| 1632 | 1631 | 
| 1633   // Continue in originally saved mode. | 1632   // Continue in originally saved mode. | 
| 1634   FLAG_enable_type_checks = saved_enable_type_checks_mode; | 1633   NOT_IN_PRODUCT(FLAG_enable_type_checks = saved_enable_type_checks_mode); | 
| 1635   FLAG_load_deferred_eagerly = saved_load_deferred_eagerly_mode; | 1634   FLAG_load_deferred_eagerly = saved_load_deferred_eagerly_mode; | 
| 1636 | 1635 | 
| 1637   { | 1636   { | 
| 1638     // Now Create an Isolate using the full snapshot and load the | 1637     // Now Create an Isolate using the full snapshot and load the | 
| 1639     // script snapshot created above and execute it. | 1638     // script snapshot created above and execute it. | 
| 1640     TestCase::CreateTestIsolateFromSnapshot(full_snapshot); | 1639     TestCase::CreateTestIsolateFromSnapshot(full_snapshot); | 
| 1641     Dart_EnterScope();  // Start a Dart API scope for invoking API functions. | 1640     Dart_EnterScope();  // Start a Dart API scope for invoking API functions. | 
| 1642 | 1641 | 
| 1643     // Load the test library from the snapshot. | 1642     // Load the test library from the snapshot. | 
| 1644     EXPECT(script_snapshot != NULL); | 1643     EXPECT(script_snapshot != NULL); | 
| (...skipping 1365 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 3010   StackZone zone(Thread::Current()); | 3009   StackZone zone(Thread::Current()); | 
| 3011   uint8_t* buffer; | 3010   uint8_t* buffer; | 
| 3012   MessageWriter writer(&buffer, &zone_allocator, true); | 3011   MessageWriter writer(&buffer, &zone_allocator, true); | 
| 3013   writer.WriteInlinedObjectHeader(kOmittedObjectId); | 3012   writer.WriteInlinedObjectHeader(kOmittedObjectId); | 
| 3014   // For performance, we'd like single-byte headers when ids are omitted. | 3013   // For performance, we'd like single-byte headers when ids are omitted. | 
| 3015   // If this starts failing, consider renumbering the snapshot ids. | 3014   // If this starts failing, consider renumbering the snapshot ids. | 
| 3016   EXPECT_EQ(1, writer.BytesWritten()); | 3015   EXPECT_EQ(1, writer.BytesWritten()); | 
| 3017 } | 3016 } | 
| 3018 | 3017 | 
| 3019 }  // namespace dart | 3018 }  // namespace dart | 
| OLD | NEW | 
|---|