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

Side by Side Diff: include/v8.h

Issue 24550006: remove Local::New with no isolate parameter (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: rebase Created 7 years, 2 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 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 371
372 template <class S> V8_INLINE Local<S> As() { 372 template <class S> V8_INLINE Local<S> As() {
373 return Local<S>::Cast(*this); 373 return Local<S>::Cast(*this);
374 } 374 }
375 375
376 /** 376 /**
377 * Create a local handle for the content of another handle. 377 * Create a local handle for the content of another handle.
378 * The referee is kept alive by the local handle even when 378 * The referee is kept alive by the local handle even when
379 * the original handle is destroyed/disposed. 379 * the original handle is destroyed/disposed.
380 */ 380 */
381 V8_INLINE static Local<T> New(Handle<T> that);
382 V8_INLINE static Local<T> New(Isolate* isolate, Handle<T> that); 381 V8_INLINE static Local<T> New(Isolate* isolate, Handle<T> that);
383 template<class M> 382 template<class M>
384 V8_INLINE static Local<T> New(Isolate* isolate, 383 V8_INLINE static Local<T> New(Isolate* isolate,
385 const Persistent<T, M>& that); 384 const Persistent<T, M>& that);
386 385
387 #ifndef V8_ALLOW_ACCESS_TO_RAW_HANDLE_CONSTRUCTOR 386 #ifndef V8_ALLOW_ACCESS_TO_RAW_HANDLE_CONSTRUCTOR
388 387
389 private: 388 private:
390 #endif 389 #endif
391 template <class S> V8_INLINE Local(S* that) : Handle<T>(that) { } 390 template <class S> V8_INLINE Local(S* that) : Handle<T>(that) { }
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
776 ~HandleScope(); 775 ~HandleScope();
777 776
778 // TODO(dcarney): deprecated - use EscapableHandleScope::Escape. 777 // TODO(dcarney): deprecated - use EscapableHandleScope::Escape.
779 template <class T> Local<T> Close(Handle<T> value); 778 template <class T> Local<T> Close(Handle<T> value);
780 779
781 /** 780 /**
782 * Counts the number of allocated handles. 781 * Counts the number of allocated handles.
783 */ 782 */
784 static int NumberOfHandles(); 783 static int NumberOfHandles();
785 784
785 private:
786 /** 786 /**
787 * Creates a new handle with the given value. 787 * Creates a new handle with the given value.
788 */ 788 */
789 static internal::Object** CreateHandle(internal::Object* value);
790 static internal::Object** CreateHandle(internal::Isolate* isolate, 789 static internal::Object** CreateHandle(internal::Isolate* isolate,
791 internal::Object* value); 790 internal::Object* value);
792 // Faster version, uses HeapObject to obtain the current Isolate. 791 // Uses HeapObject to obtain the current Isolate.
793 static internal::Object** CreateHandle(internal::HeapObject* value); 792 static internal::Object** CreateHandle(internal::HeapObject* heap_object,
793 internal::Object* value);
794 794
795 private:
796 V8_INLINE HandleScope() {} 795 V8_INLINE HandleScope() {}
797 void Initialize(Isolate* isolate); 796 void Initialize(Isolate* isolate);
798 797
799 // Make it hard to create heap-allocated or illegal handle scopes by 798 // Make it hard to create heap-allocated or illegal handle scopes by
800 // disallowing certain operations. 799 // disallowing certain operations.
801 HandleScope(const HandleScope&); 800 HandleScope(const HandleScope&);
802 void operator=(const HandleScope&); 801 void operator=(const HandleScope&);
803 void* operator new(size_t size); 802 void* operator new(size_t size);
804 void operator delete(void*, size_t); 803 void operator delete(void*, size_t);
805 804
(...skipping 17 matching lines...) Expand all
823 internal::Object** prev_limit_; 822 internal::Object** prev_limit_;
824 823
825 // TODO(dcarney): remove this field 824 // TODO(dcarney): remove this field
826 // Allow for the active closing of HandleScopes which allows to pass a handle 825 // Allow for the active closing of HandleScopes which allows to pass a handle
827 // from the HandleScope being closed to the next top most HandleScope. 826 // from the HandleScope being closed to the next top most HandleScope.
828 bool is_closed_; 827 bool is_closed_;
829 internal::Object** RawClose(internal::Object** value); 828 internal::Object** RawClose(internal::Object** value);
830 829
831 friend class ImplementationUtilities; 830 friend class ImplementationUtilities;
832 friend class EscapableHandleScope; 831 friend class EscapableHandleScope;
832 template<class F> friend class Handle;
833 template<class F> friend class Local;
834 friend class Object;
835 friend class Context;
833 }; 836 };
834 837
835 838
836 /** 839 /**
837 * A HandleScope which first allocates a handle in the current scope 840 * A HandleScope which first allocates a handle in the current scope
838 * which will be later filled with the escape value. 841 * which will be later filled with the escape value.
839 */ 842 */
840 class V8_EXPORT EscapableHandleScope : public HandleScope { 843 class V8_EXPORT EscapableHandleScope : public HandleScope {
841 public: 844 public:
842 EscapableHandleScope(Isolate* isolate); 845 EscapableHandleScope(Isolate* isolate);
(...skipping 4719 matching lines...) Expand 10 before | Expand all | Expand 10 after
5562 }; 5565 };
5563 5566
5564 } // namespace internal 5567 } // namespace internal
5565 5568
5566 5569
5567 template <class T> 5570 template <class T>
5568 Local<T>::Local() : Handle<T>() { } 5571 Local<T>::Local() : Handle<T>() { }
5569 5572
5570 5573
5571 template <class T> 5574 template <class T>
5572 Local<T> Local<T>::New(Handle<T> that) {
5573 if (that.IsEmpty()) return Local<T>();
5574 T* that_ptr = *that;
5575 internal::Object** p = reinterpret_cast<internal::Object**>(that_ptr);
5576 if (internal::Internals::CanCastToHeapObject(that_ptr)) {
5577 return Local<T>(reinterpret_cast<T*>(HandleScope::CreateHandle(
5578 reinterpret_cast<internal::HeapObject*>(*p))));
5579 }
5580 return Local<T>(reinterpret_cast<T*>(HandleScope::CreateHandle(*p)));
5581 }
5582
5583
5584 template <class T>
5585 Local<T> Local<T>::New(Isolate* isolate, Handle<T> that) { 5575 Local<T> Local<T>::New(Isolate* isolate, Handle<T> that) {
5586 return New(isolate, that.val_); 5576 return New(isolate, that.val_);
5587 } 5577 }
5588 5578
5589 template <class T> 5579 template <class T>
5590 template <class M> 5580 template <class M>
5591 Local<T> Local<T>::New(Isolate* isolate, const Persistent<T, M>& that) { 5581 Local<T> Local<T>::New(Isolate* isolate, const Persistent<T, M>& that) {
5592 return New(isolate, that.val_); 5582 return New(isolate, that.val_);
5593 } 5583 }
5594 5584
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after
6010 6000
6011 6001
6012 void Template::Set(const char* name, v8::Handle<Data> value) { 6002 void Template::Set(const char* name, v8::Handle<Data> value) {
6013 Set(v8::String::New(name), value); 6003 Set(v8::String::New(name), value);
6014 } 6004 }
6015 6005
6016 6006
6017 Local<Value> Object::GetInternalField(int index) { 6007 Local<Value> Object::GetInternalField(int index) {
6018 #ifndef V8_ENABLE_CHECKS 6008 #ifndef V8_ENABLE_CHECKS
6019 typedef internal::Object O; 6009 typedef internal::Object O;
6010 typedef internal::HeapObject HO;
6020 typedef internal::Internals I; 6011 typedef internal::Internals I;
6021 O* obj = *reinterpret_cast<O**>(this); 6012 O* obj = *reinterpret_cast<O**>(this);
6022 // Fast path: If the object is a plain JSObject, which is the common case, we 6013 // Fast path: If the object is a plain JSObject, which is the common case, we
6023 // know where to find the internal fields and can return the value directly. 6014 // know where to find the internal fields and can return the value directly.
6024 if (I::GetInstanceType(obj) == I::kJSObjectType) { 6015 if (I::GetInstanceType(obj) == I::kJSObjectType) {
6025 int offset = I::kJSObjectHeaderSize + (internal::kApiPointerSize * index); 6016 int offset = I::kJSObjectHeaderSize + (internal::kApiPointerSize * index);
6026 O* value = I::ReadField<O*>(obj, offset); 6017 O* value = I::ReadField<O*>(obj, offset);
6027 O** result = HandleScope::CreateHandle(value); 6018 O** result = HandleScope::CreateHandle(reinterpret_cast<HO*>(obj), value);
6028 return Local<Value>(reinterpret_cast<Value*>(result)); 6019 return Local<Value>(reinterpret_cast<Value*>(result));
6029 } 6020 }
6030 #endif 6021 #endif
6031 return SlowGetInternalField(index); 6022 return SlowGetInternalField(index);
6032 } 6023 }
6033 6024
6034 6025
6035 void* Object::GetAlignedPointerFromInternalField(int index) { 6026 void* Object::GetAlignedPointerFromInternalField(int index) {
6036 #ifndef V8_ENABLE_CHECKS 6027 #ifndef V8_ENABLE_CHECKS
6037 typedef internal::Object O; 6028 typedef internal::Object O;
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after
6469 6460
6470 void* Isolate::GetData() { 6461 void* Isolate::GetData() {
6471 typedef internal::Internals I; 6462 typedef internal::Internals I;
6472 return I::GetEmbedderData(this); 6463 return I::GetEmbedderData(this);
6473 } 6464 }
6474 6465
6475 6466
6476 Local<Value> Context::GetEmbedderData(int index) { 6467 Local<Value> Context::GetEmbedderData(int index) {
6477 #ifndef V8_ENABLE_CHECKS 6468 #ifndef V8_ENABLE_CHECKS
6478 typedef internal::Object O; 6469 typedef internal::Object O;
6470 typedef internal::HeapObject HO;
6479 typedef internal::Internals I; 6471 typedef internal::Internals I;
6480 O** result = HandleScope::CreateHandle(I::ReadEmbedderData<O*>(this, index)); 6472 HO* context = *reinterpret_cast<HO**>(this);
6473 O** result =
6474 HandleScope::CreateHandle(context, I::ReadEmbedderData<O*>(this, index));
6481 return Local<Value>(reinterpret_cast<Value*>(result)); 6475 return Local<Value>(reinterpret_cast<Value*>(result));
6482 #else 6476 #else
6483 return SlowGetEmbedderData(index); 6477 return SlowGetEmbedderData(index);
6484 #endif 6478 #endif
6485 } 6479 }
6486 6480
6487 6481
6488 void* Context::GetAlignedPointerFromEmbedderData(int index) { 6482 void* Context::GetAlignedPointerFromEmbedderData(int index) {
6489 #ifndef V8_ENABLE_CHECKS 6483 #ifndef V8_ENABLE_CHECKS
6490 typedef internal::Internals I; 6484 typedef internal::Internals I;
(...skipping 16 matching lines...) Expand all
6507 */ 6501 */
6508 6502
6509 6503
6510 } // namespace v8 6504 } // namespace v8
6511 6505
6512 6506
6513 #undef TYPE_CHECK 6507 #undef TYPE_CHECK
6514 6508
6515 6509
6516 #endif // V8_H_ 6510 #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