OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 return location_; | 78 return location_; |
79 } | 79 } |
80 | 80 |
81 #ifdef DEBUG | 81 #ifdef DEBUG |
82 template <typename T> | 82 template <typename T> |
83 bool Handle<T>::IsDereferenceAllowed(DereferenceCheckMode mode) const { | 83 bool Handle<T>::IsDereferenceAllowed(DereferenceCheckMode mode) const { |
84 ASSERT(location_ != NULL); | 84 ASSERT(location_ != NULL); |
85 Object* object = *BitCast<T**>(location_); | 85 Object* object = *BitCast<T**>(location_); |
86 if (object->IsSmi()) return true; | 86 if (object->IsSmi()) return true; |
87 HeapObject* heap_object = HeapObject::cast(object); | 87 HeapObject* heap_object = HeapObject::cast(object); |
88 Isolate* isolate = heap_object->GetIsolate(); | 88 Heap* heap = heap_object->GetHeap(); |
89 Object** handle = reinterpret_cast<Object**>(location_); | 89 Object** handle = reinterpret_cast<Object**>(location_);; |
90 Object** roots_array_start = isolate->heap()->roots_array_start(); | 90 if (heap->IsInRootsArray(handle)) return true; |
91 if (roots_array_start <= handle && | |
92 handle < roots_array_start + Heap::kStrongRootListLength) { | |
93 return true; | |
94 } | |
95 if (!AllowHandleDereference::IsAllowed()) return false; | 91 if (!AllowHandleDereference::IsAllowed()) return false; |
96 if (mode == INCLUDE_DEFERRED_CHECK && | 92 if (mode == INCLUDE_DEFERRED_CHECK && |
97 !AllowDeferredHandleDereference::IsAllowed()) { | 93 !AllowDeferredHandleDereference::IsAllowed()) { |
98 // Accessing maps and internalized strings is safe. | 94 // Accessing maps and internalized strings is safe. |
99 if (heap_object->IsMap()) return true; | 95 if (heap_object->IsMap()) return true; |
100 if (heap_object->IsInternalizedString()) return true; | 96 if (heap_object->IsInternalizedString()) return true; |
101 return !isolate->IsDeferredHandle(handle); | 97 return !heap->isolate()->IsDeferredHandle(handle); |
102 } | 98 } |
103 return true; | 99 return true; |
104 } | 100 } |
105 #endif | 101 #endif // DEBUG |
106 | 102 |
107 | 103 |
108 | 104 |
109 HandleScope::HandleScope(Isolate* isolate) { | 105 HandleScope::HandleScope(Isolate* isolate) { |
110 v8::ImplementationUtilities::HandleScopeData* current = | 106 v8::ImplementationUtilities::HandleScopeData* current = |
111 isolate->handle_scope_data(); | 107 isolate->handle_scope_data(); |
112 isolate_ = isolate; | 108 isolate_ = isolate; |
113 prev_next_ = current->next; | 109 prev_next_ = current->next; |
114 prev_limit_ = current->limit; | 110 prev_limit_ = current->limit; |
115 current->level++; | 111 current->level++; |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 current->level = level_; | 199 current->level = level_; |
204 ASSERT_EQ(current->next, current->limit); | 200 ASSERT_EQ(current->next, current->limit); |
205 current->limit = limit_; | 201 current->limit = limit_; |
206 } | 202 } |
207 | 203 |
208 #endif | 204 #endif |
209 | 205 |
210 } } // namespace v8::internal | 206 } } // namespace v8::internal |
211 | 207 |
212 #endif // V8_HANDLES_INL_H_ | 208 #endif // V8_HANDLES_INL_H_ |
OLD | NEW |