@@ -11,8 +11,8 @@ namespace rubinius {
11
11
diagnostics::Diagnostics::log ();
12
12
13
13
utilities::logger::write (" code manager: diagnostics: " \
14
- " chunks: %ld, objects: %ld, bytes: %ld" ,
15
- chunks_, objects_, bytes_);
14
+ " collections: %ld, chunks: %ld, objects: %ld, bytes: %ld" ,
15
+ collections_, chunks_, objects_, bytes_);
16
16
}
17
17
18
18
CodeManager::Chunk::Chunk (int size)
@@ -33,11 +33,6 @@ namespace rubinius {
33
33
, last_chunk_(0 )
34
34
, current_chunk_(0 )
35
35
, current_index_(0 )
36
- , freed_resources_(0 )
37
- , total_allocated_(0 )
38
- , total_freed_(0 )
39
- , gc_triggered_(0 )
40
- , bytes_used_(0 )
41
36
, diagnostics_(Diagnostics())
42
37
{
43
38
first_chunk_ = new Chunk (chunk_size_);
@@ -68,20 +63,11 @@ namespace rubinius {
68
63
last_chunk_->next = c;
69
64
last_chunk_ = c;
70
65
current_chunk_ = c;
71
- diagnostics_.chunks_ ++;
72
66
}
73
67
74
68
void CodeManager::add_resource (CodeResource* cr, bool * collect_now) {
75
69
utilities::thread::Mutex::LockGuard guard (mutex_);
76
70
77
- total_allocated_ += cr->size ();
78
- bytes_used_ += cr->size ();
79
-
80
- if (total_allocated_ - gc_triggered_ > cGCTriggerThreshold) {
81
- gc_triggered_ = total_allocated_;
82
- *collect_now = true ;
83
- }
84
-
85
71
for (;;) {
86
72
while (current_index_ < chunk_size_) {
87
73
if (current_chunk_->resources [current_index_] == 0 ) {
@@ -95,15 +81,19 @@ namespace rubinius {
95
81
// Move on to the next one or add a new one
96
82
current_index_ = 0 ;
97
83
current_chunk_ = current_chunk_->next ;
98
- if (!current_chunk_) add_chunk ();
84
+ if (!current_chunk_) {
85
+ add_chunk ();
86
+ *collect_now = true ;
87
+ diagnostics_.collections_ ++;
88
+ }
99
89
}
100
90
}
101
91
102
92
void CodeManager::sweep () {
103
93
Chunk* chunk = first_chunk_;
104
94
Chunk* prev = NULL ;
105
95
106
- freed_resources_ = 0 ;
96
+ diagnostics_ = Diagnostics (diagnostics_. collections_ ) ;
107
97
108
98
State state (shared_->root_vm ());
109
99
@@ -112,10 +102,6 @@ namespace rubinius {
112
102
for (int i = 0 ; i < chunk_size_; i++) {
113
103
if (CodeResource* cr = chunk->resources [i]) {
114
104
if (!cr->marked ()) {
115
- total_freed_ += cr->size ();
116
- bytes_used_ -= cr->size ();
117
-
118
- freed_resources_++;
119
105
cr->cleanup (&state, this );
120
106
delete cr;
121
107
chunk->resources [i] = 0 ;
@@ -148,14 +134,14 @@ namespace rubinius {
148
134
}
149
135
delete chunk;
150
136
chunk = prev->next ;
151
- diagnostics_.chunks_ --;
152
137
} else {
153
138
prev = chunk;
154
139
chunk = chunk->next ;
140
+ diagnostics_.chunks_ ++;
155
141
}
156
-
157
- diagnostics_.modify ();
158
142
}
143
+
144
+ diagnostics_.modify ();
159
145
}
160
146
161
147
void CodeManager::clear_marks () {
0 commit comments