Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 44 class V8DOMWrapper { | 44 class V8DOMWrapper { |
| 45 public: | 45 public: |
| 46 static v8::Local<v8::Object> createWrapper(v8::Handle<v8::Object> creati onContext, const WrapperTypeInfo*, void*, v8::Isolate*); | 46 static v8::Local<v8::Object> createWrapper(v8::Handle<v8::Object> creati onContext, const WrapperTypeInfo*, void*, v8::Isolate*); |
| 47 | 47 |
| 48 template<typename V8T, typename T> | 48 template<typename V8T, typename T> |
| 49 static inline v8::Handle<v8::Object> associateObjectWithWrapper(PassRefP tr<T>, const WrapperTypeInfo*, v8::Handle<v8::Object>, v8::Isolate*, WrapperConf iguration::Lifetime); | 49 static inline v8::Handle<v8::Object> associateObjectWithWrapper(PassRefP tr<T>, const WrapperTypeInfo*, v8::Handle<v8::Object>, v8::Isolate*, WrapperConf iguration::Lifetime); |
| 50 template<typename V8T, typename T> | 50 template<typename V8T, typename T> |
| 51 static inline v8::Handle<v8::Object> associateObjectWithWrapper(RawPtr<T > object, const WrapperTypeInfo* type, v8::Handle<v8::Object> wrapper, v8::Isola te* isolate, WrapperConfiguration::Lifetime lifetime) { return associateObjectWi thWrapper<V8T, T>(object.get(), type, wrapper, isolate, lifetime); } | 51 static inline v8::Handle<v8::Object> associateObjectWithWrapper(RawPtr<T > object, const WrapperTypeInfo* type, v8::Handle<v8::Object> wrapper, v8::Isola te* isolate, WrapperConfiguration::Lifetime lifetime) { return associateObjectWi thWrapper<V8T, T>(object.get(), type, wrapper, isolate, lifetime); } |
| 52 template<typename V8T, typename T> | 52 template<typename V8T, typename T> |
| 53 static inline v8::Handle<v8::Object> associateObjectWithWrapper(T*, cons t WrapperTypeInfo*, v8::Handle<v8::Object>, v8::Isolate*, WrapperConfiguration:: Lifetime); | 53 static inline v8::Handle<v8::Object> associateObjectWithWrapper(T*, cons t WrapperTypeInfo*, v8::Handle<v8::Object>, v8::Isolate*, WrapperConfiguration:: Lifetime); |
| 54 static inline void setNativeInfo(v8::Handle<v8::Object>, const WrapperTy peInfo*, void*); | 54 static inline void setNativeInfo(v8::Handle<v8::Object>, const WrapperTy peInfo*, void*); |
|
haraken
2014/03/26 08:16:10
Another thing I'm considering is we want to cause
| |
| 55 static inline void setNativeInfoGarbageCollected(v8::Handle<v8::Object>, const WrapperTypeInfo*, void*); | |
| 55 static inline void setNativeInfoWithPersistentHandle(v8::Handle<v8::Obje ct>, const WrapperTypeInfo*, void*, PersistentNode*); | 56 static inline void setNativeInfoWithPersistentHandle(v8::Handle<v8::Obje ct>, const WrapperTypeInfo*, void*, PersistentNode*); |
| 56 static inline void clearNativeInfo(v8::Handle<v8::Object>, const Wrapper TypeInfo*); | 57 static inline void clearNativeInfo(v8::Handle<v8::Object>, const Wrapper TypeInfo*); |
| 57 | 58 |
| 58 static bool isDOMWrapper(v8::Handle<v8::Value>); | 59 static bool isDOMWrapper(v8::Handle<v8::Value>); |
| 59 }; | 60 }; |
| 60 | 61 |
| 61 inline void V8DOMWrapper::setNativeInfo(v8::Handle<v8::Object> wrapper, cons t WrapperTypeInfo* type, void* object) | 62 inline void V8DOMWrapper::setNativeInfo(v8::Handle<v8::Object> wrapper, cons t WrapperTypeInfo* type, void* object) |
| 62 { | 63 { |
| 63 ASSERT(wrapper->InternalFieldCount() >= 2); | 64 ASSERT(wrapper->InternalFieldCount() >= 2); |
| 64 ASSERT(object); | 65 ASSERT(object); |
| 65 ASSERT(type); | 66 ASSERT(type); |
| 66 #if ENABLE(OILPAN) | 67 #if ENABLE(OILPAN) |
| 67 ASSERT(!type->isGarbageCollected); | 68 ASSERT(!type->isGarbageCollected); |
| 68 #endif | 69 #endif |
| 69 wrapper->SetAlignedPointerInInternalField(v8DOMWrapperObjectIndex, objec t); | 70 wrapper->SetAlignedPointerInInternalField(v8DOMWrapperObjectIndex, objec t); |
| 70 wrapper->SetAlignedPointerInInternalField(v8DOMWrapperTypeIndex, const_c ast<WrapperTypeInfo*>(type)); | 71 wrapper->SetAlignedPointerInInternalField(v8DOMWrapperTypeIndex, const_c ast<WrapperTypeInfo*>(type)); |
| 71 } | 72 } |
| 72 | 73 |
| 74 // Identical to setNativeInfo() but for the "is GCed" assert. | |
| 75 inline void V8DOMWrapper::setNativeInfoGarbageCollected(v8::Handle<v8::Objec t> wrapper, const WrapperTypeInfo* type, void* object) | |
|
haraken
2014/03/26 01:13:32
The GC interaction between V8 and oilpan is compli
sof
2014/03/26 06:36:46
I did explore that option. Handful of tests were l
Mads Ager (chromium)
2014/03/26 07:29:43
Yeah, the problem with that is that there is only
haraken
2014/03/26 08:07:16
Yeah. Given that DOMWindow is not the only object
sof
2014/03/26 10:42:04
...
| |
| 76 { | |
| 77 ASSERT(wrapper->InternalFieldCount() >= 2); | |
| 78 ASSERT(object); | |
| 79 ASSERT(type); | |
| 80 #if ENABLE(OILPAN) | |
| 81 ASSERT(type->isGarbageCollected); | |
| 82 #endif | |
| 83 wrapper->SetAlignedPointerInInternalField(v8DOMWrapperObjectIndex, objec t); | |
| 84 wrapper->SetAlignedPointerInInternalField(v8DOMWrapperTypeIndex, const_c ast<WrapperTypeInfo*>(type)); | |
| 85 } | |
| 86 | |
| 87 | |
| 73 inline void V8DOMWrapper::setNativeInfoWithPersistentHandle(v8::Handle<v8::O bject> wrapper, const WrapperTypeInfo* type, void* object, PersistentNode* handl e) | 88 inline void V8DOMWrapper::setNativeInfoWithPersistentHandle(v8::Handle<v8::O bject> wrapper, const WrapperTypeInfo* type, void* object, PersistentNode* handl e) |
| 74 { | 89 { |
| 75 ASSERT(wrapper->InternalFieldCount() >= 3); | 90 ASSERT(wrapper->InternalFieldCount() >= 3); |
| 76 ASSERT(object); | 91 ASSERT(object); |
| 77 ASSERT(type); | 92 ASSERT(type); |
| 78 ASSERT(type->isGarbageCollected); | 93 ASSERT(type->isGarbageCollected); |
| 79 wrapper->SetAlignedPointerInInternalField(v8DOMWrapperObjectIndex, objec t); | 94 wrapper->SetAlignedPointerInInternalField(v8DOMWrapperObjectIndex, objec t); |
| 80 wrapper->SetAlignedPointerInInternalField(v8DOMWrapperTypeIndex, const_c ast<WrapperTypeInfo*>(type)); | 95 wrapper->SetAlignedPointerInInternalField(v8DOMWrapperTypeIndex, const_c ast<WrapperTypeInfo*>(type)); |
| 81 // Persistent handle is stored in the last internal field. | 96 // Persistent handle is stored in the last internal field. |
| 82 wrapper->SetAlignedPointerInInternalField(wrapper->InternalFieldCount() - 1, handle); | 97 wrapper->SetAlignedPointerInInternalField(wrapper->InternalFieldCount() - 1, handle); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 143 v8::Handle<v8::Context> context() const { return m_context; } | 158 v8::Handle<v8::Context> context() const { return m_context; } |
| 144 | 159 |
| 145 private: | 160 private: |
| 146 bool m_didEnterContext; | 161 bool m_didEnterContext; |
| 147 v8::Handle<v8::Context> m_context; | 162 v8::Handle<v8::Context> m_context; |
| 148 }; | 163 }; |
| 149 | 164 |
| 150 } | 165 } |
| 151 | 166 |
| 152 #endif // V8DOMWrapper_h | 167 #endif // V8DOMWrapper_h |
| OLD | NEW |