| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 | 298 |
| 299 template <class S> inline Local<S> As() { | 299 template <class S> inline Local<S> As() { |
| 300 return Local<S>::Cast(*this); | 300 return Local<S>::Cast(*this); |
| 301 } | 301 } |
| 302 | 302 |
| 303 /** Create a local handle for the content of another handle. | 303 /** Create a local handle for the content of another handle. |
| 304 * The referee is kept alive by the local handle even when | 304 * The referee is kept alive by the local handle even when |
| 305 * the original handle is destroyed/disposed. | 305 * the original handle is destroyed/disposed. |
| 306 */ | 306 */ |
| 307 inline static Local<T> New(Handle<T> that); | 307 inline static Local<T> New(Handle<T> that); |
| 308 inline static Local<T> New(Isolate* isolate, Handle<T> that); |
| 308 }; | 309 }; |
| 309 | 310 |
| 310 | 311 |
| 311 /** | 312 /** |
| 312 * An object reference that is independent of any handle scope. Where | 313 * An object reference that is independent of any handle scope. Where |
| 313 * a Local handle only lives as long as the HandleScope in which it was | 314 * a Local handle only lives as long as the HandleScope in which it was |
| 314 * allocated, a Persistent handle remains valid until it is explicitly | 315 * allocated, a Persistent handle remains valid until it is explicitly |
| 315 * disposed. | 316 * disposed. |
| 316 * | 317 * |
| 317 * A persistent handle contains a reference to a storage cell within | 318 * A persistent handle contains a reference to a storage cell within |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 479 | 480 |
| 480 /** | 481 /** |
| 481 * Counts the number of allocated handles. | 482 * Counts the number of allocated handles. |
| 482 */ | 483 */ |
| 483 static int NumberOfHandles(); | 484 static int NumberOfHandles(); |
| 484 | 485 |
| 485 /** | 486 /** |
| 486 * Creates a new handle with the given value. | 487 * Creates a new handle with the given value. |
| 487 */ | 488 */ |
| 488 static internal::Object** CreateHandle(internal::Object* value); | 489 static internal::Object** CreateHandle(internal::Object* value); |
| 490 static internal::Object** CreateHandle(internal::Isolate* isolate, |
| 491 internal::Object* value); |
| 489 // Faster version, uses HeapObject to obtain the current Isolate. | 492 // Faster version, uses HeapObject to obtain the current Isolate. |
| 490 static internal::Object** CreateHandle(internal::HeapObject* value); | 493 static internal::Object** CreateHandle(internal::HeapObject* value); |
| 491 | 494 |
| 492 private: | 495 private: |
| 493 // Make it hard to create heap-allocated or illegal handle scopes by | 496 // Make it hard to create heap-allocated or illegal handle scopes by |
| 494 // disallowing certain operations. | 497 // disallowing certain operations. |
| 495 HandleScope(const HandleScope&); | 498 HandleScope(const HandleScope&); |
| 496 void operator=(const HandleScope&); | 499 void operator=(const HandleScope&); |
| 497 void* operator new(size_t size); | 500 void* operator new(size_t size); |
| 498 void operator delete(void*, size_t); | 501 void operator delete(void*, size_t); |
| (...skipping 3769 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4268 internal::Object** p = reinterpret_cast<internal::Object**>(that_ptr); | 4271 internal::Object** p = reinterpret_cast<internal::Object**>(that_ptr); |
| 4269 if (internal::Internals::CanCastToHeapObject(that_ptr)) { | 4272 if (internal::Internals::CanCastToHeapObject(that_ptr)) { |
| 4270 return Local<T>(reinterpret_cast<T*>(HandleScope::CreateHandle( | 4273 return Local<T>(reinterpret_cast<T*>(HandleScope::CreateHandle( |
| 4271 reinterpret_cast<internal::HeapObject*>(*p)))); | 4274 reinterpret_cast<internal::HeapObject*>(*p)))); |
| 4272 } | 4275 } |
| 4273 return Local<T>(reinterpret_cast<T*>(HandleScope::CreateHandle(*p))); | 4276 return Local<T>(reinterpret_cast<T*>(HandleScope::CreateHandle(*p))); |
| 4274 } | 4277 } |
| 4275 | 4278 |
| 4276 | 4279 |
| 4277 template <class T> | 4280 template <class T> |
| 4281 Local<T> Local<T>::New(Isolate* isolate, Handle<T> that) { |
| 4282 if (that.IsEmpty()) return Local<T>(); |
| 4283 T* that_ptr = *that; |
| 4284 internal::Object** p = reinterpret_cast<internal::Object**>(that_ptr); |
| 4285 return Local<T>(reinterpret_cast<T*>(HandleScope::CreateHandle( |
| 4286 reinterpret_cast<internal::Isolate*>(isolate), *p))); |
| 4287 } |
| 4288 |
| 4289 |
| 4290 template <class T> |
| 4278 Persistent<T> Persistent<T>::New(Handle<T> that) { | 4291 Persistent<T> Persistent<T>::New(Handle<T> that) { |
| 4279 if (that.IsEmpty()) return Persistent<T>(); | 4292 if (that.IsEmpty()) return Persistent<T>(); |
| 4280 internal::Object** p = reinterpret_cast<internal::Object**>(*that); | 4293 internal::Object** p = reinterpret_cast<internal::Object**>(*that); |
| 4281 return Persistent<T>(reinterpret_cast<T*>(V8::GlobalizeReference(p))); | 4294 return Persistent<T>(reinterpret_cast<T*>(V8::GlobalizeReference(p))); |
| 4282 } | 4295 } |
| 4283 | 4296 |
| 4284 | 4297 |
| 4285 template <class T> | 4298 template <class T> |
| 4286 bool Persistent<T>::IsIndependent() const { | 4299 bool Persistent<T>::IsIndependent() const { |
| 4287 if (this->IsEmpty()) return false; | 4300 if (this->IsEmpty()) return false; |
| (...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4814 | 4827 |
| 4815 | 4828 |
| 4816 } // namespace v8 | 4829 } // namespace v8 |
| 4817 | 4830 |
| 4818 | 4831 |
| 4819 #undef V8EXPORT | 4832 #undef V8EXPORT |
| 4820 #undef TYPE_CHECK | 4833 #undef TYPE_CHECK |
| 4821 | 4834 |
| 4822 | 4835 |
| 4823 #endif // V8_H_ | 4836 #endif // V8_H_ |
| OLD | NEW |