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

Unified Diff: src/handles.cc

Issue 1128533002: [handles] Sanitize Handle and friends. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Lower kTargetRecursionDepth. Created 5 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/handles.h ('k') | src/handles-inl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/handles.cc
diff --git a/src/handles.cc b/src/handles.cc
index d4153159861bd21cf00b01f64d6f1bc23a087422..ca23a6f75f711d5fd00f142b0f53860b5fee0428 100644
--- a/src/handles.cc
+++ b/src/handles.cc
@@ -9,6 +9,34 @@
namespace v8 {
namespace internal {
+#ifdef DEBUG
+bool HandleBase::IsDereferenceAllowed(DereferenceCheckMode mode) const {
+ DCHECK_NOT_NULL(location_);
+ Object* object = *location_;
+ if (object->IsSmi()) return true;
+ HeapObject* heap_object = HeapObject::cast(object);
+ Heap* heap = heap_object->GetHeap();
+ Object** roots_array_start = heap->roots_array_start();
+ if (roots_array_start <= location_ &&
+ location_ < roots_array_start + Heap::kStrongRootListLength &&
+ heap->RootCanBeTreatedAsConstant(
+ static_cast<Heap::RootListIndex>(location_ - roots_array_start))) {
+ return true;
+ }
+ if (!AllowHandleDereference::IsAllowed()) return false;
+ if (mode == INCLUDE_DEFERRED_CHECK &&
+ !AllowDeferredHandleDereference::IsAllowed()) {
+ // Accessing cells, maps and internalized strings is safe.
+ if (heap_object->IsCell()) return true;
+ if (heap_object->IsMap()) return true;
+ if (heap_object->IsInternalizedString()) return true;
+ return !heap->isolate()->IsDeferredHandle(location_);
+ }
+ return true;
+}
+#endif
+
+
int HandleScope::NumberOfHandles(Isolate* isolate) {
HandleScopeImplementer* impl = isolate->handle_scope_implementer();
int n = impl->blocks()->length();
@@ -67,7 +95,7 @@ void HandleScope::DeleteExtensions(Isolate* isolate) {
void HandleScope::ZapRange(Object** start, Object** end) {
DCHECK(end - start <= kHandleBlockSize);
for (Object** p = start; p != end; p++) {
- *reinterpret_cast<Address*>(p) = v8::internal::kHandleZapValue;
+ *reinterpret_cast<Address*>(p) = kHandleZapValue;
}
}
#endif
« no previous file with comments | « src/handles.h ('k') | src/handles-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698