| 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 14 matching lines...) Expand all Loading... |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 // | 27 // |
| 28 | 28 |
| 29 #ifndef V8_HANDLES_INL_H_ | 29 #ifndef V8_HANDLES_INL_H_ |
| 30 #define V8_HANDLES_INL_H_ | 30 #define V8_HANDLES_INL_H_ |
| 31 | 31 |
| 32 #include "api.h" | 32 #include "api.h" |
| 33 #include "apiutils.h" | 33 #include "apiutils.h" |
| 34 #include "handles.h" | 34 #include "handles.h" |
| 35 #include "heap.h" |
| 35 #include "isolate.h" | 36 #include "isolate.h" |
| 36 | 37 |
| 37 namespace v8 { | 38 namespace v8 { |
| 38 namespace internal { | 39 namespace internal { |
| 39 | 40 |
| 40 template<typename T> | 41 template<typename T> |
| 41 Handle<T>::Handle(T* obj) { | 42 Handle<T>::Handle(T* obj) { |
| 42 ASSERT(!obj->IsFailure()); | 43 ASSERT(!obj->IsFailure()); |
| 43 location_ = HandleScope::CreateHandle(obj->GetIsolate(), obj); | 44 location_ = HandleScope::CreateHandle(obj->GetIsolate(), obj); |
| 44 } | 45 } |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 return location_; | 79 return location_; |
| 79 } | 80 } |
| 80 | 81 |
| 81 #ifdef DEBUG | 82 #ifdef DEBUG |
| 82 template <typename T> | 83 template <typename T> |
| 83 bool Handle<T>::IsDereferenceAllowed(DereferenceCheckMode mode) const { | 84 bool Handle<T>::IsDereferenceAllowed(DereferenceCheckMode mode) const { |
| 84 ASSERT(location_ != NULL); | 85 ASSERT(location_ != NULL); |
| 85 Object* object = *BitCast<T**>(location_); | 86 Object* object = *BitCast<T**>(location_); |
| 86 if (object->IsSmi()) return true; | 87 if (object->IsSmi()) return true; |
| 87 HeapObject* heap_object = HeapObject::cast(object); | 88 HeapObject* heap_object = HeapObject::cast(object); |
| 88 Isolate* isolate = heap_object->GetIsolate(); | 89 Heap* heap = heap_object->GetHeap(); |
| 89 Object** handle = reinterpret_cast<Object**>(location_); | 90 Object** handle = reinterpret_cast<Object**>(location_); |
| 90 Object** roots_array_start = isolate->heap()->roots_array_start(); | 91 Object** roots_array_start = heap->roots_array_start(); |
| 91 if (roots_array_start <= handle && | 92 if (roots_array_start <= handle && |
| 92 handle < roots_array_start + Heap::kStrongRootListLength) { | 93 handle < roots_array_start + Heap::kStrongRootListLength && |
| 94 heap->RootCanBeTreatedAsConstant( |
| 95 static_cast<Heap::RootListIndex>(handle - roots_array_start))) { |
| 93 return true; | 96 return true; |
| 94 } | 97 } |
| 95 if (!AllowHandleDereference::IsAllowed()) return false; | 98 if (!AllowHandleDereference::IsAllowed()) return false; |
| 96 if (mode == INCLUDE_DEFERRED_CHECK && | 99 if (mode == INCLUDE_DEFERRED_CHECK && |
| 97 !AllowDeferredHandleDereference::IsAllowed()) { | 100 !AllowDeferredHandleDereference::IsAllowed()) { |
| 98 // Accessing maps and internalized strings is safe. | 101 // Accessing maps and internalized strings is safe. |
| 99 if (heap_object->IsMap()) return true; | 102 if (heap_object->IsMap()) return true; |
| 100 if (heap_object->IsInternalizedString()) return true; | 103 if (heap_object->IsInternalizedString()) return true; |
| 101 return !isolate->IsDeferredHandle(handle); | 104 return !heap->isolate()->IsDeferredHandle(handle); |
| 102 } | 105 } |
| 103 return true; | 106 return true; |
| 104 } | 107 } |
| 105 #endif | 108 #endif |
| 106 | 109 |
| 107 | 110 |
| 108 | 111 |
| 109 HandleScope::HandleScope(Isolate* isolate) { | 112 HandleScope::HandleScope(Isolate* isolate) { |
| 110 v8::ImplementationUtilities::HandleScopeData* current = | 113 v8::ImplementationUtilities::HandleScopeData* current = |
| 111 isolate->handle_scope_data(); | 114 isolate->handle_scope_data(); |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 current->level = level_; | 206 current->level = level_; |
| 204 ASSERT_EQ(current->next, current->limit); | 207 ASSERT_EQ(current->next, current->limit); |
| 205 current->limit = limit_; | 208 current->limit = limit_; |
| 206 } | 209 } |
| 207 | 210 |
| 208 #endif | 211 #endif |
| 209 | 212 |
| 210 } } // namespace v8::internal | 213 } } // namespace v8::internal |
| 211 | 214 |
| 212 #endif // V8_HANDLES_INL_H_ | 215 #endif // V8_HANDLES_INL_H_ |
| OLD | NEW |