From d956448ff76bdccb97717aeda08fdd6790d7a076 Mon Sep 17 00:00:00 2001 From: "mrbkap@gmail.com" Date: Thu, 19 Mar 2009 09:41:58 -0700 Subject: [PATCH] Bug 484151 - Initializing non-int elements calls the wrong imacro. Also call the right builtin when setting and initializing non-int properties (r=brendan). --- js/src/imacros.c.out | 11 +++++++++++ js/src/imacros.jsasm | 11 +++++++++++ js/src/jstracer.cpp | 4 +++- js/src/trace-test.js | 8 ++++++++ 4 files changed, 33 insertions(+), 1 deletion(-) diff --git a/js/src/imacros.c.out b/js/src/imacros.c.out index 03ff8675ff6..c5dbd564ac7 100644 --- a/js/src/imacros.c.out +++ b/js/src/imacros.c.out @@ -666,11 +666,22 @@ static struct { }, }; static struct { + jsbytecode initprop[15]; jsbytecode initelem[15]; } initelem_imacros = { { /* 0*/ JSOP_PICK, 2, /* 2*/ JSOP_DUP, +/* 3*/ JSOP_CALLBUILTIN, ((JSBUILTIN_SetProperty) & 0xff00) >> 8, ((JSBUILTIN_SetProperty) & 0xff), +/* 6*/ JSOP_PICK, 4, +/* 8*/ JSOP_PICK, 4, +/*10*/ JSOP_CALL, 0, 2, +/*13*/ JSOP_POP, +/*14*/ JSOP_STOP, + }, + { +/* 0*/ JSOP_PICK, 2, +/* 2*/ JSOP_DUP, /* 3*/ JSOP_CALLBUILTIN, ((JSBUILTIN_SetElement) & 0xff00) >> 8, ((JSBUILTIN_SetElement) & 0xff), /* 6*/ JSOP_PICK, 4, /* 8*/ JSOP_PICK, 4, diff --git a/js/src/imacros.jsasm b/js/src/imacros.jsasm index 5d98eb68451..a74b5643767 100644 --- a/js/src/imacros.jsasm +++ b/js/src/imacros.jsasm @@ -713,6 +713,17 @@ .igroup initelem JSOP_INITELEM + .imacro initprop # obj i val + pick 2 # i val obj + dup # i val obj obj + callbuiltin (JSBUILTIN_SetProperty) # i val obj fun obj + pick 4 # val obj fun obj i + pick 4 # obj fun obj i val + call 2 # obj junk + pop # obj + stop + .end + .imacro initelem # obj i val pick 2 # i val obj dup # i val obj obj diff --git a/js/src/jstracer.cpp b/js/src/jstracer.cpp index bd2f90353ad..22e8208ec2f 100644 --- a/js/src/jstracer.cpp +++ b/js/src/jstracer.cpp @@ -7297,7 +7297,9 @@ TraceRecorder::record_JSOP_SETELEM() if (!guardNotGlobalObject(obj, obj_ins)) return false; - return call_imacro(setelem_imacros.setprop); + return call_imacro((*cx->fp->regs->pc == JSOP_INITELEM) + ? initelem_imacros.initprop + : setelem_imacros.setprop); } if (JSVAL_TO_INT(idx) < 0 || !OBJ_IS_DENSE_ARRAY(cx, obj)) { diff --git a/js/src/trace-test.js b/js/src/trace-test.js index 7ebcbd7e3e6..61d40cd35b7 100644 --- a/js/src/trace-test.js +++ b/js/src/trace-test.js @@ -4647,6 +4647,14 @@ function testNEWINIT() testNEWINIT.expected = "[{}]"; test(testNEWINIT); +function testNEWINIT_DOUBLE() +{ + for (var z = 0; z < 2; ++z) { ({ 0.1: null })} + return "ok"; +} +testNEWINIT_DOUBLE.expected = "ok"; +test(testNEWINIT_DOUBLE); + /***************************************************************************** * * * _____ _ _ _____ ______ _____ _______ *