| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 "vm/snapshot.h" | 5 #include "vm/snapshot.h" |
| 6 | 6 |
| 7 #include "vm/assert.h" | 7 #include "vm/assert.h" |
| 8 #include "vm/bigint_operations.h" | 8 #include "vm/bigint_operations.h" |
| 9 #include "vm/class_finalizer.h" | 9 #include "vm/class_finalizer.h" |
| 10 #include "vm/unit_test.h" | 10 #include "vm/unit_test.h" |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 EXPECT_EQ(BigintOperations::ToInt64(bigint), BigintOperations::ToInt64(obj)); | 158 EXPECT_EQ(BigintOperations::ToInt64(bigint), BigintOperations::ToInt64(obj)); |
| 159 } | 159 } |
| 160 | 160 |
| 161 | 161 |
| 162 TEST_CASE(SerializeSingletons) { | 162 TEST_CASE(SerializeSingletons) { |
| 163 // Write snapshot with object content. | 163 // Write snapshot with object content. |
| 164 uint8_t* buffer; | 164 uint8_t* buffer; |
| 165 SnapshotWriter writer(false, &buffer, &allocator); | 165 SnapshotWriter writer(false, &buffer, &allocator); |
| 166 writer.WriteObject(Object::class_class()); | 166 writer.WriteObject(Object::class_class()); |
| 167 writer.WriteObject(Object::null_class()); | 167 writer.WriteObject(Object::null_class()); |
| 168 writer.WriteObject(Object::parameterized_type_class()); | 168 writer.WriteObject(Object::type_class()); |
| 169 writer.WriteObject(Object::type_parameter_class()); | 169 writer.WriteObject(Object::type_parameter_class()); |
| 170 writer.WriteObject(Object::instantiated_type_class()); | 170 writer.WriteObject(Object::instantiated_type_class()); |
| 171 writer.WriteObject(Object::type_arguments_class()); | 171 writer.WriteObject(Object::type_arguments_class()); |
| 172 writer.WriteObject(Object::type_array_class()); | 172 writer.WriteObject(Object::type_array_class()); |
| 173 writer.WriteObject(Object::instantiated_type_arguments_class()); | 173 writer.WriteObject(Object::instantiated_type_arguments_class()); |
| 174 writer.WriteObject(Object::function_class()); | 174 writer.WriteObject(Object::function_class()); |
| 175 writer.WriteObject(Object::field_class()); | 175 writer.WriteObject(Object::field_class()); |
| 176 writer.WriteObject(Object::token_stream_class()); | 176 writer.WriteObject(Object::token_stream_class()); |
| 177 writer.WriteObject(Object::script_class()); | 177 writer.WriteObject(Object::script_class()); |
| 178 writer.WriteObject(Object::library_class()); | 178 writer.WriteObject(Object::library_class()); |
| 179 writer.WriteObject(Object::code_class()); | 179 writer.WriteObject(Object::code_class()); |
| 180 writer.WriteObject(Object::instructions_class()); | 180 writer.WriteObject(Object::instructions_class()); |
| 181 writer.WriteObject(Object::pc_descriptors_class()); | 181 writer.WriteObject(Object::pc_descriptors_class()); |
| 182 writer.WriteObject(Object::exception_handlers_class()); | 182 writer.WriteObject(Object::exception_handlers_class()); |
| 183 writer.WriteObject(Object::context_class()); | 183 writer.WriteObject(Object::context_class()); |
| 184 writer.WriteObject(Object::context_scope_class()); | 184 writer.WriteObject(Object::context_scope_class()); |
| 185 writer.FinalizeBuffer(); | 185 writer.FinalizeBuffer(); |
| 186 | 186 |
| 187 // Create a snapshot object using the buffer. | 187 // Create a snapshot object using the buffer. |
| 188 const Snapshot* snapshot = Snapshot::SetupFromBuffer(buffer); | 188 const Snapshot* snapshot = Snapshot::SetupFromBuffer(buffer); |
| 189 | 189 |
| 190 // Read object back from the snapshot. | 190 // Read object back from the snapshot. |
| 191 Isolate* isolate= Isolate::Current(); | 191 Isolate* isolate= Isolate::Current(); |
| 192 SnapshotReader reader(snapshot, isolate->heap(), isolate->object_store()); | 192 SnapshotReader reader(snapshot, isolate->heap(), isolate->object_store()); |
| 193 EXPECT(Object::class_class() == reader.ReadObject()); | 193 EXPECT(Object::class_class() == reader.ReadObject()); |
| 194 EXPECT(Object::null_class() == reader.ReadObject()); | 194 EXPECT(Object::null_class() == reader.ReadObject()); |
| 195 EXPECT(Object::parameterized_type_class() == reader.ReadObject()); | 195 EXPECT(Object::type_class() == reader.ReadObject()); |
| 196 EXPECT(Object::type_parameter_class() == reader.ReadObject()); | 196 EXPECT(Object::type_parameter_class() == reader.ReadObject()); |
| 197 EXPECT(Object::instantiated_type_class() == reader.ReadObject()); | 197 EXPECT(Object::instantiated_type_class() == reader.ReadObject()); |
| 198 EXPECT(Object::type_arguments_class() == reader.ReadObject()); | 198 EXPECT(Object::type_arguments_class() == reader.ReadObject()); |
| 199 EXPECT(Object::type_array_class() == reader.ReadObject()); | 199 EXPECT(Object::type_array_class() == reader.ReadObject()); |
| 200 EXPECT(Object::instantiated_type_arguments_class() == reader.ReadObject()); | 200 EXPECT(Object::instantiated_type_arguments_class() == reader.ReadObject()); |
| 201 EXPECT(Object::function_class() == reader.ReadObject()); | 201 EXPECT(Object::function_class() == reader.ReadObject()); |
| 202 EXPECT(Object::field_class() == reader.ReadObject()); | 202 EXPECT(Object::field_class() == reader.ReadObject()); |
| 203 EXPECT(Object::token_stream_class() == reader.ReadObject()); | 203 EXPECT(Object::token_stream_class() == reader.ReadObject()); |
| 204 EXPECT(Object::script_class() == reader.ReadObject()); | 204 EXPECT(Object::script_class() == reader.ReadObject()); |
| 205 EXPECT(Object::library_class() == reader.ReadObject()); | 205 EXPECT(Object::library_class() == reader.ReadObject()); |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 445 | 445 |
| 446 Dart_ExitScope(); // Exit the Dart API scope. | 446 Dart_ExitScope(); // Exit the Dart API scope. |
| 447 } | 447 } |
| 448 Dart_ShutdownIsolate(); | 448 Dart_ShutdownIsolate(); |
| 449 | 449 |
| 450 free(buffer); | 450 free(buffer); |
| 451 } | 451 } |
| 452 #endif // TARGET_ARCH_IA32. | 452 #endif // TARGET_ARCH_IA32. |
| 453 | 453 |
| 454 } // namespace dart | 454 } // namespace dart |
| OLD | NEW |