Bug 61544

Summary: Overload resolution in generated JSC bindings could be more efficient.
Product: WebKit Reporter: Andreas Kling <kling>
Component: WebCore JavaScriptAssignee: Andreas Kling <kling>
Status: RESOLVED FIXED    
Severity: Normal CC: darin
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Proposed patch none

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.