| 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 "vm/snapshot.h" | 5 #include "vm/snapshot.h" |
| 6 | 6 |
| 7 #include "platform/assert.h" | 7 #include "platform/assert.h" |
| 8 #include "vm/bootstrap.h" | 8 #include "vm/bootstrap.h" |
| 9 #include "vm/class_finalizer.h" | 9 #include "vm/class_finalizer.h" |
| 10 #include "vm/dart.h" | 10 #include "vm/dart.h" |
| (...skipping 1178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1189 if (((c >= 'a') && (c <= 'z')) || | 1189 if (((c >= 'a') && (c <= 'z')) || |
| 1190 ((c >= 'A') && (c <= 'Z')) || | 1190 ((c >= 'A') && (c <= 'Z')) || |
| 1191 ((c >= '0') && (c <= '9'))) { | 1191 ((c >= '0') && (c <= '9'))) { |
| 1192 continue; | 1192 continue; |
| 1193 } | 1193 } |
| 1194 *label = '_'; | 1194 *label = '_'; |
| 1195 } | 1195 } |
| 1196 } | 1196 } |
| 1197 | 1197 |
| 1198 | 1198 |
| 1199 void InstructionsWriter::WriteAssembly() { | 1199 void AssemblyInstructionsWriter::Write() { |
| 1200 Zone* zone = Thread::Current()->zone(); | 1200 Zone* zone = Thread::Current()->zone(); |
| 1201 | 1201 |
| 1202 // Handlify collected raw pointers as building the names below | 1202 // Handlify collected raw pointers as building the names below |
| 1203 // will allocate on the Dart heap. | 1203 // will allocate on the Dart heap. |
| 1204 for (intptr_t i = 0; i < instructions_.length(); i++) { | 1204 for (intptr_t i = 0; i < instructions_.length(); i++) { |
| 1205 InstructionsData& data = instructions_[i]; | 1205 InstructionsData& data = instructions_[i]; |
| 1206 data.insns_ = &Instructions::Handle(zone, data.raw_insns_); | 1206 data.insns_ = &Instructions::Handle(zone, data.raw_insns_); |
| 1207 ASSERT(data.raw_code_ != NULL); | 1207 ASSERT(data.raw_code_ != NULL); |
| 1208 data.code_ = &Code::Handle(zone, data.raw_code_); | 1208 data.code_ = &Code::Handle(zone, data.raw_code_); |
| 1209 } | 1209 } |
| 1210 for (intptr_t i = 0; i < objects_.length(); i++) { | 1210 for (intptr_t i = 0; i < objects_.length(); i++) { |
| 1211 ObjectData& data = objects_[i]; | 1211 ObjectData& data = objects_[i]; |
| 1212 data.obj_ = &Object::Handle(zone, data.raw_obj_); | 1212 data.obj_ = &Object::Handle(zone, data.raw_obj_); |
| 1213 } | 1213 } |
| 1214 | 1214 |
| 1215 stream_.Print(".text\n"); | 1215 assembly_stream_.Print(".text\n"); |
| 1216 stream_.Print(".globl _kInstructionsSnapshot\n"); | 1216 assembly_stream_.Print(".globl _kInstructionsSnapshot\n"); |
| 1217 // Start snapshot at page boundary. | 1217 // Start snapshot at page boundary. |
| 1218 ASSERT(VirtualMemory::PageSize() >= OS::kMaxPreferredCodeAlignment); | 1218 ASSERT(VirtualMemory::PageSize() >= OS::kMaxPreferredCodeAlignment); |
| 1219 stream_.Print(".balign %" Pd ", 0\n", VirtualMemory::PageSize()); | 1219 assembly_stream_.Print(".balign %" Pd ", 0\n", VirtualMemory::PageSize()); |
| 1220 stream_.Print("_kInstructionsSnapshot:\n"); | 1220 assembly_stream_.Print("_kInstructionsSnapshot:\n"); |
| 1221 | 1221 |
| 1222 // This head also provides the gap to make the instructions snapshot | 1222 // This head also provides the gap to make the instructions snapshot |
| 1223 // look like a HeapPage. | 1223 // look like a HeapPage. |
| 1224 intptr_t instructions_length = next_offset_; | 1224 intptr_t instructions_length = next_offset_; |
| 1225 WriteWordLiteral(instructions_length); | 1225 WriteWordLiteral(instructions_length); |
| 1226 intptr_t header_words = InstructionsSnapshot::kHeaderSize / sizeof(uword); | 1226 intptr_t header_words = InstructionsSnapshot::kHeaderSize / sizeof(uword); |
| 1227 for (intptr_t i = 1; i < header_words; i++) { | 1227 for (intptr_t i = 1; i < header_words; i++) { |
| 1228 WriteWordLiteral(0); | 1228 WriteWordLiteral(0); |
| 1229 } | 1229 } |
| 1230 | 1230 |
| 1231 Object& owner = Object::Handle(zone); | 1231 Object& owner = Object::Handle(zone); |
| 1232 String& str = String::Handle(zone); | 1232 String& str = String::Handle(zone); |
| 1233 | 1233 |
| 1234 for (intptr_t i = 0; i < instructions_.length(); i++) { | 1234 for (intptr_t i = 0; i < instructions_.length(); i++) { |
| 1235 const Instructions& insns = *instructions_[i].insns_; | 1235 const Instructions& insns = *instructions_[i].insns_; |
| 1236 const Code& code = *instructions_[i].code_; | 1236 const Code& code = *instructions_[i].code_; |
| 1237 | 1237 |
| 1238 ASSERT(insns.raw()->Size() % sizeof(uint64_t) == 0); | 1238 ASSERT(insns.raw()->Size() % sizeof(uint64_t) == 0); |
| 1239 | 1239 |
| 1240 // 1. Write a label at the entry point. | 1240 // 1. Write a label at the entry point. |
| 1241 owner = code.owner(); | 1241 owner = code.owner(); |
| 1242 if (owner.IsNull()) { | 1242 if (owner.IsNull()) { |
| 1243 const char* name = StubCode::NameOfStub(insns.EntryPoint()); | 1243 const char* name = StubCode::NameOfStub(insns.EntryPoint()); |
| 1244 stream_.Print("Precompiled_Stub_%s:\n", name); | 1244 assembly_stream_.Print("Precompiled_Stub_%s:\n", name); |
| 1245 } else if (owner.IsClass()) { | 1245 } else if (owner.IsClass()) { |
| 1246 str = Class::Cast(owner).Name(); | 1246 str = Class::Cast(owner).Name(); |
| 1247 const char* name = str.ToCString(); | 1247 const char* name = str.ToCString(); |
| 1248 EnsureIdentifier(const_cast<char*>(name)); | 1248 EnsureIdentifier(const_cast<char*>(name)); |
| 1249 stream_.Print("Precompiled_AllocationStub_%s_%" Pd ":\n", name, i); | 1249 assembly_stream_.Print("Precompiled_AllocationStub_%s_%" Pd ":\n", |
| 1250 name, i); |
| 1250 } else if (owner.IsFunction()) { | 1251 } else if (owner.IsFunction()) { |
| 1251 const char* name = Function::Cast(owner).ToQualifiedCString(); | 1252 const char* name = Function::Cast(owner).ToQualifiedCString(); |
| 1252 EnsureIdentifier(const_cast<char*>(name)); | 1253 EnsureIdentifier(const_cast<char*>(name)); |
| 1253 stream_.Print("Precompiled_%s_%" Pd ":\n", name, i); | 1254 assembly_stream_.Print("Precompiled_%s_%" Pd ":\n", name, i); |
| 1254 } else { | 1255 } else { |
| 1255 UNREACHABLE(); | 1256 UNREACHABLE(); |
| 1256 } | 1257 } |
| 1257 | 1258 |
| 1258 { | 1259 { |
| 1259 // 2. Write from the entry point to the end. | 1260 // 2. Write from the entry point to the end. |
| 1260 NoSafepointScope no_safepoint; | 1261 NoSafepointScope no_safepoint; |
| 1261 uword beginning = reinterpret_cast<uword>(insns.raw()) - kHeapObjectTag; | 1262 uword beginning = reinterpret_cast<uword>(insns.raw()) - kHeapObjectTag; |
| 1262 uword entry = beginning + Instructions::HeaderSize(); | 1263 uword entry = beginning + Instructions::HeaderSize(); |
| 1263 uword payload_size = insns.size(); | 1264 uword payload_size = insns.size(); |
| 1264 payload_size = Utils::RoundUp(payload_size, OS::PreferredCodeAlignment()); | 1265 payload_size = Utils::RoundUp(payload_size, OS::PreferredCodeAlignment()); |
| 1265 uword end = entry + payload_size; | 1266 uword end = entry + payload_size; |
| 1266 | 1267 |
| 1267 ASSERT(Utils::IsAligned(beginning, sizeof(uint64_t))); | 1268 ASSERT(Utils::IsAligned(beginning, sizeof(uint64_t))); |
| 1268 ASSERT(Utils::IsAligned(entry, sizeof(uint64_t))); | 1269 ASSERT(Utils::IsAligned(entry, sizeof(uint64_t))); |
| 1269 ASSERT(Utils::IsAligned(end, sizeof(uint64_t))); | 1270 ASSERT(Utils::IsAligned(end, sizeof(uint64_t))); |
| 1270 | 1271 |
| 1271 for (uword* cursor = reinterpret_cast<uword*>(entry); | 1272 for (uword* cursor = reinterpret_cast<uword*>(entry); |
| 1272 cursor < reinterpret_cast<uword*>(end); | 1273 cursor < reinterpret_cast<uword*>(end); |
| 1273 cursor++) { | 1274 cursor++) { |
| 1274 WriteWordLiteral(*cursor); | 1275 WriteWordLiteral(*cursor); |
| 1275 } | 1276 } |
| 1276 } | 1277 } |
| 1277 } | 1278 } |
| 1278 #if defined(TARGET_OS_LINUX) | 1279 #if defined(TARGET_OS_LINUX) |
| 1279 stream_.Print(".section .rodata\n"); | 1280 assembly_stream_.Print(".section .rodata\n"); |
| 1280 #elif defined(TARGET_OS_MACOS) | 1281 #elif defined(TARGET_OS_MACOS) |
| 1281 stream_.Print(".const\n"); | 1282 assembly_stream_.Print(".const\n"); |
| 1282 #else | 1283 #else |
| 1283 // Unsupported platform. | 1284 // Unsupported platform. |
| 1284 UNREACHABLE(); | 1285 UNREACHABLE(); |
| 1285 #endif | 1286 #endif |
| 1286 stream_.Print(".globl _kDataSnapshot\n"); | 1287 assembly_stream_.Print(".globl _kDataSnapshot\n"); |
| 1287 // Start snapshot at page boundary. | 1288 // Start snapshot at page boundary. |
| 1288 stream_.Print(".balign %" Pd ", 0\n", VirtualMemory::PageSize()); | 1289 assembly_stream_.Print(".balign %" Pd ", 0\n", VirtualMemory::PageSize()); |
| 1289 stream_.Print("_kDataSnapshot:\n"); | 1290 assembly_stream_.Print("_kDataSnapshot:\n"); |
| 1290 WriteWordLiteral(next_object_offset_); // Data length. | 1291 WriteWordLiteral(next_object_offset_); // Data length. |
| 1291 COMPILE_ASSERT(OS::kMaxPreferredCodeAlignment >= kObjectAlignment); | 1292 COMPILE_ASSERT(OS::kMaxPreferredCodeAlignment >= kObjectAlignment); |
| 1292 stream_.Print(".balign %" Pd ", 0\n", OS::kMaxPreferredCodeAlignment); | 1293 assembly_stream_.Print(".balign %" Pd ", 0\n", |
| 1294 OS::kMaxPreferredCodeAlignment); |
| 1293 | 1295 |
| 1294 for (intptr_t i = 0; i < objects_.length(); i++) { | 1296 for (intptr_t i = 0; i < objects_.length(); i++) { |
| 1295 const Object& obj = *objects_[i].obj_; | 1297 const Object& obj = *objects_[i].obj_; |
| 1296 stream_.Print("Precompiled_Obj_%d:\n", i); | 1298 assembly_stream_.Print("Precompiled_Obj_%d:\n", i); |
| 1297 | 1299 |
| 1298 NoSafepointScope no_safepoint; | 1300 NoSafepointScope no_safepoint; |
| 1299 uword start = reinterpret_cast<uword>(obj.raw()) - kHeapObjectTag; | 1301 uword start = reinterpret_cast<uword>(obj.raw()) - kHeapObjectTag; |
| 1300 uword end = start + obj.raw()->Size(); | 1302 uword end = start + obj.raw()->Size(); |
| 1301 | 1303 |
| 1302 // Write object header with the mark and VM heap bits set. | 1304 // Write object header with the mark and VM heap bits set. |
| 1303 uword marked_tags = obj.raw()->ptr()->tags_; | 1305 uword marked_tags = obj.raw()->ptr()->tags_; |
| 1304 marked_tags = RawObject::VMHeapObjectTag::update(true, marked_tags); | 1306 marked_tags = RawObject::VMHeapObjectTag::update(true, marked_tags); |
| 1305 marked_tags = RawObject::MarkBit::update(true, marked_tags); | 1307 marked_tags = RawObject::MarkBit::update(true, marked_tags); |
| 1306 WriteWordLiteral(marked_tags); | 1308 WriteWordLiteral(marked_tags); |
| 1307 start += sizeof(uword); | 1309 start += sizeof(uword); |
| 1308 for (uword* cursor = reinterpret_cast<uword*>(start); | 1310 for (uword* cursor = reinterpret_cast<uword*>(start); |
| 1309 cursor < reinterpret_cast<uword*>(end); | 1311 cursor < reinterpret_cast<uword*>(end); |
| 1310 cursor++) { | 1312 cursor++) { |
| 1311 WriteWordLiteral(*cursor); | 1313 WriteWordLiteral(*cursor); |
| 1312 } | 1314 } |
| 1313 } | 1315 } |
| 1314 } | 1316 } |
| 1315 | 1317 |
| 1316 | 1318 |
| 1319 void BlobInstructionsWriter::Write() { |
| 1320 Zone* zone = Thread::Current()->zone(); |
| 1321 |
| 1322 // Handlify collected raw pointers as building the names below |
| 1323 // will allocate on the Dart heap. |
| 1324 for (intptr_t i = 0; i < instructions_.length(); i++) { |
| 1325 InstructionsData& data = instructions_[i]; |
| 1326 data.insns_ = &Instructions::Handle(zone, data.raw_insns_); |
| 1327 ASSERT(data.raw_code_ != NULL); |
| 1328 data.code_ = &Code::Handle(zone, data.raw_code_); |
| 1329 } |
| 1330 for (intptr_t i = 0; i < objects_.length(); i++) { |
| 1331 ObjectData& data = objects_[i]; |
| 1332 data.obj_ = &Object::Handle(zone, data.raw_obj_); |
| 1333 } |
| 1334 |
| 1335 // This head also provides the gap to make the instructions snapshot |
| 1336 // look like a HeapPage. |
| 1337 intptr_t instructions_length = next_offset_; |
| 1338 instructions_blob_stream_.WriteWord(instructions_length); |
| 1339 intptr_t header_words = InstructionsSnapshot::kHeaderSize / sizeof(uword); |
| 1340 for (intptr_t i = 1; i < header_words; i++) { |
| 1341 instructions_blob_stream_.WriteWord(0); |
| 1342 } |
| 1343 |
| 1344 for (intptr_t i = 0; i < instructions_.length(); i++) { |
| 1345 const Instructions& insns = *instructions_[i].insns_; |
| 1346 |
| 1347 { |
| 1348 // 2. Write from the entry point to the end. |
| 1349 NoSafepointScope no_safepoint; |
| 1350 uword beginning = reinterpret_cast<uword>(insns.raw()) - kHeapObjectTag; |
| 1351 uword entry = beginning + Instructions::HeaderSize(); |
| 1352 uword payload_size = insns.size(); |
| 1353 payload_size = Utils::RoundUp(payload_size, OS::PreferredCodeAlignment()); |
| 1354 uword end = entry + payload_size; |
| 1355 |
| 1356 ASSERT(Utils::IsAligned(beginning, sizeof(uint64_t))); |
| 1357 ASSERT(Utils::IsAligned(entry, sizeof(uint64_t))); |
| 1358 ASSERT(Utils::IsAligned(end, sizeof(uint64_t))); |
| 1359 |
| 1360 for (uword* cursor = reinterpret_cast<uword*>(entry); |
| 1361 cursor < reinterpret_cast<uword*>(end); |
| 1362 cursor++) { |
| 1363 instructions_blob_stream_.WriteWord(*cursor); |
| 1364 } |
| 1365 } |
| 1366 } |
| 1367 |
| 1368 rodata_blob_stream_.WriteWord(next_object_offset_); // Data length. |
| 1369 COMPILE_ASSERT(OS::kMaxPreferredCodeAlignment >= kObjectAlignment); |
| 1370 while (!Utils::IsAligned(rodata_blob_stream_.bytes_written(), |
| 1371 OS::kMaxPreferredCodeAlignment)) { |
| 1372 rodata_blob_stream_.WriteWord(0); |
| 1373 } |
| 1374 |
| 1375 for (intptr_t i = 0; i < objects_.length(); i++) { |
| 1376 const Object& obj = *objects_[i].obj_; |
| 1377 |
| 1378 NoSafepointScope no_safepoint; |
| 1379 uword start = reinterpret_cast<uword>(obj.raw()) - kHeapObjectTag; |
| 1380 uword end = start + obj.raw()->Size(); |
| 1381 |
| 1382 // Write object header with the mark and VM heap bits set. |
| 1383 uword marked_tags = obj.raw()->ptr()->tags_; |
| 1384 marked_tags = RawObject::VMHeapObjectTag::update(true, marked_tags); |
| 1385 marked_tags = RawObject::MarkBit::update(true, marked_tags); |
| 1386 rodata_blob_stream_.WriteWord(marked_tags); |
| 1387 start += sizeof(uword); |
| 1388 for (uword* cursor = reinterpret_cast<uword*>(start); |
| 1389 cursor < reinterpret_cast<uword*>(end); |
| 1390 cursor++) { |
| 1391 rodata_blob_stream_.WriteWord(*cursor); |
| 1392 } |
| 1393 } |
| 1394 } |
| 1395 |
| 1396 |
| 1317 uword InstructionsReader::GetInstructionsAt(int32_t offset) { | 1397 uword InstructionsReader::GetInstructionsAt(int32_t offset) { |
| 1318 ASSERT(Utils::IsAligned(offset, OS::PreferredCodeAlignment())); | 1398 ASSERT(Utils::IsAligned(offset, OS::PreferredCodeAlignment())); |
| 1319 return reinterpret_cast<uword>(instructions_buffer_) + offset; | 1399 return reinterpret_cast<uword>(instructions_buffer_) + offset; |
| 1320 } | 1400 } |
| 1321 | 1401 |
| 1322 | 1402 |
| 1323 RawObject* InstructionsReader::GetObjectAt(int32_t offset) { | 1403 RawObject* InstructionsReader::GetObjectAt(int32_t offset) { |
| 1324 ASSERT(Utils::IsAligned(offset, kWordSize)); | 1404 ASSERT(Utils::IsAligned(offset, kWordSize)); |
| 1325 | 1405 |
| 1326 RawObject* result = | 1406 RawObject* result = |
| (...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1876 | 1956 |
| 1877 private: | 1957 private: |
| 1878 Object& objHandle_; | 1958 Object& objHandle_; |
| 1879 intptr_t count_; | 1959 intptr_t count_; |
| 1880 const Array* scripts_; | 1960 const Array* scripts_; |
| 1881 }; | 1961 }; |
| 1882 | 1962 |
| 1883 | 1963 |
| 1884 FullSnapshotWriter::FullSnapshotWriter(uint8_t** vm_isolate_snapshot_buffer, | 1964 FullSnapshotWriter::FullSnapshotWriter(uint8_t** vm_isolate_snapshot_buffer, |
| 1885 uint8_t** isolate_snapshot_buffer, | 1965 uint8_t** isolate_snapshot_buffer, |
| 1886 uint8_t** instructions_snapshot_buffer, | |
| 1887 ReAlloc alloc, | 1966 ReAlloc alloc, |
| 1967 InstructionsWriter* instructions_writer, |
| 1888 bool snapshot_code, | 1968 bool snapshot_code, |
| 1889 bool vm_isolate_is_symbolic) | 1969 bool vm_isolate_is_symbolic) |
| 1890 : thread_(Thread::Current()), | 1970 : thread_(Thread::Current()), |
| 1891 vm_isolate_snapshot_buffer_(vm_isolate_snapshot_buffer), | 1971 vm_isolate_snapshot_buffer_(vm_isolate_snapshot_buffer), |
| 1892 isolate_snapshot_buffer_(isolate_snapshot_buffer), | 1972 isolate_snapshot_buffer_(isolate_snapshot_buffer), |
| 1893 instructions_snapshot_buffer_(instructions_snapshot_buffer), | |
| 1894 alloc_(alloc), | 1973 alloc_(alloc), |
| 1895 vm_isolate_snapshot_size_(0), | 1974 vm_isolate_snapshot_size_(0), |
| 1896 isolate_snapshot_size_(0), | 1975 isolate_snapshot_size_(0), |
| 1897 instructions_snapshot_size_(0), | |
| 1898 forward_list_(NULL), | 1976 forward_list_(NULL), |
| 1899 instructions_writer_(NULL), | 1977 instructions_writer_(instructions_writer), |
| 1900 scripts_(Array::Handle(zone())), | 1978 scripts_(Array::Handle(zone())), |
| 1901 symbol_table_(Array::Handle(zone())), | 1979 symbol_table_(Array::Handle(zone())), |
| 1902 snapshot_code_(snapshot_code), | 1980 snapshot_code_(snapshot_code), |
| 1903 vm_isolate_is_symbolic_(vm_isolate_is_symbolic) { | 1981 vm_isolate_is_symbolic_(vm_isolate_is_symbolic) { |
| 1904 ASSERT(isolate_snapshot_buffer_ != NULL); | 1982 ASSERT(isolate_snapshot_buffer_ != NULL); |
| 1905 ASSERT(alloc_ != NULL); | 1983 ASSERT(alloc_ != NULL); |
| 1906 ASSERT(isolate() != NULL); | 1984 ASSERT(isolate() != NULL); |
| 1907 ASSERT(ClassFinalizer::AllClassesFinalized()); | 1985 ASSERT(ClassFinalizer::AllClassesFinalized()); |
| 1908 ASSERT(isolate() != NULL); | 1986 ASSERT(isolate() != NULL); |
| 1909 ASSERT(heap() != NULL); | 1987 ASSERT(heap() != NULL); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1928 if (vm_isolate_snapshot_buffer != NULL) { | 2006 if (vm_isolate_snapshot_buffer != NULL) { |
| 1929 // Stash the symbol table away for writing and reading into the vm isolate, | 2007 // Stash the symbol table away for writing and reading into the vm isolate, |
| 1930 // and reset the symbol table for the regular isolate so that we do not | 2008 // and reset the symbol table for the regular isolate so that we do not |
| 1931 // write these symbols into the snapshot of a regular dart isolate. | 2009 // write these symbols into the snapshot of a regular dart isolate. |
| 1932 symbol_table_ = object_store->symbol_table(); | 2010 symbol_table_ = object_store->symbol_table(); |
| 1933 Symbols::SetupSymbolTable(isolate()); | 2011 Symbols::SetupSymbolTable(isolate()); |
| 1934 } | 2012 } |
| 1935 | 2013 |
| 1936 forward_list_ = new ForwardList(thread(), SnapshotWriter::FirstObjectId()); | 2014 forward_list_ = new ForwardList(thread(), SnapshotWriter::FirstObjectId()); |
| 1937 ASSERT(forward_list_ != NULL); | 2015 ASSERT(forward_list_ != NULL); |
| 1938 | |
| 1939 if (instructions_snapshot_buffer != NULL) { | |
| 1940 instructions_writer_ = new InstructionsWriter(instructions_snapshot_buffer, | |
| 1941 alloc, | |
| 1942 kInitialSize); | |
| 1943 } | |
| 1944 } | 2016 } |
| 1945 | 2017 |
| 1946 | 2018 |
| 1947 FullSnapshotWriter::~FullSnapshotWriter() { | 2019 FullSnapshotWriter::~FullSnapshotWriter() { |
| 1948 delete forward_list_; | 2020 delete forward_list_; |
| 1949 // We may run Dart code afterwards, restore the symbol table if needed. | 2021 // We may run Dart code afterwards, restore the symbol table if needed. |
| 1950 if (!symbol_table_.IsNull()) { | 2022 if (!symbol_table_.IsNull()) { |
| 1951 isolate()->object_store()->set_symbol_table(symbol_table_); | 2023 isolate()->object_store()->set_symbol_table(symbol_table_); |
| 1952 symbol_table_ = Array::null(); | 2024 symbol_table_ = Array::null(); |
| 1953 } | 2025 } |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2052 } | 2124 } |
| 2053 } | 2125 } |
| 2054 | 2126 |
| 2055 | 2127 |
| 2056 void FullSnapshotWriter::WriteFullSnapshot() { | 2128 void FullSnapshotWriter::WriteFullSnapshot() { |
| 2057 if (vm_isolate_snapshot_buffer() != NULL) { | 2129 if (vm_isolate_snapshot_buffer() != NULL) { |
| 2058 WriteVmIsolateSnapshot(); | 2130 WriteVmIsolateSnapshot(); |
| 2059 } | 2131 } |
| 2060 WriteIsolateFullSnapshot(); | 2132 WriteIsolateFullSnapshot(); |
| 2061 if (snapshot_code_) { | 2133 if (snapshot_code_) { |
| 2062 instructions_writer_->WriteAssembly(); | 2134 instructions_writer_->Write(); |
| 2063 instructions_snapshot_size_ = instructions_writer_->BytesWritten(); | |
| 2064 | 2135 |
| 2065 OS::Print("VMIsolate(CodeSize): %" Pd "\n", VmIsolateSnapshotSize()); | 2136 OS::Print("VMIsolate(CodeSize): %" Pd "\n", VmIsolateSnapshotSize()); |
| 2066 OS::Print("Isolate(CodeSize): %" Pd "\n", IsolateSnapshotSize()); | 2137 OS::Print("Isolate(CodeSize): %" Pd "\n", IsolateSnapshotSize()); |
| 2067 OS::Print("Instructions(CodeSize): %" Pd "\n", | 2138 OS::Print("Instructions(CodeSize): %" Pd "\n", |
| 2068 instructions_writer_->binary_size()); | 2139 instructions_writer_->binary_size()); |
| 2069 intptr_t total = VmIsolateSnapshotSize() + | 2140 intptr_t total = VmIsolateSnapshotSize() + |
| 2070 IsolateSnapshotSize() + | 2141 IsolateSnapshotSize() + |
| 2071 instructions_writer_->binary_size(); | 2142 instructions_writer_->binary_size(); |
| 2072 OS::Print("Total(CodeSize): %" Pd "\n", total); | 2143 OS::Print("Total(CodeSize): %" Pd "\n", total); |
| 2073 } | 2144 } |
| 2074 } | 2145 } |
| 2075 | 2146 |
| 2076 | 2147 |
| 2077 PrecompiledSnapshotWriter::PrecompiledSnapshotWriter( | 2148 PrecompiledSnapshotWriter::PrecompiledSnapshotWriter( |
| 2078 uint8_t** vm_isolate_snapshot_buffer, | 2149 uint8_t** vm_isolate_snapshot_buffer, |
| 2079 uint8_t** isolate_snapshot_buffer, | 2150 uint8_t** isolate_snapshot_buffer, |
| 2080 uint8_t** instructions_snapshot_buffer, | 2151 ReAlloc alloc, |
| 2081 ReAlloc alloc) | 2152 InstructionsWriter* instructions_writer) |
| 2082 : FullSnapshotWriter(vm_isolate_snapshot_buffer, | 2153 : FullSnapshotWriter(vm_isolate_snapshot_buffer, |
| 2083 isolate_snapshot_buffer, | 2154 isolate_snapshot_buffer, |
| 2084 instructions_snapshot_buffer, | |
| 2085 alloc, | 2155 alloc, |
| 2156 instructions_writer, |
| 2086 true, /* snapshot_code */ | 2157 true, /* snapshot_code */ |
| 2087 false /* vm_isolate_is_symbolic */) { | 2158 false /* vm_isolate_is_symbolic */) { |
| 2088 } | 2159 } |
| 2089 | 2160 |
| 2090 | 2161 |
| 2091 PrecompiledSnapshotWriter::~PrecompiledSnapshotWriter() {} | 2162 PrecompiledSnapshotWriter::~PrecompiledSnapshotWriter() {} |
| 2092 | 2163 |
| 2093 | 2164 |
| 2094 ForwardList::ForwardList(Thread* thread, intptr_t first_object_id) | 2165 ForwardList::ForwardList(Thread* thread, intptr_t first_object_id) |
| 2095 : thread_(thread), | 2166 : thread_(thread), |
| (...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2674 if (setjmp(*jump.Set()) == 0) { | 2745 if (setjmp(*jump.Set()) == 0) { |
| 2675 NoSafepointScope no_safepoint; | 2746 NoSafepointScope no_safepoint; |
| 2676 WriteObject(obj.raw()); | 2747 WriteObject(obj.raw()); |
| 2677 } else { | 2748 } else { |
| 2678 ThrowException(exception_type(), exception_msg()); | 2749 ThrowException(exception_type(), exception_msg()); |
| 2679 } | 2750 } |
| 2680 } | 2751 } |
| 2681 | 2752 |
| 2682 | 2753 |
| 2683 } // namespace dart | 2754 } // namespace dart |
| OLD | NEW |