[JAEGER] Added JSOP_OBJTOSTR.
authorDavid Anderson <danderson@mozilla.com>
Sat, 05 Jun 2010 15:20:36 -0700
changeset 52717 5d4331d3edb69bc618522218d6d043c5c344a2cc
parent 52716 41651aabced9872c26dc3e1597a87550069868a9
child 52718 2ee44fdce7d232da7b694e141353cd8d66f15fd7
push idunknown
push userunknown
push dateunknown
milestone1.9.3a5pre
[JAEGER] Added JSOP_OBJTOSTR.
js/src/methodjit/Compiler.cpp
js/src/methodjit/Compiler.h
js/src/methodjit/StubCalls.cpp
js/src/methodjit/StubCalls.h
js/src/methodjit/nunbox/FastOps.cpp
--- a/js/src/methodjit/Compiler.cpp
+++ b/js/src/methodjit/Compiler.cpp
@@ -701,16 +701,20 @@ mjit::Compiler::generateMethod()
             frame.takeReg(Registers::ReturnReg);
             frame.pushTypedPayload(JSVAL_MASK32_NONFUNOBJ, Registers::ReturnReg);
           }
           END_CASE(JSOP_NEWARRAY)
 
           BEGIN_CASE(JSOP_TRACE)
           END_CASE(JSOP_TRACE)
 
+          BEGIN_CASE(JSOP_OBJTOSTR)
+            jsop_objtostr();
+          END_CASE(JSOP_OBJTOSTR)
+
           BEGIN_CASE(JSOP_GETGLOBAL)
             jsop_getglobal(GET_SLOTNO(PC));
           END_CASE(JSOP_GETGLOBAL)
 
           BEGIN_CASE(JSOP_SETGLOBAL)
             jsop_setglobal(GET_SLOTNO(PC));
           END_CASE(JSOP_SETGLOBAL)
 
--- a/js/src/methodjit/Compiler.h
+++ b/js/src/methodjit/Compiler.h
@@ -135,16 +135,17 @@ class Compiler
     void emitReturn();
     void dispatchCall(VoidPtrStubUInt32 stub);
 
     /* Fast opcodes. */
     void jsop_bitop(JSOp op);
     void jsop_globalinc(JSOp op, uint32 index);
     void jsop_relational(JSOp op, BoolStub stub, jsbytecode *target, JSOp fused);
     void jsop_neg();
+    void jsop_objtostr();
 
 #define STUB_CALL_TYPE(type)                                            \
     Call stubCall(type stub, Uses uses, Defs defs) {                    \
         return stubCall(JS_FUNC_TO_DATA_PTR(void *, stub), uses, defs); \
     }
 
     STUB_CALL_TYPE(JSObjStub);
     STUB_CALL_TYPE(VoidStubUInt32);
--- a/js/src/methodjit/StubCalls.cpp
+++ b/js/src/methodjit/StubCalls.cpp
@@ -1626,8 +1626,20 @@ stubs::Neg(VMFrame &f)
 {
     double d;
     if (!ValueToNumber(f.cx, f.regs.sp[-1], &d))
         THROW();
     d = -d;
     f.regs.sp[-1].setNumber(d);
 }
 
+void JS_FASTCALL
+stubs::ObjToStr(VMFrame &f)
+{
+    const Value &ref = f.regs.sp[-1];
+    if (ref.isObject()) {
+        JSString *str = js_ValueToString(f.cx, ref);
+        if (!str)
+            THROW();
+        f.regs.sp[-1].setString(str);
+    }
+}
+
--- a/js/src/methodjit/StubCalls.h
+++ b/js/src/methodjit/StubCalls.h
@@ -77,16 +77,17 @@ void JS_FASTCALL BitAnd(VMFrame &f);
 void JS_FASTCALL Lsh(VMFrame &f);
 void JS_FASTCALL Rsh(VMFrame &f);
 void JS_FASTCALL Add(VMFrame &f);
 void JS_FASTCALL Sub(VMFrame &f);
 void JS_FASTCALL Mul(VMFrame &f);
 void JS_FASTCALL Div(VMFrame &f);
 void JS_FASTCALL Mod(VMFrame &f);
 void JS_FASTCALL Neg(VMFrame &f);
+void JS_FASTCALL ObjToStr(VMFrame &f);
 
 JSBool JS_FASTCALL ValueToBoolean(VMFrame &f);
 
 }}} /* namespace stubs,mjit,js */
 
 extern "C" void *
 js_InternalThrow(js::VMFrame &f);
 
--- a/js/src/methodjit/nunbox/FastOps.cpp
+++ b/js/src/methodjit/nunbox/FastOps.cpp
@@ -488,8 +488,17 @@ void
 mjit::Compiler::jsop_neg()
 {
     prepareStubCall();
     stubCall(stubs::Neg, Uses(1), Defs(1));
     frame.pop();
     frame.pushSynced();
 }
 
+void
+mjit::Compiler::jsop_objtostr()
+{
+    prepareStubCall();
+    stubCall(stubs::ObjToStr, Uses(1), Defs(1));
+    frame.pop();
+    frame.pushSynced();
+}
+