| 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 Handle<T>::Handle(T* obj, Isolate* isolate) { | 56 Handle<T>::Handle(T* obj, Isolate* isolate) { |
| 57 ASSERT(!obj->IsFailure()); | 57 ASSERT(!obj->IsFailure()); |
| 58 location_ = HandleScope::CreateHandle(obj, isolate); | 58 location_ = HandleScope::CreateHandle(obj, isolate); |
| 59 } | 59 } |
| 60 | 60 |
| 61 | 61 |
| 62 template <typename T> | 62 template <typename T> |
| 63 inline T* Handle<T>::operator*() const { | 63 inline T* Handle<T>::operator*() const { |
| 64 ASSERT(location_ != NULL); | 64 ASSERT(location_ != NULL); |
| 65 ASSERT(reinterpret_cast<Address>(*location_) != kHandleZapValue); | 65 ASSERT(reinterpret_cast<Address>(*location_) != kHandleZapValue); |
| 66 SLOW_ASSERT(ISOLATE->allow_handle_deref()); |
| 66 return *BitCast<T**>(location_); | 67 return *BitCast<T**>(location_); |
| 67 } | 68 } |
| 68 | 69 |
| 70 template <typename T> |
| 71 inline T** Handle<T>::location() const { |
| 72 ASSERT(location_ == NULL || |
| 73 reinterpret_cast<Address>(*location_) != kZapValue); |
| 74 SLOW_ASSERT(ISOLATE->allow_handle_deref()); |
| 75 return location_; |
| 76 } |
| 77 |
| 69 | 78 |
| 70 HandleScope::HandleScope() { | 79 HandleScope::HandleScope() { |
| 71 Isolate* isolate = Isolate::Current(); | 80 Isolate* isolate = Isolate::Current(); |
| 72 v8::ImplementationUtilities::HandleScopeData* current = | 81 v8::ImplementationUtilities::HandleScopeData* current = |
| 73 isolate->handle_scope_data(); | 82 isolate->handle_scope_data(); |
| 74 isolate_ = isolate; | 83 isolate_ = isolate; |
| 75 prev_next_ = current->next; | 84 prev_next_ = current->next; |
| 76 prev_limit_ = current->limit; | 85 prev_limit_ = current->limit; |
| 77 current->level++; | 86 current->level++; |
| 78 } | 87 } |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 inline NoHandleAllocation::~NoHandleAllocation() { | 177 inline NoHandleAllocation::~NoHandleAllocation() { |
| 169 if (active_) { | 178 if (active_) { |
| 170 // Restore state in current handle scope to re-enable handle | 179 // Restore state in current handle scope to re-enable handle |
| 171 // allocations. | 180 // allocations. |
| 172 v8::ImplementationUtilities::HandleScopeData* data = | 181 v8::ImplementationUtilities::HandleScopeData* data = |
| 173 Isolate::Current()->handle_scope_data(); | 182 Isolate::Current()->handle_scope_data(); |
| 174 ASSERT_EQ(0, data->level); | 183 ASSERT_EQ(0, data->level); |
| 175 data->level = level_; | 184 data->level = level_; |
| 176 } | 185 } |
| 177 } | 186 } |
| 187 |
| 188 |
| 189 NoHandleDereference::NoHandleDereference() { |
| 190 // The guard is set on a per-isolate basis, so it affects all threads. |
| 191 // That's why we can only use it when running without parallel recompilation. |
| 192 if (FLAG_parallel_recompilation) return; |
| 193 Isolate* isolate = Isolate::Current(); |
| 194 old_state_ = isolate->allow_handle_deref(); |
| 195 isolate->set_allow_handle_deref(false); |
| 196 } |
| 197 |
| 198 |
| 199 NoHandleDereference::~NoHandleDereference() { |
| 200 if (FLAG_parallel_recompilation) return; |
| 201 Isolate::Current()->set_allow_handle_deref(old_state_); |
| 202 } |
| 203 |
| 204 |
| 205 AllowHandleDereference::AllowHandleDereference() { |
| 206 // The guard is set on a per-isolate basis, so it affects all threads. |
| 207 // That's why we can only use it when running without parallel recompilation. |
| 208 if (FLAG_parallel_recompilation) return; |
| 209 Isolate* isolate = Isolate::Current(); |
| 210 old_state_ = isolate->allow_handle_deref(); |
| 211 isolate->set_allow_handle_deref(true); |
| 212 } |
| 213 |
| 214 |
| 215 AllowHandleDereference::~AllowHandleDereference() { |
| 216 if (FLAG_parallel_recompilation) return; |
| 217 Isolate::Current()->set_allow_handle_deref(old_state_); |
| 218 } |
| 178 #endif | 219 #endif |
| 179 | 220 |
| 180 | 221 |
| 181 } } // namespace v8::internal | 222 } } // namespace v8::internal |
| 182 | 223 |
| 183 #endif // V8_HANDLES_INL_H_ | 224 #endif // V8_HANDLES_INL_H_ |
| OLD | NEW |