[Webkit-unassigned] [Bug 162502] New: [Binding] Use unchekcedArgument if argumentCount is already checked

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Fri Sep 23 12:26:53 PDT 2016


https://bugs.webkit.org/show_bug.cgi?id=162502

            Bug ID: 162502
           Summary: [Binding] Use unchekcedArgument if argumentCount is
                    already checked
    Classification: Unclassified
           Product: WebKit
           Version: WebKit Nightly Build
          Hardware: Unspecified
                OS: Unspecified
            Status: NEW
          Severity: Normal
          Priority: P2
         Component: Bindings
          Assignee: webkit-unassigned at lists.webkit.org
          Reporter: utatane.tea at gmail.com
                CC: cdumez at apple.com

Looking the current binding code, we can find that argument(n) is used even after we checked the argument count and throw an error.

3794 EncodedJSValue JSC_HOST_CALL jsWebGLRenderingContextBasePrototypeFunctionUniform1f(ExecState* state)
3795 {
3796     VM& vm = state->vm();
3797     auto throwScope = DECLARE_THROW_SCOPE(vm);
3798     UNUSED_PARAM(throwScope);
3799     JSValue thisValue = state->thisValue();
3800     auto castedThis = jsDynamicCast<JSWebGLRenderingContextBase*>(thisValue);
3801     if (UNLIKELY(!castedThis))
3802         return throwThisTypeError(*state, throwScope, "WebGLRenderingContextBase", "uniform1f");
3803     ASSERT_GC_OBJECT_INHERITS(castedThis, JSWebGLRenderingContextBase::info());
3804     auto& impl = castedThis->wrapped();
3805     if (UNLIKELY(state->argumentCount() < 2))
3806         return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
3807     ExceptionCode ec = 0;
3808     WebGLUniformLocation* location = nullptr;
3809     if (!state->argument(0).isUndefinedOrNull()) {
3810         location = JSWebGLUniformLocation::toWrapped(state->uncheckedArgument(0));
3811         if (UNLIKELY(!location))
3812             return throwArgumentTypeError(*state, throwScope, 0, "location", "WebGLRenderingContextBase", "uniform1f", "WebGLUniformLocation");
3813     }
3814     auto x = convert<float>(*state, state->argument(1), ShouldAllowNonFinite::Yes);
3815     if (UNLIKELY(throwScope.exception()))
3816         return JSValue::encode(jsUndefined());
3817     impl.uniform1f(WTFMove(location), WTFMove(x), ec);
3818     setDOMException(state, ec);
3819     return JSValue::encode(jsUndefined());
3820 }

In L3805, we emit the guard against less arguments case.
So after this check, we should access to arguments by using `uncheckedArgument` instead of `argument`. However, L3809 and L3814 use argument().
It introduces unnecessary extra branches.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.webkit.org/pipermail/webkit-unassigned/attachments/20160923/21248259/attachment.html>


More information about the webkit-unassigned mailing list