diff --git a/js/src/jstypedarray.cpp b/js/src/jstypedarray.cpp index f4961b897982..e57e7e699377 100644 --- a/js/src/jstypedarray.cpp +++ b/js/src/jstypedarray.cpp @@ -70,7 +70,7 @@ using namespace js; * access. It can be created explicitly and passed to a TypedArray, or * can be created implicitly by constructing a TypedArray with a size. */ -inline ArrayBuffer * +ArrayBuffer * ArrayBuffer::fromJSObject(JSObject *obj) { JS_ASSERT(obj->getClass() == &ArrayBuffer::jsclass); @@ -187,7 +187,7 @@ ArrayBuffer::~ArrayBuffer() * the subclasses. */ -inline TypedArray * +TypedArray * TypedArray::fromJSObject(JSObject *obj) { return reinterpret_cast(obj->getPrivate()); @@ -1004,7 +1004,7 @@ TypedArrayTemplate::copyIndexToValue(JSContext *cx, uint32 index, jsval * JSClass ArrayBuffer::jsclass = { "ArrayBuffer", - JSCLASS_HAS_PRIVATE, + JSCLASS_HAS_PRIVATE | JSCLASS_HAS_CACHED_PROTO(JSProto_ArrayBuffer), JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, ArrayBuffer::class_finalize, JSCLASS_NO_OPTIONAL_MEMBERS @@ -1064,14 +1064,14 @@ template<> JSObjectOps _typedArray::fastObjectOps = { \ NULL \ }; \ template<> JSFunctionSpec _typedArray::jsfuncs[] = { \ - JS_FN("slice", _typedArray::fun_slice, 2, JSFUN_GENERIC_NATIVE), \ + JS_FN("slice", _typedArray::fun_slice, 2, 0), \ JS_FS_END \ } #define IMPL_TYPED_ARRAY_SLOW_CLASS(_typedArray) \ { \ #_typedArray, \ - JSCLASS_HAS_PRIVATE, \ + JSCLASS_HAS_PRIVATE | JSCLASS_HAS_CACHED_PROTO(JSProto_##_typedArray), \ JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, \ JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, JS_FinalizeStub, \ JSCLASS_NO_OPTIONAL_MEMBERS \ @@ -1129,9 +1129,16 @@ JSClass TypedArray::slowClasses[TYPE_MAX] = { IMPL_TYPED_ARRAY_SLOW_CLASS(Float32Array) }; -JSObject * +JS_FRIEND_API(JSObject *) js_InitTypedArrayClasses(JSContext *cx, JSObject *obj) { + /* Idempotency required: we initialize several things, possibly lazily. */ + JSObject *stop; + if (!js_GetClassObject(cx, obj, JSProto_ArrayBuffer, &stop)) + return NULL; + if (stop) + return stop; + JSObject *proto; INIT_TYPED_ARRAY_CLASS(Int8Array,TYPE_INT8); @@ -1148,8 +1155,7 @@ js_InitTypedArrayClasses(JSContext *cx, JSObject *obj) if (!proto) return NULL; - proto->setPrivate(0); - + proto->setPrivate(NULL); return proto; } diff --git a/js/src/jstypedarray.h b/js/src/jstypedarray.h index cdb0b1271dd3..fd46e279230f 100644 --- a/js/src/jstypedarray.h +++ b/js/src/jstypedarray.h @@ -159,7 +159,7 @@ struct JS_FRIEND_API(TypedArray) { JS_BEGIN_EXTERN_C -JSObject * +JS_FRIEND_API(JSObject *) js_InitTypedArrayClasses(JSContext *cx, JSObject *obj); JS_FRIEND_API(JSBool)