Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 11 matching lines...) Expand all Loading... | |
| 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 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. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | 27 |
| 28 #include "v8.h" | 28 #include "v8.h" |
| 29 | 29 |
| 30 #include "incremental-marking.h" | 30 #include "incremental-marking.h" |
| 31 | 31 |
| 32 #include "code-stubs.h" | |
| 32 | 33 |
| 33 namespace v8 { | 34 namespace v8 { |
| 34 namespace internal { | 35 namespace internal { |
| 35 | 36 |
| 36 IncrementalMarking::State IncrementalMarking::state_ = STOPPED; | 37 IncrementalMarking::State IncrementalMarking::state_ = STOPPED; |
| 37 MarkingStack IncrementalMarking::marking_stack_; | 38 MarkingStack IncrementalMarking::marking_stack_; |
| 38 | 39 |
| 39 static intptr_t allocated = 0; | 40 static intptr_t allocated = 0; |
| 40 | 41 |
| 41 class IncrementalMarkingMarkingVisitor : public ObjectVisitor { | 42 class IncrementalMarkingMarkingVisitor : public ObjectVisitor { |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 115 | 116 |
| 116 static void VerifyMarkbitsAreClean() { | 117 static void VerifyMarkbitsAreClean() { |
| 117 VerifyMarkbitsAreClean(Heap::old_pointer_space()); | 118 VerifyMarkbitsAreClean(Heap::old_pointer_space()); |
| 118 VerifyMarkbitsAreClean(Heap::old_data_space()); | 119 VerifyMarkbitsAreClean(Heap::old_data_space()); |
| 119 VerifyMarkbitsAreClean(Heap::code_space()); | 120 VerifyMarkbitsAreClean(Heap::code_space()); |
| 120 VerifyMarkbitsAreClean(Heap::cell_space()); | 121 VerifyMarkbitsAreClean(Heap::cell_space()); |
| 121 VerifyMarkbitsAreClean(Heap::map_space()); | 122 VerifyMarkbitsAreClean(Heap::map_space()); |
| 122 } | 123 } |
| 123 #endif | 124 #endif |
| 124 | 125 |
| 126 bool IncrementalMarking::WorthActivating() { | |
| 127 #ifndef DEBUG | |
| 128 static const intptr_t kActivationThreshold = 20*MB; | |
| 129 #else | |
| 130 static const intptr_t kActivationThreshold = 0; | |
|
Erik Corry
2011/03/02 12:34:06
Perhaps worth setting this to some low level so th
Vyacheslav Egorov (Chromium)
2011/03/02 15:11:32
For now let's always resort to incremental marking
| |
| 131 #endif | |
| 132 | |
| 133 return FLAG_incremental_marking && | |
| 134 Heap::PromotedSpaceSize() > kActivationThreshold; | |
| 135 } | |
| 136 | |
| 137 | |
| 138 static void PatchStubs(bool enable) { | |
|
Erik Corry
2011/03/02 12:34:06
This should be called something that reveals what
Vyacheslav Egorov (Chromium)
2011/03/02 15:11:32
Done.
| |
| 139 NumberDictionary* stubs = Heap::code_stubs(); | |
| 140 | |
| 141 | |
|
Erik Corry
2011/03/02 12:34:06
Blank line.
Vyacheslav Egorov (Chromium)
2011/03/02 15:11:32
Done.
| |
| 142 int capacity = stubs->Capacity(); | |
| 143 for (int i = 0; i < capacity; i++) { | |
| 144 Object* k = stubs->KeyAt(i); | |
| 145 if (stubs->IsKey(k)) { | |
| 146 uint32_t key = NumberToUint32(k); | |
| 147 | |
| 148 if (CodeStub::MajorKeyFromKey(key) == | |
| 149 CodeStub::IncrementalMarkingRecordWrite) { | |
| 150 Object* e = stubs->ValueAt(i); | |
| 151 if (e->IsJSGlobalPropertyCell()) { | |
| 152 e = JSGlobalPropertyCell::cast(e)->value(); | |
|
Erik Corry
2011/03/02 12:34:06
WTF?
Vyacheslav Egorov (Chromium)
2011/03/02 15:11:32
Done.
| |
| 153 } | |
| 154 | |
| 155 if (e->IsCode()) { | |
| 156 Code* stub = Code::cast(e); | |
| 157 *stub->instruction_start() = enable ? 0x90 : 0xc3; | |
|
Erik Corry
2011/03/02 12:34:06
These should be constants from assembler-ia32.h
Vyacheslav Egorov (Chromium)
2011/03/02 15:11:32
Done.
| |
| 158 } | |
| 159 } | |
| 160 } | |
| 161 } | |
| 162 } | |
| 163 | |
| 164 | |
| 125 void IncrementalMarking::Start() { | 165 void IncrementalMarking::Start() { |
| 126 if (FLAG_trace_incremental_marking) { | 166 if (FLAG_trace_incremental_marking) { |
| 127 PrintF("[IncrementalMarking] Start\n"); | 167 PrintF("[IncrementalMarking] Start\n"); |
| 128 } | 168 } |
| 129 ASSERT(FLAG_incremental_marking); | 169 ASSERT(FLAG_incremental_marking); |
| 130 ASSERT(state_ == STOPPED); | 170 ASSERT(state_ == STOPPED); |
| 131 state_ = MARKING; | 171 state_ = MARKING; |
| 132 | 172 |
| 173 PatchStubs(true); | |
| 174 | |
| 133 // Initialize marking stack. | 175 // Initialize marking stack. |
| 134 marking_stack_.Initialize(Heap::new_space()->FromSpaceLow(), | 176 marking_stack_.Initialize(Heap::new_space()->FromSpaceLow(), |
| 135 Heap::new_space()->FromSpaceHigh()); | 177 Heap::new_space()->FromSpaceHigh()); |
| 136 | 178 |
| 137 // Clear markbits. | 179 // Clear markbits. |
| 138 Address new_space_top = Heap::new_space()->top(); | 180 Address new_space_top = Heap::new_space()->top(); |
| 139 Address new_space_bottom = Heap::new_space()->bottom(); | 181 Address new_space_bottom = Heap::new_space()->bottom(); |
| 140 | 182 |
| 141 Marking::ClearRange(new_space_bottom, | 183 Marking::ClearRange(new_space_bottom, |
| 142 static_cast<int>(new_space_top - new_space_bottom)); | 184 static_cast<int>(new_space_top - new_space_bottom)); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 174 if (FLAG_trace_incremental_marking) { | 216 if (FLAG_trace_incremental_marking) { |
| 175 PrintF("[IncrementalMarking] Complete (hurry)\n"); | 217 PrintF("[IncrementalMarking] Complete (hurry)\n"); |
| 176 } | 218 } |
| 177 } | 219 } |
| 178 } | 220 } |
| 179 | 221 |
| 180 | 222 |
| 181 void IncrementalMarking::Finalize() { | 223 void IncrementalMarking::Finalize() { |
| 182 Hurry(); | 224 Hurry(); |
| 183 state_ = STOPPED; | 225 state_ = STOPPED; |
| 226 PatchStubs(false); | |
| 184 ASSERT(marking_stack_.is_empty()); | 227 ASSERT(marking_stack_.is_empty()); |
| 185 } | 228 } |
| 186 | 229 |
| 187 | 230 |
| 188 void IncrementalMarking::MarkingComplete() { | 231 void IncrementalMarking::MarkingComplete() { |
| 189 state_ = COMPLETE; | 232 state_ = COMPLETE; |
| 190 // We completed marking. | 233 // We completed marking. |
| 191 if (FLAG_trace_incremental_marking) { | 234 if (FLAG_trace_incremental_marking) { |
| 192 PrintF("[IncrementalMarking] Complete (normal)\n"); | 235 PrintF("[IncrementalMarking] Complete (normal)\n"); |
| 193 } | 236 } |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 225 static_cast<int>(end - start)); | 268 static_cast<int>(end - start)); |
| 226 } | 269 } |
| 227 allocated = 0; | 270 allocated = 0; |
| 228 if (marking_stack_.is_empty()) MarkingComplete(); | 271 if (marking_stack_.is_empty()) MarkingComplete(); |
| 229 } | 272 } |
| 230 } | 273 } |
| 231 } | 274 } |
| 232 | 275 |
| 233 | 276 |
| 234 } } // namespace v8::internal | 277 } } // namespace v8::internal |
| OLD | NEW |