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

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

Issue 566853005: Fix to allocation stub invalidation: we cannot just remove it as it will be collected even though c… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 3 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 | Annotate | Revision Log
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/stack_frame.h" 19 #include "vm/stack_frame.h"
20 #include "vm/tags.h" 20 #include "vm/tags.h"
21 #include "vm/verifier.h" 21 #include "vm/verifier.h"
22 #include "vm/virtual_memory.h" 22 #include "vm/virtual_memory.h"
23 #include "vm/weak_table.h" 23 #include "vm/weak_table.h"
24 24
25 namespace dart { 25 namespace dart {
26 26
27 DEFINE_FLAG(bool, verbose_gc, false, "Enables verbose GC."); 27 DEFINE_FLAG(bool, disable_alloc_stubs_after_gc, false, "Stress testing flag.");
28 DEFINE_FLAG(int, verbose_gc_hdr, 40, "Print verbose GC header interval.");
29 DEFINE_FLAG(bool, verify_before_gc, false,
30 "Enables heap verification before GC.");
31 DEFINE_FLAG(bool, verify_after_gc, false,
32 "Enables heap verification after GC.");
33 DEFINE_FLAG(bool, gc_at_alloc, false, "GC at every allocation."); 28 DEFINE_FLAG(bool, gc_at_alloc, false, "GC at every allocation.");
34 DEFINE_FLAG(int, new_gen_ext_limit, 64, 29 DEFINE_FLAG(int, new_gen_ext_limit, 64,
35 "maximum total external size (MB) in new gen before triggering GC"); 30 "maximum total external size (MB) in new gen before triggering GC");
31 DEFINE_FLAG(int, pretenure_interval, 10,
32 "Back off pretenuring after this many cycles.");
36 DEFINE_FLAG(int, pretenure_threshold, 98, 33 DEFINE_FLAG(int, pretenure_threshold, 98,
37 "Trigger pretenuring when this many percent are promoted."); 34 "Trigger pretenuring when this many percent are promoted.");
38 DEFINE_FLAG(int, pretenure_interval, 10, 35 DEFINE_FLAG(bool, verbose_gc, false, "Enables verbose GC.");
39 "Back off pretenuring after this many cycles."); 36 DEFINE_FLAG(int, verbose_gc_hdr, 40, "Print verbose GC header interval.");
37 DEFINE_FLAG(bool, verify_after_gc, false,
38 "Enables heap verification after GC.");
39 DEFINE_FLAG(bool, verify_before_gc, false,
40 "Enables heap verification before GC.");
41
40 42
41 Heap::Heap(Isolate* isolate, 43 Heap::Heap(Isolate* isolate,
42 intptr_t max_new_gen_semi_words, 44 intptr_t max_new_gen_semi_words,
43 intptr_t max_old_gen_words) 45 intptr_t max_old_gen_words)
44 : isolate_(isolate), 46 : isolate_(isolate),
45 read_only_(false), 47 read_only_(false),
46 gc_in_progress_(false), 48 gc_in_progress_(false),
47 pretenure_policy_(0) { 49 pretenure_policy_(0) {
48 for (int sel = 0; 50 for (int sel = 0;
49 sel < kNumWeakSelectors; 51 sel < kNumWeakSelectors;
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 bool Heap::ShouldPretenure(intptr_t class_id) const { 358 bool Heap::ShouldPretenure(intptr_t class_id) const {
357 if (class_id == kOneByteStringCid) { 359 if (class_id == kOneByteStringCid) {
358 return pretenure_policy_ > 0; 360 return pretenure_policy_ > 0;
359 } else { 361 } else {
360 return false; 362 return false;
361 } 363 }
362 } 364 }
363 365
364 366
365 void Heap::UpdatePretenurePolicy() { 367 void Heap::UpdatePretenurePolicy() {
368 if (FLAG_disable_alloc_stubs_after_gc) {
369 ClassTable* table = isolate_->class_table();
370 for (intptr_t cid = kNumPredefinedCids; cid < table->NumCids(); ++cid) {
371 if (table->IsValidIndex(cid) && table->HasValidClassAt(cid)) {
372 const Class& cls = Class::Handle(isolate_, table->At(cid));
373 cls.DisableAllocationStub();
374 }
375 }
376 }
366 ClassHeapStats* stats = 377 ClassHeapStats* stats =
367 isolate_->class_table()->StatsWithUpdatedSize(kOneByteStringCid); 378 isolate_->class_table()->StatsWithUpdatedSize(kOneByteStringCid);
368 int allocated = stats->pre_gc.new_count; 379 int allocated = stats->pre_gc.new_count;
369 int promo_percent = (allocated == 0) ? 0 : 380 int promo_percent = (allocated == 0) ? 0 :
370 (100 * stats->promoted_count) / allocated; 381 (100 * stats->promoted_count) / allocated;
371 if (promo_percent >= FLAG_pretenure_threshold) { 382 if (promo_percent >= FLAG_pretenure_threshold) {
372 pretenure_policy_ += FLAG_pretenure_interval; 383 pretenure_policy_ += FLAG_pretenure_interval;
373 } else { 384 } else {
374 pretenure_policy_ = Utils::Maximum(0, pretenure_policy_ - 1); 385 pretenure_policy_ = Utils::Maximum(0, pretenure_policy_ - 1);
375 } 386 }
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
688 heap->DisableGrowthControl(); 699 heap->DisableGrowthControl();
689 } 700 }
690 701
691 702
692 NoHeapGrowthControlScope::~NoHeapGrowthControlScope() { 703 NoHeapGrowthControlScope::~NoHeapGrowthControlScope() {
693 Heap* heap = reinterpret_cast<Isolate*>(isolate())->heap(); 704 Heap* heap = reinterpret_cast<Isolate*>(isolate())->heap();
694 heap->SetGrowthControlState(current_growth_controller_state_); 705 heap->SetGrowthControlState(current_growth_controller_state_);
695 } 706 }
696 707
697 } // namespace dart 708 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698