Bug 810285 part 3 - More jit-test fixes. r=djvj
authorJan de Mooij <jdemooij@mozilla.com>
Mon, 12 Nov 2012 13:17:30 +0100
changeset 112743 973074c7d7ce48a154a2906ebd30b8c8efb43e04
parent 112742 1e550841ca78200a08235259b41009efb2453ec9
child 112744 ba510446fef6ffbf32bc2bca92e414c7f0b3f603
push id1351
push userjandemooij@gmail.com
push dateMon, 12 Nov 2012 12:18:00 +0000
reviewersdjvj
bugs810285
milestone19.0a1
Bug 810285 part 3 - More jit-test fixes. r=djvj
js/src/ion/BaselineCompiler.cpp
js/src/ion/BaselineCompiler.h
js/src/ion/BaselineJIT.cpp
js/src/ion/shared/Assembler-shared.h
js/src/ion/shared/CodeGenerator-shared.h
--- a/js/src/ion/BaselineCompiler.cpp
+++ b/js/src/ion/BaselineCompiler.cpp
@@ -14,17 +14,18 @@
 #include "IonSpewer.h"
 #include "VMFunctions.h"
 #include "IonFrames-inl.h"
 
 using namespace js;
 using namespace js::ion;
 
 BaselineCompiler::BaselineCompiler(JSContext *cx, JSScript *script)
-  : BaselineCompilerSpecific(cx, script)
+  : BaselineCompilerSpecific(cx, script),
+    return_(new HeapLabel())
 {
 }
 
 bool
 BaselineCompiler::init()
 {
     if (!labels_.init(script->length))
         return false;
@@ -127,17 +128,17 @@ BaselineCompiler::emitPrologue()
         masm.pushValue(R0);
 
     return true;
 }
 
 bool
 BaselineCompiler::emitEpilogue()
 {
-    masm.bind(&return_);
+    masm.bind(return_);
 
     masm.mov(BaselineFrameReg, BaselineStackReg);
     masm.pop(BaselineFrameReg);
 
     masm.ret();
     return true;
 }
 
@@ -420,16 +421,25 @@ BaselineCompiler::emitCompare()
     frame.push(R0);
     return true;
 }
 
 bool
 BaselineCompiler::emit_JSOP_GETLOCAL()
 {
     uint32_t local = GET_SLOTNO(pc);
+
+    if (local >= frame.nlocals()) {
+        // Destructuring assignments may use GETLOCAL to access stack values.
+        frame.syncStack(0);
+        masm.loadValue(Address(BaselineFrameReg, BaselineFrame::offsetOfLocal(local)), R0);
+        frame.push(R0);
+        return true;
+    }
+
     frame.pushLocal(local);
     return true;
 }
 
 bool
 BaselineCompiler::emit_JSOP_SETLOCAL()
 {
     // Ensure no other StackValue refers to the old value, for instance i + (i = 3).
@@ -467,17 +477,17 @@ BaselineCompiler::emit_JSOP_SETARG()
 }
 
 bool
 BaselineCompiler::emit_JSOP_RETURN()
 {
     JS_ASSERT(frame.stackDepth() == 1);
 
     frame.popValue(JSReturnOperand);
-    masm.jump(&return_);
+    masm.jump(return_);
     return true;
 }
 
 bool
 BaselineCompiler::emit_JSOP_STOP()
 {
     JS_ASSERT(frame.stackDepth() == 0);
 
--- a/js/src/ion/BaselineCompiler.h
+++ b/js/src/ion/BaselineCompiler.h
@@ -52,17 +52,17 @@ namespace ion {
     _(JSOP_GETARG)             \
     _(JSOP_SETARG)             \
     _(JSOP_RETURN)             \
     _(JSOP_STOP)
 
 class BaselineCompiler : public BaselineCompilerSpecific
 {
     FixedList<Label> labels_;
-    Label return_;
+    HeapLabel *return_;
 
     Label *labelOf(jsbytecode *pc) {
         return &labels_[pc - script->code];
     }
 
   public:
     BaselineCompiler(JSContext *cx, JSScript *script);
     bool init();
--- a/js/src/ion/BaselineJIT.cpp
+++ b/js/src/ion/BaselineJIT.cpp
@@ -178,16 +178,21 @@ BaselineCompile(JSContext *cx, HandleScr
         return Method_Error;
 
     return compiler.compile();
 }
 
 MethodStatus
 ion::CanEnterBaselineJIT(JSContext *cx, HandleScript script, StackFrame *fp)
 {
+    if (cx->compartment->debugMode()) {
+        IonSpew(IonSpew_Abort, "BASELINE FIXME: Not compiling in debug mode!");
+        return Method_CantCompile;
+    }
+
     if (!CheckFrame(fp))
         return Method_CantCompile;
 
     if (!cx->compartment->ensureIonCompartmentExists(cx))
         return Method_Error;
 
     MethodStatus status = BaselineCompile(cx, script, fp);
     if (status != Method_Compiled)
--- a/js/src/ion/shared/Assembler-shared.h
+++ b/js/src/ion/shared/Assembler-shared.h
@@ -230,16 +230,23 @@ class Label : public LabelBase
     ~Label()
     {
         // Note: the condition is a hack to avoid this assert when OOM testing,
         // see bug 756614.
         JS_ASSERT_IF(OOM_counter < OOM_maxAllocations, !used());
     }
 };
 
+// Wrapper around Label, on the heap, to avoid a bogus assert with OOM.
+struct HeapLabel
+  : public TempObject,
+    public Label
+{
+};
+
 class RepatchLabel
 {
     static const int32 INVALID_OFFSET = 0xC0000000;
     int32 offset_ : 31;
     uint32 bound_ : 1;
   public:
 
     RepatchLabel() : offset_(INVALID_OFFSET), bound_(0) {}
--- a/js/src/ion/shared/CodeGenerator-shared.h
+++ b/js/src/ion/shared/CodeGenerator-shared.h
@@ -286,23 +286,16 @@ class CodeGeneratorShared : public LInst
 
   public:
     template <class ArgSeq, class StoreOutputTo>
     bool visitOutOfLineCallVM(OutOfLineCallVM<ArgSeq, StoreOutputTo> *ool);
 
     bool visitOutOfLineTruncateSlow(OutOfLineTruncateSlow *ool);
 };
 
-// Wrapper around Label, on the heap, to avoid a bogus assert with OOM.
-struct HeapLabel
-  : public TempObject,
-    public Label
-{
-};
-
 // An out-of-line path is generated at the end of the function.
 class OutOfLineCode : public TempObject
 {
     Label entry_;
     Label rejoin_;
     uint32 framePushed_;
     jsbytecode *pc_;
     JSScript *script_;