mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 737575 - fix arguments['integer'] (r=dvander)
--HG-- extra : rebase_source : 5cb580a47187f2a88a98efc3fa8a88ee4c8bc551
This commit is contained in:
parent
32a0f7bc5f
commit
7b7d34d1b2
6
js/src/jit-test/tests/basic/testBug737575.js
Normal file
6
js/src/jit-test/tests/basic/testBug737575.js
Normal file
@ -0,0 +1,6 @@
|
||||
function f(s) {
|
||||
return arguments[s];
|
||||
}
|
||||
|
||||
for (var i = 0; i < 10; ++i)
|
||||
assertEq(f(String(i+1), 0,1,2,3,4,5,6,7,8,9), i);
|
@ -295,17 +295,29 @@ NormalArgumentsObject::optimizedGetElem(JSContext *cx, StackFrame *fp, const Val
|
||||
{
|
||||
JS_ASSERT(!fp->hasArgsObj());
|
||||
|
||||
/* Fast path: no need to convert to id when elem is already an int in range. */
|
||||
if (elem.isInt32()) {
|
||||
int32_t i = elem.toInt32();
|
||||
if (i >= 0 && uint32_t(i) < fp->numActualArgs()) {
|
||||
*vp = fp->canonicalActualArg(elem.toInt32());
|
||||
*vp = fp->canonicalActualArg(i);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/* Slow path: create and canonicalize an id, then emulate args_resolve. */
|
||||
|
||||
jsid id;
|
||||
if (!ValueToId(cx, elem, &id))
|
||||
return false;
|
||||
id = js_CheckForStringIndex(id);
|
||||
|
||||
if (JSID_IS_INT(id)) {
|
||||
int32_t i = JSID_TO_INT(id);
|
||||
if (i >= 0 && uint32_t(i) < fp->numActualArgs()) {
|
||||
*vp = fp->canonicalActualArg(i);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (id == ATOM_TO_JSID(cx->runtime->atomState.lengthAtom)) {
|
||||
*vp = Int32Value(fp->numActualArgs());
|
||||
|
Loading…
Reference in New Issue
Block a user