| 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 "apiutils.h" | 33 #include "apiutils.h" |
| 34 #include "handles.h" | 34 #include "handles.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<class T> | 40 template<class 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); | 43 location_ = HandleScope::CreateHandle(obj, Isolate::Current()); |
| 44 } | 44 } |
| 45 | 45 |
| 46 | 46 |
| 47 template<class T> |
| 48 Handle<T>::Handle(T* obj, Isolate* isolate) { |
| 49 ASSERT(!obj->IsFailure()); |
| 50 location_ = HandleScope::CreateHandle(obj, isolate); |
| 51 } |
| 52 |
| 53 |
| 47 template <class T> | 54 template <class T> |
| 48 inline T* Handle<T>::operator*() const { | 55 inline T* Handle<T>::operator*() const { |
| 49 ASSERT(location_ != NULL); | 56 ASSERT(location_ != NULL); |
| 50 ASSERT(reinterpret_cast<Address>(*location_) != kHandleZapValue); | 57 ASSERT(reinterpret_cast<Address>(*location_) != kHandleZapValue); |
| 51 return *BitCast<T**>(location_); | 58 return *BitCast<T**>(location_); |
| 52 } | 59 } |
| 53 | 60 |
| 54 | 61 |
| 55 HandleScope::HandleScope() | 62 HandleScope::HandleScope() |
| 56 : previous_(*Isolate::Current()->handle_scope_data()) { | 63 : previous_(*Isolate::Current()->handle_scope_data()) { |
| 57 Isolate::Current()->handle_scope_data()->extensions = 0; | 64 Isolate::Current()->handle_scope_data()->extensions = 0; |
| 58 } | 65 } |
| 59 | 66 |
| 60 | 67 |
| 61 template <typename T> | 68 template <typename T> |
| 62 T** HandleScope::CreateHandle(T* value) { | 69 T** HandleScope::CreateHandle(T* value, Isolate* isolate) { |
| 70 ASSERT(isolate == Isolate::Current()); |
| 63 v8::ImplementationUtilities::HandleScopeData* current = | 71 v8::ImplementationUtilities::HandleScopeData* current = |
| 64 Isolate::Current()->handle_scope_data(); | 72 isolate->handle_scope_data(); |
| 65 | 73 |
| 66 internal::Object** cur = current->next; | 74 internal::Object** cur = current->next; |
| 67 if (cur == current->limit) cur = Extend(); | 75 if (cur == current->limit) cur = Extend(); |
| 68 // Update the current next field, set the value in the created | 76 // Update the current next field, set the value in the created |
| 69 // handle, and return the result. | 77 // handle, and return the result. |
| 70 ASSERT(cur < current->limit); | 78 ASSERT(cur < current->limit); |
| 71 current->next = cur + 1; | 79 current->next = cur + 1; |
| 72 | 80 |
| 73 T** result = reinterpret_cast<T**>(cur); | 81 T** result = reinterpret_cast<T**>(cur); |
| 74 *result = value; | 82 *result = value; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 // Restore state in current handle scope to re-enable handle | 124 // Restore state in current handle scope to re-enable handle |
| 117 // allocations. | 125 // allocations. |
| 118 Isolate::Current()->handle_scope_data()->extensions = extensions_; | 126 Isolate::Current()->handle_scope_data()->extensions = extensions_; |
| 119 } | 127 } |
| 120 #endif | 128 #endif |
| 121 | 129 |
| 122 | 130 |
| 123 } } // namespace v8::internal | 131 } } // namespace v8::internal |
| 124 | 132 |
| 125 #endif // V8_HANDLES_INL_H_ | 133 #endif // V8_HANDLES_INL_H_ |
| OLD | NEW |