Bug 107163 - Objective-C API: Clean up JSValue.mm
Summary: Objective-C API: Clean up JSValue.mm
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-01-17 13:01 PST by Mark Hahnenberg
Modified: 2013-01-17 18:35 PST (History)
1 user (show)

See Also:


Attachments
Patch (22.42 KB, patch)
2013-01-17 13:14 PST, Mark Hahnenberg
no flags Details | Formatted Diff | Diff
Patch (24.42 KB, patch)
2013-01-17 13:29 PST, 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-01-17 13:01:31 PST
m_context is no longer weak, so there is now a lot of dead code in in JSValue.mm, and a wasted message send on every API call.  In the head of just about every method in JSValue.mm we're doing:
    JSContext *context = [self context];
    if (!context)
        return nil;
This is getting a retained copy of the context, which is no longer necessary now m_context is no longer weak.  We can just delete all these lines from all functions doing this, and where they were referring to the local variable 'context', instead we can just access m_context directly.
Comment 1 Mark Hahnenberg 2013-01-17 13:12:18 PST
<rdar://problem/13035927>
Comment 2 Mark Hahnenberg 2013-01-17 13:14:27 PST
Created attachment 183254 [details]
Patch
Comment 3 Mark Hahnenberg 2013-01-17 13:16:47 PST
Comment on attachment 183254 [details]
Patch

Need to make some modifications.
Comment 4 Mark Hahnenberg 2013-01-17 13:25:18 PST
Since we're already going to be modifying most of JSValue.mm, we'll also do the following:

(1) context @property is no longer weak – the context property is declared as:

    @property(readonly, weak) JSContext *context;

This is really only informative (since we're not presently synthesizing the ivar), but it is now misleading. We should change it to:

    @property(readonly, retain) JSContext *context;

(2) the JSContext ivar and accessor can be automatically generated.  Since we're no longer doing anything special with m_context, we can just let the compiler handle the ivar for us.  We'll delete:

    JSContext *m_context;

and:

    - (JSContext *)context
    {
        return m_context;

    }
and find&replace "m_context" to "_context" in JSValue.mm.
Comment 5 Mark Hahnenberg 2013-01-17 13:29:33 PST
Created attachment 183259 [details]
Patch
Comment 6 Filip Pizlo 2013-01-17 13:32:35 PST
Comment on attachment 183259 [details]
Patch

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

> Source/JavaScriptCore/ChangeLog:8
> +        m_context is no longer weak, so there is now a lot of dead code in in JSValue.mm, and a wasted message send 

in in
Comment 7 WebKit Review Bot 2013-01-17 18:35:11 PST
Comment on attachment 183259 [details]
Patch

Clearing flags on attachment: 183259

Committed r140086: <http://trac.webkit.org/changeset/140086>
Comment 8 WebKit Review Bot 2013-01-17 18:35:14 PST
All reviewed patches have been landed.  Closing bug.