OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 | 166 |
167 int LCodeGenBase::GetNextEmittedBlock() const { | 167 int LCodeGenBase::GetNextEmittedBlock() const { |
168 for (int i = current_block_ + 1; i < graph()->blocks()->length(); ++i) { | 168 for (int i = current_block_ + 1; i < graph()->blocks()->length(); ++i) { |
169 if (!graph()->blocks()->at(i)->IsReachable()) continue; | 169 if (!graph()->blocks()->at(i)->IsReachable()) continue; |
170 if (!chunk_->GetLabel(i)->HasReplacement()) return i; | 170 if (!chunk_->GetLabel(i)->HasReplacement()) return i; |
171 } | 171 } |
172 return -1; | 172 return -1; |
173 } | 173 } |
174 | 174 |
175 | 175 |
| 176 static void AddWeakObjectToCodeDependency(Isolate* isolate, |
| 177 Handle<Object> object, |
| 178 Handle<Code> code) { |
| 179 Heap* heap = isolate->heap(); |
| 180 heap->EnsureWeakObjectToCodeTable(); |
| 181 Handle<DependentCode> dep(heap->LookupWeakObjectToCodeDependency(*object)); |
| 182 dep = DependentCode::Insert(dep, DependentCode::kWeakCodeGroup, code); |
| 183 CALL_HEAP_FUNCTION_VOID(isolate, |
| 184 heap->AddWeakObjectToCodeDependency(*object, *dep)); |
| 185 } |
| 186 |
| 187 |
176 void LCodeGenBase::RegisterWeakObjectsInOptimizedCode(Handle<Code> code) { | 188 void LCodeGenBase::RegisterWeakObjectsInOptimizedCode(Handle<Code> code) { |
177 ASSERT(code->is_optimized_code()); | 189 ASSERT(code->is_optimized_code()); |
178 ZoneList<Handle<Map> > maps(1, zone()); | 190 ZoneList<Handle<Map> > maps(1, zone()); |
179 ZoneList<Handle<JSObject> > objects(1, zone()); | 191 ZoneList<Handle<JSObject> > objects(1, zone()); |
180 ZoneList<Handle<Cell> > cells(1, zone()); | 192 ZoneList<Handle<Cell> > cells(1, zone()); |
181 int mode_mask = RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT) | | 193 int mode_mask = RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT) | |
182 RelocInfo::ModeMask(RelocInfo::CELL); | 194 RelocInfo::ModeMask(RelocInfo::CELL); |
183 for (RelocIterator it(*code, mode_mask); !it.done(); it.next()) { | 195 for (RelocIterator it(*code, mode_mask); !it.done(); it.next()) { |
184 RelocInfo::Mode mode = it.rinfo()->rmode(); | 196 RelocInfo::Mode mode = it.rinfo()->rmode(); |
185 if (mode == RelocInfo::CELL && | 197 if (mode == RelocInfo::CELL && |
(...skipping 21 matching lines...) Expand all Loading... |
207 #ifdef VERIFY_HEAP | 219 #ifdef VERIFY_HEAP |
208 // This disables verification of weak embedded objects after full GC. | 220 // This disables verification of weak embedded objects after full GC. |
209 // AddDependentCode can cause a GC, which would observe the state where | 221 // AddDependentCode can cause a GC, which would observe the state where |
210 // this code is not yet in the depended code lists of the embedded maps. | 222 // this code is not yet in the depended code lists of the embedded maps. |
211 NoWeakObjectVerificationScope disable_verification_of_embedded_objects; | 223 NoWeakObjectVerificationScope disable_verification_of_embedded_objects; |
212 #endif | 224 #endif |
213 for (int i = 0; i < maps.length(); i++) { | 225 for (int i = 0; i < maps.length(); i++) { |
214 Map::AddDependentCode(maps.at(i), DependentCode::kWeakCodeGroup, code); | 226 Map::AddDependentCode(maps.at(i), DependentCode::kWeakCodeGroup, code); |
215 } | 227 } |
216 for (int i = 0; i < objects.length(); i++) { | 228 for (int i = 0; i < objects.length(); i++) { |
217 AddWeakObjectToCodeDependency(isolate()->heap(), objects.at(i), code); | 229 AddWeakObjectToCodeDependency(isolate(), objects.at(i), code); |
218 } | 230 } |
219 for (int i = 0; i < cells.length(); i++) { | 231 for (int i = 0; i < cells.length(); i++) { |
220 AddWeakObjectToCodeDependency(isolate()->heap(), cells.at(i), code); | 232 AddWeakObjectToCodeDependency(isolate(), cells.at(i), code); |
221 } | 233 } |
222 } | 234 } |
223 | 235 |
224 | 236 |
225 } } // namespace v8::internal | 237 } } // namespace v8::internal |
OLD | NEW |