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

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

Issue 1170503004: Initial Timeline Events (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 6 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
« no previous file with comments | « runtime/vm/deopt_instructions.cc ('k') | runtime/vm/isolate.h » ('j') | 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/heap.h" 5 #include "vm/heap.h"
6 6
7 #include "platform/assert.h" 7 #include "platform/assert.h"
8 #include "platform/utils.h" 8 #include "platform/utils.h"
9 #include "vm/flags.h" 9 #include "vm/flags.h"
10 #include "vm/isolate.h" 10 #include "vm/isolate.h"
11 #include "vm/lockers.h" 11 #include "vm/lockers.h"
12 #include "vm/object.h" 12 #include "vm/object.h"
13 #include "vm/object_set.h" 13 #include "vm/object_set.h"
14 #include "vm/os.h" 14 #include "vm/os.h"
15 #include "vm/pages.h" 15 #include "vm/pages.h"
16 #include "vm/raw_object.h" 16 #include "vm/raw_object.h"
17 #include "vm/scavenger.h" 17 #include "vm/scavenger.h"
18 #include "vm/service.h" 18 #include "vm/service.h"
19 #include "vm/service_event.h" 19 #include "vm/service_event.h"
20 #include "vm/stack_frame.h" 20 #include "vm/stack_frame.h"
21 #include "vm/tags.h" 21 #include "vm/tags.h"
22 #include "vm/timeline.h"
22 #include "vm/verifier.h" 23 #include "vm/verifier.h"
23 #include "vm/virtual_memory.h" 24 #include "vm/virtual_memory.h"
24 #include "vm/weak_table.h" 25 #include "vm/weak_table.h"
25 26
26 namespace dart { 27 namespace dart {
27 28
28 DEFINE_FLAG(bool, disable_alloc_stubs_after_gc, false, "Stress testing flag."); 29 DEFINE_FLAG(bool, disable_alloc_stubs_after_gc, false, "Stress testing flag.");
29 DEFINE_FLAG(bool, gc_at_alloc, false, "GC at every allocation."); 30 DEFINE_FLAG(bool, gc_at_alloc, false, "GC at every allocation.");
30 DEFINE_FLAG(int, new_gen_ext_limit, 64, 31 DEFINE_FLAG(int, new_gen_ext_limit, 64,
31 "maximum total external size (MB) in new gen before triggering GC"); 32 "maximum total external size (MB) in new gen before triggering GC");
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 265
265 266
266 void Heap::CollectGarbage(Space space, 267 void Heap::CollectGarbage(Space space,
267 ApiCallbacks api_callbacks, 268 ApiCallbacks api_callbacks,
268 GCReason reason) { 269 GCReason reason) {
269 TIMERSCOPE(isolate(), time_gc); 270 TIMERSCOPE(isolate(), time_gc);
270 bool invoke_api_callbacks = (api_callbacks == kInvokeApiCallbacks); 271 bool invoke_api_callbacks = (api_callbacks == kInvokeApiCallbacks);
271 switch (space) { 272 switch (space) {
272 case kNew: { 273 case kNew: {
273 VMTagScope tagScope(isolate(), VMTag::kGCNewSpaceTagId); 274 VMTagScope tagScope(isolate(), VMTag::kGCNewSpaceTagId);
275 TimelineDurationScope tds(isolate(),
276 isolate()->GetGCStream(),
277 "CollectNewGeneration");
274 RecordBeforeGC(kNew, reason); 278 RecordBeforeGC(kNew, reason);
275 UpdateClassHeapStatsBeforeGC(kNew); 279 UpdateClassHeapStatsBeforeGC(kNew);
276 new_space_->Scavenge(invoke_api_callbacks); 280 new_space_->Scavenge(invoke_api_callbacks);
277 isolate()->class_table()->UpdatePromoted(); 281 isolate()->class_table()->UpdatePromoted();
278 UpdatePretenurePolicy(); 282 UpdatePretenurePolicy();
279 RecordAfterGC(); 283 RecordAfterGC();
280 PrintStats(); 284 PrintStats();
281 if (old_space_->NeedsGarbageCollection()) { 285 if (old_space_->NeedsGarbageCollection()) {
282 // Old collections should call the API callbacks. 286 // Old collections should call the API callbacks.
283 CollectGarbage(kOld, kInvokeApiCallbacks, kPromotion); 287 CollectGarbage(kOld, kInvokeApiCallbacks, kPromotion);
284 } 288 }
285 break; 289 break;
286 } 290 }
287 case kOld: 291 case kOld:
288 case kCode: { 292 case kCode: {
289 VMTagScope tagScope(isolate(), VMTag::kGCOldSpaceTagId); 293 VMTagScope tagScope(isolate(), VMTag::kGCOldSpaceTagId);
294 TimelineDurationScope tds(isolate(),
295 isolate()->GetGCStream(),
296 "CollectOldGeneration");
290 RecordBeforeGC(kOld, reason); 297 RecordBeforeGC(kOld, reason);
291 UpdateClassHeapStatsBeforeGC(kOld); 298 UpdateClassHeapStatsBeforeGC(kOld);
292 old_space_->MarkSweep(invoke_api_callbacks); 299 old_space_->MarkSweep(invoke_api_callbacks);
293 RecordAfterGC(); 300 RecordAfterGC();
294 PrintStats(); 301 PrintStats();
295 break; 302 break;
296 } 303 }
297 default: 304 default:
298 UNREACHABLE(); 305 UNREACHABLE();
299 } 306 }
(...skipping 17 matching lines...) Expand all
317 ASSERT(space == kNew); 324 ASSERT(space == kNew);
318 CollectGarbage(space, kInvokeApiCallbacks, kNewSpace); 325 CollectGarbage(space, kInvokeApiCallbacks, kNewSpace);
319 } 326 }
320 } 327 }
321 328
322 329
323 void Heap::CollectAllGarbage() { 330 void Heap::CollectAllGarbage() {
324 TIMERSCOPE(isolate(), time_gc); 331 TIMERSCOPE(isolate(), time_gc);
325 { 332 {
326 VMTagScope tagScope(isolate(), VMTag::kGCNewSpaceTagId); 333 VMTagScope tagScope(isolate(), VMTag::kGCNewSpaceTagId);
334 TimelineDurationScope tds(isolate(),
335 isolate()->GetGCStream(),
336 "CollectNewGeneration");
327 RecordBeforeGC(kNew, kFull); 337 RecordBeforeGC(kNew, kFull);
328 UpdateClassHeapStatsBeforeGC(kNew); 338 UpdateClassHeapStatsBeforeGC(kNew);
329 new_space_->Scavenge(kInvokeApiCallbacks); 339 new_space_->Scavenge(kInvokeApiCallbacks);
330 isolate()->class_table()->UpdatePromoted(); 340 isolate()->class_table()->UpdatePromoted();
331 UpdatePretenurePolicy(); 341 UpdatePretenurePolicy();
332 RecordAfterGC(); 342 RecordAfterGC();
333 PrintStats(); 343 PrintStats();
334 } 344 }
335 { 345 {
336 VMTagScope tagScope(isolate(), VMTag::kGCOldSpaceTagId); 346 VMTagScope tagScope(isolate(), VMTag::kGCOldSpaceTagId);
347 TimelineDurationScope tds(isolate(),
348 isolate()->GetGCStream(),
349 "CollectOldGeneration");
337 RecordBeforeGC(kOld, kFull); 350 RecordBeforeGC(kOld, kFull);
338 UpdateClassHeapStatsBeforeGC(kOld); 351 UpdateClassHeapStatsBeforeGC(kOld);
339 old_space_->MarkSweep(kInvokeApiCallbacks); 352 old_space_->MarkSweep(kInvokeApiCallbacks);
340 RecordAfterGC(); 353 RecordAfterGC();
341 PrintStats(); 354 PrintStats();
342 } 355 }
343 } 356 }
344 357
345 358
346 bool Heap::ShouldPretenure(intptr_t class_id) const { 359 bool Heap::ShouldPretenure(intptr_t class_id) const {
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
701 heap->DisableGrowthControl(); 714 heap->DisableGrowthControl();
702 } 715 }
703 716
704 717
705 NoHeapGrowthControlScope::~NoHeapGrowthControlScope() { 718 NoHeapGrowthControlScope::~NoHeapGrowthControlScope() {
706 Heap* heap = reinterpret_cast<Isolate*>(isolate())->heap(); 719 Heap* heap = reinterpret_cast<Isolate*>(isolate())->heap();
707 heap->SetGrowthControlState(current_growth_controller_state_); 720 heap->SetGrowthControlState(current_growth_controller_state_);
708 } 721 }
709 722
710 } // namespace dart 723 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/deopt_instructions.cc ('k') | runtime/vm/isolate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698