Bug 61544 - Overload resolution in generated JSC bindings could be more efficient.
Summary: Overload resolution in generated JSC bindings could be more efficient.
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore JavaScript (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Andreas Kling
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-05-26 11:00 PDT by Andreas Kling
Modified: 2011-05-26 12:25 PDT (History)
1 user (show)

See Also:


Attachments
Proposed patch (7.10 KB, patch)
2011-05-26 11:04 PDT, Andreas Kling
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Andreas Kling 2011-05-26 11:00:04 PDT
The overload resolution code generated by CodeGeneratorJS.pm currently looks like this:

EncodedJSValue JSC_HOST_CALL jsWebGLRenderingContextPrototypeFunctionBufferSubData(ExecState* exec)
{
    if ((exec->argumentCount() == 3 && (exec->argument(2).isNull() || (exec->argument(2).isObject() && asObject(exec->argument(2))->inherits(&JSArrayBuffer::s_info)))))
        return jsWebGLRenderingContextPrototypeFunctionBufferSubData1(exec);
    if ((exec->argumentCount() == 3 && (exec->argument(2).isNull() || (exec->argument(2).isObject() && asObject(exec->argument(2))->inherits(&JSArrayBufferView::s_info)))))
        return jsWebGLRenderingContextPrototypeFunctionBufferSubData2(exec);
    return throwVMTypeError(exec);
}

This could be a lot more efficient (no need for all those calls to argumentCount() and argument().)
Comment 1 Andreas Kling 2011-05-26 11:04:22 PDT
Created attachment 95006 [details]
Proposed patch
Comment 2 Andreas Kling 2011-05-26 11:05:29 PDT
For reference, same function after this patch:

EncodedJSValue JSC_HOST_CALL jsWebGLRenderingContextPrototypeFunctionBufferSubData(ExecState* exec)
{
    size_t argsCount = exec->argumentCount();
    JSValue arg2(exec->argument(2));
    if ((argsCount == 3 && (arg2.isNull() || (arg2.isObject() && asObject(arg2)->inherits(&JSArrayBuffer::s_info)))))
        return jsWebGLRenderingContextPrototypeFunctionBufferSubData1(exec);
    if ((argsCount == 3 && (arg2.isNull() || (arg2.isObject() && asObject(arg2)->inherits(&JSArrayBufferView::s_info)))))
        return jsWebGLRenderingContextPrototypeFunctionBufferSubData2(exec);
    return throwVMTypeError(exec);
}
Comment 3 Geoffrey Garen 2011-05-26 11:08:48 PDT
Comment on attachment 95006 [details]
Proposed patch

r=me
Comment 4 Andreas Kling 2011-05-26 12:25:13 PDT
Comment on attachment 95006 [details]
Proposed patch

Clearing flags on attachment: 95006

Committed r87412: <http://trac.webkit.org/changeset/87412>
Comment 5 Andreas Kling 2011-05-26 12:25:21 PDT
All reviewed patches have been landed.  Closing bug.