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" |
(...skipping 926 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
937 " }\n" | 937 " }\n" |
938 "}\n"; | 938 "}\n"; |
939 | 939 |
940 String& url = String::Handle(String::New("dart-test:SerializeScript")); | 940 String& url = String::Handle(String::New("dart-test:SerializeScript")); |
941 String& source = String::Handle(String::New(kScriptChars)); | 941 String& source = String::Handle(String::New(kScriptChars)); |
942 Script& script = Script::Handle(Script::New(url, | 942 Script& script = Script::Handle(Script::New(url, |
943 source, | 943 source, |
944 RawScript::kScriptTag)); | 944 RawScript::kScriptTag)); |
945 const String& lib_url = String::Handle(Symbols::New(thread, "TestLib")); | 945 const String& lib_url = String::Handle(Symbols::New(thread, "TestLib")); |
946 Library& lib = Library::Handle(Library::New(lib_url)); | 946 Library& lib = Library::Handle(Library::New(lib_url)); |
947 lib.Register(); | 947 lib.Register(thread); |
948 EXPECT(CompilerTest::TestCompileScript(lib, script)); | 948 EXPECT(CompilerTest::TestCompileScript(lib, script)); |
949 | 949 |
950 // Write snapshot with script content. | 950 // Write snapshot with script content. |
951 uint8_t* buffer; | 951 uint8_t* buffer; |
952 TestSnapshotWriter writer(&buffer, &malloc_allocator); | 952 TestSnapshotWriter writer(&buffer, &malloc_allocator); |
953 writer.WriteScript(script); | 953 writer.WriteScript(script); |
954 | 954 |
955 // Read object back from the snapshot. | 955 // Read object back from the snapshot. |
956 ScriptSnapshotReader reader(buffer, writer.BytesWritten(), thread); | 956 ScriptSnapshotReader reader(buffer, writer.BytesWritten(), thread); |
957 Script& serialized_script = Script::Handle(thread->zone()); | 957 Script& serialized_script = Script::Handle(thread->zone()); |
(...skipping 2050 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3008 StackZone zone(Thread::Current()); | 3008 StackZone zone(Thread::Current()); |
3009 uint8_t* buffer; | 3009 uint8_t* buffer; |
3010 MessageWriter writer(&buffer, &zone_allocator, true); | 3010 MessageWriter writer(&buffer, &zone_allocator, true); |
3011 writer.WriteInlinedObjectHeader(kOmittedObjectId); | 3011 writer.WriteInlinedObjectHeader(kOmittedObjectId); |
3012 // For performance, we'd like single-byte headers when ids are omitted. | 3012 // For performance, we'd like single-byte headers when ids are omitted. |
3013 // If this starts failing, consider renumbering the snapshot ids. | 3013 // If this starts failing, consider renumbering the snapshot ids. |
3014 EXPECT_EQ(1, writer.BytesWritten()); | 3014 EXPECT_EQ(1, writer.BytesWritten()); |
3015 } | 3015 } |
3016 | 3016 |
3017 } // namespace dart | 3017 } // namespace dart |
OLD | NEW |