| 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 694 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 705 // TODO(dcarney): remove | 705 // TODO(dcarney): remove |
| 706 #ifndef V8_ALLOW_ACCESS_TO_RAW_HANDLE_CONSTRUCTOR | 706 #ifndef V8_ALLOW_ACCESS_TO_RAW_HANDLE_CONSTRUCTOR |
| 707 | 707 |
| 708 private: | 708 private: |
| 709 #endif | 709 #endif |
| 710 template <class S> V8_INLINE Persistent(S* that) : val_(that) { } | 710 template <class S> V8_INLINE Persistent(S* that) : val_(that) { } |
| 711 | 711 |
| 712 V8_INLINE T* operator*() const { return val_; } | 712 V8_INLINE T* operator*() const { return val_; } |
| 713 | 713 |
| 714 private: | 714 private: |
| 715 friend class Isolate; |
| 715 friend class Utils; | 716 friend class Utils; |
| 716 template<class F> friend class Handle; | 717 template<class F> friend class Handle; |
| 717 template<class F> friend class Local; | 718 template<class F> friend class Local; |
| 718 template<class F1, class F2> friend class Persistent; | 719 template<class F1, class F2> friend class Persistent; |
| 719 template<class F> friend class ReturnValue; | 720 template<class F> friend class ReturnValue; |
| 720 | 721 |
| 721 V8_INLINE static T* New(Isolate* isolate, T* that); | 722 V8_INLINE static T* New(Isolate* isolate, T* that); |
| 722 template<class S, class M2> | 723 template<class S, class M2> |
| 723 V8_INLINE void Copy(const Persistent<S, M2>& that); | 724 V8_INLINE void Copy(const Persistent<S, M2>& that); |
| 724 | 725 |
| (...skipping 3334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4059 * Allows the host application to group objects together. If one | 4060 * Allows the host application to group objects together. If one |
| 4060 * object in the group is alive, all objects in the group are alive. | 4061 * object in the group is alive, all objects in the group are alive. |
| 4061 * After each garbage collection, object groups are removed. It is | 4062 * After each garbage collection, object groups are removed. It is |
| 4062 * intended to be used in the before-garbage-collection callback | 4063 * intended to be used in the before-garbage-collection callback |
| 4063 * function, for instance to simulate DOM tree connections among JS | 4064 * function, for instance to simulate DOM tree connections among JS |
| 4064 * wrapper objects. Object groups for all dependent handles need to | 4065 * wrapper objects. Object groups for all dependent handles need to |
| 4065 * be provided for kGCTypeMarkSweepCompact collections, for all other | 4066 * be provided for kGCTypeMarkSweepCompact collections, for all other |
| 4066 * garbage collection types it is sufficient to provide object groups | 4067 * garbage collection types it is sufficient to provide object groups |
| 4067 * for partially dependent handles only. | 4068 * for partially dependent handles only. |
| 4068 */ | 4069 */ |
| 4069 void SetObjectGroupId(const Persistent<Value>& object, | 4070 template<typename T> void SetObjectGroupId(const Persistent<T>& object, |
| 4070 UniqueId id); | 4071 UniqueId id); |
| 4071 | 4072 |
| 4072 /** | 4073 /** |
| 4073 * Allows the host application to declare implicit references from an object | 4074 * Allows the host application to declare implicit references from an object |
| 4074 * group to an object. If the objects of the object group are alive, the child | 4075 * group to an object. If the objects of the object group are alive, the child |
| 4075 * object is alive too. After each garbage collection, all implicit references | 4076 * object is alive too. After each garbage collection, all implicit references |
| 4076 * are removed. It is intended to be used in the before-garbage-collection | 4077 * are removed. It is intended to be used in the before-garbage-collection |
| 4077 * callback function. | 4078 * callback function. |
| 4078 */ | 4079 */ |
| 4079 void SetReferenceFromGroup(UniqueId id, | 4080 template<typename T> void SetReferenceFromGroup(UniqueId id, |
| 4080 const Persistent<Value>& child); | 4081 const Persistent<T>& child); |
| 4081 | 4082 |
| 4082 /** | 4083 /** |
| 4083 * Allows the host application to declare implicit references from an object | 4084 * Allows the host application to declare implicit references from an object |
| 4084 * to another object. If the parent object is alive, the child object is alive | 4085 * to another object. If the parent object is alive, the child object is alive |
| 4085 * too. After each garbage collection, all implicit references are removed. It | 4086 * too. After each garbage collection, all implicit references are removed. It |
| 4086 * is intended to be used in the before-garbage-collection callback function. | 4087 * is intended to be used in the before-garbage-collection callback function. |
| 4087 */ | 4088 */ |
| 4088 void SetReference(const Persistent<Object>& parent, | 4089 template<typename T, typename S> |
| 4089 const Persistent<Value>& child); | 4090 void SetReference(const Persistent<T>& parent, const Persistent<S>& child); |
| 4090 | 4091 |
| 4091 typedef void (*GCPrologueCallback)(Isolate* isolate, | 4092 typedef void (*GCPrologueCallback)(Isolate* isolate, |
| 4092 GCType type, | 4093 GCType type, |
| 4093 GCCallbackFlags flags); | 4094 GCCallbackFlags flags); |
| 4094 typedef void (*GCEpilogueCallback)(Isolate* isolate, | 4095 typedef void (*GCEpilogueCallback)(Isolate* isolate, |
| 4095 GCType type, | 4096 GCType type, |
| 4096 GCCallbackFlags flags); | 4097 GCCallbackFlags flags); |
| 4097 | 4098 |
| 4098 /** | 4099 /** |
| 4099 * Enables the host application to receive a notification before a | 4100 * Enables the host application to receive a notification before a |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4133 */ | 4134 */ |
| 4134 void RemoveGCEpilogueCallback(GCEpilogueCallback callback); | 4135 void RemoveGCEpilogueCallback(GCEpilogueCallback callback); |
| 4135 | 4136 |
| 4136 private: | 4137 private: |
| 4137 Isolate(); | 4138 Isolate(); |
| 4138 Isolate(const Isolate&); | 4139 Isolate(const Isolate&); |
| 4139 ~Isolate(); | 4140 ~Isolate(); |
| 4140 Isolate& operator=(const Isolate&); | 4141 Isolate& operator=(const Isolate&); |
| 4141 void* operator new(size_t size); | 4142 void* operator new(size_t size); |
| 4142 void operator delete(void*, size_t); | 4143 void operator delete(void*, size_t); |
| 4144 |
| 4145 void SetObjectGroupId(internal::Object** object, UniqueId id); |
| 4146 void SetReferenceFromGroup(UniqueId id, internal::Object** object); |
| 4147 void SetReference(internal::Object** parent, internal::Object** child); |
| 4143 }; | 4148 }; |
| 4144 | 4149 |
| 4145 | |
| 4146 class V8_EXPORT StartupData { | 4150 class V8_EXPORT StartupData { |
| 4147 public: | 4151 public: |
| 4148 enum CompressionAlgorithm { | 4152 enum CompressionAlgorithm { |
| 4149 kUncompressed, | 4153 kUncompressed, |
| 4150 kBZip2 | 4154 kBZip2 |
| 4151 }; | 4155 }; |
| 4152 | 4156 |
| 4153 const char* data; | 4157 const char* data; |
| 4154 int compressed_size; | 4158 int compressed_size; |
| 4155 int raw_size; | 4159 int raw_size; |
| (...skipping 2257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6413 I::SetEmbedderData(this, data); | 6417 I::SetEmbedderData(this, data); |
| 6414 } | 6418 } |
| 6415 | 6419 |
| 6416 | 6420 |
| 6417 void* Isolate::GetData() { | 6421 void* Isolate::GetData() { |
| 6418 typedef internal::Internals I; | 6422 typedef internal::Internals I; |
| 6419 return I::GetEmbedderData(this); | 6423 return I::GetEmbedderData(this); |
| 6420 } | 6424 } |
| 6421 | 6425 |
| 6422 | 6426 |
| 6427 template<typename T> |
| 6428 void Isolate::SetObjectGroupId(const Persistent<T>& object, |
| 6429 UniqueId id) { |
| 6430 TYPE_CHECK(Value, T); |
| 6431 SetObjectGroupId(reinterpret_cast<v8::internal::Object**>(object.val_), id); |
| 6432 } |
| 6433 |
| 6434 |
| 6435 template<typename T> |
| 6436 void Isolate::SetReferenceFromGroup(UniqueId id, |
| 6437 const Persistent<T>& object) { |
| 6438 TYPE_CHECK(Value, T); |
| 6439 SetReferenceFromGroup(id, |
| 6440 reinterpret_cast<v8::internal::Object**>(object.val_)); |
| 6441 } |
| 6442 |
| 6443 |
| 6444 template<typename T, typename S> |
| 6445 void Isolate::SetReference(const Persistent<T>& parent, |
| 6446 const Persistent<S>& child) { |
| 6447 TYPE_CHECK(Object, T); |
| 6448 TYPE_CHECK(Value, S); |
| 6449 SetReference(reinterpret_cast<v8::internal::Object**>(parent.val_), |
| 6450 reinterpret_cast<v8::internal::Object**>(child.val_)); |
| 6451 } |
| 6452 |
| 6453 |
| 6423 Local<Value> Context::GetEmbedderData(int index) { | 6454 Local<Value> Context::GetEmbedderData(int index) { |
| 6424 #ifndef V8_ENABLE_CHECKS | 6455 #ifndef V8_ENABLE_CHECKS |
| 6425 typedef internal::Object O; | 6456 typedef internal::Object O; |
| 6426 typedef internal::HeapObject HO; | 6457 typedef internal::HeapObject HO; |
| 6427 typedef internal::Internals I; | 6458 typedef internal::Internals I; |
| 6428 HO* context = *reinterpret_cast<HO**>(this); | 6459 HO* context = *reinterpret_cast<HO**>(this); |
| 6429 O** result = | 6460 O** result = |
| 6430 HandleScope::CreateHandle(context, I::ReadEmbedderData<O*>(this, index)); | 6461 HandleScope::CreateHandle(context, I::ReadEmbedderData<O*>(this, index)); |
| 6431 return Local<Value>(reinterpret_cast<Value*>(result)); | 6462 return Local<Value>(reinterpret_cast<Value*>(result)); |
| 6432 #else | 6463 #else |
| (...skipping 24 matching lines...) Expand all Loading... |
| 6457 */ | 6488 */ |
| 6458 | 6489 |
| 6459 | 6490 |
| 6460 } // namespace v8 | 6491 } // namespace v8 |
| 6461 | 6492 |
| 6462 | 6493 |
| 6463 #undef TYPE_CHECK | 6494 #undef TYPE_CHECK |
| 6464 | 6495 |
| 6465 | 6496 |
| 6466 #endif // V8_H_ | 6497 #endif // V8_H_ |
| OLD | NEW |