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

Side by Side Diff: src/handles.cc

Issue 1235253007: Revert of [handles] Sanitize Handle and friends. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: 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
40 int HandleScope::NumberOfHandles(Isolate* isolate) { 12 int HandleScope::NumberOfHandles(Isolate* isolate) {
41 HandleScopeImplementer* impl = isolate->handle_scope_implementer(); 13 HandleScopeImplementer* impl = isolate->handle_scope_implementer();
42 int n = impl->blocks()->length(); 14 int n = impl->blocks()->length();
43 if (n == 0) return 0; 15 if (n == 0) return 0;
44 return ((n - 1) * kHandleBlockSize) + static_cast<int>( 16 return ((n - 1) * kHandleBlockSize) + static_cast<int>(
45 (isolate->handle_scope_data()->next - impl->blocks()->last())); 17 (isolate->handle_scope_data()->next - impl->blocks()->last()));
46 } 18 }
47 19
48 20
49 Object** HandleScope::Extend(Isolate* isolate) { 21 Object** HandleScope::Extend(Isolate* isolate) {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 void HandleScope::DeleteExtensions(Isolate* isolate) { 60 void HandleScope::DeleteExtensions(Isolate* isolate) {
89 HandleScopeData* current = isolate->handle_scope_data(); 61 HandleScopeData* current = isolate->handle_scope_data();
90 isolate->handle_scope_implementer()->DeleteExtensions(current->limit); 62 isolate->handle_scope_implementer()->DeleteExtensions(current->limit);
91 } 63 }
92 64
93 65
94 #ifdef ENABLE_HANDLE_ZAPPING 66 #ifdef ENABLE_HANDLE_ZAPPING
95 void HandleScope::ZapRange(Object** start, Object** end) { 67 void HandleScope::ZapRange(Object** start, Object** end) {
96 DCHECK(end - start <= kHandleBlockSize); 68 DCHECK(end - start <= kHandleBlockSize);
97 for (Object** p = start; p != end; p++) { 69 for (Object** p = start; p != end; p++) {
98 *reinterpret_cast<Address*>(p) = kHandleZapValue; 70 *reinterpret_cast<Address*>(p) = v8::internal::kHandleZapValue;
99 } 71 }
100 } 72 }
101 #endif 73 #endif
102 74
103 75
104 Address HandleScope::current_level_address(Isolate* isolate) { 76 Address HandleScope::current_level_address(Isolate* isolate) {
105 return reinterpret_cast<Address>(&isolate->handle_scope_data()->level); 77 return reinterpret_cast<Address>(&isolate->handle_scope_data()->level);
106 } 78 }
107 79
108 80
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 data->next = prev_next_; 121 data->next = prev_next_;
150 data->limit = prev_limit_; 122 data->limit = prev_limit_;
151 #ifdef DEBUG 123 #ifdef DEBUG
152 handles_detached_ = true; 124 handles_detached_ = true;
153 #endif 125 #endif
154 return deferred; 126 return deferred;
155 } 127 }
156 128
157 } // namespace internal 129 } // namespace internal
158 } // namespace v8 130 } // 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