Bug 122531 - ObjCCallbackFunctionImpl shouldn't store a JSContext
Summary: ObjCCallbackFunctionImpl shouldn't store a JSContext
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Mark Hahnenberg
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-10-08 16:25 PDT by Mark Hahnenberg
Modified: 2013-10-15 14:06 PDT (History)
4 users (show)

See Also:


Attachments
Patch (18.28 KB, patch)
2013-10-08 17:54 PDT, Mark Hahnenberg
no flags Details | Formatted Diff | Diff
Patch (18.49 KB, patch)
2013-10-14 18:45 PDT, Mark Hahnenberg
no flags Details | Formatted Diff | Diff
Patch (18.88 KB, patch)
2013-10-14 21:08 PDT, Mark Hahnenberg
no flags Details | Formatted Diff | Diff
Patch (19.87 KB, patch)
2013-10-15 11:30 PDT, Mark Hahnenberg
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Mark Hahnenberg 2013-10-08 16:25:38 PDT
The m_context field in ObjCCallbackFunctionImpl is vestigial and is only incidentally correct in the common case. It's also no longer necessary in that we can look up the current JSContext by looking using the globalObject of the callee when the function callback is invoked.
Comment 1 Mark Hahnenberg 2013-10-08 17:54:55 PDT
Created attachment 213737 [details]
Patch
Comment 2 Geoffrey Garen 2013-10-08 22:15:18 PDT
Comment on attachment 213737 [details]
Patch

r=me
Comment 3 Mark Rowe (bdash) 2013-10-09 02:23:20 PDT
Adding new API requires a) sending it through API review, and b) tagging the new API with the appropriate availability macro.
Comment 4 Mark Hahnenberg 2013-10-14 18:45:09 PDT
Created attachment 214218 [details]
Patch
Comment 5 Mark Hahnenberg 2013-10-14 18:46:27 PDT
(In reply to comment #4)
> Created an attachment (id=214218) [details]
> Patch

@bdash: Not sure what availability macro to use, so I just winged it. Your input would be valuable!
Comment 6 Mark Rowe (bdash) 2013-10-14 18:54:00 PDT
Comment on attachment 214218 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=214218&action=review

> Source/JavaScriptCore/API/JSContextRef.h:136
> +#if defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
> +/*!
> +@function
> +@abstract Gets the global context of a JavaScript execution context.
> +@param ctx The JSContext whose global context you want to get.
> +@result ctx's global context.
> +*/
> +JS_EXPORT JSGlobalContextRef JSContextGetGlobalContext(JSContextRef ctx);
> +#endif

This isn't how availability macros are used. You use something like NS_AVAILABLE_MAC(10_7) at the end of the method declaration:

 JS_EXPORT JSGlobalContextRef JSContextGetGlobalContext(JSContextRef ctx) NS_AVAILABLE_MAC(10_7);

There's a slightly different macro to use if this should be exposed on iOS as well.

If this header file is used by non-Mac platforms you may need to add some creative #ifing so that other platforms don't choke on the availability macros.
Comment 7 Mark Hahnenberg 2013-10-14 21:08:13 PDT
Created attachment 214230 [details]
Patch
Comment 8 Geoffrey Garen 2013-10-14 21:20:28 PDT
Comment on attachment 214230 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=214230&action=review

> Source/JavaScriptCore/API/JSContextRef.h:134
> +JS_EXPORT JSGlobalContextRef JSContextGetGlobalContext(JSContextRef ctx) CF_AVAILABLE(10_7, NA);

Does NA mean not available on iOS?

Should we be using AVAILABLE_IN_WEBKIT_VERSION*?
Comment 9 Mark Hahnenberg 2013-10-14 21:24:32 PDT
(In reply to comment #8)
> (From update of attachment 214230 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=214230&action=review
> 
> > Source/JavaScriptCore/API/JSContextRef.h:134
> > +JS_EXPORT JSGlobalContextRef JSContextGetGlobalContext(JSContextRef ctx) CF_AVAILABLE(10_7, NA);
> 
> Does NA mean not available on iOS?
NA does mean not available. I wasn't sure which version of iOS first had the symbol in the binary, but I figured I could go back and fill it in later.

> 
> Should we be using AVAILABLE_IN_WEBKIT_VERSION*?

I think the standard these days is to use OS versions rather than WebKit versions. I spoke with bdash, and he recommended using the OS-provided availability macros (see above). I ended up using the CF_* version rather than the NS_* version due to the fact that this header is typically included in C/C++ compilation units.
Comment 10 Build Bot 2013-10-14 21:37:04 PDT
Comment on attachment 214230 [details]
Patch

Attachment 214230 [details] did not pass mac-wk2-ews (mac-wk2):
Output: http://webkit-queues.appspot.com/results/4068010
Comment 11 Build Bot 2013-10-14 21:50:54 PDT
Comment on attachment 214230 [details]
Patch

Attachment 214230 [details] did not pass mac-ews (mac):
Output: http://webkit-queues.appspot.com/results/4070008
Comment 12 Mark Hahnenberg 2013-10-15 11:30:02 PDT
Created attachment 214285 [details]
Patch
Comment 13 Geoffrey Garen 2013-10-15 11:59:14 PDT
Comment on attachment 214285 [details]
Patch

r=me
Comment 14 WebKit Commit Bot 2013-10-15 14:06:33 PDT
Comment on attachment 214285 [details]
Patch

Clearing flags on attachment: 214285

Committed r157468: <http://trac.webkit.org/changeset/157468>
Comment 15 WebKit Commit Bot 2013-10-15 14:06:35 PDT
All reviewed patches have been landed.  Closing bug.