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

Side by Side Diff: src/heap.cc

Issue 141363005: A64: Synchronize with r15204. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/a64
Patch Set: Created 6 years, 11 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
« no previous file with comments | « src/heap.h ('k') | src/heap-inl.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 contexts_disposed_(0), 98 contexts_disposed_(0),
99 global_ic_age_(0), 99 global_ic_age_(0),
100 flush_monomorphic_ics_(false), 100 flush_monomorphic_ics_(false),
101 scan_on_scavenge_pages_(0), 101 scan_on_scavenge_pages_(0),
102 new_space_(this), 102 new_space_(this),
103 old_pointer_space_(NULL), 103 old_pointer_space_(NULL),
104 old_data_space_(NULL), 104 old_data_space_(NULL),
105 code_space_(NULL), 105 code_space_(NULL),
106 map_space_(NULL), 106 map_space_(NULL),
107 cell_space_(NULL), 107 cell_space_(NULL),
108 property_cell_space_(NULL),
108 lo_space_(NULL), 109 lo_space_(NULL),
109 gc_state_(NOT_IN_GC), 110 gc_state_(NOT_IN_GC),
110 gc_post_processing_depth_(0), 111 gc_post_processing_depth_(0),
111 ms_count_(0), 112 ms_count_(0),
112 gc_count_(0), 113 gc_count_(0),
113 remembered_unmapped_pages_index_(0), 114 remembered_unmapped_pages_index_(0),
114 unflattened_strings_length_(0), 115 unflattened_strings_length_(0),
115 #ifdef DEBUG 116 #ifdef DEBUG
116 allocation_timeout_(0), 117 allocation_timeout_(0),
117 disallow_allocation_failure_(false), 118 disallow_allocation_failure_(false),
(...skipping 26 matching lines...) Expand all
144 last_gc_end_timestamp_(0.0), 145 last_gc_end_timestamp_(0.0),
145 marking_time_(0.0), 146 marking_time_(0.0),
146 sweeping_time_(0.0), 147 sweeping_time_(0.0),
147 store_buffer_(this), 148 store_buffer_(this),
148 marking_(this), 149 marking_(this),
149 incremental_marking_(this), 150 incremental_marking_(this),
150 number_idle_notifications_(0), 151 number_idle_notifications_(0),
151 last_idle_notification_gc_count_(0), 152 last_idle_notification_gc_count_(0),
152 last_idle_notification_gc_count_init_(false), 153 last_idle_notification_gc_count_init_(false),
153 mark_sweeps_since_idle_round_started_(0), 154 mark_sweeps_since_idle_round_started_(0),
154 ms_count_at_last_idle_notification_(0),
155 gc_count_at_last_idle_gc_(0), 155 gc_count_at_last_idle_gc_(0),
156 scavenges_since_last_idle_round_(kIdleScavengeThreshold), 156 scavenges_since_last_idle_round_(kIdleScavengeThreshold),
157 gcs_since_last_deopt_(0), 157 gcs_since_last_deopt_(0),
158 #ifdef VERIFY_HEAP 158 #ifdef VERIFY_HEAP
159 no_weak_embedded_maps_verification_scope_depth_(0), 159 no_weak_embedded_maps_verification_scope_depth_(0),
160 #endif 160 #endif
161 promotion_queue_(this), 161 promotion_queue_(this),
162 configured_(false), 162 configured_(false),
163 chunks_queued_for_free_(NULL), 163 chunks_queued_for_free_(NULL),
164 relocation_mutex_(NULL) { 164 relocation_mutex_(NULL) {
(...skipping 27 matching lines...) Expand all
192 192
193 193
194 intptr_t Heap::Capacity() { 194 intptr_t Heap::Capacity() {
195 if (!HasBeenSetUp()) return 0; 195 if (!HasBeenSetUp()) return 0;
196 196
197 return new_space_.Capacity() + 197 return new_space_.Capacity() +
198 old_pointer_space_->Capacity() + 198 old_pointer_space_->Capacity() +
199 old_data_space_->Capacity() + 199 old_data_space_->Capacity() +
200 code_space_->Capacity() + 200 code_space_->Capacity() +
201 map_space_->Capacity() + 201 map_space_->Capacity() +
202 cell_space_->Capacity(); 202 cell_space_->Capacity() +
203 property_cell_space_->Capacity();
203 } 204 }
204 205
205 206
206 intptr_t Heap::CommittedMemory() { 207 intptr_t Heap::CommittedMemory() {
207 if (!HasBeenSetUp()) return 0; 208 if (!HasBeenSetUp()) return 0;
208 209
209 return new_space_.CommittedMemory() + 210 return new_space_.CommittedMemory() +
210 old_pointer_space_->CommittedMemory() + 211 old_pointer_space_->CommittedMemory() +
211 old_data_space_->CommittedMemory() + 212 old_data_space_->CommittedMemory() +
212 code_space_->CommittedMemory() + 213 code_space_->CommittedMemory() +
213 map_space_->CommittedMemory() + 214 map_space_->CommittedMemory() +
214 cell_space_->CommittedMemory() + 215 cell_space_->CommittedMemory() +
216 property_cell_space_->CommittedMemory() +
215 lo_space_->Size(); 217 lo_space_->Size();
216 } 218 }
217 219
218 220
219 size_t Heap::CommittedPhysicalMemory() { 221 size_t Heap::CommittedPhysicalMemory() {
220 if (!HasBeenSetUp()) return 0; 222 if (!HasBeenSetUp()) return 0;
221 223
222 return new_space_.CommittedPhysicalMemory() + 224 return new_space_.CommittedPhysicalMemory() +
223 old_pointer_space_->CommittedPhysicalMemory() + 225 old_pointer_space_->CommittedPhysicalMemory() +
224 old_data_space_->CommittedPhysicalMemory() + 226 old_data_space_->CommittedPhysicalMemory() +
225 code_space_->CommittedPhysicalMemory() + 227 code_space_->CommittedPhysicalMemory() +
226 map_space_->CommittedPhysicalMemory() + 228 map_space_->CommittedPhysicalMemory() +
227 cell_space_->CommittedPhysicalMemory() + 229 cell_space_->CommittedPhysicalMemory() +
230 property_cell_space_->CommittedPhysicalMemory() +
228 lo_space_->CommittedPhysicalMemory(); 231 lo_space_->CommittedPhysicalMemory();
229 } 232 }
230 233
231 234
232 intptr_t Heap::CommittedMemoryExecutable() { 235 intptr_t Heap::CommittedMemoryExecutable() {
233 if (!HasBeenSetUp()) return 0; 236 if (!HasBeenSetUp()) return 0;
234 237
235 return isolate()->memory_allocator()->SizeExecutable(); 238 return isolate()->memory_allocator()->SizeExecutable();
236 } 239 }
237 240
238 241
239 intptr_t Heap::Available() { 242 intptr_t Heap::Available() {
240 if (!HasBeenSetUp()) return 0; 243 if (!HasBeenSetUp()) return 0;
241 244
242 return new_space_.Available() + 245 return new_space_.Available() +
243 old_pointer_space_->Available() + 246 old_pointer_space_->Available() +
244 old_data_space_->Available() + 247 old_data_space_->Available() +
245 code_space_->Available() + 248 code_space_->Available() +
246 map_space_->Available() + 249 map_space_->Available() +
247 cell_space_->Available(); 250 cell_space_->Available() +
251 property_cell_space_->Available();
248 } 252 }
249 253
250 254
251 bool Heap::HasBeenSetUp() { 255 bool Heap::HasBeenSetUp() {
252 return old_pointer_space_ != NULL && 256 return old_pointer_space_ != NULL &&
253 old_data_space_ != NULL && 257 old_data_space_ != NULL &&
254 code_space_ != NULL && 258 code_space_ != NULL &&
255 map_space_ != NULL && 259 map_space_ != NULL &&
256 cell_space_ != NULL && 260 cell_space_ != NULL &&
261 property_cell_space_ != NULL &&
257 lo_space_ != NULL; 262 lo_space_ != NULL;
258 } 263 }
259 264
260 265
261 int Heap::GcSafeSizeOfOldObject(HeapObject* object) { 266 int Heap::GcSafeSizeOfOldObject(HeapObject* object) {
262 if (IntrusiveMarking::IsMarked(object)) { 267 if (IntrusiveMarking::IsMarked(object)) {
263 return IntrusiveMarking::SizeOfMarkedObject(object); 268 return IntrusiveMarking::SizeOfMarkedObject(object);
264 } 269 }
265 return object->SizeFromMap(object->map()); 270 return object->SizeFromMap(object->map());
266 } 271 }
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 ", committed: %6" V8_PTR_PREFIX "d KB\n", 381 ", committed: %6" V8_PTR_PREFIX "d KB\n",
377 map_space_->SizeOfObjects() / KB, 382 map_space_->SizeOfObjects() / KB,
378 map_space_->Available() / KB, 383 map_space_->Available() / KB,
379 map_space_->CommittedMemory() / KB); 384 map_space_->CommittedMemory() / KB);
380 PrintPID("Cell space, used: %6" V8_PTR_PREFIX "d KB" 385 PrintPID("Cell space, used: %6" V8_PTR_PREFIX "d KB"
381 ", available: %6" V8_PTR_PREFIX "d KB" 386 ", available: %6" V8_PTR_PREFIX "d KB"
382 ", committed: %6" V8_PTR_PREFIX "d KB\n", 387 ", committed: %6" V8_PTR_PREFIX "d KB\n",
383 cell_space_->SizeOfObjects() / KB, 388 cell_space_->SizeOfObjects() / KB,
384 cell_space_->Available() / KB, 389 cell_space_->Available() / KB,
385 cell_space_->CommittedMemory() / KB); 390 cell_space_->CommittedMemory() / KB);
391 PrintPID("PropertyCell space, used: %6" V8_PTR_PREFIX "d KB"
392 ", available: %6" V8_PTR_PREFIX "d KB"
393 ", committed: %6" V8_PTR_PREFIX "d KB\n",
394 property_cell_space_->SizeOfObjects() / KB,
395 property_cell_space_->Available() / KB,
396 property_cell_space_->CommittedMemory() / KB);
386 PrintPID("Large object space, used: %6" V8_PTR_PREFIX "d KB" 397 PrintPID("Large object space, used: %6" V8_PTR_PREFIX "d KB"
387 ", available: %6" V8_PTR_PREFIX "d KB" 398 ", available: %6" V8_PTR_PREFIX "d KB"
388 ", committed: %6" V8_PTR_PREFIX "d KB\n", 399 ", committed: %6" V8_PTR_PREFIX "d KB\n",
389 lo_space_->SizeOfObjects() / KB, 400 lo_space_->SizeOfObjects() / KB,
390 lo_space_->Available() / KB, 401 lo_space_->Available() / KB,
391 lo_space_->CommittedMemory() / KB); 402 lo_space_->CommittedMemory() / KB);
392 PrintPID("All spaces, used: %6" V8_PTR_PREFIX "d KB" 403 PrintPID("All spaces, used: %6" V8_PTR_PREFIX "d KB"
393 ", available: %6" V8_PTR_PREFIX "d KB" 404 ", available: %6" V8_PTR_PREFIX "d KB"
394 ", committed: %6" V8_PTR_PREFIX "d KB\n", 405 ", committed: %6" V8_PTR_PREFIX "d KB\n",
395 this->SizeOfObjects() / KB, 406 this->SizeOfObjects() / KB,
396 this->Available() / KB, 407 this->Available() / KB,
397 this->CommittedMemory() / KB); 408 this->CommittedMemory() / KB);
409 PrintPID("External memory reported: %6" V8_PTR_PREFIX "d KB\n",
410 amount_of_external_allocated_memory_ / KB);
398 PrintPID("Total time spent in GC : %.1f ms\n", total_gc_time_ms_); 411 PrintPID("Total time spent in GC : %.1f ms\n", total_gc_time_ms_);
399 } 412 }
400 413
401 414
402 // TODO(1238405): Combine the infrastructure for --heap-stats and 415 // TODO(1238405): Combine the infrastructure for --heap-stats and
403 // --log-gc to avoid the complicated preprocessor and flag testing. 416 // --log-gc to avoid the complicated preprocessor and flag testing.
404 void Heap::ReportStatisticsAfterGC() { 417 void Heap::ReportStatisticsAfterGC() {
405 // Similar to the before GC, we use some complicated logic to ensure that 418 // Similar to the before GC, we use some complicated logic to ensure that
406 // NewSpace statistics are logged exactly once when --log-gc is turned on. 419 // NewSpace statistics are logged exactly once when --log-gc is turned on.
407 #if defined(DEBUG) 420 #if defined(DEBUG)
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 if (CommittedMemory() > 0) { 520 if (CommittedMemory() > 0) {
508 isolate_->counters()->external_fragmentation_total()->AddSample( 521 isolate_->counters()->external_fragmentation_total()->AddSample(
509 static_cast<int>(100 - (SizeOfObjects() * 100.0) / CommittedMemory())); 522 static_cast<int>(100 - (SizeOfObjects() * 100.0) / CommittedMemory()));
510 523
511 isolate_->counters()->heap_fraction_map_space()->AddSample( 524 isolate_->counters()->heap_fraction_map_space()->AddSample(
512 static_cast<int>( 525 static_cast<int>(
513 (map_space()->CommittedMemory() * 100.0) / CommittedMemory())); 526 (map_space()->CommittedMemory() * 100.0) / CommittedMemory()));
514 isolate_->counters()->heap_fraction_cell_space()->AddSample( 527 isolate_->counters()->heap_fraction_cell_space()->AddSample(
515 static_cast<int>( 528 static_cast<int>(
516 (cell_space()->CommittedMemory() * 100.0) / CommittedMemory())); 529 (cell_space()->CommittedMemory() * 100.0) / CommittedMemory()));
530 isolate_->counters()->heap_fraction_property_cell_space()->
531 AddSample(static_cast<int>(
532 (property_cell_space()->CommittedMemory() * 100.0) /
533 CommittedMemory()));
517 534
518 isolate_->counters()->heap_sample_total_committed()->AddSample( 535 isolate_->counters()->heap_sample_total_committed()->AddSample(
519 static_cast<int>(CommittedMemory() / KB)); 536 static_cast<int>(CommittedMemory() / KB));
520 isolate_->counters()->heap_sample_total_used()->AddSample( 537 isolate_->counters()->heap_sample_total_used()->AddSample(
521 static_cast<int>(SizeOfObjects() / KB)); 538 static_cast<int>(SizeOfObjects() / KB));
522 isolate_->counters()->heap_sample_map_space_committed()->AddSample( 539 isolate_->counters()->heap_sample_map_space_committed()->AddSample(
523 static_cast<int>(map_space()->CommittedMemory() / KB)); 540 static_cast<int>(map_space()->CommittedMemory() / KB));
524 isolate_->counters()->heap_sample_cell_space_committed()->AddSample( 541 isolate_->counters()->heap_sample_cell_space_committed()->AddSample(
525 static_cast<int>(cell_space()->CommittedMemory() / KB)); 542 static_cast<int>(cell_space()->CommittedMemory() / KB));
543 isolate_->counters()->
544 heap_sample_property_cell_space_committed()->
545 AddSample(static_cast<int>(
546 property_cell_space()->CommittedMemory() / KB));
526 } 547 }
527 548
528 #define UPDATE_COUNTERS_FOR_SPACE(space) \ 549 #define UPDATE_COUNTERS_FOR_SPACE(space) \
529 isolate_->counters()->space##_bytes_available()->Set( \ 550 isolate_->counters()->space##_bytes_available()->Set( \
530 static_cast<int>(space()->Available())); \ 551 static_cast<int>(space()->Available())); \
531 isolate_->counters()->space##_bytes_committed()->Set( \ 552 isolate_->counters()->space##_bytes_committed()->Set( \
532 static_cast<int>(space()->CommittedMemory())); \ 553 static_cast<int>(space()->CommittedMemory())); \
533 isolate_->counters()->space##_bytes_used()->Set( \ 554 isolate_->counters()->space##_bytes_used()->Set( \
534 static_cast<int>(space()->SizeOfObjects())); 555 static_cast<int>(space()->SizeOfObjects()));
535 #define UPDATE_FRAGMENTATION_FOR_SPACE(space) \ 556 #define UPDATE_FRAGMENTATION_FOR_SPACE(space) \
536 if (space()->CommittedMemory() > 0) { \ 557 if (space()->CommittedMemory() > 0) { \
537 isolate_->counters()->external_fragmentation_##space()->AddSample( \ 558 isolate_->counters()->external_fragmentation_##space()->AddSample( \
538 static_cast<int>(100 - \ 559 static_cast<int>(100 - \
539 (space()->SizeOfObjects() * 100.0) / space()->CommittedMemory())); \ 560 (space()->SizeOfObjects() * 100.0) / space()->CommittedMemory())); \
540 } 561 }
541 #define UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE(space) \ 562 #define UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE(space) \
542 UPDATE_COUNTERS_FOR_SPACE(space) \ 563 UPDATE_COUNTERS_FOR_SPACE(space) \
543 UPDATE_FRAGMENTATION_FOR_SPACE(space) 564 UPDATE_FRAGMENTATION_FOR_SPACE(space)
544 565
545 UPDATE_COUNTERS_FOR_SPACE(new_space) 566 UPDATE_COUNTERS_FOR_SPACE(new_space)
546 UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE(old_pointer_space) 567 UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE(old_pointer_space)
547 UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE(old_data_space) 568 UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE(old_data_space)
548 UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE(code_space) 569 UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE(code_space)
549 UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE(map_space) 570 UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE(map_space)
550 UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE(cell_space) 571 UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE(cell_space)
572 UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE(property_cell_space)
551 UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE(lo_space) 573 UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE(lo_space)
552 #undef UPDATE_COUNTERS_FOR_SPACE 574 #undef UPDATE_COUNTERS_FOR_SPACE
553 #undef UPDATE_FRAGMENTATION_FOR_SPACE 575 #undef UPDATE_FRAGMENTATION_FOR_SPACE
554 #undef UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE 576 #undef UPDATE_COUNTERS_AND_FRAGMENTATION_FOR_SPACE
555 577
556 #if defined(DEBUG) 578 #if defined(DEBUG)
557 ReportStatisticsAfterGC(); 579 ReportStatisticsAfterGC();
558 #endif // DEBUG 580 #endif // DEBUG
559 #ifdef ENABLE_DEBUGGER_SUPPORT 581 #ifdef ENABLE_DEBUGGER_SUPPORT
560 isolate_->debug()->AfterGarbageCollection(); 582 isolate_->debug()->AfterGarbageCollection();
(...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after
1205 start_of_current_page_ = store_buffer_->Top(); 1227 start_of_current_page_ = store_buffer_->Top();
1206 current_page_ = page; 1228 current_page_ = page;
1207 } else if (event == kStoreBufferFullEvent) { 1229 } else if (event == kStoreBufferFullEvent) {
1208 // The current page overflowed the store buffer again. Wipe out its entries 1230 // The current page overflowed the store buffer again. Wipe out its entries
1209 // in the store buffer and mark it scan-on-scavenge again. This may happen 1231 // in the store buffer and mark it scan-on-scavenge again. This may happen
1210 // several times while scanning. 1232 // several times while scanning.
1211 if (current_page_ == NULL) { 1233 if (current_page_ == NULL) {
1212 // Store Buffer overflowed while scanning promoted objects. These are not 1234 // Store Buffer overflowed while scanning promoted objects. These are not
1213 // in any particular page, though they are likely to be clustered by the 1235 // in any particular page, though they are likely to be clustered by the
1214 // allocation routines. 1236 // allocation routines.
1215 store_buffer_->EnsureSpace(StoreBuffer::kStoreBufferSize); 1237 store_buffer_->EnsureSpace(StoreBuffer::kStoreBufferSize / 2);
1216 } else { 1238 } else {
1217 // Store Buffer overflowed while scanning a particular old space page for 1239 // Store Buffer overflowed while scanning a particular old space page for
1218 // pointers to new space. 1240 // pointers to new space.
1219 ASSERT(current_page_ == page); 1241 ASSERT(current_page_ == page);
1220 ASSERT(page != NULL); 1242 ASSERT(page != NULL);
1221 current_page_->set_scan_on_scavenge(true); 1243 current_page_->set_scan_on_scavenge(true);
1222 ASSERT(start_of_current_page_ != store_buffer_->Top()); 1244 ASSERT(start_of_current_page_ != store_buffer_->Top());
1223 store_buffer_->SetTop(start_of_current_page_); 1245 store_buffer_->SetTop(start_of_current_page_);
1224 } 1246 }
1225 } else { 1247 } else {
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
1346 IterateRoots(&scavenge_visitor, VISIT_ALL_IN_SCAVENGE); 1368 IterateRoots(&scavenge_visitor, VISIT_ALL_IN_SCAVENGE);
1347 1369
1348 // Copy objects reachable from the old generation. 1370 // Copy objects reachable from the old generation.
1349 { 1371 {
1350 StoreBufferRebuildScope scope(this, 1372 StoreBufferRebuildScope scope(this,
1351 store_buffer(), 1373 store_buffer(),
1352 &ScavengeStoreBufferCallback); 1374 &ScavengeStoreBufferCallback);
1353 store_buffer()->IteratePointersToNewSpace(&ScavengeObject); 1375 store_buffer()->IteratePointersToNewSpace(&ScavengeObject);
1354 } 1376 }
1355 1377
1356 // Copy objects reachable from cells by scavenging cell values directly. 1378 // Copy objects reachable from simple cells by scavenging cell values
1379 // directly.
1357 HeapObjectIterator cell_iterator(cell_space_); 1380 HeapObjectIterator cell_iterator(cell_space_);
1358 for (HeapObject* heap_object = cell_iterator.Next(); 1381 for (HeapObject* heap_object = cell_iterator.Next();
1359 heap_object != NULL; 1382 heap_object != NULL;
1360 heap_object = cell_iterator.Next()) { 1383 heap_object = cell_iterator.Next()) {
1361 if (heap_object->IsJSGlobalPropertyCell()) { 1384 if (heap_object->IsCell()) {
1362 JSGlobalPropertyCell* cell = JSGlobalPropertyCell::cast(heap_object); 1385 Cell* cell = Cell::cast(heap_object);
1363 Address value_address = cell->ValueAddress(); 1386 Address value_address = cell->ValueAddress();
1364 scavenge_visitor.VisitPointer(reinterpret_cast<Object**>(value_address)); 1387 scavenge_visitor.VisitPointer(reinterpret_cast<Object**>(value_address));
1365 } 1388 }
1366 } 1389 }
1367 1390
1391 // Copy objects reachable from global property cells by scavenging global
1392 // property cell values directly.
1393 HeapObjectIterator js_global_property_cell_iterator(property_cell_space_);
1394 for (HeapObject* heap_object = js_global_property_cell_iterator.Next();
1395 heap_object != NULL;
1396 heap_object = js_global_property_cell_iterator.Next()) {
1397 if (heap_object->IsPropertyCell()) {
1398 PropertyCell* cell = PropertyCell::cast(heap_object);
1399 Address value_address = cell->ValueAddress();
1400 scavenge_visitor.VisitPointer(reinterpret_cast<Object**>(value_address));
1401 Address type_address = cell->TypeAddress();
1402 scavenge_visitor.VisitPointer(reinterpret_cast<Object**>(type_address));
1403 }
1404 }
1405
1368 // Copy objects reachable from the code flushing candidates list. 1406 // Copy objects reachable from the code flushing candidates list.
1369 MarkCompactCollector* collector = mark_compact_collector(); 1407 MarkCompactCollector* collector = mark_compact_collector();
1370 if (collector->is_code_flushing_enabled()) { 1408 if (collector->is_code_flushing_enabled()) {
1371 collector->code_flusher()->IteratePointersToFromSpace(&scavenge_visitor); 1409 collector->code_flusher()->IteratePointersToFromSpace(&scavenge_visitor);
1372 } 1410 }
1373 1411
1374 // Scavenge object reachable from the native contexts list directly. 1412 // Scavenge object reachable from the native contexts list directly.
1375 scavenge_visitor.VisitPointer(BitCast<Object**>(&native_contexts_list_)); 1413 scavenge_visitor.VisitPointer(BitCast<Object**>(&native_contexts_list_));
1376 1414
1377 new_space_front = DoScavenge(&scavenge_visitor, new_space_front); 1415 new_space_front = DoScavenge(&scavenge_visitor, new_space_front);
(...skipping 1249 matching lines...) Expand 10 before | Expand all | Expand 10 after
2627 { MaybeObject* maybe_obj = AllocateEmptyExternalArray(kExternalPixelArray); 2665 { MaybeObject* maybe_obj = AllocateEmptyExternalArray(kExternalPixelArray);
2628 if (!maybe_obj->ToObject(&obj)) return false; 2666 if (!maybe_obj->ToObject(&obj)) return false;
2629 } 2667 }
2630 set_empty_external_pixel_array(ExternalArray::cast(obj)); 2668 set_empty_external_pixel_array(ExternalArray::cast(obj));
2631 2669
2632 { MaybeObject* maybe_obj = AllocateMap(CODE_TYPE, kVariableSizeSentinel); 2670 { MaybeObject* maybe_obj = AllocateMap(CODE_TYPE, kVariableSizeSentinel);
2633 if (!maybe_obj->ToObject(&obj)) return false; 2671 if (!maybe_obj->ToObject(&obj)) return false;
2634 } 2672 }
2635 set_code_map(Map::cast(obj)); 2673 set_code_map(Map::cast(obj));
2636 2674
2637 { MaybeObject* maybe_obj = AllocateMap(JS_GLOBAL_PROPERTY_CELL_TYPE, 2675 { MaybeObject* maybe_obj = AllocateMap(CELL_TYPE, Cell::kSize);
2638 JSGlobalPropertyCell::kSize); 2676 if (!maybe_obj->ToObject(&obj)) return false;
2677 }
2678 set_cell_map(Map::cast(obj));
2679
2680 { MaybeObject* maybe_obj = AllocateMap(PROPERTY_CELL_TYPE,
2681 PropertyCell::kSize);
2639 if (!maybe_obj->ToObject(&obj)) return false; 2682 if (!maybe_obj->ToObject(&obj)) return false;
2640 } 2683 }
2641 set_global_property_cell_map(Map::cast(obj)); 2684 set_global_property_cell_map(Map::cast(obj));
2642 2685
2643 { MaybeObject* maybe_obj = AllocateMap(FILLER_TYPE, kPointerSize); 2686 { MaybeObject* maybe_obj = AllocateMap(FILLER_TYPE, kPointerSize);
2644 if (!maybe_obj->ToObject(&obj)) return false; 2687 if (!maybe_obj->ToObject(&obj)) return false;
2645 } 2688 }
2646 set_one_pointer_filler_map(Map::cast(obj)); 2689 set_one_pointer_filler_map(Map::cast(obj));
2647 2690
2648 { MaybeObject* maybe_obj = AllocateMap(FILLER_TYPE, 2 * kPointerSize); 2691 { MaybeObject* maybe_obj = AllocateMap(FILLER_TYPE, 2 * kPointerSize);
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
2762 Object* result; 2805 Object* result;
2763 { MaybeObject* maybe_result = new_space_.AllocateRaw(HeapNumber::kSize); 2806 { MaybeObject* maybe_result = new_space_.AllocateRaw(HeapNumber::kSize);
2764 if (!maybe_result->ToObject(&result)) return maybe_result; 2807 if (!maybe_result->ToObject(&result)) return maybe_result;
2765 } 2808 }
2766 HeapObject::cast(result)->set_map_no_write_barrier(heap_number_map()); 2809 HeapObject::cast(result)->set_map_no_write_barrier(heap_number_map());
2767 HeapNumber::cast(result)->set_value(value); 2810 HeapNumber::cast(result)->set_value(value);
2768 return result; 2811 return result;
2769 } 2812 }
2770 2813
2771 2814
2772 MaybeObject* Heap::AllocateJSGlobalPropertyCell(Object* value) { 2815 MaybeObject* Heap::AllocateCell(Object* value) {
2773 Object* result; 2816 Object* result;
2774 { MaybeObject* maybe_result = AllocateRawCell(); 2817 { MaybeObject* maybe_result = AllocateRawCell();
2775 if (!maybe_result->ToObject(&result)) return maybe_result; 2818 if (!maybe_result->ToObject(&result)) return maybe_result;
2776 } 2819 }
2777 HeapObject::cast(result)->set_map_no_write_barrier( 2820 HeapObject::cast(result)->set_map_no_write_barrier(cell_map());
2778 global_property_cell_map()); 2821 Cell::cast(result)->set_value(value);
2779 JSGlobalPropertyCell::cast(result)->set_value(value);
2780 return result; 2822 return result;
2781 } 2823 }
2782 2824
2825
2826 MaybeObject* Heap::AllocatePropertyCell(Object* value) {
2827 Object* result;
2828 { MaybeObject* maybe_result = AllocateRawPropertyCell();
2829 if (!maybe_result->ToObject(&result)) return maybe_result;
2830 }
2831 HeapObject::cast(result)->set_map_no_write_barrier(
2832 global_property_cell_map());
2833 PropertyCell::cast(result)->set_value(value);
2834 PropertyCell::cast(result)->set_type(Type::None());
2835 return result;
2836 }
2837
2783 2838
2784 MaybeObject* Heap::AllocateBox(Object* value, PretenureFlag pretenure) { 2839 MaybeObject* Heap::AllocateBox(Object* value, PretenureFlag pretenure) {
2785 Box* result; 2840 Box* result;
2786 MaybeObject* maybe_result = AllocateStruct(BOX_TYPE); 2841 MaybeObject* maybe_result = AllocateStruct(BOX_TYPE);
2787 if (!maybe_result->To(&result)) return maybe_result; 2842 if (!maybe_result->To(&result)) return maybe_result;
2788 result->set_value(value); 2843 result->set_value(value);
2789 return result; 2844 return result;
2790 } 2845 }
2791 2846
2792 2847
(...skipping 1645 matching lines...) Expand 10 before | Expand all | Expand 10 after
4438 { MaybeObject* maybe_initial_map = AllocateInitialMap(constructor); 4493 { MaybeObject* maybe_initial_map = AllocateInitialMap(constructor);
4439 if (!maybe_initial_map->ToObject(&initial_map)) return maybe_initial_map; 4494 if (!maybe_initial_map->ToObject(&initial_map)) return maybe_initial_map;
4440 } 4495 }
4441 constructor->set_initial_map(Map::cast(initial_map)); 4496 constructor->set_initial_map(Map::cast(initial_map));
4442 Map::cast(initial_map)->set_constructor(constructor); 4497 Map::cast(initial_map)->set_constructor(constructor);
4443 } 4498 }
4444 // Allocate the object based on the constructors initial map, or the payload 4499 // Allocate the object based on the constructors initial map, or the payload
4445 // advice 4500 // advice
4446 Map* initial_map = constructor->initial_map(); 4501 Map* initial_map = constructor->initial_map();
4447 4502
4448 JSGlobalPropertyCell* cell = JSGlobalPropertyCell::cast( 4503 Cell* cell = Cell::cast(*allocation_site_info_payload);
4449 *allocation_site_info_payload);
4450 Smi* smi = Smi::cast(cell->value()); 4504 Smi* smi = Smi::cast(cell->value());
4451 ElementsKind to_kind = static_cast<ElementsKind>(smi->value()); 4505 ElementsKind to_kind = static_cast<ElementsKind>(smi->value());
4452 AllocationSiteMode mode = TRACK_ALLOCATION_SITE; 4506 AllocationSiteMode mode = TRACK_ALLOCATION_SITE;
4453 if (to_kind != initial_map->elements_kind()) { 4507 if (to_kind != initial_map->elements_kind()) {
4454 MaybeObject* maybe_new_map = initial_map->AsElementsKind(to_kind); 4508 MaybeObject* maybe_new_map = initial_map->AsElementsKind(to_kind);
4455 if (!maybe_new_map->To(&initial_map)) return maybe_new_map; 4509 if (!maybe_new_map->To(&initial_map)) return maybe_new_map;
4456 // Possibly alter the mode, since we found an updated elements kind 4510 // Possibly alter the mode, since we found an updated elements kind
4457 // in the type info cell. 4511 // in the type info cell.
4458 mode = AllocationSiteInfo::GetMode(to_kind); 4512 mode = AllocationSiteInfo::GetMode(to_kind);
4459 } 4513 }
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
4668 } 4722 }
4669 4723
4670 4724
4671 MaybeObject* Heap::AllocateGlobalObject(JSFunction* constructor) { 4725 MaybeObject* Heap::AllocateGlobalObject(JSFunction* constructor) {
4672 ASSERT(constructor->has_initial_map()); 4726 ASSERT(constructor->has_initial_map());
4673 Map* map = constructor->initial_map(); 4727 Map* map = constructor->initial_map();
4674 ASSERT(map->is_dictionary_map()); 4728 ASSERT(map->is_dictionary_map());
4675 4729
4676 // Make sure no field properties are described in the initial map. 4730 // Make sure no field properties are described in the initial map.
4677 // This guarantees us that normalizing the properties does not 4731 // This guarantees us that normalizing the properties does not
4678 // require us to change property values to JSGlobalPropertyCells. 4732 // require us to change property values to PropertyCells.
4679 ASSERT(map->NextFreePropertyIndex() == 0); 4733 ASSERT(map->NextFreePropertyIndex() == 0);
4680 4734
4681 // Make sure we don't have a ton of pre-allocated slots in the 4735 // Make sure we don't have a ton of pre-allocated slots in the
4682 // global objects. They will be unused once we normalize the object. 4736 // global objects. They will be unused once we normalize the object.
4683 ASSERT(map->unused_property_fields() == 0); 4737 ASSERT(map->unused_property_fields() == 0);
4684 ASSERT(map->inobject_properties() == 0); 4738 ASSERT(map->inobject_properties() == 0);
4685 4739
4686 // Initial size of the backing store to avoid resize of the storage during 4740 // Initial size of the backing store to avoid resize of the storage during
4687 // bootstrapping. The size differs between the JS global object ad the 4741 // bootstrapping. The size differs between the JS global object ad the
4688 // builtins object. 4742 // builtins object.
4689 int initial_size = map->instance_type() == JS_GLOBAL_OBJECT_TYPE ? 64 : 512; 4743 int initial_size = map->instance_type() == JS_GLOBAL_OBJECT_TYPE ? 64 : 512;
4690 4744
4691 // Allocate a dictionary object for backing storage. 4745 // Allocate a dictionary object for backing storage.
4692 NameDictionary* dictionary; 4746 NameDictionary* dictionary;
4693 MaybeObject* maybe_dictionary = 4747 MaybeObject* maybe_dictionary =
4694 NameDictionary::Allocate( 4748 NameDictionary::Allocate(
4695 this, 4749 this,
4696 map->NumberOfOwnDescriptors() * 2 + initial_size); 4750 map->NumberOfOwnDescriptors() * 2 + initial_size);
4697 if (!maybe_dictionary->To(&dictionary)) return maybe_dictionary; 4751 if (!maybe_dictionary->To(&dictionary)) return maybe_dictionary;
4698 4752
4699 // The global object might be created from an object template with accessors. 4753 // The global object might be created from an object template with accessors.
4700 // Fill these accessors into the dictionary. 4754 // Fill these accessors into the dictionary.
4701 DescriptorArray* descs = map->instance_descriptors(); 4755 DescriptorArray* descs = map->instance_descriptors();
4702 for (int i = 0; i < map->NumberOfOwnDescriptors(); i++) { 4756 for (int i = 0; i < map->NumberOfOwnDescriptors(); i++) {
4703 PropertyDetails details = descs->GetDetails(i); 4757 PropertyDetails details = descs->GetDetails(i);
4704 ASSERT(details.type() == CALLBACKS); // Only accessors are expected. 4758 ASSERT(details.type() == CALLBACKS); // Only accessors are expected.
4705 PropertyDetails d = PropertyDetails(details.attributes(), CALLBACKS, i + 1); 4759 PropertyDetails d = PropertyDetails(details.attributes(), CALLBACKS, i + 1);
4706 Object* value = descs->GetCallbacksObject(i); 4760 Object* value = descs->GetCallbacksObject(i);
4707 MaybeObject* maybe_value = AllocateJSGlobalPropertyCell(value); 4761 MaybeObject* maybe_value = AllocatePropertyCell(value);
4708 if (!maybe_value->ToObject(&value)) return maybe_value; 4762 if (!maybe_value->ToObject(&value)) return maybe_value;
4709 4763
4710 MaybeObject* maybe_added = dictionary->Add(descs->GetKey(i), value, d); 4764 MaybeObject* maybe_added = dictionary->Add(descs->GetKey(i), value, d);
4711 if (!maybe_added->To(&dictionary)) return maybe_added; 4765 if (!maybe_added->To(&dictionary)) return maybe_added;
4712 } 4766 }
4713 4767
4714 // Allocate the global object and initialize it with the backing store. 4768 // Allocate the global object and initialize it with the backing store.
4715 JSObject* global; 4769 JSObject* global;
4716 MaybeObject* maybe_global = Allocate(map, OLD_POINTER_SPACE); 4770 MaybeObject* maybe_global = Allocate(map, OLD_POINTER_SPACE);
4717 if (!maybe_global->To(&global)) return maybe_global; 4771 if (!maybe_global->To(&global)) return maybe_global;
(...skipping 1084 matching lines...) Expand 10 before | Expand all | Expand 10 after
5802 IncrementalMarking::NO_GC_VIA_STACK_GUARD); 5856 IncrementalMarking::NO_GC_VIA_STACK_GUARD);
5803 5857
5804 if (incremental_marking()->IsComplete()) { 5858 if (incremental_marking()->IsComplete()) {
5805 bool uncommit = false; 5859 bool uncommit = false;
5806 if (gc_count_at_last_idle_gc_ == gc_count_) { 5860 if (gc_count_at_last_idle_gc_ == gc_count_) {
5807 // No GC since the last full GC, the mutator is probably not active. 5861 // No GC since the last full GC, the mutator is probably not active.
5808 isolate_->compilation_cache()->Clear(); 5862 isolate_->compilation_cache()->Clear();
5809 uncommit = true; 5863 uncommit = true;
5810 } 5864 }
5811 CollectAllGarbage(kNoGCFlags, "idle notification: finalize incremental"); 5865 CollectAllGarbage(kNoGCFlags, "idle notification: finalize incremental");
5866 mark_sweeps_since_idle_round_started_++;
5812 gc_count_at_last_idle_gc_ = gc_count_; 5867 gc_count_at_last_idle_gc_ = gc_count_;
5813 if (uncommit) { 5868 if (uncommit) {
5814 new_space_.Shrink(); 5869 new_space_.Shrink();
5815 UncommitFromSpace(); 5870 UncommitFromSpace();
5816 } 5871 }
5817 } 5872 }
5818 } 5873 }
5819 5874
5820 5875
5821 bool Heap::IdleNotification(int hint) { 5876 bool Heap::IdleNotification(int hint) {
5822 // Hints greater than this value indicate that 5877 // Hints greater than this value indicate that
5823 // the embedder is requesting a lot of GC work. 5878 // the embedder is requesting a lot of GC work.
5824 const int kMaxHint = 1000; 5879 const int kMaxHint = 1000;
5880 const int kMinHintForIncrementalMarking = 10;
5825 // Minimal hint that allows to do full GC. 5881 // Minimal hint that allows to do full GC.
5826 const int kMinHintForFullGC = 100; 5882 const int kMinHintForFullGC = 100;
5827 intptr_t size_factor = Min(Max(hint, 20), kMaxHint) / 4; 5883 intptr_t size_factor = Min(Max(hint, 20), kMaxHint) / 4;
5828 // The size factor is in range [5..250]. The numbers here are chosen from 5884 // The size factor is in range [5..250]. The numbers here are chosen from
5829 // experiments. If you changes them, make sure to test with 5885 // experiments. If you changes them, make sure to test with
5830 // chrome/performance_ui_tests --gtest_filter="GeneralMixMemoryTest.* 5886 // chrome/performance_ui_tests --gtest_filter="GeneralMixMemoryTest.*
5831 intptr_t step_size = 5887 intptr_t step_size =
5832 size_factor * IncrementalMarking::kAllocatedThreshold; 5888 size_factor * IncrementalMarking::kAllocatedThreshold;
5833 5889
5834 if (contexts_disposed_ > 0) { 5890 if (contexts_disposed_ > 0) {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
5877 } 5933 }
5878 5934
5879 if (mark_sweeps_since_idle_round_started_ >= kMaxMarkSweepsInIdleRound) { 5935 if (mark_sweeps_since_idle_round_started_ >= kMaxMarkSweepsInIdleRound) {
5880 if (EnoughGarbageSinceLastIdleRound()) { 5936 if (EnoughGarbageSinceLastIdleRound()) {
5881 StartIdleRound(); 5937 StartIdleRound();
5882 } else { 5938 } else {
5883 return true; 5939 return true;
5884 } 5940 }
5885 } 5941 }
5886 5942
5887 int new_mark_sweeps = ms_count_ - ms_count_at_last_idle_notification_;
5888 mark_sweeps_since_idle_round_started_ += new_mark_sweeps;
5889 ms_count_at_last_idle_notification_ = ms_count_;
5890
5891 int remaining_mark_sweeps = kMaxMarkSweepsInIdleRound - 5943 int remaining_mark_sweeps = kMaxMarkSweepsInIdleRound -
5892 mark_sweeps_since_idle_round_started_; 5944 mark_sweeps_since_idle_round_started_;
5893 5945
5894 if (remaining_mark_sweeps <= 0) {
5895 FinishIdleRound();
5896 return true;
5897 }
5898
5899 if (incremental_marking()->IsStopped()) { 5946 if (incremental_marking()->IsStopped()) {
5900 // If there are no more than two GCs left in this idle round and we are 5947 // If there are no more than two GCs left in this idle round and we are
5901 // allowed to do a full GC, then make those GCs full in order to compact 5948 // allowed to do a full GC, then make those GCs full in order to compact
5902 // the code space. 5949 // the code space.
5903 // TODO(ulan): Once we enable code compaction for incremental marking, 5950 // TODO(ulan): Once we enable code compaction for incremental marking,
5904 // we can get rid of this special case and always start incremental marking. 5951 // we can get rid of this special case and always start incremental marking.
5905 if (remaining_mark_sweeps <= 2 && hint >= kMinHintForFullGC) { 5952 if (remaining_mark_sweeps <= 2 && hint >= kMinHintForFullGC) {
5906 CollectAllGarbage(kReduceMemoryFootprintMask, 5953 CollectAllGarbage(kReduceMemoryFootprintMask,
5907 "idle notification: finalize idle round"); 5954 "idle notification: finalize idle round");
5908 } else { 5955 mark_sweeps_since_idle_round_started_++;
5956 } else if (hint > kMinHintForIncrementalMarking) {
5909 incremental_marking()->Start(); 5957 incremental_marking()->Start();
5910 } 5958 }
5911 } 5959 }
5912 if (!incremental_marking()->IsStopped()) { 5960 if (!incremental_marking()->IsStopped() &&
5961 hint > kMinHintForIncrementalMarking) {
5913 AdvanceIdleIncrementalMarking(step_size); 5962 AdvanceIdleIncrementalMarking(step_size);
5914 } 5963 }
5964
5965 if (mark_sweeps_since_idle_round_started_ >= kMaxMarkSweepsInIdleRound) {
5966 FinishIdleRound();
5967 return true;
5968 }
5969
5915 return false; 5970 return false;
5916 } 5971 }
5917 5972
5918 5973
5919 bool Heap::IdleGlobalGC() { 5974 bool Heap::IdleGlobalGC() {
5920 static const int kIdlesBeforeScavenge = 4; 5975 static const int kIdlesBeforeScavenge = 4;
5921 static const int kIdlesBeforeMarkSweep = 7; 5976 static const int kIdlesBeforeMarkSweep = 7;
5922 static const int kIdlesBeforeMarkCompact = 8; 5977 static const int kIdlesBeforeMarkCompact = 8;
5923 static const int kMaxIdleCount = kIdlesBeforeMarkCompact + 1; 5978 static const int kMaxIdleCount = kIdlesBeforeMarkCompact + 1;
5924 static const unsigned int kGCsBetweenCleanup = 4; 5979 static const unsigned int kGCsBetweenCleanup = 4;
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
6021 PrintF("Old pointer space : "); 6076 PrintF("Old pointer space : ");
6022 old_pointer_space_->ReportStatistics(); 6077 old_pointer_space_->ReportStatistics();
6023 PrintF("Old data space : "); 6078 PrintF("Old data space : ");
6024 old_data_space_->ReportStatistics(); 6079 old_data_space_->ReportStatistics();
6025 PrintF("Code space : "); 6080 PrintF("Code space : ");
6026 code_space_->ReportStatistics(); 6081 code_space_->ReportStatistics();
6027 PrintF("Map space : "); 6082 PrintF("Map space : ");
6028 map_space_->ReportStatistics(); 6083 map_space_->ReportStatistics();
6029 PrintF("Cell space : "); 6084 PrintF("Cell space : ");
6030 cell_space_->ReportStatistics(); 6085 cell_space_->ReportStatistics();
6086 PrintF("PropertyCell space : ");
6087 property_cell_space_->ReportStatistics();
6031 PrintF("Large object space : "); 6088 PrintF("Large object space : ");
6032 lo_space_->ReportStatistics(); 6089 lo_space_->ReportStatistics();
6033 PrintF(">>>>>> ========================================= >>>>>>\n"); 6090 PrintF(">>>>>> ========================================= >>>>>>\n");
6034 } 6091 }
6035 6092
6036 #endif // DEBUG 6093 #endif // DEBUG
6037 6094
6038 bool Heap::Contains(HeapObject* value) { 6095 bool Heap::Contains(HeapObject* value) {
6039 return Contains(value->address()); 6096 return Contains(value->address());
6040 } 6097 }
6041 6098
6042 6099
6043 bool Heap::Contains(Address addr) { 6100 bool Heap::Contains(Address addr) {
6044 if (OS::IsOutsideAllocatedSpace(addr)) return false; 6101 if (OS::IsOutsideAllocatedSpace(addr)) return false;
6045 return HasBeenSetUp() && 6102 return HasBeenSetUp() &&
6046 (new_space_.ToSpaceContains(addr) || 6103 (new_space_.ToSpaceContains(addr) ||
6047 old_pointer_space_->Contains(addr) || 6104 old_pointer_space_->Contains(addr) ||
6048 old_data_space_->Contains(addr) || 6105 old_data_space_->Contains(addr) ||
6049 code_space_->Contains(addr) || 6106 code_space_->Contains(addr) ||
6050 map_space_->Contains(addr) || 6107 map_space_->Contains(addr) ||
6051 cell_space_->Contains(addr) || 6108 cell_space_->Contains(addr) ||
6109 property_cell_space_->Contains(addr) ||
6052 lo_space_->SlowContains(addr)); 6110 lo_space_->SlowContains(addr));
6053 } 6111 }
6054 6112
6055 6113
6056 bool Heap::InSpace(HeapObject* value, AllocationSpace space) { 6114 bool Heap::InSpace(HeapObject* value, AllocationSpace space) {
6057 return InSpace(value->address(), space); 6115 return InSpace(value->address(), space);
6058 } 6116 }
6059 6117
6060 6118
6061 bool Heap::InSpace(Address addr, AllocationSpace space) { 6119 bool Heap::InSpace(Address addr, AllocationSpace space) {
6062 if (OS::IsOutsideAllocatedSpace(addr)) return false; 6120 if (OS::IsOutsideAllocatedSpace(addr)) return false;
6063 if (!HasBeenSetUp()) return false; 6121 if (!HasBeenSetUp()) return false;
6064 6122
6065 switch (space) { 6123 switch (space) {
6066 case NEW_SPACE: 6124 case NEW_SPACE:
6067 return new_space_.ToSpaceContains(addr); 6125 return new_space_.ToSpaceContains(addr);
6068 case OLD_POINTER_SPACE: 6126 case OLD_POINTER_SPACE:
6069 return old_pointer_space_->Contains(addr); 6127 return old_pointer_space_->Contains(addr);
6070 case OLD_DATA_SPACE: 6128 case OLD_DATA_SPACE:
6071 return old_data_space_->Contains(addr); 6129 return old_data_space_->Contains(addr);
6072 case CODE_SPACE: 6130 case CODE_SPACE:
6073 return code_space_->Contains(addr); 6131 return code_space_->Contains(addr);
6074 case MAP_SPACE: 6132 case MAP_SPACE:
6075 return map_space_->Contains(addr); 6133 return map_space_->Contains(addr);
6076 case CELL_SPACE: 6134 case CELL_SPACE:
6077 return cell_space_->Contains(addr); 6135 return cell_space_->Contains(addr);
6136 case PROPERTY_CELL_SPACE:
6137 return property_cell_space_->Contains(addr);
6078 case LO_SPACE: 6138 case LO_SPACE:
6079 return lo_space_->SlowContains(addr); 6139 return lo_space_->SlowContains(addr);
6080 } 6140 }
6081 6141
6082 return false; 6142 return false;
6083 } 6143 }
6084 6144
6085 6145
6086 #ifdef VERIFY_HEAP 6146 #ifdef VERIFY_HEAP
6087 void Heap::Verify() { 6147 void Heap::Verify() {
6088 CHECK(HasBeenSetUp()); 6148 CHECK(HasBeenSetUp());
6089 6149
6090 store_buffer()->Verify(); 6150 store_buffer()->Verify();
6091 6151
6092 VerifyPointersVisitor visitor; 6152 VerifyPointersVisitor visitor;
6093 IterateRoots(&visitor, VISIT_ONLY_STRONG); 6153 IterateRoots(&visitor, VISIT_ONLY_STRONG);
6094 6154
6095 new_space_.Verify(); 6155 new_space_.Verify();
6096 6156
6097 old_pointer_space_->Verify(&visitor); 6157 old_pointer_space_->Verify(&visitor);
6098 map_space_->Verify(&visitor); 6158 map_space_->Verify(&visitor);
6099 6159
6100 VerifyPointersVisitor no_dirty_regions_visitor; 6160 VerifyPointersVisitor no_dirty_regions_visitor;
6101 old_data_space_->Verify(&no_dirty_regions_visitor); 6161 old_data_space_->Verify(&no_dirty_regions_visitor);
6102 code_space_->Verify(&no_dirty_regions_visitor); 6162 code_space_->Verify(&no_dirty_regions_visitor);
6103 cell_space_->Verify(&no_dirty_regions_visitor); 6163 cell_space_->Verify(&no_dirty_regions_visitor);
6164 property_cell_space_->Verify(&no_dirty_regions_visitor);
6104 6165
6105 lo_space_->Verify(); 6166 lo_space_->Verify();
6106 } 6167 }
6107 #endif 6168 #endif
6108 6169
6109 6170
6110 MaybeObject* Heap::InternalizeUtf8String(Vector<const char> string) { 6171 MaybeObject* Heap::InternalizeUtf8String(Vector<const char> string) {
6111 Object* result = NULL; 6172 Object* result = NULL;
6112 Object* new_table; 6173 Object* new_table;
6113 { MaybeObject* maybe_new_table = 6174 { MaybeObject* maybe_new_table =
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after
6593 *stats->old_pointer_space_size = old_pointer_space_->SizeOfObjects(); 6654 *stats->old_pointer_space_size = old_pointer_space_->SizeOfObjects();
6594 *stats->old_pointer_space_capacity = old_pointer_space_->Capacity(); 6655 *stats->old_pointer_space_capacity = old_pointer_space_->Capacity();
6595 *stats->old_data_space_size = old_data_space_->SizeOfObjects(); 6656 *stats->old_data_space_size = old_data_space_->SizeOfObjects();
6596 *stats->old_data_space_capacity = old_data_space_->Capacity(); 6657 *stats->old_data_space_capacity = old_data_space_->Capacity();
6597 *stats->code_space_size = code_space_->SizeOfObjects(); 6658 *stats->code_space_size = code_space_->SizeOfObjects();
6598 *stats->code_space_capacity = code_space_->Capacity(); 6659 *stats->code_space_capacity = code_space_->Capacity();
6599 *stats->map_space_size = map_space_->SizeOfObjects(); 6660 *stats->map_space_size = map_space_->SizeOfObjects();
6600 *stats->map_space_capacity = map_space_->Capacity(); 6661 *stats->map_space_capacity = map_space_->Capacity();
6601 *stats->cell_space_size = cell_space_->SizeOfObjects(); 6662 *stats->cell_space_size = cell_space_->SizeOfObjects();
6602 *stats->cell_space_capacity = cell_space_->Capacity(); 6663 *stats->cell_space_capacity = cell_space_->Capacity();
6664 *stats->property_cell_space_size = property_cell_space_->SizeOfObjects();
6665 *stats->property_cell_space_capacity = property_cell_space_->Capacity();
6603 *stats->lo_space_size = lo_space_->Size(); 6666 *stats->lo_space_size = lo_space_->Size();
6604 isolate_->global_handles()->RecordStats(stats); 6667 isolate_->global_handles()->RecordStats(stats);
6605 *stats->memory_allocator_size = isolate()->memory_allocator()->Size(); 6668 *stats->memory_allocator_size = isolate()->memory_allocator()->Size();
6606 *stats->memory_allocator_capacity = 6669 *stats->memory_allocator_capacity =
6607 isolate()->memory_allocator()->Size() + 6670 isolate()->memory_allocator()->Size() +
6608 isolate()->memory_allocator()->Available(); 6671 isolate()->memory_allocator()->Available();
6609 *stats->os_error = OS::GetLastError(); 6672 *stats->os_error = OS::GetLastError();
6610 isolate()->memory_allocator()->Available(); 6673 isolate()->memory_allocator()->Available();
6611 if (take_snapshot) { 6674 if (take_snapshot) {
6612 HeapIterator iterator(this); 6675 HeapIterator iterator(this);
6613 for (HeapObject* obj = iterator.next(); 6676 for (HeapObject* obj = iterator.next();
6614 obj != NULL; 6677 obj != NULL;
6615 obj = iterator.next()) { 6678 obj = iterator.next()) {
6616 InstanceType type = obj->map()->instance_type(); 6679 InstanceType type = obj->map()->instance_type();
6617 ASSERT(0 <= type && type <= LAST_TYPE); 6680 ASSERT(0 <= type && type <= LAST_TYPE);
6618 stats->objects_per_type[type]++; 6681 stats->objects_per_type[type]++;
6619 stats->size_per_type[type] += obj->Size(); 6682 stats->size_per_type[type] += obj->Size();
6620 } 6683 }
6621 } 6684 }
6622 } 6685 }
6623 6686
6624 6687
6625 intptr_t Heap::PromotedSpaceSizeOfObjects() { 6688 intptr_t Heap::PromotedSpaceSizeOfObjects() {
6626 return old_pointer_space_->SizeOfObjects() 6689 return old_pointer_space_->SizeOfObjects()
6627 + old_data_space_->SizeOfObjects() 6690 + old_data_space_->SizeOfObjects()
6628 + code_space_->SizeOfObjects() 6691 + code_space_->SizeOfObjects()
6629 + map_space_->SizeOfObjects() 6692 + map_space_->SizeOfObjects()
6630 + cell_space_->SizeOfObjects() 6693 + cell_space_->SizeOfObjects()
6694 + property_cell_space_->SizeOfObjects()
6631 + lo_space_->SizeOfObjects(); 6695 + lo_space_->SizeOfObjects();
6632 } 6696 }
6633 6697
6634 6698
6635 intptr_t Heap::PromotedExternalMemorySize() { 6699 intptr_t Heap::PromotedExternalMemorySize() {
6636 if (amount_of_external_allocated_memory_ 6700 if (amount_of_external_allocated_memory_
6637 <= amount_of_external_allocated_memory_at_last_global_gc_) return 0; 6701 <= amount_of_external_allocated_memory_at_last_global_gc_) return 0;
6638 return amount_of_external_allocated_memory_ 6702 return amount_of_external_allocated_memory_
6639 - amount_of_external_allocated_memory_at_last_global_gc_; 6703 - amount_of_external_allocated_memory_at_last_global_gc_;
6640 } 6704 }
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
6709 code_space_ = 6773 code_space_ =
6710 new OldSpace(this, max_old_generation_size_, CODE_SPACE, EXECUTABLE); 6774 new OldSpace(this, max_old_generation_size_, CODE_SPACE, EXECUTABLE);
6711 if (code_space_ == NULL) return false; 6775 if (code_space_ == NULL) return false;
6712 if (!code_space_->SetUp()) return false; 6776 if (!code_space_->SetUp()) return false;
6713 6777
6714 // Initialize map space. 6778 // Initialize map space.
6715 map_space_ = new MapSpace(this, max_old_generation_size_, MAP_SPACE); 6779 map_space_ = new MapSpace(this, max_old_generation_size_, MAP_SPACE);
6716 if (map_space_ == NULL) return false; 6780 if (map_space_ == NULL) return false;
6717 if (!map_space_->SetUp()) return false; 6781 if (!map_space_->SetUp()) return false;
6718 6782
6719 // Initialize global property cell space. 6783 // Initialize simple cell space.
6720 cell_space_ = new CellSpace(this, max_old_generation_size_, CELL_SPACE); 6784 cell_space_ = new CellSpace(this, max_old_generation_size_, CELL_SPACE);
6721 if (cell_space_ == NULL) return false; 6785 if (cell_space_ == NULL) return false;
6722 if (!cell_space_->SetUp()) return false; 6786 if (!cell_space_->SetUp()) return false;
6723 6787
6788 // Initialize global property cell space.
6789 property_cell_space_ = new PropertyCellSpace(this, max_old_generation_size_,
6790 PROPERTY_CELL_SPACE);
6791 if (property_cell_space_ == NULL) return false;
6792 if (!property_cell_space_->SetUp()) return false;
6793
6724 // The large object code space may contain code or data. We set the memory 6794 // The large object code space may contain code or data. We set the memory
6725 // to be non-executable here for safety, but this means we need to enable it 6795 // to be non-executable here for safety, but this means we need to enable it
6726 // explicitly when allocating large code objects. 6796 // explicitly when allocating large code objects.
6727 lo_space_ = new LargeObjectSpace(this, max_old_generation_size_, LO_SPACE); 6797 lo_space_ = new LargeObjectSpace(this, max_old_generation_size_, LO_SPACE);
6728 if (lo_space_ == NULL) return false; 6798 if (lo_space_ == NULL) return false;
6729 if (!lo_space_->SetUp()) return false; 6799 if (!lo_space_->SetUp()) return false;
6730 6800
6731 // Set up the seed that is used to randomize the string hash function. 6801 // Set up the seed that is used to randomize the string hash function.
6732 ASSERT(hash_seed() == 0); 6802 ASSERT(hash_seed() == 0);
6733 if (FLAG_randomize_hashes) { 6803 if (FLAG_randomize_hashes) {
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
6835 delete map_space_; 6905 delete map_space_;
6836 map_space_ = NULL; 6906 map_space_ = NULL;
6837 } 6907 }
6838 6908
6839 if (cell_space_ != NULL) { 6909 if (cell_space_ != NULL) {
6840 cell_space_->TearDown(); 6910 cell_space_->TearDown();
6841 delete cell_space_; 6911 delete cell_space_;
6842 cell_space_ = NULL; 6912 cell_space_ = NULL;
6843 } 6913 }
6844 6914
6915 if (property_cell_space_ != NULL) {
6916 property_cell_space_->TearDown();
6917 delete property_cell_space_;
6918 property_cell_space_ = NULL;
6919 }
6920
6845 if (lo_space_ != NULL) { 6921 if (lo_space_ != NULL) {
6846 lo_space_->TearDown(); 6922 lo_space_->TearDown();
6847 delete lo_space_; 6923 delete lo_space_;
6848 lo_space_ = NULL; 6924 lo_space_ = NULL;
6849 } 6925 }
6850 6926
6851 store_buffer()->TearDown(); 6927 store_buffer()->TearDown();
6852 incremental_marking()->TearDown(); 6928 incremental_marking()->TearDown();
6853 6929
6854 isolate_->memory_allocator()->TearDown(); 6930 isolate_->memory_allocator()->TearDown();
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
6925 case OLD_POINTER_SPACE: 7001 case OLD_POINTER_SPACE:
6926 return heap_->old_pointer_space(); 7002 return heap_->old_pointer_space();
6927 case OLD_DATA_SPACE: 7003 case OLD_DATA_SPACE:
6928 return heap_->old_data_space(); 7004 return heap_->old_data_space();
6929 case CODE_SPACE: 7005 case CODE_SPACE:
6930 return heap_->code_space(); 7006 return heap_->code_space();
6931 case MAP_SPACE: 7007 case MAP_SPACE:
6932 return heap_->map_space(); 7008 return heap_->map_space();
6933 case CELL_SPACE: 7009 case CELL_SPACE:
6934 return heap_->cell_space(); 7010 return heap_->cell_space();
7011 case PROPERTY_CELL_SPACE:
7012 return heap_->property_cell_space();
6935 case LO_SPACE: 7013 case LO_SPACE:
6936 return heap_->lo_space(); 7014 return heap_->lo_space();
6937 default: 7015 default:
6938 return NULL; 7016 return NULL;
6939 } 7017 }
6940 } 7018 }
6941 7019
6942 7020
6943 PagedSpace* PagedSpaces::next() { 7021 PagedSpace* PagedSpaces::next() {
6944 switch (counter_++) { 7022 switch (counter_++) {
6945 case OLD_POINTER_SPACE: 7023 case OLD_POINTER_SPACE:
6946 return heap_->old_pointer_space(); 7024 return heap_->old_pointer_space();
6947 case OLD_DATA_SPACE: 7025 case OLD_DATA_SPACE:
6948 return heap_->old_data_space(); 7026 return heap_->old_data_space();
6949 case CODE_SPACE: 7027 case CODE_SPACE:
6950 return heap_->code_space(); 7028 return heap_->code_space();
6951 case MAP_SPACE: 7029 case MAP_SPACE:
6952 return heap_->map_space(); 7030 return heap_->map_space();
6953 case CELL_SPACE: 7031 case CELL_SPACE:
6954 return heap_->cell_space(); 7032 return heap_->cell_space();
7033 case PROPERTY_CELL_SPACE:
7034 return heap_->property_cell_space();
6955 default: 7035 default:
6956 return NULL; 7036 return NULL;
6957 } 7037 }
6958 } 7038 }
6959 7039
6960 7040
6961 7041
6962 OldSpace* OldSpaces::next() { 7042 OldSpace* OldSpaces::next() {
6963 switch (counter_++) { 7043 switch (counter_++) {
6964 case OLD_POINTER_SPACE: 7044 case OLD_POINTER_SPACE:
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
7034 break; 7114 break;
7035 case CODE_SPACE: 7115 case CODE_SPACE:
7036 iterator_ = new HeapObjectIterator(heap_->code_space(), size_func_); 7116 iterator_ = new HeapObjectIterator(heap_->code_space(), size_func_);
7037 break; 7117 break;
7038 case MAP_SPACE: 7118 case MAP_SPACE:
7039 iterator_ = new HeapObjectIterator(heap_->map_space(), size_func_); 7119 iterator_ = new HeapObjectIterator(heap_->map_space(), size_func_);
7040 break; 7120 break;
7041 case CELL_SPACE: 7121 case CELL_SPACE:
7042 iterator_ = new HeapObjectIterator(heap_->cell_space(), size_func_); 7122 iterator_ = new HeapObjectIterator(heap_->cell_space(), size_func_);
7043 break; 7123 break;
7124 case PROPERTY_CELL_SPACE:
7125 iterator_ = new HeapObjectIterator(heap_->property_cell_space(),
7126 size_func_);
7127 break;
7044 case LO_SPACE: 7128 case LO_SPACE:
7045 iterator_ = new LargeObjectIterator(heap_->lo_space(), size_func_); 7129 iterator_ = new LargeObjectIterator(heap_->lo_space(), size_func_);
7046 break; 7130 break;
7047 } 7131 }
7048 7132
7049 // Return the newly allocated iterator; 7133 // Return the newly allocated iterator;
7050 ASSERT(iterator_ != NULL); 7134 ASSERT(iterator_ != NULL);
7051 return iterator_; 7135 return iterator_;
7052 } 7136 }
7053 7137
(...skipping 937 matching lines...) Expand 10 before | Expand all | Expand 10 after
7991 if (FLAG_parallel_recompilation) { 8075 if (FLAG_parallel_recompilation) {
7992 heap_->relocation_mutex_->Lock(); 8076 heap_->relocation_mutex_->Lock();
7993 #ifdef DEBUG 8077 #ifdef DEBUG
7994 heap_->relocation_mutex_locked_by_optimizer_thread_ = 8078 heap_->relocation_mutex_locked_by_optimizer_thread_ =
7995 heap_->isolate()->optimizing_compiler_thread()->IsOptimizerThread(); 8079 heap_->isolate()->optimizing_compiler_thread()->IsOptimizerThread();
7996 #endif // DEBUG 8080 #endif // DEBUG
7997 } 8081 }
7998 } 8082 }
7999 8083
8000 } } // namespace v8::internal 8084 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/heap.h ('k') | src/heap-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698