/[jscoverage]/trunk/js/jsarray.cpp
ViewVC logotype

Diff of /trunk/js/jsarray.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 584 by siliconforks, Sun Jan 10 07:23:34 2010 UTC revision 585 by siliconforks, Sun Sep 12 15:13:23 2010 UTC
# Line 736  Line 736 
736          *propp = NULL;          *propp = NULL;
737          return JS_TRUE;          return JS_TRUE;
738      }      }
739    
740        JSAutoTempValueRooter root(cx, proto);
741      return proto->lookupProperty(cx, id, objp, propp);      return proto->lookupProperty(cx, id, objp, propp);
742  }  }
743    
# Line 822  Line 824 
824      return JS_TRUE;      return JS_TRUE;
825  }  }
826    
 static void  
 slowarray_trace(JSTracer *trc, JSObject *obj)  
 {  
     uint32 length = obj->fslots[JSSLOT_ARRAY_LENGTH];  
   
     JS_ASSERT(STOBJ_GET_CLASS(obj) == &js_SlowArrayClass);  
   
     /*  
      * Move JSSLOT_ARRAY_LENGTH aside to prevent the GC from treating  
      * untagged integer values as objects or strings.  
      */  
     obj->fslots[JSSLOT_ARRAY_LENGTH] = JSVAL_VOID;  
     js_TraceObject(trc, obj);  
     obj->fslots[JSSLOT_ARRAY_LENGTH] = length;  
 }  
   
827  static JSObjectOps js_SlowArrayObjectOps;  static JSObjectOps js_SlowArrayObjectOps;
828    
829  static JSObjectOps *  static JSObjectOps *
# Line 1271  Line 1257 
1257    
1258  JSClass js_SlowArrayClass = {  JSClass js_SlowArrayClass = {
1259      "Array",      "Array",
1260      JSCLASS_HAS_RESERVED_SLOTS(1) |      JSCLASS_HAS_PRIVATE |
1261      JSCLASS_HAS_CACHED_PROTO(JSProto_Array),      JSCLASS_HAS_CACHED_PROTO(JSProto_Array),
1262      slowarray_addProperty, JS_PropertyStub, JS_PropertyStub,  JS_PropertyStub,      slowarray_addProperty, JS_PropertyStub, JS_PropertyStub,  JS_PropertyStub,
1263      JS_EnumerateStub,      JS_ResolveStub,  js_TryValueOf,    NULL,      JS_EnumerateStub,      JS_ResolveStub,  js_TryValueOf,    NULL,
# Line 1338  Line 1324 
1324       * a jsval, set our slow/sparse COUNT to the current length as a jsval, so       * a jsval, set our slow/sparse COUNT to the current length as a jsval, so
1325       * we can tell when only named properties have been added to a dense array       * we can tell when only named properties have been added to a dense array
1326       * to make it slow-but-not-sparse.       * to make it slow-but-not-sparse.
1327         *
1328         * We do not need to make the length slot GC-safe as this slot is private
1329         * where the implementation can store an arbitrary value.
1330       */       */
1331      {      {
1332          uint32 length = obj->fslots[JSSLOT_ARRAY_LENGTH];          JS_STATIC_ASSERT(JSSLOT_ARRAY_LENGTH == JSSLOT_PRIVATE);
1333            JS_ASSERT(js_SlowArrayClass.flags & JSCLASS_HAS_PRIVATE);
1334            uint32 length = uint32(obj->fslots[JSSLOT_ARRAY_LENGTH]);
1335          obj->fslots[JSSLOT_ARRAY_COUNT] = INT_FITS_IN_JSVAL(length)          obj->fslots[JSSLOT_ARRAY_COUNT] = INT_FITS_IN_JSVAL(length)
1336                                            ? INT_TO_JSVAL(length)                                            ? INT_TO_JSVAL(length)
1337                                            : JSVAL_VOID;                                            : JSVAL_VOID;
# Line 3450  Line 3441 
3441    
3442      /* Initialize the ops structure used by slow arrays */      /* Initialize the ops structure used by slow arrays */
3443      memcpy(&js_SlowArrayObjectOps, &js_ObjectOps, sizeof(JSObjectOps));      memcpy(&js_SlowArrayObjectOps, &js_ObjectOps, sizeof(JSObjectOps));
     js_SlowArrayObjectOps.trace = slowarray_trace;  
3444      js_SlowArrayObjectOps.enumerate = slowarray_enumerate;      js_SlowArrayObjectOps.enumerate = slowarray_enumerate;
3445      js_SlowArrayObjectOps.call = NULL;      js_SlowArrayObjectOps.call = NULL;
3446    
# Line 3537  Line 3527 
3527  js_CoerceArrayToCanvasImageData(JSObject *obj, jsuint offset, jsuint count,  js_CoerceArrayToCanvasImageData(JSObject *obj, jsuint offset, jsuint count,
3528                                  JSUint8 *dest)                                  JSUint8 *dest)
3529  {  {
3530      uint32 length;      uint32 length, capacity;
3531    
3532      if (!obj || !js_IsDenseArray(obj))      if (!obj || !js_IsDenseArray(obj))
3533          return JS_FALSE;          return JS_FALSE;
# Line 3546  Line 3536 
3536      if (length < offset + count)      if (length < offset + count)
3537          return JS_FALSE;          return JS_FALSE;
3538    
3539        capacity = js_DenseArrayCapacity(obj);
3540        if (capacity < offset + count)
3541            return JS_FALSE;
3542    
3543      JSUint8 *dp = dest;      JSUint8 *dp = dest;
3544      for (uintN i = offset; i < offset+count; i++) {      for (uintN i = offset; i < offset+count; i++) {
3545          jsval v = obj->dslots[i];          jsval v = obj->dslots[i];

Legend:
Removed from v.584  
changed lines
  Added in v.585

  ViewVC Help
Powered by ViewVC 1.1.24