diff --git a/js/src/jit/CodeGenerator.cpp b/js/src/jit/CodeGenerator.cpp index 52961b32f6e3..35018505741c 100644 --- a/js/src/jit/CodeGenerator.cpp +++ b/js/src/jit/CodeGenerator.cpp @@ -6087,7 +6087,7 @@ CodeGenerator::visitNewTypedArray(LNewTypedArray* lir) ool->entry(), /*initContents*/true, /*convertDoubleElements*/false); masm.initTypedArraySlots(objReg, tempReg, lengthReg, liveRegs, ool->entry(), - ttemplate, TypedArrayLength::Fixed); + ttemplate, MacroAssembler::TypedArrayLength::Fixed); masm.bind(ool->rejoin()); } @@ -6113,7 +6113,7 @@ CodeGenerator::visitNewTypedArrayDynamicLength(LNewTypedArrayDynamicLength* lir) ool->entry(), /*initContents*/true, /*convertDoubleElements*/false); masm.initTypedArraySlots(objReg, tempReg, lengthReg, liveRegs, ool->entry(), - ttemplate, TypedArrayLength::Dynamic); + ttemplate, MacroAssembler::TypedArrayLength::Dynamic); masm.bind(ool->rejoin()); } diff --git a/js/src/jit/MIR.cpp b/js/src/jit/MIR.cpp index 81d71159fe96..60f38e9c328b 100644 --- a/js/src/jit/MIR.cpp +++ b/js/src/jit/MIR.cpp @@ -6267,7 +6267,7 @@ PropertyReadNeedsTypeBarrier(CompilerConstraintList* constraints, } if (!name && IsTypedArrayClass(key->clasp())) { - Scalar::Type arrayType = Scalar::Type(key->clasp() - &TypedArrayObject::classes[0]); + Scalar::Type arrayType = GetTypedArrayClassType(key->clasp()); MIRType type = MIRTypeForTypedArrayRead(arrayType, true); if (observed->mightBeMIRType(type)) return BarrierKind::NoBarrier; diff --git a/js/src/jit/MacroAssembler.h b/js/src/jit/MacroAssembler.h index 87e27974ea37..9b309d71dbcd 100644 --- a/js/src/jit/MacroAssembler.h +++ b/js/src/jit/MacroAssembler.h @@ -2255,6 +2255,9 @@ class MacroAssembler : public MacroAssemblerSpecific void initGCThing(Register obj, Register temp, JSObject* templateObj, bool initContents = true, bool convertDoubleElements = false); + + enum class TypedArrayLength { Fixed, Dynamic }; + void initTypedArraySlots(Register obj, Register temp, Register lengthReg, LiveRegisterSet liveRegs, Label* fail, TypedArrayObject* templateObj, TypedArrayLength lengthKind); diff --git a/js/src/vm/ArrayBufferObject.h b/js/src/vm/ArrayBufferObject.h index 27960539e60a..a6bbd7a29bd1 100644 --- a/js/src/vm/ArrayBufferObject.h +++ b/js/src/vm/ArrayBufferObject.h @@ -16,8 +16,6 @@ #include "vm/SharedMem.h" #include "wasm/WasmTypes.h" -typedef struct JSProperty JSProperty; - namespace js { class ArrayBufferViewObject; diff --git a/js/src/vm/SharedArrayObject.h b/js/src/vm/SharedArrayObject.h index 2affe8f04759..5f9313b80a3a 100644 --- a/js/src/vm/SharedArrayObject.h +++ b/js/src/vm/SharedArrayObject.h @@ -16,8 +16,6 @@ #include "vm/ArrayBufferObject.h" #include "vm/JSObject.h" -typedef struct JSProperty JSProperty; - namespace js { class FutexWaiter; diff --git a/js/src/vm/TypeInference.cpp b/js/src/vm/TypeInference.cpp index d77cd9bd1336..3a6095f492eb 100644 --- a/js/src/vm/TypeInference.cpp +++ b/js/src/vm/TypeInference.cpp @@ -2340,7 +2340,7 @@ TemporaryTypeSet::getTypedArrayType(CompilerConstraintList* constraints, if (clasp && IsTypedArrayClass(clasp)) { if (sharedness) getTypedArraySharedness(constraints, sharedness); - return (Scalar::Type) (clasp - &TypedArrayObject::classes[0]); + return GetTypedArrayClassType(clasp); } return Scalar::MaxTypedArrayViewType; } diff --git a/js/src/vm/TypedArrayObject.cpp b/js/src/vm/TypedArrayObject.cpp index 649d51567154..9438ed9f1dbc 100644 --- a/js/src/vm/TypedArrayObject.cpp +++ b/js/src/vm/TypedArrayObject.cpp @@ -1405,37 +1405,12 @@ JS_FOR_EACH_TYPED_ARRAY(CHECK_TYPED_ARRAY_CONSTRUCTOR) return true; } -/* - * These next 3 functions are brought to you by the buggy GCC we use to build - * B2G ICS. Older GCC versions have a bug in which they fail to compile - * reinterpret_casts of templated functions with the message: "insufficient - * contextual information to determine type". JS_PSG needs to - * reinterpret_cast, so this causes problems for us here. - * - * We could restructure all this code to make this nicer, but since ICS isn't - * going to be around forever (and since this bug is fixed with the newer GCC - * versions we use on JB and KK), the workaround here is designed for ease of - * removal. When you stop seeing ICS Emulator builds on TBPL, remove these 3 - * JSNatives and insert the templated callee directly into the JS_PSG below. - */ static bool TypedArray_lengthGetter(JSContext* cx, unsigned argc, Value* vp) { return TypedArrayObject::Getter(cx, argc, vp); } -static bool -TypedArray_byteLengthGetter(JSContext* cx, unsigned argc, Value* vp) -{ - return TypedArrayObject::Getter(cx, argc, vp); -} - -static bool -TypedArray_byteOffsetGetter(JSContext* cx, unsigned argc, Value* vp) -{ - return TypedArrayObject::Getter(cx, argc, vp); -} - bool BufferGetterImpl(JSContext* cx, const CallArgs& args) { @@ -1458,8 +1433,8 @@ js::TypedArray_bufferGetter(JSContext* cx, unsigned argc, Value* vp) TypedArrayObject::protoAccessors[] = { JS_PSG("length", TypedArray_lengthGetter, 0), JS_PSG("buffer", TypedArray_bufferGetter, 0), - JS_PSG("byteLength", TypedArray_byteLengthGetter, 0), - JS_PSG("byteOffset", TypedArray_byteOffsetGetter, 0), + JS_PSG("byteLength", TypedArrayObject::Getter, 0), + JS_PSG("byteOffset", TypedArrayObject::Getter, 0), JS_SELF_HOSTED_SYM_GET(toStringTag, "TypedArrayToStringTag", 0), JS_PS_END }; diff --git a/js/src/vm/TypedArrayObject.h b/js/src/vm/TypedArrayObject.h index 4d9459020e7c..45110f550d16 100644 --- a/js/src/vm/TypedArrayObject.h +++ b/js/src/vm/TypedArrayObject.h @@ -26,12 +26,8 @@ macro(double, Float64) \ macro(uint8_clamped, Uint8Clamped) -typedef struct JSProperty JSProperty; - namespace js { -enum class TypedArrayLength { Fixed, Dynamic }; - /* * TypedArrayObject * @@ -314,6 +310,13 @@ IsTypedArrayClass(const Class* clasp) clasp < &TypedArrayObject::classes[Scalar::MaxTypedArrayViewType]; } +inline Scalar::Type +GetTypedArrayClassType(const Class* clasp) +{ + MOZ_ASSERT(IsTypedArrayClass(clasp)); + return static_cast(clasp - &TypedArrayObject::classes[0]); +} + bool IsTypedArrayConstructor(HandleValue v, uint32_t type); @@ -325,8 +328,7 @@ IsBufferSource(JSObject* object, SharedMem* dataPointer, size_t* byteL inline Scalar::Type TypedArrayObject::type() const { - MOZ_ASSERT(IsTypedArrayClass(getClass())); - return static_cast(getClass() - &classes[0]); + return GetTypedArrayClassType(getClass()); } inline size_t