WebKit Bugzilla
Attachment 342610 Details for
Bug 186579
: Share structure across instances of classes exported through the ObjC API
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-186579-20180612162404.patch (text/plain), 4.03 KB, created by
Tadeu Zagallo
on 2018-06-12 16:24:05 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Tadeu Zagallo
Created:
2018-06-12 16:24:05 PDT
Size:
4.03 KB
patch
obsolete
>Subversion Revision: 232634 >diff --git a/Source/JavaScriptCore/ChangeLog b/Source/JavaScriptCore/ChangeLog >index e89b57395009cc09d3fd8a8460af9319cfa14bf1..1fe65b3b8ecb1f5b42f09129cb70bfd883760d1b 100644 >--- a/Source/JavaScriptCore/ChangeLog >+++ b/Source/JavaScriptCore/ChangeLog >@@ -1,3 +1,23 @@ >+2018-06-12 Tadeu Zagallo <tzagallo@apple.com> >+ >+ Share structure across instances of classes exported through the ObjC API >+ https://bugs.webkit.org/show_bug.cgi?id=186579 >+ <rdar://problem/40969212> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ A new prototype and structure were being created for each instance of >+ exported ObjC classes due to a bug in the caching logic + setting the >+ prototype in the structure for every object, since prototype transitions >+ are not cached by the structure. Cache the Structure in the JSObjcClassInfo >+ to avoid the transition. >+ >+ * API/JSWrapperMap.mm: >+ (-[JSObjCClassInfo wrapperForObject:inContext:]): >+ (-[JSObjCClassInfo constructorInContext:]): >+ (-[JSObjCClassInfo prototypeInContext:]): >+ (-[JSObjCClassInfo structureInContext:]): >+ > 2018-06-07 Chris Dumez <cdumez@apple.com> > > Add base class to get WeakPtrFactory member and avoid some boilerplate code >diff --git a/Source/JavaScriptCore/API/JSWrapperMap.mm b/Source/JavaScriptCore/API/JSWrapperMap.mm >index 4f5a13b8012a657ae219ae6042aa092e8f37c209..a604a0732286d6409332de25783ab0ba53026ceb 100644 >--- a/Source/JavaScriptCore/API/JSWrapperMap.mm >+++ b/Source/JavaScriptCore/API/JSWrapperMap.mm >@@ -367,6 +367,7 @@ @interface JSObjCClassInfo : NSObject { > JSClassRef m_classRef; > JSC::Weak<JSC::JSObject> m_prototype; > JSC::Weak<JSC::JSObject> m_constructor; >+ JSC::Weak<JSC::Structure> m_structure; > } > > - (instancetype)initForClass:(Class)cls; >@@ -517,31 +518,54 @@ - (JSC::JSObject*)wrapperForObject:(id)object inContext:(JSContext *)context > } > } > >- JSC::JSObject* prototype = [self prototypeInContext:context]; >+ auto structure = [self structureInContext:context]; > >- JSC::JSObject* wrapper = makeWrapper([context JSGlobalContextRef], m_classRef, object); >- JSObjectSetPrototype([context JSGlobalContextRef], toRef(wrapper), toRef(prototype)); >+ JSC::ExecState* exec = toJS([context JSGlobalContextRef]); >+ JSC::VM& vm = exec->vm(); >+ JSC::JSLockHolder locker(vm); >+ >+ auto wrapper = JSC::JSCallbackObject<JSC::JSAPIWrapperObject>::create(exec, exec->lexicalGlobalObject(), structure, m_classRef, 0); >+ wrapper->setWrappedObject(object); > return wrapper; > } > > - (JSC::JSObject*)constructorInContext:(JSContext *)context > { > JSC::JSObject* constructor = m_constructor.get(); >- if (!constructor) >- constructor = [self allocateConstructorAndPrototypeInContext:context].first; >- ASSERT(!!constructor); >- return constructor; >+ if (constructor) >+ return constructor; >+ >+ m_constructor = [self allocateConstructorAndPrototypeInContext:context].first; >+ ASSERT(!!m_constructor); >+ return m_constructor.get(); > } > > - (JSC::JSObject*)prototypeInContext:(JSContext *)context > { > JSC::JSObject* prototype = m_prototype.get(); >- if (!prototype) >- prototype = [self allocateConstructorAndPrototypeInContext:context].second; >- ASSERT(!!prototype); >- return prototype; >+ if (prototype) >+ return prototype; >+ >+ m_prototype = [self allocateConstructorAndPrototypeInContext:context].second; >+ ASSERT(!!m_prototype); >+ return m_prototype.get(); > } > >+- (JSC::Structure*)structureInContext:(JSContext *)context >+{ >+ auto structure = m_structure.get(); >+ if (structure) >+ return structure; >+ >+ JSC::ExecState* exec = toJS([context JSGlobalContextRef]); >+ auto globalObject = toJSGlobalObject([context JSGlobalContextRef]); >+ auto prototype = [self prototypeInContext:context]; >+ m_structure = JSC::JSCallbackObject<JSC::JSAPIWrapperObject>::createStructure(exec->vm(), globalObject, prototype); >+ >+ return m_structure.get(); >+} >+ >+ > @end > > @implementation JSWrapperMap {
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 186579
:
342610
|
342672
|
342730
|
342733
|
342773
|
342776
|
342807
|
342833
|
342850