Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(165)

Side by Side Diff: include/v8.h

Issue 22384003: expose eternal handle api (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: added uninitialized constant Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | src/api.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 friend class HandleScope; 381 friend class HandleScope;
382 382
383 #ifndef V8_USE_UNSAFE_HANDLES 383 #ifndef V8_USE_UNSAFE_HANDLES
384 V8_INLINE(static Handle<T> New(Isolate* isolate, T* that)); 384 V8_INLINE(static Handle<T> New(Isolate* isolate, T* that));
385 #endif 385 #endif
386 386
387 T* val_; 387 T* val_;
388 }; 388 };
389 389
390 390
391 // A value which will never be returned by Local::Eternalize
392 // Useful for static initialization
393 const int kUninitializedEternalIndex = -1;
394
395
391 /** 396 /**
392 * A light-weight stack-allocated object handle. All operations 397 * A light-weight stack-allocated object handle. All operations
393 * that return objects from within v8 return them in local handles. They 398 * that return objects from within v8 return them in local handles. They
394 * are created within HandleScopes, and all local handles allocated within a 399 * are created within HandleScopes, and all local handles allocated within a
395 * handle scope are destroyed when the handle scope is destroyed. Hence it 400 * handle scope are destroyed when the handle scope is destroyed. Hence it
396 * is not necessary to explicitly deallocate local handles. 401 * is not necessary to explicitly deallocate local handles.
397 */ 402 */
398 // TODO(dcarney): deprecate entire class 403 // TODO(dcarney): deprecate entire class
399 template <class T> class Local : public Handle<T> { 404 template <class T> class Local : public Handle<T> {
400 public: 405 public:
(...skipping 25 matching lines...) Expand all
426 template <class S> V8_INLINE(Local(Handle<S> that)) 431 template <class S> V8_INLINE(Local(Handle<S> that))
427 : Handle<T>(reinterpret_cast<T*>(*that)) { 432 : Handle<T>(reinterpret_cast<T*>(*that)) {
428 TYPE_CHECK(T, S); 433 TYPE_CHECK(T, S);
429 } 434 }
430 #endif 435 #endif
431 436
432 template <class S> V8_INLINE(Local<S> As()) { 437 template <class S> V8_INLINE(Local<S> As()) {
433 return Local<S>::Cast(*this); 438 return Local<S>::Cast(*this);
434 } 439 }
435 440
441 // Keep this Local alive for the lifetime of the Isolate.
442 // It remains retrievable via the returned index,
443 V8_INLINE(int Eternalize(Isolate* isolate));
444 V8_INLINE(static Local<T> GetEternal(Isolate* isolate, int index));
445
436 /** 446 /**
437 * Create a local handle for the content of another handle. 447 * Create a local handle for the content of another handle.
438 * The referee is kept alive by the local handle even when 448 * The referee is kept alive by the local handle even when
439 * the original handle is destroyed/disposed. 449 * the original handle is destroyed/disposed.
440 */ 450 */
441 V8_INLINE(static Local<T> New(Handle<T> that)); 451 V8_INLINE(static Local<T> New(Handle<T> that));
442 V8_INLINE(static Local<T> New(Isolate* isolate, Handle<T> that)); 452 V8_INLINE(static Local<T> New(Isolate* isolate, Handle<T> that));
443 #ifndef V8_USE_UNSAFE_HANDLES 453 #ifndef V8_USE_UNSAFE_HANDLES
444 // TODO(dcarney): remove before cutover 454 // TODO(dcarney): remove before cutover
445 V8_INLINE(static Local<T> New(Isolate* isolate, const Persistent<T>& that)); 455 V8_INLINE(static Local<T> New(Isolate* isolate, const Persistent<T>& that));
(...skipping 4334 matching lines...) Expand 10 before | Expand all | Expand 10 after
4780 V8(); 4790 V8();
4781 4791
4782 static internal::Object** GlobalizeReference(internal::Isolate* isolate, 4792 static internal::Object** GlobalizeReference(internal::Isolate* isolate,
4783 internal::Object** handle); 4793 internal::Object** handle);
4784 static void DisposeGlobal(internal::Object** global_handle); 4794 static void DisposeGlobal(internal::Object** global_handle);
4785 typedef WeakReferenceCallbacks<Value, void>::Revivable RevivableCallback; 4795 typedef WeakReferenceCallbacks<Value, void>::Revivable RevivableCallback;
4786 static void MakeWeak(internal::Object** global_handle, 4796 static void MakeWeak(internal::Object** global_handle,
4787 void* data, 4797 void* data,
4788 RevivableCallback weak_reference_callback); 4798 RevivableCallback weak_reference_callback);
4789 static void ClearWeak(internal::Object** global_handle); 4799 static void ClearWeak(internal::Object** global_handle);
4800 static int Eternalize(internal::Isolate* isolate,
4801 internal::Object** handle);
4802 static internal::Object** GetEternal(internal::Isolate* isolate, int index);
4790 4803
4791 template <class T> friend class Handle; 4804 template <class T> friend class Handle;
4792 template <class T> friend class Local; 4805 template <class T> friend class Local;
4793 template <class T> friend class Persistent; 4806 template <class T> friend class Persistent;
4794 friend class Context; 4807 friend class Context;
4795 }; 4808 };
4796 4809
4797 4810
4798 /** 4811 /**
4799 * An external exception handler. 4812 * An external exception handler.
(...skipping 843 matching lines...) Expand 10 before | Expand all | Expand 10 after
5643 template <class T> 5656 template <class T>
5644 Local<T> Local<T>::New(Isolate* isolate, T* that) { 5657 Local<T> Local<T>::New(Isolate* isolate, T* that) {
5645 if (that == NULL) return Local<T>(); 5658 if (that == NULL) return Local<T>();
5646 T* that_ptr = that; 5659 T* that_ptr = that;
5647 internal::Object** p = reinterpret_cast<internal::Object**>(that_ptr); 5660 internal::Object** p = reinterpret_cast<internal::Object**>(that_ptr);
5648 return Local<T>(reinterpret_cast<T*>(HandleScope::CreateHandle( 5661 return Local<T>(reinterpret_cast<T*>(HandleScope::CreateHandle(
5649 reinterpret_cast<internal::Isolate*>(isolate), *p))); 5662 reinterpret_cast<internal::Isolate*>(isolate), *p)));
5650 } 5663 }
5651 5664
5652 5665
5666 template<class T>
5667 int Local<T>::Eternalize(Isolate* isolate) {
5668 return V8::Eternalize(reinterpret_cast<internal::Isolate*>(isolate),
5669 reinterpret_cast<internal::Object**>(this->val_));
5670 }
5671
5672
5673 template<class T>
5674 Local<T> Local<T>::GetEternal(Isolate* isolate, int index) {
5675 internal::Object** handle =
5676 V8::GetEternal(reinterpret_cast<internal::Isolate*>(isolate), index);
5677 return Local<T>(T::Cast(reinterpret_cast<Value*>(handle)));
5678 }
5679
5680
5653 #ifdef V8_USE_UNSAFE_HANDLES 5681 #ifdef V8_USE_UNSAFE_HANDLES
5654 template <class T> 5682 template <class T>
5655 Persistent<T> Persistent<T>::New(Handle<T> that) { 5683 Persistent<T> Persistent<T>::New(Handle<T> that) {
5656 return New(Isolate::GetCurrent(), that.val_); 5684 return New(Isolate::GetCurrent(), that.val_);
5657 } 5685 }
5658 5686
5659 5687
5660 template <class T> 5688 template <class T>
5661 Persistent<T> Persistent<T>::New(Isolate* isolate, Handle<T> that) { 5689 Persistent<T> Persistent<T>::New(Isolate* isolate, Handle<T> that) {
5662 return New(Isolate::GetCurrent(), that.val_); 5690 return New(Isolate::GetCurrent(), that.val_);
(...skipping 895 matching lines...) Expand 10 before | Expand all | Expand 10 after
6558 */ 6586 */
6559 6587
6560 6588
6561 } // namespace v8 6589 } // namespace v8
6562 6590
6563 6591
6564 #undef TYPE_CHECK 6592 #undef TYPE_CHECK
6565 6593
6566 6594
6567 #endif // V8_H_ 6595 #endif // V8_H_
OLDNEW
« no previous file with comments | « no previous file | src/api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698