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 1899 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1910 // into an array so that we can write it out as part of the VM isolate | 1910 // into an array so that we can write it out as part of the VM isolate |
1911 // snapshot. We first count the number of script objects, allocate an array | 1911 // snapshot. We first count the number of script objects, allocate an array |
1912 // and then fill it up with the script objects. | 1912 // and then fill it up with the script objects. |
1913 ScriptVisitor scripts_counter(thread()); | 1913 ScriptVisitor scripts_counter(thread()); |
1914 heap()->IterateOldObjects(&scripts_counter); | 1914 heap()->IterateOldObjects(&scripts_counter); |
1915 intptr_t count = scripts_counter.count(); | 1915 intptr_t count = scripts_counter.count(); |
1916 scripts_ = Array::New(count, Heap::kOld); | 1916 scripts_ = Array::New(count, Heap::kOld); |
1917 ScriptVisitor script_visitor(thread(), &scripts_); | 1917 ScriptVisitor script_visitor(thread(), &scripts_); |
1918 heap()->IterateOldObjects(&script_visitor); | 1918 heap()->IterateOldObjects(&script_visitor); |
1919 | 1919 |
1920 // Stash the symbol table away for writing and reading into the vm isolate, | 1920 if (vm_isolate_snapshot_buffer != NULL) { |
1921 // and reset the symbol table for the regular isolate so that we do not | 1921 // Stash the symbol table away for writing and reading into the vm isolate, |
1922 // write these symbols into the snapshot of a regular dart isolate. | 1922 // and reset the symbol table for the regular isolate so that we do not |
1923 symbol_table_ = object_store->symbol_table(); | 1923 // write these symbols into the snapshot of a regular dart isolate. |
1924 Symbols::SetupSymbolTable(isolate()); | 1924 symbol_table_ = object_store->symbol_table(); |
| 1925 Symbols::SetupSymbolTable(isolate()); |
| 1926 } |
1925 | 1927 |
1926 forward_list_ = new ForwardList(thread(), SnapshotWriter::FirstObjectId()); | 1928 forward_list_ = new ForwardList(thread(), SnapshotWriter::FirstObjectId()); |
1927 ASSERT(forward_list_ != NULL); | 1929 ASSERT(forward_list_ != NULL); |
1928 | 1930 |
1929 if (instructions_snapshot_buffer != NULL) { | 1931 if (instructions_snapshot_buffer != NULL) { |
1930 instructions_writer_ = new InstructionsWriter(instructions_snapshot_buffer, | 1932 instructions_writer_ = new InstructionsWriter(instructions_snapshot_buffer, |
1931 alloc, | 1933 alloc, |
1932 kInitialSize); | 1934 kInitialSize); |
1933 } | 1935 } |
1934 } | 1936 } |
1935 | 1937 |
1936 | 1938 |
1937 FullSnapshotWriter::~FullSnapshotWriter() { | 1939 FullSnapshotWriter::~FullSnapshotWriter() { |
1938 delete forward_list_; | 1940 delete forward_list_; |
1939 // We may run Dart code afterwards, restore the symbol table. | 1941 // We may run Dart code afterwards, restore the symbol table if needed. |
1940 isolate()->object_store()->set_symbol_table(symbol_table_); | 1942 if (!symbol_table_.IsNull()) { |
1941 symbol_table_ = Array::null(); | 1943 isolate()->object_store()->set_symbol_table(symbol_table_); |
| 1944 symbol_table_ = Array::null(); |
| 1945 } |
1942 scripts_ = Array::null(); | 1946 scripts_ = Array::null(); |
1943 } | 1947 } |
1944 | 1948 |
1945 | 1949 |
1946 void FullSnapshotWriter::WriteVmIsolateSnapshot() { | 1950 void FullSnapshotWriter::WriteVmIsolateSnapshot() { |
1947 ASSERT(vm_isolate_snapshot_buffer_ != NULL); | 1951 ASSERT(vm_isolate_snapshot_buffer_ != NULL); |
1948 SnapshotWriter writer(Snapshot::kFull, | 1952 SnapshotWriter writer(Snapshot::kFull, |
1949 thread(), | 1953 thread(), |
1950 vm_isolate_snapshot_buffer_, | 1954 vm_isolate_snapshot_buffer_, |
1951 alloc_, | 1955 alloc_, |
(...skipping 710 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2662 if (setjmp(*jump.Set()) == 0) { | 2666 if (setjmp(*jump.Set()) == 0) { |
2663 NoSafepointScope no_safepoint; | 2667 NoSafepointScope no_safepoint; |
2664 WriteObject(obj.raw()); | 2668 WriteObject(obj.raw()); |
2665 } else { | 2669 } else { |
2666 ThrowException(exception_type(), exception_msg()); | 2670 ThrowException(exception_type(), exception_msg()); |
2667 } | 2671 } |
2668 } | 2672 } |
2669 | 2673 |
2670 | 2674 |
2671 } // namespace dart | 2675 } // namespace dart |
OLD | NEW |