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 22 matching lines...) Expand all Loading... |
33 #include "handles.h" | 33 #include "handles.h" |
34 #include "heap.h" | 34 #include "heap.h" |
35 #include "isolate.h" | 35 #include "isolate.h" |
36 | 36 |
37 namespace v8 { | 37 namespace v8 { |
38 namespace internal { | 38 namespace internal { |
39 | 39 |
40 template<typename T> | 40 template<typename T> |
41 Handle<T>::Handle(T* obj) { | 41 Handle<T>::Handle(T* obj) { |
42 ASSERT(!obj->IsFailure()); | 42 ASSERT(!obj->IsFailure()); |
43 location_ = HandleScope::CreateHandle(obj->GetIsolate(), obj); | 43 this->location_ = HandleScope::CreateHandle(obj->GetIsolate(), obj); |
44 } | 44 } |
45 | 45 |
46 | 46 |
47 template<typename T> | 47 template<typename T> |
48 Handle<T>::Handle(T* obj, Isolate* isolate) { | 48 Handle<T>::Handle(T* obj, Isolate* isolate) { |
49 ASSERT(!obj->IsFailure()); | 49 ASSERT(!obj->IsFailure()); |
50 location_ = HandleScope::CreateHandle(isolate, obj); | 50 this->location_ = HandleScope::CreateHandle(isolate, obj); |
51 } | 51 } |
52 | 52 |
53 | 53 |
54 template <typename T> | 54 template <typename T> |
55 inline bool Handle<T>::is_identical_to(const Handle<T> o) const { | 55 inline bool Handle<T>::is_identical_to(const Handle<T> o) const { |
56 ASSERT(location_ == NULL || !(*location_)->IsFailure()); | 56 ASSERT(this->location_ == NULL || !(*this->location_)->IsFailure()); |
57 // Dereferencing deferred handles to check object equality is safe. | 57 // Dereferencing deferred handles to check object equality is safe. |
58 SLOW_ASSERT( | 58 SLOW_ASSERT( |
59 (location_ == NULL || IsDereferenceAllowed(NO_DEFERRED_CHECK)) && | 59 (this->location_ == NULL || IsDereferenceAllowed(NO_DEFERRED_CHECK)) && |
60 (o.location_ == NULL || o.IsDereferenceAllowed(NO_DEFERRED_CHECK))); | 60 (o.location_ == NULL || o.IsDereferenceAllowed(NO_DEFERRED_CHECK))); |
61 if (location_ == o.location_) return true; | 61 if (this->location_ == o.location_) return true; |
62 if (location_ == NULL || o.location_ == NULL) return false; | 62 if (this->location_ == NULL || o.location_ == NULL) return false; |
63 return *location_ == *o.location_; | 63 return *this->location_ == *o.location_; |
64 } | 64 } |
65 | 65 |
66 | 66 |
67 template <typename T> | 67 template <typename T> |
68 inline T* Handle<T>::operator*() const { | 68 inline T* Handle<T>::operator*() const { |
69 ASSERT(location_ != NULL && !(*location_)->IsFailure()); | 69 ASSERT(this->location_ != NULL && !(*this->location_)->IsFailure()); |
70 SLOW_ASSERT(IsDereferenceAllowed(INCLUDE_DEFERRED_CHECK)); | 70 SLOW_ASSERT(IsDereferenceAllowed(INCLUDE_DEFERRED_CHECK)); |
71 return *BitCast<T**>(location_); | 71 return *BitCast<T**>(this->location_); |
72 } | 72 } |
73 | 73 |
74 template <typename T> | 74 template <typename T> |
75 inline T** Handle<T>::location() const { | 75 inline T** Handle<T>::location() const { |
76 ASSERT(location_ == NULL || !(*location_)->IsFailure()); | 76 ASSERT(this->location_ == NULL || !(*this->location_)->IsFailure()); |
77 SLOW_ASSERT(location_ == NULL || | 77 SLOW_ASSERT(this->location_ == NULL || |
78 IsDereferenceAllowed(INCLUDE_DEFERRED_CHECK)); | 78 IsDereferenceAllowed(INCLUDE_DEFERRED_CHECK)); |
79 return location_; | 79 return this->location_; |
80 } | 80 } |
81 | 81 |
82 #ifdef DEBUG | 82 #ifdef DEBUG |
83 template <typename T> | 83 template <typename T> |
84 bool Handle<T>::IsDereferenceAllowed(DereferenceCheckMode mode) const { | 84 bool Handle<T>::IsDereferenceAllowed(DereferenceCheckMode mode) const { |
85 ASSERT(location_ != NULL); | 85 ASSERT(this->location_ != NULL); |
86 Object* object = *BitCast<T**>(location_); | 86 Object* object = *BitCast<T**>(this->location_); |
87 if (object->IsSmi()) return true; | 87 if (object->IsSmi()) return true; |
88 HeapObject* heap_object = HeapObject::cast(object); | 88 HeapObject* heap_object = HeapObject::cast(object); |
89 Heap* heap = heap_object->GetHeap(); | 89 Heap* heap = heap_object->GetHeap(); |
90 Object** handle = reinterpret_cast<Object**>(location_); | 90 Object** handle = reinterpret_cast<Object**>(this->location_); |
91 Object** roots_array_start = heap->roots_array_start(); | 91 Object** roots_array_start = heap->roots_array_start(); |
92 if (roots_array_start <= handle && | 92 if (roots_array_start <= handle && |
93 handle < roots_array_start + Heap::kStrongRootListLength && | 93 handle < roots_array_start + Heap::kStrongRootListLength && |
94 heap->RootCanBeTreatedAsConstant( | 94 heap->RootCanBeTreatedAsConstant( |
95 static_cast<Heap::RootListIndex>(handle - roots_array_start))) { | 95 static_cast<Heap::RootListIndex>(handle - roots_array_start))) { |
96 return true; | 96 return true; |
97 } | 97 } |
98 if (!AllowHandleDereference::IsAllowed()) return false; | 98 if (!AllowHandleDereference::IsAllowed()) return false; |
99 if (mode == INCLUDE_DEFERRED_CHECK && | 99 if (mode == INCLUDE_DEFERRED_CHECK && |
100 !AllowDeferredHandleDereference::IsAllowed()) { | 100 !AllowDeferredHandleDereference::IsAllowed()) { |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 current->level = level_; | 202 current->level = level_; |
203 ASSERT_EQ(current->next, current->limit); | 203 ASSERT_EQ(current->next, current->limit); |
204 current->limit = limit_; | 204 current->limit = limit_; |
205 } | 205 } |
206 | 206 |
207 #endif | 207 #endif |
208 | 208 |
209 } } // namespace v8::internal | 209 } } // namespace v8::internal |
210 | 210 |
211 #endif // V8_HANDLES_INL_H_ | 211 #endif // V8_HANDLES_INL_H_ |
OLD | NEW |