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

Side by Side Diff: src/mark-compact-inl.h

Issue 6880010: Merge (7265, 7271] from bleeding_edge to experimental/gc branch.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/gc/
Patch Set: '' Created 9 years, 8 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
(Empty)
1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28 #ifndef V8_MARK_COMPACT_INL_H_
29 #define V8_MARK_COMPACT_INL_H_
30
31 #include "isolate.h"
32 #include "memory.h"
33 #include "mark-compact.h"
34
35 namespace v8 {
36 namespace internal {
37
38 MarkBit Marking::MarkBitFromNewSpace(HeapObject* obj) {
39 ASSERT(HEAP->InNewSpace(obj));
40 uint32_t index = HEAP->new_space()->AddressToMarkbitIndex(
41 reinterpret_cast<Address>(obj));
42 return new_space_bitmap_->MarkBitFromIndex(index);
43 }
44
45
46 MarkBit Marking::MarkBitFromOldSpace(HeapObject* obj) {
47 ASSERT(!HEAP->InNewSpace(obj));
48 ASSERT(obj->IsHeapObject());
49 Address addr = reinterpret_cast<Address>(obj);
50 Page *p = Page::FromAddress(addr);
51 return p->markbits()->MarkBitFromIndex(p->AddressToMarkbitIndex(addr));
52 }
53
54
55 MarkBit Marking::MarkBitFrom(Address addr) {
56 // TODO(gc) !!!!!!
Erik Corry 2011/04/20 20:07:40 Marking has a heap_ field so this is easy to fix.
Vyacheslav Egorov (Chromium) 2011/04/24 11:24:08 Done.
57 if (HEAP->InNewSpace(addr)) {
58 uint32_t index = HEAP->new_space()->AddressToMarkbitIndex(addr);
59 return new_space_bitmap_->MarkBitFromIndex(index);
60 } else {
61 Page *p = Page::FromAddress(addr);
62 return p->markbits()->MarkBitFromIndex(p->AddressToMarkbitIndex(addr),
63 p->ContainsOnlyData());
64 }
65 }
66
67
68 void Marking::ClearRange(Address addr, int size) {
69 if (HEAP->InNewSpace(addr)) {
70 uint32_t index = HEAP->new_space()->AddressToMarkbitIndex(addr);
71 new_space_bitmap_->ClearRange(index, size >> kPointerSizeLog2);
72 } else {
73 Page *p = Page::FromAddress(addr);
74 p->markbits()->ClearRange(p->FastAddressToMarkbitIndex(addr),
75 size >> kPointerSizeLog2);
76 }
77 }
78
79
80 void MarkCompactCollector::SetFlags(int flags) {
81 force_compaction_ = ((flags & Heap::kForceCompactionMask) != 0);
82 sweep_precisely_ = ((flags & Heap::kMakeHeapIterableMask) != 0);
83 }
84
85
86 void MarkCompactCollector::MarkObject(HeapObject* obj, MarkBit mark_bit) {
87 ASSERT(heap()->marking()->MarkBitFrom(obj) == mark_bit);
88 if (!mark_bit.Get()) {
89 mark_bit.Set();
90 tracer_->increment_marked_count();
91 #ifdef DEBUG
92 UpdateLiveObjectCount(obj);
93 #endif
94 ProcessNewlyMarkedObject(obj);
95 }
96 }
97
98 void MarkCompactCollector::SetMark(HeapObject* obj, MarkBit mark_bit) {
99 ASSERT(heap()->marking()->MarkBitFrom(obj) == mark_bit);
100 mark_bit.Set();
101 tracer_->increment_marked_count();
102 #ifdef DEBUG
103 UpdateLiveObjectCount(obj);
104 #endif
105 }
106
107
108 bool MarkCompactCollector::IsMarked(Object* obj) {
109 ASSERT(obj->IsHeapObject());
110 HeapObject* heap_object = HeapObject::cast(obj);
111 return heap_->marking()->MarkBitFrom(heap_object).Get();
112 }
113
114
115 } } // namespace v8::internal
116
117 #endif // V8_MARK_COMPACT_INL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698