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

Side by Side Diff: src/objects-debug.cc

Issue 879273004: Verify that code stubs and full code do not have pointers that can retain (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Add comment Created 5 years, 10 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
« no previous file with comments | « src/objects.h ('k') | no next file » | 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 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/disasm.h" 7 #include "src/disasm.h"
8 #include "src/disassembler.h" 8 #include "src/disassembler.h"
9 #include "src/heap/objects-visiting.h" 9 #include "src/heap/objects-visiting.h"
10 #include "src/jsregexp.h" 10 #include "src/jsregexp.h"
(...skipping 1218 matching lines...) Expand 10 before | Expand all | Expand 10 after
1229 1229
1230 1230
1231 bool TransitionArray::IsConsistentWithBackPointers(Map* current_map) { 1231 bool TransitionArray::IsConsistentWithBackPointers(Map* current_map) {
1232 for (int i = 0; i < number_of_transitions(); ++i) { 1232 for (int i = 0; i < number_of_transitions(); ++i) {
1233 if (!CheckOneBackPointer(current_map, GetTarget(i))) return false; 1233 if (!CheckOneBackPointer(current_map, GetTarget(i))) return false;
1234 } 1234 }
1235 return true; 1235 return true;
1236 } 1236 }
1237 1237
1238 1238
1239 void Code::VerifyEmbeddedObjectsInFullCode() { 1239 // Estimates if there is a path from the object to a context.
1240 // Check that no context-specific object has been embedded. 1240 // This function is not precise, and can return false even if
1241 // there is a path to a context.
1242 bool CanLeak(Object* obj, Heap* heap, bool skip_weak_cell) {
1243 if (!obj->IsHeapObject()) return false;
1244 if (obj->IsWeakCell()) {
1245 if (skip_weak_cell) return false;
1246 return CanLeak(WeakCell::cast(obj)->value(), heap, skip_weak_cell);
1247 }
1248 if (obj->IsCell()) {
1249 return CanLeak(Cell::cast(obj)->value(), heap, skip_weak_cell);
1250 }
1251 if (obj->IsPropertyCell()) {
1252 return CanLeak(PropertyCell::cast(obj)->value(), heap, skip_weak_cell);
1253 }
1254 if (obj->IsContext()) return true;
1255 if (obj->IsMap()) {
1256 Map* map = Map::cast(obj);
1257 for (int i = 0; i < Heap::kStrongRootListLength; i++) {
1258 if (map == heap->roots_array_start()[i]) return false;
1259 }
1260 return true;
1261 }
1262 return CanLeak(HeapObject::cast(obj)->map(), heap, skip_weak_cell);
1263 }
1264
1265
1266 void Code::VerifyEmbeddedObjects(VerifyMode mode) {
1267 if (kind() == OPTIMIZED_FUNCTION) return;
1241 Heap* heap = GetIsolate()->heap(); 1268 Heap* heap = GetIsolate()->heap();
1242 int mask = RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT); 1269 int mask = RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT) |
1270 RelocInfo::ModeMask(RelocInfo::CELL);
1271 bool skip_weak_cell = (mode == kNoContextSpecificPointers) ? false : true;
1243 for (RelocIterator it(this, mask); !it.done(); it.next()) { 1272 for (RelocIterator it(this, mask); !it.done(); it.next()) {
1244 Object* obj = it.rinfo()->target_object(); 1273 CHECK(!CanLeak(it.rinfo()->target_object(), heap, skip_weak_cell));
1245 if (obj->IsCell()) obj = Cell::cast(obj)->value();
1246 if (obj->IsPropertyCell()) obj = PropertyCell::cast(obj)->value();
1247 if (!obj->IsHeapObject()) continue;
1248 Map* map = obj->IsMap() ? Map::cast(obj) : HeapObject::cast(obj)->map();
1249 int i = 0;
1250 while (map != heap->roots_array_start()[i++]) {
1251 CHECK_LT(i, Heap::kStrongRootListLength);
1252 }
1253 } 1274 }
1254 } 1275 }
1255 1276
1256 1277
1257 #endif // DEBUG 1278 #endif // DEBUG
1258 1279
1259 } } // namespace v8::internal 1280 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698