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

Side by Side Diff: src/heap.cc

Issue 7112030: Make backing store for incremental marking deque non-static. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/gc
Patch Set: Created 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 22 matching lines...) Expand all
33 #include "codegen.h" 33 #include "codegen.h"
34 #include "compilation-cache.h" 34 #include "compilation-cache.h"
35 #include "debug.h" 35 #include "debug.h"
36 #include "global-handles.h" 36 #include "global-handles.h"
37 #include "heap-profiler.h" 37 #include "heap-profiler.h"
38 #include "incremental-marking.h" 38 #include "incremental-marking.h"
39 #include "liveobjectlist-inl.h" 39 #include "liveobjectlist-inl.h"
40 #include "mark-compact.h" 40 #include "mark-compact.h"
41 #include "natives.h" 41 #include "natives.h"
42 #include "objects-visiting.h" 42 #include "objects-visiting.h"
43 #include "objects-visiting-inl.h"
43 #include "runtime-profiler.h" 44 #include "runtime-profiler.h"
44 #include "scanner-base.h" 45 #include "scanner-base.h"
45 #include "scopeinfo.h" 46 #include "scopeinfo.h"
46 #include "snapshot.h" 47 #include "snapshot.h"
47 #include "store-buffer.h" 48 #include "store-buffer.h"
48 #include "v8threads.h" 49 #include "v8threads.h"
49 #include "vm-state-inl.h" 50 #include "vm-state-inl.h"
50 #if V8_TARGET_ARCH_ARM && !V8_INTERPRETED_REGEXP 51 #if V8_TARGET_ARCH_ARM && !V8_INTERPRETED_REGEXP
51 #include "regexp-macro-assembler.h" 52 #include "regexp-macro-assembler.h"
52 #include "arm/regexp-macro-assembler-arm.h" 53 #include "arm/regexp-macro-assembler-arm.h"
(...skipping 1251 matching lines...) Expand 10 before | Expand all | Expand 10 after
1304 1305
1305 1306
1306 enum LoggingAndProfiling { 1307 enum LoggingAndProfiling {
1307 LOGGING_AND_PROFILING_ENABLED, 1308 LOGGING_AND_PROFILING_ENABLED,
1308 LOGGING_AND_PROFILING_DISABLED 1309 LOGGING_AND_PROFILING_DISABLED
1309 }; 1310 };
1310 1311
1311 1312
1312 enum MarksHandling { TRANSFER_MARKS, IGNORE_MARKS }; 1313 enum MarksHandling { TRANSFER_MARKS, IGNORE_MARKS };
1313 1314
1314 typedef void (*ScavengingCallback)(Map* map,
1315 HeapObject** slot,
1316 HeapObject* object);
1317
1318
1319 static Atomic32 scavenging_visitors_table_mode_;
1320 // TODO(gc) ISOLATES MERGE: this table can no longer be static!
1321 static VisitorDispatchTable<ScavengingCallback> scavenging_visitors_table_;
1322
1323
1324 static inline void DoScavengeObject(Map* map,
1325 HeapObject** slot,
1326 HeapObject* obj) {
1327 scavenging_visitors_table_.GetVisitor(map)(map, slot, obj);
1328 }
1329
1330 1315
1331 template<MarksHandling marks_handling, 1316 template<MarksHandling marks_handling,
1332 LoggingAndProfiling logging_and_profiling_mode> 1317 LoggingAndProfiling logging_and_profiling_mode>
1333 class ScavengingVisitor : public StaticVisitorBase { 1318 class ScavengingVisitor : public StaticVisitorBase {
1334 public: 1319 public:
1335 static void Initialize() { 1320 static void Initialize() {
1336 table_.Register(kVisitSeqAsciiString, &EvacuateSeqAsciiString); 1321 table_.Register(kVisitSeqAsciiString, &EvacuateSeqAsciiString);
1337 table_.Register(kVisitSeqTwoByteString, &EvacuateSeqTwoByteString); 1322 table_.Register(kVisitSeqTwoByteString, &EvacuateSeqTwoByteString);
1338 table_.Register(kVisitShortcutCandidate, &EvacuateShortcutCandidate); 1323 table_.Register(kVisitShortcutCandidate, &EvacuateShortcutCandidate);
1339 table_.Register(kVisitByteArray, &EvacuateByteArray); 1324 table_.Register(kVisitByteArray, &EvacuateByteArray);
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
1419 if (isolate->logger()->is_logging() || 1404 if (isolate->logger()->is_logging() ||
1420 CpuProfiler::is_profiling(isolate)) { 1405 CpuProfiler::is_profiling(isolate)) {
1421 if (target->IsSharedFunctionInfo()) { 1406 if (target->IsSharedFunctionInfo()) {
1422 PROFILE(isolate, SharedFunctionInfoMoveEvent( 1407 PROFILE(isolate, SharedFunctionInfoMoveEvent(
1423 source->address(), target->address())); 1408 source->address(), target->address()));
1424 } 1409 }
1425 } 1410 }
1426 #endif 1411 #endif
1427 } 1412 }
1428 1413
1429
1430 if (marks_handling == TRANSFER_MARKS) { 1414 if (marks_handling == TRANSFER_MARKS) {
1431 Marking::TransferColor(source, target); 1415 Marking::TransferColor(source, target);
1432 } 1416 }
1433 1417
1434 return target; 1418 return target;
1435 } 1419 }
1436 1420
1437 template<ObjectContents object_contents, SizeRestriction size_restriction> 1421 template<ObjectContents object_contents, SizeRestriction size_restriction>
1438 static inline void EvacuateObject(Map* map, 1422 static inline void EvacuateObject(Map* map,
1439 HeapObject** slot, 1423 HeapObject** slot,
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
1517 1501
1518 static inline bool IsShortcutCandidate(int type) { 1502 static inline bool IsShortcutCandidate(int type) {
1519 return ((type & kShortcutTypeMask) == kShortcutTypeTag); 1503 return ((type & kShortcutTypeMask) == kShortcutTypeTag);
1520 } 1504 }
1521 1505
1522 static inline void EvacuateShortcutCandidate(Map* map, 1506 static inline void EvacuateShortcutCandidate(Map* map,
1523 HeapObject** slot, 1507 HeapObject** slot,
1524 HeapObject* object) { 1508 HeapObject* object) {
1525 ASSERT(IsShortcutCandidate(map->instance_type())); 1509 ASSERT(IsShortcutCandidate(map->instance_type()));
1526 1510
1511 Heap* heap = map->GetHeap();
1512
1527 if (marks_handling == IGNORE_MARKS && 1513 if (marks_handling == IGNORE_MARKS &&
1528 ConsString::cast(object)->unchecked_second() == 1514 ConsString::cast(object)->unchecked_second() ==
1529 map->GetHeap()->empty_string()) { 1515 heap->empty_string()) {
1530 HeapObject* first = 1516 HeapObject* first =
1531 HeapObject::cast(ConsString::cast(object)->unchecked_first()); 1517 HeapObject::cast(ConsString::cast(object)->unchecked_first());
1532 1518
1533 *slot = first; 1519 *slot = first;
1534 1520
1535 if (!map->GetHeap()->InNewSpace(first)) { 1521 if (!heap->InNewSpace(first)) {
1536 object->set_map_word(MapWord::FromForwardingAddress(first)); 1522 object->set_map_word(MapWord::FromForwardingAddress(first));
1537 return; 1523 return;
1538 } 1524 }
1539 1525
1540 MapWord first_word = first->map_word(); 1526 MapWord first_word = first->map_word();
1541 if (first_word.IsForwardingAddress()) { 1527 if (first_word.IsForwardingAddress()) {
1542 HeapObject* target = first_word.ToForwardingAddress(); 1528 HeapObject* target = first_word.ToForwardingAddress();
1543 1529
1544 *slot = target; 1530 *slot = target;
1545 object->set_map_word(MapWord::FromForwardingAddress(target)); 1531 object->set_map_word(MapWord::FromForwardingAddress(target));
1546 return; 1532 return;
1547 } 1533 }
1548 1534
1549 DoScavengeObject(first->map(), slot, first); 1535 heap->DoScavengeObject(first->map(), slot, first);
1550 object->set_map_word(MapWord::FromForwardingAddress(*slot)); 1536 object->set_map_word(MapWord::FromForwardingAddress(*slot));
1551 return; 1537 return;
1552 } 1538 }
1553 1539
1554 int object_size = ConsString::kSize; 1540 int object_size = ConsString::kSize;
1555 EvacuateObject<POINTER_OBJECT, SMALL>(map, slot, object, object_size); 1541 EvacuateObject<POINTER_OBJECT, SMALL>(map, slot, object, object_size);
1556 } 1542 }
1557 1543
1558 template<ObjectContents object_contents> 1544 template<ObjectContents object_contents>
1559 class ObjectEvacuationStrategy { 1545 class ObjectEvacuationStrategy {
(...skipping 23 matching lines...) Expand all
1583 ScavengingVisitor<marks_handling, logging_and_profiling_mode>::table_; 1569 ScavengingVisitor<marks_handling, logging_and_profiling_mode>::table_;
1584 1570
1585 1571
1586 static void InitializeScavengingVisitorsTables() { 1572 static void InitializeScavengingVisitorsTables() {
1587 ScavengingVisitor<TRANSFER_MARKS, 1573 ScavengingVisitor<TRANSFER_MARKS,
1588 LOGGING_AND_PROFILING_DISABLED>::Initialize(); 1574 LOGGING_AND_PROFILING_DISABLED>::Initialize();
1589 ScavengingVisitor<IGNORE_MARKS, LOGGING_AND_PROFILING_DISABLED>::Initialize(); 1575 ScavengingVisitor<IGNORE_MARKS, LOGGING_AND_PROFILING_DISABLED>::Initialize();
1590 ScavengingVisitor<TRANSFER_MARKS, 1576 ScavengingVisitor<TRANSFER_MARKS,
1591 LOGGING_AND_PROFILING_ENABLED>::Initialize(); 1577 LOGGING_AND_PROFILING_ENABLED>::Initialize();
1592 ScavengingVisitor<IGNORE_MARKS, LOGGING_AND_PROFILING_ENABLED>::Initialize(); 1578 ScavengingVisitor<IGNORE_MARKS, LOGGING_AND_PROFILING_ENABLED>::Initialize();
1593 scavenging_visitors_table_.CopyFrom(
1594 ScavengingVisitor<IGNORE_MARKS,
1595 LOGGING_AND_PROFILING_DISABLED>::GetTable());
1596 scavenging_visitors_table_mode_ = LOGGING_AND_PROFILING_DISABLED;
1597 } 1579 }
1598 1580
1599 1581
1600 void Heap::SelectScavengingVisitorsTable() { 1582 void Heap::SelectScavengingVisitorsTable() {
1583 #ifdef ENABLE_LOGGING_AND_PROFILING
1584 bool logging_and_profiling =
1585 isolate()->logger()->is_logging() ||
1586 CpuProfiler::is_profiling(isolate()) ||
1587 (isolate()->heap_profiler() != NULL &&
1588 isolate()->heap_profiler()->is_profiling());
1589 #else
1590 bool logging_and_profiling = false;
1591 #endif
1592
1593
1601 if (!incremental_marking()->IsMarking()) { 1594 if (!incremental_marking()->IsMarking()) {
1602 if (scavenging_visitors_table_mode_ == LOGGING_AND_PROFILING_DISABLED) { 1595 if (!logging_and_profiling) {
1603 scavenging_visitors_table_.CopyFrom( 1596 scavenging_visitors_table_.CopyFrom(
1604 ScavengingVisitor<IGNORE_MARKS, 1597 ScavengingVisitor<IGNORE_MARKS,
1605 LOGGING_AND_PROFILING_DISABLED>::GetTable()); 1598 LOGGING_AND_PROFILING_DISABLED>::GetTable());
1606 } else { 1599 } else {
1607 scavenging_visitors_table_.CopyFrom( 1600 scavenging_visitors_table_.CopyFrom(
1608 ScavengingVisitor<IGNORE_MARKS, 1601 ScavengingVisitor<IGNORE_MARKS,
1609 LOGGING_AND_PROFILING_ENABLED>::GetTable()); 1602 LOGGING_AND_PROFILING_ENABLED>::GetTable());
1610 } 1603 }
1611 } else { 1604 } else {
1612 if (scavenging_visitors_table_mode_ == LOGGING_AND_PROFILING_DISABLED) { 1605 if (!logging_and_profiling) {
1613 scavenging_visitors_table_.CopyFrom( 1606 scavenging_visitors_table_.CopyFrom(
1614 ScavengingVisitor<TRANSFER_MARKS, 1607 ScavengingVisitor<TRANSFER_MARKS,
1615 LOGGING_AND_PROFILING_DISABLED>::GetTable()); 1608 LOGGING_AND_PROFILING_DISABLED>::GetTable());
1616 } else { 1609 } else {
1617 scavenging_visitors_table_.CopyFrom( 1610 scavenging_visitors_table_.CopyFrom(
1618 ScavengingVisitor<TRANSFER_MARKS, 1611 ScavengingVisitor<TRANSFER_MARKS,
1619 LOGGING_AND_PROFILING_ENABLED>::GetTable()); 1612 LOGGING_AND_PROFILING_ENABLED>::GetTable());
1620 } 1613 }
1621 } 1614 }
1622 } 1615 }
1623 1616
1624 1617
1625 void Heap::ScavengeObjectSlow(HeapObject** p, HeapObject* object) { 1618 void Heap::ScavengeObjectSlow(HeapObject** p, HeapObject* object) {
1626 ASSERT(HEAP->InFromSpace(object)); 1619 ASSERT(HEAP->InFromSpace(object));
1627 MapWord first_word = object->map_word(); 1620 MapWord first_word = object->map_word();
1628 ASSERT(!first_word.IsForwardingAddress()); 1621 ASSERT(!first_word.IsForwardingAddress());
1629 Map* map = first_word.ToMap(); 1622 Map* map = first_word.ToMap();
1630 DoScavengeObject(map, p, object); 1623 map->GetHeap()->DoScavengeObject(map, p, object);
1631 } 1624 }
1632 1625
1633 1626
1634 MaybeObject* Heap::AllocatePartialMap(InstanceType instance_type, 1627 MaybeObject* Heap::AllocatePartialMap(InstanceType instance_type,
1635 int instance_size) { 1628 int instance_size) {
1636 Object* result; 1629 Object* result;
1637 { MaybeObject* maybe_result = AllocateRawMap(); 1630 { MaybeObject* maybe_result = AllocateRawMap();
1638 if (!maybe_result->ToObject(&result)) return maybe_result; 1631 if (!maybe_result->ToObject(&result)) return maybe_result;
1639 } 1632 }
1640 1633
(...skipping 3587 matching lines...) Expand 10 before | Expand all | Expand 10 after
5228 cell_space_ = NULL; 5221 cell_space_ = NULL;
5229 } 5222 }
5230 5223
5231 if (lo_space_ != NULL) { 5224 if (lo_space_ != NULL) {
5232 lo_space_->TearDown(); 5225 lo_space_->TearDown();
5233 delete lo_space_; 5226 delete lo_space_;
5234 lo_space_ = NULL; 5227 lo_space_ = NULL;
5235 } 5228 }
5236 5229
5237 store_buffer()->TearDown(); 5230 store_buffer()->TearDown();
5231 incremental_marking()->TearDown();
5238 5232
5239 isolate_->memory_allocator()->TearDown(); 5233 isolate_->memory_allocator()->TearDown();
5240 5234
5241 #ifdef DEBUG 5235 #ifdef DEBUG
5242 delete debug_utils_; 5236 delete debug_utils_;
5243 debug_utils_ = NULL; 5237 debug_utils_ = NULL;
5244 #endif 5238 #endif
5245 } 5239 }
5246 5240
5247 5241
(...skipping 765 matching lines...) Expand 10 before | Expand all | Expand 10 after
6013 } 6007 }
6014 6008
6015 6009
6016 void ExternalStringTable::TearDown() { 6010 void ExternalStringTable::TearDown() {
6017 new_space_strings_.Free(); 6011 new_space_strings_.Free();
6018 old_space_strings_.Free(); 6012 old_space_strings_.Free();
6019 } 6013 }
6020 6014
6021 6015
6022 } } // namespace v8::internal 6016 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/heap.h ('k') | src/incremental-marking.h » ('j') | src/incremental-marking.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698