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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « src/handles.h ('k') | src/handles-inl.h » ('j') | 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/handles.h" 7 #include "src/handles.h"
8 8
9 namespace v8 { 9 namespace v8 {
10 namespace internal { 10 namespace internal {
11 11
12 #ifdef DEBUG
13 bool HandleBase::IsDereferenceAllowed(DereferenceCheckMode mode) const {
14 DCHECK_NOT_NULL(location_);
15 Object* object = *location_;
16 if (object->IsSmi()) return true;
17 HeapObject* heap_object = HeapObject::cast(object);
18 Heap* heap = heap_object->GetHeap();
19 Object** roots_array_start = heap->roots_array_start();
20 if (roots_array_start <= location_ &&
21 location_ < roots_array_start + Heap::kStrongRootListLength &&
22 heap->RootCanBeTreatedAsConstant(
23 static_cast<Heap::RootListIndex>(location_ - roots_array_start))) {
24 return true;
25 }
26 if (!AllowHandleDereference::IsAllowed()) return false;
27 if (mode == INCLUDE_DEFERRED_CHECK &&
28 !AllowDeferredHandleDereference::IsAllowed()) {
29 // Accessing cells, maps and internalized strings is safe.
30 if (heap_object->IsCell()) return true;
31 if (heap_object->IsMap()) return true;
32 if (heap_object->IsInternalizedString()) return true;
33 return !heap->isolate()->IsDeferredHandle(location_);
34 }
35 return true;
36 }
37 #endif
38
39
12 int HandleScope::NumberOfHandles(Isolate* isolate) { 40 int HandleScope::NumberOfHandles(Isolate* isolate) {
13 HandleScopeImplementer* impl = isolate->handle_scope_implementer(); 41 HandleScopeImplementer* impl = isolate->handle_scope_implementer();
14 int n = impl->blocks()->length(); 42 int n = impl->blocks()->length();
15 if (n == 0) return 0; 43 if (n == 0) return 0;
16 return ((n - 1) * kHandleBlockSize) + static_cast<int>( 44 return ((n - 1) * kHandleBlockSize) + static_cast<int>(
17 (isolate->handle_scope_data()->next - impl->blocks()->last())); 45 (isolate->handle_scope_data()->next - impl->blocks()->last()));
18 } 46 }
19 47
20 48
21 Object** HandleScope::Extend(Isolate* isolate) { 49 Object** HandleScope::Extend(Isolate* isolate) {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 void HandleScope::DeleteExtensions(Isolate* isolate) { 88 void HandleScope::DeleteExtensions(Isolate* isolate) {
61 HandleScopeData* current = isolate->handle_scope_data(); 89 HandleScopeData* current = isolate->handle_scope_data();
62 isolate->handle_scope_implementer()->DeleteExtensions(current->limit); 90 isolate->handle_scope_implementer()->DeleteExtensions(current->limit);
63 } 91 }
64 92
65 93
66 #ifdef ENABLE_HANDLE_ZAPPING 94 #ifdef ENABLE_HANDLE_ZAPPING
67 void HandleScope::ZapRange(Object** start, Object** end) { 95 void HandleScope::ZapRange(Object** start, Object** end) {
68 DCHECK(end - start <= kHandleBlockSize); 96 DCHECK(end - start <= kHandleBlockSize);
69 for (Object** p = start; p != end; p++) { 97 for (Object** p = start; p != end; p++) {
70 *reinterpret_cast<Address*>(p) = v8::internal::kHandleZapValue; 98 *reinterpret_cast<Address*>(p) = kHandleZapValue;
71 } 99 }
72 } 100 }
73 #endif 101 #endif
74 102
75 103
76 Address HandleScope::current_level_address(Isolate* isolate) { 104 Address HandleScope::current_level_address(Isolate* isolate) {
77 return reinterpret_cast<Address>(&isolate->handle_scope_data()->level); 105 return reinterpret_cast<Address>(&isolate->handle_scope_data()->level);
78 } 106 }
79 107
80 108
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 data->next = prev_next_; 149 data->next = prev_next_;
122 data->limit = prev_limit_; 150 data->limit = prev_limit_;
123 #ifdef DEBUG 151 #ifdef DEBUG
124 handles_detached_ = true; 152 handles_detached_ = true;
125 #endif 153 #endif
126 return deferred; 154 return deferred;
127 } 155 }
128 156
129 } // namespace internal 157 } // namespace internal
130 } // namespace v8 158 } // namespace v8
OLDNEW
« 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