WebKit Bugzilla
Attachment 342730 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-20180614130411.patch (text/plain), 3.10 KB, created by
Tadeu Zagallo
on 2018-06-14 04:04:13 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Tadeu Zagallo
Created:
2018-06-14 04:04:13 PDT
Size:
3.10 KB
patch
obsolete
>Subversion Revision: 232634 >diff --git a/Source/JavaScriptCore/ChangeLog b/Source/JavaScriptCore/ChangeLog >index e89b57395009cc09d3fd8a8460af9319cfa14bf1..f7fbde644c1bde179d02e449239d3ec6c8e24103 100644 >--- a/Source/JavaScriptCore/ChangeLog >+++ b/Source/JavaScriptCore/ChangeLog >@@ -1,3 +1,21 @@ >+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 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..af086a1e85f5fb2613032736d47e4af1d9af1752 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,10 +518,14 @@ - (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; > } > >@@ -542,6 +547,20 @@ - (JSC::JSObject*)prototypeInContext:(JSContext *)context > return prototype; > } > >+- (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