Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(159)

Side by Side Diff: runtime/vm/snapshot.cc

Issue 1970363002: Add timeline events for compiling static initializers and writing full snapshots. Remove timeline e… (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« runtime/vm/compiler.cc ('K') | « runtime/vm/snapshot.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "vm/dart_entry.h" 11 #include "vm/dart_entry.h"
12 #include "vm/exceptions.h" 12 #include "vm/exceptions.h"
13 #include "vm/heap.h" 13 #include "vm/heap.h"
14 #include "vm/lockers.h" 14 #include "vm/lockers.h"
15 #include "vm/longjump.h" 15 #include "vm/longjump.h"
16 #include "vm/object.h" 16 #include "vm/object.h"
17 #include "vm/object_store.h" 17 #include "vm/object_store.h"
18 #include "vm/snapshot_ids.h" 18 #include "vm/snapshot_ids.h"
19 #include "vm/stub_code.h" 19 #include "vm/stub_code.h"
20 #include "vm/symbols.h" 20 #include "vm/symbols.h"
21 #include "vm/timeline.h"
21 #include "vm/verified_memory.h" 22 #include "vm/verified_memory.h"
22 #include "vm/version.h" 23 #include "vm/version.h"
23 24
24 // We currently only expect the Dart mutator to read snapshots. 25 // We currently only expect the Dart mutator to read snapshots.
25 #define ASSERT_NO_SAFEPOINT_SCOPE() \ 26 #define ASSERT_NO_SAFEPOINT_SCOPE() \
26 isolate()->AssertCurrentThreadIsMutator(); \ 27 isolate()->AssertCurrentThreadIsMutator(); \
27 ASSERT(thread()->no_safepoint_scope_depth() != 0) 28 ASSERT(thread()->no_safepoint_scope_depth() != 0)
28 29
29 namespace dart { 30 namespace dart {
30 31
(...skipping 1153 matching lines...) Expand 10 before | Expand all | Expand 10 after
1184 ((c >= 'A') && (c <= 'Z')) || 1185 ((c >= 'A') && (c <= 'Z')) ||
1185 ((c >= '0') && (c <= '9'))) { 1186 ((c >= '0') && (c <= '9'))) {
1186 continue; 1187 continue;
1187 } 1188 }
1188 *label = '_'; 1189 *label = '_';
1189 } 1190 }
1190 } 1191 }
1191 1192
1192 1193
1193 void AssemblyInstructionsWriter::Write() { 1194 void AssemblyInstructionsWriter::Write() {
1194 Zone* zone = Thread::Current()->zone(); 1195 Thread* thread = Thread::Current();
1196 Zone* zone = thread->zone();
1197 NOT_IN_PRODUCT(TimelineDurationScope tds(thread,
1198 Timeline::GetIsolateStream(), "WriteInstructions"));
1195 1199
1196 // Handlify collected raw pointers as building the names below 1200 // Handlify collected raw pointers as building the names below
1197 // will allocate on the Dart heap. 1201 // will allocate on the Dart heap.
1198 for (intptr_t i = 0; i < instructions_.length(); i++) { 1202 for (intptr_t i = 0; i < instructions_.length(); i++) {
1199 InstructionsData& data = instructions_[i]; 1203 InstructionsData& data = instructions_[i];
1200 data.insns_ = &Instructions::Handle(zone, data.raw_insns_); 1204 data.insns_ = &Instructions::Handle(zone, data.raw_insns_);
1201 ASSERT(data.raw_code_ != NULL); 1205 ASSERT(data.raw_code_ != NULL);
1202 data.code_ = &Code::Handle(zone, data.raw_code_); 1206 data.code_ = &Code::Handle(zone, data.raw_code_);
1203 } 1207 }
1204 for (intptr_t i = 0; i < objects_.length(); i++) { 1208 for (intptr_t i = 0; i < objects_.length(); i++) {
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
1329 for (uword* cursor = reinterpret_cast<uword*>(start); 1333 for (uword* cursor = reinterpret_cast<uword*>(start);
1330 cursor < reinterpret_cast<uword*>(end); 1334 cursor < reinterpret_cast<uword*>(end);
1331 cursor++) { 1335 cursor++) {
1332 WriteWordLiteral(*cursor); 1336 WriteWordLiteral(*cursor);
1333 } 1337 }
1334 } 1338 }
1335 } 1339 }
1336 1340
1337 1341
1338 void BlobInstructionsWriter::Write() { 1342 void BlobInstructionsWriter::Write() {
1339 Zone* zone = Thread::Current()->zone(); 1343 Thread* thread = Thread::Current();
1344 Zone* zone = thread->zone();
1345 NOT_IN_PRODUCT(TimelineDurationScope tds(thread,
1346 Timeline::GetIsolateStream(), "WriteInstructions"));
1340 1347
1341 // Handlify collected raw pointers as building the names below 1348 // Handlify collected raw pointers as building the names below
1342 // will allocate on the Dart heap. 1349 // will allocate on the Dart heap.
1343 for (intptr_t i = 0; i < instructions_.length(); i++) { 1350 for (intptr_t i = 0; i < instructions_.length(); i++) {
1344 InstructionsData& data = instructions_[i]; 1351 InstructionsData& data = instructions_[i];
1345 data.insns_ = &Instructions::Handle(zone, data.raw_insns_); 1352 data.insns_ = &Instructions::Handle(zone, data.raw_insns_);
1346 ASSERT(data.raw_code_ != NULL); 1353 ASSERT(data.raw_code_ != NULL);
1347 data.code_ = &Code::Handle(zone, data.raw_code_); 1354 data.code_ = &Code::Handle(zone, data.raw_code_);
1348 } 1355 }
1349 for (intptr_t i = 0; i < objects_.length(); i++) { 1356 for (intptr_t i = 0; i < objects_.length(); i++) {
(...skipping 687 matching lines...) Expand 10 before | Expand all | Expand 10 after
2037 2044
2038 #if defined(DEBUG) 2045 #if defined(DEBUG)
2039 // Ensure the class table is valid. 2046 // Ensure the class table is valid.
2040 isolate()->ValidateClassTable(); 2047 isolate()->ValidateClassTable();
2041 #endif 2048 #endif
2042 // Can't have any mutation happening while we're serializing. 2049 // Can't have any mutation happening while we're serializing.
2043 ASSERT(isolate()->background_compiler() == NULL); 2050 ASSERT(isolate()->background_compiler() == NULL);
2044 2051
2045 intptr_t first_object_id = -1; 2052 intptr_t first_object_id = -1;
2046 if (vm_isolate_snapshot_buffer != NULL) { 2053 if (vm_isolate_snapshot_buffer != NULL) {
2054 NOT_IN_PRODUCT(TimelineDurationScope tds(thread(),
2055 Timeline::GetIsolateStream(), "PrepareNewVMIsolate"));
2056
2047 // Collect all the script objects and their accompanying token stream 2057 // Collect all the script objects and their accompanying token stream
2048 // objects into an array so that we can write it out as part of the VM 2058 // objects into an array so that we can write it out as part of the VM
2049 // isolate snapshot. We first count the number of script objects, allocate 2059 // isolate snapshot. We first count the number of script objects, allocate
2050 // an array and then fill it up with the script objects. 2060 // an array and then fill it up with the script objects.
2051 ScriptVisitor scripts_counter(thread()); 2061 ScriptVisitor scripts_counter(thread());
2052 heap()->IterateOldObjects(&scripts_counter); 2062 heap()->IterateOldObjects(&scripts_counter);
2053 Dart::vm_isolate()->heap()->IterateOldObjects(&scripts_counter); 2063 Dart::vm_isolate()->heap()->IterateOldObjects(&scripts_counter);
2054 intptr_t count = scripts_counter.count(); 2064 intptr_t count = scripts_counter.count();
2055 scripts_ = Array::New(count, Heap::kOld); 2065 scripts_ = Array::New(count, Heap::kOld);
2056 ScriptVisitor script_visitor(thread(), &scripts_); 2066 ScriptVisitor script_visitor(thread(), &scripts_);
(...skipping 30 matching lines...) Expand all
2087 if (!saved_symbol_table_.IsNull()) { 2097 if (!saved_symbol_table_.IsNull()) {
2088 isolate()->object_store()->set_symbol_table(saved_symbol_table_); 2098 isolate()->object_store()->set_symbol_table(saved_symbol_table_);
2089 saved_symbol_table_ = Array::null(); 2099 saved_symbol_table_ = Array::null();
2090 } 2100 }
2091 new_vm_symbol_table_ = Array::null(); 2101 new_vm_symbol_table_ = Array::null();
2092 scripts_ = Array::null(); 2102 scripts_ = Array::null();
2093 } 2103 }
2094 2104
2095 2105
2096 void FullSnapshotWriter::WriteVmIsolateSnapshot() { 2106 void FullSnapshotWriter::WriteVmIsolateSnapshot() {
2107 NOT_IN_PRODUCT(TimelineDurationScope tds(thread(),
2108 Timeline::GetIsolateStream(), "WriteVmIsolateSnapshot"));
2109
2097 ASSERT(vm_isolate_snapshot_buffer_ != NULL); 2110 ASSERT(vm_isolate_snapshot_buffer_ != NULL);
2098 SnapshotWriter writer(thread(), 2111 SnapshotWriter writer(thread(),
2099 kind_, 2112 kind_,
2100 vm_isolate_snapshot_buffer_, 2113 vm_isolate_snapshot_buffer_,
2101 alloc_, 2114 alloc_,
2102 kInitialSize, 2115 kInitialSize,
2103 forward_list_, 2116 forward_list_,
2104 instructions_writer_, 2117 instructions_writer_,
2105 true, /* can_send_any_object */ 2118 true, /* can_send_any_object */
2106 true /* writing_vm_isolate */); 2119 true /* writing_vm_isolate */);
(...skipping 29 matching lines...) Expand all
2136 writer.FillHeader(writer.kind()); 2149 writer.FillHeader(writer.kind());
2137 2150
2138 vm_isolate_snapshot_size_ = writer.BytesWritten(); 2151 vm_isolate_snapshot_size_ = writer.BytesWritten();
2139 } else { 2152 } else {
2140 writer.ThrowException(writer.exception_type(), writer.exception_msg()); 2153 writer.ThrowException(writer.exception_type(), writer.exception_msg());
2141 } 2154 }
2142 } 2155 }
2143 2156
2144 2157
2145 void FullSnapshotWriter::WriteIsolateFullSnapshot() { 2158 void FullSnapshotWriter::WriteIsolateFullSnapshot() {
2159 NOT_IN_PRODUCT(TimelineDurationScope tds(thread(),
2160 Timeline::GetIsolateStream(), "WriteIsolateFullSnapshot"));
2161
2146 SnapshotWriter writer(thread(), 2162 SnapshotWriter writer(thread(),
2147 kind_, 2163 kind_,
2148 isolate_snapshot_buffer_, 2164 isolate_snapshot_buffer_,
2149 alloc_, 2165 alloc_,
2150 kInitialSize, 2166 kInitialSize,
2151 forward_list_, 2167 forward_list_,
2152 instructions_writer_, 2168 instructions_writer_,
2153 true, /* can_send_any_object */ 2169 true, /* can_send_any_object */
2154 false /* writing_vm_isolate */); 2170 false /* writing_vm_isolate */);
2155 ObjectStore* object_store = isolate()->object_store(); 2171 ObjectStore* object_store = isolate()->object_store();
(...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after
2779 if (setjmp(*jump.Set()) == 0) { 2795 if (setjmp(*jump.Set()) == 0) {
2780 NoSafepointScope no_safepoint; 2796 NoSafepointScope no_safepoint;
2781 WriteObject(obj.raw()); 2797 WriteObject(obj.raw());
2782 } else { 2798 } else {
2783 ThrowException(exception_type(), exception_msg()); 2799 ThrowException(exception_type(), exception_msg());
2784 } 2800 }
2785 } 2801 }
2786 2802
2787 2803
2788 } // namespace dart 2804 } // namespace dart
OLDNEW
« runtime/vm/compiler.cc ('K') | « runtime/vm/snapshot.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698