Compile JSOP_DELPROP, JSOP_DELELEM (bug 578736, r=dmandelin).
authorDavid Anderson <danderson@mozilla.com>
Thu, 16 Sep 2010 12:13:25 -0700
changeset 54406 810968cf05996cb7dc571e352335f57151a275d9
parent 54405 e578b218b6717fb2e6af6944fcb91e74f01c68f5
child 54407 52a659928d229c5c4991d6c76445418bcaad3fd4
push idunknown
push userunknown
push dateunknown
reviewersdmandelin
bugs578736
milestone2.0b6pre
Compile JSOP_DELPROP, JSOP_DELELEM (bug 578736, r=dmandelin).
js/src/methodjit/Compiler.cpp
js/src/methodjit/StubCalls.cpp
js/src/methodjit/StubCalls.h
--- a/js/src/methodjit/Compiler.cpp
+++ b/js/src/methodjit/Compiler.cpp
@@ -880,16 +880,36 @@ mjit::Compiler::generateMethod()
             }
           }
           END_CASE(JSOP_NEG)
 
           BEGIN_CASE(JSOP_POS)
             jsop_pos();
           END_CASE(JSOP_POS)
 
+          BEGIN_CASE(JSOP_DELPROP)
+          {
+            uint32 index = fullAtomIndex(PC);
+            JSAtom *atom = script->getAtom(index);
+
+            prepareStubCall(Uses(1));
+            masm.move(ImmPtr(atom), Registers::ArgReg1);
+            stubCall(STRICT_VARIANT(stubs::DelProp));
+            frame.pop();
+            frame.pushSynced();
+          }
+          END_CASE(JSOP_DELPROP) 
+
+          BEGIN_CASE(JSOP_DELELEM)
+            prepareStubCall(Uses(2));
+            stubCall(STRICT_VARIANT(stubs::DelElem));
+            frame.popn(2);
+            frame.pushSynced();
+          END_CASE(JSOP_DELELEM)
+
           BEGIN_CASE(JSOP_TYPEOF)
           BEGIN_CASE(JSOP_TYPEOFEXPR)
             jsop_typeof();
           END_CASE(JSOP_TYPEOF)
 
           BEGIN_CASE(JSOP_VOID)
             frame.pop();
             frame.push(UndefinedValue());
--- a/js/src/methodjit/StubCalls.cpp
+++ b/js/src/methodjit/StubCalls.cpp
@@ -2660,8 +2660,49 @@ stubs::ArgSub(VMFrame &f, uint32 n)
 {
     jsid id = INT_TO_JSID(n);
     Value rval;
     if (!js_GetArgsProperty(f.cx, f.fp(), id, &rval))
         THROW();
     f.regs.sp[0] = rval;
 }
 
+template<JSBool strict>
+void JS_FASTCALL
+stubs::DelProp(VMFrame &f, JSAtom *atom)
+{
+    JSContext *cx = f.cx;
+
+    JSObject *obj = ValueToObject(cx, &f.regs.sp[-1]);
+    if (!obj)
+        THROW();
+
+    Value rval;
+    if (!obj->deleteProperty(cx, ATOM_TO_JSID(atom), &rval, strict))
+        THROW();
+
+    f.regs.sp[-1] = rval;
+}
+
+template void JS_FASTCALL stubs::DelProp<true>(VMFrame &f, JSAtom *atom);
+template void JS_FASTCALL stubs::DelProp<false>(VMFrame &f, JSAtom *atom);
+
+template<JSBool strict>
+void JS_FASTCALL
+stubs::DelElem(VMFrame &f)
+{
+    JSContext *cx = f.cx;
+
+    JSObject *obj = ValueToObject(cx, &f.regs.sp[-2]);
+    if (!obj)
+        THROW();
+
+    jsid id;
+    if (!FetchElementId(f, obj, f.regs.sp[-1], id, &f.regs.sp[-1]))
+        THROW();
+
+    if (!obj->deleteProperty(cx, id, &f.regs.sp[-2], strict))
+        THROW();
+}
+
+template void JS_FASTCALL stubs::DelElem<true>(VMFrame &f);
+template void JS_FASTCALL stubs::DelElem<false>(VMFrame &f);
+
--- a/js/src/methodjit/StubCalls.h
+++ b/js/src/methodjit/StubCalls.h
@@ -140,16 +140,18 @@ template<JSBool strict> void JS_FASTCALL
 template<JSBool strict> void JS_FASTCALL PropDec(VMFrame &f, JSAtom *atom);
 template<JSBool strict> void JS_FASTCALL IncProp(VMFrame &f, JSAtom *atom);
 template<JSBool strict> void JS_FASTCALL DecProp(VMFrame &f, JSAtom *atom);
 template<JSBool strict> void JS_FASTCALL ElemInc(VMFrame &f);
 template<JSBool strict> void JS_FASTCALL ElemDec(VMFrame &f);
 template<JSBool strict> void JS_FASTCALL IncElem(VMFrame &f);
 template<JSBool strict> void JS_FASTCALL DecElem(VMFrame &f);
 void JS_FASTCALL CallProp(VMFrame &f, JSAtom *atom);
+template <JSBool strict> void JS_FASTCALL DelProp(VMFrame &f, JSAtom *atom);
+template <JSBool strict> void JS_FASTCALL DelElem(VMFrame &f);
 
 template<JSBool strict> void JS_FASTCALL DefFun(VMFrame &f, JSFunction *fun);
 JSObject * JS_FASTCALL DefLocalFun(VMFrame &f, JSFunction *fun);
 JSObject * JS_FASTCALL DefLocalFun_FC(VMFrame &f, JSFunction *fun);
 JSObject * JS_FASTCALL RegExp(VMFrame &f, JSObject *regex);
 JSObject * JS_FASTCALL Lambda(VMFrame &f, JSFunction *fun);
 JSObject * JS_FASTCALL LambdaForInit(VMFrame &f, JSFunction *fun);
 JSObject * JS_FASTCALL LambdaForSet(VMFrame &f, JSFunction *fun);