<html>
<head>
<base href="https://bugs.webkit.org/" />
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - [Binding] Use unchekcedArgument if argumentCount is already checked"
href="https://bugs.webkit.org/show_bug.cgi?id=162502">162502</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>[Binding] Use unchekcedArgument if argumentCount is already checked
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr>
<tr>
<th>Product</th>
<td>WebKit
</td>
</tr>
<tr>
<th>Version</th>
<td>WebKit Nightly Build
</td>
</tr>
<tr>
<th>Hardware</th>
<td>Unspecified
</td>
</tr>
<tr>
<th>OS</th>
<td>Unspecified
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>Normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P2
</td>
</tr>
<tr>
<th>Component</th>
<td>Bindings
</td>
</tr>
<tr>
<th>Assignee</th>
<td>webkit-unassigned@lists.webkit.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>utatane.tea@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>cdumez@apple.com
</td>
</tr></table>
<p>
<div>
<pre>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.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are the assignee for the bug.</li>
</ul>
</body>
</html>