| 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/clustered_snapshot.h" | 10 #include "vm/clustered_snapshot.h" |
| 11 #include "vm/dart_api_impl.h" | 11 #include "vm/dart_api_impl.h" |
| 12 #include "vm/dart_api_message.h" | 12 #include "vm/dart_api_message.h" |
| 13 #include "vm/dart_api_state.h" | 13 #include "vm/dart_api_state.h" |
| 14 #include "vm/flags.h" | 14 #include "vm/flags.h" |
| 15 #include "vm/malloc_hooks.h" | |
| 16 #include "vm/snapshot.h" | 15 #include "vm/snapshot.h" |
| 17 #include "vm/symbols.h" | 16 #include "vm/symbols.h" |
| 18 #include "vm/unicode.h" | 17 #include "vm/unicode.h" |
| 19 #include "vm/unit_test.h" | 18 #include "vm/unit_test.h" |
| 20 | 19 |
| 21 namespace dart { | 20 namespace dart { |
| 22 | 21 |
| 23 // Check if serialized and deserialized objects are equal. | 22 // Check if serialized and deserialized objects are equal. |
| 24 static bool Equals(const Object& expected, const Object& actual) { | 23 static bool Equals(const Object& expected, const Object& actual) { |
| 25 if (expected.IsNull()) { | 24 if (expected.IsNull()) { |
| (...skipping 1090 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1116 for (intptr_t i = 0; i < lib_scripts.Length(); i++) { | 1115 for (intptr_t i = 0; i < lib_scripts.Length(); i++) { |
| 1117 script ^= lib_scripts.At(i); | 1116 script ^= lib_scripts.At(i); |
| 1118 EXPECT(!script.IsNull()); | 1117 EXPECT(!script.IsNull()); |
| 1119 uri = script.url(); | 1118 uri = script.url(); |
| 1120 OS::Print("Generating source for part: %s\n", uri.ToCString()); | 1119 OS::Print("Generating source for part: %s\n", uri.ToCString()); |
| 1121 GenerateSourceAndCheck(script); | 1120 GenerateSourceAndCheck(script); |
| 1122 } | 1121 } |
| 1123 } | 1122 } |
| 1124 | 1123 |
| 1125 ISOLATE_UNIT_TEST_CASE(GenerateSource) { | 1124 ISOLATE_UNIT_TEST_CASE(GenerateSource) { |
| 1126 // Disable stack trace collection for this test as it results in a timeout. | |
| 1127 bool stack_trace_collection_enabled = | |
| 1128 MallocHooks::stack_trace_collection_enabled(); | |
| 1129 MallocHooks::set_stack_trace_collection_enabled(false); | |
| 1130 | |
| 1131 Zone* zone = thread->zone(); | 1125 Zone* zone = thread->zone(); |
| 1132 Isolate* isolate = thread->isolate(); | 1126 Isolate* isolate = thread->isolate(); |
| 1133 const GrowableObjectArray& libs = | 1127 const GrowableObjectArray& libs = |
| 1134 GrowableObjectArray::Handle(zone, isolate->object_store()->libraries()); | 1128 GrowableObjectArray::Handle(zone, isolate->object_store()->libraries()); |
| 1135 Library& lib = Library::Handle(); | 1129 Library& lib = Library::Handle(); |
| 1136 String& uri = String::Handle(); | 1130 String& uri = String::Handle(); |
| 1137 for (intptr_t i = 0; i < libs.Length(); i++) { | 1131 for (intptr_t i = 0; i < libs.Length(); i++) { |
| 1138 lib ^= libs.At(i); | 1132 lib ^= libs.At(i); |
| 1139 EXPECT(!lib.IsNull()); | 1133 EXPECT(!lib.IsNull()); |
| 1140 uri = lib.url(); | 1134 uri = lib.url(); |
| 1141 OS::Print("Generating source for library: %s\n", uri.ToCString()); | 1135 OS::Print("Generating source for library: %s\n", uri.ToCString()); |
| 1142 IterateScripts(lib); | 1136 IterateScripts(lib); |
| 1143 } | 1137 } |
| 1144 | |
| 1145 MallocHooks::set_stack_trace_collection_enabled( | |
| 1146 stack_trace_collection_enabled); | |
| 1147 } | 1138 } |
| 1148 | 1139 |
| 1149 | 1140 |
| 1150 VM_UNIT_TEST_CASE(FullSnapshot) { | 1141 VM_UNIT_TEST_CASE(FullSnapshot) { |
| 1151 const char* kScriptChars = | 1142 const char* kScriptChars = |
| 1152 "class Fields {\n" | 1143 "class Fields {\n" |
| 1153 " Fields(int i, int j) : fld1 = i, fld2 = j {}\n" | 1144 " Fields(int i, int j) : fld1 = i, fld2 = j {}\n" |
| 1154 " int fld1;\n" | 1145 " int fld1;\n" |
| 1155 " final int fld2;\n" | 1146 " final int fld2;\n" |
| 1156 " final int bigint_fld = 0xfffffffffff;\n" | 1147 " final int bigint_fld = 0xfffffffffff;\n" |
| (...skipping 1855 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3012 StackZone zone(Thread::Current()); | 3003 StackZone zone(Thread::Current()); |
| 3013 uint8_t* buffer; | 3004 uint8_t* buffer; |
| 3014 MessageWriter writer(&buffer, &zone_allocator, &zone_deallocator, true); | 3005 MessageWriter writer(&buffer, &zone_allocator, &zone_deallocator, true); |
| 3015 writer.WriteInlinedObjectHeader(kOmittedObjectId); | 3006 writer.WriteInlinedObjectHeader(kOmittedObjectId); |
| 3016 // For performance, we'd like single-byte headers when ids are omitted. | 3007 // For performance, we'd like single-byte headers when ids are omitted. |
| 3017 // If this starts failing, consider renumbering the snapshot ids. | 3008 // If this starts failing, consider renumbering the snapshot ids. |
| 3018 EXPECT_EQ(1, writer.BytesWritten()); | 3009 EXPECT_EQ(1, writer.BytesWritten()); |
| 3019 } | 3010 } |
| 3020 | 3011 |
| 3021 } // namespace dart | 3012 } // namespace dart |
| OLD | NEW |