Added boolean boxing/unboxing code.
authorAndreas Gal <gal@mozilla.com>
Sat, 05 Jul 2008 18:34:41 -0700
changeset 17439 0523b54c86d82a7aa4dc531290557630c07a4c70
parent 17438 e3af49ee7476edbcc11fab2097190f52c66933e9
child 17440 04f3c8fdf238f14566efd1fa27c716d3e486c4d8
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone1.9.1a1pre
Added boolean boxing/unboxing code.
js/src/jstracer.cpp
js/src/jstracer.h
--- a/js/src/jstracer.cpp
+++ b/js/src/jstracer.cpp
@@ -881,16 +881,22 @@ TraceRecorder::double_to_jsval(LIns* d_i
 {
     LIns* args[] = { cx_ins, d_ins };
     LIns* ret = lir->insCall(F_BoxDouble, args);
     guard(false, lir->ins2(LIR_eq, ret, lir->insImmPtr((void*)JSVAL_ERROR_COOKIE)));
     return ret;
 }
 
 LIns*
+TraceRecorder::boolean_to_jsval(LIns* b_ins)
+{
+    return lir->ins2i(LIR_or, lir->ins2i(LIR_lsh, b_ins, JSVAL_TAGBITS), JSVAL_BOOLEAN);
+}
+
+LIns*
 TraceRecorder::jsval_to_int32(LIns* v_ins)
 {
     LIns* ret = lir->insCall(F_UnboxInt32, &v_ins);
     guard(false, lir->ins2i(LIR_eq, ret, INT32_ERROR_COOKIE));
     return ret;
 }    
 
 LIns*
@@ -898,27 +904,22 @@ TraceRecorder::jsval_to_double(LIns* v_i
 {
     guard(true, lir->ins2i(LIR_eq,
             lir->ins2(LIR_and, v_ins, lir->insImmPtr((void*)JSVAL_TAGMASK)),
             JSVAL_DOUBLE));
     return lir->insLoadi(lir->ins2(LIR_and, v_ins, lir->insImmPtr((void*)~JSVAL_TAGMASK)), 0);
 }    
 
 LIns*
-TraceRecorder::jsval_to_object(LIns* v_ins)
+TraceRecorder::jsval_to_boolean(LIns* v_ins)
 {
-    LIns* isObj = lir->ins2i(LIR_eq,
-            lir->ins2(LIR_and, v_ins, lir->insImmPtr((void*)JSVAL_TAGMASK)),
-            JSVAL_OBJECT);
-    LIns* isNull = lir->ins_eq0(
-            v_ins);
-    return lir->ins2(LIR_or, isObj, isNull);
+    guard(true, lir->ins2i(LIR_eq, lir->ins2i(LIR_not, v_ins, 8), 6));
+    return lir->ins2i(LIR_ush, v_ins, JSVAL_TAGBITS); 
 }
 
-
 bool TraceRecorder::guardThatObjectIsDenseArray(JSObject* obj, LIns* obj_ins, LIns*& dslots_ins)
 {
     if (!OBJ_IS_DENSE_ARRAY(cx, obj))
         return false;
     // guard(OBJ_GET_CLASS(obj) == &js_ArrayClass);
     LIns* class_ins;
     stobj_get_slot(obj_ins, JSSLOT_CLASS, dslots_ins, class_ins);
     class_ins = lir->ins2(LIR_and, class_ins, lir->insImmPtr((void*)~3));
--- a/js/src/jstracer.h
+++ b/js/src/jstracer.h
@@ -159,20 +159,21 @@ class TraceRecorder {
     bool native_set(nanojit::LIns* obj_ins, JSScopeProperty* sprop, 
             nanojit::LIns*& dslots_ins, nanojit::LIns* v_ins);
     bool native_get(nanojit::LIns* obj_ins, nanojit::LIns* pobj_ins, JSScopeProperty* sprop, 
             nanojit::LIns*& dslots_ins, nanojit::LIns*& v_ins);
     bool box_into_jsval(jsval& v, nanojit::LIns* cx_ins, nanojit::LIns* in_ins, 
             nanojit::LIns*& out_ins);
     nanojit::LIns* int32_to_jsval(nanojit::LIns* i_ins);
     nanojit::LIns* double_to_jsval(nanojit::LIns* d_ins);
+    nanojit::LIns* boolean_to_jsval(nanojit::LIns* b_ins);
     nanojit::LIns* jsval_to_int32(nanojit::LIns* v_ins);
     nanojit::LIns* jsval_to_double(nanojit::LIns* v_ins);
-    nanojit::LIns* jsval_to_object(nanojit::LIns* v_ins);
-
+    nanojit::LIns* jsval_to_boolean(nanojit::LIns* v_ins);
+    
     bool guardThatObjectIsDenseArray(JSObject* obj, 
             nanojit::LIns* obj_ins, nanojit::LIns*& dslots_ins);
     bool guardDenseArrayIndexWithinBounds(JSObject* obj, jsint idx, 
             nanojit::LIns* obj_ins, nanojit::LIns*& dslots_ins, nanojit::LIns* idx_ins);
 public:
     TraceRecorder(JSContext* cx, nanojit::Fragmento*, nanojit::Fragment*);
     ~TraceRecorder();