From c2b5f396eb4ed1bd9be5a6625bd823d7a3e63678 Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Thu, 23 May 2019 02:48:13 +0000 Subject: Remove UnboxedArray code part 1 --- js/src/builtin/ModuleObject.cpp | 2 +- js/src/jit/AliasAnalysisShared.cpp | 4 - js/src/jit/BaselineCacheIR.cpp | 16 -- js/src/jit/BaselineIC.cpp | 146 +-------------- js/src/jit/CacheIR.cpp | 9 +- js/src/jit/CacheIR.h | 5 - js/src/jit/CodeGenerator.cpp | 341 ++++++++---------------------------- js/src/jit/CodeGenerator.h | 4 - js/src/jit/IonBuilder.cpp | 199 +++++++-------------- js/src/jit/IonBuilder.h | 12 +- js/src/jit/IonCaches.cpp | 135 ++------------ js/src/jit/Lowering.cpp | 30 ---- js/src/jit/Lowering.h | 4 - js/src/jit/MCallOptimize.cpp | 71 ++------ js/src/jit/MIR.cpp | 45 ----- js/src/jit/MIR.h | 176 ++----------------- js/src/jit/MOpcodes.h | 4 - js/src/jit/MacroAssembler.cpp | 35 ---- js/src/jit/MacroAssembler.h | 5 +- js/src/jit/ScalarReplacement.cpp | 5 - js/src/jit/SharedIC.cpp | 9 - js/src/jit/VMFunctions.cpp | 12 +- js/src/jit/shared/LIR-shared.h | 66 ------- js/src/jit/shared/LOpcodes-shared.h | 4 - js/src/jsarray.cpp | 141 ++++++--------- js/src/jsfriendapi.cpp | 2 +- 26 files changed, 251 insertions(+), 1231 deletions(-) diff --git a/js/src/builtin/ModuleObject.cpp b/js/src/builtin/ModuleObject.cpp index 710c7a76c..c6bd2d300 100644 --- a/js/src/builtin/ModuleObject.cpp +++ b/js/src/builtin/ModuleObject.cpp @@ -947,7 +947,7 @@ ModuleObject::evaluate(JSContext* cx, HandleModuleObject self, MutableHandleValu ModuleObject::createNamespace(JSContext* cx, HandleModuleObject self, HandleObject exports) { MOZ_ASSERT(!self->namespace_()); - MOZ_ASSERT(exports->is() || exports->is()); + MOZ_ASSERT(exports->is()); RootedModuleNamespaceObject ns(cx, ModuleNamespaceObject::create(cx, self)); if (!ns) diff --git a/js/src/jit/AliasAnalysisShared.cpp b/js/src/jit/AliasAnalysisShared.cpp index 3b83df74e..0f0d4a66a 100644 --- a/js/src/jit/AliasAnalysisShared.cpp +++ b/js/src/jit/AliasAnalysisShared.cpp @@ -93,10 +93,6 @@ GetObject(const MDefinition* ins) case MDefinition::Op_Elements: case MDefinition::Op_MaybeCopyElementsForWrite: case MDefinition::Op_MaybeToDoubleElement: - case MDefinition::Op_UnboxedArrayLength: - case MDefinition::Op_UnboxedArrayInitializedLength: - case MDefinition::Op_IncrementUnboxedArrayInitializedLength: - case MDefinition::Op_SetUnboxedArrayInitializedLength: case MDefinition::Op_TypedArrayLength: case MDefinition::Op_SetTypedObjectOffset: case MDefinition::Op_SetDisjointTypedElements: diff --git a/js/src/jit/BaselineCacheIR.cpp b/js/src/jit/BaselineCacheIR.cpp index bf96932d1..7fb586811 100644 --- a/js/src/jit/BaselineCacheIR.cpp +++ b/js/src/jit/BaselineCacheIR.cpp @@ -787,9 +787,6 @@ BaselineCacheIRCompiler::emitGuardClass() case GuardClassKind::Array: clasp = &ArrayObject::class_; break; - case GuardClassKind::UnboxedArray: - clasp = &UnboxedArrayObject::class_; - break; case GuardClassKind::MappedArguments: clasp = &MappedArgumentsObject::class_; break; @@ -1003,19 +1000,6 @@ BaselineCacheIRCompiler::emitLoadInt32ArrayLengthResult() return true; } -bool -BaselineCacheIRCompiler::emitLoadUnboxedArrayLengthResult() -{ - Register obj = allocator.useRegister(masm, reader.objOperandId()); - masm.load32(Address(obj, UnboxedArrayObject::offsetOfLength()), R0.scratchReg()); - masm.tagValue(JSVAL_TYPE_INT32, R0.scratchReg(), R0); - - // The int32 type was monitored when attaching the stub, so we can - // just return. - emitReturnFromIC(); - return true; -} - bool BaselineCacheIRCompiler::emitLoadArgumentsObjectLengthResult() { diff --git a/js/src/jit/BaselineIC.cpp b/js/src/jit/BaselineIC.cpp index 863c61161..f43fc5bf9 100644 --- a/js/src/jit/BaselineIC.cpp +++ b/js/src/jit/BaselineIC.cpp @@ -280,12 +280,6 @@ DoTypeUpdateFallback(JSContext* cx, BaselineFrame* frame, ICUpdatedStub* stub, H RootedId id(cx); switch(stub->kind()) { - case ICStub::SetElem_DenseOrUnboxedArray: - case ICStub::SetElem_DenseOrUnboxedArrayAdd: { - id = JSID_VOID; - AddTypePropertyId(cx, obj, id, value); - break; - } case ICStub::SetProp_Native: case ICStub::SetProp_NativeAdd: case ICStub::SetProp_Unboxed: { @@ -1366,7 +1360,7 @@ IsNativeDenseElementAccess(HandleObject obj, HandleValue key) static bool IsNativeOrUnboxedDenseElementAccess(HandleObject obj, HandleValue key) { - if (!obj->isNative() && !obj->is()) + if (!obj->isNative()) return false; if (key.isInt32() && key.toInt32() >= 0 && !obj->is()) return true; @@ -1470,20 +1464,6 @@ TryAttachGetElemStub(JSContext* cx, JSScript* script, jsbytecode* pc, ICGetElem_ script = rootedScript; } - // Check for UnboxedArray[int] accesses. - if (obj->is() && rhs.isInt32() && rhs.toInt32() >= 0) { - JitSpew(JitSpew_BaselineIC, " Generating GetElem(UnboxedArray[Int32]) stub"); - ICGetElem_UnboxedArray::Compiler compiler(cx, stub->fallbackMonitorStub()->firstMonitorStub(), - obj->group()); - ICStub* unboxedStub = compiler.getStub(compiler.getStubSpace(script)); - if (!unboxedStub) - return false; - - stub->addNewStub(unboxedStub); - *attached = true; - return true; - } - // Check for TypedArray[int] => Number and TypedObject[int] => Number accesses. if ((obj->is() || IsPrimitiveArrayTypedObject(obj)) && rhs.isNumber() && @@ -2089,56 +2069,6 @@ ICGetElem_Dense::Compiler::generateStubCode(MacroAssembler& masm) return true; } -// -// GetElem_UnboxedArray -// - -bool -ICGetElem_UnboxedArray::Compiler::generateStubCode(MacroAssembler& masm) -{ - MOZ_ASSERT(engine_ == Engine::Baseline); - - Label failure; - masm.branchTestObject(Assembler::NotEqual, R0, &failure); - masm.branchTestInt32(Assembler::NotEqual, R1, &failure); - - AllocatableGeneralRegisterSet regs(availableGeneralRegs(2)); - Register scratchReg = regs.takeAny(); - - // Unbox R0 and group guard. - Register obj = masm.extractObject(R0, ExtractTemp0); - masm.loadPtr(Address(ICStubReg, ICGetElem_UnboxedArray::offsetOfGroup()), scratchReg); - masm.branchTestObjGroup(Assembler::NotEqual, obj, scratchReg, &failure); - - // Unbox key. - Register key = masm.extractInt32(R1, ExtractTemp1); - - // Bounds check. - masm.load32(Address(obj, UnboxedArrayObject::offsetOfCapacityIndexAndInitializedLength()), - scratchReg); - masm.and32(Imm32(UnboxedArrayObject::InitializedLengthMask), scratchReg); - masm.branch32(Assembler::BelowOrEqual, scratchReg, key, &failure); - - // Load obj->elements. - masm.loadPtr(Address(obj, UnboxedArrayObject::offsetOfElements()), scratchReg); - - // Load value. - size_t width = UnboxedTypeSize(elementType_); - BaseIndex addr(scratchReg, key, ScaleFromElemWidth(width)); - masm.loadUnboxedProperty(addr, elementType_, R0); - - // Only monitor the result if its type might change. - if (elementType_ == JSVAL_TYPE_OBJECT) - EmitEnterTypeMonitorIC(masm); - else - EmitReturnFromIC(masm); - - // Failure case - jump to next stub - masm.bind(&failure); - EmitStubGuardFailure(masm); - return true; -} - // // GetElem_TypedArray // @@ -2447,10 +2377,6 @@ CanOptimizeDenseOrUnboxedArraySetElem(JSObject* obj, uint32_t index, if (initLength < oldInitLength || capacity < oldCapacity) return false; - // Unboxed arrays need to be able to emit floating point code. - if (obj->is() && !obj->runtimeFromMainThread()->jitSupportsFloatingPoint) - return false; - Shape* shape = obj->maybeShape(); // Cannot optimize if the shape changed. @@ -2871,29 +2797,6 @@ ICSetElem_DenseOrUnboxedArray::Compiler::generateStubCode(MacroAssembler& masm) masm.loadValue(valueAddr, tmpVal); EmitPreBarrier(masm, element, MIRType::Value); masm.storeValue(tmpVal, element); - } else { - // Set element on an unboxed array. - - // Bounds check. - Address initLength(obj, UnboxedArrayObject::offsetOfCapacityIndexAndInitializedLength()); - masm.load32(initLength, scratchReg); - masm.and32(Imm32(UnboxedArrayObject::InitializedLengthMask), scratchReg); - masm.branch32(Assembler::BelowOrEqual, scratchReg, key, &failure); - - // Load obj->elements. - masm.loadPtr(Address(obj, UnboxedArrayObject::offsetOfElements()), scratchReg); - - // Compute the address being written to. - BaseIndex address(scratchReg, key, ScaleFromElemWidth(UnboxedTypeSize(unboxedType_))); - - EmitUnboxedPreBarrierForBaseline(masm, address, unboxedType_); - - Address valueAddr(masm.getStackPointer(), ICStackValueOffset + sizeof(Value)); - masm.Push(R0); - masm.loadValue(valueAddr, R0); - masm.storeUnboxedProperty(address, unboxedType_, - ConstantOrRegister(TypedOrValueRegister(R0)), &failurePopR0); - masm.Pop(R0); } EmitReturnFromIC(masm); @@ -3087,40 +2990,6 @@ ICSetElemDenseOrUnboxedArrayAddCompiler::generateStubCode(MacroAssembler& masm) BaseIndex element(scratchReg, key, TimesEight); masm.loadValue(valueAddr, tmpVal); masm.storeValue(tmpVal, element); - } else { - // Adding element to an unboxed array. - - // Bounds check (key == initLength) - Address initLengthAddr(obj, UnboxedArrayObject::offsetOfCapacityIndexAndInitializedLength()); - masm.load32(initLengthAddr, scratchReg); - masm.and32(Imm32(UnboxedArrayObject::InitializedLengthMask), scratchReg); - masm.branch32(Assembler::NotEqual, scratchReg, key, &failure); - - // Capacity check. - masm.checkUnboxedArrayCapacity(obj, RegisterOrInt32Constant(key), scratchReg, &failure); - - // Load obj->elements. - masm.loadPtr(Address(obj, UnboxedArrayObject::offsetOfElements()), scratchReg); - - // Write the value first, since this can fail. No need for pre-barrier - // since we're not overwriting an old value. - masm.Push(R0); - Address valueAddr(masm.getStackPointer(), ICStackValueOffset + sizeof(Value)); - masm.loadValue(valueAddr, R0); - BaseIndex address(scratchReg, key, ScaleFromElemWidth(UnboxedTypeSize(unboxedType_))); - masm.storeUnboxedProperty(address, unboxedType_, - ConstantOrRegister(TypedOrValueRegister(R0)), &failurePopR0); - masm.Pop(R0); - - // Increment initialized length. - masm.add32(Imm32(1), initLengthAddr); - - // If length is now <= key, increment length. - Address lengthAddr(obj, UnboxedArrayObject::offsetOfLength()); - Label skipIncrementLength; - masm.branch32(Assembler::Above, lengthAddr, key, &skipIncrementLength); - masm.add32(Imm32(1), lengthAddr); - masm.bind(&skipIncrementLength); } EmitReturnFromIC(masm); @@ -8301,19 +8170,6 @@ ICGetElem_Dense::Clone(JSContext* cx, ICStubSpace* space, ICStub* firstMonitorSt return New(cx, space, other.jitCode(), firstMonitorStub, other.shape_); } -ICGetElem_UnboxedArray::ICGetElem_UnboxedArray(JitCode* stubCode, ICStub* firstMonitorStub, - ObjectGroup *group) - : ICMonitoredStub(GetElem_UnboxedArray, stubCode, firstMonitorStub), - group_(group) -{ } - -/* static */ ICGetElem_UnboxedArray* -ICGetElem_UnboxedArray::Clone(JSContext* cx, ICStubSpace* space, ICStub* firstMonitorStub, - ICGetElem_UnboxedArray& other) -{ - return New(cx, space, other.jitCode(), firstMonitorStub, other.group_); -} - ICGetElem_TypedArray::ICGetElem_TypedArray(JitCode* stubCode, Shape* shape, Scalar::Type type) : ICStub(GetElem_TypedArray, stubCode), shape_(shape) diff --git a/js/src/jit/CacheIR.cpp b/js/src/jit/CacheIR.cpp index f1061af70..6822a70af 100644 --- a/js/src/jit/CacheIR.cpp +++ b/js/src/jit/CacheIR.cpp @@ -175,7 +175,7 @@ TestMatchingReceiver(CacheIRWriter& writer, JSObject* obj, Shape* shape, ObjOper } else { writer.guardNoUnboxedExpando(objId); } - } else if (obj->is() || obj->is()) { + } else if (obj->is()) { writer.guardGroup(objId, obj->group()); } else { Shape* shape = obj->maybeShape(); @@ -368,13 +368,6 @@ GetPropIRGenerator::tryAttachObjectLength(CacheIRWriter& writer, HandleObject ob return true; } - if (obj->is()) { - writer.guardClass(objId, GuardClassKind::UnboxedArray); - writer.loadUnboxedArrayLengthResult(objId); - emitted_ = true; - return true; - } - if (obj->is() && !obj->as().hasOverriddenLength()) { if (obj->is()) { writer.guardClass(objId, GuardClassKind::MappedArguments); diff --git a/js/src/jit/CacheIR.h b/js/src/jit/CacheIR.h index 51e55f48b..4fd8575f0 100644 --- a/js/src/jit/CacheIR.h +++ b/js/src/jit/CacheIR.h @@ -96,7 +96,6 @@ class ObjOperandId : public OperandId _(LoadUnboxedPropertyResult) \ _(LoadTypedObjectResult) \ _(LoadInt32ArrayLengthResult) \ - _(LoadUnboxedArrayLengthResult) \ _(LoadArgumentsObjectLengthResult) \ _(LoadUndefinedResult) @@ -128,7 +127,6 @@ struct StubField { enum class GuardClassKind { Array, - UnboxedArray, MappedArguments, UnmappedArguments, }; @@ -327,9 +325,6 @@ class MOZ_RAII CacheIRWriter void loadInt32ArrayLengthResult(ObjOperandId obj) { writeOpWithOperandId(CacheOp::LoadInt32ArrayLengthResult, obj); } - void loadUnboxedArrayLengthResult(ObjOperandId obj) { - writeOpWithOperandId(CacheOp::LoadUnboxedArrayLengthResult, obj); - } void loadArgumentsObjectLengthResult(ObjOperandId obj) { writeOpWithOperandId(CacheOp::LoadArgumentsObjectLengthResult, obj); } diff --git a/js/src/jit/CodeGenerator.cpp b/js/src/jit/CodeGenerator.cpp index 6d1fb6b9b..bd275a2c1 100644 --- a/js/src/jit/CodeGenerator.cpp +++ b/js/src/jit/CodeGenerator.cpp @@ -3183,9 +3183,7 @@ CodeGenerator::visitSetPropertyPolymorphicT(LSetPropertyPolymorphicT* ins) void CodeGenerator::visitElements(LElements* lir) { - Address elements(ToRegister(lir->object()), - lir->mir()->unboxed() ? UnboxedArrayObject::offsetOfElements() - : NativeObject::offsetOfElements()); + Address elements(ToRegister(lir->object()), NativeObject::offsetOfElements()); masm.loadPtr(elements, ToRegister(lir->output())); } @@ -5341,21 +5339,11 @@ CodeGenerator::visitNewArrayDynamicLength(LNewArrayDynamicLength* lir) bool canInline = true; size_t inlineLength = 0; - if (templateObject->is()) { - if (templateObject->as().hasFixedElements()) { - size_t numSlots = gc::GetGCKindSlots(templateObject->asTenured().getAllocKind()); - inlineLength = numSlots - ObjectElements::VALUES_PER_HEADER; - } else { - canInline = false; - } + if (templateObject->as().hasFixedElements()) { + size_t numSlots = gc::GetGCKindSlots(templateObject->asTenured().getAllocKind()); + inlineLength = numSlots - ObjectElements::VALUES_PER_HEADER; } else { - if (templateObject->as().hasInlineElements()) { - size_t nbytes = - templateObject->tenuredSizeOfThis() - UnboxedArrayObject::offsetOfInlineElements(); - inlineLength = nbytes / templateObject->as().elementSize(); - } else { - canInline = false; - } + canInline = false; } if (canInline) { @@ -7811,49 +7799,6 @@ CodeGenerator::visitSetInitializedLength(LSetInitializedLength* lir) masm.dec32(&index); } -void -CodeGenerator::visitUnboxedArrayLength(LUnboxedArrayLength* lir) -{ - Register obj = ToRegister(lir->object()); - Register result = ToRegister(lir->output()); - masm.load32(Address(obj, UnboxedArrayObject::offsetOfLength()), result); -} - -void -CodeGenerator::visitUnboxedArrayInitializedLength(LUnboxedArrayInitializedLength* lir) -{ - Register obj = ToRegister(lir->object()); - Register result = ToRegister(lir->output()); - masm.load32(Address(obj, UnboxedArrayObject::offsetOfCapacityIndexAndInitializedLength()), result); - masm.and32(Imm32(UnboxedArrayObject::InitializedLengthMask), result); -} - -void -CodeGenerator::visitIncrementUnboxedArrayInitializedLength(LIncrementUnboxedArrayInitializedLength* lir) -{ - Register obj = ToRegister(lir->object()); - masm.add32(Imm32(1), Address(obj, UnboxedArrayObject::offsetOfCapacityIndexAndInitializedLength())); -} - -void -CodeGenerator::visitSetUnboxedArrayInitializedLength(LSetUnboxedArrayInitializedLength* lir) -{ - Register obj = ToRegister(lir->object()); - RegisterOrInt32Constant key = ToRegisterOrInt32Constant(lir->length()); - Register temp = ToRegister(lir->temp()); - - Address initLengthAddr(obj, UnboxedArrayObject::offsetOfCapacityIndexAndInitializedLength()); - masm.load32(initLengthAddr, temp); - masm.and32(Imm32(UnboxedArrayObject::CapacityMask), temp); - - if (key.isRegister()) - masm.or32(key.reg(), temp); - else - masm.or32(Imm32(key.constant()), temp); - - masm.store32(temp, initLengthAddr); -} - void CodeGenerator::visitNotO(LNotO* lir) { @@ -8150,46 +8095,19 @@ CodeGenerator::emitStoreElementHoleT(T* lir) OutOfLineStoreElementHole* ool = new(alloc()) OutOfLineStoreElementHole(lir); addOutOfLineCode(ool, lir->mir()); - Register obj = ToRegister(lir->object()); Register elements = ToRegister(lir->elements()); const LAllocation* index = lir->index(); RegisterOrInt32Constant key = ToRegisterOrInt32Constant(index); - JSValueType unboxedType = lir->mir()->unboxedType(); - if (unboxedType == JSVAL_TYPE_MAGIC) { - Address initLength(elements, ObjectElements::offsetOfInitializedLength()); - masm.branch32(Assembler::BelowOrEqual, initLength, key, ool->entry()); - - if (lir->mir()->needsBarrier()) - emitPreBarrier(elements, index, 0); + Address initLength(elements, ObjectElements::offsetOfInitializedLength()); + masm.branch32(Assembler::BelowOrEqual, initLength, key, ool->entry()); - masm.bind(ool->rejoinStore()); - emitStoreElementTyped(lir->value(), lir->mir()->value()->type(), lir->mir()->elementType(), - elements, index, 0); - } else { - Register temp = ToRegister(lir->getTemp(0)); - Address initLength(obj, UnboxedArrayObject::offsetOfCapacityIndexAndInitializedLength()); - masm.load32(initLength, temp); - masm.and32(Imm32(UnboxedArrayObject::InitializedLengthMask), temp); - masm.branch32(Assembler::BelowOrEqual, temp, key, ool->entry()); - - ConstantOrRegister v = ToConstantOrRegister(lir->value(), lir->mir()->value()->type()); - - if (index->isConstant()) { - Address address(elements, ToInt32(index) * UnboxedTypeSize(unboxedType)); - EmitUnboxedPreBarrier(masm, address, unboxedType); - - masm.bind(ool->rejoinStore()); - masm.storeUnboxedProperty(address, unboxedType, v, nullptr); - } else { - BaseIndex address(elements, ToRegister(index), - ScaleFromElemWidth(UnboxedTypeSize(unboxedType))); - EmitUnboxedPreBarrier(masm, address, unboxedType); + if (lir->mir()->needsBarrier()) + emitPreBarrier(elements, index, 0); - masm.bind(ool->rejoinStore()); - masm.storeUnboxedProperty(address, unboxedType, v, nullptr); - } - } + masm.bind(ool->rejoinStore()); + emitStoreElementTyped(lir->value(), lir->mir()->value()->type(), lir->mir()->elementType(), + elements, index, 0); masm.bind(ool->rejoin()); } @@ -8209,47 +8127,22 @@ CodeGenerator::emitStoreElementHoleV(T* lir) OutOfLineStoreElementHole* ool = new(alloc()) OutOfLineStoreElementHole(lir); addOutOfLineCode(ool, lir->mir()); - Register obj = ToRegister(lir->object()); Register elements = ToRegister(lir->elements()); const LAllocation* index = lir->index(); const ValueOperand value = ToValue(lir, T::Value); RegisterOrInt32Constant key = ToRegisterOrInt32Constant(index); - JSValueType unboxedType = lir->mir()->unboxedType(); - if (unboxedType == JSVAL_TYPE_MAGIC) { - Address initLength(elements, ObjectElements::offsetOfInitializedLength()); - masm.branch32(Assembler::BelowOrEqual, initLength, key, ool->entry()); - - if (lir->mir()->needsBarrier()) - emitPreBarrier(elements, index, 0); + Address initLength(elements, ObjectElements::offsetOfInitializedLength()); + masm.branch32(Assembler::BelowOrEqual, initLength, key, ool->entry()); - masm.bind(ool->rejoinStore()); - if (index->isConstant()) - masm.storeValue(value, Address(elements, ToInt32(index) * sizeof(js::Value))); - else - masm.storeValue(value, BaseIndex(elements, ToRegister(index), TimesEight)); - } else { - Register temp = ToRegister(lir->getTemp(0)); - Address initLength(obj, UnboxedArrayObject::offsetOfCapacityIndexAndInitializedLength()); - masm.load32(initLength, temp); - masm.and32(Imm32(UnboxedArrayObject::InitializedLengthMask), temp); - masm.branch32(Assembler::BelowOrEqual, temp, key, ool->entry()); - - if (index->isConstant()) { - Address address(elements, ToInt32(index) * UnboxedTypeSize(unboxedType)); - EmitUnboxedPreBarrier(masm, address, unboxedType); - - masm.bind(ool->rejoinStore()); - masm.storeUnboxedProperty(address, unboxedType, ConstantOrRegister(value), nullptr); - } else { - BaseIndex address(elements, ToRegister(index), - ScaleFromElemWidth(UnboxedTypeSize(unboxedType))); - EmitUnboxedPreBarrier(masm, address, unboxedType); + if (lir->mir()->needsBarrier()) + emitPreBarrier(elements, index, 0); - masm.bind(ool->rejoinStore()); - masm.storeUnboxedProperty(address, unboxedType, ConstantOrRegister(value), nullptr); - } - } + masm.bind(ool->rejoinStore()); + if (index->isConstant()) + masm.storeValue(value, Address(elements, ToInt32(index) * sizeof(js::Value))); + else + masm.storeValue(value, BaseIndex(elements, ToRegister(index), TimesEight)); masm.bind(ool->rejoin()); } @@ -8334,8 +8227,6 @@ CodeGenerator::visitOutOfLineStoreElementHole(OutOfLineStoreElementHole* ool) const LAllocation* index; MIRType valueType; ConstantOrRegister value; - JSValueType unboxedType; - LDefinition *temp = nullptr; if (ins->isStoreElementHoleV()) { LStoreElementHoleV* store = ins->toStoreElementHoleV(); @@ -8344,8 +8235,6 @@ CodeGenerator::visitOutOfLineStoreElementHole(OutOfLineStoreElementHole* ool) index = store->index(); valueType = store->mir()->value()->type(); value = TypedOrValueRegister(ToValue(store, LStoreElementHoleV::Value)); - unboxedType = store->mir()->unboxedType(); - temp = store->getTemp(0); } else if (ins->isFallibleStoreElementV()) { LFallibleStoreElementV* store = ins->toFallibleStoreElementV(); object = ToRegister(store->object()); @@ -8353,8 +8242,6 @@ CodeGenerator::visitOutOfLineStoreElementHole(OutOfLineStoreElementHole* ool) index = store->index(); valueType = store->mir()->value()->type(); value = TypedOrValueRegister(ToValue(store, LFallibleStoreElementV::Value)); - unboxedType = store->mir()->unboxedType(); - temp = store->getTemp(0); } else if (ins->isStoreElementHoleT()) { LStoreElementHoleT* store = ins->toStoreElementHoleT(); object = ToRegister(store->object()); @@ -8365,8 +8252,6 @@ CodeGenerator::visitOutOfLineStoreElementHole(OutOfLineStoreElementHole* ool) value = ConstantOrRegister(store->value()->toConstant()->toJSValue()); else value = TypedOrValueRegister(valueType, ToAnyRegister(store->value())); - unboxedType = store->mir()->unboxedType(); - temp = store->getTemp(0); } else { // ins->isFallibleStoreElementT() LFallibleStoreElementT* store = ins->toFallibleStoreElementT(); object = ToRegister(store->object()); @@ -8377,8 +8262,6 @@ CodeGenerator::visitOutOfLineStoreElementHole(OutOfLineStoreElementHole* ool) value = ConstantOrRegister(store->value()->toConstant()->toJSValue()); else value = TypedOrValueRegister(valueType, ToAnyRegister(store->value())); - unboxedType = store->mir()->unboxedType(); - temp = store->getTemp(0); } RegisterOrInt32Constant key = ToRegisterOrInt32Constant(index); @@ -8389,54 +8272,32 @@ CodeGenerator::visitOutOfLineStoreElementHole(OutOfLineStoreElementHole* ool) Label callStub; #if defined(JS_CODEGEN_MIPS32) || defined(JS_CODEGEN_MIPS64) // Had to reimplement for MIPS because there are no flags. - if (unboxedType == JSVAL_TYPE_MAGIC) { - Address initLength(elements, ObjectElements::offsetOfInitializedLength()); - masm.branch32(Assembler::NotEqual, initLength, key, &callStub); - } else { - Address initLength(object, UnboxedArrayObject::offsetOfCapacityIndexAndInitializedLength()); - masm.load32(initLength, ToRegister(temp)); - masm.and32(Imm32(UnboxedArrayObject::InitializedLengthMask), ToRegister(temp)); - masm.branch32(Assembler::NotEqual, ToRegister(temp), key, &callStub); - } + Address initLength(elements, ObjectElements::offsetOfInitializedLength()); + masm.branch32(Assembler::NotEqual, initLength, key, &callStub); #else masm.j(Assembler::NotEqual, &callStub); #endif - if (unboxedType == JSVAL_TYPE_MAGIC) { - // Check array capacity. - masm.branch32(Assembler::BelowOrEqual, Address(elements, ObjectElements::offsetOfCapacity()), - key, &callStub); - - // Update initialized length. The capacity guard above ensures this won't overflow, - // due to MAX_DENSE_ELEMENTS_COUNT. - masm.inc32(&key); - masm.store32(key, Address(elements, ObjectElements::offsetOfInitializedLength())); - - // Update length if length < initializedLength. - Label dontUpdate; - masm.branch32(Assembler::AboveOrEqual, Address(elements, ObjectElements::offsetOfLength()), - key, &dontUpdate); - masm.store32(key, Address(elements, ObjectElements::offsetOfLength())); - masm.bind(&dontUpdate); + // Check array capacity. + masm.branch32(Assembler::BelowOrEqual, Address(elements, ObjectElements::offsetOfCapacity()), + key, &callStub); - masm.dec32(&key); - } else { - // Check array capacity. - masm.checkUnboxedArrayCapacity(object, key, ToRegister(temp), &callStub); + // Update initialized length. The capacity guard above ensures this won't overflow, + // due to MAX_DENSE_ELEMENTS_COUNT. + masm.inc32(&key); + masm.store32(key, Address(elements, ObjectElements::offsetOfInitializedLength())); - // Update initialized length. - masm.add32(Imm32(1), Address(object, UnboxedArrayObject::offsetOfCapacityIndexAndInitializedLength())); + // Update length if length < initializedLength. + Label dontUpdate; + masm.branch32(Assembler::AboveOrEqual, Address(elements, ObjectElements::offsetOfLength()), + key, &dontUpdate); + masm.store32(key, Address(elements, ObjectElements::offsetOfLength())); + masm.bind(&dontUpdate); - // Update length if length < initializedLength. - Address lengthAddr(object, UnboxedArrayObject::offsetOfLength()); - Label dontUpdate; - masm.branch32(Assembler::Above, lengthAddr, key, &dontUpdate); - masm.add32(Imm32(1), lengthAddr); - masm.bind(&dontUpdate); - } + masm.dec32(&key); if ((ins->isStoreElementHoleT() || ins->isFallibleStoreElementT()) && - unboxedType == JSVAL_TYPE_MAGIC && valueType != MIRType::Double) + valueType != MIRType::Double) { // The inline path for StoreElementHoleT and FallibleStoreElementT does not always store // the type tag, so we do the store on the OOL path. We use MIRType::None for the element @@ -8526,9 +8387,6 @@ typedef bool (*ConvertUnboxedObjectToNativeFn)(JSContext*, JSObject*); static const VMFunction ConvertUnboxedPlainObjectToNativeInfo = FunctionInfo(UnboxedPlainObject::convertToNative, "UnboxedPlainObject::convertToNative"); -static const VMFunction ConvertUnboxedArrayObjectToNativeInfo = - FunctionInfo(UnboxedArrayObject::convertToNative, - "UnboxedArrayObject::convertToNative"); typedef bool (*ArrayPopShiftFn)(JSContext*, HandleObject, MutableHandleValue); static const VMFunction ArrayPopDenseInfo = @@ -8554,20 +8412,11 @@ CodeGenerator::emitArrayPopShift(LInstruction* lir, const MArrayPopShift* mir, R // Load elements and length, and VM call if length != initializedLength. RegisterOrInt32Constant key = RegisterOrInt32Constant(lengthTemp); - if (mir->unboxedType() == JSVAL_TYPE_MAGIC) { - masm.loadPtr(Address(obj, NativeObject::offsetOfElements()), elementsTemp); - masm.load32(Address(elementsTemp, ObjectElements::offsetOfLength()), lengthTemp); + masm.loadPtr(Address(obj, NativeObject::offsetOfElements()), elementsTemp); + masm.load32(Address(elementsTemp, ObjectElements::offsetOfLength()), lengthTemp); - Address initLength(elementsTemp, ObjectElements::offsetOfInitializedLength()); - masm.branch32(Assembler::NotEqual, initLength, key, ool->entry()); - } else { - masm.loadPtr(Address(obj, UnboxedArrayObject::offsetOfElements()), elementsTemp); - masm.load32(Address(obj, UnboxedArrayObject::offsetOfCapacityIndexAndInitializedLength()), lengthTemp); - masm.and32(Imm32(UnboxedArrayObject::InitializedLengthMask), lengthTemp); - - Address lengthAddr(obj, UnboxedArrayObject::offsetOfLength()); - masm.branch32(Assembler::NotEqual, lengthAddr, key, ool->entry()); - } + Address initLength(elementsTemp, ObjectElements::offsetOfInitializedLength()); + masm.branch32(Assembler::NotEqual, initLength, key, ool->entry()); // Test for length != 0. On zero length either take a VM call or generate // an undefined value, depending on whether the call is known to produce @@ -8579,13 +8428,10 @@ CodeGenerator::emitArrayPopShift(LInstruction* lir, const MArrayPopShift* mir, R // According to the spec we need to set the length 0 (which is already 0). // This is observable when the array length is made non-writable. - // Handle this case in the OOL. When freezing an unboxed array it is converted - // to an normal array. - if (mir->unboxedType() == JSVAL_TYPE_MAGIC) { - Address elementFlags(elementsTemp, ObjectElements::offsetOfFlags()); - Imm32 bit(ObjectElements::NONWRITABLE_ARRAY_LENGTH); - masm.branchTest32(Assembler::NonZero, elementFlags, bit, ool->entry()); - } + // Handle this case in the OOL. + Address elementFlags(elementsTemp, ObjectElements::offsetOfFlags()); + Imm32 bit(ObjectElements::NONWRITABLE_ARRAY_LENGTH); + masm.branchTest32(Assembler::NonZero, elementFlags, bit, ool->entry()); masm.moveValue(UndefinedValue(), out.valueReg()); masm.jump(&done); @@ -8597,41 +8443,25 @@ CodeGenerator::emitArrayPopShift(LInstruction* lir, const MArrayPopShift* mir, R masm.dec32(&key); if (mir->mode() == MArrayPopShift::Pop) { - if (mir->unboxedType() == JSVAL_TYPE_MAGIC) { - BaseIndex addr(elementsTemp, lengthTemp, TimesEight); - masm.loadElementTypedOrValue(addr, out, mir->needsHoleCheck(), ool->entry()); - } else { - size_t elemSize = UnboxedTypeSize(mir->unboxedType()); - BaseIndex addr(elementsTemp, lengthTemp, ScaleFromElemWidth(elemSize)); - masm.loadUnboxedProperty(addr, mir->unboxedType(), out); - } + BaseIndex addr(elementsTemp, lengthTemp, TimesEight); + masm.loadElementTypedOrValue(addr, out, mir->needsHoleCheck(), ool->entry()); } else { MOZ_ASSERT(mir->mode() == MArrayPopShift::Shift); Address addr(elementsTemp, 0); - if (mir->unboxedType() == JSVAL_TYPE_MAGIC) - masm.loadElementTypedOrValue(addr, out, mir->needsHoleCheck(), ool->entry()); - else - masm.loadUnboxedProperty(addr, mir->unboxedType(), out); + masm.loadElementTypedOrValue(addr, out, mir->needsHoleCheck(), ool->entry()); } - if (mir->unboxedType() == JSVAL_TYPE_MAGIC) { - // Handle the failure case when the array length is non-writable in the - // OOL path. (Unlike in the adding-an-element cases, we can't rely on the - // capacity <= length invariant for such arrays to avoid an explicit - // check.) - Address elementFlags(elementsTemp, ObjectElements::offsetOfFlags()); - Imm32 bit(ObjectElements::NONWRITABLE_ARRAY_LENGTH); - masm.branchTest32(Assembler::NonZero, elementFlags, bit, ool->entry()); + // Handle the failure case when the array length is non-writable in the + // OOL path. (Unlike in the adding-an-element cases, we can't rely on the + // capacity <= length invariant for such arrays to avoid an explicit + // check.) + Address elementFlags(elementsTemp, ObjectElements::offsetOfFlags()); + Imm32 bit(ObjectElements::NONWRITABLE_ARRAY_LENGTH); + masm.branchTest32(Assembler::NonZero, elementFlags, bit, ool->entry()); - // Now adjust length and initializedLength. - masm.store32(lengthTemp, Address(elementsTemp, ObjectElements::offsetOfLength())); - masm.store32(lengthTemp, Address(elementsTemp, ObjectElements::offsetOfInitializedLength())); - } else { - // Unboxed arrays always have writable lengths. Adjust length and - // initializedLength. - masm.store32(lengthTemp, Address(obj, UnboxedArrayObject::offsetOfLength())); - masm.add32(Imm32(-1), Address(obj, UnboxedArrayObject::offsetOfCapacityIndexAndInitializedLength())); - } + // Now adjust length and initializedLength. + masm.store32(lengthTemp, Address(elementsTemp, ObjectElements::offsetOfLength())); + masm.store32(lengthTemp, Address(elementsTemp, ObjectElements::offsetOfInitializedLength())); if (mir->mode() == MArrayPopShift::Shift) { // Don't save the temp registers. @@ -8681,50 +8511,27 @@ CodeGenerator::emitArrayPush(LInstruction* lir, const MArrayPush* mir, Register OutOfLineCode* ool = oolCallVM(ArrayPushDenseInfo, lir, ArgList(obj, value), StoreRegisterTo(length)); RegisterOrInt32Constant key = RegisterOrInt32Constant(length); - if (mir->unboxedType() == JSVAL_TYPE_MAGIC) { - // Load elements and length. - masm.loadPtr(Address(obj, NativeObject::offsetOfElements()), elementsTemp); - masm.load32(Address(elementsTemp, ObjectElements::offsetOfLength()), length); - - // Guard length == initializedLength. - Address initLength(elementsTemp, ObjectElements::offsetOfInitializedLength()); - masm.branch32(Assembler::NotEqual, initLength, key, ool->entry()); - // Guard length < capacity. - Address capacity(elementsTemp, ObjectElements::offsetOfCapacity()); - masm.branch32(Assembler::BelowOrEqual, capacity, key, ool->entry()); + // Load elements and length. + masm.loadPtr(Address(obj, NativeObject::offsetOfElements()), elementsTemp); + masm.load32(Address(elementsTemp, ObjectElements::offsetOfLength()), length); - // Do the store. - masm.storeConstantOrRegister(value, BaseIndex(elementsTemp, length, TimesEight)); - } else { - // Load initialized length. - masm.load32(Address(obj, UnboxedArrayObject::offsetOfCapacityIndexAndInitializedLength()), length); - masm.and32(Imm32(UnboxedArrayObject::InitializedLengthMask), length); - - // Guard length == initializedLength. - Address lengthAddr(obj, UnboxedArrayObject::offsetOfLength()); - masm.branch32(Assembler::NotEqual, lengthAddr, key, ool->entry()); + // Guard length == initializedLength. + Address initLength(elementsTemp, ObjectElements::offsetOfInitializedLength()); + masm.branch32(Assembler::NotEqual, initLength, key, ool->entry()); - // Guard length < capacity. - masm.checkUnboxedArrayCapacity(obj, key, elementsTemp, ool->entry()); + // Guard length < capacity. + Address capacity(elementsTemp, ObjectElements::offsetOfCapacity()); + masm.branch32(Assembler::BelowOrEqual, capacity, key, ool->entry()); - // Load elements and do the store. - masm.loadPtr(Address(obj, UnboxedArrayObject::offsetOfElements()), elementsTemp); - size_t elemSize = UnboxedTypeSize(mir->unboxedType()); - BaseIndex addr(elementsTemp, length, ScaleFromElemWidth(elemSize)); - masm.storeUnboxedProperty(addr, mir->unboxedType(), value, nullptr); - } + // Do the store. + masm.storeConstantOrRegister(value, BaseIndex(elementsTemp, length, TimesEight)); masm.inc32(&key); // Update length and initialized length. - if (mir->unboxedType() == JSVAL_TYPE_MAGIC) { - masm.store32(length, Address(elementsTemp, ObjectElements::offsetOfLength())); - masm.store32(length, Address(elementsTemp, ObjectElements::offsetOfInitializedLength())); - } else { - masm.store32(length, Address(obj, UnboxedArrayObject::offsetOfLength())); - masm.add32(Imm32(1), Address(obj, UnboxedArrayObject::offsetOfCapacityIndexAndInitializedLength())); - } + masm.store32(length, Address(elementsTemp, ObjectElements::offsetOfLength())); + masm.store32(length, Address(elementsTemp, ObjectElements::offsetOfInitializedLength())); masm.bind(ool->rejoin()); } @@ -10922,7 +10729,7 @@ CodeGenerator::visitInArray(LInArray* lir) } masm.branch32(Assembler::BelowOrEqual, initLength, Imm32(index), failedInitLength); - if (mir->needsHoleCheck() && mir->unboxedType() == JSVAL_TYPE_MAGIC) { + if (mir->needsHoleCheck()) { NativeObject::elementsSizeMustNotOverflow(); Address address = Address(elements, index * sizeof(Value)); masm.branchTestMagic(Assembler::Equal, address, &falseBranch); @@ -10935,7 +10742,7 @@ CodeGenerator::visitInArray(LInArray* lir) failedInitLength = &negativeIntCheck; masm.branch32(Assembler::BelowOrEqual, initLength, index, failedInitLength); - if (mir->needsHoleCheck() && mir->unboxedType() == JSVAL_TYPE_MAGIC) { + if (mir->needsHoleCheck()) { BaseIndex address = BaseIndex(elements, ToRegister(lir->index()), TimesEight); masm.branchTestMagic(Assembler::Equal, address, &falseBranch); } diff --git a/js/src/jit/CodeGenerator.h b/js/src/jit/CodeGenerator.h index 292f163b5..b5f170d84 100644 --- a/js/src/jit/CodeGenerator.h +++ b/js/src/jit/CodeGenerator.h @@ -234,10 +234,6 @@ class CodeGenerator final : public CodeGeneratorSpecific void visitSubstr(LSubstr* lir); void visitInitializedLength(LInitializedLength* lir); void visitSetInitializedLength(LSetInitializedLength* lir); - void visitUnboxedArrayLength(LUnboxedArrayLength* lir); - void visitUnboxedArrayInitializedLength(LUnboxedArrayInitializedLength* lir); - void visitIncrementUnboxedArrayInitializedLength(LIncrementUnboxedArrayInitializedLength* lir); - void visitSetUnboxedArrayInitializedLength(LSetUnboxedArrayInitializedLength* lir); void visitNotO(LNotO* ins); void visitNotV(LNotV* ins); void visitBoundsCheck(LBoundsCheck* lir); diff --git a/js/src/jit/IonBuilder.cpp b/js/src/jit/IonBuilder.cpp index af85011be..3d964d1c6 100644 --- a/js/src/jit/IonBuilder.cpp +++ b/js/src/jit/IonBuilder.cpp @@ -7336,12 +7336,6 @@ IonBuilder::newArrayTryTemplateObject(bool* emitted, JSObject* templateObject, u if (!templateObject) return true; - if (templateObject->is()) { - MOZ_ASSERT(templateObject->as().capacity() >= length); - if (!templateObject->as().hasInlineElements()) - return true; - } - MOZ_ASSERT(length <= NativeObject::MAX_DENSE_ELEMENTS_COUNT); size_t arraySlots = @@ -7597,7 +7591,6 @@ IonBuilder::jsop_initelem_array() // intializer, and that arrays are marked as non-packed when writing holes // to them during initialization. bool needStub = false; - JSValueType unboxedType = JSVAL_TYPE_MAGIC; if (shouldAbortOnPreliminaryGroups(obj)) { needStub = true; } else if (!obj->resultTypeSet() || @@ -7608,12 +7601,6 @@ IonBuilder::jsop_initelem_array() } else { MOZ_ASSERT(obj->resultTypeSet()->getObjectCount() == 1); TypeSet::ObjectKey* initializer = obj->resultTypeSet()->getObject(0); - if (initializer->clasp() == &UnboxedArrayObject::class_) { - if (initializer->group()->unboxedLayout().nativeGroup()) - needStub = true; - else - unboxedType = initializer->group()->unboxedLayout().elementType(); - } if (value->type() == MIRType::MagicHole) { if (!initializer->hasFlags(constraints(), OBJECT_FLAG_NON_PACKED)) needStub = true; @@ -7633,60 +7620,46 @@ IonBuilder::jsop_initelem_array() return resumeAfter(store); } - return initializeArrayElement(obj, index, value, unboxedType, /* addResumePoint = */ true); + return initializeArrayElement(obj, index, value, /* addResumePoint = */ true); } bool IonBuilder::initializeArrayElement(MDefinition* obj, size_t index, MDefinition* value, - JSValueType unboxedType, bool addResumePointAndIncrementInitializedLength) { MConstant* id = MConstant::New(alloc(), Int32Value(index)); current->add(id); // Get the elements vector. - MElements* elements = MElements::New(alloc(), obj, unboxedType != JSVAL_TYPE_MAGIC); + MElements* elements = MElements::New(alloc(), obj); current->add(elements); - if (unboxedType != JSVAL_TYPE_MAGIC) { - // Note: storeUnboxedValue takes care of any post barriers on the value. - storeUnboxedValue(obj, elements, 0, id, unboxedType, value, /* preBarrier = */ false); - - if (addResumePointAndIncrementInitializedLength) { - MInstruction* increment = MIncrementUnboxedArrayInitializedLength::New(alloc(), obj); - current->add(increment); - - if (!resumeAfter(increment)) - return false; - } - } else { - if (NeedsPostBarrier(value)) - current->add(MPostWriteBarrier::New(alloc(), obj, value)); + if (NeedsPostBarrier(value)) + current->add(MPostWriteBarrier::New(alloc(), obj, value)); - if ((obj->isNewArray() && obj->toNewArray()->convertDoubleElements()) || - (obj->isNullarySharedStub() && - obj->resultTypeSet()->convertDoubleElements(constraints()) == TemporaryTypeSet::AlwaysConvertToDoubles)) - { - MInstruction* valueDouble = MToDouble::New(alloc(), value); - current->add(valueDouble); - value = valueDouble; - } + if ((obj->isNewArray() && obj->toNewArray()->convertDoubleElements()) || + (obj->isNullarySharedStub() && + obj->resultTypeSet()->convertDoubleElements(constraints()) == TemporaryTypeSet::AlwaysConvertToDoubles)) + { + MInstruction* valueDouble = MToDouble::New(alloc(), value); + current->add(valueDouble); + value = valueDouble; + } - // Store the value. - MStoreElement* store = MStoreElement::New(alloc(), elements, id, value, + // Store the value. + MStoreElement* store = MStoreElement::New(alloc(), elements, id, value, /* needsHoleCheck = */ false); - current->add(store); + current->add(store); - if (addResumePointAndIncrementInitializedLength) { - // Update the initialized length. (The template object for this - // array has the array's ultimate length, so the length field is - // already correct: no updating needed.) - MSetInitializedLength* initLength = MSetInitializedLength::New(alloc(), elements, id); - current->add(initLength); + if (addResumePointAndIncrementInitializedLength) { + // Update the initialized length. (The template object for this + // array has the array's ultimate length, so the length field is + // already correct: no updating needed.) + MSetInitializedLength* initLength = MSetInitializedLength::New(alloc(), elements, id); + current->add(initLength); - if (!resumeAfter(initLength)) - return false; - } + if (!resumeAfter(initLength)) + return false; } return true; @@ -8175,8 +8148,7 @@ IonBuilder::maybeMarkEmpty(MDefinition* ins) static bool ClassHasEffectlessLookup(const Class* clasp) { - return (clasp == &UnboxedArrayObject::class_) || - IsTypedObjectClass(clasp) || + return IsTypedObjectClass(clasp) || (clasp->isNative() && !clasp->getOpsLookupProperty()); } @@ -9452,12 +9424,9 @@ IonBuilder::getElemTryDense(bool* emitted, MDefinition* obj, MDefinition* index) { MOZ_ASSERT(*emitted == false); - JSValueType unboxedType = UnboxedArrayElementType(constraints(), obj, index); - if (unboxedType == JSVAL_TYPE_MAGIC) { - if (!ElementAccessIsDenseNative(constraints(), obj, index)) { - trackOptimizationOutcome(TrackedOutcome::AccessNotDense); - return true; - } + if (!ElementAccessIsDenseNative(constraints(), obj, index)) { + trackOptimizationOutcome(TrackedOutcome::AccessNotDense); + return true; } // Don't generate a fast path if there have been bounds check failures @@ -9474,7 +9443,7 @@ IonBuilder::getElemTryDense(bool* emitted, MDefinition* obj, MDefinition* index) return true; } - if (!jsop_getelem_dense(obj, index, unboxedType)) + if (!jsop_getelem_dense(obj, index)) return false; trackOptimizationSuccess(); @@ -9826,7 +9795,7 @@ IonBuilder::computeHeapType(const TemporaryTypeSet* objTypes, const jsid id) } bool -IonBuilder::jsop_getelem_dense(MDefinition* obj, MDefinition* index, JSValueType unboxedType) +IonBuilder::jsop_getelem_dense(MDefinition* obj, MDefinition* index) { TemporaryTypeSet* types = bytecodeTypes(pc); @@ -9850,7 +9819,7 @@ IonBuilder::jsop_getelem_dense(MDefinition* obj, MDefinition* index, JSValueType !ElementAccessHasExtraIndexedProperty(this, obj); MIRType knownType = MIRType::Value; - if (unboxedType == JSVAL_TYPE_MAGIC && barrier == BarrierKind::NoBarrier) + if (barrier == BarrierKind::NoBarrier) knownType = GetElemKnownType(needsHoleCheck, types); // Ensure index is an integer. @@ -9859,13 +9828,13 @@ IonBuilder::jsop_getelem_dense(MDefinition* obj, MDefinition* index, JSValueType index = idInt32; // Get the elements vector. - MInstruction* elements = MElements::New(alloc(), obj, unboxedType != JSVAL_TYPE_MAGIC); + MInstruction* elements = MElements::New(alloc(), obj); current->add(elements); // Note: to help GVN, use the original MElements instruction and not // MConvertElementsToDoubles as operand. This is fine because converting // elements to double does not change the initialized length. - MInstruction* initLength = initializedLength(obj, elements, unboxedType); + MInstruction* initLength = initializedLength(obj, elements); // If we can load the element as a definite double, make sure to check that // the array has been converted to homogenous doubles first. @@ -9881,7 +9850,6 @@ IonBuilder::jsop_getelem_dense(MDefinition* obj, MDefinition* index, JSValueType } bool loadDouble = - unboxedType == JSVAL_TYPE_MAGIC && barrier == BarrierKind::NoBarrier && loopDepth_ && inBounds && @@ -9900,18 +9868,13 @@ IonBuilder::jsop_getelem_dense(MDefinition* obj, MDefinition* index, JSValueType // hoisting. index = addBoundsCheck(index, initLength); - if (unboxedType != JSVAL_TYPE_MAGIC) { - load = loadUnboxedValue(elements, 0, index, unboxedType, barrier, types); - } else { - load = MLoadElement::New(alloc(), elements, index, needsHoleCheck, loadDouble); - current->add(load); - } + load = MLoadElement::New(alloc(), elements, index, needsHoleCheck, loadDouble); + current->add(load); } else { // This load may return undefined, so assume that we *can* read holes, // or that we can read out-of-bounds accesses. In this case, the bounds // check is part of the opcode. - load = MLoadElementHole::New(alloc(), elements, index, initLength, - unboxedType, needsHoleCheck); + load = MLoadElementHole::New(alloc(), elements, index, initLength, needsHoleCheck); current->add(load); // If maybeUndefined was true, the typeset must have undefined, and @@ -9921,8 +9884,7 @@ IonBuilder::jsop_getelem_dense(MDefinition* obj, MDefinition* index, JSValueType } if (knownType != MIRType::Value) { - if (unboxedType == JSVAL_TYPE_MAGIC) - load->setResultType(knownType); + load->setResultType(knownType); load->setResultTypeSet(types); } @@ -10369,12 +10331,9 @@ IonBuilder::setElemTryDense(bool* emitted, MDefinition* object, { MOZ_ASSERT(*emitted == false); - JSValueType unboxedType = UnboxedArrayElementType(constraints(), object, index); - if (unboxedType == JSVAL_TYPE_MAGIC) { - if (!ElementAccessIsDenseNative(constraints(), object, index)) { - trackOptimizationOutcome(TrackedOutcome::AccessNotDense); - return true; - } + if (!ElementAccessIsDenseNative(constraints(), object, index)) { + trackOptimizationOutcome(TrackedOutcome::AccessNotDense); + return true; } if (PropertyWriteNeedsTypeBarrier(alloc(), constraints(), current, @@ -10408,7 +10367,7 @@ IonBuilder::setElemTryDense(bool* emitted, MDefinition* object, } // Emit dense setelem variant. - if (!jsop_setelem_dense(conversion, object, index, value, unboxedType, writeHole, emitted)) + if (!jsop_setelem_dense(conversion, object, index, value, writeHole, emitted)) return false; if (!*emitted) { @@ -10498,13 +10457,11 @@ IonBuilder::setElemTryCache(bool* emitted, MDefinition* object, bool IonBuilder::jsop_setelem_dense(TemporaryTypeSet::DoubleConversion conversion, MDefinition* obj, MDefinition* id, MDefinition* value, - JSValueType unboxedType, bool writeHole, bool* emitted) + bool writeHole, bool* emitted) { MOZ_ASSERT(*emitted == false); - MIRType elementType = MIRType::None; - if (unboxedType == JSVAL_TYPE_MAGIC) - elementType = DenseNativeElementType(constraints(), obj); + MIRType elementType = DenseNativeElementType(constraints(), obj); bool packed = ElementAccessIsPacked(constraints(), obj); // Writes which are on holes in the object do not have to bail out if they @@ -10534,7 +10491,7 @@ IonBuilder::jsop_setelem_dense(TemporaryTypeSet::DoubleConversion conversion, obj = addMaybeCopyElementsForWrite(obj, /* checkNative = */ false); // Get the elements vector. - MElements* elements = MElements::New(alloc(), obj, unboxedType != JSVAL_TYPE_MAGIC); + MElements* elements = MElements::New(alloc(), obj); current->add(elements); // Ensure the value is a double, if double conversion might be needed. @@ -10571,7 +10528,7 @@ IonBuilder::jsop_setelem_dense(TemporaryTypeSet::DoubleConversion conversion, MInstruction* store; MStoreElementCommon* common = nullptr; if (writeHole && hasNoExtraIndexedProperty && !mayBeFrozen) { - MStoreElementHole* ins = MStoreElementHole::New(alloc(), obj, elements, id, newValue, unboxedType); + MStoreElementHole* ins = MStoreElementHole::New(alloc(), obj, elements, id, newValue); store = ins; common = ins; @@ -10583,27 +10540,23 @@ IonBuilder::jsop_setelem_dense(TemporaryTypeSet::DoubleConversion conversion, bool strict = IsStrictSetPC(pc); MFallibleStoreElement* ins = MFallibleStoreElement::New(alloc(), obj, elements, id, - newValue, unboxedType, strict); + newValue, strict); store = ins; common = ins; current->add(ins); current->push(value); } else { - MInstruction* initLength = initializedLength(obj, elements, unboxedType); + MInstruction* initLength = initializedLength(obj, elements); id = addBoundsCheck(id, initLength); bool needsHoleCheck = !packed && !hasNoExtraIndexedProperty; - if (unboxedType != JSVAL_TYPE_MAGIC) { - store = storeUnboxedValue(obj, elements, 0, id, unboxedType, newValue); - } else { - MStoreElement* ins = MStoreElement::New(alloc(), elements, id, newValue, needsHoleCheck); - store = ins; - common = ins; + MStoreElement* ins = MStoreElement::New(alloc(), elements, id, newValue, needsHoleCheck); + store = ins; + common = ins; - current->add(store); - } + current->add(store); current->push(value); } @@ -10721,18 +10674,6 @@ IonBuilder::jsop_length_fastPath() return true; } - // Compute the length for unboxed array objects. - if (UnboxedArrayElementType(constraints(), obj, nullptr) != JSVAL_TYPE_MAGIC && - !objTypes->hasObjectFlags(constraints(), OBJECT_FLAG_LENGTH_OVERFLOW)) - { - current->pop(); - - MUnboxedArrayLength* length = MUnboxedArrayLength::New(alloc(), obj); - current->add(length); - current->push(length); - return true; - } - // Compute the length for array typed objects. TypedObjectPrediction prediction = typedObjectPrediction(obj); if (!prediction.isUseless()) { @@ -13687,11 +13628,8 @@ IonBuilder::inTryDense(bool* emitted, MDefinition* obj, MDefinition* id) if (shouldAbortOnPreliminaryGroups(obj)) return true; - JSValueType unboxedType = UnboxedArrayElementType(constraints(), obj, id); - if (unboxedType == JSVAL_TYPE_MAGIC) { - if (!ElementAccessIsDenseNative(constraints(), obj, id)) - return true; - } + if (!ElementAccessIsDenseNative(constraints(), obj, id)) + return true; if (ElementAccessHasExtraIndexedProperty(this, obj)) return true; @@ -13706,10 +13644,10 @@ IonBuilder::inTryDense(bool* emitted, MDefinition* obj, MDefinition* id) id = idInt32; // Get the elements vector. - MElements* elements = MElements::New(alloc(), obj, unboxedType != JSVAL_TYPE_MAGIC); + MElements* elements = MElements::New(alloc(), obj); current->add(elements); - MInstruction* initLength = initializedLength(obj, elements, unboxedType); + MInstruction* initLength = initializedLength(obj, elements); // If there are no holes, speculate the InArray check will not fail. if (!needsHoleCheck && !failedBoundsCheck_) { @@ -13719,8 +13657,7 @@ IonBuilder::inTryDense(bool* emitted, MDefinition* obj, MDefinition* id) } // Check if id < initLength and elem[id] not a hole. - MInArray* ins = MInArray::New(alloc(), elements, id, initLength, obj, needsHoleCheck, - unboxedType); + MInArray* ins = MInArray::New(alloc(), elements, id, initLength, obj, needsHoleCheck); current->add(ins); current->push(ins); @@ -14398,32 +14335,24 @@ IonBuilder::constantInt(int32_t i) } MInstruction* -IonBuilder::initializedLength(MDefinition* obj, MDefinition* elements, JSValueType unboxedType) +IonBuilder::initializedLength(MDefinition* obj, MDefinition* elements) { - MInstruction* res; - if (unboxedType != JSVAL_TYPE_MAGIC) - res = MUnboxedArrayInitializedLength::New(alloc(), obj); - else - res = MInitializedLength::New(alloc(), elements); + MInstruction* res = MInitializedLength::New(alloc(), elements); current->add(res); return res; } MInstruction* -IonBuilder::setInitializedLength(MDefinition* obj, JSValueType unboxedType, size_t count) +IonBuilder::setInitializedLength(MDefinition* obj, size_t count) { MOZ_ASSERT(count); - MInstruction* res; - if (unboxedType != JSVAL_TYPE_MAGIC) { - res = MSetUnboxedArrayInitializedLength::New(alloc(), obj, constant(Int32Value(count))); - } else { - // MSetInitializedLength takes the index of the last element, rather - // than the count itself. - MInstruction* elements = MElements::New(alloc(), obj, /* unboxed = */ false); - current->add(elements); - res = MSetInitializedLength::New(alloc(), elements, constant(Int32Value(count - 1))); - } + // MSetInitializedLength takes the index of the last element, rather + // than the count itself. + MInstruction* elements = MElements::New(alloc(), obj, /* unboxed = */ false); + current->add(elements); + MInstruction* res = + MSetInitializedLength::New(alloc(), elements, constant(Int32Value(count - 1))); current->add(res); return res; } diff --git a/js/src/jit/IonBuilder.h b/js/src/jit/IonBuilder.h index 77528ad37..1b97c4743 100644 --- a/js/src/jit/IonBuilder.h +++ b/js/src/jit/IonBuilder.h @@ -346,9 +346,8 @@ class IonBuilder MConstant* constant(const Value& v); MConstant* constantInt(int32_t i); - MInstruction* initializedLength(MDefinition* obj, MDefinition* elements, - JSValueType unboxedType); - MInstruction* setInitializedLength(MDefinition* obj, JSValueType unboxedType, size_t count); + MInstruction* initializedLength(MDefinition* obj, MDefinition* elements); + MInstruction* setInitializedLength(MDefinition* obj, size_t count); // Improve the type information at tests MOZ_MUST_USE bool improveTypesAtTest(MDefinition* ins, bool trueBranch, MTest* test); @@ -611,7 +610,6 @@ class IonBuilder TypedObjectPrediction elemTypeReprs, uint32_t elemSize); MOZ_MUST_USE bool initializeArrayElement(MDefinition* obj, size_t index, MDefinition* value, - JSValueType unboxedType, bool addResumePointAndIncrementInitializedLength); // jsop_getelem() helpers. @@ -723,15 +721,13 @@ class IonBuilder MOZ_MUST_USE bool jsop_bindname(PropertyName* name); MOZ_MUST_USE bool jsop_bindvar(); MOZ_MUST_USE bool jsop_getelem(); - MOZ_MUST_USE bool jsop_getelem_dense(MDefinition* obj, MDefinition* index, - JSValueType unboxedType); + MOZ_MUST_USE bool jsop_getelem_dense(MDefinition* obj, MDefinition* index); MOZ_MUST_USE bool jsop_getelem_typed(MDefinition* obj, MDefinition* index, ScalarTypeDescr::Type arrayType); MOZ_MUST_USE bool jsop_setelem(); MOZ_MUST_USE bool jsop_setelem_dense(TemporaryTypeSet::DoubleConversion conversion, MDefinition* object, MDefinition* index, - MDefinition* value, JSValueType unboxedType, - bool writeHole, bool* emitted); + MDefinition* value, bool writeHole, bool* emitted); MOZ_MUST_USE bool jsop_setelem_typed(ScalarTypeDescr::Type arrayType, MDefinition* object, MDefinition* index, MDefinition* value); diff --git a/js/src/jit/IonCaches.cpp b/js/src/jit/IonCaches.cpp index 96e488ea8..0a53f178f 100644 --- a/js/src/jit/IonCaches.cpp +++ b/js/src/jit/IonCaches.cpp @@ -638,9 +638,6 @@ TestMatchingReceiver(MacroAssembler& masm, IonCache::StubAttacher& attacher, } else { masm.branchPtr(Assembler::NotEqual, expandoAddress, ImmWord(0), failure); } - } else if (obj->is()) { - MOZ_ASSERT(failure); - masm.branchTestObjGroup(Assembler::NotEqual, object, obj->group(), failure); } else if (obj->is()) { attacher.branchNextStubOrLabel(masm, Assembler::NotEqual, Address(object, JSObject::offsetOfGroup()), @@ -1187,39 +1184,6 @@ GenerateArrayLength(JSContext* cx, MacroAssembler& masm, IonCache::StubAttacher& return true; } -static void -GenerateUnboxedArrayLength(JSContext* cx, MacroAssembler& masm, IonCache::StubAttacher& attacher, - JSObject* array, Register object, TypedOrValueRegister output, - Label* failures) -{ - Register outReg; - if (output.hasValue()) { - outReg = output.valueReg().scratchReg(); - } else { - MOZ_ASSERT(output.type() == MIRType::Int32); - outReg = output.typedReg().gpr(); - } - MOZ_ASSERT(object != outReg); - - TestMatchingReceiver(masm, attacher, object, array, failures); - - // Load length. - masm.load32(Address(object, UnboxedArrayObject::offsetOfLength()), outReg); - - // Check for a length that fits in an int32. - masm.branchTest32(Assembler::Signed, outReg, outReg, failures); - - if (output.hasValue()) - masm.tagValue(JSVAL_TYPE_INT32, outReg, output.valueReg()); - - // Success. - attacher.jumpRejoin(masm); - - // Failure. - masm.bind(failures); - attacher.jumpNextStub(masm); -} - // In this case, the code for TypedArray and SharedTypedArray is not the same, // because the code embeds pointers to the respective class arrays. Code that // caches the stub code must distinguish between the two cases. @@ -1593,40 +1557,6 @@ GetPropertyIC::tryAttachUnboxedExpando(JSContext* cx, HandleScript outerScript, JS::TrackedOutcome::ICGetPropStub_UnboxedReadExpando); } -bool -GetPropertyIC::tryAttachUnboxedArrayLength(JSContext* cx, HandleScript outerScript, IonScript* ion, - HandleObject obj, HandleId id, void* returnAddr, - bool* emitted) -{ - MOZ_ASSERT(canAttachStub()); - MOZ_ASSERT(!*emitted); - MOZ_ASSERT(outerScript->ionScript() == ion); - - if (!obj->is()) - return true; - - if (!JSID_IS_ATOM(id, cx->names().length)) - return true; - - if (obj->as().length() > INT32_MAX) - return true; - - if (!allowArrayLength(cx)) - return true; - - *emitted = true; - - MacroAssembler masm(cx, ion, outerScript, profilerLeavePc_); - - Label failures; - emitIdGuard(masm, id, &failures); - - StubAttacher attacher(*this); - GenerateUnboxedArrayLength(cx, masm, attacher, obj, object(), output(), &failures); - return linkAndAttachStub(cx, masm, attacher, ion, "unboxed array length", - JS::TrackedOutcome::ICGetPropStub_UnboxedArrayLength); -} - bool GetPropertyIC::tryAttachTypedArrayLength(JSContext* cx, HandleScript outerScript, IonScript* ion, HandleObject obj, HandleId id, bool* emitted) @@ -2202,9 +2132,6 @@ GetPropertyIC::tryAttachStub(JSContext* cx, HandleScript outerScript, IonScript* if (!*emitted && !tryAttachUnboxedExpando(cx, outerScript, ion, obj, id, returnAddr, emitted)) return false; - if (!*emitted && !tryAttachUnboxedArrayLength(cx, outerScript, ion, obj, id, returnAddr, emitted)) - return false; - if (!*emitted && !tryAttachTypedArrayLength(cx, outerScript, ion, obj, id, emitted)) return false; } @@ -4025,7 +3952,7 @@ GetPropertyIC::tryAttachDenseElementHole(JSContext* cx, HandleScript outerScript GetPropertyIC::canAttachTypedOrUnboxedArrayElement(JSObject* obj, const Value& idval, TypedOrValueRegister output) { - if (!obj->is() && !obj->is()) + if (!obj->is()) return false; MOZ_ASSERT(idval.isInt32() || idval.isString()); @@ -4056,13 +3983,6 @@ GetPropertyIC::canAttachTypedOrUnboxedArrayElement(JSObject* obj, const Value& i return output.hasValue() || !output.typedReg().isFloat(); } - if (index >= obj->as().initializedLength()) - return false; - - JSValueType elementType = obj->as().elementType(); - if (elementType == JSVAL_TYPE_DOUBLE) - return output.hasValue(); - return output.hasValue() || !output.typedReg().isFloat(); } @@ -4139,46 +4059,27 @@ GenerateGetTypedOrUnboxedArrayElement(JSContext* cx, MacroAssembler& masm, Label popObjectAndFail; - if (array->is()) { - // Guard on the initialized length. - Address length(object, TypedArrayObject::lengthOffset()); - masm.branch32(Assembler::BelowOrEqual, length, indexReg, &failures); + // Guard on the initialized length. + Address length(object, TypedArrayObject::lengthOffset()); + masm.branch32(Assembler::BelowOrEqual, length, indexReg, &failures); - // Save the object register on the stack in case of failure. - Register elementReg = object; - masm.push(object); + // Save the object register on the stack in case of failure. + Register elementReg = object; + masm.push(object); - // Load elements vector. - masm.loadPtr(Address(object, TypedArrayObject::dataOffset()), elementReg); + // Load elements vector. + masm.loadPtr(Address(object, TypedArrayObject::dataOffset()), elementReg); - // Load the value. We use an invalid register because the destination - // register is necessary a non double register. - Scalar::Type arrayType = array->as().type(); - int width = Scalar::byteSize(arrayType); - BaseIndex source(elementReg, indexReg, ScaleFromElemWidth(width)); - if (output.hasValue()) { - masm.loadFromTypedArray(arrayType, source, output.valueReg(), allowDoubleResult, - elementReg, &popObjectAndFail); - } else { - masm.loadFromTypedArray(arrayType, source, output.typedReg(), elementReg, &popObjectAndFail); - } + // Load the value. We use an invalid register because the destination + // register is necessary a non double register. + Scalar::Type arrayType = array->as().type(); + int width = Scalar::byteSize(arrayType); + BaseIndex source(elementReg, indexReg, ScaleFromElemWidth(width)); + if (output.hasValue()) { + masm.loadFromTypedArray(arrayType, source, output.valueReg(), allowDoubleResult, + elementReg, &popObjectAndFail); } else { - // Save the object register on the stack in case of failure. - masm.push(object); - - // Guard on the initialized length. - masm.load32(Address(object, UnboxedArrayObject::offsetOfCapacityIndexAndInitializedLength()), object); - masm.and32(Imm32(UnboxedArrayObject::InitializedLengthMask), object); - masm.branch32(Assembler::BelowOrEqual, object, indexReg, &popObjectAndFail); - - // Load elements vector. - Register elementReg = object; - masm.loadPtr(Address(masm.getStackPointer(), 0), object); - masm.loadPtr(Address(object, UnboxedArrayObject::offsetOfElements()), elementReg); - - JSValueType elementType = array->as().elementType(); - BaseIndex source(elementReg, indexReg, ScaleFromElemWidth(UnboxedTypeSize(elementType))); - masm.loadUnboxedProperty(source, elementType, output); + masm.loadFromTypedArray(arrayType, source, output.typedReg(), elementReg, &popObjectAndFail); } masm.pop(object); diff --git a/js/src/jit/Lowering.cpp b/js/src/jit/Lowering.cpp index aafa57c09..e185b5746 100644 --- a/js/src/jit/Lowering.cpp +++ b/js/src/jit/Lowering.cpp @@ -2888,32 +2888,6 @@ LIRGenerator::visitSetInitializedLength(MSetInitializedLength* ins) useRegisterOrConstant(ins->index())), ins); } -void -LIRGenerator::visitUnboxedArrayLength(MUnboxedArrayLength* ins) -{ - define(new(alloc()) LUnboxedArrayLength(useRegisterAtStart(ins->object())), ins); -} - -void -LIRGenerator::visitUnboxedArrayInitializedLength(MUnboxedArrayInitializedLength* ins) -{ - define(new(alloc()) LUnboxedArrayInitializedLength(useRegisterAtStart(ins->object())), ins); -} - -void -LIRGenerator::visitIncrementUnboxedArrayInitializedLength(MIncrementUnboxedArrayInitializedLength* ins) -{ - add(new(alloc()) LIncrementUnboxedArrayInitializedLength(useRegister(ins->object())), ins); -} - -void -LIRGenerator::visitSetUnboxedArrayInitializedLength(MSetUnboxedArrayInitializedLength* ins) -{ - add(new(alloc()) LSetUnboxedArrayInitializedLength(useRegister(ins->object()), - useRegisterOrConstant(ins->length()), - temp()), ins); -} - void LIRGenerator::visitNot(MNot* ins) { @@ -3165,8 +3139,6 @@ LIRGenerator::visitStoreElementHole(MStoreElementHole* ins) // Use a temp register when adding new elements to unboxed arrays. LDefinition tempDef = LDefinition::BogusTemp(); - if (ins->unboxedType() != JSVAL_TYPE_MAGIC) - tempDef = temp(); LInstruction* lir; switch (ins->value()->type()) { @@ -3199,8 +3171,6 @@ LIRGenerator::visitFallibleStoreElement(MFallibleStoreElement* ins) // Use a temp register when adding new elements to unboxed arrays. LDefinition tempDef = LDefinition::BogusTemp(); - if (ins->unboxedType() != JSVAL_TYPE_MAGIC) - tempDef = temp(); LInstruction* lir; switch (ins->value()->type()) { diff --git a/js/src/jit/Lowering.h b/js/src/jit/Lowering.h index e36620bce..b096bb143 100644 --- a/js/src/jit/Lowering.h +++ b/js/src/jit/Lowering.h @@ -216,10 +216,6 @@ class LIRGenerator : public LIRGeneratorSpecific void visitTypedObjectDescr(MTypedObjectDescr* ins); void visitInitializedLength(MInitializedLength* ins); void visitSetInitializedLength(MSetInitializedLength* ins); - void visitUnboxedArrayLength(MUnboxedArrayLength* ins); - void visitUnboxedArrayInitializedLength(MUnboxedArrayInitializedLength* ins); - void visitIncrementUnboxedArrayInitializedLength(MIncrementUnboxedArrayInitializedLength* ins); - void visitSetUnboxedArrayInitializedLength(MSetUnboxedArrayInitializedLength* ins); void visitNot(MNot* ins); void visitBoundsCheck(MBoundsCheck* ins); void visitBoundsCheckLower(MBoundsCheckLower* ins); diff --git a/js/src/jit/MCallOptimize.cpp b/js/src/jit/MCallOptimize.cpp index 41ccd0ca7..7283497ea 100644 --- a/js/src/jit/MCallOptimize.cpp +++ b/js/src/jit/MCallOptimize.cpp @@ -475,11 +475,6 @@ IonBuilder::inlineArray(CallInfo& callInfo) return InliningStatus_NotInlined; } - if (templateObject->is()) { - if (templateObject->group()->unboxedLayout().nativeGroup()) - return InliningStatus_NotInlined; - } - // Multiple arguments imply array initialization, not just construction. if (callInfo.argc() >= 2) { initLength = callInfo.argc(); @@ -542,16 +537,15 @@ IonBuilder::inlineArray(CallInfo& callInfo) MDefinition* array = current->peek(-1); if (callInfo.argc() >= 2) { - JSValueType unboxedType = GetBoxedOrUnboxedType(templateObject); for (uint32_t i = 0; i < initLength; i++) { if (!alloc().ensureBallast()) return InliningStatus_Error; MDefinition* value = callInfo.getArg(i); - if (!initializeArrayElement(array, i, value, unboxedType, /* addResumePoint = */ false)) + if (!initializeArrayElement(array, i, /* addResumePoint = */ false)) return InliningStatus_Error; } - MInstruction* setLength = setInitializedLength(array, unboxedType, initLength); + MInstruction* setLength = setInitializedLength(array, initLength); if (!resumeAfter(setLength)) return InliningStatus_Error; } @@ -620,7 +614,7 @@ IonBuilder::inlineArrayPopShift(CallInfo& callInfo, MArrayPopShift::Mode mode) if (!thisTypes) return InliningStatus_NotInlined; const Class* clasp = thisTypes->getKnownClass(constraints()); - if (clasp != &ArrayObject::class_ && clasp != &UnboxedArrayObject::class_) + if (clasp != &ArrayObject::class_) return InliningStatus_NotInlined; if (thisTypes->hasObjectFlags(constraints(), unhandledFlags)) { trackOptimizationOutcome(TrackedOutcome::ArrayBadFlags); @@ -632,17 +626,9 @@ IonBuilder::inlineArrayPopShift(CallInfo& callInfo, MArrayPopShift::Mode mode) return InliningStatus_NotInlined; } - JSValueType unboxedType = JSVAL_TYPE_MAGIC; - if (clasp == &UnboxedArrayObject::class_) { - unboxedType = UnboxedArrayElementType(constraints(), obj, nullptr); - if (unboxedType == JSVAL_TYPE_MAGIC) - return InliningStatus_NotInlined; - } - callInfo.setImplicitlyUsedUnchecked(); - if (clasp == &ArrayObject::class_) - obj = addMaybeCopyElementsForWrite(obj, /* checkNative = */ false); + obj = addMaybeCopyElementsForWrite(obj, /* checkNative = */ false); TemporaryTypeSet* returnTypes = getInlineReturnTypeSet(); bool needsHoleCheck = thisTypes->hasObjectFlags(constraints(), OBJECT_FLAG_NON_PACKED); @@ -653,8 +639,7 @@ IonBuilder::inlineArrayPopShift(CallInfo& callInfo, MArrayPopShift::Mode mode) if (barrier != BarrierKind::NoBarrier) returnType = MIRType::Value; - MArrayPopShift* ins = MArrayPopShift::New(alloc(), obj, mode, - unboxedType, needsHoleCheck, maybeUndefined); + MArrayPopShift* ins = MArrayPopShift::New(alloc(), obj, mode, needsHoleCheck, maybeUndefined); current->add(ins); current->push(ins); ins->setResultType(returnType); @@ -761,7 +746,7 @@ IonBuilder::inlineArrayPush(CallInfo& callInfo) if (!thisTypes) return InliningStatus_NotInlined; const Class* clasp = thisTypes->getKnownClass(constraints()); - if (clasp != &ArrayObject::class_ && clasp != &UnboxedArrayObject::class_) + if (clasp != &ArrayObject::class_) return InliningStatus_NotInlined; if (thisTypes->hasObjectFlags(constraints(), OBJECT_FLAG_SPARSE_INDEXES | OBJECT_FLAG_LENGTH_OVERFLOW)) @@ -782,13 +767,6 @@ IonBuilder::inlineArrayPush(CallInfo& callInfo) return InliningStatus_NotInlined; } - JSValueType unboxedType = JSVAL_TYPE_MAGIC; - if (clasp == &UnboxedArrayObject::class_) { - unboxedType = UnboxedArrayElementType(constraints(), obj, nullptr); - if (unboxedType == JSVAL_TYPE_MAGIC) - return InliningStatus_NotInlined; - } - callInfo.setImplicitlyUsedUnchecked(); if (conversion == TemporaryTypeSet::AlwaysConvertToDoubles || @@ -799,13 +777,12 @@ IonBuilder::inlineArrayPush(CallInfo& callInfo) value = valueDouble; } - if (unboxedType == JSVAL_TYPE_MAGIC) - obj = addMaybeCopyElementsForWrite(obj, /* checkNative = */ false); + obj = addMaybeCopyElementsForWrite(obj, /* checkNative = */ false); if (NeedsPostBarrier(value)) current->add(MPostWriteBarrier::New(alloc(), obj, value)); - MArrayPush* ins = MArrayPush::New(alloc(), obj, value, unboxedType); + MArrayPush* ins = MArrayPush::New(alloc(), obj, value); current->add(ins); current->push(ins); @@ -846,7 +823,7 @@ IonBuilder::inlineArraySlice(CallInfo& callInfo) return InliningStatus_NotInlined; const Class* clasp = thisTypes->getKnownClass(constraints()); - if (clasp != &ArrayObject::class_ && clasp != &UnboxedArrayObject::class_) + if (clasp != &ArrayObject::class_) return InliningStatus_NotInlined; if (thisTypes->hasObjectFlags(constraints(), OBJECT_FLAG_SPARSE_INDEXES | OBJECT_FLAG_LENGTH_OVERFLOW)) @@ -855,13 +832,6 @@ IonBuilder::inlineArraySlice(CallInfo& callInfo) return InliningStatus_NotInlined; } - JSValueType unboxedType = JSVAL_TYPE_MAGIC; - if (clasp == &UnboxedArrayObject::class_) { - unboxedType = UnboxedArrayElementType(constraints(), obj, nullptr); - if (unboxedType == JSVAL_TYPE_MAGIC) - return InliningStatus_NotInlined; - } - // Watch out for indexed properties on the prototype. if (ArrayPrototypeHasIndexedProperty(this, script())) { trackOptimizationOutcome(TrackedOutcome::ProtoIndexedProps); @@ -882,15 +852,8 @@ IonBuilder::inlineArraySlice(CallInfo& callInfo) if (!templateObj) return InliningStatus_NotInlined; - if (unboxedType == JSVAL_TYPE_MAGIC) { - if (!templateObj->is()) - return InliningStatus_NotInlined; - } else { - if (!templateObj->is()) - return InliningStatus_NotInlined; - if (templateObj->as().elementType() != unboxedType) - return InliningStatus_NotInlined; - } + if (!templateObj->is()) + return InliningStatus_NotInlined; callInfo.setImplicitlyUsedUnchecked(); @@ -909,16 +872,12 @@ IonBuilder::inlineArraySlice(CallInfo& callInfo) end = MArrayLength::New(alloc(), elements); current->add(end->toInstruction()); - } else { - end = MUnboxedArrayLength::New(alloc(), obj); - current->add(end->toInstruction()); } MArraySlice* ins = MArraySlice::New(alloc(), constraints(), obj, begin, end, templateObj, - templateObj->group()->initialHeap(constraints()), - unboxedType); + templateObj->group()->initialHeap(constraints())); current->add(ins); current->push(ins); @@ -1500,8 +1459,6 @@ IonBuilder::inlineConstantStringSplitString(CallInfo& callInfo) return InliningStatus_Inlined; } - JSValueType unboxedType = GetBoxedOrUnboxedType(templateObject); - // Store all values, no need to initialize the length after each as // jsop_initelem_array is doing because we do not expect to bailout // because the memory is supposed to be allocated by now. @@ -1512,11 +1469,11 @@ IonBuilder::inlineConstantStringSplitString(CallInfo& callInfo) MConstant* value = arrayValues[i]; current->add(value); - if (!initializeArrayElement(array, i, value, unboxedType, /* addResumePoint = */ false)) + if (!initializeArrayElement(array, i, value, /* addResumePoint = */ false)) return InliningStatus_Error; } - MInstruction* setLength = setInitializedLength(array, unboxedType, initLength); + MInstruction* setLength = setInitializedLength(array, initLength); if (!resumeAfter(setLength)) return InliningStatus_Error; diff --git a/js/src/jit/MIR.cpp b/js/src/jit/MIR.cpp index 1f33b2174..6aa46be4b 100644 --- a/js/src/jit/MIR.cpp +++ b/js/src/jit/MIR.cpp @@ -5823,46 +5823,6 @@ jit::ElementAccessIsDenseNative(CompilerConstraintList* constraints, return clasp && clasp->isNative() && !IsTypedArrayClass(clasp); } -JSValueType -jit::UnboxedArrayElementType(CompilerConstraintList* constraints, MDefinition* obj, - MDefinition* id) -{ - if (obj->mightBeType(MIRType::String)) - return JSVAL_TYPE_MAGIC; - - if (id && id->type() != MIRType::Int32 && id->type() != MIRType::Double) - return JSVAL_TYPE_MAGIC; - - TemporaryTypeSet* types = obj->resultTypeSet(); - if (!types || types->unknownObject()) - return JSVAL_TYPE_MAGIC; - - JSValueType elementType = JSVAL_TYPE_MAGIC; - for (unsigned i = 0; i < types->getObjectCount(); i++) { - TypeSet::ObjectKey* key = types->getObject(i); - if (!key) - continue; - - if (key->unknownProperties() || !key->isGroup()) - return JSVAL_TYPE_MAGIC; - - if (key->clasp() != &UnboxedArrayObject::class_) - return JSVAL_TYPE_MAGIC; - - const UnboxedLayout &layout = key->group()->unboxedLayout(); - - if (layout.nativeGroup()) - return JSVAL_TYPE_MAGIC; - - if (elementType == layout.elementType() || elementType == JSVAL_TYPE_MAGIC) - elementType = layout.elementType(); - else - return JSVAL_TYPE_MAGIC; - } - - return elementType; -} - bool jit::ElementAccessIsTypedArray(CompilerConstraintList* constraints, MDefinition* obj, MDefinition* id, @@ -6022,11 +5982,6 @@ ObjectSubsumes(TypeSet::ObjectKey* first, TypeSet::ObjectKey* second) firstElements.maybeTypes()->equals(secondElements.maybeTypes()); } - if (first->clasp() == &UnboxedArrayObject::class_) { - return first->group()->unboxedLayout().elementType() == - second->group()->unboxedLayout().elementType(); - } - return false; } diff --git a/js/src/jit/MIR.h b/js/src/jit/MIR.h index 3e0421789..cdd737b56 100644 --- a/js/src/jit/MIR.h +++ b/js/src/jit/MIR.h @@ -375,8 +375,7 @@ class AliasSet { Element = 1 << 1, // A Value member of obj->elements or // a typed object. UnboxedElement = 1 << 2, // An unboxed scalar or reference member of - // a typed array, typed object, or unboxed - // object. + // typed object or unboxed object. DynamicSlot = 1 << 3, // A Value member of obj->slots. FixedSlot = 1 << 4, // A Value member of obj->fixedSlots(). DOMProperty = 1 << 5, // A DOM property @@ -433,9 +432,6 @@ class AliasSet { MOZ_ASSERT(flags && !(flags & Store_)); return AliasSet(flags | Store_); } - static uint32_t BoxedOrUnboxedElements(JSValueType type) { - return (type == JSVAL_TYPE_MAGIC) ? Element : UnboxedElement; - } }; typedef Vector MDefinitionVector; @@ -8745,102 +8741,6 @@ class MSetInitializedLength ALLOW_CLONE(MSetInitializedLength) }; -// Load the length from an unboxed array. -class MUnboxedArrayLength - : public MUnaryInstruction, - public SingleObjectPolicy::Data -{ - explicit MUnboxedArrayLength(MDefinition* object) - : MUnaryInstruction(object) - { - setResultType(MIRType::Int32); - setMovable(); - } - - public: - INSTRUCTION_HEADER(UnboxedArrayLength) - TRIVIAL_NEW_WRAPPERS - NAMED_OPERANDS((0, object)) - - bool congruentTo(const MDefinition* ins) const override { - return congruentIfOperandsEqual(ins); - } - AliasSet getAliasSet() const override { - return AliasSet::Load(AliasSet::ObjectFields); - } - - ALLOW_CLONE(MUnboxedArrayLength) -}; - -// Load the initialized length from an unboxed array. -class MUnboxedArrayInitializedLength - : public MUnaryInstruction, - public SingleObjectPolicy::Data -{ - explicit MUnboxedArrayInitializedLength(MDefinition* object) - : MUnaryInstruction(object) - { - setResultType(MIRType::Int32); - setMovable(); - } - - public: - INSTRUCTION_HEADER(UnboxedArrayInitializedLength) - TRIVIAL_NEW_WRAPPERS - NAMED_OPERANDS((0, object)) - - bool congruentTo(const MDefinition* ins) const override { - return congruentIfOperandsEqual(ins); - } - AliasSet getAliasSet() const override { - return AliasSet::Load(AliasSet::ObjectFields); - } - - ALLOW_CLONE(MUnboxedArrayInitializedLength) -}; - -// Increment the initialized length of an unboxed array object. -class MIncrementUnboxedArrayInitializedLength - : public MUnaryInstruction, - public SingleObjectPolicy::Data -{ - explicit MIncrementUnboxedArrayInitializedLength(MDefinition* obj) - : MUnaryInstruction(obj) - {} - - public: - INSTRUCTION_HEADER(IncrementUnboxedArrayInitializedLength) - TRIVIAL_NEW_WRAPPERS - NAMED_OPERANDS((0, object)) - - AliasSet getAliasSet() const override { - return AliasSet::Store(AliasSet::ObjectFields); - } - - ALLOW_CLONE(MIncrementUnboxedArrayInitializedLength) -}; - -// Set the initialized length of an unboxed array object. -class MSetUnboxedArrayInitializedLength - : public MBinaryInstruction, - public SingleObjectPolicy::Data -{ - explicit MSetUnboxedArrayInitializedLength(MDefinition* obj, MDefinition* length) - : MBinaryInstruction(obj, length) - {} - - public: - INSTRUCTION_HEADER(SetUnboxedArrayInitializedLength) - TRIVIAL_NEW_WRAPPERS - NAMED_OPERANDS((0, object), (1, length)) - - AliasSet getAliasSet() const override { - return AliasSet::Store(AliasSet::ObjectFields); - } - - ALLOW_CLONE(MSetUnboxedArrayInitializedLength) -}; - // Load the array length from an elements header. class MArrayLength : public MUnaryInstruction, @@ -9341,16 +9241,12 @@ class MLoadElementHole : public MTernaryInstruction, public SingleObjectPolicy::Data { - // Unboxed element type, JSVAL_TYPE_MAGIC for dense native elements. - JSValueType unboxedType_; - bool needsNegativeIntCheck_; bool needsHoleCheck_; MLoadElementHole(MDefinition* elements, MDefinition* index, MDefinition* initLength, JSValueType unboxedType, bool needsHoleCheck) : MTernaryInstruction(elements, index, initLength), - unboxedType_(unboxedType), needsNegativeIntCheck_(true), needsHoleCheck_(needsHoleCheck) { @@ -9372,9 +9268,6 @@ class MLoadElementHole TRIVIAL_NEW_WRAPPERS NAMED_OPERANDS((0, elements), (1, index), (2, initLength)) - JSValueType unboxedType() const { - return unboxedType_; - } bool needsNegativeIntCheck() const { return needsNegativeIntCheck_; } @@ -9385,8 +9278,6 @@ class MLoadElementHole if (!ins->isLoadElementHole()) return false; const MLoadElementHole* other = ins->toLoadElementHole(); - if (unboxedType() != other->unboxedType()) - return false; if (needsHoleCheck() != other->needsHoleCheck()) return false; if (needsNegativeIntCheck() != other->needsNegativeIntCheck()) @@ -9394,7 +9285,7 @@ class MLoadElementHole return congruentIfOperandsEqual(other); } AliasSet getAliasSet() const override { - return AliasSet::Load(AliasSet::BoxedOrUnboxedElements(unboxedType())); + return AliasSet::Load(AliasSet::Element); } void collectRangeInfoPreTrunc() override; @@ -9583,11 +9474,8 @@ class MStoreElementHole public MStoreElementCommon, public MixPolicy >::Data { - JSValueType unboxedType_; - MStoreElementHole(MDefinition* object, MDefinition* elements, - MDefinition* index, MDefinition* value, JSValueType unboxedType) - : unboxedType_(unboxedType) + MDefinition* index, MDefinition* value) { initOperand(0, object); initOperand(1, elements); @@ -9602,14 +9490,10 @@ class MStoreElementHole TRIVIAL_NEW_WRAPPERS NAMED_OPERANDS((0, object), (1, elements), (2, index), (3, value)) - JSValueType unboxedType() const { - return unboxedType_; - } AliasSet getAliasSet() const override { // StoreElementHole can update the initialized length, the array length // or reallocate obj->elements. - return AliasSet::Store(AliasSet::ObjectFields | - AliasSet::BoxedOrUnboxedElements(unboxedType())); + return AliasSet::Store(AliasSet::ObjectFields | AliasSet::Element); } ALLOW_CLONE(MStoreElementHole) @@ -9622,13 +9506,11 @@ class MFallibleStoreElement public MStoreElementCommon, public MixPolicy >::Data { - JSValueType unboxedType_; bool strict_; MFallibleStoreElement(MDefinition* object, MDefinition* elements, MDefinition* index, MDefinition* value, - JSValueType unboxedType, bool strict) - : unboxedType_(unboxedType) + bool strict) { initOperand(0, object); initOperand(1, elements); @@ -9644,12 +9526,8 @@ class MFallibleStoreElement TRIVIAL_NEW_WRAPPERS NAMED_OPERANDS((0, object), (1, elements), (2, index), (3, value)) - JSValueType unboxedType() const { - return unboxedType_; - } AliasSet getAliasSet() const override { - return AliasSet::Store(AliasSet::ObjectFields | - AliasSet::BoxedOrUnboxedElements(unboxedType())); + return AliasSet::Store(AliasSet::ObjectFields | AliasSet::Element); } bool strict() const { return strict_; @@ -9754,13 +9632,12 @@ class MArrayPopShift private: Mode mode_; - JSValueType unboxedType_; bool needsHoleCheck_; bool maybeUndefined_; - MArrayPopShift(MDefinition* object, Mode mode, JSValueType unboxedType, + MArrayPopShift(MDefinition* object, Mode mode, bool needsHoleCheck, bool maybeUndefined) - : MUnaryInstruction(object), mode_(mode), unboxedType_(unboxedType), + : MUnaryInstruction(object), mode_(mode), needsHoleCheck_(needsHoleCheck), maybeUndefined_(maybeUndefined) { } @@ -9778,12 +9655,8 @@ class MArrayPopShift bool mode() const { return mode_; } - JSValueType unboxedType() const { - return unboxedType_; - } AliasSet getAliasSet() const override { - return AliasSet::Store(AliasSet::ObjectFields | - AliasSet::BoxedOrUnboxedElements(unboxedType())); + return AliasSet::Store(AliasSet::ObjectFields | AliasSet::Element); } ALLOW_CLONE(MArrayPopShift) @@ -9794,10 +9667,8 @@ class MArrayPush : public MBinaryInstruction, public MixPolicy >::Data { - JSValueType unboxedType_; - - MArrayPush(MDefinition* object, MDefinition* value, JSValueType unboxedType) - : MBinaryInstruction(object, value), unboxedType_(unboxedType) + MArrayPush(MDefinition* object, MDefinition* value) + : MBinaryInstruction(object, value) { setResultType(MIRType::Int32); } @@ -9807,12 +9678,8 @@ class MArrayPush TRIVIAL_NEW_WRAPPERS NAMED_OPERANDS((0, object), (1, value)) - JSValueType unboxedType() const { - return unboxedType_; - } AliasSet getAliasSet() const override { - return AliasSet::Store(AliasSet::ObjectFields | - AliasSet::BoxedOrUnboxedElements(unboxedType())); + return AliasSet::Store(AliasSet::ObjectFields | AliasSet::Element); } void computeRange(TempAllocator& alloc) override; @@ -9826,15 +9693,13 @@ class MArraySlice { CompilerObject templateObj_; gc::InitialHeap initialHeap_; - JSValueType unboxedType_; MArraySlice(CompilerConstraintList* constraints, MDefinition* obj, MDefinition* begin, MDefinition* end, - JSObject* templateObj, gc::InitialHeap initialHeap, JSValueType unboxedType) + JSObject* templateObj, gc::InitialHeap initialHeap) : MTernaryInstruction(obj, begin, end), templateObj_(templateObj), - initialHeap_(initialHeap), - unboxedType_(unboxedType) + initialHeap_(initialHeap) { setResultType(MIRType::Object); } @@ -12224,15 +12089,13 @@ class MInArray { bool needsHoleCheck_; bool needsNegativeIntCheck_; - JSValueType unboxedType_; MInArray(MDefinition* elements, MDefinition* index, MDefinition* initLength, MDefinition* object, - bool needsHoleCheck, JSValueType unboxedType) + bool needsHoleCheck) : MQuaternaryInstruction(elements, index, initLength, object), needsHoleCheck_(needsHoleCheck), - needsNegativeIntCheck_(true), - unboxedType_(unboxedType) + needsNegativeIntCheck_(true) { setResultType(MIRType::Boolean); setMovable(); @@ -12252,9 +12115,6 @@ class MInArray bool needsNegativeIntCheck() const { return needsNegativeIntCheck_; } - JSValueType unboxedType() const { - return unboxedType_; - } void collectRangeInfoPreTrunc() override; AliasSet getAliasSet() const override { return AliasSet::Load(AliasSet::Element); @@ -12267,8 +12127,6 @@ class MInArray return false; if (needsNegativeIntCheck() != other->needsNegativeIntCheck()) return false; - if (unboxedType() != other->unboxedType()) - return false; return congruentIfOperandsEqual(other); } }; @@ -14169,8 +14027,6 @@ MDefinition::maybeConstantValue() bool ElementAccessIsDenseNative(CompilerConstraintList* constraints, MDefinition* obj, MDefinition* id); -JSValueType UnboxedArrayElementType(CompilerConstraintList* constraints, MDefinition* obj, - MDefinition* id); bool ElementAccessIsTypedArray(CompilerConstraintList* constraints, MDefinition* obj, MDefinition* id, Scalar::Type* arrayType); diff --git a/js/src/jit/MOpcodes.h b/js/src/jit/MOpcodes.h index b80d1baf9..ab37604b4 100644 --- a/js/src/jit/MOpcodes.h +++ b/js/src/jit/MOpcodes.h @@ -198,10 +198,6 @@ namespace jit { _(SetTypedObjectOffset) \ _(InitializedLength) \ _(SetInitializedLength) \ - _(UnboxedArrayLength) \ - _(UnboxedArrayInitializedLength) \ - _(IncrementUnboxedArrayInitializedLength) \ - _(SetUnboxedArrayInitializedLength) \ _(Not) \ _(BoundsCheck) \ _(BoundsCheckLower) \ diff --git a/js/src/jit/MacroAssembler.cpp b/js/src/jit/MacroAssembler.cpp index f633b9b7b..e50f68722 100644 --- a/js/src/jit/MacroAssembler.cpp +++ b/js/src/jit/MacroAssembler.cpp @@ -705,31 +705,6 @@ template void MacroAssembler::storeUnboxedProperty(BaseIndex address, JSValueType type, const ConstantOrRegister& value, Label* failure); -void -MacroAssembler::checkUnboxedArrayCapacity(Register obj, const RegisterOrInt32Constant& index, - Register temp, Label* failure) -{ - Address initLengthAddr(obj, UnboxedArrayObject::offsetOfCapacityIndexAndInitializedLength()); - Address lengthAddr(obj, UnboxedArrayObject::offsetOfLength()); - - Label capacityIsIndex, done; - load32(initLengthAddr, temp); - branchTest32(Assembler::NonZero, temp, Imm32(UnboxedArrayObject::CapacityMask), &capacityIsIndex); - branch32(Assembler::BelowOrEqual, lengthAddr, index, failure); - jump(&done); - bind(&capacityIsIndex); - - // Do a partial shift so that we can get an absolute offset from the base - // of CapacityArray to use. - JS_STATIC_ASSERT(sizeof(UnboxedArrayObject::CapacityArray[0]) == 4); - rshiftPtr(Imm32(UnboxedArrayObject::CapacityShift - 2), temp); - and32(Imm32(~0x3), temp); - - addPtr(ImmPtr(&UnboxedArrayObject::CapacityArray), temp); - branch32(Assembler::BelowOrEqual, Address(temp, 0), index, failure); - bind(&done); -} - // Inlined version of gc::CheckAllocatorState that checks the bare essentials // and bails for anything that cannot be handled with our jit allocators. void @@ -1281,16 +1256,6 @@ MacroAssembler::initGCThing(Register obj, Register temp, JSObject* templateObj, storePtr(ImmWord(0), Address(obj, UnboxedPlainObject::offsetOfExpando())); if (initContents) initUnboxedObjectContents(obj, &templateObj->as()); - } else if (templateObj->is()) { - MOZ_ASSERT(templateObj->as().hasInlineElements()); - int elementsOffset = UnboxedArrayObject::offsetOfInlineElements(); - computeEffectiveAddress(Address(obj, elementsOffset), temp); - storePtr(temp, Address(obj, UnboxedArrayObject::offsetOfElements())); - store32(Imm32(templateObj->as().length()), - Address(obj, UnboxedArrayObject::offsetOfLength())); - uint32_t capacityIndex = templateObj->as().capacityIndex(); - store32(Imm32(capacityIndex << UnboxedArrayObject::CapacityShift), - Address(obj, UnboxedArrayObject::offsetOfCapacityIndexAndInitializedLength())); } else { MOZ_CRASH("Unknown object"); } diff --git a/js/src/jit/MacroAssembler.h b/js/src/jit/MacroAssembler.h index b6616321c..6ee989463 100644 --- a/js/src/jit/MacroAssembler.h +++ b/js/src/jit/MacroAssembler.h @@ -1626,7 +1626,7 @@ class MacroAssembler : public MacroAssemblerSpecific void storeToTypedFloatArray(Scalar::Type arrayType, FloatRegister value, const Address& dest, unsigned numElems = 0); - // Load a property from an UnboxedPlainObject or UnboxedArrayObject. + // Load a property from an UnboxedPlainObject. template void loadUnboxedProperty(T address, JSValueType type, TypedOrValueRegister output); @@ -1637,9 +1637,6 @@ class MacroAssembler : public MacroAssemblerSpecific void storeUnboxedProperty(T address, JSValueType type, const ConstantOrRegister& value, Label* failure); - void checkUnboxedArrayCapacity(Register obj, const RegisterOrInt32Constant& index, - Register temp, Label* failure); - Register extractString(const Address& address, Register scratch) { return extractObject(address, scratch); } diff --git a/js/src/jit/ScalarReplacement.cpp b/js/src/jit/ScalarReplacement.cpp index 2065c0371..be9ceee2e 100644 --- a/js/src/jit/ScalarReplacement.cpp +++ b/js/src/jit/ScalarReplacement.cpp @@ -795,11 +795,6 @@ IsArrayEscaped(MInstruction* ins) return true; } - if (obj->is()) { - JitSpew(JitSpew_Escape, "Template object is an unboxed plain object."); - return true; - } - if (length >= 16) { JitSpew(JitSpew_Escape, "Array has too many elements"); return true; diff --git a/js/src/jit/SharedIC.cpp b/js/src/jit/SharedIC.cpp index 2475dfb22..313957462 100644 --- a/js/src/jit/SharedIC.cpp +++ b/js/src/jit/SharedIC.cpp @@ -286,11 +286,6 @@ ICStub::trace(JSTracer* trc) TraceEdge(trc, &getElemStub->shape(), "baseline-getelem-dense-shape"); break; } - case ICStub::GetElem_UnboxedArray: { - ICGetElem_UnboxedArray* getElemStub = toGetElem_UnboxedArray(); - TraceEdge(trc, &getElemStub->group(), "baseline-getelem-unboxed-array-group"); - break; - } case ICStub::GetElem_TypedArray: { ICGetElem_TypedArray* getElemStub = toGetElem_TypedArray(); TraceEdge(trc, &getElemStub->shape(), "baseline-getelem-typedarray-shape"); @@ -2250,7 +2245,6 @@ IsCacheableProtoChain(JSObject* obj, JSObject* holder, bool isDOMProxy) if (obj == holder) return false; if (!obj->is() && - !obj->is() && !obj->is()) { return false; @@ -2582,9 +2576,6 @@ CheckHasNoSuchProperty(JSContext* cx, JSObject* obj, PropertyName* name, } else if (curObj->is()) { if (curObj->as().containsUnboxedOrExpandoProperty(cx, NameToId(name))) return false; - } else if (curObj->is()) { - if (name == cx->names().length) - return false; } else if (curObj->is()) { if (curObj->as().typeDescr().hasProperty(cx->names(), NameToId(name))) return false; diff --git a/js/src/jit/VMFunctions.cpp b/js/src/jit/VMFunctions.cpp index 77b9e3647..0717bb86d 100644 --- a/js/src/jit/VMFunctions.cpp +++ b/js/src/jit/VMFunctions.cpp @@ -318,7 +318,7 @@ ArraySpliceDense(JSContext* cx, HandleObject obj, uint32_t start, uint32_t delet bool ArrayPopDense(JSContext* cx, HandleObject obj, MutableHandleValue rval) { - MOZ_ASSERT(obj->is() || obj->is()); + MOZ_ASSERT(obj->is()); AutoDetectInvalidation adi(cx, rval); @@ -341,8 +341,8 @@ ArrayPushDense(JSContext* cx, HandleObject obj, HandleValue v, uint32_t* length) { *length = GetAnyBoxedOrUnboxedArrayLength(obj); DenseElementResult result = - SetOrExtendAnyBoxedOrUnboxedDenseElements(cx, obj, *length, v.address(), 1, - ShouldUpdateTypes::DontUpdate); + SetOrExtendBoxedOrUnboxedDenseElements(cx, obj, *length, v.address(), 1, + ShouldUpdateTypes::DontUpdate); if (result != DenseElementResult::Incomplete) { (*length)++; return result == DenseElementResult::Success; @@ -362,7 +362,7 @@ ArrayPushDense(JSContext* cx, HandleObject obj, HandleValue v, uint32_t* length) bool ArrayShiftDense(JSContext* cx, HandleObject obj, MutableHandleValue rval) { - MOZ_ASSERT(obj->is() || obj->is()); + MOZ_ASSERT(obj->is()); AutoDetectInvalidation adi(cx, rval); @@ -1151,8 +1151,8 @@ SetDenseOrUnboxedArrayElement(JSContext* cx, HandleObject obj, int32_t index, // no type changes are needed. DenseElementResult result = - SetOrExtendAnyBoxedOrUnboxedDenseElements(cx, obj, index, value.address(), 1, - ShouldUpdateTypes::DontUpdate); + SetOrExtendBoxedOrUnboxedDenseElements(cx, obj, index, value.address(), 1, + ShouldUpdateTypes::DontUpdate); if (result != DenseElementResult::Incomplete) return result == DenseElementResult::Success; diff --git a/js/src/jit/shared/LIR-shared.h b/js/src/jit/shared/LIR-shared.h index f386d5256..35c7e7442 100644 --- a/js/src/jit/shared/LIR-shared.h +++ b/js/src/jit/shared/LIR-shared.h @@ -5165,72 +5165,6 @@ class LSetInitializedLength : public LInstructionHelper<0, 2, 0> } }; -class LUnboxedArrayLength : public LInstructionHelper<1, 1, 0> -{ - public: - LIR_HEADER(UnboxedArrayLength) - - explicit LUnboxedArrayLength(const LAllocation& object) { - setOperand(0, object); - } - - const LAllocation* object() { - return getOperand(0); - } -}; - -class LUnboxedArrayInitializedLength : public LInstructionHelper<1, 1, 0> -{ - public: - LIR_HEADER(UnboxedArrayInitializedLength) - - explicit LUnboxedArrayInitializedLength(const LAllocation& object) { - setOperand(0, object); - } - - const LAllocation* object() { - return getOperand(0); - } -}; - -class LIncrementUnboxedArrayInitializedLength : public LInstructionHelper<0, 1, 0> -{ - public: - LIR_HEADER(IncrementUnboxedArrayInitializedLength) - - explicit LIncrementUnboxedArrayInitializedLength(const LAllocation& object) { - setOperand(0, object); - } - - const LAllocation* object() { - return getOperand(0); - } -}; - -class LSetUnboxedArrayInitializedLength : public LInstructionHelper<0, 2, 1> -{ - public: - LIR_HEADER(SetUnboxedArrayInitializedLength) - - explicit LSetUnboxedArrayInitializedLength(const LAllocation& object, - const LAllocation& length, - const LDefinition& temp) { - setOperand(0, object); - setOperand(1, length); - setTemp(0, temp); - } - - const LAllocation* object() { - return getOperand(0); - } - const LAllocation* length() { - return getOperand(1); - } - const LDefinition* temp() { - return getTemp(0); - } -}; - // Load the length from an elements header. class LArrayLength : public LInstructionHelper<1, 1, 0> { diff --git a/js/src/jit/shared/LOpcodes-shared.h b/js/src/jit/shared/LOpcodes-shared.h index 6912e8904..deae92839 100644 --- a/js/src/jit/shared/LOpcodes-shared.h +++ b/js/src/jit/shared/LOpcodes-shared.h @@ -267,10 +267,6 @@ _(PostWriteElementBarrierV) \ _(InitializedLength) \ _(SetInitializedLength) \ - _(UnboxedArrayLength) \ - _(UnboxedArrayInitializedLength) \ - _(IncrementUnboxedArrayInitializedLength) \ - _(SetUnboxedArrayInitializedLength) \ _(BoundsCheck) \ _(BoundsCheckRange) \ _(BoundsCheckLower) \ diff --git a/js/src/jsarray.cpp b/js/src/jsarray.cpp index 7a67c0095..190439d4b 100644 --- a/js/src/jsarray.cpp +++ b/js/src/jsarray.cpp @@ -64,7 +64,7 @@ using JS::ToUint32; bool JS::IsArray(JSContext* cx, HandleObject obj, IsArrayAnswer* answer) { - if (obj->is() || obj->is()) { + if (obj->is()) { *answer = IsArrayAnswer::Array; return true; } @@ -100,11 +100,6 @@ js::GetLengthProperty(JSContext* cx, HandleObject obj, uint32_t* lengthp) return true; } - if (obj->is()) { - *lengthp = obj->as().length(); - return true; - } - if (obj->is()) { ArgumentsObject& argsobj = obj->as(); if (!argsobj.hasOverriddenLength()) { @@ -284,7 +279,7 @@ ElementAdder::append(JSContext* cx, HandleValue v) MOZ_ASSERT(index_ < length_); if (resObj_) { DenseElementResult result = - SetOrExtendAnyBoxedOrUnboxedDenseElements(cx, resObj_, index_, v.address(), 1); + SetOrExtendBoxedOrUnboxedDenseElements(cx, resObj_, index_, v.address(), 1); if (result == DenseElementResult::Failure) return false; if (result == DenseElementResult::Incomplete) { @@ -342,11 +337,11 @@ GetBoxedOrUnboxedDenseElements(JSObject* aobj, uint32_t length, Value* vp) { MOZ_ASSERT(!ObjectMayHaveExtraIndexedProperties(aobj)); - if (length > GetBoxedOrUnboxedInitializedLength(aobj)) + if (length > GetBoxedOrUnboxedInitializedLength(aobj)) return DenseElementResult::Incomplete; for (size_t i = 0; i < length; i++) { - vp[i] = GetBoxedOrUnboxedDenseElement(aobj, i); + vp[i] = GetBoxedOrUnboxedDenseElement(aobj, i); // No other indexed properties so hole => undefined. if (vp[i].isMagic(JS_ELEMENTS_HOLE)) @@ -398,7 +393,7 @@ SetArrayElement(JSContext* cx, HandleObject obj, double index, HandleValue v) { MOZ_ASSERT(index >= 0); - if ((obj->is() || obj->is()) && !obj->isIndexed() && index <= UINT32_MAX) { + if (obj->is() && !obj->isIndexed() && index <= UINT32_MAX) { DenseElementResult result = SetOrExtendAnyBoxedOrUnboxedDenseElements(cx, obj, uint32_t(index), v.address(), 1); if (result != DenseElementResult::Incomplete) @@ -823,7 +818,7 @@ array_addProperty(JSContext* cx, HandleObject obj, HandleId id, HandleValue v) static inline bool ObjectMayHaveExtraIndexedOwnProperties(JSObject* obj) { - return (!obj->isNative() && !obj->is()) || + return !obj->isNative() || obj->isIndexed() || obj->is() || ClassMayResolveId(*obj->runtimeFromAnyThread()->commonNames, @@ -1288,10 +1283,6 @@ array_toLocaleString(JSContext* cx, unsigned argc, Value* vp) args.rval().setString(cx->names().empty); return true; } - if (obj->is() && obj->as().length() == 0) { - args.rval().setString(cx->names().empty); - return true; - } AutoCycleDetector detector(cx, obj); if (!detector.init()) @@ -1371,46 +1362,38 @@ ArrayReverseDenseKernel(JSContext* cx, HandleObject obj, uint32_t length) if (length == 0 || GetBoxedOrUnboxedInitializedLength(obj) == 0) return DenseElementResult::Success; - if (Type == JSVAL_TYPE_MAGIC) { - if (obj->as().denseElementsAreFrozen()) - return DenseElementResult::Incomplete; + if (obj->as().denseElementsAreFrozen()) + return DenseElementResult::Incomplete; - /* - * It's actually surprisingly complicated to reverse an array due to the - * orthogonality of array length and array capacity while handling - * leading and trailing holes correctly. Reversing seems less likely to - * be a common operation than other array mass-mutation methods, so for - * now just take a probably-small memory hit (in the absence of too many - * holes in the array at its start) and ensure that the capacity is - * sufficient to hold all the elements in the array if it were full. - */ - DenseElementResult result = obj->as().ensureDenseElements(cx, length, 0); - if (result != DenseElementResult::Success) - return result; + /* + * It's actually surprisingly complicated to reverse an array due to the + * orthogonality of array length and array capacity while handling + * leading and trailing holes correctly. Reversing seems less likely to + * be a common operation than other array mass-mutation methods, so for + * now just take a probably-small memory hit (in the absence of too many + * holes in the array at its start) and ensure that the capacity is + * sufficient to hold all the elements in the array if it were full. + */ + DenseElementResult result = obj->as().ensureDenseElements(cx, length, 0); + if (result != DenseElementResult::Success) + return result; - /* Fill out the array's initialized length to its proper length. */ - obj->as().ensureDenseInitializedLength(cx, length, 0); - } else { - // Unboxed arrays can only be reversed here if their initialized length - // matches their actual length. Otherwise the reversal will place holes - // at the beginning of the array, which we don't support. - if (length != obj->as().initializedLength()) - return DenseElementResult::Incomplete; - } + /* Fill out the array's initialized length to its proper length. */ + obj->as().ensureDenseInitializedLength(cx, length, 0); RootedValue origlo(cx), orighi(cx); uint32_t lo = 0, hi = length - 1; for (; lo < hi; lo++, hi--) { - origlo = GetBoxedOrUnboxedDenseElement(obj, lo); - orighi = GetBoxedOrUnboxedDenseElement(obj, hi); - SetBoxedOrUnboxedDenseElementNoTypeChange(obj, lo, orighi); + origlo = GetBoxedOrUnboxedDenseElement(obj, lo); + orighi = GetBoxedOrUnboxedDenseElement(obj, hi); + SetBoxedOrUnboxedDenseElementNoTypeChange(obj, lo, orighi); if (orighi.isMagic(JS_ELEMENTS_HOLE) && !SuppressDeletedProperty(cx, obj, INT_TO_JSID(lo))) { return DenseElementResult::Failure; } - SetBoxedOrUnboxedDenseElementNoTypeChange(obj, hi, origlo); + SetBoxedOrUnboxedDenseElementNoTypeChange(obj, hi, origlo); if (origlo.isMagic(JS_ELEMENTS_HOLE) && !SuppressDeletedProperty(cx, obj, INT_TO_JSID(hi))) { @@ -2082,8 +2065,8 @@ js::array_push(JSContext* cx, unsigned argc, Value* vp) if (!ObjectMayHaveExtraIndexedProperties(obj)) { DenseElementResult result = - SetOrExtendAnyBoxedOrUnboxedDenseElements(cx, obj, length, - args.array(), args.length()); + SetOrExtendBoxedOrUnboxedDenseElements(cx, obj, length, + args.array(), args.length()); if (result != DenseElementResult::Incomplete) { if (result == DenseElementResult::Failure) return false; @@ -2158,21 +2141,15 @@ template static inline DenseElementResult ShiftMoveBoxedOrUnboxedDenseElements(JSObject* obj) { - MOZ_ASSERT(HasBoxedOrUnboxedDenseElements(obj)); + MOZ_ASSERT(HasBoxedOrUnboxedDenseElements(obj)); /* * At this point the length and initialized length have already been * decremented and the result fetched, so just shift the array elements * themselves. */ - size_t initlen = GetBoxedOrUnboxedInitializedLength(obj); - if (Type == JSVAL_TYPE_MAGIC) { - obj->as().moveDenseElementsNoPreBarrier(0, 1, initlen); - } else { - uint8_t* data = obj->as().elements(); - size_t elementSize = UnboxedTypeSize(Type); - memmove(data, data + elementSize, initlen * elementSize); - } + size_t initlen = GetBoxedOrUnboxedInitializedLength(obj); + obj->as().moveDenseElementsNoPreBarrier(0, 1, initlen); return DenseElementResult::Success; } @@ -2202,19 +2179,19 @@ ArrayShiftDenseKernel(JSContext* cx, HandleObject obj, MutableHandleValue rval) if (MOZ_UNLIKELY(group->hasAllFlags(OBJECT_FLAG_ITERATED))) return DenseElementResult::Incomplete; - size_t initlen = GetBoxedOrUnboxedInitializedLength(obj); + size_t initlen = GetBoxedOrUnboxedInitializedLength(obj); if (initlen == 0) return DenseElementResult::Incomplete; - rval.set(GetBoxedOrUnboxedDenseElement(obj, 0)); + rval.set(GetBoxedOrUnboxedDenseElement(obj, 0)); if (rval.isMagic(JS_ELEMENTS_HOLE)) rval.setUndefined(); - DenseElementResult result = MoveBoxedOrUnboxedDenseElements(cx, obj, 0, 1, initlen - 1); + DenseElementResult result = MoveBoxedOrUnboxedDenseElements(cx, obj, 0, 1, initlen - 1); if (result != DenseElementResult::Success) return result; - SetBoxedOrUnboxedInitializedLength(cx, obj, initlen - 1); + SetBoxedOrUnboxedInitializedLength(cx, obj, initlen - 1); return DenseElementResult::Success; } @@ -2520,7 +2497,7 @@ js::array_splice_impl(JSContext* cx, unsigned argc, Value* vp, bool returnValueI /* Steps 10-11. */ DebugOnly result = - CopyAnyBoxedOrUnboxedDenseElements(cx, arr, obj, 0, actualStart, actualDeleteCount); + CopyBoxedOrUnboxedDenseElements(cx, arr, obj, 0, actualStart, actualDeleteCount); MOZ_ASSERT(result.value == DenseElementResult::Success); /* Step 12 (implicit). */ @@ -2557,14 +2534,14 @@ js::array_splice_impl(JSContext* cx, unsigned argc, Value* vp, bool returnValueI if (CanOptimizeForDenseStorage(obj, 0, len, cx)) { /* Steps 15.a-b. */ DenseElementResult result = - MoveAnyBoxedOrUnboxedDenseElements(cx, obj, targetIndex, sourceIndex, - len - sourceIndex); + MoveBoxedOrUnboxedDenseElements(cx, obj, targetIndex, sourceIndex, + len - sourceIndex); MOZ_ASSERT(result != DenseElementResult::Incomplete); if (result == DenseElementResult::Failure) return false; /* Steps 15.c-d. */ - SetAnyBoxedOrUnboxedInitializedLength(cx, obj, finalLength); + SetBoxedOrUnboxedInitializedLength(cx, obj, finalLength); } else { /* * This is all very slow if the length is very large. We don't yet @@ -2644,15 +2621,15 @@ js::array_splice_impl(JSContext* cx, unsigned argc, Value* vp, bool returnValueI if (CanOptimizeForDenseStorage(obj, len, itemCount - actualDeleteCount, cx)) { DenseElementResult result = - MoveAnyBoxedOrUnboxedDenseElements(cx, obj, actualStart + itemCount, - actualStart + actualDeleteCount, - len - (actualStart + actualDeleteCount)); + MoveBoxedOrUnboxedDenseElements(cx, obj, actualStart + itemCount, + actualStart + actualDeleteCount, + len - (actualStart + actualDeleteCount)); MOZ_ASSERT(result != DenseElementResult::Incomplete); if (result == DenseElementResult::Failure) return false; /* Steps 16.a-b. */ - SetAnyBoxedOrUnboxedInitializedLength(cx, obj, len + itemCount - actualDeleteCount); + SetBoxedOrUnboxedInitializedLength(cx, obj, len + itemCount - actualDeleteCount); } else { RootedValue fromValue(cx); for (double k = len - actualDeleteCount; k > actualStart; k--) { @@ -3022,14 +2999,14 @@ ArraySliceDenseKernel(JSContext* cx, JSObject* obj, int32_t beginArg, int32_t en if (begin > end) begin = end; - size_t initlen = GetBoxedOrUnboxedInitializedLength(obj); + size_t initlen = GetBoxedOrUnboxedInitializedLength(obj); if (initlen > begin) { size_t count = Min(initlen - begin, end - begin); if (count) { - DenseElementResult rv = EnsureBoxedOrUnboxedDenseElements(cx, result, count); + DenseElementResult rv = EnsureBoxedOrUnboxedDenseElements(cx, result, count); if (rv != DenseElementResult::Success) return rv; - CopyBoxedOrUnboxedDenseElements(cx, result, obj, 0, begin, count); + CopyBoxedOrUnboxedDenseElements(cx, result, obj, 0, begin, count); } } @@ -3589,12 +3566,6 @@ NewArrayTryUseGroup(ExclusiveContext* cx, HandleObjectGroup group, size_t length newKind = TenuredObject; RootedObject proto(cx, group->proto().toObject()); - if (group->maybeUnboxedLayout()) { - if (length > UnboxedArrayObject::MaximumCapacity) - return NewArray(cx, length, proto, newKind); - return UnboxedArrayObject::create(cx, group, length, newKind, maxLength); - } - ArrayObject* res = NewArray(cx, length, proto, newKind); if (!res) return nullptr; @@ -3701,8 +3672,8 @@ js::MaybeAnalyzeBeforeCreatingLargeArray(ExclusiveContext* cx, HandleObjectGroup if (!obj) return false; DebugOnly result = - SetOrExtendAnyBoxedOrUnboxedDenseElements(cx, obj, 0, vp, nlength, - ShouldUpdateTypes::Update); + SetOrExtendBoxedOrUnboxedDenseElements(cx, obj, 0, vp, nlength, + ShouldUpdateTypes::Update); MOZ_ASSERT(result.value == DenseElementResult::Success); } objects->maybeAnalyze(cx, group, /* forceAnalyze = */ true); @@ -3724,22 +3695,10 @@ js::NewCopiedArrayTryUseGroup(ExclusiveContext* cx, HandleObjectGroup group, return nullptr; DenseElementResult result = - SetOrExtendAnyBoxedOrUnboxedDenseElements(cx, obj, 0, vp, length, updateTypes); + SetOrExtendBoxedOrUnboxedDenseElements(cx, obj, 0, vp, length, updateTypes); if (result == DenseElementResult::Failure) return nullptr; - if (result == DenseElementResult::Success) - return obj; - - MOZ_ASSERT(obj->is()); - if (!UnboxedArrayObject::convertToNative(cx->asJSContext(), obj)) - return nullptr; - - result = SetOrExtendBoxedOrUnboxedDenseElements(cx, obj, 0, vp, length, - updateTypes); - MOZ_ASSERT(result != DenseElementResult::Incomplete); - if (result == DenseElementResult::Failure) - return nullptr; - + MOZ_ASSERT(result == DenseElementResult::Success); return obj; } diff --git a/js/src/jsfriendapi.cpp b/js/src/jsfriendapi.cpp index f5cd56a9b..1fd9d1d28 100644 --- a/js/src/jsfriendapi.cpp +++ b/js/src/jsfriendapi.cpp @@ -271,7 +271,7 @@ js::GetBuiltinClass(JSContext* cx, HandleObject obj, ESClass* cls) if (obj->is() || obj->is()) *cls = ESClass::Object; - else if (obj->is() || obj->is()) + else if (obj->is()) *cls = ESClass::Array; else if (obj->is()) *cls = ESClass::Number; -- cgit v1.2.3 From c8300fbd6ae08925736c32f8b02c980ce1531f3f Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Thu, 23 May 2019 10:51:09 +0000 Subject: Remove UnboxedArray code part 2 --- js/src/gc/Marking.cpp | 2 - js/src/jit/BaselineIC.cpp | 8 +- js/src/jit/BaselineIC.h | 56 +-- js/src/jit/CodeGenerator.cpp | 19 +- js/src/jit/MCallOptimize.cpp | 4 +- js/src/jit/MIR.h | 6 +- js/src/jsarray.cpp | 18 +- js/src/jsobj.cpp | 27 +- js/src/jsobjinlines.h | 2 - js/src/vm/Interpreter-inl.h | 2 +- js/src/vm/Interpreter.cpp | 9 - js/src/vm/ObjectGroup.cpp | 73 +--- js/src/vm/ReceiverGuard.cpp | 8 +- js/src/vm/TypeInference.cpp | 2 +- js/src/vm/UnboxedObject-inl.h | 466 +++--------------------- js/src/vm/UnboxedObject.cpp | 826 +----------------------------------------- js/src/vm/UnboxedObject.h | 207 +---------- 17 files changed, 124 insertions(+), 1611 deletions(-) diff --git a/js/src/gc/Marking.cpp b/js/src/gc/Marking.cpp index 47d2314c1..da3ef7d0d 100644 --- a/js/src/gc/Marking.cpp +++ b/js/src/gc/Marking.cpp @@ -2504,8 +2504,6 @@ js::TenuringTracer::moveObjectToTenured(JSObject* dst, JSObject* src, AllocKind InlineTypedObject::objectMovedDuringMinorGC(this, dst, src); } else if (src->is()) { tenuredSize += TypedArrayObject::objectMovedDuringMinorGC(this, dst, src, dstKind); - } else if (src->is()) { - tenuredSize += UnboxedArrayObject::objectMovedDuringMinorGC(this, dst, src, dstKind); } else if (src->is()) { tenuredSize += ArgumentsObject::objectMovedDuringMinorGC(this, dst, src); } else if (src->is()) { diff --git a/js/src/jit/BaselineIC.cpp b/js/src/jit/BaselineIC.cpp index f43fc5bf9..1d230e083 100644 --- a/js/src/jit/BaselineIC.cpp +++ b/js/src/jit/BaselineIC.cpp @@ -280,6 +280,12 @@ DoTypeUpdateFallback(JSContext* cx, BaselineFrame* frame, ICUpdatedStub* stub, H RootedId id(cx); switch(stub->kind()) { + case ICStub::SetElem_DenseOrUnboxedArray: + case ICStub::SetElem_DenseOrUnboxedArrayAdd: { + id = JSID_VOID; + AddTypePropertyId(cx, obj, id, value); + break; + } case ICStub::SetProp_Native: case ICStub::SetProp_NativeAdd: case ICStub::SetProp_Unboxed: { @@ -5763,7 +5769,7 @@ CopyArray(JSContext* cx, HandleObject obj, MutableHandleValue result) if (!nobj) return false; EnsureArrayGroupAnalyzed(cx, nobj); - CopyAnyBoxedOrUnboxedDenseElements(cx, nobj, obj, 0, 0, length); + CopyBoxedOrUnboxedDenseElements(cx, nobj, obj, 0, 0, length); result.setObject(*nobj); return true; diff --git a/js/src/jit/BaselineIC.h b/js/src/jit/BaselineIC.h index a57556d99..afbea3b69 100644 --- a/js/src/jit/BaselineIC.h +++ b/js/src/jit/BaselineIC.h @@ -892,54 +892,6 @@ class ICGetElem_Dense : public ICMonitoredStub }; }; -class ICGetElem_UnboxedArray : public ICMonitoredStub -{ - friend class ICStubSpace; - - GCPtrObjectGroup group_; - - ICGetElem_UnboxedArray(JitCode* stubCode, ICStub* firstMonitorStub, ObjectGroup* group); - - public: - static ICGetElem_UnboxedArray* Clone(JSContext* cx, ICStubSpace* space, - ICStub* firstMonitorStub, ICGetElem_UnboxedArray& other); - - static size_t offsetOfGroup() { - return offsetof(ICGetElem_UnboxedArray, group_); - } - - GCPtrObjectGroup& group() { - return group_; - } - - class Compiler : public ICStubCompiler { - ICStub* firstMonitorStub_; - RootedObjectGroup group_; - JSValueType elementType_; - - protected: - MOZ_MUST_USE bool generateStubCode(MacroAssembler& masm); - - virtual int32_t getKey() const { - return static_cast(engine_) | - (static_cast(kind) << 1) | - (static_cast(elementType_) << 17); - } - - public: - Compiler(JSContext* cx, ICStub* firstMonitorStub, ObjectGroup* group) - : ICStubCompiler(cx, ICStub::GetElem_UnboxedArray, Engine::Baseline), - firstMonitorStub_(firstMonitorStub), - group_(cx, group), - elementType_(group->unboxedLayoutDontCheckGeneration().elementType()) - {} - - ICStub* getStub(ICStubSpace* space) { - return newStub(space, getStubCode(), firstMonitorStub_, group_); - } - }; -}; - // Accesses scalar elements of a typed array or typed object. class ICGetElem_TypedArray : public ICStub { @@ -1115,9 +1067,7 @@ class ICSetElem_DenseOrUnboxedArray : public ICUpdatedStub : ICStubCompiler(cx, ICStub::SetElem_DenseOrUnboxedArray, Engine::Baseline), shape_(cx, shape), group_(cx, group), - unboxedType_(shape - ? JSVAL_TYPE_MAGIC - : group->unboxedLayoutDontCheckGeneration().elementType()) + unboxedType_(JSVAL_TYPE_MAGIC) {} ICUpdatedStub* getStub(ICStubSpace* space) { @@ -1225,9 +1175,7 @@ class ICSetElemDenseOrUnboxedArrayAddCompiler : public ICStubCompiler { : ICStubCompiler(cx, ICStub::SetElem_DenseOrUnboxedArrayAdd, Engine::Baseline), obj_(cx, obj), protoChainDepth_(protoChainDepth), - unboxedType_(obj->is() - ? obj->as().elementType() - : JSVAL_TYPE_MAGIC) + unboxedType_(JSVAL_TYPE_MAGIC) {} template diff --git a/js/src/jit/CodeGenerator.cpp b/js/src/jit/CodeGenerator.cpp index bd275a2c1..485e881fe 100644 --- a/js/src/jit/CodeGenerator.cpp +++ b/js/src/jit/CodeGenerator.cpp @@ -10336,22 +10336,11 @@ CodeGenerator::visitLoadElementHole(LLoadElementHole* lir) else masm.branch32(Assembler::BelowOrEqual, initLength, ToRegister(lir->index()), &undefined); - if (mir->unboxedType() != JSVAL_TYPE_MAGIC) { - size_t width = UnboxedTypeSize(mir->unboxedType()); - if (lir->index()->isConstant()) { - Address addr(elements, ToInt32(lir->index()) * width); - masm.loadUnboxedProperty(addr, mir->unboxedType(), out); - } else { - BaseIndex addr(elements, ToRegister(lir->index()), ScaleFromElemWidth(width)); - masm.loadUnboxedProperty(addr, mir->unboxedType(), out); - } + if (lir->index()->isConstant()) { + NativeObject::elementsSizeMustNotOverflow(); + masm.loadValue(Address(elements, ToInt32(lir->index()) * sizeof(Value)), out); } else { - if (lir->index()->isConstant()) { - NativeObject::elementsSizeMustNotOverflow(); - masm.loadValue(Address(elements, ToInt32(lir->index()) * sizeof(Value)), out); - } else { - masm.loadValue(BaseObjectElementIndex(elements, ToRegister(lir->index())), out); - } + masm.loadValue(BaseObjectElementIndex(elements, ToRegister(lir->index())), out); } // If a hole check is needed, and the value wasn't a hole, we're done. diff --git a/js/src/jit/MCallOptimize.cpp b/js/src/jit/MCallOptimize.cpp index 7283497ea..748a70973 100644 --- a/js/src/jit/MCallOptimize.cpp +++ b/js/src/jit/MCallOptimize.cpp @@ -541,7 +541,7 @@ IonBuilder::inlineArray(CallInfo& callInfo) if (!alloc().ensureBallast()) return InliningStatus_Error; MDefinition* value = callInfo.getArg(i); - if (!initializeArrayElement(array, i, /* addResumePoint = */ false)) + if (!initializeArrayElement(array, i, value, /* addResumePoint = */ false)) return InliningStatus_Error; } @@ -578,7 +578,7 @@ IonBuilder::inlineArrayIsArray(CallInfo& callInfo) if (!clasp || clasp->isProxy()) return InliningStatus_NotInlined; - isArray = (clasp == &ArrayObject::class_ || clasp == &UnboxedArrayObject::class_); + isArray = (clasp == &ArrayObject::class_); } pushConstant(BooleanValue(isArray)); diff --git a/js/src/jit/MIR.h b/js/src/jit/MIR.h index cdd737b56..f316827dc 100644 --- a/js/src/jit/MIR.h +++ b/js/src/jit/MIR.h @@ -9245,7 +9245,7 @@ class MLoadElementHole bool needsHoleCheck_; MLoadElementHole(MDefinition* elements, MDefinition* index, MDefinition* initLength, - JSValueType unboxedType, bool needsHoleCheck) + bool needsHoleCheck) : MTernaryInstruction(elements, index, initLength), needsNegativeIntCheck_(true), needsHoleCheck_(needsHoleCheck) @@ -9717,10 +9717,6 @@ class MArraySlice return initialHeap_; } - JSValueType unboxedType() const { - return unboxedType_; - } - bool possiblyCalls() const override { return true; } diff --git a/js/src/jsarray.cpp b/js/src/jsarray.cpp index 190439d4b..fa5ef2ab3 100644 --- a/js/src/jsarray.cpp +++ b/js/src/jsarray.cpp @@ -395,7 +395,7 @@ SetArrayElement(JSContext* cx, HandleObject obj, double index, HandleValue v) if (obj->is() && !obj->isIndexed() && index <= UINT32_MAX) { DenseElementResult result = - SetOrExtendAnyBoxedOrUnboxedDenseElements(cx, obj, uint32_t(index), v.address(), 1); + SetOrExtendBoxedOrUnboxedDenseElements(cx, obj, uint32_t(index), v.address(), 1); if (result != DenseElementResult::Incomplete) return result == DenseElementResult::Success; } @@ -1068,12 +1068,12 @@ ArrayJoinDenseKernel(JSContext* cx, SeparatorOp sepOp, HandleObject obj, uint32_ // length > initLength we rely on the second loop to add the // other elements. MOZ_ASSERT(*numProcessed == 0); - uint32_t initLength = Min(GetBoxedOrUnboxedInitializedLength(obj), length); + uint32_t initLength = Min(GetBoxedOrUnboxedInitializedLength(obj), length); while (*numProcessed < initLength) { if (!CheckForInterrupt(cx)) return DenseElementResult::Failure; - Value elem = GetBoxedOrUnboxedDenseElement(obj, *numProcessed); + Value elem = GetBoxedOrUnboxedDenseElement(obj, *numProcessed); if (elem.isString()) { if (!sb.append(elem.toString())) @@ -1320,7 +1320,7 @@ InitArrayElements(JSContext* cx, HandleObject obj, uint32_t start, if (!ObjectMayHaveExtraIndexedProperties(obj)) { DenseElementResult result = - SetOrExtendAnyBoxedOrUnboxedDenseElements(cx, obj, start, vector, count, updateTypes); + SetOrExtendBoxedOrUnboxedDenseElements(cx, obj, start, vector, count, updateTypes); if (result != DenseElementResult::Incomplete) return result == DenseElementResult::Success; } @@ -1359,7 +1359,7 @@ DenseElementResult ArrayReverseDenseKernel(JSContext* cx, HandleObject obj, uint32_t length) { /* An empty array or an array with no elements is already reversed. */ - if (length == 0 || GetBoxedOrUnboxedInitializedLength(obj) == 0) + if (length == 0 || GetBoxedOrUnboxedInitializedLength(obj) == 0) return DenseElementResult::Success; if (obj->as().denseElementsAreFrozen()) @@ -2074,7 +2074,7 @@ js::array_push(JSContext* cx, unsigned argc, Value* vp) uint32_t newlength = length + args.length(); args.rval().setNumber(newlength); - // SetOrExtendAnyBoxedOrUnboxedDenseElements takes care of updating the + // SetOrExtendBoxedOrUnboxedDenseElements takes care of updating the // length for boxed and unboxed arrays. Handle updates to the length of // non-arrays here. bool isArray; @@ -2360,7 +2360,7 @@ CanOptimizeForDenseStorage(HandleObject arr, uint32_t startingIndex, uint32_t co return false; /* There's no optimizing possible if it's not an array. */ - if (!arr->is() && !arr->is()) + if (!arr->is()) return false; /* If it's a frozen array, always pick the slow path */ @@ -2863,7 +2863,7 @@ ArraySliceOrdinary(JSContext* cx, HandleObject obj, uint32_t length, uint32_t be if (count) { DebugOnly result = - CopyAnyBoxedOrUnboxedDenseElements(cx, narr, obj, 0, begin, count); + CopyBoxedOrUnboxedDenseElements(cx, narr, obj, 0, begin, count); MOZ_ASSERT(result.value == DenseElementResult::Success); } arr.set(narr); @@ -3608,7 +3608,7 @@ static inline JSObject* NewArrayTryReuseGroup(JSContext* cx, JSObject* obj, size_t length, NewObjectKind newKind = GenericObject) { - if (!obj->is() && !obj->is()) + if (!obj->is()) return NewArray(cx, length, nullptr, newKind); if (obj->staticPrototype() != cx->global()->maybeGetArrayPrototype()) diff --git a/js/src/jsobj.cpp b/js/src/jsobj.cpp index f22ecb445..c26a42f48 100644 --- a/js/src/jsobj.cpp +++ b/js/src/jsobj.cpp @@ -1146,7 +1146,7 @@ static bool GetScriptArrayObjectElements(JSContext* cx, HandleObject obj, MutableHandle> values) { MOZ_ASSERT(!obj->isSingleton()); - MOZ_ASSERT(obj->is() || obj->is()); + MOZ_ASSERT(obj->is()); MOZ_ASSERT(!obj->isIndexed()); size_t length = GetAnyBoxedOrUnboxedArrayLength(obj); @@ -1207,11 +1207,10 @@ js::DeepCloneObjectLiteral(JSContext* cx, HandleObject obj, NewObjectKind newKin MOZ_ASSERT_IF(obj->isSingleton(), cx->compartment()->behaviors().getSingletonsAsTemplates()); MOZ_ASSERT(obj->is() || - obj->is() || - obj->is()); + obj->is()); MOZ_ASSERT(newKind != SingletonObject); - if (obj->is() || obj->is()) { + if (obj->is()) { Rooted> values(cx, GCVector(cx)); if (!GetScriptArrayObjectElements(cx, obj, &values)) return nullptr; @@ -1327,9 +1326,8 @@ js::XDRObjectLiteral(XDRState* xdr, MutableHandleObject obj) { if (mode == XDR_ENCODE) { MOZ_ASSERT(obj->is() || - obj->is() || - obj->is()); - isArray = (obj->is() || obj->is()) ? 1 : 0; + obj->is()); + isArray = obj->is() ? 1 : 0; } if (!xdr->codeUint32(&isArray)) @@ -2312,11 +2310,6 @@ js::LookupOwnPropertyPure(ExclusiveContext* cx, JSObject* obj, jsid id, Shape** // us the resolve hook won't define a property with this id. if (ClassMayResolveId(cx->names(), obj->getClass(), id, obj)) return false; - } else if (obj->is()) { - if (obj->as().containsProperty(cx, id)) { - MarkNonNativePropertyFound(propp); - return true; - } } else if (obj->is()) { if (obj->as().typeDescr().hasProperty(cx->names(), id)) { MarkNonNativePropertyFound(propp); @@ -3680,16 +3673,6 @@ JSObject::allocKindForTenure(const js::Nursery& nursery) const if (IsProxy(this)) return as().allocKindForTenure(); - // Unboxed arrays use inline data if their size is small enough. - if (is()) { - const UnboxedArrayObject* nobj = &as(); - size_t nbytes = UnboxedArrayObject::offsetOfInlineElements() + - nobj->capacity() * nobj->elementSize(); - if (nbytes <= JSObject::MAX_BYTE_SIZE) - return GetGCObjectKindForBytes(nbytes); - return AllocKind::OBJECT0; - } - // Inlined typed objects are followed by their data, so make sure we copy // it all over to the new object. if (is()) { diff --git a/js/src/jsobjinlines.h b/js/src/jsobjinlines.h index 6be4d0d28..26f9eacce 100644 --- a/js/src/jsobjinlines.h +++ b/js/src/jsobjinlines.h @@ -40,8 +40,6 @@ MaybeConvertUnboxedObjectToNative(ExclusiveContext* cx, JSObject* obj) { if (obj->is()) return UnboxedPlainObject::convertToNative(cx->asJSContext(), obj); - if (obj->is()) - return UnboxedArrayObject::convertToNative(cx->asJSContext(), obj); return true; } diff --git a/js/src/vm/Interpreter-inl.h b/js/src/vm/Interpreter-inl.h index 710f1d89b..a2c8e220a 100644 --- a/js/src/vm/Interpreter-inl.h +++ b/js/src/vm/Interpreter-inl.h @@ -593,7 +593,7 @@ InitArrayElemOperation(JSContext* cx, jsbytecode* pc, HandleObject obj, uint32_t JSOp op = JSOp(*pc); MOZ_ASSERT(op == JSOP_INITELEM_ARRAY || op == JSOP_INITELEM_INC); - MOZ_ASSERT(obj->is() || obj->is()); + MOZ_ASSERT(obj->is()); if (op == JSOP_INITELEM_INC && index == INT32_MAX) { JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_SPREAD_TOO_LARGE); diff --git a/js/src/vm/Interpreter.cpp b/js/src/vm/Interpreter.cpp index 3cf2deb83..7d05b2d4c 100644 --- a/js/src/vm/Interpreter.cpp +++ b/js/src/vm/Interpreter.cpp @@ -5001,9 +5001,6 @@ js::NewArrayOperation(JSContext* cx, HandleScript script, jsbytecode* pc, uint32 if (group->shouldPreTenure() || group->maybePreliminaryObjects()) newKind = TenuredObject; - - if (group->maybeUnboxedLayout()) - return UnboxedArrayObject::create(cx, group, length, newKind); } ArrayObject* obj = NewDenseFullyAllocatedArray(cx, length, nullptr, newKind); @@ -5029,12 +5026,6 @@ js::NewArrayOperationWithTemplate(JSContext* cx, HandleObject templateObject) NewObjectKind newKind = templateObject->group()->shouldPreTenure() ? TenuredObject : GenericObject; - if (templateObject->is()) { - uint32_t length = templateObject->as().length(); - RootedObjectGroup group(cx, templateObject->group()); - return UnboxedArrayObject::create(cx, group, length, newKind); - } - ArrayObject* obj = NewDenseFullyAllocatedArray(cx, templateObject->as().length(), nullptr, newKind); if (!obj) diff --git a/js/src/vm/ObjectGroup.cpp b/js/src/vm/ObjectGroup.cpp index 46159a972..a227b7c9c 100644 --- a/js/src/vm/ObjectGroup.cpp +++ b/js/src/vm/ObjectGroup.cpp @@ -861,32 +861,6 @@ ObjectGroup::newArrayObject(ExclusiveContext* cx, return nullptr; if (group->maybePreliminaryObjects()) group->maybePreliminaryObjects()->maybeAnalyze(cx, group); - if (group->maybeUnboxedLayout()) { - switch (group->unboxedLayout().elementType()) { - case JSVAL_TYPE_BOOLEAN: - if (elementType != TypeSet::BooleanType()) - updateTypes = ShouldUpdateTypes::Update; - break; - case JSVAL_TYPE_INT32: - if (elementType != TypeSet::Int32Type()) - updateTypes = ShouldUpdateTypes::Update; - break; - case JSVAL_TYPE_DOUBLE: - if (elementType != TypeSet::Int32Type() && elementType != TypeSet::DoubleType()) - updateTypes = ShouldUpdateTypes::Update; - break; - case JSVAL_TYPE_STRING: - if (elementType != TypeSet::StringType()) - updateTypes = ShouldUpdateTypes::Update; - break; - case JSVAL_TYPE_OBJECT: - if (elementType != TypeSet::NullType() && !elementType.get().isObjectUnchecked()) - updateTypes = ShouldUpdateTypes::Update; - break; - default: - MOZ_CRASH(); - } - } return NewCopiedArrayTryUseGroup(cx, group, vp, length, newKind, updateTypes); } @@ -897,7 +871,7 @@ GiveObjectGroup(ExclusiveContext* cx, JSObject* source, JSObject* target) { MOZ_ASSERT(source->group() != target->group()); - if (!target->is() && !target->is()) + if (!target->is()) return true; if (target->group()->maybePreliminaryObjects()) { @@ -905,41 +879,21 @@ GiveObjectGroup(ExclusiveContext* cx, JSObject* source, JSObject* target) target->group()->maybePreliminaryObjects()->maybeAnalyze(cx, target->group(), force); } - if (target->is()) { - ObjectGroup* sourceGroup = source->group(); - - if (source->is()) { - Shape* shape = target->as().lastProperty(); - if (!UnboxedArrayObject::convertToNativeWithGroup(cx, source, target->group(), shape)) - return false; - } else if (source->is()) { - source->setGroup(target->group()); - } else { - return true; - } - - if (sourceGroup->maybePreliminaryObjects()) - sourceGroup->maybePreliminaryObjects()->unregisterObject(source); - if (target->group()->maybePreliminaryObjects()) - target->group()->maybePreliminaryObjects()->registerNewObject(source); - - for (size_t i = 0; i < source->as().getDenseInitializedLength(); i++) { - Value v = source->as().getDenseElement(i); - AddTypePropertyId(cx, source->group(), source, JSID_VOID, v); - } + ObjectGroup* sourceGroup = source->group(); + if (source->is()) { + source->setGroup(target->group()); + } else { return true; } - if (target->is()) { - if (!source->is()) - return true; - if (source->as().elementType() != JSVAL_TYPE_INT32) - return true; - if (target->as().elementType() != JSVAL_TYPE_DOUBLE) - return true; - - return source->as().convertInt32ToDouble(cx, target->group()); + if (sourceGroup->maybePreliminaryObjects()) + sourceGroup->maybePreliminaryObjects()->unregisterObject(source); + if (target->group()->maybePreliminaryObjects()) + target->group()->maybePreliminaryObjects()->registerNewObject(source); + for (size_t i = 0; i < source->as().getDenseInitializedLength(); i++) { + Value v = source->as().getDenseElement(i); + AddTypePropertyId(cx, source->group(), source, JSID_VOID, v); } return true; @@ -1503,7 +1457,8 @@ ObjectGroup::allocationSiteGroup(JSContext* cx, JSScript* scriptArg, jsbytecode* } } - if (kind == JSProto_Array && + // FIXME: This block can probably go because of cx->options().unboxedArrays() + if (kind == JSProto_Array && (JSOp(*pc) == JSOP_NEWARRAY || IsCallPC(pc)) && cx->options().unboxedArrays()) { diff --git a/js/src/vm/ReceiverGuard.cpp b/js/src/vm/ReceiverGuard.cpp index 11c2d0727..e37bf8ee5 100644 --- a/js/src/vm/ReceiverGuard.cpp +++ b/js/src/vm/ReceiverGuard.cpp @@ -19,7 +19,7 @@ ReceiverGuard::ReceiverGuard(JSObject* obj) group = obj->group(); if (UnboxedExpandoObject* expando = obj->as().maybeExpando()) shape = expando->lastProperty(); - } else if (obj->is() || obj->is()) { + } else if (obj->is()) { group = obj->group(); } else { shape = obj->maybeShape(); @@ -34,7 +34,7 @@ ReceiverGuard::ReceiverGuard(ObjectGroup* group, Shape* shape) const Class* clasp = group->clasp(); if (clasp == &UnboxedPlainObject::class_) { // Keep both group and shape. - } else if (clasp == &UnboxedArrayObject::class_ || IsTypedObjectClass(clasp)) { + } else if (IsTypedObjectClass(clasp)) { this->shape = nullptr; } else { this->group = nullptr; @@ -49,8 +49,8 @@ HeapReceiverGuard::keyBits(JSObject* obj) // Both the group and shape need to be guarded for unboxed plain objects. return obj->as().maybeExpando() ? 0 : 1; } - if (obj->is() || obj->is()) { - // Only the group needs to be guarded for unboxed arrays and typed objects. + if (obj->is()) { + // Only the group needs to be guarded for typed objects. return 2; } // Other objects only need the shape to be guarded. diff --git a/js/src/vm/TypeInference.cpp b/js/src/vm/TypeInference.cpp index 9e0342382..2160dbc51 100644 --- a/js/src/vm/TypeInference.cpp +++ b/js/src/vm/TypeInference.cpp @@ -2505,7 +2505,7 @@ TemporaryTypeSet::propertyNeedsBarrier(CompilerConstraintList* constraints, jsid bool js::ClassCanHaveExtraProperties(const Class* clasp) { - if (clasp == &UnboxedPlainObject::class_ || clasp == &UnboxedArrayObject::class_) + if (clasp == &UnboxedPlainObject::class_) return false; return clasp->getResolve() || clasp->getOpsLookupProperty() diff --git a/js/src/vm/UnboxedObject-inl.h b/js/src/vm/UnboxedObject-inl.h index 93ad7bf28..499f3604b 100644 --- a/js/src/vm/UnboxedObject-inl.h +++ b/js/src/vm/UnboxedObject-inl.h @@ -172,123 +172,6 @@ UnboxedPlainObject::layout() const return group()->unboxedLayout(); } -///////////////////////////////////////////////////////////////////// -// UnboxedArrayObject -///////////////////////////////////////////////////////////////////// - -inline const UnboxedLayout& -UnboxedArrayObject::layout() const -{ - return group()->unboxedLayout(); -} - -inline void -UnboxedArrayObject::setLength(ExclusiveContext* cx, uint32_t length) -{ - if (length > INT32_MAX) { - // Track objects with overflowing lengths in type information. - MarkObjectGroupFlags(cx, this, OBJECT_FLAG_LENGTH_OVERFLOW); - } - - length_ = length; -} - -inline void -UnboxedArrayObject::setInitializedLength(uint32_t initlen) -{ - if (initlen < initializedLength()) { - switch (elementType()) { - case JSVAL_TYPE_STRING: - for (size_t i = initlen; i < initializedLength(); i++) - triggerPreBarrier(i); - break; - case JSVAL_TYPE_OBJECT: - for (size_t i = initlen; i < initializedLength(); i++) - triggerPreBarrier(i); - break; - default: - MOZ_ASSERT(!UnboxedTypeNeedsPreBarrier(elementType())); - } - } - setInitializedLengthNoBarrier(initlen); -} - -template -inline bool -UnboxedArrayObject::setElementSpecific(ExclusiveContext* cx, size_t index, const Value& v) -{ - MOZ_ASSERT(index < initializedLength()); - MOZ_ASSERT(Type == elementType()); - uint8_t* p = elements() + index * UnboxedTypeSize(Type); - return SetUnboxedValue(cx, this, JSID_VOID, p, elementType(), v, /* preBarrier = */ true); -} - -template -inline void -UnboxedArrayObject::setElementNoTypeChangeSpecific(size_t index, const Value& v) -{ - MOZ_ASSERT(index < initializedLength()); - MOZ_ASSERT(Type == elementType()); - uint8_t* p = elements() + index * UnboxedTypeSize(Type); - return SetUnboxedValueNoTypeChange(this, p, elementType(), v, /* preBarrier = */ true); -} - -template -inline bool -UnboxedArrayObject::initElementSpecific(ExclusiveContext* cx, size_t index, const Value& v) -{ - MOZ_ASSERT(index < initializedLength()); - MOZ_ASSERT(Type == elementType()); - uint8_t* p = elements() + index * UnboxedTypeSize(Type); - return SetUnboxedValue(cx, this, JSID_VOID, p, elementType(), v, /* preBarrier = */ false); -} - -template -inline void -UnboxedArrayObject::initElementNoTypeChangeSpecific(size_t index, const Value& v) -{ - MOZ_ASSERT(index < initializedLength()); - MOZ_ASSERT(Type == elementType()); - uint8_t* p = elements() + index * UnboxedTypeSize(Type); - return SetUnboxedValueNoTypeChange(this, p, elementType(), v, /* preBarrier = */ false); -} - -template -inline Value -UnboxedArrayObject::getElementSpecific(size_t index) -{ - MOZ_ASSERT(index < initializedLength()); - MOZ_ASSERT(Type == elementType()); - uint8_t* p = elements() + index * UnboxedTypeSize(Type); - return GetUnboxedValue(p, Type, /* maybeUninitialized = */ false); -} - -template -inline void -UnboxedArrayObject::triggerPreBarrier(size_t index) -{ - MOZ_ASSERT(UnboxedTypeNeedsPreBarrier(Type)); - - uint8_t* p = elements() + index * UnboxedTypeSize(Type); - - switch (Type) { - case JSVAL_TYPE_STRING: { - JSString** np = reinterpret_cast(p); - JSString::writeBarrierPre(*np); - break; - } - - case JSVAL_TYPE_OBJECT: { - JSObject** np = reinterpret_cast(p); - JSObject::writeBarrierPre(*np); - break; - } - - default: - MOZ_CRASH("Bad type"); - } -} - ///////////////////////////////////////////////////////////////////// // Combined methods for NativeObject and UnboxedArrayObject accesses. ///////////////////////////////////////////////////////////////////// @@ -296,7 +179,7 @@ UnboxedArrayObject::triggerPreBarrier(size_t index) static inline bool HasAnyBoxedOrUnboxedDenseElements(JSObject* obj) { - return obj->isNative() || obj->is(); + return obj->isNative(); } static inline size_t @@ -304,8 +187,6 @@ GetAnyBoxedOrUnboxedInitializedLength(JSObject* obj) { if (obj->isNative()) return obj->as().getDenseInitializedLength(); - if (obj->is()) - return obj->as().initializedLength(); return 0; } @@ -314,57 +195,40 @@ GetAnyBoxedOrUnboxedCapacity(JSObject* obj) { if (obj->isNative()) return obj->as().getDenseCapacity(); - if (obj->is()) - return obj->as().capacity(); return 0; } static inline Value GetAnyBoxedOrUnboxedDenseElement(JSObject* obj, size_t index) { - if (obj->isNative()) - return obj->as().getDenseElement(index); - return obj->as().getElement(index); + return obj->as().getDenseElement(index); } static inline size_t GetAnyBoxedOrUnboxedArrayLength(JSObject* obj) { - if (obj->is()) - return obj->as().length(); - return obj->as().length(); + return obj->as().length(); } static inline void SetAnyBoxedOrUnboxedArrayLength(JSContext* cx, JSObject* obj, size_t length) { - if (obj->is()) { - MOZ_ASSERT(length >= obj->as().length()); - obj->as().setLength(cx, length); - } else { - MOZ_ASSERT(length >= obj->as().length()); - obj->as().setLength(cx, length); - } + MOZ_ASSERT(length >= obj->as().length()); + obj->as().setLength(cx, length); } static inline bool SetAnyBoxedOrUnboxedDenseElement(JSContext* cx, JSObject* obj, size_t index, const Value& value) { - if (obj->isNative()) { - obj->as().setDenseElementWithType(cx, index, value); - return true; - } - return obj->as().setElement(cx, index, value); + obj->as().setDenseElementWithType(cx, index, value); + return true; } static inline bool InitAnyBoxedOrUnboxedDenseElement(JSContext* cx, JSObject* obj, size_t index, const Value& value) { - if (obj->isNative()) { - obj->as().initDenseElementWithType(cx, index, value); - return true; - } - return obj->as().initElement(cx, index, value); + obj->as().initDenseElementWithType(cx, index, value); + return true; } ///////////////////////////////////////////////////////////////////// @@ -374,273 +238,128 @@ InitAnyBoxedOrUnboxedDenseElement(JSContext* cx, JSObject* obj, size_t index, co static inline JSValueType GetBoxedOrUnboxedType(JSObject* obj) { - if (obj->isNative()) - return JSVAL_TYPE_MAGIC; - return obj->as().elementType(); + return JSVAL_TYPE_MAGIC; } -template static inline bool HasBoxedOrUnboxedDenseElements(JSObject* obj) { - if (Type == JSVAL_TYPE_MAGIC) - return obj->isNative(); - return obj->is() && obj->as().elementType() == Type; + return obj->isNative(); } -template static inline size_t GetBoxedOrUnboxedInitializedLength(JSObject* obj) { - if (Type == JSVAL_TYPE_MAGIC) - return obj->as().getDenseInitializedLength(); - return obj->as().initializedLength(); + return obj->as().getDenseInitializedLength(); } -template static inline DenseElementResult SetBoxedOrUnboxedInitializedLength(JSContext* cx, JSObject* obj, size_t initlen) { - size_t oldInitlen = GetBoxedOrUnboxedInitializedLength(obj); - if (Type == JSVAL_TYPE_MAGIC) { - obj->as().setDenseInitializedLength(initlen); - if (initlen < oldInitlen) - obj->as().shrinkElements(cx, initlen); - } else { - obj->as().setInitializedLength(initlen); - if (initlen < oldInitlen) - obj->as().shrinkElements(cx, initlen); - } + size_t oldInitlen = GetBoxedOrUnboxedInitializedLength(obj); + obj->as().setDenseInitializedLength(initlen); + if (initlen < oldInitlen) + obj->as().shrinkElements(cx, initlen); return DenseElementResult::Success; } -template static inline size_t GetBoxedOrUnboxedCapacity(JSObject* obj) { - if (Type == JSVAL_TYPE_MAGIC) - return obj->as().getDenseCapacity(); - return obj->as().capacity(); + return obj->as().getDenseCapacity(); } -template static inline Value GetBoxedOrUnboxedDenseElement(JSObject* obj, size_t index) { - if (Type == JSVAL_TYPE_MAGIC) - return obj->as().getDenseElement(index); - return obj->as().getElementSpecific(index); + return obj->as().getDenseElement(index); } -template static inline void SetBoxedOrUnboxedDenseElementNoTypeChange(JSObject* obj, size_t index, const Value& value) { - if (Type == JSVAL_TYPE_MAGIC) - obj->as().setDenseElement(index, value); - else - obj->as().setElementNoTypeChangeSpecific(index, value); + obj->as().setDenseElement(index, value); } -template static inline bool SetBoxedOrUnboxedDenseElement(JSContext* cx, JSObject* obj, size_t index, const Value& value) { - if (Type == JSVAL_TYPE_MAGIC) { - obj->as().setDenseElementWithType(cx, index, value); - return true; - } - return obj->as().setElementSpecific(cx, index, value); + obj->as().setDenseElementWithType(cx, index, value); + return true; } -template static inline DenseElementResult EnsureBoxedOrUnboxedDenseElements(JSContext* cx, JSObject* obj, size_t count) { - if (Type == JSVAL_TYPE_MAGIC) { - if (!obj->as().ensureElements(cx, count)) - return DenseElementResult::Failure; - } else { - if (obj->as().capacity() < count) { - if (!obj->as().growElements(cx, count)) - return DenseElementResult::Failure; - } - } + if (!obj->as().ensureElements(cx, count)) + return DenseElementResult::Failure; return DenseElementResult::Success; } -template static inline DenseElementResult SetOrExtendBoxedOrUnboxedDenseElements(ExclusiveContext* cx, JSObject* obj, uint32_t start, const Value* vp, uint32_t count, ShouldUpdateTypes updateTypes = ShouldUpdateTypes::Update) { - if (Type == JSVAL_TYPE_MAGIC) { - NativeObject* nobj = &obj->as(); - - if (nobj->denseElementsAreFrozen()) - return DenseElementResult::Incomplete; - - if (obj->is() && - !obj->as().lengthIsWritable() && - start + count >= obj->as().length()) - { - return DenseElementResult::Incomplete; - } - - DenseElementResult result = nobj->ensureDenseElements(cx, start, count); - if (result != DenseElementResult::Success) - return result; - - if (obj->is() && start + count >= obj->as().length()) - obj->as().setLengthInt32(start + count); - - if (updateTypes == ShouldUpdateTypes::DontUpdate && !nobj->shouldConvertDoubleElements()) { - nobj->copyDenseElements(start, vp, count); - } else { - for (size_t i = 0; i < count; i++) - nobj->setDenseElementWithType(cx, start + i, vp[i]); - } - - return DenseElementResult::Success; - } - - UnboxedArrayObject* nobj = &obj->as(); + NativeObject* nobj = &obj->as(); - if (start > nobj->initializedLength()) + if (nobj->denseElementsAreFrozen()) return DenseElementResult::Incomplete; - if (start + count >= UnboxedArrayObject::MaximumCapacity) + if (obj->is() && + !obj->as().lengthIsWritable() && + start + count >= obj->as().length()) + { return DenseElementResult::Incomplete; + } - if (start + count > nobj->capacity() && !nobj->growElements(cx, start + count)) - return DenseElementResult::Failure; + DenseElementResult result = nobj->ensureDenseElements(cx, start, count); + if (result != DenseElementResult::Success) + return result; - size_t oldInitlen = nobj->initializedLength(); - - // Overwrite any existing elements covered by the new range. If we fail - // after this point due to some incompatible type being written to the - // object's elements, afterwards the contents will be different from when - // we started. The caller must retry the operation using a generic path, - // which will overwrite the already-modified elements as well as the ones - // that were left alone. - size_t i = 0; - if (updateTypes == ShouldUpdateTypes::DontUpdate) { - for (size_t j = start; i < count && j < oldInitlen; i++, j++) - nobj->setElementNoTypeChangeSpecific(j, vp[i]); - } else { - for (size_t j = start; i < count && j < oldInitlen; i++, j++) { - if (!nobj->setElementSpecific(cx, j, vp[i])) - return DenseElementResult::Incomplete; - } - } + if (obj->is() && start + count >= obj->as().length()) + obj->as().setLengthInt32(start + count); - if (i != count) { - obj->as().setInitializedLength(start + count); - if (updateTypes == ShouldUpdateTypes::DontUpdate) { - for (; i < count; i++) - nobj->initElementNoTypeChangeSpecific(start + i, vp[i]); - } else { - for (; i < count; i++) { - if (!nobj->initElementSpecific(cx, start + i, vp[i])) { - nobj->setInitializedLengthNoBarrier(oldInitlen); - return DenseElementResult::Incomplete; - } - } - } + if (updateTypes == ShouldUpdateTypes::DontUpdate && !nobj->shouldConvertDoubleElements()) { + nobj->copyDenseElements(start, vp, count); + } else { + for (size_t i = 0; i < count; i++) + nobj->setDenseElementWithType(cx, start + i, vp[i]); } - if (start + count >= nobj->length()) - nobj->setLength(cx, start + count); - return DenseElementResult::Success; } -template static inline DenseElementResult MoveBoxedOrUnboxedDenseElements(JSContext* cx, JSObject* obj, uint32_t dstStart, uint32_t srcStart, uint32_t length) { - MOZ_ASSERT(HasBoxedOrUnboxedDenseElements(obj)); - - if (Type == JSVAL_TYPE_MAGIC) { - if (obj->as().denseElementsAreFrozen()) - return DenseElementResult::Incomplete; + MOZ_ASSERT(HasBoxedOrUnboxedDenseElements(obj)); - if (!obj->as().maybeCopyElementsForWrite(cx)) - return DenseElementResult::Failure; - obj->as().moveDenseElements(dstStart, srcStart, length); - } else { - uint8_t* data = obj->as().elements(); - size_t elementSize = UnboxedTypeSize(Type); - - if (UnboxedTypeNeedsPreBarrier(Type) && - JS::shadow::Zone::asShadowZone(obj->zone())->needsIncrementalBarrier()) - { - // Trigger pre barriers on any elements we are overwriting. See - // NativeObject::moveDenseElements. No post barrier is needed as - // only whole cell post barriers are used with unboxed objects. - for (size_t i = 0; i < length; i++) - obj->as().triggerPreBarrier(dstStart + i); - } + if (obj->as().denseElementsAreFrozen()) + return DenseElementResult::Incomplete; - memmove(data + dstStart * elementSize, - data + srcStart * elementSize, - length * elementSize); - } + if (!obj->as().maybeCopyElementsForWrite(cx)) + return DenseElementResult::Failure; + obj->as().moveDenseElements(dstStart, srcStart, length); return DenseElementResult::Success; } -template static inline DenseElementResult CopyBoxedOrUnboxedDenseElements(JSContext* cx, JSObject* dst, JSObject* src, uint32_t dstStart, uint32_t srcStart, uint32_t length) { - MOZ_ASSERT(HasBoxedOrUnboxedDenseElements(src)); - MOZ_ASSERT(HasBoxedOrUnboxedDenseElements(dst)); - MOZ_ASSERT(GetBoxedOrUnboxedInitializedLength(dst) == dstStart); - MOZ_ASSERT(GetBoxedOrUnboxedInitializedLength(src) >= srcStart + length); - MOZ_ASSERT(GetBoxedOrUnboxedCapacity(dst) >= dstStart + length); - - SetBoxedOrUnboxedInitializedLength(cx, dst, dstStart + length); - - if (DstType == JSVAL_TYPE_MAGIC) { - if (SrcType == JSVAL_TYPE_MAGIC) { - const Value* vp = src->as().getDenseElements() + srcStart; - dst->as().initDenseElements(dstStart, vp, length); - } else { - for (size_t i = 0; i < length; i++) { - Value v = GetBoxedOrUnboxedDenseElement(src, srcStart + i); - dst->as().initDenseElement(dstStart + i, v); - } - } - } else if (DstType == SrcType) { - uint8_t* dstData = dst->as().elements(); - uint8_t* srcData = src->as().elements(); - size_t elementSize = UnboxedTypeSize(DstType); - - memcpy(dstData + dstStart * elementSize, - srcData + srcStart * elementSize, - length * elementSize); - - // Add a store buffer entry if we might have copied a nursery pointer to dst. - if (UnboxedTypeNeedsPostBarrier(DstType) && !IsInsideNursery(dst)) - dst->runtimeFromMainThread()->gc.storeBuffer.putWholeCell(dst); - } else if (DstType == JSVAL_TYPE_DOUBLE && SrcType == JSVAL_TYPE_INT32) { - uint8_t* dstData = dst->as().elements(); - uint8_t* srcData = src->as().elements(); - - for (size_t i = 0; i < length; i++) { - int32_t v = *reinterpret_cast(srcData + (srcStart + i) * sizeof(int32_t)); - *reinterpret_cast(dstData + (dstStart + i) * sizeof(double)) = v; - } - } else { - for (size_t i = 0; i < length; i++) { - Value v = GetBoxedOrUnboxedDenseElement(src, srcStart + i); - dst->as().initElementNoTypeChangeSpecific(dstStart + i, v); - } - } + MOZ_ASSERT(HasBoxedOrUnboxedDenseElements(src)); + MOZ_ASSERT(HasBoxedOrUnboxedDenseElements(dst)); + MOZ_ASSERT(GetBoxedOrUnboxedInitializedLength(dst) == dstStart); + MOZ_ASSERT(GetBoxedOrUnboxedInitializedLength(src) >= srcStart + length); + MOZ_ASSERT(GetBoxedOrUnboxedCapacity(dst) >= dstStart + length); + + SetBoxedOrUnboxedInitializedLength(cx, dst, dstStart + length); + + const Value* vp = src->as().getDenseElements() + srcStart; + dst->as().initDenseElements(dstStart, vp, length); return DenseElementResult::Success; } @@ -666,22 +385,7 @@ CallBoxedOrUnboxedSpecialization(F f, JSObject* obj) { if (!HasAnyBoxedOrUnboxedDenseElements(obj)) return DenseElementResult::Incomplete; - switch (GetBoxedOrUnboxedType(obj)) { - case JSVAL_TYPE_MAGIC: - return f. DEPENDENT_TEMPLATE_HINT operator()(); - case JSVAL_TYPE_BOOLEAN: - return f. DEPENDENT_TEMPLATE_HINT operator()(); - case JSVAL_TYPE_INT32: - return f. DEPENDENT_TEMPLATE_HINT operator()(); - case JSVAL_TYPE_DOUBLE: - return f. DEPENDENT_TEMPLATE_HINT operator()(); - case JSVAL_TYPE_STRING: - return f. DEPENDENT_TEMPLATE_HINT operator()(); - case JSVAL_TYPE_OBJECT: - return f. DEPENDENT_TEMPLATE_HINT operator()(); - default: - MOZ_CRASH(); - } + return f. DEPENDENT_TEMPLATE_HINT operator()(); } // As above, except the specialization can reflect the unboxed type of two objects. @@ -692,42 +396,7 @@ CallBoxedOrUnboxedSpecialization(F f, JSObject* obj1, JSObject* obj2) if (!HasAnyBoxedOrUnboxedDenseElements(obj1) || !HasAnyBoxedOrUnboxedDenseElements(obj2)) return DenseElementResult::Incomplete; -#define SPECIALIZE_OBJ2(TYPE) \ - switch (GetBoxedOrUnboxedType(obj2)) { \ - case JSVAL_TYPE_MAGIC: \ - return f. DEPENDENT_TEMPLATE_HINT operator()(); \ - case JSVAL_TYPE_BOOLEAN: \ - return f. DEPENDENT_TEMPLATE_HINT operator()(); \ - case JSVAL_TYPE_INT32: \ - return f. DEPENDENT_TEMPLATE_HINT operator()(); \ - case JSVAL_TYPE_DOUBLE: \ - return f. DEPENDENT_TEMPLATE_HINT operator()(); \ - case JSVAL_TYPE_STRING: \ - return f. DEPENDENT_TEMPLATE_HINT operator()(); \ - case JSVAL_TYPE_OBJECT: \ - return f. DEPENDENT_TEMPLATE_HINT operator()(); \ - default: \ - MOZ_CRASH(); \ - } - - switch (GetBoxedOrUnboxedType(obj1)) { - case JSVAL_TYPE_MAGIC: - SPECIALIZE_OBJ2(JSVAL_TYPE_MAGIC) - case JSVAL_TYPE_BOOLEAN: - SPECIALIZE_OBJ2(JSVAL_TYPE_BOOLEAN) - case JSVAL_TYPE_INT32: - SPECIALIZE_OBJ2(JSVAL_TYPE_INT32) - case JSVAL_TYPE_DOUBLE: - SPECIALIZE_OBJ2(JSVAL_TYPE_DOUBLE) - case JSVAL_TYPE_STRING: - SPECIALIZE_OBJ2(JSVAL_TYPE_STRING) - case JSVAL_TYPE_OBJECT: - SPECIALIZE_OBJ2(JSVAL_TYPE_OBJECT) - default: - MOZ_CRASH(); - } - -#undef SPECIALIZE_OBJ2 + return f. DEPENDENT_TEMPLATE_HINT operator()(); } #undef DEPENDENT_TEMPLATE_HINT @@ -816,25 +485,6 @@ struct Signature ## Functor { \ } \ } -DenseElementResult -SetOrExtendAnyBoxedOrUnboxedDenseElements(ExclusiveContext* cx, JSObject* obj, - uint32_t start, const Value* vp, uint32_t count, - ShouldUpdateTypes updateTypes = ShouldUpdateTypes::Update); - -DenseElementResult -MoveAnyBoxedOrUnboxedDenseElements(JSContext* cx, JSObject* obj, - uint32_t dstStart, uint32_t srcStart, uint32_t length); - -DenseElementResult -CopyAnyBoxedOrUnboxedDenseElements(JSContext* cx, JSObject* dst, JSObject* src, - uint32_t dstStart, uint32_t srcStart, uint32_t length); - -void -SetAnyBoxedOrUnboxedInitializedLength(JSContext* cx, JSObject* obj, size_t initlen); - -DenseElementResult -EnsureAnyBoxedOrUnboxedDenseElements(JSContext* cx, JSObject* obj, size_t count); - } // namespace js #endif // vm_UnboxedObject_inl_h diff --git a/js/src/vm/UnboxedObject.cpp b/js/src/vm/UnboxedObject.cpp index d7ad91de4..806a9db81 100644 --- a/js/src/vm/UnboxedObject.cpp +++ b/js/src/vm/UnboxedObject.cpp @@ -417,8 +417,6 @@ UnboxedLayout::makeNativeGroup(JSContext* cx, ObjectGroup* group) RootedObjectGroup replacementGroup(cx); - const Class* clasp = layout.isArray() ? &ArrayObject::class_ : &PlainObject::class_; - // Immediately clear any new script on the group. This is done by replacing // the existing new script with one for a replacement default new group. // This is done so that the size of the replacment group's objects is the @@ -426,8 +424,6 @@ UnboxedLayout::makeNativeGroup(JSContext* cx, ObjectGroup* group) // slot accesses later on for sites that see converted objects from this // group and objects that were allocated using the replacement new group. if (layout.newScript()) { - MOZ_ASSERT(!layout.isArray()); - replacementGroup = ObjectGroupCompartment::makeGroup(cx, &PlainObject::class_, proto); if (!replacementGroup) return false; @@ -453,15 +449,14 @@ UnboxedLayout::makeNativeGroup(JSContext* cx, ObjectGroup* group) RootedScript script(cx, layout.allocationScript()); jsbytecode* pc = layout.allocationPc(); - replacementGroup = ObjectGroupCompartment::makeGroup(cx, clasp, proto); + replacementGroup = ObjectGroupCompartment::makeGroup(cx, &PlainObject::class_, proto); if (!replacementGroup) return false; PlainObject* templateObject = &script->getObject(pc)->as(); replacementGroup->addDefiniteProperties(cx, templateObject->lastProperty()); - JSProtoKey key = layout.isArray() ? JSProto_Array : JSProto_Object; - cx->compartment()->objectGroups.replaceAllocationSiteGroup(script, pc, key, + cx->compartment()->objectGroups.replaceAllocationSiteGroup(script, pc, JSProto_Object, replacementGroup); // Clear any baseline information at this opcode which might use the old group. @@ -477,22 +472,12 @@ UnboxedLayout::makeNativeGroup(JSContext* cx, ObjectGroup* group) } } - size_t nfixed = layout.isArray() ? 0 : gc::GetGCKindSlots(layout.getAllocKind()); - - if (layout.isArray()) { - // The length shape to use for arrays is cached via a modified initial - // shape for array objects. Create an array now to make sure this entry - // is instantiated. - if (!NewDenseEmptyArray(cx)) - return false; - } + size_t nfixed = gc::GetGCKindSlots(layout.getAllocKind()); - RootedShape shape(cx, EmptyShape::getInitialShape(cx, clasp, proto, nfixed, 0)); + RootedShape shape(cx, EmptyShape::getInitialShape(cx, &PlainObject::class_, proto, nfixed, 0)); if (!shape) return false; - MOZ_ASSERT_IF(layout.isArray(), !shape->isEmptyShape() && shape->slotSpan() == 0); - // Add shapes for each property, if this is for a plain object. for (size_t i = 0; i < layout.properties().length(); i++) { const UnboxedLayout::Property& property = layout.properties()[i]; @@ -505,7 +490,7 @@ UnboxedLayout::makeNativeGroup(JSContext* cx, ObjectGroup* group) } ObjectGroup* nativeGroup = - ObjectGroupCompartment::makeGroup(cx, clasp, proto, + ObjectGroupCompartment::makeGroup(cx, &PlainObject::class_, proto, group->flags() & OBJECT_FLAG_DYNAMIC_MASK); if (!nativeGroup) return false; @@ -513,24 +498,19 @@ UnboxedLayout::makeNativeGroup(JSContext* cx, ObjectGroup* group) // No sense propagating if we don't know what we started with. if (!group->unknownProperties()) { // Propagate all property types from the old group to the new group. - if (layout.isArray()) { - if (!PropagatePropertyTypes(cx, JSID_VOID, group, nativeGroup)) + for (size_t i = 0; i < layout.properties().length(); i++) { + const UnboxedLayout::Property& property = layout.properties()[i]; + jsid id = NameToId(property.name); + if (!PropagatePropertyTypes(cx, id, group, nativeGroup)) return false; - } else { - for (size_t i = 0; i < layout.properties().length(); i++) { - const UnboxedLayout::Property& property = layout.properties()[i]; - jsid id = NameToId(property.name); - if (!PropagatePropertyTypes(cx, id, group, nativeGroup)) - return false; - // If we are OOM we may not be able to propagate properties. - if (nativeGroup->unknownProperties()) - break; + // If we are OOM we may not be able to propagate properties. + if (nativeGroup->unknownProperties()) + break; - HeapTypeSet* nativeProperty = nativeGroup->maybeGetProperty(id); - if (nativeProperty && nativeProperty->canSetDefinite(i)) - nativeProperty->setDefinite(i); - } + HeapTypeSet* nativeProperty = nativeGroup->maybeGetProperty(id); + if (nativeProperty && nativeProperty->canSetDefinite(i)) + nativeProperty->setDefinite(i); } } else { // If we skip, though, the new group had better agree. @@ -955,702 +935,6 @@ const Class UnboxedPlainObject::class_ = { &UnboxedPlainObjectObjectOps }; -///////////////////////////////////////////////////////////////////// -// UnboxedArrayObject -///////////////////////////////////////////////////////////////////// - -template -DenseElementResult -AppendUnboxedDenseElements(UnboxedArrayObject* obj, uint32_t initlen, - MutableHandle> values) -{ - for (size_t i = 0; i < initlen; i++) - values.infallibleAppend(obj->getElementSpecific(i)); - return DenseElementResult::Success; -} - -DefineBoxedOrUnboxedFunctor3(AppendUnboxedDenseElements, - UnboxedArrayObject*, uint32_t, MutableHandle>); - -/* static */ bool -UnboxedArrayObject::convertToNativeWithGroup(ExclusiveContext* cx, JSObject* obj, - ObjectGroup* group, Shape* shape) -{ - size_t length = obj->as().length(); - size_t initlen = obj->as().initializedLength(); - - Rooted> values(cx, GCVector(cx)); - if (!values.reserve(initlen)) - return false; - - AppendUnboxedDenseElementsFunctor functor(&obj->as(), initlen, &values); - DebugOnly result = CallBoxedOrUnboxedSpecialization(functor, obj); - MOZ_ASSERT(result.value == DenseElementResult::Success); - - obj->setGroup(group); - - ArrayObject* aobj = &obj->as(); - aobj->setLastPropertyMakeNative(cx, shape); - - // Make sure there is at least one element, so that this array does not - // use emptyObjectElements / emptyObjectElementsShared. - if (!aobj->ensureElements(cx, Max(initlen, 1))) - return false; - - MOZ_ASSERT(!aobj->getDenseInitializedLength()); - aobj->setDenseInitializedLength(initlen); - aobj->initDenseElements(0, values.begin(), initlen); - aobj->setLengthInt32(length); - - return true; -} - -/* static */ bool -UnboxedArrayObject::convertToNative(JSContext* cx, JSObject* obj) -{ - const UnboxedLayout& layout = obj->as().layout(); - - if (!layout.nativeGroup()) { - if (!UnboxedLayout::makeNativeGroup(cx, obj->group())) - return false; - } - - return convertToNativeWithGroup(cx, obj, layout.nativeGroup(), layout.nativeShape()); -} - -bool -UnboxedArrayObject::convertInt32ToDouble(ExclusiveContext* cx, ObjectGroup* group) -{ - MOZ_ASSERT(elementType() == JSVAL_TYPE_INT32); - MOZ_ASSERT(group->unboxedLayout().elementType() == JSVAL_TYPE_DOUBLE); - - Vector values(cx); - if (!values.reserve(initializedLength())) - return false; - for (size_t i = 0; i < initializedLength(); i++) - values.infallibleAppend(getElementSpecific(i).toInt32()); - - uint8_t* newElements; - if (hasInlineElements()) { - newElements = AllocateObjectBuffer(cx, this, capacity() * sizeof(double)); - } else { - newElements = ReallocateObjectBuffer(cx, this, elements(), - capacity() * sizeof(int32_t), - capacity() * sizeof(double)); - } - if (!newElements) - return false; - - setGroup(group); - elements_ = newElements; - - for (size_t i = 0; i < initializedLength(); i++) - setElementNoTypeChangeSpecific(i, DoubleValue(values[i])); - - return true; -} - -/* static */ UnboxedArrayObject* -UnboxedArrayObject::create(ExclusiveContext* cx, HandleObjectGroup group, uint32_t length, - NewObjectKind newKind, uint32_t maxLength) -{ - MOZ_ASSERT(length <= MaximumCapacity); - - MOZ_ASSERT(group->clasp() == &class_); - uint32_t elementSize = UnboxedTypeSize(group->unboxedLayout().elementType()); - uint32_t capacity = Min(length, maxLength); - uint32_t nbytes = offsetOfInlineElements() + elementSize * capacity; - - UnboxedArrayObject* res; - if (nbytes <= JSObject::MAX_BYTE_SIZE) { - gc::AllocKind allocKind = gc::GetGCObjectKindForBytes(nbytes); - - // If there was no provided length information, pick an allocation kind - // to accommodate small arrays (as is done for normal native arrays). - if (capacity == 0) - allocKind = gc::AllocKind::OBJECT8; - - res = NewObjectWithGroup(cx, group, allocKind, newKind); - if (!res) - return nullptr; - res->setInitializedLengthNoBarrier(0); - res->setInlineElements(); - - size_t actualCapacity = (GetGCKindBytes(allocKind) - offsetOfInlineElements()) / elementSize; - MOZ_ASSERT(actualCapacity >= capacity); - res->setCapacityIndex(exactCapacityIndex(actualCapacity)); - } else { - res = NewObjectWithGroup(cx, group, gc::AllocKind::OBJECT0, newKind); - if (!res) - return nullptr; - res->setInitializedLengthNoBarrier(0); - - uint32_t capacityIndex = (capacity == length) - ? CapacityMatchesLengthIndex - : chooseCapacityIndex(capacity, length); - uint32_t actualCapacity = computeCapacity(capacityIndex, length); - - res->elements_ = AllocateObjectBuffer(cx, res, actualCapacity * elementSize); - if (!res->elements_) { - // Make the object safe for GC. - res->setInlineElements(); - return nullptr; - } - - res->setCapacityIndex(capacityIndex); - } - - res->setLength(cx, length); - return res; -} - -bool -UnboxedArrayObject::setElement(ExclusiveContext* cx, size_t index, const Value& v) -{ - MOZ_ASSERT(index < initializedLength()); - uint8_t* p = elements() + index * elementSize(); - return SetUnboxedValue(cx, this, JSID_VOID, p, elementType(), v, /* preBarrier = */ true); -} - -bool -UnboxedArrayObject::initElement(ExclusiveContext* cx, size_t index, const Value& v) -{ - MOZ_ASSERT(index < initializedLength()); - uint8_t* p = elements() + index * elementSize(); - return SetUnboxedValue(cx, this, JSID_VOID, p, elementType(), v, /* preBarrier = */ false); -} - -void -UnboxedArrayObject::initElementNoTypeChange(size_t index, const Value& v) -{ - MOZ_ASSERT(index < initializedLength()); - uint8_t* p = elements() + index * elementSize(); - if (UnboxedTypeNeedsPreBarrier(elementType())) - *reinterpret_cast(p) = nullptr; - SetUnboxedValueNoTypeChange(this, p, elementType(), v, /* preBarrier = */ false); -} - -Value -UnboxedArrayObject::getElement(size_t index) -{ - MOZ_ASSERT(index < initializedLength()); - uint8_t* p = elements() + index * elementSize(); - return GetUnboxedValue(p, elementType(), /* maybeUninitialized = */ false); -} - -/* static */ void -UnboxedArrayObject::trace(JSTracer* trc, JSObject* obj) -{ - JSValueType type = obj->as().elementType(); - if (!UnboxedTypeNeedsPreBarrier(type)) - return; - - MOZ_ASSERT(obj->as().elementSize() == sizeof(uintptr_t)); - size_t initlen = obj->as().initializedLength(); - void** elements = reinterpret_cast(obj->as().elements()); - - switch (type) { - case JSVAL_TYPE_OBJECT: - for (size_t i = 0; i < initlen; i++) { - GCPtrObject* heap = reinterpret_cast(elements + i); - TraceNullableEdge(trc, heap, "unboxed_object"); - } - break; - - case JSVAL_TYPE_STRING: - for (size_t i = 0; i < initlen; i++) { - GCPtrString* heap = reinterpret_cast(elements + i); - TraceEdge(trc, heap, "unboxed_string"); - } - break; - - default: - MOZ_CRASH(); - } -} - -/* static */ void -UnboxedArrayObject::objectMoved(JSObject* obj, const JSObject* old) -{ - UnboxedArrayObject& dst = obj->as(); - const UnboxedArrayObject& src = old->as(); - - // Fix up possible inline data pointer. - if (src.hasInlineElements()) - dst.setInlineElements(); -} - -/* static */ void -UnboxedArrayObject::finalize(FreeOp* fop, JSObject* obj) -{ - MOZ_ASSERT(!IsInsideNursery(obj)); - if (!obj->as().hasInlineElements()) - js_free(obj->as().elements()); -} - -/* static */ size_t -UnboxedArrayObject::objectMovedDuringMinorGC(JSTracer* trc, JSObject* dst, JSObject* src, - gc::AllocKind allocKind) -{ - UnboxedArrayObject* ndst = &dst->as(); - UnboxedArrayObject* nsrc = &src->as(); - MOZ_ASSERT(ndst->elements() == nsrc->elements()); - - Nursery& nursery = trc->runtime()->gc.nursery; - - if (!nursery.isInside(nsrc->elements())) { - nursery.removeMallocedBuffer(nsrc->elements()); - return 0; - } - - // Determine if we can use inline data for the target array. If this is - // possible, the nursery will have picked an allocation size that is large - // enough. - size_t nbytes = nsrc->capacity() * nsrc->elementSize(); - if (offsetOfInlineElements() + nbytes <= GetGCKindBytes(allocKind)) { - ndst->setInlineElements(); - } else { - MOZ_ASSERT(allocKind == gc::AllocKind::OBJECT0); - - AutoEnterOOMUnsafeRegion oomUnsafe; - uint8_t* data = nsrc->zone()->pod_malloc(nbytes); - if (!data) - oomUnsafe.crash("Failed to allocate unboxed array elements while tenuring."); - ndst->elements_ = data; - } - - PodCopy(ndst->elements(), nsrc->elements(), nsrc->initializedLength() * nsrc->elementSize()); - - // Set a forwarding pointer for the element buffers in case they were - // preserved on the stack by Ion. - bool direct = nsrc->capacity() * nsrc->elementSize() >= sizeof(uintptr_t); - nursery.maybeSetForwardingPointer(trc, nsrc->elements(), ndst->elements(), direct); - - return ndst->hasInlineElements() ? 0 : nbytes; -} - -// Possible capacities for unboxed arrays. Some of these capacities might seem -// a little weird, but were chosen to allow the inline data of objects of each -// size to be fully utilized for arrays of the various types on both 32 bit and -// 64 bit platforms. -// -// To find the possible inline capacities, the following script was used: -// -// var fixedSlotCapacities = [0, 2, 4, 8, 12, 16]; -// var dataSizes = [1, 4, 8]; -// var header32 = 4 * 2 + 4 * 2; -// var header64 = 8 * 2 + 4 * 2; -// -// for (var i = 0; i < fixedSlotCapacities.length; i++) { -// var nfixed = fixedSlotCapacities[i]; -// var size32 = 4 * 4 + 8 * nfixed - header32; -// var size64 = 8 * 4 + 8 * nfixed - header64; -// for (var j = 0; j < dataSizes.length; j++) { -// print(size32 / dataSizes[j]); -// print(size64 / dataSizes[j]); -// } -// } -// -/* static */ const uint32_t -UnboxedArrayObject::CapacityArray[] = { - UINT32_MAX, // For CapacityMatchesLengthIndex. - 0, 1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 13, 16, 17, 18, 24, 26, 32, 34, 40, 64, 72, 96, 104, 128, 136, - 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, - 1048576, 2097152, 3145728, 4194304, 5242880, 6291456, 7340032, 8388608, 9437184, 11534336, - 13631488, 15728640, 17825792, 20971520, 24117248, 27262976, 31457280, 35651584, 40894464, - 46137344, 52428800, 59768832, MaximumCapacity -}; - -static const uint32_t -Pow2CapacityIndexes[] = { - 2, // 1 - 3, // 2 - 5, // 4 - 8, // 8 - 13, // 16 - 18, // 32 - 21, // 64 - 25, // 128 - 27, // 256 - 28, // 512 - 29, // 1024 - 30, // 2048 - 31, // 4096 - 32, // 8192 - 33, // 16384 - 34, // 32768 - 35, // 65536 - 36, // 131072 - 37, // 262144 - 38, // 524288 - 39 // 1048576 -}; - -static const uint32_t MebiCapacityIndex = 39; - -/* static */ uint32_t -UnboxedArrayObject::chooseCapacityIndex(uint32_t capacity, uint32_t length) -{ - // Note: the structure and behavior of this method follow along with - // NativeObject::goodAllocated. Changes to the allocation strategy in one - // should generally be matched by the other. - - // Make sure we have enough space to store all possible values for the capacity index. - // This ought to be a static_assert, but MSVC doesn't like that. - MOZ_ASSERT(mozilla::ArrayLength(CapacityArray) - 1 <= (CapacityMask >> CapacityShift)); - - // The caller should have ensured the capacity is possible for an unboxed array. - MOZ_ASSERT(capacity <= MaximumCapacity); - - static const uint32_t Mebi = 1024 * 1024; - - if (capacity <= Mebi) { - capacity = mozilla::RoundUpPow2(capacity); - - // When the required capacity is close to the array length, then round - // up to the array length itself, as for NativeObject. - if (length >= capacity && capacity > (length / 3) * 2) - return CapacityMatchesLengthIndex; - - if (capacity < MinimumDynamicCapacity) - capacity = MinimumDynamicCapacity; - - uint32_t bit = mozilla::FloorLog2Size(capacity); - MOZ_ASSERT(capacity == uint32_t(1 << bit)); - MOZ_ASSERT(bit <= 20); - MOZ_ASSERT(mozilla::ArrayLength(Pow2CapacityIndexes) == 21); - - uint32_t index = Pow2CapacityIndexes[bit]; - MOZ_ASSERT(CapacityArray[index] == capacity); - - return index; - } - - MOZ_ASSERT(CapacityArray[MebiCapacityIndex] == Mebi); - - for (uint32_t i = MebiCapacityIndex + 1;; i++) { - if (CapacityArray[i] >= capacity) - return i; - } - - MOZ_CRASH("Invalid capacity"); -} - -/* static */ uint32_t -UnboxedArrayObject::exactCapacityIndex(uint32_t capacity) -{ - for (size_t i = CapacityMatchesLengthIndex + 1; i < ArrayLength(CapacityArray); i++) { - if (CapacityArray[i] == capacity) - return i; - } - MOZ_CRASH(); -} - -bool -UnboxedArrayObject::growElements(ExclusiveContext* cx, size_t cap) -{ - // The caller should have checked if this capacity is possible for an - // unboxed array, so the only way this call can fail is from OOM. - MOZ_ASSERT(cap <= MaximumCapacity); - - uint32_t oldCapacity = capacity(); - uint32_t newCapacityIndex = chooseCapacityIndex(cap, length()); - uint32_t newCapacity = computeCapacity(newCapacityIndex, length()); - - MOZ_ASSERT(oldCapacity < cap); - MOZ_ASSERT(cap <= newCapacity); - - // The allocation size computation below cannot have integer overflows. - JS_STATIC_ASSERT(MaximumCapacity < UINT32_MAX / sizeof(double)); - - uint8_t* newElements; - if (hasInlineElements()) { - newElements = AllocateObjectBuffer(cx, this, newCapacity * elementSize()); - if (!newElements) - return false; - js_memcpy(newElements, elements(), initializedLength() * elementSize()); - } else { - newElements = ReallocateObjectBuffer(cx, this, elements(), - oldCapacity * elementSize(), - newCapacity * elementSize()); - if (!newElements) - return false; - } - - elements_ = newElements; - setCapacityIndex(newCapacityIndex); - - return true; -} - -void -UnboxedArrayObject::shrinkElements(ExclusiveContext* cx, size_t cap) -{ - if (hasInlineElements()) - return; - - uint32_t oldCapacity = capacity(); - uint32_t newCapacityIndex = chooseCapacityIndex(cap, 0); - uint32_t newCapacity = computeCapacity(newCapacityIndex, 0); - - MOZ_ASSERT(cap < oldCapacity); - MOZ_ASSERT(cap <= newCapacity); - - if (newCapacity >= oldCapacity) - return; - - uint8_t* newElements = ReallocateObjectBuffer(cx, this, elements(), - oldCapacity * elementSize(), - newCapacity * elementSize()); - if (!newElements) - return; - - elements_ = newElements; - setCapacityIndex(newCapacityIndex); -} - -bool -UnboxedArrayObject::containsProperty(ExclusiveContext* cx, jsid id) -{ - if (JSID_IS_INT(id) && uint32_t(JSID_TO_INT(id)) < initializedLength()) - return true; - if (JSID_IS_ATOM(id) && JSID_TO_ATOM(id) == cx->names().length) - return true; - return false; -} - -/* static */ bool -UnboxedArrayObject::obj_lookupProperty(JSContext* cx, HandleObject obj, - HandleId id, MutableHandleObject objp, - MutableHandleShape propp) -{ - if (obj->as().containsProperty(cx, id)) { - MarkNonNativePropertyFound(propp); - objp.set(obj); - return true; - } - - RootedObject proto(cx, obj->staticPrototype()); - if (!proto) { - objp.set(nullptr); - propp.set(nullptr); - return true; - } - - return LookupProperty(cx, proto, id, objp, propp); -} - -/* static */ bool -UnboxedArrayObject::obj_defineProperty(JSContext* cx, HandleObject obj, HandleId id, - Handle desc, - ObjectOpResult& result) -{ - if (JSID_IS_INT(id) && !desc.getter() && !desc.setter() && desc.attributes() == JSPROP_ENUMERATE) { - UnboxedArrayObject* nobj = &obj->as(); - - uint32_t index = JSID_TO_INT(id); - if (index < nobj->initializedLength()) { - if (nobj->setElement(cx, index, desc.value())) - return result.succeed(); - } else if (index == nobj->initializedLength() && index < MaximumCapacity) { - if (nobj->initializedLength() == nobj->capacity()) { - if (!nobj->growElements(cx, index + 1)) - return false; - } - nobj->setInitializedLength(index + 1); - if (nobj->initElement(cx, index, desc.value())) { - if (nobj->length() <= index) - nobj->setLengthInt32(index + 1); - return result.succeed(); - } - nobj->setInitializedLengthNoBarrier(index); - } - } - - if (!convertToNative(cx, obj)) - return false; - - return DefineProperty(cx, obj, id, desc, result); -} - -/* static */ bool -UnboxedArrayObject::obj_hasProperty(JSContext* cx, HandleObject obj, HandleId id, bool* foundp) -{ - if (obj->as().containsProperty(cx, id)) { - *foundp = true; - return true; - } - - RootedObject proto(cx, obj->staticPrototype()); - if (!proto) { - *foundp = false; - return true; - } - - return HasProperty(cx, proto, id, foundp); -} - -/* static */ bool -UnboxedArrayObject::obj_getProperty(JSContext* cx, HandleObject obj, HandleValue receiver, - HandleId id, MutableHandleValue vp) -{ - if (obj->as().containsProperty(cx, id)) { - if (JSID_IS_INT(id)) - vp.set(obj->as().getElement(JSID_TO_INT(id))); - else - vp.set(Int32Value(obj->as().length())); - return true; - } - - RootedObject proto(cx, obj->staticPrototype()); - if (!proto) { - vp.setUndefined(); - return true; - } - - return GetProperty(cx, proto, receiver, id, vp); -} - -/* static */ bool -UnboxedArrayObject::obj_setProperty(JSContext* cx, HandleObject obj, HandleId id, HandleValue v, - HandleValue receiver, ObjectOpResult& result) -{ - if (obj->as().containsProperty(cx, id)) { - if (receiver.isObject() && obj == &receiver.toObject()) { - if (JSID_IS_INT(id)) { - if (obj->as().setElement(cx, JSID_TO_INT(id), v)) - return result.succeed(); - } else { - uint32_t len; - if (!CanonicalizeArrayLengthValue(cx, v, &len)) - return false; - UnboxedArrayObject* nobj = &obj->as(); - if (len < nobj->initializedLength()) { - nobj->setInitializedLength(len); - nobj->shrinkElements(cx, len); - } - nobj->setLength(cx, len); - return result.succeed(); - } - - if (!convertToNative(cx, obj)) - return false; - return SetProperty(cx, obj, id, v, receiver, result); - } - - return SetPropertyByDefining(cx, id, v, receiver, result); - } - - return SetPropertyOnProto(cx, obj, id, v, receiver, result); -} - -/* static */ bool -UnboxedArrayObject::obj_getOwnPropertyDescriptor(JSContext* cx, HandleObject obj, HandleId id, - MutableHandle desc) -{ - if (obj->as().containsProperty(cx, id)) { - if (JSID_IS_INT(id)) { - desc.value().set(obj->as().getElement(JSID_TO_INT(id))); - desc.setAttributes(JSPROP_ENUMERATE); - } else { - desc.value().set(Int32Value(obj->as().length())); - desc.setAttributes(JSPROP_PERMANENT); - } - desc.object().set(obj); - return true; - } - - desc.object().set(nullptr); - return true; -} - -/* static */ bool -UnboxedArrayObject::obj_deleteProperty(JSContext* cx, HandleObject obj, HandleId id, - ObjectOpResult& result) -{ - if (obj->as().containsProperty(cx, id)) { - size_t initlen = obj->as().initializedLength(); - if (JSID_IS_INT(id) && JSID_TO_INT(id) == int32_t(initlen - 1)) { - obj->as().setInitializedLength(initlen - 1); - obj->as().shrinkElements(cx, initlen - 1); - return result.succeed(); - } - } - - if (!convertToNative(cx, obj)) - return false; - return DeleteProperty(cx, obj, id, result); -} - -/* static */ bool -UnboxedArrayObject::obj_watch(JSContext* cx, HandleObject obj, HandleId id, HandleObject callable) -{ - if (!convertToNative(cx, obj)) - return false; - return WatchProperty(cx, obj, id, callable); -} - -/* static */ bool -UnboxedArrayObject::obj_enumerate(JSContext* cx, HandleObject obj, AutoIdVector& properties, - bool enumerableOnly) -{ - for (size_t i = 0; i < obj->as().initializedLength(); i++) { - if (!properties.append(INT_TO_JSID(i))) - return false; - } - - if (!enumerableOnly && !properties.append(NameToId(cx->names().length))) - return false; - - return true; -} - -static const ClassOps UnboxedArrayObjectClassOps = { - nullptr, /* addProperty */ - nullptr, /* delProperty */ - nullptr, /* getProperty */ - nullptr, /* setProperty */ - nullptr, /* enumerate */ - nullptr, /* resolve */ - nullptr, /* mayResolve */ - UnboxedArrayObject::finalize, - nullptr, /* call */ - nullptr, /* hasInstance */ - nullptr, /* construct */ - UnboxedArrayObject::trace, -}; - -static const ClassExtension UnboxedArrayObjectClassExtension = { - nullptr, /* weakmapKeyDelegateOp */ - UnboxedArrayObject::objectMoved -}; - -static const ObjectOps UnboxedArrayObjectObjectOps = { - UnboxedArrayObject::obj_lookupProperty, - UnboxedArrayObject::obj_defineProperty, - UnboxedArrayObject::obj_hasProperty, - UnboxedArrayObject::obj_getProperty, - UnboxedArrayObject::obj_setProperty, - UnboxedArrayObject::obj_getOwnPropertyDescriptor, - UnboxedArrayObject::obj_deleteProperty, - UnboxedArrayObject::obj_watch, - nullptr, /* No unwatch needed, as watch() converts the object to native */ - nullptr, /* getElements */ - UnboxedArrayObject::obj_enumerate, - nullptr /* funToString */ -}; - -const Class UnboxedArrayObject::class_ = { - "Array", - Class::NON_NATIVE | - JSCLASS_SKIP_NURSERY_FINALIZE | - JSCLASS_BACKGROUND_FINALIZE, - &UnboxedArrayObjectClassOps, - JS_NULL_CLASS_SPEC, - &UnboxedArrayObjectClassExtension, - &UnboxedArrayObjectObjectOps -}; - ///////////////////////////////////////////////////////////////////// // API ///////////////////////////////////////////////////////////////////// @@ -1661,31 +945,6 @@ NextValue(Handle> values, size_t* valueCursor) return values[(*valueCursor)++]; } -void -UnboxedArrayObject::fillAfterConvert(ExclusiveContext* cx, - Handle> values, size_t* valueCursor) -{ - MOZ_ASSERT(CapacityArray[1] == 0); - setCapacityIndex(1); - setInitializedLengthNoBarrier(0); - setInlineElements(); - - setLength(cx, NextValue(values, valueCursor).toInt32()); - - int32_t initlen = NextValue(values, valueCursor).toInt32(); - if (!initlen) - return; - - AutoEnterOOMUnsafeRegion oomUnsafe; - if (!growElements(cx, initlen)) - oomUnsafe.crash("UnboxedArrayObject::fillAfterConvert"); - - setInitializedLength(initlen); - - for (size_t i = 0; i < size_t(initlen); i++) - JS_ALWAYS_TRUE(initElement(cx, i, NextValue(values, valueCursor))); -} - void UnboxedPlainObject::fillAfterConvert(ExclusiveContext* cx, Handle> values, size_t* valueCursor) @@ -1695,58 +954,3 @@ UnboxedPlainObject::fillAfterConvert(ExclusiveContext* cx, for (size_t i = 0; i < layout().properties().length(); i++) JS_ALWAYS_TRUE(setValue(cx, layout().properties()[i], NextValue(values, valueCursor))); } - -DefineBoxedOrUnboxedFunctor6(SetOrExtendBoxedOrUnboxedDenseElements, - ExclusiveContext*, JSObject*, uint32_t, const Value*, uint32_t, - ShouldUpdateTypes); - -DenseElementResult -js::SetOrExtendAnyBoxedOrUnboxedDenseElements(ExclusiveContext* cx, JSObject* obj, - uint32_t start, const Value* vp, uint32_t count, - ShouldUpdateTypes updateTypes) -{ - SetOrExtendBoxedOrUnboxedDenseElementsFunctor functor(cx, obj, start, vp, count, updateTypes); - return CallBoxedOrUnboxedSpecialization(functor, obj); -}; - -DefineBoxedOrUnboxedFunctor5(MoveBoxedOrUnboxedDenseElements, - JSContext*, JSObject*, uint32_t, uint32_t, uint32_t); - -DenseElementResult -js::MoveAnyBoxedOrUnboxedDenseElements(JSContext* cx, JSObject* obj, - uint32_t dstStart, uint32_t srcStart, uint32_t length) -{ - MoveBoxedOrUnboxedDenseElementsFunctor functor(cx, obj, dstStart, srcStart, length); - return CallBoxedOrUnboxedSpecialization(functor, obj); -} - -DefineBoxedOrUnboxedFunctorPair6(CopyBoxedOrUnboxedDenseElements, - JSContext*, JSObject*, JSObject*, uint32_t, uint32_t, uint32_t); - -DenseElementResult -js::CopyAnyBoxedOrUnboxedDenseElements(JSContext* cx, JSObject* dst, JSObject* src, - uint32_t dstStart, uint32_t srcStart, uint32_t length) -{ - CopyBoxedOrUnboxedDenseElementsFunctor functor(cx, dst, src, dstStart, srcStart, length); - return CallBoxedOrUnboxedSpecialization(functor, dst, src); -} - -DefineBoxedOrUnboxedFunctor3(SetBoxedOrUnboxedInitializedLength, - JSContext*, JSObject*, size_t); - -void -js::SetAnyBoxedOrUnboxedInitializedLength(JSContext* cx, JSObject* obj, size_t initlen) -{ - SetBoxedOrUnboxedInitializedLengthFunctor functor(cx, obj, initlen); - JS_ALWAYS_TRUE(CallBoxedOrUnboxedSpecialization(functor, obj) == DenseElementResult::Success); -} - -DefineBoxedOrUnboxedFunctor3(EnsureBoxedOrUnboxedDenseElements, - JSContext*, JSObject*, size_t); - -DenseElementResult -js::EnsureAnyBoxedOrUnboxedDenseElements(JSContext* cx, JSObject* obj, size_t initlen) -{ - EnsureBoxedOrUnboxedDenseElementsFunctor functor(cx, obj, initlen); - return CallBoxedOrUnboxedSpecialization(functor, obj); -} diff --git a/js/src/vm/UnboxedObject.h b/js/src/vm/UnboxedObject.h index 779dd14c7..ba66434bc 100644 --- a/js/src/vm/UnboxedObject.h +++ b/js/src/vm/UnboxedObject.h @@ -96,17 +96,11 @@ class UnboxedLayout : public mozilla::LinkedListElement // from an array of values. GCPtrJitCode constructorCode_; - // The following members are only used for unboxed arrays. - - // The type of array elements. - JSValueType elementType_; - public: UnboxedLayout() : nativeGroup_(nullptr), nativeShape_(nullptr), allocationScript_(nullptr), allocationPc_(nullptr), replacementGroup_(nullptr), - size_(0), newScript_(nullptr), traceList_(nullptr), constructorCode_(nullptr), - elementType_(JSVAL_TYPE_MAGIC) + size_(0), newScript_(nullptr), traceList_(nullptr), constructorCode_(nullptr) {} bool initProperties(const PropertyVector& properties, size_t size) { @@ -114,10 +108,6 @@ class UnboxedLayout : public mozilla::LinkedListElement return properties_.appendAll(properties); } - void initArray(JSValueType elementType) { - elementType_ = elementType; - } - ~UnboxedLayout() { if (newScript_) newScript_->clear(); @@ -130,10 +120,6 @@ class UnboxedLayout : public mozilla::LinkedListElement constructorCode_.init(nullptr); } - bool isArray() const { - return elementType_ != JSVAL_TYPE_MAGIC; - } - void detachFromCompartment(); const PropertyVector& properties() const { @@ -201,10 +187,6 @@ class UnboxedLayout : public mozilla::LinkedListElement constructorCode_ = code; } - JSValueType elementType() const { - return elementType_; - } - inline gc::AllocKind getAllocKind() const; void trace(JSTracer* trc); @@ -324,193 +306,6 @@ UnboxedLayout::getAllocKind() const return gc::GetGCObjectKindForBytes(UnboxedPlainObject::offsetOfData() + size()); } -// Class for an array object using an unboxed representation. -class UnboxedArrayObject : public JSObject -{ - // Elements pointer for the object. - uint8_t* elements_; - - // The nominal array length. This always fits in an int32_t. - uint32_t length_; - - // Value indicating the allocated capacity and initialized length of the - // array. The top CapacityBits bits are an index into CapacityArray, which - // indicates the elements capacity. The low InitializedLengthBits store the - // initialized length of the array. - uint32_t capacityIndexAndInitializedLength_; - - // If the elements are inline, they will point here. - uint8_t inlineElements_[1]; - - public: - static const uint32_t CapacityBits = 6; - static const uint32_t CapacityShift = 26; - - static const uint32_t CapacityMask = uint32_t(-1) << CapacityShift; - static const uint32_t InitializedLengthMask = (1 << CapacityShift) - 1; - - static const uint32_t MaximumCapacity = InitializedLengthMask; - static const uint32_t MinimumDynamicCapacity = 8; - - static const uint32_t CapacityArray[]; - - // Capacity index which indicates the array's length is also its capacity. - static const uint32_t CapacityMatchesLengthIndex = 0; - - private: - static inline uint32_t computeCapacity(uint32_t index, uint32_t length) { - if (index == CapacityMatchesLengthIndex) - return length; - return CapacityArray[index]; - } - - static uint32_t chooseCapacityIndex(uint32_t capacity, uint32_t length); - static uint32_t exactCapacityIndex(uint32_t capacity); - - public: - static const Class class_; - - static bool obj_lookupProperty(JSContext* cx, HandleObject obj, - HandleId id, MutableHandleObject objp, - MutableHandleShape propp); - - static bool obj_defineProperty(JSContext* cx, HandleObject obj, HandleId id, - Handle desc, - ObjectOpResult& result); - - static bool obj_hasProperty(JSContext* cx, HandleObject obj, HandleId id, bool* foundp); - - static bool obj_getProperty(JSContext* cx, HandleObject obj, HandleValue receiver, - HandleId id, MutableHandleValue vp); - - static bool obj_setProperty(JSContext* cx, HandleObject obj, HandleId id, HandleValue v, - HandleValue receiver, ObjectOpResult& result); - - static bool obj_getOwnPropertyDescriptor(JSContext* cx, HandleObject obj, HandleId id, - MutableHandle desc); - - static bool obj_deleteProperty(JSContext* cx, HandleObject obj, HandleId id, - ObjectOpResult& result); - - static bool obj_enumerate(JSContext* cx, HandleObject obj, AutoIdVector& properties, - bool enumerableOnly); - static bool obj_watch(JSContext* cx, HandleObject obj, HandleId id, HandleObject callable); - - inline const UnboxedLayout& layout() const; - - const UnboxedLayout& layoutDontCheckGeneration() const { - return group()->unboxedLayoutDontCheckGeneration(); - } - - JSValueType elementType() const { - return layoutDontCheckGeneration().elementType(); - } - - uint32_t elementSize() const { - return UnboxedTypeSize(elementType()); - } - - static bool convertToNative(JSContext* cx, JSObject* obj); - static UnboxedArrayObject* create(ExclusiveContext* cx, HandleObjectGroup group, - uint32_t length, NewObjectKind newKind, - uint32_t maxLength = MaximumCapacity); - - static bool convertToNativeWithGroup(ExclusiveContext* cx, JSObject* obj, - ObjectGroup* group, Shape* shape); - bool convertInt32ToDouble(ExclusiveContext* cx, ObjectGroup* group); - - void fillAfterConvert(ExclusiveContext* cx, - Handle> values, size_t* valueCursor); - - static void trace(JSTracer* trc, JSObject* object); - static void objectMoved(JSObject* obj, const JSObject* old); - static void finalize(FreeOp* fop, JSObject* obj); - - static size_t objectMovedDuringMinorGC(JSTracer* trc, JSObject* dst, JSObject* src, - gc::AllocKind allocKind); - - uint8_t* elements() { - return elements_; - } - - bool hasInlineElements() const { - return elements_ == &inlineElements_[0]; - } - - uint32_t length() const { - return length_; - } - - uint32_t initializedLength() const { - return capacityIndexAndInitializedLength_ & InitializedLengthMask; - } - - uint32_t capacityIndex() const { - return (capacityIndexAndInitializedLength_ & CapacityMask) >> CapacityShift; - } - - uint32_t capacity() const { - return computeCapacity(capacityIndex(), length()); - } - - bool containsProperty(ExclusiveContext* cx, jsid id); - - bool setElement(ExclusiveContext* cx, size_t index, const Value& v); - bool initElement(ExclusiveContext* cx, size_t index, const Value& v); - void initElementNoTypeChange(size_t index, const Value& v); - Value getElement(size_t index); - - template inline bool setElementSpecific(ExclusiveContext* cx, size_t index, - const Value& v); - template inline void setElementNoTypeChangeSpecific(size_t index, const Value& v); - template inline bool initElementSpecific(ExclusiveContext* cx, size_t index, - const Value& v); - template inline void initElementNoTypeChangeSpecific(size_t index, const Value& v); - template inline Value getElementSpecific(size_t index); - template inline void triggerPreBarrier(size_t index); - - bool growElements(ExclusiveContext* cx, size_t cap); - void shrinkElements(ExclusiveContext* cx, size_t cap); - - static uint32_t offsetOfElements() { - return offsetof(UnboxedArrayObject, elements_); - } - static uint32_t offsetOfLength() { - return offsetof(UnboxedArrayObject, length_); - } - static uint32_t offsetOfCapacityIndexAndInitializedLength() { - return offsetof(UnboxedArrayObject, capacityIndexAndInitializedLength_); - } - static uint32_t offsetOfInlineElements() { - return offsetof(UnboxedArrayObject, inlineElements_); - } - - void setLengthInt32(uint32_t length) { - MOZ_ASSERT(length <= INT32_MAX); - length_ = length; - } - - inline void setLength(ExclusiveContext* cx, uint32_t len); - inline void setInitializedLength(uint32_t initlen); - - inline void setInitializedLengthNoBarrier(uint32_t initlen) { - MOZ_ASSERT(initlen <= InitializedLengthMask); - capacityIndexAndInitializedLength_ = - (capacityIndexAndInitializedLength_ & CapacityMask) | initlen; - } - - private: - void setInlineElements() { - elements_ = &inlineElements_[0]; - } - - void setCapacityIndex(uint32_t index) { - MOZ_ASSERT(index <= (CapacityMask >> CapacityShift)); - capacityIndexAndInitializedLength_ = - (index << CapacityShift) | initializedLength(); - } -}; - } // namespace js namespace JS { -- cgit v1.2.3 From f47d45be4b6c8a1fc758d50497a964fc7a75154b Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Tue, 4 Jun 2019 23:58:47 +0200 Subject: Revert "Improve origin-clean algorithm" This reverts commit e69b3f567c4b8957cc09ba4359e84939f77781c5. --- dom/canvas/CanvasRenderingContext2D.cpp | 13 ++++--------- dom/canvas/CanvasUtils.cpp | 20 ------------------- dom/canvas/CanvasUtils.h | 5 ----- dom/canvas/ImageBitmap.cpp | 34 +++++++++++++++++++++++++++++++-- layout/base/nsLayoutUtils.cpp | 8 +++----- 5 files changed, 39 insertions(+), 41 deletions(-) diff --git a/dom/canvas/CanvasRenderingContext2D.cpp b/dom/canvas/CanvasRenderingContext2D.cpp index 2bf40732a..4849fda57 100644 --- a/dom/canvas/CanvasRenderingContext2D.cpp +++ b/dom/canvas/CanvasRenderingContext2D.cpp @@ -2406,11 +2406,7 @@ CanvasRenderingContext2D::SetStyleFromUnion(const StringOrCanvasGradientOrCanvas } if (aValue.IsCanvasPattern()) { - CanvasPattern& pattern = aValue.GetAsCanvasPattern(); - SetStyleFromPattern(pattern, aWhichStyle); - if (pattern.mForceWriteOnly) { - SetWriteOnly(); - } + SetStyleFromPattern(aValue.GetAsCanvasPattern(), aWhichStyle); return; } @@ -2585,12 +2581,11 @@ CanvasRenderingContext2D::CreatePattern(const CanvasImageSource& aSource, nsLayoutUtils::SurfaceFromElement(element, nsLayoutUtils::SFE_WANT_FIRST_FRAME, mTarget); - RefPtr surface = res.GetSourceSurface(); - if (!surface) { + if (!res.GetSourceSurface()) { return nullptr; } - RefPtr pat = new CanvasPattern(this, surface, repeatMode, + RefPtr pat = new CanvasPattern(this, res.GetSourceSurface(), repeatMode, res.mPrincipal, res.mIsWriteOnly, res.mCORSUsed); return pat.forget(); @@ -4900,8 +4895,8 @@ CanvasRenderingContext2D::CachedSurfaceFromElement(Element* aElement) res.mSize = res.mSourceSurface->GetSize(); res.mPrincipal = principal.forget(); + res.mIsWriteOnly = false; res.mImageRequest = imgRequest.forget(); - res.mIsWriteOnly = CheckWriteOnlySecurity(res.mCORSUsed, res.mPrincipal); return res; } diff --git a/dom/canvas/CanvasUtils.cpp b/dom/canvas/CanvasUtils.cpp index 6c9addf59..c7cfed83f 100644 --- a/dom/canvas/CanvasUtils.cpp +++ b/dom/canvas/CanvasUtils.cpp @@ -126,25 +126,5 @@ CoerceDouble(const JS::Value& v, double* d) return true; } -bool CheckWriteOnlySecurity(bool aCORSUsed, nsIPrincipal* aPrincipal) { - if (!aPrincipal) { - return true; - } - - if (!aCORSUsed) { - nsIGlobalObject* incumbentSettingsObject = dom::GetIncumbentGlobal(); - if (NS_WARN_IF(!incumbentSettingsObject)) { - return true; - } - - nsIPrincipal* principal = incumbentSettingsObject->PrincipalOrNull(); - if (NS_WARN_IF(!principal) || !(principal->Subsumes(aPrincipal))) { - return true; - } - } - - return false; -} - } // namespace CanvasUtils } // namespace mozilla diff --git a/dom/canvas/CanvasUtils.h b/dom/canvas/CanvasUtils.h index 264b2b5bb..a69b8bd72 100644 --- a/dom/canvas/CanvasUtils.h +++ b/dom/canvas/CanvasUtils.h @@ -11,7 +11,6 @@ #include "mozilla/dom/ToJSValue.h" #include "jsapi.h" #include "mozilla/FloatingPoint.h" -#include "nsLayoutUtils.h" class nsIPrincipal; @@ -157,10 +156,6 @@ DashArrayToJSVal(nsTArray& dashes, } } -// returns true if write-only mode must used for this principal based on -// the incumbent global. -bool CheckWriteOnlySecurity(bool aCORSUsed, nsIPrincipal* aPrincipal); - } // namespace CanvasUtils } // namespace mozilla diff --git a/dom/canvas/ImageBitmap.cpp b/dom/canvas/ImageBitmap.cpp index 4a1b6e3c2..6efe1b318 100644 --- a/dom/canvas/ImageBitmap.cpp +++ b/dom/canvas/ImageBitmap.cpp @@ -315,6 +315,36 @@ private: const Maybe& mCropRect; }; +static bool +CheckSecurityForHTMLElements(bool aIsWriteOnly, bool aCORSUsed, nsIPrincipal* aPrincipal) +{ + MOZ_ASSERT(aPrincipal); + + if (aIsWriteOnly) { + return false; + } + + if (!aCORSUsed) { + nsIGlobalObject* incumbentSettingsObject = GetIncumbentGlobal(); + if (NS_WARN_IF(!incumbentSettingsObject)) { + return false; + } + + nsIPrincipal* principal = incumbentSettingsObject->PrincipalOrNull(); + if (NS_WARN_IF(!principal) || !(principal->Subsumes(aPrincipal))) { + return false; + } + } + + return true; +} + +static bool +CheckSecurityForHTMLElements(const nsLayoutUtils::SurfaceFromElementResult& aRes) +{ + return CheckSecurityForHTMLElements(aRes.mIsWriteOnly, aRes.mCORSUsed, aRes.mPrincipal); +} + /* * A wrapper to the nsLayoutUtils::SurfaceFromElement() function followed by the * security checking. @@ -335,7 +365,7 @@ GetSurfaceFromElement(nsIGlobalObject* aGlobal, HTMLElementType& aElement, } // Check origin-clean and pass back - *aWriteOnly = res.mIsWriteOnly; + *aWriteOnly = !CheckSecurityForHTMLElements(res); return surface.forget(); } @@ -788,7 +818,7 @@ ImageBitmap::CreateInternal(nsIGlobalObject* aGlobal, HTMLVideoElement& aVideoEl nsCOMPtr principal = aVideoEl.GetCurrentVideoPrincipal(); bool CORSUsed = aVideoEl.GetCORSMode() != CORS_NONE; - writeOnly = CheckWriteOnlySecurity(CORSUsed, principal); + writeOnly = !CheckSecurityForHTMLElements(false, CORSUsed, principal); // Create ImageBitmap. ImageContainer *container = aVideoEl.GetImageContainer(); diff --git a/layout/base/nsLayoutUtils.cpp b/layout/base/nsLayoutUtils.cpp index 17ece8e61..07befdc81 100644 --- a/layout/base/nsLayoutUtils.cpp +++ b/layout/base/nsLayoutUtils.cpp @@ -8,7 +8,6 @@ #include "mozilla/ArrayUtils.h" #include "mozilla/BasicEvents.h" -#include "mozilla/dom/CanvasUtils.h" #include "mozilla/ClearOnShutdown.h" #include "mozilla/EffectCompositor.h" #include "mozilla/EffectSet.h" @@ -7286,10 +7285,10 @@ nsLayoutUtils::SurfaceFromElement(nsIImageLoadingContent* aElement, } result.mPrincipal = principal.forget(); + // no images, including SVG images, can load content from another domain. + result.mIsWriteOnly = false; result.mImageRequest = imgRequest.forget(); return result; - result.mIsWriteOnly = - CanvasUtils::CheckWriteOnlySecurity(result.mCORSUsed, result.mPrincipal); } nsLayoutUtils::SurfaceFromElementResult @@ -7401,8 +7400,7 @@ nsLayoutUtils::SurfaceFromElement(HTMLVideoElement* aElement, result.mHasSize = true; result.mSize = result.mLayersImage->GetSize(); result.mPrincipal = principal.forget(); - result.mIsWriteOnly = - CanvasUtils::CheckWriteOnlySecurity(result.mCORSUsed, result.mPrincipal); + result.mIsWriteOnly = false; return result; } -- cgit v1.2.3 From 3f1ef7a67d42d5dfd93088d74480222e781e3840 Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Wed, 5 Jun 2019 22:11:53 +0200 Subject: Improve `origin-clean` algorithm based on our previous changes. - Instead of trying the failing refactored Mozilla way, simply add a check where needed building on what was put in place previously. --- dom/canvas/CanvasRenderingContext2D.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/dom/canvas/CanvasRenderingContext2D.cpp b/dom/canvas/CanvasRenderingContext2D.cpp index 4849fda57..111519c71 100644 --- a/dom/canvas/CanvasRenderingContext2D.cpp +++ b/dom/canvas/CanvasRenderingContext2D.cpp @@ -4219,6 +4219,12 @@ struct MOZ_STACK_CLASS CanvasBidiProcessor : public nsBidiPresUtils::BidiProcess if (state->gradientStyles[style]) { // Gradient pattern = GetGradientFor(style); } else if (state->patternStyles[style]) { // Pattern + if (mCtx->mCanvasElement) { + CanvasUtils::DoDrawImageSecurityCheck( + mCtx->mCanvasElement, state->patternStyles[style]->mPrincipal, + state->patternStyles[style]->mForceWriteOnly, + state->patternStyles[style]->mCORSUsed); + } pattern = GetPatternFor(style); } else { MOZ_ASSERT(false, "Should never reach here."); -- cgit v1.2.3 From 19c0f5e9ff625c6a67e5e0a08f0a800782168492 Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Fri, 7 Jun 2019 12:40:36 +0200 Subject: Remove e10s force-enable/-disable prefs and a11y considerations for starting in e10s mode. This resolves #1130 --- dom/ipc/ContentParent.cpp | 17 ---------- toolkit/xre/nsAppRunner.cpp | 79 ++------------------------------------------- 2 files changed, 3 insertions(+), 93 deletions(-) diff --git a/dom/ipc/ContentParent.cpp b/dom/ipc/ContentParent.cpp index 79446151c..97e3a4880 100644 --- a/dom/ipc/ContentParent.cpp +++ b/dom/ipc/ContentParent.cpp @@ -229,11 +229,6 @@ static NS_DEFINE_CID(kCClipboardCID, NS_CLIPBOARD_CID); -#if defined(XP_WIN) -// e10s forced enable pref, defined in nsAppRunner.cpp -extern const char* kForceEnableE10sPref; -#endif - using base::ChildPrivileges; using base::KillProcess; @@ -1275,12 +1270,6 @@ ContentParent::Init() if (nsIPresShell::IsAccessibilityActive()) { #if !defined(XP_WIN) Unused << SendActivateA11y(0); -#else - // On Windows we currently only enable a11y in the content process - // for testing purposes. - if (Preferences::GetBool(kForceEnableE10sPref, false)) { - Unused << SendActivateA11y(a11y::AccessibleWrap::GetContentProcessIdFor(ChildID())); - } #endif } #endif @@ -2573,12 +2562,6 @@ ContentParent::Observe(nsISupports* aSubject, // accessibility gets initiated in chrome process. #if !defined(XP_WIN) Unused << SendActivateA11y(0); -#else - // On Windows we currently only enable a11y in the content process - // for testing purposes. - if (Preferences::GetBool(kForceEnableE10sPref, false)) { - Unused << SendActivateA11y(a11y::AccessibleWrap::GetContentProcessIdFor(ChildID())); - } #endif } else { // If possible, shut down accessibility in content process when diff --git a/toolkit/xre/nsAppRunner.cpp b/toolkit/xre/nsAppRunner.cpp index 4ae70fd43..5a51fd3e7 100644 --- a/toolkit/xre/nsAppRunner.cpp +++ b/toolkit/xre/nsAppRunner.cpp @@ -4232,9 +4232,6 @@ PRTimeToSeconds(PRTime t_usec) } #endif -const char* kForceEnableE10sPref = "browser.tabs.remote.force-enable"; -const char* kForceDisableE10sPref = "browser.tabs.remote.force-disable"; - uint32_t MultiprocessBlockPolicy() { if (gMultiprocessBlockPolicyInitialized) { @@ -4242,50 +4239,6 @@ MultiprocessBlockPolicy() { } gMultiprocessBlockPolicyInitialized = true; - /** - * Avoids enabling e10s if there are add-ons installed. - */ - bool addonsCanDisable = Preferences::GetBool("extensions.e10sBlocksEnabling", false); - bool disabledByAddons = Preferences::GetBool("extensions.e10sBlockedByAddons", false); - - if (addonsCanDisable && disabledByAddons) { - gMultiprocessBlockPolicy = kE10sDisabledForAddons; - } - -#if defined(XP_WIN) - bool disabledForA11y = false; - /** - * Avoids enabling e10s if accessibility has recently loaded. Performs the - * following checks: - * 1) Checks a pref indicating if a11y loaded in the last session. This pref - * is set in nsBrowserGlue.js. If a11y was loaded in the last session we - * do not enable e10s in this session. - * 2) Accessibility stores a last run date (PR_IntervalNow) when it is - * initialized (see nsBaseWidget.cpp). We check if this pref exists and - * compare it to now. If a11y hasn't run in an extended period of time or - * if the date pref does not exist we load e10s. - */ - disabledForA11y = Preferences::GetBool(kAccessibilityLoadedLastSessionPref, false); - if (!disabledForA11y && - Preferences::HasUserValue(kAccessibilityLastRunDatePref)) { - #define ONE_WEEK_IN_SECONDS (60*60*24*7) - uint32_t a11yRunDate = Preferences::GetInt(kAccessibilityLastRunDatePref, 0); - MOZ_ASSERT(0 != a11yRunDate); - // If a11y hasn't run for a period of time, clear the pref and load e10s - uint32_t now = PRTimeToSeconds(PR_Now()); - uint32_t difference = now - a11yRunDate; - if (difference > ONE_WEEK_IN_SECONDS || !a11yRunDate) { - Preferences::ClearUser(kAccessibilityLastRunDatePref); - } else { - disabledForA11y = true; - } - } - - if (disabledForA11y) { - gMultiprocessBlockPolicy = kE10sDisabledForAccessibility; - } -#endif - // We do not support E10S, block by policy. gMultiprocessBlockPolicy = kE10sForceDisabled; @@ -4300,46 +4253,20 @@ mozilla::BrowserTabsRemoteAutostart() } gBrowserTabsRemoteAutostartInitialized = true; - // If we're in the content process, we are running E10S. - if (XRE_IsContentProcess()) { - gBrowserTabsRemoteAutostart = true; - return gBrowserTabsRemoteAutostart; - } - bool optInPref = Preferences::GetBool("browser.tabs.remote.autostart", false); bool trialPref = Preferences::GetBool("browser.tabs.remote.autostart.2", false); bool prefEnabled = optInPref || trialPref; int status; - if (optInPref) { - status = kE10sEnabledByUser; - } else if (trialPref) { - status = kE10sEnabledByDefault; - } else { - status = kE10sDisabledByUser; - } if (prefEnabled) { uint32_t blockPolicy = MultiprocessBlockPolicy(); if (blockPolicy != 0) { status = blockPolicy; } else { - gBrowserTabsRemoteAutostart = true; + MOZ_CRASH("e10s force enabled bypassing policy -- unsupported configuration"); } - } - - // Uber override pref for manual testing purposes - if (Preferences::GetBool(kForceEnableE10sPref, false)) { - gBrowserTabsRemoteAutostart = true; - prefEnabled = true; - status = kE10sEnabledByUser; - } - - // Uber override pref for emergency blocking - if (gBrowserTabsRemoteAutostart && - (Preferences::GetBool(kForceDisableE10sPref, false) || - EnvHasValue("MOZ_FORCE_DISABLE_E10S"))) { - gBrowserTabsRemoteAutostart = false; - status = kE10sForceDisabled; + } else { + status = kE10sDisabledByUser; } gBrowserTabsRemoteStatus = status; -- cgit v1.2.3 From e34920575d6dac353cb3d8a5d1b9c11ae05c5a8c Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Mon, 10 Jun 2019 16:49:47 +0000 Subject: Inline combined methods for NativeObject and UnboxedArrayObject accesses. --- js/src/jit/BaselineIC.cpp | 34 +++++----- js/src/jit/BaselineIC.h | 12 ++-- js/src/jit/BaselineInspector.cpp | 2 +- js/src/jit/BaselineInspector.h | 2 +- js/src/jit/MCallOptimize.cpp | 10 +-- js/src/jit/VMFunctions.cpp | 2 +- js/src/jsarray.cpp | 117 ++++++++++++++++++--------------- js/src/jsobj.cpp | 22 ++++--- js/src/vm/UnboxedObject-inl.h | 138 +++------------------------------------ 9 files changed, 115 insertions(+), 224 deletions(-) diff --git a/js/src/jit/BaselineIC.cpp b/js/src/jit/BaselineIC.cpp index 1d230e083..28e263ac7 100644 --- a/js/src/jit/BaselineIC.cpp +++ b/js/src/jit/BaselineIC.cpp @@ -2373,8 +2373,8 @@ CanOptimizeDenseOrUnboxedArraySetElem(JSObject* obj, uint32_t index, Shape* oldShape, uint32_t oldCapacity, uint32_t oldInitLength, bool* isAddingCaseOut, size_t* protoDepthOut) { - uint32_t initLength = GetAnyBoxedOrUnboxedInitializedLength(obj); - uint32_t capacity = GetAnyBoxedOrUnboxedCapacity(obj); + uint32_t initLength = obj->as().getDenseInitializedLength(); + uint32_t capacity = obj->as().getDenseCapacity(); *isAddingCaseOut = false; *protoDepthOut = 0; @@ -2464,8 +2464,8 @@ DoSetElemFallback(JSContext* cx, BaselineFrame* frame, ICSetElem_Fallback* stub_ uint32_t oldCapacity = 0; uint32_t oldInitLength = 0; if (index.isInt32() && index.toInt32() >= 0) { - oldCapacity = GetAnyBoxedOrUnboxedCapacity(obj); - oldInitLength = GetAnyBoxedOrUnboxedInitializedLength(obj); + oldCapacity = obj->as().getDenseCapacity(); + oldInitLength = obj->as().getDenseInitializedLength(); } if (op == JSOP_INITELEM || op == JSOP_INITHIDDENELEM) { @@ -5762,14 +5762,14 @@ TryAttachCallStub(JSContext* cx, ICCall_Fallback* stub, HandleScript script, jsb } static bool -CopyArray(JSContext* cx, HandleObject obj, MutableHandleValue result) +CopyArray(JSContext* cx, HandleArrayObject arr, MutableHandleValue result) { - uint32_t length = GetAnyBoxedOrUnboxedArrayLength(obj); - JSObject* nobj = NewFullyAllocatedArrayTryReuseGroup(cx, obj, length, TenuredObject); + uint32_t length = arr->length(); + JSObject* nobj = NewFullyAllocatedArrayTryReuseGroup(cx, arr, length, TenuredObject); if (!nobj) return false; EnsureArrayGroupAnalyzed(cx, nobj); - CopyBoxedOrUnboxedDenseElements(cx, nobj, obj, 0, 0, length); + CopyBoxedOrUnboxedDenseElements(cx, nobj, arr, 0, 0, length); result.setObject(*nobj); return true; @@ -5801,26 +5801,22 @@ TryAttachStringSplit(JSContext* cx, ICCall_Fallback* stub, HandleScript script, RootedValue arr(cx); // Copy the array before storing in stub. - if (!CopyArray(cx, obj, &arr)) + if (!CopyArray(cx, obj.as(), &arr)) return false; // Atomize all elements of the array. - RootedObject arrObj(cx, &arr.toObject()); - uint32_t initLength = GetAnyBoxedOrUnboxedArrayLength(arrObj); + RootedArrayObject arrObj(cx, &arr.toObject().as()); + uint32_t initLength = arrObj->length(); for (uint32_t i = 0; i < initLength; i++) { - JSAtom* str = js::AtomizeString(cx, GetAnyBoxedOrUnboxedDenseElement(arrObj, i).toString()); + JSAtom* str = js::AtomizeString(cx, arrObj->getDenseElement(i).toString()); if (!str) return false; - if (!SetAnyBoxedOrUnboxedDenseElement(cx, arrObj, i, StringValue(str))) { - // The value could not be stored to an unboxed dense element. - return true; - } + arrObj->setDenseElementWithType(cx, i, StringValue(str)); } ICCall_StringSplit::Compiler compiler(cx, stub->fallbackMonitorStub()->firstMonitorStub(), - script->pcToOffset(pc), str, sep, - arr); + script->pcToOffset(pc), str, sep, arrObj); ICStub* newStub = compiler.getStub(compiler.getStubSpace(script)); if (!newStub) return false; @@ -6705,7 +6701,7 @@ ICCallScriptedCompiler::generateStubCode(MacroAssembler& masm) return true; } -typedef bool (*CopyArrayFn)(JSContext*, HandleObject, MutableHandleValue); +typedef bool (*CopyArrayFn)(JSContext*, HandleArrayObject, MutableHandleValue); static const VMFunction CopyArrayInfo = FunctionInfo(CopyArray, "CopyArray"); bool diff --git a/js/src/jit/BaselineIC.h b/js/src/jit/BaselineIC.h index afbea3b69..901fca9cc 100644 --- a/js/src/jit/BaselineIC.h +++ b/js/src/jit/BaselineIC.h @@ -2818,10 +2818,10 @@ class ICCall_StringSplit : public ICMonitoredStub uint32_t pcOffset_; GCPtrString expectedStr_; GCPtrString expectedSep_; - GCPtrObject templateObject_; + GCPtrArrayObject templateObject_; ICCall_StringSplit(JitCode* stubCode, ICStub* firstMonitorStub, uint32_t pcOffset, JSString* str, - JSString* sep, JSObject* templateObject) + JSString* sep, ArrayObject* templateObject) : ICMonitoredStub(ICStub::Call_StringSplit, stubCode, firstMonitorStub), pcOffset_(pcOffset), expectedStr_(str), expectedSep_(sep), templateObject_(templateObject) @@ -2848,7 +2848,7 @@ class ICCall_StringSplit : public ICMonitoredStub return expectedSep_; } - GCPtrObject& templateObject() { + GCPtrArrayObject& templateObject() { return templateObject_; } @@ -2858,7 +2858,7 @@ class ICCall_StringSplit : public ICMonitoredStub uint32_t pcOffset_; RootedString expectedStr_; RootedString expectedSep_; - RootedObject templateObject_; + RootedArrayObject templateObject_; MOZ_MUST_USE bool generateStubCode(MacroAssembler& masm); @@ -2869,13 +2869,13 @@ class ICCall_StringSplit : public ICMonitoredStub public: Compiler(JSContext* cx, ICStub* firstMonitorStub, uint32_t pcOffset, HandleString str, - HandleString sep, HandleValue templateObject) + HandleString sep, HandleArrayObject templateObject) : ICCallStubCompiler(cx, ICStub::Call_StringSplit), firstMonitorStub_(firstMonitorStub), pcOffset_(pcOffset), expectedStr_(cx, str), expectedSep_(cx, sep), - templateObject_(cx, &templateObject.toObject()) + templateObject_(cx, templateObject) { } ICStub* getStub(ICStubSpace* space) { diff --git a/js/src/jit/BaselineInspector.cpp b/js/src/jit/BaselineInspector.cpp index 9c7b88fb2..bcb527516 100644 --- a/js/src/jit/BaselineInspector.cpp +++ b/js/src/jit/BaselineInspector.cpp @@ -580,7 +580,7 @@ BaselineInspector::getTemplateObjectForNative(jsbytecode* pc, Native native) bool BaselineInspector::isOptimizableCallStringSplit(jsbytecode* pc, JSString** strOut, JSString** sepOut, - JSObject** objOut) + ArrayObject** objOut) { if (!hasBaselineScript()) return false; diff --git a/js/src/jit/BaselineInspector.h b/js/src/jit/BaselineInspector.h index 4a1791798..1ed4b5547 100644 --- a/js/src/jit/BaselineInspector.h +++ b/js/src/jit/BaselineInspector.h @@ -113,7 +113,7 @@ class BaselineInspector bool hasSeenNonStringIterMore(jsbytecode* pc); MOZ_MUST_USE bool isOptimizableCallStringSplit(jsbytecode* pc, JSString** strOut, - JSString** sepOut, JSObject** objOut); + JSString** sepOut, ArrayObject** objOut); JSObject* getTemplateObject(jsbytecode* pc); JSObject* getTemplateObjectForNative(jsbytecode* pc, Native native); JSObject* getTemplateObjectForClassHook(jsbytecode* pc, const Class* clasp); diff --git a/js/src/jit/MCallOptimize.cpp b/js/src/jit/MCallOptimize.cpp index 748a70973..0d5779cee 100644 --- a/js/src/jit/MCallOptimize.cpp +++ b/js/src/jit/MCallOptimize.cpp @@ -522,7 +522,7 @@ IonBuilder::inlineArray(CallInfo& callInfo) // Make sure initLength matches the template object's length. This is // not guaranteed to be the case, for instance if we're inlining the // MConstant may come from an outer script. - if (initLength != GetAnyBoxedOrUnboxedArrayLength(templateObject)) + if (initLength != templateObject->as().length()) return InliningStatus_NotInlined; // Don't inline large allocations. @@ -1396,7 +1396,7 @@ IonBuilder::inlineConstantStringSplitString(CallInfo& callInfo) // Check if exist a template object in stub. JSString* stringStr = nullptr; JSString* stringSep = nullptr; - JSObject* templateObject = nullptr; + ArrayObject* templateObject = nullptr; if (!inspector->isOptimizableCallStringSplit(pc, &stringStr, &stringSep, &templateObject)) return InliningStatus_NotInlined; @@ -1422,13 +1422,13 @@ IonBuilder::inlineConstantStringSplitString(CallInfo& callInfo) if (!key.maybeTypes()->hasType(TypeSet::StringType())) return InliningStatus_NotInlined; - uint32_t initLength = GetAnyBoxedOrUnboxedArrayLength(templateObject); - if (GetAnyBoxedOrUnboxedInitializedLength(templateObject) != initLength) + uint32_t initLength = templateObject->length(); + if (templateObject->getDenseInitializedLength() != initLength) return InliningStatus_NotInlined; Vector arrayValues; for (uint32_t i = 0; i < initLength; i++) { - Value str = GetAnyBoxedOrUnboxedDenseElement(templateObject, i); + Value str = templateObject->getDenseElement(i); MOZ_ASSERT(str.toString()->isAtom()); MConstant* value = MConstant::New(alloc().fallible(), str, constraints()); if (!value) diff --git a/js/src/jit/VMFunctions.cpp b/js/src/jit/VMFunctions.cpp index 0717bb86d..7b1e1cad6 100644 --- a/js/src/jit/VMFunctions.cpp +++ b/js/src/jit/VMFunctions.cpp @@ -339,7 +339,7 @@ ArrayPopDense(JSContext* cx, HandleObject obj, MutableHandleValue rval) bool ArrayPushDense(JSContext* cx, HandleObject obj, HandleValue v, uint32_t* length) { - *length = GetAnyBoxedOrUnboxedArrayLength(obj); + *length = obj->as().length(); DenseElementResult result = SetOrExtendBoxedOrUnboxedDenseElements(cx, obj, *length, v.address(), 1, ShouldUpdateTypes::DontUpdate); diff --git a/js/src/jsarray.cpp b/js/src/jsarray.cpp index a8bd3f028..da692c1b5 100644 --- a/js/src/jsarray.cpp +++ b/js/src/jsarray.cpp @@ -248,18 +248,20 @@ static bool GetElement(JSContext* cx, HandleObject obj, HandleObject receiver, uint32_t index, bool* hole, MutableHandleValue vp) { - AssertGreaterThanZero(index); - if (index < GetAnyBoxedOrUnboxedInitializedLength(obj)) { - vp.set(GetAnyBoxedOrUnboxedDenseElement(obj, uint32_t(index))); - if (!vp.isMagic(JS_ELEMENTS_HOLE)) { - *hole = false; - return true; + if (obj->isNative()) { + NativeObject* nobj = &obj->as(); + if (index < nobj->getDenseInitializedLength()) { + vp.set(nobj->getDenseElement(size_t(index))); + if (!vp.isMagic(JS_ELEMENTS_HOLE)) { + *hole = false; + return true; + } } - } - if (obj->is()) { - if (obj->as().maybeGetElement(uint32_t(index), vp)) { - *hole = false; - return true; + if (nobj->is() && index <= UINT32_MAX) { + if (nobj->as().maybeGetElement(uint32_t(index), vp)) { + *hole = false; + return true; + } } } @@ -337,11 +339,11 @@ GetBoxedOrUnboxedDenseElements(JSObject* aobj, uint32_t length, Value* vp) { MOZ_ASSERT(!ObjectMayHaveExtraIndexedProperties(aobj)); - if (length > GetBoxedOrUnboxedInitializedLength(aobj)) + if (length > aobj->as().getDenseInitializedLength()) return DenseElementResult::Incomplete; for (size_t i = 0; i < length; i++) { - vp[i] = GetBoxedOrUnboxedDenseElement(aobj, i); + vp[i] = aobj->as().getDenseElement(i); // No other indexed properties so hole => undefined. if (vp[i].isMagic(JS_ELEMENTS_HOLE)) @@ -849,7 +851,7 @@ js::ObjectMayHaveExtraIndexedProperties(JSObject* obj) if (ObjectMayHaveExtraIndexedOwnProperties(obj)) return true; - if (GetAnyBoxedOrUnboxedInitializedLength(obj) != 0) + if (obj->as().getDenseInitializedLength() != 0) return true; } while (true); } @@ -1068,12 +1070,13 @@ ArrayJoinDenseKernel(JSContext* cx, SeparatorOp sepOp, HandleObject obj, uint32_ // length > initLength we rely on the second loop to add the // other elements. MOZ_ASSERT(*numProcessed == 0); - uint32_t initLength = Min(GetBoxedOrUnboxedInitializedLength(obj), length); + uint32_t initLength = Min(obj->as().getDenseInitializedLength(), + length); while (*numProcessed < initLength) { if (!CheckForInterrupt(cx)) return DenseElementResult::Failure; - Value elem = GetBoxedOrUnboxedDenseElement(obj, *numProcessed); + Value elem = obj->as().getDenseElement(*numProcessed); if (elem.isString()) { if (!sb.append(elem.toString())) @@ -1207,11 +1210,14 @@ js::array_join(JSContext* cx, unsigned argc, Value* vp) // An optimized version of a special case of steps 7-11: when length==1 and // the 0th element is a string, ToString() of that element is a no-op and // so it can be immediately returned as the result. - if (length == 1 && GetAnyBoxedOrUnboxedInitializedLength(obj) == 1) { - Value elem0 = GetAnyBoxedOrUnboxedDenseElement(obj, 0); - if (elem0.isString()) { - args.rval().set(elem0); - return true; + if (length == 1 && obj->isNative()) { + NativeObject* nobj = &obj->as(); + if (nobj->getDenseInitializedLength() == 1) { + Value elem0 = nobj->getDenseElement(0); + if (elem0.isString()) { + args.rval().set(elem0); + return true; + } } } @@ -1359,7 +1365,7 @@ DenseElementResult ArrayReverseDenseKernel(JSContext* cx, HandleObject obj, uint32_t length) { /* An empty array or an array with no elements is already reversed. */ - if (length == 0 || GetBoxedOrUnboxedInitializedLength(obj) == 0) + if (length == 0 || obj->as().getDenseInitializedLength() == 0) return DenseElementResult::Success; if (obj->as().denseElementsAreFrozen()) @@ -1385,15 +1391,15 @@ ArrayReverseDenseKernel(JSContext* cx, HandleObject obj, uint32_t length) uint32_t lo = 0, hi = length - 1; for (; lo < hi; lo++, hi--) { - origlo = GetBoxedOrUnboxedDenseElement(obj, lo); - orighi = GetBoxedOrUnboxedDenseElement(obj, hi); - SetBoxedOrUnboxedDenseElementNoTypeChange(obj, lo, orighi); + origlo = obj->as().getDenseElement(lo); + orighi = obj->as().getDenseElement(hi); + obj->as().setDenseElement(lo, orighi); if (orighi.isMagic(JS_ELEMENTS_HOLE) && !SuppressDeletedProperty(cx, obj, INT_TO_JSID(lo))) { return DenseElementResult::Failure; } - SetBoxedOrUnboxedDenseElementNoTypeChange(obj, hi, origlo); + obj->as().setDenseElement(hi, origlo); if (origlo.isMagic(JS_ELEMENTS_HOLE) && !SuppressDeletedProperty(cx, obj, INT_TO_JSID(hi))) { @@ -2074,14 +2080,8 @@ js::array_push(JSContext* cx, unsigned argc, Value* vp) uint32_t newlength = length + args.length(); args.rval().setNumber(newlength); - // SetOrExtendBoxedOrUnboxedDenseElements takes care of updating the - // length for boxed and unboxed arrays. Handle updates to the length of - // non-arrays here. - bool isArray; - if (!IsArray(cx, obj, &isArray)) - return false; - - if (!isArray) + // Handle updates to the length of non-arrays here. + if (!obj->is()) return SetLengthProperty(cx, obj, newlength); return true; @@ -2141,14 +2141,15 @@ template static inline DenseElementResult ShiftMoveBoxedOrUnboxedDenseElements(JSObject* obj) { - MOZ_ASSERT(HasBoxedOrUnboxedDenseElements(obj)); + MOZ_ASSERT(obj->isNative()); + + size_t initlen = obj->as().getDenseInitializedLength(); /* * At this point the length and initialized length have already been * decremented and the result fetched, so just shift the array elements * themselves. */ - size_t initlen = GetBoxedOrUnboxedInitializedLength(obj); obj->as().moveDenseElementsNoPreBarrier(0, 1, initlen); return DenseElementResult::Success; @@ -2165,6 +2166,15 @@ js::ArrayShiftMoveElements(JSObject* obj) JS_ALWAYS_TRUE(CallBoxedOrUnboxedSpecialization(functor, obj) == DenseElementResult::Success); } +static inline void +SetInitializedLength(JSContext* cx, NativeObject* obj, size_t initlen) +{ + size_t oldInitlen = obj->getDenseInitializedLength(); + obj->setDenseInitializedLength(initlen); + if (initlen < oldInitlen) + obj->shrinkElements(cx, initlen); +} + template DenseElementResult ArrayShiftDenseKernel(JSContext* cx, HandleObject obj, MutableHandleValue rval) @@ -2179,11 +2189,11 @@ ArrayShiftDenseKernel(JSContext* cx, HandleObject obj, MutableHandleValue rval) if (MOZ_UNLIKELY(group->hasAllFlags(OBJECT_FLAG_ITERATED))) return DenseElementResult::Incomplete; - size_t initlen = GetBoxedOrUnboxedInitializedLength(obj); + size_t initlen = obj->as().getDenseInitializedLength(); if (initlen == 0) return DenseElementResult::Incomplete; - rval.set(GetBoxedOrUnboxedDenseElement(obj, 0)); + rval.set(obj->as().getDenseElement(0)); if (rval.isMagic(JS_ELEMENTS_HOLE)) rval.setUndefined(); @@ -2191,7 +2201,7 @@ ArrayShiftDenseKernel(JSContext* cx, HandleObject obj, MutableHandleValue rval) if (result != DenseElementResult::Success) return result; - SetBoxedOrUnboxedInitializedLength(cx, obj, initlen - 1); + SetInitializedLength(cx, obj.as(), initlen - 1); return DenseElementResult::Success; } @@ -2364,7 +2374,7 @@ CanOptimizeForDenseStorage(HandleObject arr, uint32_t startingIndex, uint32_t co return false; /* If it's a frozen array, always pick the slow path */ - if (arr->is() && arr->as().denseElementsAreFrozen()) + if (arr->as().denseElementsAreFrozen()) return false; /* @@ -2396,7 +2406,7 @@ CanOptimizeForDenseStorage(HandleObject arr, uint32_t startingIndex, uint32_t co * is subsumed by the initializedLength comparison.) */ return !ObjectMayHaveExtraIndexedProperties(arr) && - startingIndex + count <= GetAnyBoxedOrUnboxedInitializedLength(arr); + startingIndex + count <= arr->as().getDenseInitializedLength(); } /* ES 2016 draft Mar 25, 2016 22.1.3.26. */ @@ -2541,7 +2551,7 @@ js::array_splice_impl(JSContext* cx, unsigned argc, Value* vp, bool returnValueI return false; /* Steps 15.c-d. */ - SetBoxedOrUnboxedInitializedLength(cx, obj, finalLength); + SetInitializedLength(cx, obj.as(), finalLength); } else { /* * This is all very slow if the length is very large. We don't yet @@ -2629,7 +2639,7 @@ js::array_splice_impl(JSContext* cx, unsigned argc, Value* vp, bool returnValueI return false; /* Steps 16.a-b. */ - SetBoxedOrUnboxedInitializedLength(cx, obj, len + itemCount - actualDeleteCount); + SetInitializedLength(cx, obj.as(), len + itemCount - actualDeleteCount); } else { RootedValue fromValue(cx); for (double k = len - actualDeleteCount; k > actualStart; k--) { @@ -2851,7 +2861,7 @@ ArraySliceOrdinary(JSContext* cx, HandleObject obj, uint32_t length, uint32_t be begin = end; if (!ObjectMayHaveExtraIndexedProperties(obj)) { - size_t initlen = GetAnyBoxedOrUnboxedInitializedLength(obj); + size_t initlen = obj->as().getDenseInitializedLength(); size_t count = 0; if (initlen > begin) count = Min(initlen - begin, end - begin); @@ -2859,7 +2869,9 @@ ArraySliceOrdinary(JSContext* cx, HandleObject obj, uint32_t length, uint32_t be RootedObject narr(cx, NewFullyAllocatedArrayTryReuseGroup(cx, obj, count)); if (!narr) return false; - SetAnyBoxedOrUnboxedArrayLength(cx, narr, end - begin); + + MOZ_ASSERT(count >= narr->as().length()); + narr->as().setLength(cx, count); if (count) { DebugOnly result = @@ -2991,7 +3003,7 @@ template DenseElementResult ArraySliceDenseKernel(JSContext* cx, JSObject* obj, int32_t beginArg, int32_t endArg, JSObject* result) { - int32_t length = GetAnyBoxedOrUnboxedArrayLength(obj); + int32_t length = obj->as().length(); uint32_t begin = NormalizeSliceTerm(beginArg, length); uint32_t end = NormalizeSliceTerm(endArg, length); @@ -2999,18 +3011,19 @@ ArraySliceDenseKernel(JSContext* cx, JSObject* obj, int32_t beginArg, int32_t en if (begin > end) begin = end; - size_t initlen = GetBoxedOrUnboxedInitializedLength(obj); + size_t initlen = obj->as().getDenseInitializedLength(); + size_t count = Min(initlen - begin, end - begin); if (initlen > begin) { - size_t count = Min(initlen - begin, end - begin); if (count) { - DenseElementResult rv = EnsureBoxedOrUnboxedDenseElements(cx, result, count); - if (rv != DenseElementResult::Success) - return rv; + if (!result->as().ensureElements(cx, count)) + return DenseElementResult::Failure; CopyBoxedOrUnboxedDenseElements(cx, result, obj, 0, begin, count); } } - SetAnyBoxedOrUnboxedArrayLength(cx, result, end - begin); + MOZ_ASSERT(count >= result->as().length()); + result->as().setLength(cx, count); + return DenseElementResult::Success; } diff --git a/js/src/jsobj.cpp b/js/src/jsobj.cpp index c26a42f48..deaa1d53e 100644 --- a/js/src/jsobj.cpp +++ b/js/src/jsobj.cpp @@ -1143,19 +1143,18 @@ js::CloneObject(JSContext* cx, HandleObject obj, Handle proto) } static bool -GetScriptArrayObjectElements(JSContext* cx, HandleObject obj, MutableHandle> values) +GetScriptArrayObjectElements(JSContext* cx, HandleArrayObject arr, MutableHandle> values) { - MOZ_ASSERT(!obj->isSingleton()); - MOZ_ASSERT(obj->is()); - MOZ_ASSERT(!obj->isIndexed()); + MOZ_ASSERT(!arr->isSingleton()); + MOZ_ASSERT(!arr->isIndexed()); - size_t length = GetAnyBoxedOrUnboxedArrayLength(obj); + size_t length = arr->length(); if (!values.appendN(MagicValue(JS_ELEMENTS_HOLE), length)) return false; - size_t initlen = GetAnyBoxedOrUnboxedInitializedLength(obj); + size_t initlen = arr->getDenseInitializedLength(); for (size_t i = 0; i < initlen; i++) - values[i].set(GetAnyBoxedOrUnboxedDenseElement(obj, i)); + values[i].set(arr->getDenseElement(i)); return true; } @@ -1212,7 +1211,7 @@ js::DeepCloneObjectLiteral(JSContext* cx, HandleObject obj, NewObjectKind newKin if (obj->is()) { Rooted> values(cx, GCVector(cx)); - if (!GetScriptArrayObjectElements(cx, obj, &values)) + if (!GetScriptArrayObjectElements(cx, obj.as(), &values)) return nullptr; // Deep clone any elements. @@ -1339,8 +1338,11 @@ js::XDRObjectLiteral(XDRState* xdr, MutableHandleObject obj) if (isArray) { Rooted> values(cx, GCVector(cx)); - if (mode == XDR_ENCODE && !GetScriptArrayObjectElements(cx, obj, &values)) - return false; + if (mode == XDR_ENCODE) { + RootedArrayObject arr(cx, &obj->as()); + if (!GetScriptArrayObjectElements(cx, arr, &values)) + return false; + } uint32_t initialized; if (mode == XDR_ENCODE) diff --git a/js/src/vm/UnboxedObject-inl.h b/js/src/vm/UnboxedObject-inl.h index 499f3604b..b308464fe 100644 --- a/js/src/vm/UnboxedObject-inl.h +++ b/js/src/vm/UnboxedObject-inl.h @@ -172,130 +172,10 @@ UnboxedPlainObject::layout() const return group()->unboxedLayout(); } -///////////////////////////////////////////////////////////////////// -// Combined methods for NativeObject and UnboxedArrayObject accesses. -///////////////////////////////////////////////////////////////////// - -static inline bool -HasAnyBoxedOrUnboxedDenseElements(JSObject* obj) -{ - return obj->isNative(); -} - -static inline size_t -GetAnyBoxedOrUnboxedInitializedLength(JSObject* obj) -{ - if (obj->isNative()) - return obj->as().getDenseInitializedLength(); - return 0; -} - -static inline size_t -GetAnyBoxedOrUnboxedCapacity(JSObject* obj) -{ - if (obj->isNative()) - return obj->as().getDenseCapacity(); - return 0; -} - -static inline Value -GetAnyBoxedOrUnboxedDenseElement(JSObject* obj, size_t index) -{ - return obj->as().getDenseElement(index); -} - -static inline size_t -GetAnyBoxedOrUnboxedArrayLength(JSObject* obj) -{ - return obj->as().length(); -} - -static inline void -SetAnyBoxedOrUnboxedArrayLength(JSContext* cx, JSObject* obj, size_t length) -{ - MOZ_ASSERT(length >= obj->as().length()); - obj->as().setLength(cx, length); -} - -static inline bool -SetAnyBoxedOrUnboxedDenseElement(JSContext* cx, JSObject* obj, size_t index, const Value& value) -{ - obj->as().setDenseElementWithType(cx, index, value); - return true; -} - -static inline bool -InitAnyBoxedOrUnboxedDenseElement(JSContext* cx, JSObject* obj, size_t index, const Value& value) -{ - obj->as().initDenseElementWithType(cx, index, value); - return true; -} - ///////////////////////////////////////////////////////////////////// // Template methods for NativeObject and UnboxedArrayObject accesses. ///////////////////////////////////////////////////////////////////// -static inline JSValueType -GetBoxedOrUnboxedType(JSObject* obj) -{ - return JSVAL_TYPE_MAGIC; -} - -static inline bool -HasBoxedOrUnboxedDenseElements(JSObject* obj) -{ - return obj->isNative(); -} - -static inline size_t -GetBoxedOrUnboxedInitializedLength(JSObject* obj) -{ - return obj->as().getDenseInitializedLength(); -} - -static inline DenseElementResult -SetBoxedOrUnboxedInitializedLength(JSContext* cx, JSObject* obj, size_t initlen) -{ - size_t oldInitlen = GetBoxedOrUnboxedInitializedLength(obj); - obj->as().setDenseInitializedLength(initlen); - if (initlen < oldInitlen) - obj->as().shrinkElements(cx, initlen); - return DenseElementResult::Success; -} - -static inline size_t -GetBoxedOrUnboxedCapacity(JSObject* obj) -{ - return obj->as().getDenseCapacity(); -} - -static inline Value -GetBoxedOrUnboxedDenseElement(JSObject* obj, size_t index) -{ - return obj->as().getDenseElement(index); -} - -static inline void -SetBoxedOrUnboxedDenseElementNoTypeChange(JSObject* obj, size_t index, const Value& value) -{ - obj->as().setDenseElement(index, value); -} - -static inline bool -SetBoxedOrUnboxedDenseElement(JSContext* cx, JSObject* obj, size_t index, const Value& value) -{ - obj->as().setDenseElementWithType(cx, index, value); - return true; -} - -static inline DenseElementResult -EnsureBoxedOrUnboxedDenseElements(JSContext* cx, JSObject* obj, size_t count) -{ - if (!obj->as().ensureElements(cx, count)) - return DenseElementResult::Failure; - return DenseElementResult::Success; -} - static inline DenseElementResult SetOrExtendBoxedOrUnboxedDenseElements(ExclusiveContext* cx, JSObject* obj, uint32_t start, const Value* vp, uint32_t count, @@ -334,7 +214,7 @@ static inline DenseElementResult MoveBoxedOrUnboxedDenseElements(JSContext* cx, JSObject* obj, uint32_t dstStart, uint32_t srcStart, uint32_t length) { - MOZ_ASSERT(HasBoxedOrUnboxedDenseElements(obj)); + MOZ_ASSERT(obj->isNative()); if (obj->as().denseElementsAreFrozen()) return DenseElementResult::Incomplete; @@ -350,13 +230,13 @@ static inline DenseElementResult CopyBoxedOrUnboxedDenseElements(JSContext* cx, JSObject* dst, JSObject* src, uint32_t dstStart, uint32_t srcStart, uint32_t length) { - MOZ_ASSERT(HasBoxedOrUnboxedDenseElements(src)); - MOZ_ASSERT(HasBoxedOrUnboxedDenseElements(dst)); - MOZ_ASSERT(GetBoxedOrUnboxedInitializedLength(dst) == dstStart); - MOZ_ASSERT(GetBoxedOrUnboxedInitializedLength(src) >= srcStart + length); - MOZ_ASSERT(GetBoxedOrUnboxedCapacity(dst) >= dstStart + length); + MOZ_ASSERT(src->isNative()); + MOZ_ASSERT(dst->isNative()); + MOZ_ASSERT(dst->as().getDenseInitializedLength() == dstStart); + MOZ_ASSERT(src->as().getDenseInitializedLength() >= srcStart + length); + MOZ_ASSERT(dst->as().getDenseCapacity() >= dstStart + length); - SetBoxedOrUnboxedInitializedLength(cx, dst, dstStart + length); + dst->as().setDenseInitializedLength(dstStart + length); const Value* vp = src->as().getDenseElements() + srcStart; dst->as().initDenseElements(dstStart, vp, length); @@ -383,7 +263,7 @@ template DenseElementResult CallBoxedOrUnboxedSpecialization(F f, JSObject* obj) { - if (!HasAnyBoxedOrUnboxedDenseElements(obj)) + if (!obj->isNative()) return DenseElementResult::Incomplete; return f. DEPENDENT_TEMPLATE_HINT operator()(); } @@ -393,7 +273,7 @@ template DenseElementResult CallBoxedOrUnboxedSpecialization(F f, JSObject* obj1, JSObject* obj2) { - if (!HasAnyBoxedOrUnboxedDenseElements(obj1) || !HasAnyBoxedOrUnboxedDenseElements(obj2)) + if (!obj1->isNative() || !obj2->isNative()) return DenseElementResult::Incomplete; return f. DEPENDENT_TEMPLATE_HINT operator()(); -- cgit v1.2.3 From a072b02d9305ac35e9698f272ef9fe2f99420791 Mon Sep 17 00:00:00 2001 From: Ascrod <32915892+Ascrod@users.noreply.github.com> Date: Mon, 10 Jun 2019 16:34:50 -0400 Subject: Issue #1132 - Add application executable location to the about:support page. --- toolkit/content/aboutSupport.js | 1 + toolkit/content/aboutSupport.xhtml | 9 +++++++++ toolkit/locales/en-US/chrome/global/aboutSupport.dtd | 1 + 3 files changed, 11 insertions(+) diff --git a/toolkit/content/aboutSupport.js b/toolkit/content/aboutSupport.js index b1d7ab5f6..8908a0f80 100644 --- a/toolkit/content/aboutSupport.js +++ b/toolkit/content/aboutSupport.js @@ -40,6 +40,7 @@ var snapshotFormatters = { $("application-box").textContent = data.name; $("useragent-box").textContent = data.userAgent; $("os-box").textContent = data.osVersion; + $("binary-box").textContent = Services.dirsvc.get("XREExeF", Ci.nsIFile).path; $("supportLink").href = data.supportURL; let version = AppConstants.MOZ_APP_VERSION_DISPLAY; if (data.versionArch) { diff --git a/toolkit/content/aboutSupport.xhtml b/toolkit/content/aboutSupport.xhtml index 5eb64d437..5e6319182 100644 --- a/toolkit/content/aboutSupport.xhtml +++ b/toolkit/content/aboutSupport.xhtml @@ -147,6 +147,15 @@ + + + &aboutSupport.appBasicsBinary; + + + + + + #ifdef XP_WIN diff --git a/toolkit/locales/en-US/chrome/global/aboutSupport.dtd b/toolkit/locales/en-US/chrome/global/aboutSupport.dtd index a0dd3531b..a2477fb2e 100644 --- a/toolkit/locales/en-US/chrome/global/aboutSupport.dtd +++ b/toolkit/locales/en-US/chrome/global/aboutSupport.dtd @@ -45,6 +45,7 @@ This is likely the same like id.heading in crashes.dtd. --> + - + id="svg2" + height="44.113129" + width="314.56464"> + id="filter4610" + style="color-interpolation-filters:sRGB"> + flood-color="rgb(252,252,247)" + flood-opacity="1" /> + operator="in" + in2="SourceGraphic" + in="flood" /> + stdDeviation="1" + in="composite1" /> + dy="0" + dx="2.77556e-017" /> + operator="over" + in2="offset" + in="SourceGraphic" /> - @@ -83,100 +51,83 @@ image/svg+xml - + + transform="translate(-29.067649,-53.687969)" + id="layer1">   + x="34.479874" + id="tspan2987">      + style="font-style:normal;font-weight:normal;font-size:48px;line-height:125%;font-family:'Museo 500';-inkscape-font-specification:'Museo 500';letter-spacing:0px;word-spacing:0px;fill:#0b3575;fill-opacity:1;stroke:none;filter:url(#filter4610)"> + style="fill:#0b3575;fill-opacity:1;stroke-width:1.06666672" /> + style="fill:#0b3575;fill-opacity:1;stroke-width:1.06666672" /> + style="fill:#0b3575;fill-opacity:1;stroke-width:1.06666672" /> + style="fill:#0b3575;fill-opacity:1;stroke-width:1.06666672" /> + style="fill:#0b3575;fill-opacity:1;stroke-width:1.06666672" /> + style="fill:#0b3575;fill-opacity:1;stroke-width:1.06666672" /> + style="fill:#0b3575;fill-opacity:1;stroke-width:1.06666672" /> + style="fill:#0b3575;fill-opacity:1;stroke-width:1.06666672" /> + style="font-style:normal;font-weight:normal;font-size:10px;line-height:125%;font-family:'Museo 500';-inkscape-font-specification:'Museo 500';letter-spacing:0px;word-spacing:0px;fill:#0b3575;fill-opacity:1;stroke:none;filter:url(#filter4610)"> + style="fill:#0b3575;fill-opacity:1;stroke-width:1.06666672" /> + style="fill:#0b3575;fill-opacity:1;stroke-width:1.06666672" /> -- cgit v1.2.3 From 32e6b0f4711cd65ec513f3f3aa64779293b458be Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Fri, 28 Jun 2019 19:47:49 +0200 Subject: Revert "Treat *.jnlp as an executable class file, like *.jar" Rationale: This was a Mozilla oversight and/or error. This change has caused harm and is causing users to switch back to Chrome, Safari or Edge for their WebStart needs. JNLP is not an executable and should not be treated as such. JNLP should be treated the same as any (e.g. Word) document and allowed to be opened with the designated program. A JNLP file will not cause execution on a system unless it has a valid signature, and the user explicitly authorizes the launching based on information provided by the signature. Moreover, there will even be a check by the Java environment to see if the Java runtime (if there is one) is current, and prompt the user to update if required. This reverts commit 21495c58976e3cbbfe54d2e54d1fd67e36dff2a6 and modifies ApplicationReputation.cpp to keep the list in sync (was a discrepancy before). --- toolkit/components/downloads/ApplicationReputation.cpp | 2 +- xpcom/io/nsLocalFileWin.cpp | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/toolkit/components/downloads/ApplicationReputation.cpp b/toolkit/components/downloads/ApplicationReputation.cpp index 9fdc8a103..6adefbb8b 100644 --- a/toolkit/components/downloads/ApplicationReputation.cpp +++ b/toolkit/components/downloads/ApplicationReputation.cpp @@ -467,7 +467,7 @@ static const char16_t* kBinaryFileExtensions[] = { u".isp", // IIS config //u".isu", // InstallShield u".jar", // Java - u".jnlp", // Java + //u".jnlp", // Java //u".job", // Windows u".js", // JavaScript script u".jse", // JScript diff --git a/xpcom/io/nsLocalFileWin.cpp b/xpcom/io/nsLocalFileWin.cpp index 23c283f95..e73e15950 100644 --- a/xpcom/io/nsLocalFileWin.cpp +++ b/xpcom/io/nsLocalFileWin.cpp @@ -3034,7 +3034,6 @@ nsLocalFile::IsExecutable(bool* aResult) "ins", "isp", "jar", // java application bundle - "jnlp", // java web start "js", "jse", "lnk", -- cgit v1.2.3 From e4b2fa17baea1d35d80de19ffb90d9ba2a1033f8 Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Sat, 29 Jun 2019 01:37:06 +0200 Subject: [Pale Moon] Remove *.pdf file association in the installer. --- application/palemoon/installer/windows/nsis/shared.nsh | 2 -- application/palemoon/installer/windows/nsis/uninstaller.nsi | 1 - 2 files changed, 3 deletions(-) diff --git a/application/palemoon/installer/windows/nsis/shared.nsh b/application/palemoon/installer/windows/nsis/shared.nsh index 49e9369f7..385a411a3 100644 --- a/application/palemoon/installer/windows/nsis/shared.nsh +++ b/application/palemoon/installer/windows/nsis/shared.nsh @@ -322,11 +322,9 @@ WriteRegStr SHCTX "$0\.xhtml" "" "PaleMoonHTML" ${EndIf} - ${AddAssociationIfNoneExist} ".pdf" ${AddAssociationIfNoneExist} ".oga" ${AddAssociationIfNoneExist} ".ogg" ${AddAssociationIfNoneExist} ".ogv" - ${AddAssociationIfNoneExist} ".pdf" ${AddAssociationIfNoneExist} ".webm" ; An empty string is used for the 5th param because PaleMoonHTML is not a diff --git a/application/palemoon/installer/windows/nsis/uninstaller.nsi b/application/palemoon/installer/windows/nsis/uninstaller.nsi index 215e93ac4..44b7c060b 100644 --- a/application/palemoon/installer/windows/nsis/uninstaller.nsi +++ b/application/palemoon/installer/windows/nsis/uninstaller.nsi @@ -246,7 +246,6 @@ Section "Uninstall" ${un.RegCleanFileHandler} ".oga" "PaleMoonHTML" ${un.RegCleanFileHandler} ".ogg" "PaleMoonHTML" ${un.RegCleanFileHandler} ".ogv" "PaleMoonHTML" - ${un.RegCleanFileHandler} ".pdf" "PaleMoonHTML" ${un.RegCleanFileHandler} ".webm" "PaleMoonHTML" ${EndIf} -- cgit v1.2.3 From 01e1fcf522219bf1b2d7d2dcc6209db3d270a182 Mon Sep 17 00:00:00 2001 From: g4jc Date: Fri, 28 Jun 2019 21:35:05 -0400 Subject: Issue #1142 - Remove uneeded assertion (#1145) Since unboxed objects were removed, isUnboxed is undefined. This causes a build failure when debuging is enabled. This patch fixes the issue by removing the uneeeded assertion. --- js/src/jit/MIR.h | 1 - 1 file changed, 1 deletion(-) diff --git a/js/src/jit/MIR.h b/js/src/jit/MIR.h index 0992768bf..9076339f1 100644 --- a/js/src/jit/MIR.h +++ b/js/src/jit/MIR.h @@ -3785,7 +3785,6 @@ class MObjectState MOZ_MUST_USE bool initFromTemplateObject(TempAllocator& alloc, MDefinition* undefinedVal); size_t numFixedSlots() const { - MOZ_ASSERT(!isUnboxed()); return numFixedSlots_; } size_t numSlots() const { -- cgit v1.2.3 From 35d29c05c59057fc84be41ec94f2e3bc31ddef44 Mon Sep 17 00:00:00 2001 From: Gaming4JC Date: Fri, 28 Jun 2019 23:02:15 -0400 Subject: Issue #1142 - Cleanup unused debug code for unboxed objects Also fixes an assertion during compile if debug is enabled since unboxed objects have been removed. --- js/src/jit/BaselineIC.cpp | 2 +- js/src/jscompartment.cpp | 7 ------- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/js/src/jit/BaselineIC.cpp b/js/src/jit/BaselineIC.cpp index d95d08edc..2f20ffa4f 100644 --- a/js/src/jit/BaselineIC.cpp +++ b/js/src/jit/BaselineIC.cpp @@ -289,7 +289,7 @@ DoTypeUpdateFallback(JSContext* cx, BaselineFrame* frame, ICUpdatedStub* stub, H case ICStub::SetProp_Native: case ICStub::SetProp_NativeAdd: case ICStub::SetProp_Unboxed: { - MOZ_ASSERT(obj->isNative() || obj->is()); + MOZ_ASSERT(obj->isNative()); jsbytecode* pc = stub->getChainFallback()->icEntry()->pc(script); if (*pc == JSOP_SETALIASEDVAR || *pc == JSOP_INITALIASEDLEXICAL) id = NameToId(EnvironmentCoordinateName(cx->caches.envCoordinateNameCache, script, pc)); diff --git a/js/src/jscompartment.cpp b/js/src/jscompartment.cpp index a48bb0ffe..6024a1768 100644 --- a/js/src/jscompartment.cpp +++ b/js/src/jscompartment.cpp @@ -112,13 +112,6 @@ JSCompartment::~JSCompartment() js_delete(nonSyntacticLexicalEnvironments_), js_free(enumerators); -#ifdef DEBUG - // Avoid assertion destroying the unboxed layouts list if the embedding - // leaked GC things. - if (!rt->gc.shutdownCollectedEverything()) - unboxedLayouts.clear(); -#endif - runtime_->numCompartments--; } -- cgit v1.2.3 From 01af8598698507ce11c3382ed71d2889da0e8c13 Mon Sep 17 00:00:00 2001 From: "Matt A. Tobin" Date: Sat, 29 Jun 2019 11:26:21 -0400 Subject: [Pale Moon] Add a configure flag to functionally disable personas at build time --- application/palemoon/base/content/browser-addons.js | 3 ++- application/palemoon/base/content/browser.js | 2 ++ application/palemoon/base/content/browser.xul | 2 ++ application/palemoon/configure.in | 13 +++++++++++++ application/palemoon/confvars.sh | 3 +++ build/moz.configure/old.configure | 1 + 6 files changed, 23 insertions(+), 1 deletion(-) diff --git a/application/palemoon/base/content/browser-addons.js b/application/palemoon/base/content/browser-addons.js index f5c398f33..630a0cf79 100644 --- a/application/palemoon/base/content/browser-addons.js +++ b/application/palemoon/base/content/browser-addons.js @@ -263,7 +263,7 @@ var AddonsMgrListener = { onDisabled: function(aAddon) this.onUninstalled(), }; - +#ifdef MOZ_PERSONAS var LightWeightThemeWebInstaller = { handleEvent: function (event) { switch (event.type) { @@ -534,3 +534,4 @@ var LightweightThemeListener = { this.updateStyleSheet("url(" + themeData.headerURL + ")"); }, }; +#endif diff --git a/application/palemoon/base/content/browser.js b/application/palemoon/base/content/browser.js index 16b7c0019..a5d77a90d 100644 --- a/application/palemoon/base/content/browser.js +++ b/application/palemoon/base/content/browser.js @@ -1216,9 +1216,11 @@ var gBrowserInit = { placesContext.addEventListener("popuphiding", updateEditUIVisibility, false); #endif +#ifdef MOZ_PERSONAS gBrowser.mPanelContainer.addEventListener("InstallBrowserTheme", LightWeightThemeWebInstaller, false, true); gBrowser.mPanelContainer.addEventListener("PreviewBrowserTheme", LightWeightThemeWebInstaller, false, true); gBrowser.mPanelContainer.addEventListener("ResetBrowserThemePreview", LightWeightThemeWebInstaller, false, true); +#endif // Bug 666808 - AeroPeek support for e10s if (!gMultiProcessBrowser) { diff --git a/application/palemoon/base/content/browser.xul b/application/palemoon/base/content/browser.xul index ddc305a7b..0a249afa9 100644 --- a/application/palemoon/base/content/browser.xul +++ b/application/palemoon/base/content/browser.xul @@ -53,8 +53,10 @@ titlemodifier_privatebrowsing="&mainWindow.titlemodifier; &mainWindow.titlePrivateBrowsingSuffix;" #endif titlemenuseparator="&mainWindow.titlemodifiermenuseparator;" +#ifdef MOZ_PERSONAS lightweightthemes="true" lightweightthemesfooter="browser-bottombox" +#endif windowtype="navigator:browser" macanimationtype="document" screenX="4" screenY="4" diff --git a/application/palemoon/configure.in b/application/palemoon/configure.in index eb02af3c0..9d820f6d4 100644 --- a/application/palemoon/configure.in +++ b/application/palemoon/configure.in @@ -36,3 +36,16 @@ MOZ_ARG_DISABLE_BOOL(sync, MOZ_SERVICES_SYNC=, MOZ_SERVICES_SYNC=1) +dnl ======================================================== +dnl = Disable Lightweight Themes +dnl ======================================================== +MOZ_ARG_DISABLE_BOOL(personas, +[ --disable-personas Disable lightweight theme support], + MOZ_PERSONAS=, + MOZ_PERSONAS=1) + +if test -n "$MOZ_PERSONAS"; then + AC_DEFINE(MOZ_PERSONAS) +fi + +AC_SUBST(MOZ_PERSONAS) \ No newline at end of file diff --git a/application/palemoon/confvars.sh b/application/palemoon/confvars.sh index 6216cba5b..79681f013 100644 --- a/application/palemoon/confvars.sh +++ b/application/palemoon/confvars.sh @@ -46,6 +46,9 @@ MOZ_PHOENIX=1 # Browser Feature: Status bar Component MOZ_BROWSER_STATUSBAR=1 +# Lightweight Themes +MOZ_PERSONAS=1 + # Browser Feature: Profile Migration Component MOZ_PROFILE_MIGRATOR= diff --git a/build/moz.configure/old.configure b/build/moz.configure/old.configure index 59dc8b57b..326b2327e 100644 --- a/build/moz.configure/old.configure +++ b/build/moz.configure/old.configure @@ -310,6 +310,7 @@ def old_configure_options(*options): # Below are configure flags used by Pale Moon '--disable-browser-statusbar', '--disable-sync', + '--disable-personas', # Below are configure flags used by Basilisk '--disable-webextensions', -- cgit v1.2.3 From a61cca1c15b807225423fd991792b00ef82e36fe Mon Sep 17 00:00:00 2001 From: Kevin Bhasi <37286461+kbhasi@users.noreply.github.com> Date: Mon, 1 Jul 2019 13:14:14 +0800 Subject: Issue #1148 - Part 1: Add StartupWMClass to .desktop for unofficial --- application/palemoon/branding/unofficial/newmoon.desktop | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/application/palemoon/branding/unofficial/newmoon.desktop b/application/palemoon/branding/unofficial/newmoon.desktop index 6dcf32477..3b337fdd4 100644 --- a/application/palemoon/branding/unofficial/newmoon.desktop +++ b/application/palemoon/branding/unofficial/newmoon.desktop @@ -87,8 +87,9 @@ Type=Application Icon=palemoon Categories=Network;WebBrowser; MimeType=text/html;text/xml;application/xhtml+xml;application/vnd.mozilla.xul+xml;text/mml;x-scheme-handler/http;x-scheme-handler/https;x-scheme-handler/ftp; -StartupNotify=true +StartupNotify=false Actions=NewTab;NewWindow;NewPrivateWindow; +StartupWMClass="new moon" [Desktop Action NewTab] Name=Open new tab -- cgit v1.2.3 From 4f3ec55dd6a709b9273e32689f53c873291721a8 Mon Sep 17 00:00:00 2001 From: Kevin Bhasi <37286461+kbhasi@users.noreply.github.com> Date: Mon, 1 Jul 2019 13:24:01 +0800 Subject: Issue #1148 - Part 2: Add StartupWMClass to .desktop for official --- application/palemoon/branding/official/palemoon.desktop | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/application/palemoon/branding/official/palemoon.desktop b/application/palemoon/branding/official/palemoon.desktop index 3f678e1bf..440092b33 100644 --- a/application/palemoon/branding/official/palemoon.desktop +++ b/application/palemoon/branding/official/palemoon.desktop @@ -87,8 +87,9 @@ Type=Application Icon=palemoon Categories=Network;WebBrowser; MimeType=text/html;text/xml;application/xhtml+xml;application/vnd.mozilla.xul+xml;text/mml;x-scheme-handler/http;x-scheme-handler/https;x-scheme-handler/ftp; -StartupNotify=true +StartupNotify=false Actions=NewTab;NewWindow;NewPrivateWindow; +StartupWMClass="pale moon" [Desktop Action NewTab] Name=Open new tab -- cgit v1.2.3 From c794a79d87a64425c3c23af78f4234833fb9bd79 Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Tue, 2 Jul 2019 16:07:31 +0200 Subject: New cycle version bump. --- application/palemoon/config/version.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/palemoon/config/version.txt b/application/palemoon/config/version.txt index bcbf0fd12..ff225a990 100644 --- a/application/palemoon/config/version.txt +++ b/application/palemoon/config/version.txt @@ -1 +1 @@ -28.6.0a1 \ No newline at end of file +28.7.0a1 \ No newline at end of file -- cgit v1.2.3 From f46e7a46cc16260d9c346016db43cf920cc6706a Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Wed, 3 Jul 2019 00:05:41 +0200 Subject: Update SSUAO for web.whatsapp.com. This resolves #1152 --- application/palemoon/branding/shared/pref/uaoverrides.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/palemoon/branding/shared/pref/uaoverrides.inc b/application/palemoon/branding/shared/pref/uaoverrides.inc index 36a0ae145..487d083a9 100644 --- a/application/palemoon/branding/shared/pref/uaoverrides.inc +++ b/application/palemoon/branding/shared/pref/uaoverrides.inc @@ -76,7 +76,7 @@ pref("@GUAO_PREF@.netflix.com","Mozilla/5.0 (@OS_SLICE@ rv:45.9) @GK_SLICE@ Fire pref("@GUAO_PREF@.netflximg.net","Mozilla/5.0 (@OS_SLICE@ rv:45.9) @GK_SLICE@ Firefox/45.9"); // UA-sniffing domains that are "app/vendor-specific" and do not like Pale Moon -pref("@GUAO_PREF@.web.whatsapp.com","Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2049.0 Safari/537.36"); +pref("@GUAO_PREF@.web.whatsapp.com","Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36"); // The following domains do not like the Goanna slice pref("@GUAO_PREF@.hitbox.tv","Mozilla/5.0 (@OS_SLICE@ rv:@GK_VERSION@) @GK_SLICE@ @FX_SLICE@"); -- cgit v1.2.3 From 893de15c27912cd96649e56597d25b1ecb2ee6d9 Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Wed, 3 Jul 2019 12:01:25 +0200 Subject: Update 16x16 branding images/icons for improved contrast on grey backgrounds. --- .../palemoon/branding/official/default16.png | Bin 767 -> 836 bytes .../palemoon/branding/official/firefox.icns | Bin 251912 -> 251915 bytes application/palemoon/branding/official/firefox.ico | Bin 101320 -> 101320 bytes 3 files changed, 0 insertions(+), 0 deletions(-) diff --git a/application/palemoon/branding/official/default16.png b/application/palemoon/branding/official/default16.png index a2e8b1a01..d76bb6fad 100644 Binary files a/application/palemoon/branding/official/default16.png and b/application/palemoon/branding/official/default16.png differ diff --git a/application/palemoon/branding/official/firefox.icns b/application/palemoon/branding/official/firefox.icns index 64f17ff62..d63c656c7 100644 Binary files a/application/palemoon/branding/official/firefox.icns and b/application/palemoon/branding/official/firefox.icns differ diff --git a/application/palemoon/branding/official/firefox.ico b/application/palemoon/branding/official/firefox.ico index 0d142c5f1..43c5d9343 100644 Binary files a/application/palemoon/branding/official/firefox.ico and b/application/palemoon/branding/official/firefox.ico differ -- cgit v1.2.3 From 8ea1f38f9c55a076dade47eaf0daaea27590d179 Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Wed, 3 Jul 2019 15:01:34 +0200 Subject: Change softoken password rounds to a more conservative number still within industry standard security, considering our db hashing is more CPU intensive than anticipated. --- security/nss/lib/softoken/sftkpwd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/security/nss/lib/softoken/sftkpwd.c b/security/nss/lib/softoken/sftkpwd.c index 745e724f0..b6d098a07 100644 --- a/security/nss/lib/softoken/sftkpwd.c +++ b/security/nss/lib/softoken/sftkpwd.c @@ -36,9 +36,9 @@ const int NSS_DEFAULT_ITERATION_COUNT = #ifdef DEBUG - 1000 + 25 #else - 60000 + 500 #endif ; -- cgit v1.2.3 From 6fce24e0e85934061d95f6ad1ee64919d325ae5c Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Thu, 4 Jul 2019 13:47:47 +0200 Subject: Remove FT's polyfill.io SSUAO now they have fixed their detection. See also: https://github.com/Financial-Times/polyfill-useragent-normaliser/pull/12 --- application/palemoon/branding/shared/pref/uaoverrides.inc | 2 -- 1 file changed, 2 deletions(-) diff --git a/application/palemoon/branding/shared/pref/uaoverrides.inc b/application/palemoon/branding/shared/pref/uaoverrides.inc index 487d083a9..028b29b41 100644 --- a/application/palemoon/branding/shared/pref/uaoverrides.inc +++ b/application/palemoon/branding/shared/pref/uaoverrides.inc @@ -57,8 +57,6 @@ pref("@GUAO_PREF@.www.amazon.com","Mozilla/5.0 (@OS_SLICE@ rv:45.9) @GK_SLICE@ F pref("@GUAO_PREF@.soundcloud.com","Mozilla/5.0 (@OS_SLICE@ rv:@GRE_VERSION@) @GRE_DATE_SLICE@ @PM_SLICE@"); // Daily motion only likes strict Firefox UAs pref("@GUAO_PREF@.dailymotion.com","Mozilla/5.0 (@OS_SLICE@ rv:52.0) @GK_SLICE@ Firefox/52.0"); -// Financial Times' polyfill.io breaks horribly on a Pale Moon UA. Send a strict Firefox UA instead. -pref("@GUAO_PREF@.polyfill.io","Mozilla/5.0 (@OS_SLICE@ rv:60.9) @GK_SLICE@ Firefox/60.9"); // The following requires native mode. Or it blocks.. "too old firefox", breakage, etc. -- cgit v1.2.3 From 8096258c0ca2e96d0d3641165f408b231980e859 Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Thu, 4 Jul 2019 18:50:29 +0200 Subject: Add adjusted icon for 2k/XP classic grey toolbar backgrounds. (because otherwise we won't hear the end of it) --- application/palemoon/branding/official/firefox.ico | Bin 101320 -> 94683 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/application/palemoon/branding/official/firefox.ico b/application/palemoon/branding/official/firefox.ico index 43c5d9343..ea25fd887 100644 Binary files a/application/palemoon/branding/official/firefox.ico and b/application/palemoon/branding/official/firefox.ico differ -- cgit v1.2.3 From 15e8d1c9195400727079716b4cfc65afe08511e5 Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Thu, 4 Jul 2019 19:38:41 +0200 Subject: Give Mac an Linux (small sizes) the same treatment --- .../palemoon/branding/official/default16.png | Bin 836 -> 811 bytes .../palemoon/branding/official/default22.png | Bin 1198 -> 1377 bytes .../palemoon/branding/official/default24.png | Bin 1372 -> 1534 bytes .../palemoon/branding/official/default32.png | Bin 2079 -> 2273 bytes .../palemoon/branding/official/firefox.icns | Bin 251915 -> 253858 bytes 5 files changed, 0 insertions(+), 0 deletions(-) diff --git a/application/palemoon/branding/official/default16.png b/application/palemoon/branding/official/default16.png index d76bb6fad..b840a3acf 100644 Binary files a/application/palemoon/branding/official/default16.png and b/application/palemoon/branding/official/default16.png differ diff --git a/application/palemoon/branding/official/default22.png b/application/palemoon/branding/official/default22.png index 6508e7b84..4e290f84b 100644 Binary files a/application/palemoon/branding/official/default22.png and b/application/palemoon/branding/official/default22.png differ diff --git a/application/palemoon/branding/official/default24.png b/application/palemoon/branding/official/default24.png index 1d4e66a27..f47d3ef23 100644 Binary files a/application/palemoon/branding/official/default24.png and b/application/palemoon/branding/official/default24.png differ diff --git a/application/palemoon/branding/official/default32.png b/application/palemoon/branding/official/default32.png index ce9630745..fde9707d8 100644 Binary files a/application/palemoon/branding/official/default32.png and b/application/palemoon/branding/official/default32.png differ diff --git a/application/palemoon/branding/official/firefox.icns b/application/palemoon/branding/official/firefox.icns index d63c656c7..87f9ac751 100644 Binary files a/application/palemoon/branding/official/firefox.icns and b/application/palemoon/branding/official/firefox.icns differ -- cgit v1.2.3 From 281b66c7a2899380e03a0399a0d5f1ab51b3f3a0 Mon Sep 17 00:00:00 2001 From: FranklinDM Date: Fri, 5 Jul 2019 17:32:17 +0800 Subject: Issue #1158 - Remove extraneous closing brace - This also adjusts code indentation --- application/basilisk/base/content/tabbrowser.xml | 27 ++++++++++++------------ 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/application/basilisk/base/content/tabbrowser.xml b/application/basilisk/base/content/tabbrowser.xml index 0e819a3ed..e64ebb1e6 100644 --- a/application/basilisk/base/content/tabbrowser.xml +++ b/application/basilisk/base/content/tabbrowser.xml @@ -6906,21 +6906,20 @@ -- cgit v1.2.3 From 51bf4b3df415e4f7993da8f5f8499e9b029202ec Mon Sep 17 00:00:00 2001 From: FranklinDM Date: Fri, 5 Jul 2019 17:50:00 +0800 Subject: Issue #1158 - Reinstate `tabcontainer` variable - This was erroneously removed in commit 1f5194b5f1deb0f36b36ed886d94ce5f8b62ca9d because it is still being used by surrounding code. --- application/basilisk/base/content/tabbrowser.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/application/basilisk/base/content/tabbrowser.xml b/application/basilisk/base/content/tabbrowser.xml index e64ebb1e6..85f923923 100644 --- a/application/basilisk/base/content/tabbrowser.xml +++ b/application/basilisk/base/content/tabbrowser.xml @@ -6909,6 +6909,8 @@ document.getElementById("alltabs_undoCloseTab").disabled = SessionStore.getClosedTabCount(window) == 0; + var tabcontainer = gBrowser.tabContainer; + // Listen for changes in the tab bar. tabcontainer.addEventListener("TabAttrModified", this, false); tabcontainer.addEventListener("TabClose", this, false); -- cgit v1.2.3 From 7c5a0db237c7a43136ee3cdc6cfb0663778d9e2c Mon Sep 17 00:00:00 2001 From: win7-7 Date: Fri, 5 Jul 2019 21:58:21 +0300 Subject: Introduce a new non-heap-allocated type for holding nsStringBuffer* in the HTML parser. An innerHTML setter profile shows about 10% of the time being spent under nsHtml5HtmlAttributes::clear, mostly deleting nsStrings. --- parser/html/moz.build | 2 + parser/html/nsHtml5ArrayCopy.h | 7 +- parser/html/nsHtml5AttributeName.cpp | 2 +- parser/html/nsHtml5AttributeName.h | 2 +- parser/html/nsHtml5ElementName.cpp | 2 +- parser/html/nsHtml5ElementName.h | 2 +- parser/html/nsHtml5Highlighter.cpp | 16 +- parser/html/nsHtml5Highlighter.h | 6 +- parser/html/nsHtml5HtmlAttributes.cpp | 27 +-- parser/html/nsHtml5HtmlAttributes.h | 12 +- parser/html/nsHtml5MetaScanner.cpp | 15 +- parser/html/nsHtml5MetaScanner.h | 8 +- parser/html/nsHtml5MetaScannerCppSupplement.h | 6 +- parser/html/nsHtml5PlainTextUtils.cpp | 15 +- parser/html/nsHtml5Portability.cpp | 99 ++++------- parser/html/nsHtml5Portability.h | 29 ++-- parser/html/nsHtml5SpeculativeLoad.h | 106 ++++++------ parser/html/nsHtml5StackNode.cpp | 2 +- parser/html/nsHtml5StackNode.h | 2 +- parser/html/nsHtml5StateSnapshot.cpp | 2 +- parser/html/nsHtml5StateSnapshot.h | 2 +- parser/html/nsHtml5StreamParser.cpp | 7 +- parser/html/nsHtml5StreamParser.h | 2 +- parser/html/nsHtml5String.cpp | 226 ++++++++++++++++++++++++++ parser/html/nsHtml5String.h | 95 +++++++++++ parser/html/nsHtml5Tokenizer.cpp | 34 ++-- parser/html/nsHtml5Tokenizer.h | 16 +- parser/html/nsHtml5TreeBuilder.cpp | 49 ++++-- parser/html/nsHtml5TreeBuilder.h | 27 ++- parser/html/nsHtml5TreeBuilderCppSupplement.h | 206 +++++++++++------------ parser/html/nsHtml5TreeOperation.cpp | 14 +- parser/html/nsHtml5UTF16Buffer.cpp | 2 +- parser/html/nsHtml5UTF16Buffer.h | 2 +- parser/html/nsHtml5ViewSourceUtils.cpp | 33 ++-- 34 files changed, 719 insertions(+), 358 deletions(-) create mode 100644 parser/html/nsHtml5String.cpp create mode 100644 parser/html/nsHtml5String.h diff --git a/parser/html/moz.build b/parser/html/moz.build index 4a2da8a79..cd6031abe 100644 --- a/parser/html/moz.build +++ b/parser/html/moz.build @@ -39,6 +39,7 @@ EXPORTS += [ 'nsHtml5SpeculativeLoad.h', 'nsHtml5StreamListener.h', 'nsHtml5StreamParser.h', + 'nsHtml5String.h', 'nsHtml5StringParser.h', 'nsHtml5SVGLoadDispatcher.h', 'nsHtml5TreeOperation.h', @@ -78,6 +79,7 @@ UNIFIED_SOURCES += [ 'nsHtml5StateSnapshot.cpp', 'nsHtml5StreamListener.cpp', 'nsHtml5StreamParser.cpp', + 'nsHtml5String.cpp', 'nsHtml5StringParser.cpp', 'nsHtml5SVGLoadDispatcher.cpp', 'nsHtml5Tokenizer.cpp', diff --git a/parser/html/nsHtml5ArrayCopy.h b/parser/html/nsHtml5ArrayCopy.h index 78ed65568..594a801ab 100644 --- a/parser/html/nsHtml5ArrayCopy.h +++ b/parser/html/nsHtml5ArrayCopy.h @@ -51,10 +51,11 @@ class nsHtml5ArrayCopy { memcpy(target, source, size_t(length) * sizeof(int32_t)); } - static inline void - arraycopy(nsString** source, nsString** target, int32_t length) + static inline void arraycopy(nsHtml5String* source, + nsHtml5String* target, + int32_t length) { - memcpy(target, source, size_t(length) * sizeof(nsString*)); + memcpy(target, source, size_t(length) * sizeof(nsHtml5String)); } static inline void diff --git a/parser/html/nsHtml5AttributeName.cpp b/parser/html/nsHtml5AttributeName.cpp index fc7745adc..dc546c111 100644 --- a/parser/html/nsHtml5AttributeName.cpp +++ b/parser/html/nsHtml5AttributeName.cpp @@ -29,7 +29,7 @@ #include "nsIAtom.h" #include "nsHtml5AtomTable.h" -#include "nsString.h" +#include "nsHtml5String.h" #include "nsNameSpaceManager.h" #include "nsIContent.h" #include "nsTraceRefcnt.h" diff --git a/parser/html/nsHtml5AttributeName.h b/parser/html/nsHtml5AttributeName.h index 748dcf3c9..d0b93341b 100644 --- a/parser/html/nsHtml5AttributeName.h +++ b/parser/html/nsHtml5AttributeName.h @@ -30,7 +30,7 @@ #include "nsIAtom.h" #include "nsHtml5AtomTable.h" -#include "nsString.h" +#include "nsHtml5String.h" #include "nsNameSpaceManager.h" #include "nsIContent.h" #include "nsTraceRefcnt.h" diff --git a/parser/html/nsHtml5ElementName.cpp b/parser/html/nsHtml5ElementName.cpp index 1aa6f11ce..fb523e7ef 100644 --- a/parser/html/nsHtml5ElementName.cpp +++ b/parser/html/nsHtml5ElementName.cpp @@ -29,7 +29,7 @@ #include "nsIAtom.h" #include "nsHtml5AtomTable.h" -#include "nsString.h" +#include "nsHtml5String.h" #include "nsNameSpaceManager.h" #include "nsIContent.h" #include "nsTraceRefcnt.h" diff --git a/parser/html/nsHtml5ElementName.h b/parser/html/nsHtml5ElementName.h index b4df323a6..b5f0e4b9b 100644 --- a/parser/html/nsHtml5ElementName.h +++ b/parser/html/nsHtml5ElementName.h @@ -30,7 +30,7 @@ #include "nsIAtom.h" #include "nsHtml5AtomTable.h" -#include "nsString.h" +#include "nsHtml5String.h" #include "nsNameSpaceManager.h" #include "nsIContent.h" #include "nsTraceRefcnt.h" diff --git a/parser/html/nsHtml5Highlighter.cpp b/parser/html/nsHtml5Highlighter.cpp index 259803ee1..23cdf7d84 100644 --- a/parser/html/nsHtml5Highlighter.cpp +++ b/parser/html/nsHtml5Highlighter.cpp @@ -91,7 +91,7 @@ nsHtml5Highlighter::Start(const nsAutoString& aTitle) if (length > INT32_MAX) { length = INT32_MAX; } - AppendCharacters(aTitle.get(), 0, (int32_t)length); + AppendCharacters(aTitle.BeginReading(), 0, (int32_t)length); Pop(); // title Push(nsGkAtoms::link, nsHtml5ViewSourceUtils::NewLinkAttributes()); @@ -105,7 +105,7 @@ nsHtml5Highlighter::Start(const nsAutoString& aTitle) Push(nsGkAtoms::body, nsHtml5ViewSourceUtils::NewBodyAttributes()); nsHtml5HtmlAttributes* preAttrs = new nsHtml5HtmlAttributes(0); - nsString* preId = new nsString(NS_LITERAL_STRING("line1")); + nsHtml5String preId = nsHtml5Portability::newStringFromLiteral("line1"); preAttrs->addAttribute(nsHtml5AttributeName::ATTR_ID, preId, -1); Push(nsGkAtoms::pre, preAttrs); @@ -618,7 +618,7 @@ nsHtml5Highlighter::FlushOps() void nsHtml5Highlighter::MaybeLinkifyAttributeValue(nsHtml5AttributeName* aName, - nsString* aValue) + nsHtml5String aValue) { if (!(nsHtml5AttributeName::ATTR_HREF == aName || nsHtml5AttributeName::ATTR_SRC == aName || @@ -630,7 +630,7 @@ nsHtml5Highlighter::MaybeLinkifyAttributeValue(nsHtml5AttributeName* aName, nsHtml5AttributeName::ATTR_DEFINITIONURL == aName)) { return; } - AddViewSourceHref(*aValue); + AddViewSourceHref(aValue); } void @@ -717,10 +717,10 @@ nsHtml5Highlighter::AddClass(const char16_t* aClass) } void -nsHtml5Highlighter::AddViewSourceHref(const nsString& aValue) +nsHtml5Highlighter::AddViewSourceHref(nsHtml5String aValue) { char16_t* bufferCopy = new char16_t[aValue.Length() + 1]; - memcpy(bufferCopy, aValue.get(), aValue.Length() * sizeof(char16_t)); + aValue.CopyToBuffer(bufferCopy); bufferCopy[aValue.Length()] = 0; mOpQueue.AppendElement()->Init(eTreeOpAddViewSourceHref, @@ -730,14 +730,14 @@ nsHtml5Highlighter::AddViewSourceHref(const nsString& aValue) } void -nsHtml5Highlighter::AddBase(const nsString& aValue) +nsHtml5Highlighter::AddBase(nsHtml5String aValue) { if(mSeenBase) { return; } mSeenBase = true; char16_t* bufferCopy = new char16_t[aValue.Length() + 1]; - memcpy(bufferCopy, aValue.get(), aValue.Length() * sizeof(char16_t)); + aValue.CopyToBuffer(bufferCopy); bufferCopy[aValue.Length()] = 0; mOpQueue.AppendElement()->Init(eTreeOpAddViewSourceBase, diff --git a/parser/html/nsHtml5Highlighter.h b/parser/html/nsHtml5Highlighter.h index e9474869e..366f11582 100644 --- a/parser/html/nsHtml5Highlighter.h +++ b/parser/html/nsHtml5Highlighter.h @@ -78,7 +78,7 @@ class nsHtml5Highlighter * @param aValue the value of the attribute */ void MaybeLinkifyAttributeValue(nsHtml5AttributeName* aName, - nsString* aValue); + nsHtml5String aValue); /** * Inform the highlighter that the tokenizer successfully completed a @@ -147,7 +147,7 @@ class nsHtml5Highlighter * * @param aValue the base URL to add */ - void AddBase(const nsString& aValue); + void AddBase(nsHtml5String aValue); private: @@ -272,7 +272,7 @@ class nsHtml5Highlighter * * @param aValue the (potentially relative) URL to link to */ - void AddViewSourceHref(const nsString& aValue); + void AddViewSourceHref(nsHtml5String aValue); /** * The state we are transitioning away from. diff --git a/parser/html/nsHtml5HtmlAttributes.cpp b/parser/html/nsHtml5HtmlAttributes.cpp index d515f381d..62b9ae2b2 100644 --- a/parser/html/nsHtml5HtmlAttributes.cpp +++ b/parser/html/nsHtml5HtmlAttributes.cpp @@ -30,7 +30,7 @@ #include "nsIAtom.h" #include "nsHtml5AtomTable.h" -#include "nsString.h" +#include "nsHtml5String.h" #include "nsNameSpaceManager.h" #include "nsIContent.h" #include "nsTraceRefcnt.h" @@ -58,11 +58,11 @@ nsHtml5HtmlAttributes* nsHtml5HtmlAttributes::EMPTY_ATTRIBUTES = nullptr; nsHtml5HtmlAttributes::nsHtml5HtmlAttributes(int32_t mode) - : mode(mode), - length(0), - names(jArray::newJArray(8)), - values(jArray::newJArray(8)), - lines(jArray::newJArray(8)) + : mode(mode) + , length(0) + , names(jArray::newJArray(8)) + , values(jArray::newJArray(8)) + , lines(jArray::newJArray(8)) { MOZ_COUNT_CTOR(nsHtml5HtmlAttributes); } @@ -85,7 +85,7 @@ nsHtml5HtmlAttributes::getIndex(nsHtml5AttributeName* name) return -1; } -nsString* +nsHtml5String nsHtml5HtmlAttributes::getValue(nsHtml5AttributeName* name) { int32_t index = getIndex(name); @@ -123,7 +123,7 @@ nsHtml5HtmlAttributes::getPrefixNoBoundsCheck(int32_t index) return names[index]->getPrefix(mode); } -nsString* +nsHtml5String nsHtml5HtmlAttributes::getValueNoBoundsCheck(int32_t index) { MOZ_ASSERT(index < length && index >= 0, "Index out of bounds"); @@ -145,14 +145,17 @@ nsHtml5HtmlAttributes::getLineNoBoundsCheck(int32_t index) } void -nsHtml5HtmlAttributes::addAttribute(nsHtml5AttributeName* name, nsString* value, int32_t line) +nsHtml5HtmlAttributes::addAttribute(nsHtml5AttributeName* name, + nsHtml5String value, + int32_t line) { if (names.length == length) { int32_t newLen = length << 1; jArray newNames = jArray::newJArray(newLen); nsHtml5ArrayCopy::arraycopy(names, newNames, names.length); names = newNames; - jArray newValues = jArray::newJArray(newLen); + jArray newValues = + jArray::newJArray(newLen); nsHtml5ArrayCopy::arraycopy(values, newValues, values.length); values = newValues; jArray newLines = jArray::newJArray(newLen); @@ -171,7 +174,7 @@ nsHtml5HtmlAttributes::clear(int32_t m) for (int32_t i = 0; i < length; i++) { names[i]->release(); names[i] = nullptr; - nsHtml5Portability::releaseString(values[i]); + values[i].Release(); values[i] = nullptr; } length = 0; @@ -181,7 +184,7 @@ nsHtml5HtmlAttributes::clear(int32_t m) void nsHtml5HtmlAttributes::releaseValue(int32_t i) { - nsHtml5Portability::releaseString(values[i]); + values[i].Release(); } void diff --git a/parser/html/nsHtml5HtmlAttributes.h b/parser/html/nsHtml5HtmlAttributes.h index c02d0a08c..12149a0b5 100644 --- a/parser/html/nsHtml5HtmlAttributes.h +++ b/parser/html/nsHtml5HtmlAttributes.h @@ -31,7 +31,7 @@ #include "nsIAtom.h" #include "nsHtml5AtomTable.h" -#include "nsString.h" +#include "nsHtml5String.h" #include "nsNameSpaceManager.h" #include "nsIContent.h" #include "nsTraceRefcnt.h" @@ -64,21 +64,23 @@ class nsHtml5HtmlAttributes int32_t mode; int32_t length; autoJArray names; - autoJArray values; + autoJArray values; autoJArray lines; public: explicit nsHtml5HtmlAttributes(int32_t mode); ~nsHtml5HtmlAttributes(); int32_t getIndex(nsHtml5AttributeName* name); - nsString* getValue(nsHtml5AttributeName* name); + nsHtml5String getValue(nsHtml5AttributeName* name); int32_t getLength(); nsIAtom* getLocalNameNoBoundsCheck(int32_t index); int32_t getURINoBoundsCheck(int32_t index); nsIAtom* getPrefixNoBoundsCheck(int32_t index); - nsString* getValueNoBoundsCheck(int32_t index); + nsHtml5String getValueNoBoundsCheck(int32_t index); nsHtml5AttributeName* getAttributeNameNoBoundsCheck(int32_t index); int32_t getLineNoBoundsCheck(int32_t index); - void addAttribute(nsHtml5AttributeName* name, nsString* value, int32_t line); + void addAttribute(nsHtml5AttributeName* name, + nsHtml5String value, + int32_t line); void clear(int32_t m); void releaseValue(int32_t i); void clearWithoutReleasingContents(); diff --git a/parser/html/nsHtml5MetaScanner.cpp b/parser/html/nsHtml5MetaScanner.cpp index d39eacd9b..24f17b02b 100644 --- a/parser/html/nsHtml5MetaScanner.cpp +++ b/parser/html/nsHtml5MetaScanner.cpp @@ -30,7 +30,7 @@ #include "nsIAtom.h" #include "nsHtml5AtomTable.h" -#include "nsString.h" +#include "nsHtml5String.h" #include "nsNameSpaceManager.h" #include "nsIContent.h" #include "nsTraceRefcnt.h" @@ -86,8 +86,8 @@ nsHtml5MetaScanner::nsHtml5MetaScanner(nsHtml5TreeBuilder* tb) nsHtml5MetaScanner::~nsHtml5MetaScanner() { MOZ_COUNT_DTOR(nsHtml5MetaScanner); - nsHtml5Portability::releaseString(content); - nsHtml5Portability::releaseString(charset); + content.Release(); + charset.Release(); } void @@ -771,9 +771,9 @@ bool nsHtml5MetaScanner::handleTag() { bool stop = handleTagInner(); - nsHtml5Portability::releaseString(content); + content.Release(); content = nullptr; - nsHtml5Portability::releaseString(charset); + charset.Release(); charset = nullptr; httpEquivState = NS_HTML5META_SCANNER_HTTP_EQUIV_NOT_SEEN; return stop; @@ -786,12 +786,13 @@ nsHtml5MetaScanner::handleTagInner() return true; } if (!!content && httpEquivState == NS_HTML5META_SCANNER_HTTP_EQUIV_CONTENT_TYPE) { - nsString* extract = nsHtml5TreeBuilder::extractCharsetFromContent(content, treeBuilder); + nsHtml5String extract = + nsHtml5TreeBuilder::extractCharsetFromContent(content, treeBuilder); if (!extract) { return false; } bool success = tryCharset(extract); - nsHtml5Portability::releaseString(extract); + extract.Release(); return success; } return false; diff --git a/parser/html/nsHtml5MetaScanner.h b/parser/html/nsHtml5MetaScanner.h index 4e0ad7647..a4d308147 100644 --- a/parser/html/nsHtml5MetaScanner.h +++ b/parser/html/nsHtml5MetaScanner.h @@ -31,7 +31,7 @@ #include "nsIAtom.h" #include "nsHtml5AtomTable.h" -#include "nsString.h" +#include "nsHtml5String.h" #include "nsNameSpaceManager.h" #include "nsIContent.h" #include "nsTraceRefcnt.h" @@ -76,8 +76,8 @@ class nsHtml5MetaScanner private: int32_t strBufLen; autoJArray strBuf; - nsString* content; - nsString* charset; + nsHtml5String content; + nsHtml5String charset; int32_t httpEquivState; nsHtml5TreeBuilder* treeBuilder; public: @@ -100,7 +100,7 @@ class nsHtml5MetaScanner bool handleTag(); bool handleTagInner(); protected: - bool tryCharset(nsString* encoding); + bool tryCharset(nsHtml5String encoding); public: static void initializeStatics(); static void releaseStatics(); diff --git a/parser/html/nsHtml5MetaScannerCppSupplement.h b/parser/html/nsHtml5MetaScannerCppSupplement.h index 5e7033777..9d2496361 100644 --- a/parser/html/nsHtml5MetaScannerCppSupplement.h +++ b/parser/html/nsHtml5MetaScannerCppSupplement.h @@ -19,13 +19,15 @@ nsHtml5MetaScanner::sniff(nsHtml5ByteReadable* bytes, nsACString& charset) } bool -nsHtml5MetaScanner::tryCharset(nsString* charset) +nsHtml5MetaScanner::tryCharset(nsHtml5String charset) { // This code needs to stay in sync with // nsHtml5StreamParser::internalEncodingDeclaration. Unfortunately, the // trickery with member fields here leads to some copy-paste reuse. :-( nsAutoCString label; - CopyUTF16toUTF8(*charset, label); + nsString charset16; // Not Auto, because using it to hold nsStringBuffer* + charset.ToString(charset16); + CopyUTF16toUTF8(charset16, label); nsAutoCString encoding; if (!EncodingUtils::FindEncodingForLabel(label, encoding)) { return false; diff --git a/parser/html/nsHtml5PlainTextUtils.cpp b/parser/html/nsHtml5PlainTextUtils.cpp index 4f0eab81b..0d2933150 100644 --- a/parser/html/nsHtml5PlainTextUtils.cpp +++ b/parser/html/nsHtml5PlainTextUtils.cpp @@ -5,21 +5,24 @@ #include "nsHtml5PlainTextUtils.h" #include "nsHtml5AttributeName.h" +#include "nsHtml5Portability.h" #include "nsIServiceManager.h" #include "nsIStringBundle.h" #include "mozilla/Preferences.h" +#include "nsHtml5String.h" // static nsHtml5HtmlAttributes* nsHtml5PlainTextUtils::NewLinkAttributes() { nsHtml5HtmlAttributes* linkAttrs = new nsHtml5HtmlAttributes(0); - nsString* rel = new nsString(NS_LITERAL_STRING("alternate stylesheet")); + nsHtml5String rel = + nsHtml5Portability::newStringFromLiteral("alternate stylesheet"); linkAttrs->addAttribute(nsHtml5AttributeName::ATTR_REL, rel, -1); - nsString* type = new nsString(NS_LITERAL_STRING("text/css")); + nsHtml5String type = nsHtml5Portability::newStringFromLiteral("text/css"); linkAttrs->addAttribute(nsHtml5AttributeName::ATTR_TYPE, type, -1); - nsString* href = new nsString( - NS_LITERAL_STRING("resource://gre-resources/plaintext.css")); + nsHtml5String href = nsHtml5Portability::newStringFromLiteral( + "resource://gre-resources/plaintext.css"); linkAttrs->addAttribute(nsHtml5AttributeName::ATTR_HREF, href, -1); nsresult rv; @@ -34,7 +37,7 @@ nsHtml5PlainTextUtils::NewLinkAttributes() bundle->GetStringFromName(u"plainText.wordWrap", getter_Copies(title)); } - nsString* titleCopy = new nsString(title); - linkAttrs->addAttribute(nsHtml5AttributeName::ATTR_TITLE, titleCopy, -1); + linkAttrs->addAttribute( + nsHtml5AttributeName::ATTR_TITLE, nsHtml5String::FromString(title), -1); return linkAttrs; } diff --git a/parser/html/nsHtml5Portability.cpp b/parser/html/nsHtml5Portability.cpp index 0a7c6f845..5a76b3c56 100644 --- a/parser/html/nsHtml5Portability.cpp +++ b/parser/html/nsHtml5Portability.cpp @@ -16,37 +16,31 @@ nsHtml5Portability::newLocalNameFromBuffer(char16_t* buf, int32_t offset, int32_ return interner->GetAtom(nsDependentSubstring(buf, buf + length)); } -nsString* -nsHtml5Portability::newStringFromBuffer(char16_t* buf, int32_t offset, int32_t length, nsHtml5TreeBuilder* treeBuilder) +nsHtml5String +nsHtml5Portability::newStringFromBuffer(char16_t* buf, + int32_t offset, + int32_t length, + nsHtml5TreeBuilder* treeBuilder) { - nsString* str = new nsString(); - bool succeeded = str->Append(buf + offset, length, mozilla::fallible); - if (!succeeded) { - str->Assign(char16_t(0xFFFD)); - treeBuilder->MarkAsBroken(NS_ERROR_OUT_OF_MEMORY); - } - return str; + return nsHtml5String::FromBuffer(buf + offset, length, treeBuilder); } -nsString* +nsHtml5String nsHtml5Portability::newEmptyString() { - return new nsString(); + return nsHtml5String::EmptyString(); } -nsString* +nsHtml5String nsHtml5Portability::newStringFromLiteral(const char* literal) { - nsString* str = new nsString(); - str->AssignASCII(literal); - return str; + return nsHtml5String::FromLiteral(literal); } -nsString* -nsHtml5Portability::newStringFromString(nsString* string) { - nsString* newStr = new nsString(); - newStr->Assign(*string); - return newStr; +nsHtml5String +nsHtml5Portability::newStringFromString(nsHtml5String string) +{ + return string.Clone(); } jArray @@ -60,12 +54,14 @@ nsHtml5Portability::newCharArrayFromLocal(nsIAtom* local) return arr; } -jArray -nsHtml5Portability::newCharArrayFromString(nsString* string) +jArray +nsHtml5Portability::newCharArrayFromString(nsHtml5String string) { - int32_t len = string->Length(); + MOZ_RELEASE_ASSERT(string); + uint32_t len = string.Length(); + MOZ_RELEASE_ASSERT(len < INT32_MAX); jArray arr = jArray::newJArray(len); - memcpy(arr, string->BeginReading(), len * sizeof(char16_t)); + string.CopyToBuffer(arr); return arr; } @@ -82,12 +78,6 @@ nsHtml5Portability::newLocalFromLocal(nsIAtom* local, nsHtml5AtomTable* interner return local; } -void -nsHtml5Portability::releaseString(nsString* str) -{ - delete str; -} - bool nsHtml5Portability::localEqualsBuffer(nsIAtom* local, char16_t* buf, int32_t offset, int32_t length) { @@ -95,55 +85,32 @@ nsHtml5Portability::localEqualsBuffer(nsIAtom* local, char16_t* buf, int32_t off } bool -nsHtml5Portability::lowerCaseLiteralIsPrefixOfIgnoreAsciiCaseString(const char* lowerCaseLiteral, nsString* string) +nsHtml5Portability::lowerCaseLiteralIsPrefixOfIgnoreAsciiCaseString( + const char* lowerCaseLiteral, + nsHtml5String string) { - if (!string) { - return false; - } - const char* litPtr = lowerCaseLiteral; - const char16_t* strPtr = string->BeginReading(); - const char16_t* end = string->EndReading(); - char16_t litChar; - while ((litChar = *litPtr)) { - NS_ASSERTION(!(litChar >= 'A' && litChar <= 'Z'), "Literal isn't in lower case."); - if (strPtr == end) { - return false; - } - char16_t strChar = *strPtr; - if (strChar >= 'A' && strChar <= 'Z') { - strChar += 0x20; - } - if (litChar != strChar) { - return false; - } - ++litPtr; - ++strPtr; - } - return true; + return string.LowerCaseStartsWithASCII(lowerCaseLiteral); } bool -nsHtml5Portability::lowerCaseLiteralEqualsIgnoreAsciiCaseString(const char* lowerCaseLiteral, nsString* string) +nsHtml5Portability::lowerCaseLiteralEqualsIgnoreAsciiCaseString( + const char* lowerCaseLiteral, + nsHtml5String string) { - if (!string) { - return false; - } - return string->LowerCaseEqualsASCII(lowerCaseLiteral); + return string.LowerCaseEqualsASCII(lowerCaseLiteral); } bool -nsHtml5Portability::literalEqualsString(const char* literal, nsString* string) +nsHtml5Portability::literalEqualsString(const char* literal, + nsHtml5String string) { - if (!string) { - return false; - } - return string->EqualsASCII(literal); + return string.EqualsASCII(literal); } bool -nsHtml5Portability::stringEqualsString(nsString* one, nsString* other) +nsHtml5Portability::stringEqualsString(nsHtml5String one, nsHtml5String other) { - return one->Equals(*other); + return one.Equals(other); } void diff --git a/parser/html/nsHtml5Portability.h b/parser/html/nsHtml5Portability.h index bd85ccbdb..a3214dd2f 100644 --- a/parser/html/nsHtml5Portability.h +++ b/parser/html/nsHtml5Portability.h @@ -30,7 +30,7 @@ #include "nsIAtom.h" #include "nsHtml5AtomTable.h" -#include "nsString.h" +#include "nsHtml5String.h" #include "nsNameSpaceManager.h" #include "nsIContent.h" #include "nsTraceRefcnt.h" @@ -59,19 +59,26 @@ class nsHtml5Portability { public: static nsIAtom* newLocalNameFromBuffer(char16_t* buf, int32_t offset, int32_t length, nsHtml5AtomTable* interner); - static nsString* newStringFromBuffer(char16_t* buf, int32_t offset, int32_t length, nsHtml5TreeBuilder* treeBuilder); - static nsString* newEmptyString(); - static nsString* newStringFromLiteral(const char* literal); - static nsString* newStringFromString(nsString* string); + static nsHtml5String newStringFromBuffer(char16_t* buf, + int32_t offset, + int32_t length, + nsHtml5TreeBuilder* treeBuilder); + static nsHtml5String newEmptyString(); + static nsHtml5String newStringFromLiteral(const char* literal); + static nsHtml5String newStringFromString(nsHtml5String string); static jArray newCharArrayFromLocal(nsIAtom* local); - static jArray newCharArrayFromString(nsString* string); + static jArray newCharArrayFromString( + nsHtml5String string); static nsIAtom* newLocalFromLocal(nsIAtom* local, nsHtml5AtomTable* interner); - static void releaseString(nsString* str); static bool localEqualsBuffer(nsIAtom* local, char16_t* buf, int32_t offset, int32_t length); - static bool lowerCaseLiteralIsPrefixOfIgnoreAsciiCaseString(const char* lowerCaseLiteral, nsString* string); - static bool lowerCaseLiteralEqualsIgnoreAsciiCaseString(const char* lowerCaseLiteral, nsString* string); - static bool literalEqualsString(const char* literal, nsString* string); - static bool stringEqualsString(nsString* one, nsString* other); + static bool lowerCaseLiteralIsPrefixOfIgnoreAsciiCaseString( + const char* lowerCaseLiteral, + nsHtml5String string); + static bool lowerCaseLiteralEqualsIgnoreAsciiCaseString( + const char* lowerCaseLiteral, + nsHtml5String string); + static bool literalEqualsString(const char* literal, nsHtml5String string); + static bool stringEqualsString(nsHtml5String one, nsHtml5String other); static void initializeStatics(); static void releaseStatics(); }; diff --git a/parser/html/nsHtml5SpeculativeLoad.h b/parser/html/nsHtml5SpeculativeLoad.h index 575f6186d..6f1365bcf 100644 --- a/parser/html/nsHtml5SpeculativeLoad.h +++ b/parser/html/nsHtml5SpeculativeLoad.h @@ -35,45 +35,57 @@ class nsHtml5SpeculativeLoad { nsHtml5SpeculativeLoad(); ~nsHtml5SpeculativeLoad(); - inline void InitBase(const nsAString& aUrl) + inline void InitBase(nsHtml5String aUrl) { NS_PRECONDITION(mOpCode == eSpeculativeLoadUninitialized, "Trying to reinitialize a speculative load!"); mOpCode = eSpeculativeLoadBase; - mUrl.Assign(aUrl); + aUrl.ToString(mUrl); } - inline void InitMetaCSP(const nsAString& aCSP) { + inline void InitMetaCSP(nsHtml5String aCSP) + { NS_PRECONDITION(mOpCode == eSpeculativeLoadUninitialized, "Trying to reinitialize a speculative load!"); mOpCode = eSpeculativeLoadCSP; + nsString csp; // Not Auto, because using it to hold nsStringBuffer* + aCSP.ToString(csp); mMetaCSP.Assign( - nsContentUtils::TrimWhitespace(aCSP)); + nsContentUtils::TrimWhitespace(csp)); } - inline void InitMetaReferrerPolicy(const nsAString& aReferrerPolicy) { + inline void InitMetaReferrerPolicy(nsHtml5String aReferrerPolicy) + { NS_PRECONDITION(mOpCode == eSpeculativeLoadUninitialized, "Trying to reinitialize a speculative load!"); mOpCode = eSpeculativeLoadMetaReferrer; + nsString + referrerPolicy; // Not Auto, because using it to hold nsStringBuffer* + aReferrerPolicy.ToString(referrerPolicy); mReferrerPolicy.Assign( - nsContentUtils::TrimWhitespace(aReferrerPolicy)); + nsContentUtils::TrimWhitespace( + referrerPolicy)); } - inline void InitImage(const nsAString& aUrl, - const nsAString& aCrossOrigin, - const nsAString& aReferrerPolicy, - const nsAString& aSrcset, - const nsAString& aSizes) + inline void InitImage(nsHtml5String aUrl, + nsHtml5String aCrossOrigin, + nsHtml5String aReferrerPolicy, + nsHtml5String aSrcset, + nsHtml5String aSizes) { NS_PRECONDITION(mOpCode == eSpeculativeLoadUninitialized, "Trying to reinitialize a speculative load!"); mOpCode = eSpeculativeLoadImage; - mUrl.Assign(aUrl); - mCrossOrigin.Assign(aCrossOrigin); + aUrl.ToString(mUrl); + aCrossOrigin.ToString(mCrossOrigin); + nsString + referrerPolicy; // Not Auto, because using it to hold nsStringBuffer* + aReferrerPolicy.ToString(referrerPolicy); mReferrerPolicy.Assign( - nsContentUtils::TrimWhitespace(aReferrerPolicy)); - mSrcset.Assign(aSrcset); - mSizes.Assign(aSizes); + nsContentUtils::TrimWhitespace( + referrerPolicy)); + aSrcset.ToString(mSrcset); + aSizes.ToString(mSizes); } // elements have multiple nodes followed by an , @@ -97,49 +109,50 @@ class nsHtml5SpeculativeLoad { mOpCode = eSpeculativeLoadEndPicture; } - inline void InitPictureSource(const nsAString& aSrcset, - const nsAString& aSizes, - const nsAString& aType, - const nsAString& aMedia) + inline void InitPictureSource(nsHtml5String aSrcset, + nsHtml5String aSizes, + nsHtml5String aType, + nsHtml5String aMedia) { NS_PRECONDITION(mOpCode == eSpeculativeLoadUninitialized, "Trying to reinitialize a speculative load!"); mOpCode = eSpeculativeLoadPictureSource; - mSrcset.Assign(aSrcset); - mSizes.Assign(aSizes); - mTypeOrCharsetSourceOrDocumentMode.Assign(aType); - mMedia.Assign(aMedia); + aSrcset.ToString(mSrcset); + aSizes.ToString(mSizes); + aType.ToString(mTypeOrCharsetSourceOrDocumentMode); + aMedia.ToString(mMedia); } - inline void InitScript(const nsAString& aUrl, - const nsAString& aCharset, - const nsAString& aType, - const nsAString& aCrossOrigin, - const nsAString& aIntegrity, + inline void InitScript(nsHtml5String aUrl, + nsHtml5String aCharset, + nsHtml5String aType, + nsHtml5String aCrossOrigin, + nsHtml5String aIntegrity, bool aParserInHead) { NS_PRECONDITION(mOpCode == eSpeculativeLoadUninitialized, "Trying to reinitialize a speculative load!"); mOpCode = aParserInHead ? eSpeculativeLoadScriptFromHead : eSpeculativeLoadScript; - mUrl.Assign(aUrl); - mCharset.Assign(aCharset); - mTypeOrCharsetSourceOrDocumentMode.Assign(aType); - mCrossOrigin.Assign(aCrossOrigin); - mIntegrity.Assign(aIntegrity); + aUrl.ToString(mUrl); + aCharset.ToString(mCharset); + aType.ToString(mTypeOrCharsetSourceOrDocumentMode); + aCrossOrigin.ToString(mCrossOrigin); + aIntegrity.ToString(mIntegrity); } - inline void InitStyle(const nsAString& aUrl, const nsAString& aCharset, - const nsAString& aCrossOrigin, - const nsAString& aIntegrity) + inline void InitStyle(nsHtml5String aUrl, + nsHtml5String aCharset, + nsHtml5String aCrossOrigin, + nsHtml5String aIntegrity) { NS_PRECONDITION(mOpCode == eSpeculativeLoadUninitialized, "Trying to reinitialize a speculative load!"); mOpCode = eSpeculativeLoadStyle; - mUrl.Assign(aUrl); - mCharset.Assign(aCharset); - mCrossOrigin.Assign(aCrossOrigin); - mIntegrity.Assign(aIntegrity); + aUrl.ToString(mUrl); + aCharset.ToString(mCharset); + aCrossOrigin.ToString(mCrossOrigin); + aIntegrity.ToString(mIntegrity); } /** @@ -153,12 +166,12 @@ class nsHtml5SpeculativeLoad { * manifests seen by the parser thread have to maintain the queue order * relative to true speculative loads. See bug 541079. */ - inline void InitManifest(const nsAString& aUrl) + inline void InitManifest(nsHtml5String aUrl) { NS_PRECONDITION(mOpCode == eSpeculativeLoadUninitialized, "Trying to reinitialize a speculative load!"); mOpCode = eSpeculativeLoadManifest; - mUrl.Assign(aUrl); + aUrl.ToString(mUrl); } /** @@ -195,14 +208,13 @@ class nsHtml5SpeculativeLoad { mTypeOrCharsetSourceOrDocumentMode.Assign((char16_t)aMode); } - inline void InitPreconnect(const nsAString& aUrl, - const nsAString& aCrossOrigin) + inline void InitPreconnect(nsHtml5String aUrl, nsHtml5String aCrossOrigin) { NS_PRECONDITION(mOpCode == eSpeculativeLoadUninitialized, "Trying to reinitialize a speculative load!"); mOpCode = eSpeculativeLoadPreconnect; - mUrl.Assign(aUrl); - mCrossOrigin.Assign(aCrossOrigin); + aUrl.ToString(mUrl); + aCrossOrigin.ToString(mCrossOrigin); } void Perform(nsHtml5TreeOpExecutor* aExecutor); diff --git a/parser/html/nsHtml5StackNode.cpp b/parser/html/nsHtml5StackNode.cpp index ac5f0b2a3..41163ae40 100644 --- a/parser/html/nsHtml5StackNode.cpp +++ b/parser/html/nsHtml5StackNode.cpp @@ -30,7 +30,7 @@ #include "nsIAtom.h" #include "nsHtml5AtomTable.h" -#include "nsString.h" +#include "nsHtml5String.h" #include "nsNameSpaceManager.h" #include "nsIContent.h" #include "nsTraceRefcnt.h" diff --git a/parser/html/nsHtml5StackNode.h b/parser/html/nsHtml5StackNode.h index 57909ca9c..1677ec571 100644 --- a/parser/html/nsHtml5StackNode.h +++ b/parser/html/nsHtml5StackNode.h @@ -31,7 +31,7 @@ #include "nsIAtom.h" #include "nsHtml5AtomTable.h" -#include "nsString.h" +#include "nsHtml5String.h" #include "nsNameSpaceManager.h" #include "nsIContent.h" #include "nsTraceRefcnt.h" diff --git a/parser/html/nsHtml5StateSnapshot.cpp b/parser/html/nsHtml5StateSnapshot.cpp index e8e3debf0..90780738b 100644 --- a/parser/html/nsHtml5StateSnapshot.cpp +++ b/parser/html/nsHtml5StateSnapshot.cpp @@ -29,7 +29,7 @@ #include "nsIAtom.h" #include "nsHtml5AtomTable.h" -#include "nsString.h" +#include "nsHtml5String.h" #include "nsNameSpaceManager.h" #include "nsIContent.h" #include "nsTraceRefcnt.h" diff --git a/parser/html/nsHtml5StateSnapshot.h b/parser/html/nsHtml5StateSnapshot.h index 141b34340..119570499 100644 --- a/parser/html/nsHtml5StateSnapshot.h +++ b/parser/html/nsHtml5StateSnapshot.h @@ -30,7 +30,7 @@ #include "nsIAtom.h" #include "nsHtml5AtomTable.h" -#include "nsString.h" +#include "nsHtml5String.h" #include "nsNameSpaceManager.h" #include "nsIContent.h" #include "nsTraceRefcnt.h" diff --git a/parser/html/nsHtml5StreamParser.cpp b/parser/html/nsHtml5StreamParser.cpp index 83bf4d8b6..ab4548125 100644 --- a/parser/html/nsHtml5StreamParser.cpp +++ b/parser/html/nsHtml5StreamParser.cpp @@ -1261,7 +1261,7 @@ nsHtml5StreamParser::PreferredForInternalEncodingDecl(nsACString& aEncoding) } bool -nsHtml5StreamParser::internalEncodingDeclaration(nsString* aEncoding) +nsHtml5StreamParser::internalEncodingDeclaration(nsHtml5String aEncoding) { // This code needs to stay in sync with // nsHtml5MetaScanner::tryCharset. Unfortunately, the @@ -1270,9 +1270,10 @@ nsHtml5StreamParser::internalEncodingDeclaration(nsString* aEncoding) if (mCharsetSource >= kCharsetFromMetaTag) { // this threshold corresponds to "confident" in the HTML5 spec return false; } - + nsString newEncoding16; // Not Auto, because using it to hold nsStringBuffer* + aEncoding.ToString(newEncoding16); nsAutoCString newEncoding; - CopyUTF16toUTF8(*aEncoding, newEncoding); + CopyUTF16toUTF8(newEncoding16, newEncoding); if (!PreferredForInternalEncodingDecl(newEncoding)) { return false; diff --git a/parser/html/nsHtml5StreamParser.h b/parser/html/nsHtml5StreamParser.h index 9a38ba067..2560f84ab 100644 --- a/parser/html/nsHtml5StreamParser.h +++ b/parser/html/nsHtml5StreamParser.h @@ -145,7 +145,7 @@ class nsHtml5StreamParser : public nsICharsetDetectionObserver { /** * Tree builder uses this to report a late */ - bool internalEncodingDeclaration(nsString* aEncoding); + bool internalEncodingDeclaration(nsHtml5String aEncoding); // Not from an external interface diff --git a/parser/html/nsHtml5String.cpp b/parser/html/nsHtml5String.cpp new file mode 100644 index 000000000..d26eeaede --- /dev/null +++ b/parser/html/nsHtml5String.cpp @@ -0,0 +1,226 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "nsHtml5String.h" +#include "nsCharTraits.h" +#include "nsUTF8Utils.h" +#include "nsHtml5TreeBuilder.h" + +nsHtml5String::nsHtml5String(already_AddRefed aBuffer, + uint32_t aLength) + : mBuffer(aBuffer.take()) + , mLength(aLength) +{ + if (mBuffer) { + MOZ_ASSERT(aLength); + } else { + MOZ_ASSERT(!aLength || aLength == UINT32_MAX); + } +} + +void +nsHtml5String::ToString(nsAString& aString) +{ + if (mBuffer) { + mBuffer->ToString(mLength, aString); + } else { + aString.Truncate(); + if (mLength) { + aString.SetIsVoid(true); + } + } +} + +void +nsHtml5String::CopyToBuffer(char16_t* aBuffer) +{ + if (mBuffer) { + memcpy(aBuffer, mBuffer->Data(), mLength * sizeof(char16_t)); + } +} + +bool +nsHtml5String::LowerCaseEqualsASCII(const char* aLowerCaseLiteral) +{ + if (!mBuffer) { + if (mLength) { + // This string is null + return false; + } + // this string is empty + return !(*aLowerCaseLiteral); + } + return !nsCharTraits::compareLowerCaseToASCIINullTerminated( + reinterpret_cast(mBuffer->Data()), Length(), aLowerCaseLiteral); +} + +bool +nsHtml5String::EqualsASCII(const char* aLiteral) +{ + if (!mBuffer) { + if (mLength) { + // This string is null + return false; + } + // this string is empty + return !(*aLiteral); + } + return !nsCharTraits::compareASCIINullTerminated( + reinterpret_cast(mBuffer->Data()), Length(), aLiteral); +} + +bool +nsHtml5String::LowerCaseStartsWithASCII(const char* aLowerCaseLiteral) +{ + if (!mBuffer) { + if (mLength) { + // This string is null + return false; + } + // this string is empty + return !(*aLowerCaseLiteral); + } + const char* litPtr = aLowerCaseLiteral; + const char16_t* strPtr = reinterpret_cast(mBuffer->Data()); + const char16_t* end = strPtr + Length(); + char16_t litChar; + while ((litChar = *litPtr) && (strPtr != end)) { + MOZ_ASSERT(!(litChar >= 'A' && litChar <= 'Z'), + "Literal isn't in lower case."); + char16_t strChar = *strPtr; + if (strChar >= 'A' && strChar <= 'Z') { + strChar += 0x20; + } + if (litChar != strChar) { + return false; + } + ++litPtr; + ++strPtr; + } + return true; +} + +bool +nsHtml5String::Equals(nsHtml5String aOther) +{ + MOZ_ASSERT(operator bool()); + MOZ_ASSERT(aOther); + if (mLength != aOther.mLength) { + return false; + } + if (!mBuffer) { + return true; + } + MOZ_ASSERT(aOther.mBuffer); + return !memcmp( + mBuffer->Data(), aOther.mBuffer->Data(), Length() * sizeof(char16_t)); +} + +nsHtml5String +nsHtml5String::Clone() +{ + MOZ_ASSERT(operator bool()); + RefPtr ref(mBuffer); + return nsHtml5String(ref.forget(), mLength); +} + +void +nsHtml5String::Release() +{ + if (mBuffer) { + mBuffer->Release(); + mBuffer = nullptr; + } + mLength = UINT32_MAX; +} + +// static +nsHtml5String +nsHtml5String::FromBuffer(char16_t* aBuffer, + int32_t aLength, + nsHtml5TreeBuilder* aTreeBuilder) +{ + if (!aLength) { + return nsHtml5String(nullptr, 0U); + } + // Work with nsStringBuffer directly to make sure that storage is actually + // nsStringBuffer and to make sure the allocation strategy matches + // nsAttrValue::GetStringBuffer, so that it doesn't need to reallocate and + // copy. + RefPtr buffer( + nsStringBuffer::Alloc((aLength + 1) * sizeof(char16_t))); + if (!buffer) { + if (!aTreeBuilder) { + MOZ_CRASH("Out of memory."); + } + aTreeBuilder->MarkAsBroken(NS_ERROR_OUT_OF_MEMORY); + buffer = nsStringBuffer::Alloc(2 * sizeof(char16_t)); + if (!buffer) { + MOZ_CRASH( + "Out of memory so badly that couldn't even allocate placeholder."); + } + char16_t* data = reinterpret_cast(buffer->Data()); + data[0] = 0xFFFD; + data[1] = 0; + return nsHtml5String(buffer.forget(), 1); + } + char16_t* data = reinterpret_cast(buffer->Data()); + memcpy(data, aBuffer, aLength * sizeof(char16_t)); + data[aLength] = 0; + return nsHtml5String(buffer.forget(), aLength); +} + +// static +nsHtml5String +nsHtml5String::FromLiteral(const char* aLiteral) +{ + size_t length = std::strlen(aLiteral); + if (!length) { + return nsHtml5String(nullptr, 0U); + } + // Work with nsStringBuffer directly to make sure that storage is actually + // nsStringBuffer and to make sure the allocation strategy matches + // nsAttrValue::GetStringBuffer, so that it doesn't need to reallocate and + // copy. + RefPtr buffer( + nsStringBuffer::Alloc((length + 1) * sizeof(char16_t))); + if (!buffer) { + MOZ_CRASH("Out of memory."); + } + char16_t* data = reinterpret_cast(buffer->Data()); + LossyConvertEncoding8to16 converter(data); + converter.write(aLiteral, length); + data[length] = 0; + return nsHtml5String(buffer.forget(), length); +} + +// static +nsHtml5String +nsHtml5String::FromString(const nsAString& aString) +{ + auto length = aString.Length(); + if (!length) { + return nsHtml5String(nullptr, 0U); + } + RefPtr buffer = nsStringBuffer::FromString(aString); + if (buffer) { + return nsHtml5String(buffer.forget(), length); + } + buffer = nsStringBuffer::Alloc((length + 1) * sizeof(char16_t)); + if (!buffer) { + MOZ_CRASH("Out of memory."); + } + char16_t* data = reinterpret_cast(buffer->Data()); + memcpy(data, aString.BeginReading(), length * sizeof(char16_t)); + data[length] = 0; + return nsHtml5String(buffer.forget(), length); +} + +// static +nsHtml5String +nsHtml5String::EmptyString() +{ + return nsHtml5String(nullptr, 0U); + +} \ No newline at end of file diff --git a/parser/html/nsHtml5String.h b/parser/html/nsHtml5String.h new file mode 100644 index 000000000..191bf6be8 --- /dev/null +++ b/parser/html/nsHtml5String.h @@ -0,0 +1,95 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef nsHtml5String_h +#define nsHtml5String_h + +#include "nsString.h" + +class nsHtml5TreeBuilder; + +/** + * A pass-by-value type that combines an unsafe `nsStringBuffer*` with its + * logical length (`uint32_t`). (`nsStringBuffer` knows its capacity but not + * its logical length, i.e. how much of the capacity is in use.) + * + * Holding or passing this type is as unsafe as holding or passing + * `nsStringBuffer*`. + * + * Empty strings and null strings are distinct. Since an empty nsString does + * not have a an `nsStringBuffer`, both empty and null `nsHtml5String` have + * `nullptr` as `mBuffer`. If `mBuffer` is `nullptr`, the empty case is marked + * with `mLength` being zero and the null case with `mLength` being non-zero. + */ +class nsHtml5String final +{ +public: + /** + * Default constructor. + */ + inline nsHtml5String() + : nsHtml5String(nullptr) + { + } + + /** + * Constructor from nullptr. + */ + inline MOZ_IMPLICIT nsHtml5String(decltype(nullptr)) + : mBuffer(nullptr) + , mLength(UINT32_MAX) + { + } + + inline uint32_t Length() const { return mBuffer ? mLength : 0; } + + /** + * False iff the string is logically null + */ + inline MOZ_IMPLICIT operator bool() const { return !(!mBuffer && mLength); } + + void ToString(nsAString& aString); + + void CopyToBuffer(char16_t* aBuffer); + + bool LowerCaseEqualsASCII(const char* aLowerCaseLiteral); + + bool EqualsASCII(const char* aLiteral); + + bool LowerCaseStartsWithASCII(const char* aLowerCaseLiteral); + + bool Equals(nsHtml5String aOther); + + nsHtml5String Clone(); + + void Release(); + + static nsHtml5String FromBuffer(char16_t* aBuffer, + int32_t aLength, + nsHtml5TreeBuilder* aTreeBuilder); + + static nsHtml5String FromLiteral(const char* aLiteral); + + static nsHtml5String FromString(const nsAString& aString); + + static nsHtml5String EmptyString(); + +private: + /** + * Constructor from raw parts. + */ + nsHtml5String(already_AddRefed aBuffer, uint32_t aLength); + + /** + * nullptr if the string is logically null or logically empty + */ + nsStringBuffer* mBuffer; + + /** + * The length of the string. non-zero if the string is logically null. + */ + uint32_t mLength; +}; + +#endif // nsHtml5String_h \ No newline at end of file diff --git a/parser/html/nsHtml5Tokenizer.cpp b/parser/html/nsHtml5Tokenizer.cpp index 2838d74aa..a9db8d0c1 100644 --- a/parser/html/nsHtml5Tokenizer.cpp +++ b/parser/html/nsHtml5Tokenizer.cpp @@ -32,7 +32,7 @@ #include "nsIAtom.h" #include "nsHtml5AtomTable.h" -#include "nsString.h" +#include "nsHtml5String.h" #include "nsIContent.h" #include "nsTraceRefcnt.h" #include "jArray.h" @@ -113,7 +113,8 @@ nsHtml5Tokenizer::setInterner(nsHtml5AtomTable* interner) } void -nsHtml5Tokenizer::initLocation(nsString* newPublicId, nsString* newSystemId) +nsHtml5Tokenizer::initLocation(nsHtml5String newPublicId, + nsHtml5String newSystemId) { this->systemId = newSystemId; this->publicId = newPublicId; @@ -222,10 +223,11 @@ nsHtml5Tokenizer::emitOrAppendCharRefBuf(int32_t returnState) } } -nsString* +nsHtml5String nsHtml5Tokenizer::strBufToString() { - nsString* str = nsHtml5Portability::newStringFromBuffer(strBuf, 0, strBufLen, tokenHandler); + nsHtml5String str = + nsHtml5Portability::newStringFromBuffer(strBuf, 0, strBufLen, tokenHandler); clearStrBufAfterUse(); return str; } @@ -350,7 +352,7 @@ void nsHtml5Tokenizer::addAttributeWithValue() { if (attributeName) { - nsString* val = strBufToString(); + nsHtml5String val = strBufToString(); if (mViewSource) { mViewSource->MaybeLinkifyAttributeValue(attributeName, val); } @@ -3496,11 +3498,11 @@ nsHtml5Tokenizer::initDoctypeFields() clearStrBufAfterUse(); doctypeName = nsHtml5Atoms::emptystring; if (systemIdentifier) { - nsHtml5Portability::releaseString(systemIdentifier); + systemIdentifier.Release(); systemIdentifier = nullptr; } if (publicIdentifier) { - nsHtml5Portability::releaseString(publicIdentifier); + publicIdentifier.Release(); publicIdentifier = nullptr; } forceQuirks = false; @@ -3662,11 +3664,11 @@ nsHtml5Tokenizer::eof() errEofInDoctype(); doctypeName = nsHtml5Atoms::emptystring; if (systemIdentifier) { - nsHtml5Portability::releaseString(systemIdentifier); + systemIdentifier.Release(); systemIdentifier = nullptr; } if (publicIdentifier) { - nsHtml5Portability::releaseString(publicIdentifier); + publicIdentifier.Release(); publicIdentifier = nullptr; } forceQuirks = true; @@ -3896,14 +3898,14 @@ nsHtml5Tokenizer::emitDoctypeToken(int32_t pos) cstart = pos + 1; tokenHandler->doctype(doctypeName, publicIdentifier, systemIdentifier, forceQuirks); doctypeName = nullptr; - nsHtml5Portability::releaseString(publicIdentifier); + publicIdentifier.Release(); publicIdentifier = nullptr; - nsHtml5Portability::releaseString(systemIdentifier); + systemIdentifier.Release(); systemIdentifier = nullptr; } bool -nsHtml5Tokenizer::internalEncodingDeclaration(nsString* internalCharset) +nsHtml5Tokenizer::internalEncodingDeclaration(nsHtml5String internalCharset) { if (encodingDeclarationHandler) { return encodingDeclarationHandler->internalEncodingDeclaration(internalCharset); @@ -3938,11 +3940,11 @@ nsHtml5Tokenizer::end() strBuf = nullptr; doctypeName = nullptr; if (systemIdentifier) { - nsHtml5Portability::releaseString(systemIdentifier); + systemIdentifier.Release(); systemIdentifier = nullptr; } if (publicIdentifier) { - nsHtml5Portability::releaseString(publicIdentifier); + publicIdentifier.Release(); publicIdentifier = nullptr; } if (tagName) { @@ -4041,13 +4043,13 @@ nsHtml5Tokenizer::loadState(nsHtml5Tokenizer* other) } else { doctypeName = nsHtml5Portability::newLocalFromLocal(other->doctypeName, interner); } - nsHtml5Portability::releaseString(systemIdentifier); + systemIdentifier.Release(); if (!other->systemIdentifier) { systemIdentifier = nullptr; } else { systemIdentifier = nsHtml5Portability::newStringFromString(other->systemIdentifier); } - nsHtml5Portability::releaseString(publicIdentifier); + publicIdentifier.Release(); if (!other->publicIdentifier) { publicIdentifier = nullptr; } else { diff --git a/parser/html/nsHtml5Tokenizer.h b/parser/html/nsHtml5Tokenizer.h index da509b69b..00cca9a9c 100644 --- a/parser/html/nsHtml5Tokenizer.h +++ b/parser/html/nsHtml5Tokenizer.h @@ -33,7 +33,7 @@ #include "nsIAtom.h" #include "nsHtml5AtomTable.h" -#include "nsString.h" +#include "nsHtml5String.h" #include "nsIContent.h" #include "nsTraceRefcnt.h" #include "jArray.h" @@ -106,8 +106,8 @@ class nsHtml5Tokenizer protected: int32_t cstart; private: - nsString* publicId; - nsString* systemId; + nsHtml5String publicId; + nsHtml5String systemId; autoJArray strBuf; int32_t strBufLen; autoJArray charRefBuf; @@ -126,8 +126,8 @@ class nsHtml5Tokenizer nsHtml5AttributeName* attributeName; private: nsIAtom* doctypeName; - nsString* publicIdentifier; - nsString* systemIdentifier; + nsHtml5String publicIdentifier; + nsHtml5String systemIdentifier; nsHtml5HtmlAttributes* attributes; bool newAttributesEachTime; bool shouldSuspend; @@ -141,7 +141,7 @@ class nsHtml5Tokenizer public: nsHtml5Tokenizer(nsHtml5TreeBuilder* tokenHandler, bool viewingXmlSource); void setInterner(nsHtml5AtomTable* interner); - void initLocation(nsString* newPublicId, nsString* newSystemId); + void initLocation(nsHtml5String newPublicId, nsHtml5String newSystemId); bool isViewingXmlSource(); void setStateAndEndTagExpectation(int32_t specialTokenizerState, nsIAtom* endTagExpectation); void setStateAndEndTagExpectation(int32_t specialTokenizerState, nsHtml5ElementName* endTagExpectation); @@ -193,7 +193,7 @@ class nsHtml5Tokenizer } protected: - nsString* strBufToString(); + nsHtml5String strBufToString(); private: void strBufToDoctypeName(); void emitStrBuf(); @@ -285,7 +285,7 @@ class nsHtml5Tokenizer } public: - bool internalEncodingDeclaration(nsString* internalCharset); + bool internalEncodingDeclaration(nsHtml5String internalCharset); private: void emitOrAppendTwo(const char16_t* val, int32_t returnState); void emitOrAppendOne(const char16_t* val, int32_t returnState); diff --git a/parser/html/nsHtml5TreeBuilder.cpp b/parser/html/nsHtml5TreeBuilder.cpp index f694116ba..457c7deb1 100644 --- a/parser/html/nsHtml5TreeBuilder.cpp +++ b/parser/html/nsHtml5TreeBuilder.cpp @@ -34,7 +34,7 @@ #include "nsIAtom.h" #include "nsHtml5AtomTable.h" #include "nsITimer.h" -#include "nsString.h" +#include "nsHtml5String.h" #include "nsNameSpaceManager.h" #include "nsIContent.h" #include "nsTraceRefcnt.h" @@ -154,13 +154,16 @@ nsHtml5TreeBuilder::startTokenization(nsHtml5Tokenizer* self) } void -nsHtml5TreeBuilder::doctype(nsIAtom* name, nsString* publicIdentifier, nsString* systemIdentifier, bool forceQuirks) +nsHtml5TreeBuilder::doctype(nsIAtom* name, + nsHtml5String publicIdentifier, + nsHtml5String systemIdentifier, + bool forceQuirks) { needToDropLF = false; if (!isInForeign() && mode == NS_HTML5TREE_BUILDER_INITIAL) { - nsString* emptyString = nsHtml5Portability::newEmptyString(); + nsHtml5String emptyString = nsHtml5Portability::newEmptyString(); appendDoctypeToDocument(!name ? nsHtml5Atoms::emptystring : name, !publicIdentifier ? emptyString : publicIdentifier, !systemIdentifier ? emptyString : systemIdentifier); - nsHtml5Portability::releaseString(emptyString); + emptyString.Release(); if (isQuirky(name, publicIdentifier, systemIdentifier, forceQuirks)) { errQuirkyDoctype(); documentModeInternal(QUIRKS_MODE, publicIdentifier, systemIdentifier, false); @@ -1990,8 +1993,9 @@ nsHtml5TreeBuilder::isSpecialParentInForeign(nsHtml5StackNode* stackNode) return (kNameSpaceID_XHTML == ns) || (stackNode->isHtmlIntegrationPoint()) || ((kNameSpaceID_MathML == ns) && (stackNode->getGroup() == NS_HTML5TREE_BUILDER_MI_MO_MN_MS_MTEXT)); } -nsString* -nsHtml5TreeBuilder::extractCharsetFromContent(nsString* attributeValue, nsHtml5TreeBuilder* tb) +nsHtml5String +nsHtml5TreeBuilder::extractCharsetFromContent(nsHtml5String attributeValue, + nsHtml5TreeBuilder* tb) { int32_t charsetState = NS_HTML5TREE_BUILDER_CHARSET_INITIAL; int32_t start = -1; @@ -2175,12 +2179,13 @@ nsHtml5TreeBuilder::extractCharsetFromContent(nsString* attributeValue, nsHtml5T } } charsetloop_end: ; - nsString* charset = nullptr; + nsHtml5String charset = nullptr; if (start != -1) { if (end == -1) { end = buffer.length; } - charset = nsHtml5Portability::newStringFromBuffer(buffer, start, end - start, tb); + charset = + nsHtml5Portability::newStringFromBuffer(buffer, start, end - start, tb); } return charset; } @@ -2188,7 +2193,8 @@ nsHtml5TreeBuilder::extractCharsetFromContent(nsString* attributeValue, nsHtml5T void nsHtml5TreeBuilder::checkMetaCharset(nsHtml5HtmlAttributes* attributes) { - nsString* charset = attributes->getValue(nsHtml5AttributeName::ATTR_CHARSET); + nsHtml5String charset = + attributes->getValue(nsHtml5AttributeName::ATTR_CHARSET); if (charset) { if (tokenizer->internalEncodingDeclaration(charset)) { requestSuspension(); @@ -2199,15 +2205,17 @@ nsHtml5TreeBuilder::checkMetaCharset(nsHtml5HtmlAttributes* attributes) if (!nsHtml5Portability::lowerCaseLiteralEqualsIgnoreAsciiCaseString("content-type", attributes->getValue(nsHtml5AttributeName::ATTR_HTTP_EQUIV))) { return; } - nsString* content = attributes->getValue(nsHtml5AttributeName::ATTR_CONTENT); + nsHtml5String content = + attributes->getValue(nsHtml5AttributeName::ATTR_CONTENT); if (content) { - nsString* extract = nsHtml5TreeBuilder::extractCharsetFromContent(content, this); + nsHtml5String extract = + nsHtml5TreeBuilder::extractCharsetFromContent(content, this); if (extract) { if (tokenizer->internalEncodingDeclaration(extract)) { requestSuspension(); } } - nsHtml5Portability::releaseString(extract); + extract.Release(); } } @@ -3208,7 +3216,11 @@ nsHtml5TreeBuilder::isSecondOnStackBody() } void -nsHtml5TreeBuilder::documentModeInternal(nsHtml5DocumentMode m, nsString* publicIdentifier, nsString* systemIdentifier, bool html4SpecificAdditionalErrorChecks) +nsHtml5TreeBuilder::documentModeInternal( + nsHtml5DocumentMode m, + nsHtml5String publicIdentifier, + nsHtml5String systemIdentifier, + bool html4SpecificAdditionalErrorChecks) { if (isSrcdocDocument) { quirks = false; @@ -3220,7 +3232,8 @@ nsHtml5TreeBuilder::documentModeInternal(nsHtml5DocumentMode m, nsString* public } bool -nsHtml5TreeBuilder::isAlmostStandards(nsString* publicIdentifier, nsString* systemIdentifier) +nsHtml5TreeBuilder::isAlmostStandards(nsHtml5String publicIdentifier, + nsHtml5String systemIdentifier) { if (nsHtml5Portability::lowerCaseLiteralEqualsIgnoreAsciiCaseString("-//w3c//dtd xhtml 1.0 transitional//en", publicIdentifier)) { return true; @@ -3240,7 +3253,10 @@ nsHtml5TreeBuilder::isAlmostStandards(nsString* publicIdentifier, nsString* syst } bool -nsHtml5TreeBuilder::isQuirky(nsIAtom* name, nsString* publicIdentifier, nsString* systemIdentifier, bool forceQuirks) +nsHtml5TreeBuilder::isQuirky(nsIAtom* name, + nsHtml5String publicIdentifier, + nsHtml5String systemIdentifier, + bool forceQuirks) { if (forceQuirks) { return true; @@ -4051,7 +4067,8 @@ nsHtml5TreeBuilder::appendToCurrentNodeAndPushElementMayFosterMathML(nsHtml5Elem bool nsHtml5TreeBuilder::annotationXmlEncodingPermitsHtml(nsHtml5HtmlAttributes* attributes) { - nsString* encoding = attributes->getValue(nsHtml5AttributeName::ATTR_ENCODING); + nsHtml5String encoding = + attributes->getValue(nsHtml5AttributeName::ATTR_ENCODING); if (!encoding) { return false; } diff --git a/parser/html/nsHtml5TreeBuilder.h b/parser/html/nsHtml5TreeBuilder.h index a66b168be..67f5010c5 100644 --- a/parser/html/nsHtml5TreeBuilder.h +++ b/parser/html/nsHtml5TreeBuilder.h @@ -35,7 +35,7 @@ #include "nsIAtom.h" #include "nsHtml5AtomTable.h" #include "nsITimer.h" -#include "nsString.h" +#include "nsHtml5String.h" #include "nsNameSpaceManager.h" #include "nsIContent.h" #include "nsTraceRefcnt.h" @@ -103,7 +103,10 @@ class nsHtml5TreeBuilder : public nsAHtml5TreeBuilderState bool isSrcdocDocument; public: void startTokenization(nsHtml5Tokenizer* self); - void doctype(nsIAtom* name, nsString* publicIdentifier, nsString* systemIdentifier, bool forceQuirks); + void doctype(nsIAtom* name, + nsHtml5String publicIdentifier, + nsHtml5String systemIdentifier, + bool forceQuirks); void comment(char16_t* buf, int32_t start, int32_t length); void characters(const char16_t* buf, int32_t start, int32_t length); void zeroOriginatingReplacementCharacter(); @@ -119,7 +122,8 @@ class nsHtml5TreeBuilder : public nsAHtml5TreeBuilderState bool isTemplateModeStackEmpty(); bool isSpecialParentInForeign(nsHtml5StackNode* stackNode); public: - static nsString* extractCharsetFromContent(nsString* attributeValue, nsHtml5TreeBuilder* tb); + static nsHtml5String extractCharsetFromContent(nsHtml5String attributeValue, + nsHtml5TreeBuilder* tb); private: void checkMetaCharset(nsHtml5HtmlAttributes* attributes); public: @@ -136,9 +140,16 @@ class nsHtml5TreeBuilder : public nsAHtml5TreeBuilderState void generateImpliedEndTagsExceptFor(nsIAtom* name); void generateImpliedEndTags(); bool isSecondOnStackBody(); - void documentModeInternal(nsHtml5DocumentMode m, nsString* publicIdentifier, nsString* systemIdentifier, bool html4SpecificAdditionalErrorChecks); - bool isAlmostStandards(nsString* publicIdentifier, nsString* systemIdentifier); - bool isQuirky(nsIAtom* name, nsString* publicIdentifier, nsString* systemIdentifier, bool forceQuirks); + void documentModeInternal(nsHtml5DocumentMode m, + nsHtml5String publicIdentifier, + nsHtml5String systemIdentifier, + bool html4SpecificAdditionalErrorChecks); + bool isAlmostStandards(nsHtml5String publicIdentifier, + nsHtml5String systemIdentifier); + bool isQuirky(nsIAtom* name, + nsHtml5String publicIdentifier, + nsHtml5String systemIdentifier, + bool forceQuirks); void closeTheCell(int32_t eltPos); int32_t findLastInTableScopeTdTh(); void clearStackBackTo(int32_t eltPos); @@ -224,7 +235,9 @@ class nsHtml5TreeBuilder : public nsAHtml5TreeBuilderState void markMalformedIfScript(nsIContentHandle* elt); void start(bool fragmentMode); void end(); - void appendDoctypeToDocument(nsIAtom* name, nsString* publicIdentifier, nsString* systemIdentifier); + void appendDoctypeToDocument(nsIAtom* name, + nsHtml5String publicIdentifier, + nsHtml5String systemIdentifier); void elementPushed(int32_t ns, nsIAtom* name, nsIContentHandle* node); void elementPopped(int32_t ns, nsIAtom* name, nsIContentHandle* node); public: diff --git a/parser/html/nsHtml5TreeBuilderCppSupplement.h b/parser/html/nsHtml5TreeBuilderCppSupplement.h index ff17c326e..aacc5a3e0 100644 --- a/parser/html/nsHtml5TreeBuilderCppSupplement.h +++ b/parser/html/nsHtml5TreeBuilderCppSupplement.h @@ -123,181 +123,178 @@ nsHtml5TreeBuilder::createElement(int32_t aNamespace, nsIAtom* aName, switch (aNamespace) { case kNameSpaceID_XHTML: if (nsHtml5Atoms::img == aName) { - nsString* url = aAttributes->getValue(nsHtml5AttributeName::ATTR_SRC); - nsString* srcset = + nsHtml5String url = + aAttributes->getValue(nsHtml5AttributeName::ATTR_SRC); + nsHtml5String srcset = aAttributes->getValue(nsHtml5AttributeName::ATTR_SRCSET); - nsString* crossOrigin = + nsHtml5String crossOrigin = aAttributes->getValue(nsHtml5AttributeName::ATTR_CROSSORIGIN); - nsString* referrerPolicy = + nsHtml5String referrerPolicy = aAttributes->getValue(nsHtml5AttributeName::ATTR_REFERRERPOLICY); - nsString* sizes = + nsHtml5String sizes = aAttributes->getValue(nsHtml5AttributeName::ATTR_SIZES); - mSpeculativeLoadQueue.AppendElement()-> - InitImage(url ? *url : NullString(), - crossOrigin ? *crossOrigin : NullString(), - referrerPolicy ? *referrerPolicy : NullString(), - srcset ? *srcset : NullString(), - sizes ? *sizes : NullString()); + mSpeculativeLoadQueue.AppendElement()->InitImage( + url, crossOrigin, referrerPolicy, srcset, sizes); } else if (nsHtml5Atoms::source == aName) { - nsString* srcset = + nsHtml5String srcset = aAttributes->getValue(nsHtml5AttributeName::ATTR_SRCSET); // Sources without srcset cannot be selected. The source could also be // for a media element, but in that context doesn't use srcset. See // comments in nsHtml5SpeculativeLoad.h about preloading if (srcset) { - nsString* sizes = + nsHtml5String sizes = aAttributes->getValue(nsHtml5AttributeName::ATTR_SIZES); - nsString* type = + nsHtml5String type = aAttributes->getValue(nsHtml5AttributeName::ATTR_TYPE); - nsString* media = + nsHtml5String media = aAttributes->getValue(nsHtml5AttributeName::ATTR_MEDIA); - mSpeculativeLoadQueue.AppendElement()-> - InitPictureSource(*srcset, - sizes ? *sizes : NullString(), - type ? *type : NullString(), - media ? *media : NullString()); + mSpeculativeLoadQueue.AppendElement()->InitPictureSource( + srcset, sizes, type, media); } } else if (nsHtml5Atoms::script == aName) { nsHtml5TreeOperation* treeOp = mOpQueue.AppendElement(); NS_ASSERTION(treeOp, "Tree op allocation failed."); treeOp->Init(eTreeOpSetScriptLineNumberAndFreeze, content, tokenizer->getLineNumber()); - nsString* url = aAttributes->getValue(nsHtml5AttributeName::ATTR_SRC); + nsHtml5String url = + aAttributes->getValue(nsHtml5AttributeName::ATTR_SRC); if (url) { - nsString* charset = aAttributes->getValue(nsHtml5AttributeName::ATTR_CHARSET); - nsString* type = aAttributes->getValue(nsHtml5AttributeName::ATTR_TYPE); - nsString* crossOrigin = + nsHtml5String charset = + aAttributes->getValue(nsHtml5AttributeName::ATTR_CHARSET); + nsHtml5String type = + aAttributes->getValue(nsHtml5AttributeName::ATTR_TYPE); + nsHtml5String crossOrigin = aAttributes->getValue(nsHtml5AttributeName::ATTR_CROSSORIGIN); - nsString* integrity = + nsHtml5String integrity = aAttributes->getValue(nsHtml5AttributeName::ATTR_INTEGRITY); - mSpeculativeLoadQueue.AppendElement()-> - InitScript(*url, - (charset) ? *charset : EmptyString(), - (type) ? *type : EmptyString(), - (crossOrigin) ? *crossOrigin : NullString(), - (integrity) ? *integrity : NullString(), - mode == NS_HTML5TREE_BUILDER_IN_HEAD); + mSpeculativeLoadQueue.AppendElement()->InitScript( + url, + charset, + type, + crossOrigin, + integrity, + mode == NS_HTML5TREE_BUILDER_IN_HEAD); mCurrentHtmlScriptIsAsyncOrDefer = aAttributes->contains(nsHtml5AttributeName::ATTR_ASYNC) || aAttributes->contains(nsHtml5AttributeName::ATTR_DEFER); } } else if (nsHtml5Atoms::link == aName) { - nsString* rel = aAttributes->getValue(nsHtml5AttributeName::ATTR_REL); + nsHtml5String rel = + aAttributes->getValue(nsHtml5AttributeName::ATTR_REL); // Not splitting on space here is bogus but the old parser didn't even // do a case-insensitive check. if (rel) { - if (rel->LowerCaseEqualsASCII("stylesheet")) { - nsString* url = aAttributes->getValue(nsHtml5AttributeName::ATTR_HREF); + if (rel.LowerCaseEqualsASCII("stylesheet")) { + nsHtml5String url = + aAttributes->getValue(nsHtml5AttributeName::ATTR_HREF); if (url) { - nsString* charset = aAttributes->getValue(nsHtml5AttributeName::ATTR_CHARSET); - nsString* crossOrigin = + nsHtml5String charset = + aAttributes->getValue(nsHtml5AttributeName::ATTR_CHARSET); + nsHtml5String crossOrigin = aAttributes->getValue(nsHtml5AttributeName::ATTR_CROSSORIGIN); - nsString* integrity = + nsHtml5String integrity = aAttributes->getValue(nsHtml5AttributeName::ATTR_INTEGRITY); - mSpeculativeLoadQueue.AppendElement()-> - InitStyle(*url, - (charset) ? *charset : EmptyString(), - (crossOrigin) ? *crossOrigin : NullString(), - (integrity) ? *integrity : NullString()); + mSpeculativeLoadQueue.AppendElement()->InitStyle( + url, charset, crossOrigin, integrity); } - } else if (rel->LowerCaseEqualsASCII("preconnect")) { - nsString* url = aAttributes->getValue(nsHtml5AttributeName::ATTR_HREF); + } else if (rel.LowerCaseEqualsASCII("preconnect")) { + nsHtml5String url = + aAttributes->getValue(nsHtml5AttributeName::ATTR_HREF); if (url) { - nsString* crossOrigin = + nsHtml5String crossOrigin = aAttributes->getValue(nsHtml5AttributeName::ATTR_CROSSORIGIN); - mSpeculativeLoadQueue.AppendElement()-> - InitPreconnect(*url, (crossOrigin) ? *crossOrigin : NullString()); + mSpeculativeLoadQueue.AppendElement()->InitPreconnect( + url, crossOrigin); } } } } else if (nsHtml5Atoms::video == aName) { - nsString* url = aAttributes->getValue(nsHtml5AttributeName::ATTR_POSTER); + nsHtml5String url = + aAttributes->getValue(nsHtml5AttributeName::ATTR_POSTER); if (url) { - mSpeculativeLoadQueue.AppendElement()->InitImage(*url, NullString(), - NullString(), - NullString(), - NullString()); + mSpeculativeLoadQueue.AppendElement()->InitImage( + url, nullptr, nullptr, nullptr, nullptr); } } else if (nsHtml5Atoms::style == aName) { nsHtml5TreeOperation* treeOp = mOpQueue.AppendElement(); NS_ASSERTION(treeOp, "Tree op allocation failed."); treeOp->Init(eTreeOpSetStyleLineNumber, content, tokenizer->getLineNumber()); } else if (nsHtml5Atoms::html == aName) { - nsString* url = aAttributes->getValue(nsHtml5AttributeName::ATTR_MANIFEST); - if (url) { - mSpeculativeLoadQueue.AppendElement()->InitManifest(*url); - } else { - mSpeculativeLoadQueue.AppendElement()->InitManifest(EmptyString()); - } + nsHtml5String url = + aAttributes->getValue(nsHtml5AttributeName::ATTR_MANIFEST); + mSpeculativeLoadQueue.AppendElement()->InitManifest(url); } else if (nsHtml5Atoms::base == aName) { - nsString* url = - aAttributes->getValue(nsHtml5AttributeName::ATTR_HREF); + nsHtml5String url = + aAttributes->getValue(nsHtml5AttributeName::ATTR_HREF); if (url) { - mSpeculativeLoadQueue.AppendElement()->InitBase(*url); + mSpeculativeLoadQueue.AppendElement()->InitBase(url); } } else if (nsHtml5Atoms::meta == aName) { if (nsHtml5Portability::lowerCaseLiteralEqualsIgnoreAsciiCaseString( "content-security-policy", aAttributes->getValue(nsHtml5AttributeName::ATTR_HTTP_EQUIV))) { - nsString* csp = aAttributes->getValue(nsHtml5AttributeName::ATTR_CONTENT); + nsHtml5String csp = + aAttributes->getValue(nsHtml5AttributeName::ATTR_CONTENT); if (csp) { - mSpeculativeLoadQueue.AppendElement()->InitMetaCSP(*csp); + mSpeculativeLoadQueue.AppendElement()->InitMetaCSP(csp); } } else if (nsHtml5Portability::lowerCaseLiteralEqualsIgnoreAsciiCaseString( "referrer", aAttributes->getValue(nsHtml5AttributeName::ATTR_NAME))) { - nsString* referrerPolicy = aAttributes->getValue(nsHtml5AttributeName::ATTR_CONTENT); + nsHtml5String referrerPolicy = + aAttributes->getValue(nsHtml5AttributeName::ATTR_CONTENT); if (referrerPolicy) { - mSpeculativeLoadQueue.AppendElement()->InitMetaReferrerPolicy(*referrerPolicy); + mSpeculativeLoadQueue.AppendElement()->InitMetaReferrerPolicy( + referrerPolicy); } } } break; case kNameSpaceID_SVG: if (nsHtml5Atoms::image == aName) { - nsString* url = aAttributes->getValue(nsHtml5AttributeName::ATTR_XLINK_HREF); + nsHtml5String url = + aAttributes->getValue(nsHtml5AttributeName::ATTR_XLINK_HREF); if (url) { - mSpeculativeLoadQueue.AppendElement()->InitImage(*url, NullString(), - NullString(), - NullString(), - NullString()); + mSpeculativeLoadQueue.AppendElement()->InitImage( + url, nullptr, nullptr, nullptr, nullptr); } } else if (nsHtml5Atoms::script == aName) { nsHtml5TreeOperation* treeOp = mOpQueue.AppendElement(); NS_ASSERTION(treeOp, "Tree op allocation failed."); treeOp->Init(eTreeOpSetScriptLineNumberAndFreeze, content, tokenizer->getLineNumber()); - nsString* url = aAttributes->getValue(nsHtml5AttributeName::ATTR_XLINK_HREF); + nsHtml5String url = + aAttributes->getValue(nsHtml5AttributeName::ATTR_XLINK_HREF); if (url) { - nsString* type = aAttributes->getValue(nsHtml5AttributeName::ATTR_TYPE); - nsString* crossOrigin = + nsHtml5String type = + aAttributes->getValue(nsHtml5AttributeName::ATTR_TYPE); + nsHtml5String crossOrigin = aAttributes->getValue(nsHtml5AttributeName::ATTR_CROSSORIGIN); - nsString* integrity = + nsHtml5String integrity = aAttributes->getValue(nsHtml5AttributeName::ATTR_INTEGRITY); - mSpeculativeLoadQueue.AppendElement()-> - InitScript(*url, - EmptyString(), - (type) ? *type : EmptyString(), - (crossOrigin) ? *crossOrigin : NullString(), - (integrity) ? *integrity : NullString(), - mode == NS_HTML5TREE_BUILDER_IN_HEAD); + mSpeculativeLoadQueue.AppendElement()->InitScript( + url, + nullptr, + type, + crossOrigin, + integrity, + mode == NS_HTML5TREE_BUILDER_IN_HEAD); } } else if (nsHtml5Atoms::style == aName) { nsHtml5TreeOperation* treeOp = mOpQueue.AppendElement(); NS_ASSERTION(treeOp, "Tree op allocation failed."); treeOp->Init(eTreeOpSetStyleLineNumber, content, tokenizer->getLineNumber()); - nsString* url = aAttributes->getValue(nsHtml5AttributeName::ATTR_XLINK_HREF); + nsHtml5String url = + aAttributes->getValue(nsHtml5AttributeName::ATTR_XLINK_HREF); if (url) { - nsString* crossOrigin = + nsHtml5String crossOrigin = aAttributes->getValue(nsHtml5AttributeName::ATTR_CROSSORIGIN); - nsString* integrity = + nsHtml5String integrity = aAttributes->getValue(nsHtml5AttributeName::ATTR_INTEGRITY); - mSpeculativeLoadQueue.AppendElement()-> - InitStyle(*url, EmptyString(), - (crossOrigin) ? *crossOrigin : NullString(), - (integrity) ? *integrity : NullString()); + mSpeculativeLoadQueue.AppendElement()->InitStyle( + url, nullptr, crossOrigin, integrity); } } break; @@ -320,18 +317,23 @@ nsHtml5TreeBuilder::createElement(int32_t aNamespace, nsIAtom* aName, } } else if (aNamespace == kNameSpaceID_XHTML) { if (nsHtml5Atoms::html == aName) { - nsString* url = aAttributes->getValue(nsHtml5AttributeName::ATTR_MANIFEST); + nsHtml5String url = + aAttributes->getValue(nsHtml5AttributeName::ATTR_MANIFEST); nsHtml5TreeOperation* treeOp = mOpQueue.AppendElement(); NS_ASSERTION(treeOp, "Tree op allocation failed."); if (url) { - treeOp->Init(eTreeOpProcessOfflineManifest, *url); + nsString + urlString; // Not Auto, because using it to hold nsStringBuffer* + url.ToString(urlString); + treeOp->Init(eTreeOpProcessOfflineManifest, urlString); } else { treeOp->Init(eTreeOpProcessOfflineManifest, EmptyString()); } } else if (nsHtml5Atoms::base == aName && mViewSource) { - nsString* url = aAttributes->getValue(nsHtml5AttributeName::ATTR_HREF); + nsHtml5String url = + aAttributes->getValue(nsHtml5AttributeName::ATTR_HREF); if (url) { - mViewSource->AddBase(*url); + mViewSource->AddBase(url); } } } @@ -743,17 +745,19 @@ nsHtml5TreeBuilder::end() } void -nsHtml5TreeBuilder::appendDoctypeToDocument(nsIAtom* aName, nsString* aPublicId, nsString* aSystemId) +nsHtml5TreeBuilder::appendDoctypeToDocument(nsIAtom* aName, + nsHtml5String aPublicId, + nsHtml5String aSystemId) { NS_PRECONDITION(aName, "Null name"); - + nsString publicId; // Not Auto, because using it to hold nsStringBuffer* + nsString systemId; // Not Auto, because using it to hold nsStringBuffer* + aPublicId.ToString(publicId); + aSystemId.ToString(systemId); if (mBuilder) { nsCOMPtr name = nsHtml5TreeOperation::Reget(aName); - nsresult rv = - nsHtml5TreeOperation::AppendDoctypeToDocument(name, - *aPublicId, - *aSystemId, - mBuilder); + nsresult rv = nsHtml5TreeOperation::AppendDoctypeToDocument( + name, publicId, systemId, mBuilder); if (NS_FAILED(rv)) { MarkAsBrokenAndRequestSuspension(rv); } @@ -762,7 +766,7 @@ nsHtml5TreeBuilder::appendDoctypeToDocument(nsIAtom* aName, nsString* aPublicId, nsHtml5TreeOperation* treeOp = mOpQueue.AppendElement(); NS_ASSERTION(treeOp, "Tree op allocation failed."); - treeOp->Init(aName, *aPublicId, *aSystemId); + treeOp->Init(aName, publicId, systemId); // nsXMLContentSink can flush here, but what's the point? // It can also interrupt here, but we can't. } diff --git a/parser/html/nsHtml5TreeOperation.cpp b/parser/html/nsHtml5TreeOperation.cpp index af246a253..3877e01b8 100644 --- a/parser/html/nsHtml5TreeOperation.cpp +++ b/parser/html/nsHtml5TreeOperation.cpp @@ -319,11 +319,10 @@ nsHtml5TreeOperation::AddAttributes(nsIContent* aNode, if (!node->HasAttr(nsuri, localName)) { // prefix doesn't need regetting. it is always null or a static atom // local name is never null - node->SetAttr(nsuri, - localName, - aAttributes->getPrefixNoBoundsCheck(i), - *(aAttributes->getValueNoBoundsCheck(i)), - true); + nsString value; // Not Auto, because using it to hold nsStringBuffer* + aAttributes->getValueNoBoundsCheck(i).ToString(value); + node->SetAttr( + nsuri, localName, aAttributes->getPrefixNoBoundsCheck(i), value, true); // XXX what to do with nsresult? } } @@ -418,12 +417,14 @@ nsHtml5TreeOperation::CreateElement(int32_t aNs, nsCOMPtr prefix = aAttributes->getPrefixNoBoundsCheck(i); int32_t nsuri = aAttributes->getURINoBoundsCheck(i); + nsString value; // Not Auto, because using it to hold nsStringBuffer* + aAttributes->getValueNoBoundsCheck(i).ToString(value); if (aNs == kNameSpaceID_XHTML && nsHtml5Atoms::a == aName && nsHtml5Atoms::name == localName) { // This is an HTML5-incompliant Geckoism. // Remove when fixing bug 582361 - NS_ConvertUTF16toUTF8 cname(*(aAttributes->getValueNoBoundsCheck(i))); + NS_ConvertUTF16toUTF8 cname(value); NS_ConvertUTF8toUTF16 uv(nsUnescape(cname.BeginWriting())); newContent->SetAttr(nsuri, localName, @@ -431,7 +432,6 @@ nsHtml5TreeOperation::CreateElement(int32_t aNs, uv, false); } else { - nsString& value = *(aAttributes->getValueNoBoundsCheck(i)); newContent->SetAttr(nsuri, localName, prefix, diff --git a/parser/html/nsHtml5UTF16Buffer.cpp b/parser/html/nsHtml5UTF16Buffer.cpp index f70365ce4..0d6870bc4 100644 --- a/parser/html/nsHtml5UTF16Buffer.cpp +++ b/parser/html/nsHtml5UTF16Buffer.cpp @@ -29,7 +29,7 @@ #include "nsIAtom.h" #include "nsHtml5AtomTable.h" -#include "nsString.h" +#include "nsHtml5String.h" #include "nsNameSpaceManager.h" #include "nsIContent.h" #include "nsTraceRefcnt.h" diff --git a/parser/html/nsHtml5UTF16Buffer.h b/parser/html/nsHtml5UTF16Buffer.h index cf810e124..c94245f74 100644 --- a/parser/html/nsHtml5UTF16Buffer.h +++ b/parser/html/nsHtml5UTF16Buffer.h @@ -30,7 +30,7 @@ #include "nsIAtom.h" #include "nsHtml5AtomTable.h" -#include "nsString.h" +#include "nsHtml5String.h" #include "nsNameSpaceManager.h" #include "nsIContent.h" #include "nsTraceRefcnt.h" diff --git a/parser/html/nsHtml5ViewSourceUtils.cpp b/parser/html/nsHtml5ViewSourceUtils.cpp index 4dd33fc05..b2f635bff 100644 --- a/parser/html/nsHtml5ViewSourceUtils.cpp +++ b/parser/html/nsHtml5ViewSourceUtils.cpp @@ -6,32 +6,35 @@ #include "nsHtml5ViewSourceUtils.h" #include "nsHtml5AttributeName.h" #include "mozilla/Preferences.h" -#include "mozilla/UniquePtr.h" +#include "nsHtml5String.h" // static nsHtml5HtmlAttributes* nsHtml5ViewSourceUtils::NewBodyAttributes() { nsHtml5HtmlAttributes* bodyAttrs = new nsHtml5HtmlAttributes(0); - auto id = MakeUnique(NS_LITERAL_STRING("viewsource")); - bodyAttrs->addAttribute(nsHtml5AttributeName::ATTR_ID, id.release(), -1); + nsHtml5String id = nsHtml5Portability::newStringFromLiteral("viewsource"); + bodyAttrs->addAttribute(nsHtml5AttributeName::ATTR_ID, id, -1); - auto klass = MakeUnique(); + nsString klass; if (mozilla::Preferences::GetBool("view_source.wrap_long_lines", true)) { - klass->Append(NS_LITERAL_STRING("wrap ")); + klass.Append(NS_LITERAL_STRING("wrap ")); } if (mozilla::Preferences::GetBool("view_source.syntax_highlight", true)) { - klass->Append(NS_LITERAL_STRING("highlight")); + klass.Append(NS_LITERAL_STRING("highlight")); } - if (!klass->IsEmpty()) { - bodyAttrs->addAttribute(nsHtml5AttributeName::ATTR_CLASS, klass.release(), -1); + if (!klass.IsEmpty()) { + bodyAttrs->addAttribute( + nsHtml5AttributeName::ATTR_CLASS, nsHtml5String::FromString(klass), -1); } int32_t tabSize = mozilla::Preferences::GetInt("view_source.tab_size", 4); if (tabSize > 0) { - auto style = MakeUnique(NS_LITERAL_STRING("-moz-tab-size: ")); - style->AppendInt(tabSize); - bodyAttrs->addAttribute(nsHtml5AttributeName::ATTR_STYLE, style.release(), -1); + nsString style; + style.AssignASCII("-moz-tab-size: "); + style.AppendInt(tabSize); + bodyAttrs->addAttribute( + nsHtml5AttributeName::ATTR_STYLE, nsHtml5String::FromString(style), -1); } return bodyAttrs; @@ -42,12 +45,12 @@ nsHtml5HtmlAttributes* nsHtml5ViewSourceUtils::NewLinkAttributes() { nsHtml5HtmlAttributes* linkAttrs = new nsHtml5HtmlAttributes(0); - nsString* rel = new nsString(NS_LITERAL_STRING("stylesheet")); + nsHtml5String rel = nsHtml5Portability::newStringFromLiteral("stylesheet"); linkAttrs->addAttribute(nsHtml5AttributeName::ATTR_REL, rel, -1); - nsString* type = new nsString(NS_LITERAL_STRING("text/css")); + nsHtml5String type = nsHtml5Portability::newStringFromLiteral("text/css"); linkAttrs->addAttribute(nsHtml5AttributeName::ATTR_TYPE, type, -1); - nsString* href = new nsString( - NS_LITERAL_STRING("resource://gre-resources/viewsource.css")); + nsHtml5String href = nsHtml5Portability::newStringFromLiteral( + "resource://gre-resources/viewsource.css"); linkAttrs->addAttribute(nsHtml5AttributeName::ATTR_HREF, href, -1); return linkAttrs; } -- cgit v1.2.3 From 6741666a9b9d8a61346b9828e4eab851b39b5d6a Mon Sep 17 00:00:00 2001 From: Gaming4JC Date: Fri, 5 Jul 2019 11:52:56 -0400 Subject: Issue #1160 - [Basilisk] Remove unused HotFix preferences --- application/basilisk/app/profile/basilisk.js | 6 ------ 1 file changed, 6 deletions(-) diff --git a/application/basilisk/app/profile/basilisk.js b/application/basilisk/app/profile/basilisk.js index c229f3523..aa2df6d40 100644 --- a/application/basilisk/app/profile/basilisk.js +++ b/application/basilisk/app/profile/basilisk.js @@ -53,12 +53,6 @@ pref("extensions.getAddons.recommended.browseURL", "https://@AM_DOMAIN@/?compone pref("extensions.update.autoUpdateDefault", true); -// Leave these for the moment... -pref("extensions.hotfix.id", "firefox-hotfix@mozilla.org"); -pref("extensions.hotfix.cert.checkAttributes", true); -pref("extensions.hotfix.certs.1.sha1Fingerprint", "91:53:98:0C:C1:86:DF:47:8F:35:22:9E:11:C9:A7:31:04:49:A1:AA"); -pref("extensions.hotfix.certs.2.sha1Fingerprint", "39:E7:2B:7A:5B:CF:37:78:F9:5D:4A:E0:53:2D:2F:3D:68:53:C5:60"); - // Also, leave this for the moment... // Check AUS for system add-on updates. pref("extensions.systemAddon.update.url", "https://aus5.mozilla.org/update/3/SystemAddons/%VERSION%/%BUILD_ID%/%BUILD_TARGET%/%LOCALE%/%CHANNEL%/%OS_VERSION%/%DISTRIBUTION%/%DISTRIBUTION_VERSION%/update.xml"); -- cgit v1.2.3 From 48060d3484c9a8bf6c3b29e26591ab956d6061de Mon Sep 17 00:00:00 2001 From: Gaming4JC Date: Fri, 5 Jul 2019 21:17:46 -0400 Subject: Issue #1160 - Remove HotFix preferences from testing --- testing/profiles/prefs_general.js | 1 - testing/talos/talos/config.py | 2 -- testing/talos/tests/test_talosconfig_browser_config.json | 2 +- 3 files changed, 1 insertion(+), 4 deletions(-) diff --git a/testing/profiles/prefs_general.js b/testing/profiles/prefs_general.js index 35680ca43..3ec41b385 100644 --- a/testing/profiles/prefs_general.js +++ b/testing/profiles/prefs_general.js @@ -108,7 +108,6 @@ user_pref("extensions.update.background.url", "http://%(server)s/extensions-dumm user_pref("extensions.blocklist.detailsURL", "http://%(server)s/extensions-dummy/blocklistDetailsURL"); user_pref("extensions.blocklist.itemURL", "http://%(server)s/extensions-dummy/blocklistItemURL"); user_pref("extensions.blocklist.url", "http://%(server)s/extensions-dummy/blocklistURL"); -user_pref("extensions.hotfix.url", "http://%(server)s/extensions-dummy/hotfixURL"); user_pref("extensions.systemAddon.update.url", "http://%(server)s/dummy-system-addons.xml"); // Turn off extension updates so they don't bother tests user_pref("extensions.update.enabled", false); diff --git a/testing/talos/talos/config.py b/testing/talos/talos/config.py index 828e68a15..872bb3543 100644 --- a/testing/talos/talos/config.py +++ b/testing/talos/talos/config.py @@ -123,8 +123,6 @@ DEFAULTS = dict( 'extensions.blocklist.enabled': False, 'extensions.blocklist.url': 'http://127.0.0.1/extensions-dummy/blocklistURL', - 'extensions.hotfix.url': - 'http://127.0.0.1/extensions-dummy/hotfixURL', 'extensions.update.enabled': False, 'extensions.webservice.discoverURL': 'http://127.0.0.1/extensions-dummy/discoveryURL', diff --git a/testing/talos/tests/test_talosconfig_browser_config.json b/testing/talos/tests/test_talosconfig_browser_config.json index 7e7226c9f..b0ba17ad7 100644 --- a/testing/talos/tests/test_talosconfig_browser_config.json +++ b/testing/talos/tests/test_talosconfig_browser_config.json @@ -1 +1 @@ -{'deviceroot': '', 'dirs': {}, 'repository': 'http://hg.mozilla.org/releases/mozilla-release', 'buildid': '20131205075310', 'results_log': 'pathtoresults_log', 'symbols_path': None, 'bcontroller_config': 'pathtobcontroller', 'host': '', 'browser_name': 'Firefox', 'sourcestamp': '39faf812aaec', 'remote': False, 'child_process': 'plugin-container', 'branch_name': '', 'browser_version': '26.0', 'extra_args': '', 'develop': True, 'preferences': {'browser.display.overlaynavbuttons': False, 'extensions.getAddons.get.url': 'http://127.0.0.1/extensions-dummy/repositoryGetURL', 'dom.max_chrome_script_run_time': 0, 'network.proxy.type': 1, 'extensions.update.background.url': 'http://127.0.0.1/extensions-dummy/updateBackgroundURL', 'network.proxy.http': 'localhost', 'plugins.update.url': 'http://127.0.0.1/plugins-dummy/updateCheckURL', 'dom.max_script_run_time': 0, 'extensions.update.enabled': False, 'browser.safebrowsing.keyURL': 'http://127.0.0.1/safebrowsing-dummy/newkey', 'media.navigator.permission.disabled': True, 'app.update.enabled': False, 'extensions.blocklist.url': 'http://127.0.0.1/extensions-dummy/blocklistURL', 'browser.EULA.override': True, 'extensions.checkCompatibility': False, 'talos.logfile': 'pathtofile', 'browser.safebrowsing.gethashURL': 'http://127.0.0.1/safebrowsing-dummy/gethash', 'extensions.hotfix.url': 'http://127.0.0.1/extensions-dummy/hotfixURL', 'dom.disable_window_move_resize': True, 'network.proxy.http_port': 80, 'browser.dom.window.dump.enabled': True, 'extensions.update.url': 'http://127.0.0.1/extensions-dummy/updateURL', 'browser.chrome.dynamictoolbar': False, 'browser.link.open_newwindow': 2, 'extensions.getAddons.search.url': 'http://127.0.0.1/extensions-dummy/repositorySearchURL', 'browser.cache.disk.smart_size.first_run': False, 'security.turn_off_all_security_so_that_viruses_can_take_over_this_computer': True, 'dom.disable_open_during_load': False, 'extensions.getAddons.search.browseURL': 'http://127.0.0.1/extensions-dummy/repositoryBrowseURL', 'browser.cache.disk.smart_size.enabled': False, 'extensions.getAddons.getWithPerformance.url': 'http://127.0.0.1/extensions-dummy/repositoryGetWithPerformanceURL', 'hangmonitor.timeout': 0, 'extensions.getAddons.maxResults': 0, 'dom.send_after_paint_to_content': True, 'security.fileuri.strict_origin_policy': False, 'media.capturestream_hints.enabled': True, 'extensions.update.notifyUser': False, 'extensions.blocklist.enabled': False, 'browser.bookmarks.max_backups': 0, 'browser.shell.checkDefaultBrowser': False, 'media.peerconnection.enabled': True, 'dom.disable_window_flip': True, 'security.enable_java': False, 'browser.warnOnQuit': False, 'media.navigator.enabled': True, 'browser.safebrowsing.updateURL': 'http://127.0.0.1/safebrowsing-dummy/update', 'dom.allow_scripts_to_close_windows': True, 'extensions.webservice.discoverURL': 'http://127.0.0.1/extensions-dummy/discoveryURL'}, 'test_timeout': 1200, 'title': 'qm-pxp01', 'error_filename': 'pathtoerrorfile', 'webserver': 'localhost:15707', 'browser_path':ffox_path, 'port': 20701, 'browser_log': 'browser_output.txt', 'process': 'firefox.exe', 'xperf_path': 'C:/Program Files/Microsoft Windows Performance Toolkit/xperf.exe', 'extensions': ['pathtopageloader'], 'fennecIDs': '', 'env': {'NO_EM_RESTART': '1'}, 'init_url': 'http://localhost:15707/getInfo.html', 'browser_wait': 5} \ No newline at end of file +{'deviceroot': '', 'dirs': {}, 'repository': 'http://hg.mozilla.org/releases/mozilla-release', 'buildid': '20131205075310', 'results_log': 'pathtoresults_log', 'symbols_path': None, 'bcontroller_config': 'pathtobcontroller', 'host': '', 'browser_name': 'Firefox', 'sourcestamp': '39faf812aaec', 'remote': False, 'child_process': 'plugin-container', 'branch_name': '', 'browser_version': '26.0', 'extra_args': '', 'develop': True, 'preferences': {'browser.display.overlaynavbuttons': False, 'extensions.getAddons.get.url': 'http://127.0.0.1/extensions-dummy/repositoryGetURL', 'dom.max_chrome_script_run_time': 0, 'network.proxy.type': 1, 'extensions.update.background.url': 'http://127.0.0.1/extensions-dummy/updateBackgroundURL', 'network.proxy.http': 'localhost', 'plugins.update.url': 'http://127.0.0.1/plugins-dummy/updateCheckURL', 'dom.max_script_run_time': 0, 'extensions.update.enabled': False, 'browser.safebrowsing.keyURL': 'http://127.0.0.1/safebrowsing-dummy/newkey', 'media.navigator.permission.disabled': True, 'app.update.enabled': False, 'extensions.blocklist.url': 'http://127.0.0.1/extensions-dummy/blocklistURL', 'browser.EULA.override': True, 'extensions.checkCompatibility': False, 'talos.logfile': 'pathtofile', 'browser.safebrowsing.gethashURL': 'http://127.0.0.1/safebrowsing-dummy/gethash', 'dom.disable_window_move_resize': True, 'network.proxy.http_port': 80, 'browser.dom.window.dump.enabled': True, 'extensions.update.url': 'http://127.0.0.1/extensions-dummy/updateURL', 'browser.chrome.dynamictoolbar': False, 'browser.link.open_newwindow': 2, 'extensions.getAddons.search.url': 'http://127.0.0.1/extensions-dummy/repositorySearchURL', 'browser.cache.disk.smart_size.first_run': False, 'security.turn_off_all_security_so_that_viruses_can_take_over_this_computer': True, 'dom.disable_open_during_load': False, 'extensions.getAddons.search.browseURL': 'http://127.0.0.1/extensions-dummy/repositoryBrowseURL', 'browser.cache.disk.smart_size.enabled': False, 'extensions.getAddons.getWithPerformance.url': 'http://127.0.0.1/extensions-dummy/repositoryGetWithPerformanceURL', 'hangmonitor.timeout': 0, 'extensions.getAddons.maxResults': 0, 'dom.send_after_paint_to_content': True, 'security.fileuri.strict_origin_policy': False, 'media.capturestream_hints.enabled': True, 'extensions.update.notifyUser': False, 'extensions.blocklist.enabled': False, 'browser.bookmarks.max_backups': 0, 'browser.shell.checkDefaultBrowser': False, 'media.peerconnection.enabled': True, 'dom.disable_window_flip': True, 'security.enable_java': False, 'browser.warnOnQuit': False, 'media.navigator.enabled': True, 'browser.safebrowsing.updateURL': 'http://127.0.0.1/safebrowsing-dummy/update', 'dom.allow_scripts_to_close_windows': True, 'extensions.webservice.discoverURL': 'http://127.0.0.1/extensions-dummy/discoveryURL'}, 'test_timeout': 1200, 'title': 'qm-pxp01', 'error_filename': 'pathtoerrorfile', 'webserver': 'localhost:15707', 'browser_path':ffox_path, 'port': 20701, 'browser_log': 'browser_output.txt', 'process': 'firefox.exe', 'xperf_path': 'C:/Program Files/Microsoft Windows Performance Toolkit/xperf.exe', 'extensions': ['pathtopageloader'], 'fennecIDs': '', 'env': {'NO_EM_RESTART': '1'}, 'init_url': 'http://localhost:15707/getInfo.html', 'browser_wait': 5} -- cgit v1.2.3 From 24ad244d47034b36e433797914718baaffa5dada Mon Sep 17 00:00:00 2001 From: Gaming4JC Date: Fri, 5 Jul 2019 21:18:04 -0400 Subject: Issue #1160 - Remove HotFix Preferences from Telemetry --- toolkit/components/telemetry/TelemetryEnvironment.jsm | 2 -- toolkit/components/telemetry/docs/data/environment.rst | 1 - .../components/telemetry/tests/unit/test_TelemetryEnvironment.js | 8 +------- 3 files changed, 1 insertion(+), 10 deletions(-) diff --git a/toolkit/components/telemetry/TelemetryEnvironment.jsm b/toolkit/components/telemetry/TelemetryEnvironment.jsm index 295679ca4..391ea4bb4 100644 --- a/toolkit/components/telemetry/TelemetryEnvironment.jsm +++ b/toolkit/components/telemetry/TelemetryEnvironment.jsm @@ -196,7 +196,6 @@ const PREF_DISTRIBUTION_ID = "distribution.id"; const PREF_DISTRIBUTION_VERSION = "distribution.version"; const PREF_DISTRIBUTOR = "app.distributor"; const PREF_DISTRIBUTOR_CHANNEL = "app.distributor.channel"; -const PREF_HOTFIX_LASTVERSION = "extensions.hotfix.lastVersion"; const PREF_APP_PARTNER_BRANCH = "app.partner."; const PREF_PARTNER_ID = "mozilla.partner.id"; const PREF_UPDATE_ENABLED = "app.update.enabled"; @@ -1050,7 +1049,6 @@ EnvironmentCache.prototype = { vendor: Services.appinfo.vendor || null, platformVersion: Services.appinfo.platformVersion || null, xpcomAbi: Services.appinfo.XPCOMABI, - hotfixVersion: Preferences.get(PREF_HOTFIX_LASTVERSION, null), }; // Add |architecturesInBinary| only for Mac Universal builds. diff --git a/toolkit/components/telemetry/docs/data/environment.rst b/toolkit/components/telemetry/docs/data/environment.rst index ff0d204a4..0c259fa85 100644 --- a/toolkit/components/telemetry/docs/data/environment.rst +++ b/toolkit/components/telemetry/docs/data/environment.rst @@ -31,7 +31,6 @@ Structure: vendor: , // e.g. "Mozilla" platformVersion: , // e.g. "35.0" xpcomAbi: , // e.g. "x86-msvc" - hotfixVersion: , // e.g. "20141211.01" }, settings: { addonCompatibilityCheckEnabled: , // Whether application compatibility is respected for add-ons diff --git a/toolkit/components/telemetry/tests/unit/test_TelemetryEnvironment.js b/toolkit/components/telemetry/tests/unit/test_TelemetryEnvironment.js index 35181272a..2518a80ba 100644 --- a/toolkit/components/telemetry/tests/unit/test_TelemetryEnvironment.js +++ b/toolkit/components/telemetry/tests/unit/test_TelemetryEnvironment.js @@ -33,7 +33,6 @@ const PLATFORM_VERSION = "1.9.2"; const APP_VERSION = "1"; const APP_ID = "xpcshell@tests.mozilla.org"; const APP_NAME = "XPCShell"; -const APP_HOTFIX_VERSION = "2.3.4a"; const DISTRIBUTION_ID = "distributor-id"; const DISTRIBUTION_VERSION = "4.5.6b"; @@ -385,10 +384,8 @@ function checkBuildSection(data) { Assert.equal(data.build[f], expectedInfo[f], f + " must have the correct value."); } - // Make sure architecture and hotfixVersion are in the environment. + // Make sure architecture is in the environment. Assert.ok(checkString(data.build.architecture)); - Assert.ok(checkString(data.build.hotfixVersion)); - Assert.equal(data.build.hotfixVersion, APP_HOTFIX_VERSION); if (gIsMac) { let macUtils = Cc["@mozilla.org/xpcom/mac-utils;1"].getService(Ci.nsIMacUtils); @@ -830,9 +827,6 @@ add_task(function* setup() { gHttpServer.registerDirectory("/data/", do_get_cwd()); do_register_cleanup(() => gHttpServer.stop(() => {})); - // Spoof the the hotfixVersion - Preferences.set("extensions.hotfix.lastVersion", APP_HOTFIX_VERSION); - // Create the attribution data file, so that settings.attribution will exist. // The attribution functionality only exists in Firefox. if (AppConstants.MOZ_BUILD_APP == "browser") { -- cgit v1.2.3 From e0598b0ae2c748f1b38759d66e7a759aec04a6b9 Mon Sep 17 00:00:00 2001 From: win7-7 Date: Sun, 7 Jul 2019 20:02:35 +0300 Subject: Avoid multiple hashtable lookups in DisplayItemData destructor UXP has: MOZ_RELEASE_ASSERT(sAliveDisplayItemDatas && sAliveDisplayItemDatas >Contains(this)); sAliveDisplayItemDatas->RemoveEntry(this); and this gets hit during frame destruction. Combine these checks. --- layout/base/FrameLayerBuilder.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/layout/base/FrameLayerBuilder.cpp b/layout/base/FrameLayerBuilder.cpp index e87d9dc09..934d108e0 100644 --- a/layout/base/FrameLayerBuilder.cpp +++ b/layout/base/FrameLayerBuilder.cpp @@ -272,8 +272,13 @@ FrameLayerBuilder::DisplayItemData::~DisplayItemData() array->RemoveElement(this); } - MOZ_RELEASE_ASSERT(sAliveDisplayItemDatas && sAliveDisplayItemDatas->Contains(this)); - sAliveDisplayItemDatas->RemoveEntry(this); + MOZ_RELEASE_ASSERT(sAliveDisplayItemDatas); + nsPtrHashKey* entry + = sAliveDisplayItemDatas->GetEntry(this); + MOZ_RELEASE_ASSERT(entry); + + sAliveDisplayItemDatas->RemoveEntry(entry); + if (sAliveDisplayItemDatas->Count() == 0) { delete sAliveDisplayItemDatas; sAliveDisplayItemDatas = nullptr; -- cgit v1.2.3 From 20e3587ef5a97f190da7a4e674e988d7189c795c Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Mon, 8 Jul 2019 02:17:07 +0200 Subject: Avoid type confusion in ArrayJoinDenseKernel --- js/src/jsarray.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/src/jsarray.cpp b/js/src/jsarray.cpp index ec65bce64..ff581beec 100644 --- a/js/src/jsarray.cpp +++ b/js/src/jsarray.cpp @@ -1048,7 +1048,7 @@ struct StringSeparatorOp template static bool -ArrayJoinDenseKernel(JSContext* cx, SeparatorOp sepOp, HandleNativeObject obj, uint64_t length, +ArrayJoinDenseKernel(JSContext* cx, SeparatorOp sepOp, HandleNativeObject obj, uint32_t length, StringBuffer& sb, uint32_t* numProcessed) { // This loop handles all elements up to initializedLength. If -- cgit v1.2.3 From 570cad82795beeb1eb7011c09be295afa11373ce Mon Sep 17 00:00:00 2001 From: win7-7 Date: Mon, 8 Jul 2019 19:19:56 +0300 Subject: Iterate the frame property list once to collect which child list properties we have Look into optimizing out the hashtable lookups from nsContainerFrame --- layout/base/FrameProperties.h | 27 +++++++++++ layout/generic/nsContainerFrame.cpp | 89 ++++++++++++++++++++++--------------- 2 files changed, 80 insertions(+), 36 deletions(-) diff --git a/layout/base/FrameProperties.h b/layout/base/FrameProperties.h index bba3ee06b..71a79138a 100644 --- a/layout/base/FrameProperties.h +++ b/layout/base/FrameProperties.h @@ -160,6 +160,11 @@ public: MOZ_ASSERT(mProperties.Length() == 0, "forgot to delete properties"); } + /** + * Return true if we have no properties, otherwise return false. + */ + bool IsEmpty() const { return mProperties.IsEmpty(); } + /** * Set a property value. This requires a linear search through * the properties of the frame. Any existing value for the property @@ -241,6 +246,28 @@ public: { DeleteInternal(aProperty, aFrame); } + + /** + * Call @aFunction for each property or until @aFunction returns false. + */ + template + void ForEach(F aFunction) const + { +#ifdef DEBUG + size_t len = mProperties.Length(); +#endif + for (const auto& prop : mProperties) { + bool shouldContinue = aFunction(prop.mProperty, prop.mValue); +#ifdef DEBUG + MOZ_ASSERT(len == mProperties.Length(), + "frame property list was modified by ForEach callback!"); +#endif + if (!shouldContinue) { + return; + } + } + } + /** * Remove and destroy all property values for the frame. */ diff --git a/layout/generic/nsContainerFrame.cpp b/layout/generic/nsContainerFrame.cpp index 2933ac4cf..abf687c9b 100644 --- a/layout/generic/nsContainerFrame.cpp +++ b/layout/generic/nsContainerFrame.cpp @@ -219,24 +219,49 @@ nsContainerFrame::DestroyFrom(nsIFrame* aDestructRoot) // Destroy frames on the principal child list. mFrames.DestroyFramesFrom(aDestructRoot); + + if (MOZ_UNLIKELY(!mProperties.IsEmpty())) { + using T = mozilla::FrameProperties::UntypedDescriptor; + bool hasO = false, hasOC = false, hasEOC = false, hasBackdrop = false; + mProperties.ForEach([&] (const T& aProp, void*) { + if (aProp == OverflowProperty()) { + hasO = true; + } else if (aProp == OverflowContainersProperty()) { + hasOC = true; + } else if (aProp == ExcessOverflowContainersProperty()) { + hasEOC = true; + } else if (aProp == BackdropProperty()) { + hasBackdrop = true; + } + return true; + }); + // Destroy frames on the auxiliary frame lists and delete the lists. nsPresContext* pc = PresContext(); nsIPresShell* shell = pc->PresShell(); - SafelyDestroyFrameListProp(aDestructRoot, shell, OverflowProperty()); + if (hasO) { + SafelyDestroyFrameListProp(aDestructRoot, shell, OverflowProperty()); + } - MOZ_ASSERT(IsFrameOfType(nsIFrame::eCanContainOverflowContainers) || - !(GetProperty(nsContainerFrame::OverflowContainersProperty()) || - GetProperty(nsContainerFrame::ExcessOverflowContainersProperty())), - "this type of frame should't have overflow containers"); - SafelyDestroyFrameListProp(aDestructRoot, shell, - OverflowContainersProperty()); - SafelyDestroyFrameListProp(aDestructRoot, shell, - ExcessOverflowContainersProperty()); + MOZ_ASSERT(IsFrameOfType(eCanContainOverflowContainers) || + !(hasOC || hasEOC), + "this type of frame shouldn't have overflow containers"); + if (hasOC) { + SafelyDestroyFrameListProp(aDestructRoot, shell, + OverflowContainersProperty()); + } + if (hasEOC) { + SafelyDestroyFrameListProp(aDestructRoot, shell, + ExcessOverflowContainersProperty()); + } MOZ_ASSERT(!GetProperty(BackdropProperty()) || StyleDisplay()->mTopLayer != NS_STYLE_TOP_LAYER_NONE, "only top layer frame may have backdrop"); - SafelyDestroyFrameListProp(aDestructRoot, shell, BackdropProperty()); + if (hasBackdrop) { + SafelyDestroyFrameListProp(aDestructRoot, shell, BackdropProperty()); + } +} nsSplittableFrame::DestroyFrom(aDestructRoot); } @@ -274,36 +299,28 @@ nsContainerFrame::GetChildList(ChildListID aListID) const } } -static void -AppendIfNonempty(const nsIFrame* aFrame, - nsContainerFrame::FrameListPropertyDescriptor aProperty, - nsTArray* aLists, - nsIFrame::ChildListID aListID) -{ - if (nsFrameList* list = aFrame->GetProperty(aProperty)) { - list->AppendIfNonempty(aLists, aListID); - } -} - void nsContainerFrame::GetChildLists(nsTArray* aLists) const { mFrames.AppendIfNonempty(aLists, kPrincipalList); - ::AppendIfNonempty(this, OverflowProperty(), - aLists, kOverflowList); - if (IsFrameOfType(nsIFrame::eCanContainOverflowContainers)) { - ::AppendIfNonempty(this, OverflowContainersProperty(), - aLists, kOverflowContainersList); - ::AppendIfNonempty(this, ExcessOverflowContainersProperty(), - aLists, kExcessOverflowContainersList); - } - // Bypass BackdropProperty hashtable lookup for any in-flow frames - // since frames in the top layer (only which can have backdrop) are - // definitely out-of-flow. - if (GetStateBits() & NS_FRAME_OUT_OF_FLOW) { - ::AppendIfNonempty(this, BackdropProperty(), - aLists, kBackdropList); - } + using T = mozilla::FrameProperties::UntypedDescriptor; + mProperties.ForEach([this, aLists] (const T& aProp, void* aValue) { + typedef const nsFrameList* L; + if (aProp == OverflowProperty()) { + L(aValue)->AppendIfNonempty(aLists, kOverflowList); + } else if (aProp == OverflowContainersProperty()) { + MOZ_ASSERT(IsFrameOfType(nsIFrame::eCanContainOverflowContainers), + "found unexpected OverflowContainersProperty"); + L(aValue)->AppendIfNonempty(aLists, kOverflowContainersList); + } else if (aProp == ExcessOverflowContainersProperty()) { + MOZ_ASSERT(IsFrameOfType(nsIFrame::eCanContainOverflowContainers), + "found unexpected ExcessOverflowContainersProperty"); + L(aValue)->AppendIfNonempty(aLists, kExcessOverflowContainersList); + } else if (aProp == BackdropProperty()) { + L(aValue)->AppendIfNonempty(aLists, kBackdropList); + } + return true; + }); nsSplittableFrame::GetChildLists(aLists); } -- cgit v1.2.3 From f7f7224dedd63809fbf5532b7ac843cea22d9499 Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Mon, 8 Jul 2019 21:46:44 +0200 Subject: Remove e10s info from about:support tag #953 --- toolkit/content/aboutSupport.js | 22 ---------------------- toolkit/content/aboutSupport.xhtml | 9 --------- .../locales/en-US/chrome/global/aboutSupport.dtd | 2 -- .../en-US/chrome/global/aboutSupport.properties | 17 ----------------- toolkit/modules/Troubleshoot.jsm | 12 ------------ .../modules/tests/browser/browser_Troubleshoot.js | 7 ------- 6 files changed, 69 deletions(-) diff --git a/toolkit/content/aboutSupport.js b/toolkit/content/aboutSupport.js index 8908a0f80..06470f966 100644 --- a/toolkit/content/aboutSupport.js +++ b/toolkit/content/aboutSupport.js @@ -53,28 +53,6 @@ var snapshotFormatters = { if (data.updateChannel) $("updatechannel-box").textContent = data.updateChannel; - let statusText = stringBundle().GetStringFromName("multiProcessStatus.unknown"); - - // Whitelist of known values with string descriptions: - switch (data.autoStartStatus) { - case 0: - case 1: - case 2: - case 4: - case 6: - case 7: - case 8: - statusText = stringBundle().GetStringFromName("multiProcessStatus." + data.autoStartStatus); - break; - - case 10: - statusText = (Services.appinfo.OS == "Darwin" ? "OS X 10.6 - 10.8" : "Windows XP"); - break; - } - - $("multiprocess-box").textContent = stringBundle().formatStringFromName("multiProcessWindows", - [data.numRemoteWindows, data.numTotalWindows, statusText], 3); - $("safemode-box").textContent = data.safeMode; }, diff --git a/toolkit/content/aboutSupport.xhtml b/toolkit/content/aboutSupport.xhtml index 5e6319182..fff86dff6 100644 --- a/toolkit/content/aboutSupport.xhtml +++ b/toolkit/content/aboutSupport.xhtml @@ -234,15 +234,6 @@ - - - &aboutSupport.appBasicsMultiProcessSupport; - - - - - - &aboutSupport.appBasicsSafeMode; diff --git a/toolkit/locales/en-US/chrome/global/aboutSupport.dtd b/toolkit/locales/en-US/chrome/global/aboutSupport.dtd index a2477fb2e..34db4e4c4 100644 --- a/toolkit/locales/en-US/chrome/global/aboutSupport.dtd +++ b/toolkit/locales/en-US/chrome/global/aboutSupport.dtd @@ -64,8 +64,6 @@ Windows/Mac use the term "Folder" instead of "Directory" --> - - diff --git a/toolkit/locales/en-US/chrome/global/aboutSupport.properties b/toolkit/locales/en-US/chrome/global/aboutSupport.properties index 564292e3d..be9ce5f33 100644 --- a/toolkit/locales/en-US/chrome/global/aboutSupport.properties +++ b/toolkit/locales/en-US/chrome/global/aboutSupport.properties @@ -99,23 +99,6 @@ gpuProcessKillButton = Terminate GPU Process minLibVersions = Expected minimum version loadedLibVersions = Version in use -# LOCALIZATION NOTE %1$S and %2$S will be replaced with the number of remote and the total number -# of windows, respectively, while %3$S will be replaced with one of the status strings below, -# which contains a description of the multi-process preference and status. -# Note: multiProcessStatus.3 doesn't exist because status=3 was deprecated. -multiProcessWindows = %1$S/%2$S (%3$S) -multiProcessStatus.0 = Enabled by user -multiProcessStatus.1 = Enabled by default -multiProcessStatus.2 = Disabled -multiProcessStatus.4 = Disabled by accessibility tools -multiProcessStatus.5 = Disabled by lack of graphics hardware acceleration on Mac OS X -multiProcessStatus.6 = Disabled by unsupported text input -multiProcessStatus.7 = Disabled by add-ons -multiProcessStatus.8 = Disabled forcibly -# No longer in use (bug 1296353) but we might bring this back. -multiProcessStatus.9 = Disabled by graphics hardware acceleration on Windows XP -multiProcessStatus.unknown = Unknown status - asyncPanZoom = Asynchronous Pan/Zoom apzNone = none wheelEnabled = wheel input enabled diff --git a/toolkit/modules/Troubleshoot.jsm b/toolkit/modules/Troubleshoot.jsm index 8d84eec8c..6ee6cb54e 100644 --- a/toolkit/modules/Troubleshoot.jsm +++ b/toolkit/modules/Troubleshoot.jsm @@ -220,18 +220,6 @@ var dataProviders = { } } - data.remoteAutoStart = Services.appinfo.browserTabsRemoteAutostart; - - try { - let e10sStatus = Cc["@mozilla.org/supports-PRUint64;1"] - .createInstance(Ci.nsISupportsPRUint64); - let appinfo = Services.appinfo.QueryInterface(Ci.nsIObserver); - appinfo.observe(e10sStatus, "getE10SBlocked", ""); - data.autoStartStatus = e10sStatus.data; - } catch (e) { - data.autoStartStatus = -1; - } - done(data); }, diff --git a/toolkit/modules/tests/browser/browser_Troubleshoot.js b/toolkit/modules/tests/browser/browser_Troubleshoot.js index 4124be1fb..ebc4de1f9 100644 --- a/toolkit/modules/tests/browser/browser_Troubleshoot.js +++ b/toolkit/modules/tests/browser/browser_Troubleshoot.js @@ -126,13 +126,6 @@ const SNAPSHOT_SCHEMA = { supportURL: { type: "string", }, - remoteAutoStart: { - type: "boolean", - required: true, - }, - autoStartStatus: { - type: "number", - }, numTotalWindows: { type: "number", }, -- cgit v1.2.3 From 18f9b185b67120ba88f5e643b7413ca06c497383 Mon Sep 17 00:00:00 2001 From: Jeroen Vreeken Date: Wed, 10 Jul 2019 11:05:38 +0200 Subject: Allow matroska mime types for video element and MSE Allow avc (h.264) content in matroska/webm containers --- dom/media/fmp4/MP4Decoder.cpp | 3 ++- dom/media/mediasource/ContainerParser.cpp | 3 +++ dom/media/mediasource/MediaSource.cpp | 3 ++- dom/media/mediasource/TrackBuffersManager.cpp | 1 + dom/media/webm/WebMDecoder.cpp | 7 ++++++- dom/media/webm/WebMDemuxer.cpp | 24 +++++++++++++++++++++++- media/libnestegg/include/nestegg.h | 1 + media/libnestegg/src/nestegg.c | 7 ++++++- 8 files changed, 44 insertions(+), 5 deletions(-) diff --git a/dom/media/fmp4/MP4Decoder.cpp b/dom/media/fmp4/MP4Decoder.cpp index 6954e9757..b293c251b 100644 --- a/dom/media/fmp4/MP4Decoder.cpp +++ b/dom/media/fmp4/MP4Decoder.cpp @@ -172,7 +172,8 @@ bool MP4Decoder::IsH264(const nsACString& aMimeType) { return aMimeType.EqualsLiteral("video/mp4") || - aMimeType.EqualsLiteral("video/avc"); + aMimeType.EqualsLiteral("video/avc") || + aMimeType.EqualsLiteral("video/webm; codecs=avc1"); } /* static */ diff --git a/dom/media/mediasource/ContainerParser.cpp b/dom/media/mediasource/ContainerParser.cpp index 4ae37d7e9..46f2e9557 100644 --- a/dom/media/mediasource/ContainerParser.cpp +++ b/dom/media/mediasource/ContainerParser.cpp @@ -697,6 +697,9 @@ ContainerParser::CreateForMIMEType(const nsACString& aType) if (aType.LowerCaseEqualsLiteral("video/webm") || aType.LowerCaseEqualsLiteral("audio/webm")) { return new WebMContainerParser(aType); } + if (aType.LowerCaseEqualsLiteral("video/x-matroska")) { + return new WebMContainerParser(aType); + } #ifdef MOZ_FMP4 if (aType.LowerCaseEqualsLiteral("video/mp4") || aType.LowerCaseEqualsLiteral("audio/mp4")) { diff --git a/dom/media/mediasource/MediaSource.cpp b/dom/media/mediasource/MediaSource.cpp index 152c0085a..a262ff52c 100644 --- a/dom/media/mediasource/MediaSource.cpp +++ b/dom/media/mediasource/MediaSource.cpp @@ -110,7 +110,8 @@ MediaSource::IsTypeSupported(const nsAString& aType, DecoderDoctorDiagnostics* a } return NS_OK; } - if (mimeType.EqualsASCII("video/webm")) { + if (mimeType.EqualsASCII("video/webm") || + mimeType.EqualsASCII("video/x-matroska")) { if (!(Preferences::GetBool("media.mediasource.webm.enabled", false) || IsWebMForced(aDiagnostics))) { return NS_ERROR_DOM_NOT_SUPPORTED_ERR; diff --git a/dom/media/mediasource/TrackBuffersManager.cpp b/dom/media/mediasource/TrackBuffersManager.cpp index ac6d82411..3a6f2a5c8 100644 --- a/dom/media/mediasource/TrackBuffersManager.cpp +++ b/dom/media/mediasource/TrackBuffersManager.cpp @@ -814,6 +814,7 @@ TrackBuffersManager::CreateDemuxerforMIMEType() ShutdownDemuxers(); if (mType.LowerCaseEqualsLiteral("video/webm") || + mType.LowerCaseEqualsLiteral("video/x-matroska") || mType.LowerCaseEqualsLiteral("audio/webm")) { mInputDemuxer = new WebMDemuxer(mCurrentInputBuffer, true /* IsMediaSource*/ ); return; diff --git a/dom/media/webm/WebMDecoder.cpp b/dom/media/webm/WebMDecoder.cpp index 9575d6e42..37e1e4a33 100644 --- a/dom/media/webm/WebMDecoder.cpp +++ b/dom/media/webm/WebMDecoder.cpp @@ -41,7 +41,7 @@ WebMDecoder::CanHandleMediaType(const nsACString& aMIMETypeExcludingCodecs, } const bool isWebMAudio = aMIMETypeExcludingCodecs.EqualsASCII("audio/webm"); - const bool isWebMVideo = aMIMETypeExcludingCodecs.EqualsASCII("video/webm"); + const bool isWebMVideo = aMIMETypeExcludingCodecs.EqualsASCII("video/webm") || aMIMETypeExcludingCodecs.EqualsASCII("video/x-matroska") ; if (!isWebMAudio && !isWebMVideo) { return false; } @@ -74,6 +74,11 @@ WebMDecoder::CanHandleMediaType(const nsACString& aMIMETypeExcludingCodecs, continue; } #endif + + if (IsH264CodecString(codec)) { + continue; + } + // Some unsupported codec. return false; } diff --git a/dom/media/webm/WebMDemuxer.cpp b/dom/media/webm/WebMDemuxer.cpp index 013da9b2c..2b6d46186 100644 --- a/dom/media/webm/WebMDemuxer.cpp +++ b/dom/media/webm/WebMDemuxer.cpp @@ -326,6 +326,20 @@ WebMDemuxer::ReadMetadata() case NESTEGG_CODEC_AV1: mInfo.mVideo.mMimeType = "video/webm; codecs=av1"; break; + case NESTEGG_CODEC_AVC1: { + mInfo.mVideo.mMimeType = "video/webm; codecs=avc1"; + + unsigned char* data = 0; + size_t length = 0; + r = nestegg_track_codec_data(context, track, 0, &data, &length); + if (r == -1) { + return NS_ERROR_FAILURE; + } + + mInfo.mVideo.mExtraData = new MediaByteBuffer(length); + mInfo.mVideo.mExtraData->AppendElements(data, length); + break; + } default: NS_WARNING("Unknown WebM video codec"); return NS_ERROR_FAILURE; @@ -662,6 +676,9 @@ WebMDemuxer::GetNextPacket(TrackInfo::TrackType aType, MediaRawDataQueue *aSampl isKeyframe = AOMDecoder::IsKeyframe(sample); break; #endif + case NESTEGG_CODEC_AVC1: + isKeyframe = nestegg_packet_has_keyframe(holder->Packet()); + break; default: NS_WARNING("Cannot detect keyframes in unknown WebM video codec"); return NS_ERROR_FAILURE; @@ -682,7 +699,7 @@ WebMDemuxer::GetNextPacket(TrackInfo::TrackType aType, MediaRawDataQueue *aSampl dimensions = AOMDecoder::GetFrameSize(sample); break; #endif - } + } if (mLastSeenFrameSize.isSome() && (dimensions != mLastSeenFrameSize.value())) { mInfo.mVideo.mDisplay = dimensions; @@ -749,6 +766,11 @@ WebMDemuxer::GetNextPacket(TrackInfo::TrackType aType, MediaRawDataQueue *aSampl if (aType == TrackInfo::kVideoTrack) { sample->mTrackInfo = mSharedVideoTrackInfo; } + + if (mVideoCodec == NESTEGG_CODEC_AVC1) { + sample->mExtraData = mInfo.mVideo.mExtraData; + } + aSamples->Push(sample); } return NS_OK; diff --git a/media/libnestegg/include/nestegg.h b/media/libnestegg/include/nestegg.h index 2baa50bc5..777555f7b 100644 --- a/media/libnestegg/include/nestegg.h +++ b/media/libnestegg/include/nestegg.h @@ -72,6 +72,7 @@ extern "C" { #define NESTEGG_CODEC_VP9 2 /**< Track uses Google On2 VP9 codec. */ #define NESTEGG_CODEC_OPUS 3 /**< Track uses Xiph Opus codec. */ #define NESTEGG_CODEC_AV1 4 /**< Track uses AOMedia AV1 codec. */ +#define NESTEGG_CODEC_AVC1 5 /**< Track uses AVC1 'h264' */ #define NESTEGG_CODEC_UNKNOWN INT_MAX /**< Track uses unknown codec. */ #define NESTEGG_VIDEO_MONO 0 /**< Track is mono video. */ diff --git a/media/libnestegg/src/nestegg.c b/media/libnestegg/src/nestegg.c index 61c30ec6b..6f0d55b46 100644 --- a/media/libnestegg/src/nestegg.c +++ b/media/libnestegg/src/nestegg.c @@ -157,6 +157,7 @@ enum ebml_type_enum { #define TRACK_ID_AV1 "V_AV1" #define TRACK_ID_VORBIS "A_VORBIS" #define TRACK_ID_OPUS "A_OPUS" +#define TRACK_ID_AVC1 "V_MPEG4/ISO/AVC" /* Track Encryption */ #define CONTENT_ENC_ALGO_AES 5 @@ -2401,6 +2402,9 @@ nestegg_track_codec_id(nestegg * ctx, unsigned int track) if (strcmp(codec_id, TRACK_ID_OPUS) == 0) return NESTEGG_CODEC_OPUS; + if (strcmp(codec_id, TRACK_ID_AVC1) == 0) + return NESTEGG_CODEC_AVC1; + return NESTEGG_CODEC_UNKNOWN; } @@ -2459,7 +2463,8 @@ nestegg_track_codec_data(nestegg * ctx, unsigned int track, unsigned int item, return -1; if (nestegg_track_codec_id(ctx, track) != NESTEGG_CODEC_VORBIS && - nestegg_track_codec_id(ctx, track) != NESTEGG_CODEC_OPUS) + nestegg_track_codec_id(ctx, track) != NESTEGG_CODEC_OPUS && + nestegg_track_codec_id(ctx, track) != NESTEGG_CODEC_AVC1) return -1; if (ne_get_binary(entry->codec_private, &codec_private) != 0) -- cgit v1.2.3 From 31addeaac8841867008699478ef55e1c1b3d68a7 Mon Sep 17 00:00:00 2001 From: Jeroen Vreeken Date: Thu, 11 Jul 2019 16:36:22 +0200 Subject: Make matroska mime type checking more consistent. --- dom/media/mediasource/ContainerParser.cpp | 2 +- dom/media/mediasource/MediaSource.cpp | 3 ++- dom/media/mediasource/TrackBuffersManager.cpp | 1 + dom/media/webm/WebMDecoder.cpp | 9 ++++++--- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/dom/media/mediasource/ContainerParser.cpp b/dom/media/mediasource/ContainerParser.cpp index 46f2e9557..b4dcfde8a 100644 --- a/dom/media/mediasource/ContainerParser.cpp +++ b/dom/media/mediasource/ContainerParser.cpp @@ -697,7 +697,7 @@ ContainerParser::CreateForMIMEType(const nsACString& aType) if (aType.LowerCaseEqualsLiteral("video/webm") || aType.LowerCaseEqualsLiteral("audio/webm")) { return new WebMContainerParser(aType); } - if (aType.LowerCaseEqualsLiteral("video/x-matroska")) { + if (aType.LowerCaseEqualsLiteral("video/x-matroska") || aType.LowerCaseEqualsLiteral("audio/x-matroska")) { return new WebMContainerParser(aType); } diff --git a/dom/media/mediasource/MediaSource.cpp b/dom/media/mediasource/MediaSource.cpp index a262ff52c..1c276cdc1 100644 --- a/dom/media/mediasource/MediaSource.cpp +++ b/dom/media/mediasource/MediaSource.cpp @@ -118,7 +118,8 @@ MediaSource::IsTypeSupported(const nsAString& aType, DecoderDoctorDiagnostics* a } return NS_OK; } - if (mimeType.EqualsASCII("audio/webm")) { + if (mimeType.EqualsASCII("audio/webm") || + mimeType.EqualsASCII("audio/x-matroska")) { if (!(Preferences::GetBool("media.mediasource.webm.enabled", false) || Preferences::GetBool("media.mediasource.webm.audio.enabled", true))) { return NS_ERROR_DOM_NOT_SUPPORTED_ERR; diff --git a/dom/media/mediasource/TrackBuffersManager.cpp b/dom/media/mediasource/TrackBuffersManager.cpp index 3a6f2a5c8..21fb158b5 100644 --- a/dom/media/mediasource/TrackBuffersManager.cpp +++ b/dom/media/mediasource/TrackBuffersManager.cpp @@ -815,6 +815,7 @@ TrackBuffersManager::CreateDemuxerforMIMEType() if (mType.LowerCaseEqualsLiteral("video/webm") || mType.LowerCaseEqualsLiteral("video/x-matroska") || + mType.LowerCaseEqualsLiteral("audio/x-matroska") || mType.LowerCaseEqualsLiteral("audio/webm")) { mInputDemuxer = new WebMDemuxer(mCurrentInputBuffer, true /* IsMediaSource*/ ); return; diff --git a/dom/media/webm/WebMDecoder.cpp b/dom/media/webm/WebMDecoder.cpp index 37e1e4a33..5cb943742 100644 --- a/dom/media/webm/WebMDecoder.cpp +++ b/dom/media/webm/WebMDecoder.cpp @@ -41,8 +41,11 @@ WebMDecoder::CanHandleMediaType(const nsACString& aMIMETypeExcludingCodecs, } const bool isWebMAudio = aMIMETypeExcludingCodecs.EqualsASCII("audio/webm"); - const bool isWebMVideo = aMIMETypeExcludingCodecs.EqualsASCII("video/webm") || aMIMETypeExcludingCodecs.EqualsASCII("video/x-matroska") ; - if (!isWebMAudio && !isWebMVideo) { + const bool isWebMVideo = aMIMETypeExcludingCodecs.EqualsASCII("video/webm"); + const bool isMatroskaAudio = aMIMETypeExcludingCodecs.EqualsASCII("audio/x-matroska") ; + const bool isMatroskaVideo = aMIMETypeExcludingCodecs.EqualsASCII("video/x-matroska") ; + + if (!isWebMAudio && !isWebMVideo && !isMatroskaAudio && !isMatroskaVideo) { return false; } @@ -63,7 +66,7 @@ WebMDecoder::CanHandleMediaType(const nsACString& aMIMETypeExcludingCodecs, } // Note: Only accept VP8/VP9 in a video content type, not in an audio // content type. - if (isWebMVideo && + if ((isWebMVideo || isMatroskaVideo) && (codec.EqualsLiteral("vp8") || codec.EqualsLiteral("vp8.0") || codec.EqualsLiteral("vp9") || codec.EqualsLiteral("vp9.0"))) { -- cgit v1.2.3 From a059b0688b82ca1fc51eae621916eb6dd008d873 Mon Sep 17 00:00:00 2001 From: win7-7 Date: Fri, 12 Jul 2019 00:30:22 +0300 Subject: Fix comments for Frameproperties https://bugzilla.mozilla.org/show_bug.cgi?id=1373884 Fixes comments for Frameproperties. These comments went unnoticed earlier. No code changes. --- layout/base/FrameProperties.h | 2 +- layout/generic/nsIFrame.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/layout/base/FrameProperties.h b/layout/base/FrameProperties.h index 71a79138a..74513abac 100644 --- a/layout/base/FrameProperties.h +++ b/layout/base/FrameProperties.h @@ -62,7 +62,7 @@ protected: * * To use this class, declare a global (i.e., file, class or function-scope * static member) FramePropertyDescriptor and pass its address as - * aProperty in the FramePropertyTable methods. + * aProperty in the FrameProperties methods. */ template struct FramePropertyDescriptor : public FramePropertyDescriptorUntyped diff --git a/layout/generic/nsIFrame.h b/layout/generic/nsIFrame.h index 37a4e3749..ec3568483 100644 --- a/layout/generic/nsIFrame.h +++ b/layout/generic/nsIFrame.h @@ -997,7 +997,7 @@ public: #define NS_DECLARE_FRAME_PROPERTY_WITH_DTOR_NEVER_CALLED(prop, type) \ static void AssertOnDestroyingProperty##prop(type*) { \ MOZ_ASSERT_UNREACHABLE("Frame property " #prop " should never " \ - "be destroyed by the FramePropertyTable"); \ + "be destroyed by the FrameProperties class"); \ } \ NS_DECLARE_FRAME_PROPERTY_WITH_DTOR(prop, type, \ AssertOnDestroyingProperty##prop) -- cgit v1.2.3 From fdd8d6347e611ef2e045d098f8cc8840deb00355 Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Fri, 12 Jul 2019 16:37:23 +0200 Subject: Stop building /caps unified and fix deprot. Tag #80 --- caps/moz.build | 5 ----- caps/nsJSPrincipals.cpp | 2 ++ caps/nsNullPrincipal.cpp | 2 ++ caps/nsNullPrincipalURI.cpp | 6 ++++++ caps/nsPrincipal.cpp | 2 ++ caps/nsScriptSecurityManager.cpp | 2 ++ 6 files changed, 14 insertions(+), 5 deletions(-) diff --git a/caps/moz.build b/caps/moz.build index 58b45e360..dc47ecbba 100644 --- a/caps/moz.build +++ b/caps/moz.build @@ -34,12 +34,7 @@ EXPORTS.mozilla = [ ] SOURCES += [ - # Compile this separately since nsExceptionHandler.h conflicts - # with something from nsNullPrincipal.cpp. 'BasePrincipal.cpp', -] - -UNIFIED_SOURCES += [ 'DomainPolicy.cpp', 'nsJSPrincipals.cpp', 'nsNullPrincipal.cpp', diff --git a/caps/nsJSPrincipals.cpp b/caps/nsJSPrincipals.cpp index 0f3afa14e..8349aed53 100644 --- a/caps/nsJSPrincipals.cpp +++ b/caps/nsJSPrincipals.cpp @@ -15,6 +15,7 @@ #include "nsMemory.h" #include "nsStringBuffer.h" +#include "mozilla/ipc/PBackgroundSharedTypes.h" #include "mozilla/dom/StructuredCloneTags.h" // for mozilla::dom::workers::kJSPrincipalsDebugToken #include "mozilla/dom/workers/Workers.h" @@ -22,6 +23,7 @@ using namespace mozilla; using namespace mozilla::ipc; +using namespace mozilla::dom; NS_IMETHODIMP_(MozExternalRefCountType) nsJSPrincipals::AddRef() diff --git a/caps/nsNullPrincipal.cpp b/caps/nsNullPrincipal.cpp index 6ebf0f129..386344e37 100644 --- a/caps/nsNullPrincipal.cpp +++ b/caps/nsNullPrincipal.cpp @@ -20,6 +20,8 @@ #include "nsIClassInfoImpl.h" #include "nsNetCID.h" #include "nsError.h" +#include "nsIObjectInputStream.h" +#include "nsIObjectOutputStream.h" #include "nsIScriptSecurityManager.h" #include "nsPrincipal.h" #include "nsScriptSecurityManager.h" diff --git a/caps/nsNullPrincipalURI.cpp b/caps/nsNullPrincipalURI.cpp index f8b867160..159928ba6 100644 --- a/caps/nsNullPrincipalURI.cpp +++ b/caps/nsNullPrincipalURI.cpp @@ -6,8 +6,12 @@ #include "nsNullPrincipalURI.h" +#include "mozilla/ArrayUtils.h" + #include "mozilla/DebugOnly.h" #include "mozilla/MemoryReporting.h" +#include "mozilla/Services.h" +#include "mozilla/Unused.h" #include "mozilla/ipc/URIParams.h" @@ -15,6 +19,8 @@ #include "nsCRT.h" #include "nsIUUIDGenerator.h" +using namespace mozilla; + //////////////////////////////////////////////////////////////////////////////// //// nsNullPrincipalURI diff --git a/caps/nsPrincipal.cpp b/caps/nsPrincipal.cpp index 129cdf9a0..d111042c1 100644 --- a/caps/nsPrincipal.cpp +++ b/caps/nsPrincipal.cpp @@ -19,6 +19,8 @@ #include "nsJSPrincipals.h" #include "nsIEffectiveTLDService.h" #include "nsIClassInfoImpl.h" +#include "nsIObjectInputStream.h" +#include "nsIObjectOutputStream.h" #include "nsIProtocolHandler.h" #include "nsError.h" #include "nsIContentSecurityPolicy.h" diff --git a/caps/nsScriptSecurityManager.cpp b/caps/nsScriptSecurityManager.cpp index 129a4d0da..bf5f33599 100644 --- a/caps/nsScriptSecurityManager.cpp +++ b/caps/nsScriptSecurityManager.cpp @@ -59,6 +59,7 @@ #include "mozIApplication.h" #include "mozilla/Preferences.h" #include "mozilla/dom/BindingUtils.h" +#include "mozilla/dom/ContentParent.h" #include #include "mozilla/dom/ScriptSettings.h" #include "mozilla/ClearOnShutdown.h" @@ -70,6 +71,7 @@ using namespace mozilla; using namespace mozilla::dom; +using namespace mozilla::ipc; nsIIOService *nsScriptSecurityManager::sIOService = nullptr; nsIStringBundle *nsScriptSecurityManager::sStrBundle = nullptr; -- cgit v1.2.3 From dd5d075b1a2651ea020a34e9c54e1959fc9bf29b Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Fri, 12 Jul 2019 23:30:59 +0200 Subject: Stop building /chrome unified and fix deprot. Tag #80 --- chrome/moz.build | 2 +- chrome/nsChromeRegistry.cpp | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/chrome/moz.build b/chrome/moz.build index b75e9435d..15439356a 100644 --- a/chrome/moz.build +++ b/chrome/moz.build @@ -17,7 +17,7 @@ EXPORTS.mozilla.chrome += [ 'RegistryMessageUtils.h', ] -UNIFIED_SOURCES += [ +SOURCES += [ 'nsChromeProtocolHandler.cpp', 'nsChromeRegistry.cpp', 'nsChromeRegistryChrome.cpp', diff --git a/chrome/nsChromeRegistry.cpp b/chrome/nsChromeRegistry.cpp index 485ca002c..4bd8b4dca 100644 --- a/chrome/nsChromeRegistry.cpp +++ b/chrome/nsChromeRegistry.cpp @@ -14,6 +14,7 @@ #include "nsError.h" #include "nsEscape.h" #include "nsNetUtil.h" +#include "nsIURL.h" #include "nsString.h" #include "nsQueryObject.h" -- cgit v1.2.3 From 197f4cbaa47e5e8b9b1fb578b10046914eb6486e Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Sat, 13 Jul 2019 02:41:46 +0200 Subject: Remove WebIDE devtools component. This resolves #1123 --- .../components/customizableui/CustomizableUI.jsm | 5 - devtools/client/framework/devtools-browser.js | 17 - devtools/client/framework/gDevTools.jsm | 11 - devtools/client/locales/en-US/menus.properties | 5 - devtools/client/locales/en-US/webide.dtd | 222 ---- devtools/client/locales/en-US/webide.properties | 92 -- devtools/client/menus.js | 11 - devtools/client/moz.build | 1 - devtools/client/preferences/devtools.js | 3 - .../lib/plugins/app-manager/app-project-editor.js | 56 - .../lib/plugins/app-manager/moz.build | 10 - .../lib/plugins/app-manager/plugin.js | 77 -- .../client/projecteditor/lib/plugins/moz.build | 1 - devtools/client/projecteditor/lib/projecteditor.js | 1 - devtools/client/shared/telemetry.js | 17 - devtools/client/webide/components/moz.build | 10 - devtools/client/webide/components/webideCli.js | 58 - .../webide/components/webideComponents.manifest | 4 - devtools/client/webide/content/addons.js | 135 --- devtools/client/webide/content/addons.xhtml | 31 - devtools/client/webide/content/details.js | 139 --- devtools/client/webide/content/details.xhtml | 54 - .../client/webide/content/devicepreferences.js | 81 -- .../client/webide/content/devicepreferences.xhtml | 49 - devtools/client/webide/content/devicesettings.js | 81 -- .../client/webide/content/devicesettings.xhtml | 50 - devtools/client/webide/content/jar.mn | 38 - devtools/client/webide/content/logs.js | 70 -- devtools/client/webide/content/logs.xhtml | 33 - devtools/client/webide/content/monitor.js | 741 ------------- devtools/client/webide/content/monitor.xhtml | 31 - devtools/client/webide/content/moz.build | 7 - devtools/client/webide/content/newapp.js | 175 --- devtools/client/webide/content/newapp.xul | 33 - devtools/client/webide/content/permissionstable.js | 78 -- .../client/webide/content/permissionstable.xhtml | 36 - devtools/client/webide/content/prefs.js | 108 -- devtools/client/webide/content/prefs.xhtml | 112 -- devtools/client/webide/content/project-listing.js | 42 - .../client/webide/content/project-listing.xhtml | 35 - devtools/client/webide/content/project-panel.js | 11 - devtools/client/webide/content/runtime-listing.js | 66 -- .../client/webide/content/runtime-listing.xhtml | 45 - devtools/client/webide/content/runtime-panel.js | 11 - devtools/client/webide/content/runtimedetails.js | 153 --- .../client/webide/content/runtimedetails.xhtml | 46 - devtools/client/webide/content/simulator.js | 352 ------ devtools/client/webide/content/simulator.xhtml | 99 -- devtools/client/webide/content/webide.js | 1157 -------------------- devtools/client/webide/content/webide.xul | 178 --- devtools/client/webide/content/wifi-auth.js | 44 - devtools/client/webide/content/wifi-auth.xhtml | 45 - devtools/client/webide/modules/addons.js | 197 ---- devtools/client/webide/modules/app-manager.js | 850 -------------- devtools/client/webide/modules/app-projects.js | 235 ---- devtools/client/webide/modules/app-validator.js | 292 ----- devtools/client/webide/modules/build.js | 199 ---- devtools/client/webide/modules/config-view.js | 373 ------- devtools/client/webide/modules/moz.build | 21 - devtools/client/webide/modules/project-list.js | 375 ------- devtools/client/webide/modules/runtime-list.js | 207 ---- devtools/client/webide/modules/runtimes.js | 673 ------------ .../client/webide/modules/simulator-process.js | 325 ------ devtools/client/webide/modules/simulators.js | 368 ------- devtools/client/webide/modules/tab-store.js | 178 --- devtools/client/webide/modules/utils.js | 68 -- devtools/client/webide/moz.build | 23 - devtools/client/webide/test/.eslintrc.js | 6 - .../client/webide/test/addons/adbhelper-linux.xpi | Bin 1293 -> 0 bytes .../webide/test/addons/adbhelper-linux64.xpi | Bin 1293 -> 0 bytes .../client/webide/test/addons/adbhelper-mac64.xpi | Bin 1293 -> 0 bytes .../client/webide/test/addons/adbhelper-win32.xpi | Bin 1293 -> 0 bytes .../webide/test/addons/fxdt-adapters-linux32.xpi | Bin 1156 -> 0 bytes .../webide/test/addons/fxdt-adapters-linux64.xpi | Bin 1156 -> 0 bytes .../webide/test/addons/fxdt-adapters-mac64.xpi | Bin 1156 -> 0 bytes .../webide/test/addons/fxdt-adapters-win32.xpi | Bin 1156 -> 0 bytes .../test/addons/fxos_1_0_simulator-linux.xpi | Bin 5046 -> 0 bytes .../test/addons/fxos_1_0_simulator-linux64.xpi | Bin 5046 -> 0 bytes .../test/addons/fxos_1_0_simulator-mac64.xpi | Bin 5044 -> 0 bytes .../test/addons/fxos_1_0_simulator-win32.xpi | Bin 5046 -> 0 bytes .../test/addons/fxos_2_0_simulator-linux.xpi | Bin 5046 -> 0 bytes .../test/addons/fxos_2_0_simulator-linux64.xpi | Bin 5046 -> 0 bytes .../test/addons/fxos_2_0_simulator-mac64.xpi | Bin 5043 -> 0 bytes .../test/addons/fxos_2_0_simulator-win32.xpi | Bin 5045 -> 0 bytes .../test/addons/fxos_3_0_simulator-linux.xpi | Bin 5045 -> 0 bytes .../test/addons/fxos_3_0_simulator-linux64.xpi | Bin 5048 -> 0 bytes .../test/addons/fxos_3_0_simulator-mac64.xpi | Bin 5048 -> 0 bytes .../test/addons/fxos_3_0_simulator-win32.xpi | Bin 5044 -> 0 bytes .../test/addons/fxos_3_0_tv_simulator-linux.xpi | Bin 5052 -> 0 bytes .../test/addons/fxos_3_0_tv_simulator-linux64.xpi | Bin 5055 -> 0 bytes .../test/addons/fxos_3_0_tv_simulator-mac64.xpi | Bin 5051 -> 0 bytes .../test/addons/fxos_3_0_tv_simulator-win32.xpi | Bin 5051 -> 0 bytes devtools/client/webide/test/addons/simulators.json | 4 - devtools/client/webide/test/app.zip | Bin 480 -> 0 bytes devtools/client/webide/test/app/index.html | 6 - devtools/client/webide/test/app/manifest.webapp | 5 - devtools/client/webide/test/browser.ini | 12 - devtools/client/webide/test/browser_tabs.js | 84 -- devtools/client/webide/test/browser_widget.js | 15 - .../client/webide/test/build_app1/package.json | 5 - .../client/webide/test/build_app2/manifest.webapp | 1 - .../client/webide/test/build_app2/package.json | 10 - .../webide/test/build_app2/stage/empty-directory | 0 .../webide/test/build_app_windows1/package.json | 5 - .../webide/test/build_app_windows2/manifest.webapp | 1 - .../webide/test/build_app_windows2/package.json | 10 - .../test/build_app_windows2/stage/empty-directory | 0 devtools/client/webide/test/chrome.ini | 71 -- devtools/client/webide/test/device_front_shared.js | 219 ---- devtools/client/webide/test/doc_tabs.html | 15 - devtools/client/webide/test/head.js | 248 ----- devtools/client/webide/test/hosted_app.manifest | 3 - devtools/client/webide/test/templates.json | 14 - devtools/client/webide/test/test_addons.html | 176 --- .../client/webide/test/test_app_validator.html | 205 ---- .../webide/test/test_autoconnect_runtime.html | 94 -- .../webide/test/test_autoselect_project.html | 110 -- devtools/client/webide/test/test_basic.html | 55 - devtools/client/webide/test/test_build.html | 128 --- .../webide/test/test_device_permissions.html | 81 -- .../webide/test/test_device_preferences.html | 87 -- .../client/webide/test/test_device_runtime.html | 81 -- .../client/webide/test/test_device_settings.html | 87 -- .../client/webide/test/test_duplicate_import.html | 77 -- .../client/webide/test/test_fullscreenToolbox.html | 67 -- devtools/client/webide/test/test_import.html | 82 -- .../client/webide/test/test_manifestUpdate.html | 98 -- devtools/client/webide/test/test_newapp.html | 46 - devtools/client/webide/test/test_runtime.html | 203 ---- devtools/client/webide/test/test_simulators.html | 426 ------- devtools/client/webide/test/test_telemetry.html | 325 ------ devtools/client/webide/test/test_toolbox.html | 93 -- devtools/client/webide/test/test_zoom.html | 77 -- .../test/validator/no-name-or-icon/home.html | 0 .../test/validator/no-name-or-icon/manifest.webapp | 3 - .../validator/non-absolute-path/manifest.webapp | 7 - .../test/validator/valid/alsoValid/manifest.webapp | 7 - .../client/webide/test/validator/valid/home.html | 0 .../client/webide/test/validator/valid/icon.png | 0 .../webide/test/validator/valid/manifest.webapp | 7 - .../test/validator/wrong-launch-path/icon.png | 0 .../validator/wrong-launch-path/manifest.webapp | 7 - devtools/client/webide/themes/addons.css | 79 -- devtools/client/webide/themes/config-view.css | 80 -- devtools/client/webide/themes/deck.css | 91 -- devtools/client/webide/themes/default-app-icon.png | Bin 5208 -> 0 bytes devtools/client/webide/themes/details.css | 138 --- devtools/client/webide/themes/icons.png | Bin 35353 -> 0 bytes devtools/client/webide/themes/jar.mn | 24 - devtools/client/webide/themes/logs.css | 18 - devtools/client/webide/themes/monitor.css | 86 -- devtools/client/webide/themes/moz.build | 7 - devtools/client/webide/themes/newapp.css | 54 - devtools/client/webide/themes/noise.png | Bin 6216 -> 0 bytes devtools/client/webide/themes/panel-listing.css | 150 --- devtools/client/webide/themes/permissionstable.css | 23 - devtools/client/webide/themes/rocket.svg | 12 - devtools/client/webide/themes/runtimedetails.css | 25 - devtools/client/webide/themes/simulator.css | 41 - devtools/client/webide/themes/throbber.svg | 22 - devtools/client/webide/themes/webide.css | 149 --- devtools/client/webide/themes/wifi-auth.css | 64 -- devtools/client/webide/webide-prefs.js | 35 - 163 files changed, 13812 deletions(-) delete mode 100644 devtools/client/locales/en-US/webide.dtd delete mode 100644 devtools/client/locales/en-US/webide.properties delete mode 100644 devtools/client/projecteditor/lib/plugins/app-manager/app-project-editor.js delete mode 100644 devtools/client/projecteditor/lib/plugins/app-manager/moz.build delete mode 100644 devtools/client/projecteditor/lib/plugins/app-manager/plugin.js delete mode 100644 devtools/client/webide/components/moz.build delete mode 100644 devtools/client/webide/components/webideCli.js delete mode 100644 devtools/client/webide/components/webideComponents.manifest delete mode 100644 devtools/client/webide/content/addons.js delete mode 100644 devtools/client/webide/content/addons.xhtml delete mode 100644 devtools/client/webide/content/details.js delete mode 100644 devtools/client/webide/content/details.xhtml delete mode 100644 devtools/client/webide/content/devicepreferences.js delete mode 100644 devtools/client/webide/content/devicepreferences.xhtml delete mode 100644 devtools/client/webide/content/devicesettings.js delete mode 100644 devtools/client/webide/content/devicesettings.xhtml delete mode 100644 devtools/client/webide/content/jar.mn delete mode 100644 devtools/client/webide/content/logs.js delete mode 100644 devtools/client/webide/content/logs.xhtml delete mode 100644 devtools/client/webide/content/monitor.js delete mode 100644 devtools/client/webide/content/monitor.xhtml delete mode 100644 devtools/client/webide/content/moz.build delete mode 100644 devtools/client/webide/content/newapp.js delete mode 100644 devtools/client/webide/content/newapp.xul delete mode 100644 devtools/client/webide/content/permissionstable.js delete mode 100644 devtools/client/webide/content/permissionstable.xhtml delete mode 100644 devtools/client/webide/content/prefs.js delete mode 100644 devtools/client/webide/content/prefs.xhtml delete mode 100644 devtools/client/webide/content/project-listing.js delete mode 100644 devtools/client/webide/content/project-listing.xhtml delete mode 100644 devtools/client/webide/content/project-panel.js delete mode 100644 devtools/client/webide/content/runtime-listing.js delete mode 100644 devtools/client/webide/content/runtime-listing.xhtml delete mode 100644 devtools/client/webide/content/runtime-panel.js delete mode 100644 devtools/client/webide/content/runtimedetails.js delete mode 100644 devtools/client/webide/content/runtimedetails.xhtml delete mode 100644 devtools/client/webide/content/simulator.js delete mode 100644 devtools/client/webide/content/simulator.xhtml delete mode 100644 devtools/client/webide/content/webide.js delete mode 100644 devtools/client/webide/content/webide.xul delete mode 100644 devtools/client/webide/content/wifi-auth.js delete mode 100644 devtools/client/webide/content/wifi-auth.xhtml delete mode 100644 devtools/client/webide/modules/addons.js delete mode 100644 devtools/client/webide/modules/app-manager.js delete mode 100644 devtools/client/webide/modules/app-projects.js delete mode 100644 devtools/client/webide/modules/app-validator.js delete mode 100644 devtools/client/webide/modules/build.js delete mode 100644 devtools/client/webide/modules/config-view.js delete mode 100644 devtools/client/webide/modules/moz.build delete mode 100644 devtools/client/webide/modules/project-list.js delete mode 100644 devtools/client/webide/modules/runtime-list.js delete mode 100644 devtools/client/webide/modules/runtimes.js delete mode 100644 devtools/client/webide/modules/simulator-process.js delete mode 100644 devtools/client/webide/modules/simulators.js delete mode 100644 devtools/client/webide/modules/tab-store.js delete mode 100644 devtools/client/webide/modules/utils.js delete mode 100644 devtools/client/webide/moz.build delete mode 100644 devtools/client/webide/test/.eslintrc.js delete mode 100644 devtools/client/webide/test/addons/adbhelper-linux.xpi delete mode 100644 devtools/client/webide/test/addons/adbhelper-linux64.xpi delete mode 100644 devtools/client/webide/test/addons/adbhelper-mac64.xpi delete mode 100644 devtools/client/webide/test/addons/adbhelper-win32.xpi delete mode 100644 devtools/client/webide/test/addons/fxdt-adapters-linux32.xpi delete mode 100644 devtools/client/webide/test/addons/fxdt-adapters-linux64.xpi delete mode 100644 devtools/client/webide/test/addons/fxdt-adapters-mac64.xpi delete mode 100644 devtools/client/webide/test/addons/fxdt-adapters-win32.xpi delete mode 100644 devtools/client/webide/test/addons/fxos_1_0_simulator-linux.xpi delete mode 100644 devtools/client/webide/test/addons/fxos_1_0_simulator-linux64.xpi delete mode 100644 devtools/client/webide/test/addons/fxos_1_0_simulator-mac64.xpi delete mode 100644 devtools/client/webide/test/addons/fxos_1_0_simulator-win32.xpi delete mode 100644 devtools/client/webide/test/addons/fxos_2_0_simulator-linux.xpi delete mode 100644 devtools/client/webide/test/addons/fxos_2_0_simulator-linux64.xpi delete mode 100644 devtools/client/webide/test/addons/fxos_2_0_simulator-mac64.xpi delete mode 100644 devtools/client/webide/test/addons/fxos_2_0_simulator-win32.xpi delete mode 100644 devtools/client/webide/test/addons/fxos_3_0_simulator-linux.xpi delete mode 100644 devtools/client/webide/test/addons/fxos_3_0_simulator-linux64.xpi delete mode 100644 devtools/client/webide/test/addons/fxos_3_0_simulator-mac64.xpi delete mode 100644 devtools/client/webide/test/addons/fxos_3_0_simulator-win32.xpi delete mode 100644 devtools/client/webide/test/addons/fxos_3_0_tv_simulator-linux.xpi delete mode 100644 devtools/client/webide/test/addons/fxos_3_0_tv_simulator-linux64.xpi delete mode 100644 devtools/client/webide/test/addons/fxos_3_0_tv_simulator-mac64.xpi delete mode 100644 devtools/client/webide/test/addons/fxos_3_0_tv_simulator-win32.xpi delete mode 100644 devtools/client/webide/test/addons/simulators.json delete mode 100644 devtools/client/webide/test/app.zip delete mode 100644 devtools/client/webide/test/app/index.html delete mode 100644 devtools/client/webide/test/app/manifest.webapp delete mode 100644 devtools/client/webide/test/browser.ini delete mode 100644 devtools/client/webide/test/browser_tabs.js delete mode 100644 devtools/client/webide/test/browser_widget.js delete mode 100644 devtools/client/webide/test/build_app1/package.json delete mode 100644 devtools/client/webide/test/build_app2/manifest.webapp delete mode 100644 devtools/client/webide/test/build_app2/package.json delete mode 100644 devtools/client/webide/test/build_app2/stage/empty-directory delete mode 100644 devtools/client/webide/test/build_app_windows1/package.json delete mode 100644 devtools/client/webide/test/build_app_windows2/manifest.webapp delete mode 100644 devtools/client/webide/test/build_app_windows2/package.json delete mode 100644 devtools/client/webide/test/build_app_windows2/stage/empty-directory delete mode 100644 devtools/client/webide/test/chrome.ini delete mode 100644 devtools/client/webide/test/device_front_shared.js delete mode 100644 devtools/client/webide/test/doc_tabs.html delete mode 100644 devtools/client/webide/test/head.js delete mode 100644 devtools/client/webide/test/hosted_app.manifest delete mode 100644 devtools/client/webide/test/templates.json delete mode 100644 devtools/client/webide/test/test_addons.html delete mode 100644 devtools/client/webide/test/test_app_validator.html delete mode 100644 devtools/client/webide/test/test_autoconnect_runtime.html delete mode 100644 devtools/client/webide/test/test_autoselect_project.html delete mode 100644 devtools/client/webide/test/test_basic.html delete mode 100644 devtools/client/webide/test/test_build.html delete mode 100644 devtools/client/webide/test/test_device_permissions.html delete mode 100644 devtools/client/webide/test/test_device_preferences.html delete mode 100644 devtools/client/webide/test/test_device_runtime.html delete mode 100644 devtools/client/webide/test/test_device_settings.html delete mode 100644 devtools/client/webide/test/test_duplicate_import.html delete mode 100644 devtools/client/webide/test/test_fullscreenToolbox.html delete mode 100644 devtools/client/webide/test/test_import.html delete mode 100644 devtools/client/webide/test/test_manifestUpdate.html delete mode 100644 devtools/client/webide/test/test_newapp.html delete mode 100644 devtools/client/webide/test/test_runtime.html delete mode 100644 devtools/client/webide/test/test_simulators.html delete mode 100644 devtools/client/webide/test/test_telemetry.html delete mode 100644 devtools/client/webide/test/test_toolbox.html delete mode 100644 devtools/client/webide/test/test_zoom.html delete mode 100644 devtools/client/webide/test/validator/no-name-or-icon/home.html delete mode 100644 devtools/client/webide/test/validator/no-name-or-icon/manifest.webapp delete mode 100644 devtools/client/webide/test/validator/non-absolute-path/manifest.webapp delete mode 100644 devtools/client/webide/test/validator/valid/alsoValid/manifest.webapp delete mode 100644 devtools/client/webide/test/validator/valid/home.html delete mode 100644 devtools/client/webide/test/validator/valid/icon.png delete mode 100644 devtools/client/webide/test/validator/valid/manifest.webapp delete mode 100644 devtools/client/webide/test/validator/wrong-launch-path/icon.png delete mode 100644 devtools/client/webide/test/validator/wrong-launch-path/manifest.webapp delete mode 100644 devtools/client/webide/themes/addons.css delete mode 100644 devtools/client/webide/themes/config-view.css delete mode 100644 devtools/client/webide/themes/deck.css delete mode 100644 devtools/client/webide/themes/default-app-icon.png delete mode 100644 devtools/client/webide/themes/details.css delete mode 100644 devtools/client/webide/themes/icons.png delete mode 100644 devtools/client/webide/themes/jar.mn delete mode 100644 devtools/client/webide/themes/logs.css delete mode 100644 devtools/client/webide/themes/monitor.css delete mode 100644 devtools/client/webide/themes/moz.build delete mode 100644 devtools/client/webide/themes/newapp.css delete mode 100644 devtools/client/webide/themes/noise.png delete mode 100644 devtools/client/webide/themes/panel-listing.css delete mode 100644 devtools/client/webide/themes/permissionstable.css delete mode 100644 devtools/client/webide/themes/rocket.svg delete mode 100644 devtools/client/webide/themes/runtimedetails.css delete mode 100644 devtools/client/webide/themes/simulator.css delete mode 100644 devtools/client/webide/themes/throbber.svg delete mode 100644 devtools/client/webide/themes/webide.css delete mode 100644 devtools/client/webide/themes/wifi-auth.css delete mode 100644 devtools/client/webide/webide-prefs.js diff --git a/application/basilisk/components/customizableui/CustomizableUI.jsm b/application/basilisk/components/customizableui/CustomizableUI.jsm index d56d63d99..a58d33a6d 100644 --- a/application/basilisk/components/customizableui/CustomizableUI.jsm +++ b/application/basilisk/components/customizableui/CustomizableUI.jsm @@ -38,7 +38,6 @@ const kPrefCustomizationState = "browser.uiCustomization.state"; const kPrefCustomizationAutoAdd = "browser.uiCustomization.autoAdd"; const kPrefCustomizationDebug = "browser.uiCustomization.debug"; const kPrefDrawInTitlebar = "browser.tabs.drawInTitlebar"; -const kPrefWebIDEInNavbar = "devtools.webide.widget.inNavbarByDefault"; const kExpectedWindowURL = "chrome://browser/content/browser.xul"; @@ -230,10 +229,6 @@ var CustomizableUIInternal = { navbarPlacements.splice(2, 0, "developer-button"); } - if (Services.prefs.getBoolPref(kPrefWebIDEInNavbar)) { - navbarPlacements.push("webide-button"); - } - // Place this last, when createWidget is called for pocket, it will // append to the toolbar. if (Services.prefs.getPrefType("extensions.pocket.enabled") != Services.prefs.PREF_INVALID && diff --git a/devtools/client/framework/devtools-browser.js b/devtools/client/framework/devtools-browser.js index 4d7176b4c..1b34e44e0 100644 --- a/devtools/client/framework/devtools-browser.js +++ b/devtools/client/framework/devtools-browser.js @@ -123,23 +123,6 @@ var gDevToolsBrowser = exports.gDevToolsBrowser = { win.DeveloperToolbar.show(false).catch(console.error); } - // Enable WebIDE? - let webIDEEnabled = Services.prefs.getBoolPref("devtools.webide.enabled"); - idEls = [ - "appmenu_webide", - "menu_webide" - ]; - idEls.forEach(function (idEl) { - toggleMenuItem(idEl, webIDEEnabled); - }); - - let showWebIDEWidget = Services.prefs.getBoolPref("devtools.webide.widget.enabled"); - if (webIDEEnabled && showWebIDEWidget) { - gDevToolsBrowser.installWebIDEWidget(); - } else { - gDevToolsBrowser.uninstallWebIDEWidget(); - } - // Enable Browser Toolbox? let chromeEnabled = Services.prefs.getBoolPref("devtools.chrome.enabled"); let devtoolsRemoteEnabled = Services.prefs.getBoolPref("devtools.debugger.remote-enabled"); diff --git a/devtools/client/framework/gDevTools.jsm b/devtools/client/framework/gDevTools.jsm index d825c0eaa..6e0dc5e83 100644 --- a/devtools/client/framework/gDevTools.jsm +++ b/devtools/client/framework/gDevTools.jsm @@ -126,16 +126,9 @@ let gDevToolsBrowserMethods = [ // Used by browser-sets.inc, command "openConnectScreen", - // Used by browser-sets.inc, command - // itself, webide widget - "openWebIDE", - // Used by browser-sets.inc, command "openContentProcessToolbox", - // Used by webide.js - "moveWebIDEWidgetInNavbar", - // Used by browser.js "registerBrowserWindow", @@ -146,10 +139,6 @@ let gDevToolsBrowserMethods = [ "forgetBrowserWindow" ]; this.gDevToolsBrowser = { - // Used by webide.js - get isWebIDEInitialized() { - return browser.isWebIDEInitialized; - }, // Used by a test (should be removed) get _trackedBrowserWindows() { return browser._trackedBrowserWindows; diff --git a/devtools/client/locales/en-US/menus.properties b/devtools/client/locales/en-US/menus.properties index 66e158cbd..7030fe17d 100644 --- a/devtools/client/locales/en-US/menus.properties +++ b/devtools/client/locales/en-US/menus.properties @@ -54,11 +54,6 @@ devToolbarMenu.accesskey = v devToolbarMenu.key = VK_F2 devToolbarMenu.keytext = F2 -webide.label = WebIDE -webide.accesskey = W -webide.key = VK_F8 -webide.keytext = F8 - devToolboxMenuItem.label = Toggle Tools devToolboxMenuItem.accesskey = T devToolboxMenuItem.key = I diff --git a/devtools/client/locales/en-US/webide.dtd b/devtools/client/locales/en-US/webide.dtd deleted file mode 100644 index 554488f6d..000000000 --- a/devtools/client/locales/en-US/webide.dtd +++ /dev/null @@ -1,222 +0,0 @@ - - - - %brandDTD; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/devtools/client/locales/en-US/webide.properties b/devtools/client/locales/en-US/webide.properties deleted file mode 100644 index 154094906..000000000 --- a/devtools/client/locales/en-US/webide.properties +++ /dev/null @@ -1,92 +0,0 @@ -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. - -title_noApp=WebIDE -title_app=WebIDE: %S - -runtimeButton_label=Select Runtime -projectButton_label=Open App - -mainProcess_label=Main Process - -local_runtime=Local Runtime -remote_runtime=Remote Runtime -remote_runtime_promptTitle=Remote Runtime -remote_runtime_promptMessage=hostname:port - -importPackagedApp_title=Select Directory -importHostedApp_title=Open Hosted App -importHostedApp_header=Enter Manifest URL - -selectCustomBinary_title=Select custom B2G binary -selectCustomProfile_title=Select custom Gaia profile - -notification_showTroubleShooting_label=Troubleshooting -notification_showTroubleShooting_accesskey=T - -# LOCALIZATION NOTE (project_tab_loading): This is shown as a temporary tab -# title for browser tab projects when the tab is still loading. -project_tab_loading=Loading… - -# These messages appear in a notification box when an error occur. - -error_cantInstallNotFullyConnected=Can’t install project. Not fully connected. -error_cantInstallValidationErrors=Can’t install project. Validation errors. -error_listRunningApps=Can’t get app list from device - -# Variable: name of the operation (in english) -error_operationTimeout=Operation timed out: %1$S -error_operationFail=Operation failed: %1$S - -# Variable: app name -error_cantConnectToApp=Can’t connect to app: %1$S - -# Variable: error message (in english) -error_cantFetchAddonsJSON=Can’t fetch the add-on list: %S - -error_appProjectsLoadFailed=Unable to load project list. This can occur if you’ve used this profile with a newer version of the browser. -error_folderCreationFailed=Unable to create project folder in the selected directory. - -# Variable: runtime app build ID (looks like this %Y%M%D format) and firefox build ID (same format) -error_runtimeVersionTooRecent=The connected runtime has a more recent build date (%1$S) than your desktop browser (%2$S) does. This is an unsupported setup and may cause DevTools to fail. Please update the browser. - -addons_stable=stable -addons_unstable=unstable -# LOCALIZATION NOTE (addons_simulator_label): This label is shown as the name of -# a given simulator version in the "Manage Simulators" pane. %1$S: Firefox OS -# version in the simulator, ex. 1.3. %2$S: Simulator stability label, ex. -# "stable" or "unstable". -addons_simulator_label=Firefox OS %1$S Simulator (%2$S) -addons_install_button=install -addons_uninstall_button=uninstall -addons_adb_label=ADB Helper Add-on -addons_adapters_label=Tools Adapters Add-on -addons_adb_warning=USB devices won’t be detected without this add-on -addons_status_unknown=? -addons_status_installed=Installed -addons_status_uninstalled=Not Installed -addons_status_preparing=preparing -addons_status_downloading=downloading -addons_status_installing=installing - -runtimedetails_checkno=no -runtimedetails_checkyes=yes -runtimedetails_checkunknown=unknown (requires ADB Helper 0.4.0 or later) -runtimedetails_notUSBDevice=Not a USB device - -# Validation status -status_tooltip=Validation status: %1$S -status_valid=VALID -status_warning=WARNINGS -status_error=ERRORS -status_unknown=UNKNOWN - -# Device preferences and settings -device_reset_default=Reset to default - -# Simulator options -simulator_custom_device=Custom -simulator_custom_binary=Custom B2G binary… -simulator_custom_profile=Custom Gaia profile… -simulator_default_profile=Use default diff --git a/devtools/client/menus.js b/devtools/client/menus.js index dbacb367d..23f024f04 100644 --- a/devtools/client/menus.js +++ b/devtools/client/menus.js @@ -86,17 +86,6 @@ exports.menuitems = [ }, checkbox: true }, - { id: "menu_webide", - l10nKey: "webide", - disabled: true, - oncommand() { - gDevToolsBrowser.openWebIDE(); - }, - key: { - id: "webide", - modifiers: "shift" - } - }, { id: "menu_browserToolbox", l10nKey: "browserToolboxMenu", disabled: true, diff --git a/devtools/client/moz.build b/devtools/client/moz.build index b55aa5380..9699ec726 100644 --- a/devtools/client/moz.build +++ b/devtools/client/moz.build @@ -34,7 +34,6 @@ DIRS += [ 'themes', 'webaudioeditor', 'webconsole', - 'webide', ] # Shim old theme paths used by DevTools add-ons diff --git a/devtools/client/preferences/devtools.js b/devtools/client/preferences/devtools.js index 2f6ca2104..dea61e37f 100644 --- a/devtools/client/preferences/devtools.js +++ b/devtools/client/preferences/devtools.js @@ -21,9 +21,6 @@ pref("devtools.loader.hotreload", false); pref("devtools.toolbar.enabled", true); pref("devtools.toolbar.visible", false); -// Enable DevTools WebIDE by default -pref("devtools.webide.enabled", true); - // Toolbox preferences pref("devtools.toolbox.footer.height", 250); pref("devtools.toolbox.sidebar.width", 500); diff --git a/devtools/client/projecteditor/lib/plugins/app-manager/app-project-editor.js b/devtools/client/projecteditor/lib/plugins/app-manager/app-project-editor.js deleted file mode 100644 index 9a66770b0..000000000 --- a/devtools/client/projecteditor/lib/plugins/app-manager/app-project-editor.js +++ /dev/null @@ -1,56 +0,0 @@ -/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ -/* vim: set ft=javascript ts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -const { Cu } = require("chrome"); -const { Class } = require("sdk/core/heritage"); -const promise = require("promise"); -const { ItchEditor } = require("devtools/client/projecteditor/lib/editors"); - -var AppProjectEditor = Class({ - extends: ItchEditor, - - hidesToolbar: true, - - initialize: function (host) { - ItchEditor.prototype.initialize.apply(this, arguments); - this.appended = promise.resolve(); - this.host = host; - this.label = "app-manager"; - }, - - destroy: function () { - this.elt.remove(); - this.elt = null; - }, - - load: function (resource) { - let {appManagerOpts} = this.host.project; - - // Only load the frame the first time it is selected - if (!this.iframe || this.iframe.getAttribute("src") !== appManagerOpts.projectOverviewURL) { - - this.elt.textContent = ""; - let iframe = this.iframe = this.elt.ownerDocument.createElement("iframe"); - let iframeLoaded = this.iframeLoaded = promise.defer(); - - iframe.addEventListener("load", function onLoad() { - iframe.removeEventListener("load", onLoad); - iframeLoaded.resolve(); - }); - - iframe.setAttribute("flex", "1"); - iframe.setAttribute("src", appManagerOpts.projectOverviewURL); - this.elt.appendChild(iframe); - - } - - promise.all([this.iframeLoaded.promise, this.appended]).then(() => { - this.emit("load"); - }); - } -}); - -exports.AppProjectEditor = AppProjectEditor; diff --git a/devtools/client/projecteditor/lib/plugins/app-manager/moz.build b/devtools/client/projecteditor/lib/plugins/app-manager/moz.build deleted file mode 100644 index 8aae52725..000000000 --- a/devtools/client/projecteditor/lib/plugins/app-manager/moz.build +++ /dev/null @@ -1,10 +0,0 @@ -# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*- -# vim: set filetype=python: -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. - -DevToolsModules( - 'app-project-editor.js', - 'plugin.js', -) diff --git a/devtools/client/projecteditor/lib/plugins/app-manager/plugin.js b/devtools/client/projecteditor/lib/plugins/app-manager/plugin.js deleted file mode 100644 index 82bbab34b..000000000 --- a/devtools/client/projecteditor/lib/plugins/app-manager/plugin.js +++ /dev/null @@ -1,77 +0,0 @@ -const { Cu } = require("chrome"); -const { Class } = require("sdk/core/heritage"); -const { EventTarget } = require("sdk/event/target"); -const { emit } = require("sdk/event/core"); -const promise = require("promise"); -var { registerPlugin, Plugin } = require("devtools/client/projecteditor/lib/plugins/core"); -const { AppProjectEditor } = require("./app-project-editor"); -const OPTION_URL = "chrome://devtools/skin/images/tool-options.svg"; -const Services = require("Services"); -const Strings = Services.strings.createBundle("chrome://devtools/locale/webide.properties"); - -var AppManagerRenderer = Class({ - extends: Plugin, - - isAppManagerProject: function () { - return !!this.host.project.appManagerOpts; - }, - editorForResource: function (resource) { - if (!resource.parent && this.isAppManagerProject()) { - return AppProjectEditor; - } - }, - getUI: function (parent) { - let doc = parent.ownerDocument; - if (parent.childElementCount == 0) { - let image = doc.createElement("image"); - let optionImage = doc.createElement("image"); - let flexElement = doc.createElement("div"); - let nameLabel = doc.createElement("span"); - let statusElement = doc.createElement("div"); - - image.className = "project-image"; - optionImage.className = "project-options"; - optionImage.setAttribute("src", OPTION_URL); - nameLabel.className = "project-name-label"; - statusElement.className = "project-status"; - flexElement.className = "project-flex"; - - parent.appendChild(image); - parent.appendChild(nameLabel); - parent.appendChild(flexElement); - parent.appendChild(statusElement); - parent.appendChild(optionImage); - } - - return { - image: parent.querySelector(".project-image"), - nameLabel: parent.querySelector(".project-name-label"), - statusElement: parent.querySelector(".project-status") - }; - }, - onAnnotate: function (resource, editor, elt) { - if (resource.parent || !this.isAppManagerProject()) { - return; - } - - let {appManagerOpts} = this.host.project; - let doc = elt.ownerDocument; - - let {image, nameLabel, statusElement} = this.getUI(elt); - let name = appManagerOpts.name || resource.basename; - let url = appManagerOpts.iconUrl || "icon-sample.png"; - let status = appManagerOpts.validationStatus || "unknown"; - let tooltip = Strings.formatStringFromName("status_tooltip", - [Strings.GetStringFromName("status_" + status)], 1); - - nameLabel.textContent = name; - image.setAttribute("src", url); - statusElement.setAttribute("status", status); - statusElement.setAttribute("tooltiptext", tooltip); - - return true; - } -}); - -exports.AppManagerRenderer = AppManagerRenderer; -registerPlugin(AppManagerRenderer); diff --git a/devtools/client/projecteditor/lib/plugins/moz.build b/devtools/client/projecteditor/lib/plugins/moz.build index 17bff7ce0..99d864e13 100644 --- a/devtools/client/projecteditor/lib/plugins/moz.build +++ b/devtools/client/projecteditor/lib/plugins/moz.build @@ -5,7 +5,6 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. DIRS += [ - 'app-manager', 'delete', 'dirty', 'image-view', diff --git a/devtools/client/projecteditor/lib/projecteditor.js b/devtools/client/projecteditor/lib/projecteditor.js index a3ef06249..27127b0a0 100644 --- a/devtools/client/projecteditor/lib/projecteditor.js +++ b/devtools/client/projecteditor/lib/projecteditor.js @@ -31,7 +31,6 @@ require("devtools/client/projecteditor/lib/plugins/new/new"); require("devtools/client/projecteditor/lib/plugins/rename/rename"); require("devtools/client/projecteditor/lib/plugins/save/save"); require("devtools/client/projecteditor/lib/plugins/image-view/plugin"); -require("devtools/client/projecteditor/lib/plugins/app-manager/plugin"); require("devtools/client/projecteditor/lib/plugins/status-bar/plugin"); // Uncomment to enable logging. diff --git a/devtools/client/shared/telemetry.js b/devtools/client/shared/telemetry.js index 38a21cef6..547b1c07f 100644 --- a/devtools/client/shared/telemetry.js +++ b/devtools/client/shared/telemetry.js @@ -177,23 +177,6 @@ Telemetry.prototype = { histogram: "DEVTOOLS_ABOUTDEBUGGING_OPENED_COUNT", timerHistogram: "DEVTOOLS_ABOUTDEBUGGING_TIME_ACTIVE_SECONDS" }, - webide: { - histogram: "DEVTOOLS_WEBIDE_OPENED_COUNT", - timerHistogram: "DEVTOOLS_WEBIDE_TIME_ACTIVE_SECONDS" - }, - webideProjectEditor: { - histogram: "DEVTOOLS_WEBIDE_PROJECT_EDITOR_OPENED_COUNT", - timerHistogram: "DEVTOOLS_WEBIDE_PROJECT_EDITOR_TIME_ACTIVE_SECONDS" - }, - webideProjectEditorSave: { - histogram: "DEVTOOLS_WEBIDE_PROJECT_EDITOR_SAVE_COUNT", - }, - webideNewProject: { - histogram: "DEVTOOLS_WEBIDE_NEW_PROJECT_COUNT", - }, - webideImportProject: { - histogram: "DEVTOOLS_WEBIDE_IMPORT_PROJECT_COUNT", - }, custom: { histogram: "DEVTOOLS_CUSTOM_OPENED_COUNT", timerHistogram: "DEVTOOLS_CUSTOM_TIME_ACTIVE_SECONDS" diff --git a/devtools/client/webide/components/moz.build b/devtools/client/webide/components/moz.build deleted file mode 100644 index d4047c295..000000000 --- a/devtools/client/webide/components/moz.build +++ /dev/null @@ -1,10 +0,0 @@ -# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*- -# vim: set filetype=python: -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. - -EXTRA_COMPONENTS += [ - 'webideCli.js', - 'webideComponents.manifest', -] diff --git a/devtools/client/webide/components/webideCli.js b/devtools/client/webide/components/webideCli.js deleted file mode 100644 index 0f75da2c4..000000000 --- a/devtools/client/webide/components/webideCli.js +++ /dev/null @@ -1,58 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -"use strict"; - -const Ci = Components.interfaces; -const Cu = Components.utils; - -const { XPCOMUtils } = Cu.import("resource://gre/modules/XPCOMUtils.jsm", {}); - -XPCOMUtils.defineLazyModuleGetter(this, "Services", "resource://gre/modules/Services.jsm"); - -/** - * Handles --webide command line option. - */ - -function webideCli() { } - -webideCli.prototype = { - handle: function (cmdLine) { - if (!cmdLine.handleFlag("webide", false)) { - return; - } - - // If --webide is used remotely, we don't want to open - // a new tab. - // - // If --webide is used for a new Firefox instance, we - // want to open webide only. - cmdLine.preventDefault = true; - - let win = Services.wm.getMostRecentWindow("devtools:webide"); - if (win) { - win.focus(); - } else { - win = Services.ww.openWindow(null, - "chrome://webide/content/", - "webide", - "chrome,centerscreen,resizable,dialog=no", - null); - } - - if (cmdLine.state == Ci.nsICommandLine.STATE_INITIAL_LAUNCH) { - // If this is a new Firefox instance, and because we will only start - // webide, we need to notify "sessionstore-windows-restored" to trigger - // addons registration (for simulators and adb helper). - Services.obs.notifyObservers(null, "sessionstore-windows-restored", ""); - } - }, - - helpInfo: "", - - classID: Components.ID("{79b7b44e-de5e-4e4c-b7a2-044003c615d9}"), - QueryInterface: XPCOMUtils.generateQI([Ci.nsICommandLineHandler]), -}; - -this.NSGetFactory = XPCOMUtils.generateNSGetFactory([webideCli]); diff --git a/devtools/client/webide/components/webideComponents.manifest b/devtools/client/webide/components/webideComponents.manifest deleted file mode 100644 index 03af9758c..000000000 --- a/devtools/client/webide/components/webideComponents.manifest +++ /dev/null @@ -1,4 +0,0 @@ -# webide components -component {79b7b44e-de5e-4e4c-b7a2-044003c615d9} webideCli.js -contract @mozilla.org/browser/webide-clh;1 {79b7b44e-de5e-4e4c-b7a2-044003c615d9} -category command-line-handler a-webide @mozilla.org/browser/webide-clh;1 diff --git a/devtools/client/webide/content/addons.js b/devtools/client/webide/content/addons.js deleted file mode 100644 index 3948b040f..000000000 --- a/devtools/client/webide/content/addons.js +++ /dev/null @@ -1,135 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -var Cu = Components.utils; -const {require} = Cu.import("resource://devtools/shared/Loader.jsm", {}); -const Services = require("Services"); -const {gDevTools} = require("devtools/client/framework/devtools"); -const {GetAvailableAddons, ForgetAddonsList} = require("devtools/client/webide/modules/addons"); -const Strings = Services.strings.createBundle("chrome://devtools/locale/webide.properties"); - -window.addEventListener("load", function onLoad() { - window.removeEventListener("load", onLoad); - document.querySelector("#aboutaddons").onclick = function () { - let browserWin = Services.wm.getMostRecentWindow(gDevTools.chromeWindowType); - if (browserWin && browserWin.BrowserOpenAddonsMgr) { - browserWin.BrowserOpenAddonsMgr("addons://list/extension"); - } - }; - document.querySelector("#close").onclick = CloseUI; - GetAvailableAddons().then(BuildUI, (e) => { - console.error(e); - window.alert(Strings.formatStringFromName("error_cantFetchAddonsJSON", [e], 1)); - }); -}, true); - -window.addEventListener("unload", function onUnload() { - window.removeEventListener("unload", onUnload); - ForgetAddonsList(); -}, true); - -function CloseUI() { - window.parent.UI.openProject(); -} - -function BuildUI(addons) { - BuildItem(addons.adb, "adb"); - BuildItem(addons.adapters, "adapters"); - for (let addon of addons.simulators) { - BuildItem(addon, "simulator"); - } -} - -function BuildItem(addon, type) { - - function onAddonUpdate(event, arg) { - switch (event) { - case "update": - progress.removeAttribute("value"); - li.setAttribute("status", addon.status); - status.textContent = Strings.GetStringFromName("addons_status_" + addon.status); - break; - case "failure": - window.parent.UI.reportError("error_operationFail", arg); - break; - case "progress": - if (arg == -1) { - progress.removeAttribute("value"); - } else { - progress.value = arg; - } - break; - } - } - - let events = ["update", "failure", "progress"]; - for (let e of events) { - addon.on(e, onAddonUpdate); - } - window.addEventListener("unload", function onUnload() { - window.removeEventListener("unload", onUnload); - for (let e of events) { - addon.off(e, onAddonUpdate); - } - }); - - let li = document.createElement("li"); - li.setAttribute("status", addon.status); - - let name = document.createElement("span"); - name.className = "name"; - - switch (type) { - case "adb": - li.setAttribute("addon", type); - name.textContent = Strings.GetStringFromName("addons_adb_label"); - break; - case "adapters": - li.setAttribute("addon", type); - try { - name.textContent = Strings.GetStringFromName("addons_adapters_label"); - } catch (e) { - // This code (bug 1081093) will be backported to Aurora, which doesn't - // contain this string. - name.textContent = "Tools Adapters Add-on"; - } - break; - case "simulator": - li.setAttribute("addon", "simulator-" + addon.version); - let stability = Strings.GetStringFromName("addons_" + addon.stability); - name.textContent = Strings.formatStringFromName("addons_simulator_label", [addon.version, stability], 2); - break; - } - - li.appendChild(name); - - let status = document.createElement("span"); - status.className = "status"; - status.textContent = Strings.GetStringFromName("addons_status_" + addon.status); - li.appendChild(status); - - let installButton = document.createElement("button"); - installButton.className = "install-button"; - installButton.onclick = () => addon.install(); - installButton.textContent = Strings.GetStringFromName("addons_install_button"); - li.appendChild(installButton); - - let uninstallButton = document.createElement("button"); - uninstallButton.className = "uninstall-button"; - uninstallButton.onclick = () => addon.uninstall(); - uninstallButton.textContent = Strings.GetStringFromName("addons_uninstall_button"); - li.appendChild(uninstallButton); - - let progress = document.createElement("progress"); - li.appendChild(progress); - - if (type == "adb") { - let warning = document.createElement("p"); - warning.textContent = Strings.GetStringFromName("addons_adb_warning"); - warning.className = "warning"; - li.appendChild(warning); - } - - document.querySelector("ul").appendChild(li); -} diff --git a/devtools/client/webide/content/addons.xhtml b/devtools/client/webide/content/addons.xhtml deleted file mode 100644 index 6f3bc1e7c..000000000 --- a/devtools/client/webide/content/addons.xhtml +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - %webideDTD; -]> - - - - - - - - - - - - -

&addons_title;

- -
    - - - diff --git a/devtools/client/webide/content/details.js b/devtools/client/webide/content/details.js deleted file mode 100644 index 9097cd8c5..000000000 --- a/devtools/client/webide/content/details.js +++ /dev/null @@ -1,139 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -var Cu = Components.utils; -const {require} = Cu.import("resource://devtools/shared/Loader.jsm", {}); -const Services = require("Services"); -const {AppManager} = require("devtools/client/webide/modules/app-manager"); -const {ProjectBuilding} = require("devtools/client/webide/modules/build"); - -window.addEventListener("load", function onLoad() { - window.removeEventListener("load", onLoad); - document.addEventListener("visibilitychange", updateUI, true); - AppManager.on("app-manager-update", onAppManagerUpdate); - updateUI(); -}, true); - -window.addEventListener("unload", function onUnload() { - window.removeEventListener("unload", onUnload); - AppManager.off("app-manager-update", onAppManagerUpdate); -}, true); - -function onAppManagerUpdate(event, what, details) { - if (what == "project" || - what == "project-validated") { - updateUI(); - } -} - -function resetUI() { - document.querySelector("#toolbar").classList.add("hidden"); - document.querySelector("#type").classList.add("hidden"); - document.querySelector("#descriptionHeader").classList.add("hidden"); - document.querySelector("#manifestURLHeader").classList.add("hidden"); - document.querySelector("#locationHeader").classList.add("hidden"); - - document.body.className = ""; - document.querySelector("#icon").src = ""; - document.querySelector("h1").textContent = ""; - document.querySelector("#description").textContent = ""; - document.querySelector("#type").textContent = ""; - document.querySelector("#manifestURL").textContent = ""; - document.querySelector("#location").textContent = ""; - - document.querySelector("#prePackageLog").hidden = true; - - document.querySelector("#errorslist").innerHTML = ""; - document.querySelector("#warningslist").innerHTML = ""; - -} - -function updateUI() { - resetUI(); - - let project = AppManager.selectedProject; - if (!project) { - return; - } - - if (project.type != "runtimeApp" && project.type != "mainProcess") { - document.querySelector("#toolbar").classList.remove("hidden"); - document.querySelector("#locationHeader").classList.remove("hidden"); - document.querySelector("#location").textContent = project.location; - } - - document.body.className = project.validationStatus; - document.querySelector("#icon").src = project.icon; - document.querySelector("h1").textContent = project.name; - - let manifest; - if (project.type == "runtimeApp") { - manifest = project.app.manifest; - } else { - manifest = project.manifest; - } - - if (manifest) { - if (manifest.description) { - document.querySelector("#descriptionHeader").classList.remove("hidden"); - document.querySelector("#description").textContent = manifest.description; - } - - document.querySelector("#type").classList.remove("hidden"); - - if (project.type == "runtimeApp") { - let manifestURL = AppManager.getProjectManifestURL(project); - document.querySelector("#type").textContent = manifest.type || "web"; - document.querySelector("#manifestURLHeader").classList.remove("hidden"); - document.querySelector("#manifestURL").textContent = manifestURL; - } else if (project.type == "mainProcess") { - document.querySelector("#type").textContent = project.name; - } else { - document.querySelector("#type").textContent = project.type + " " + (manifest.type || "web"); - } - - if (project.type == "packaged") { - let manifestURL = AppManager.getProjectManifestURL(project); - if (manifestURL) { - document.querySelector("#manifestURLHeader").classList.remove("hidden"); - document.querySelector("#manifestURL").textContent = manifestURL; - } - } - } - - if (project.type != "runtimeApp" && project.type != "mainProcess") { - ProjectBuilding.hasPrepackage(project).then(hasPrepackage => { - document.querySelector("#prePackageLog").hidden = !hasPrepackage; - }); - } - - let errorsNode = document.querySelector("#errorslist"); - let warningsNode = document.querySelector("#warningslist"); - - if (project.errors) { - for (let e of project.errors) { - let li = document.createElement("li"); - li.textContent = e; - errorsNode.appendChild(li); - } - } - - if (project.warnings) { - for (let w of project.warnings) { - let li = document.createElement("li"); - li.textContent = w; - warningsNode.appendChild(li); - } - } - - AppManager.update("details"); -} - -function showPrepackageLog() { - window.top.UI.selectDeckPanel("logs"); -} - -function removeProject() { - AppManager.removeSelectedProject(); -} diff --git a/devtools/client/webide/content/details.xhtml b/devtools/client/webide/content/details.xhtml deleted file mode 100644 index a04c37b0c..000000000 --- a/devtools/client/webide/content/details.xhtml +++ /dev/null @@ -1,54 +0,0 @@ - - - - - - %webideDTD; -]> - - - - - - - - - -
    - -

    - &details_valid_header; - &details_warning_header; - &details_error_header; -

    -
    - -
    - -
    -

    -

    -
    -
    - -
    -

    &details_description;

    -

    - -

    &details_location;

    -

    - -

    &details_manifestURL;

    -

    - - -
    - -
      -
        - - - diff --git a/devtools/client/webide/content/devicepreferences.js b/devtools/client/webide/content/devicepreferences.js deleted file mode 100644 index 14c020f12..000000000 --- a/devtools/client/webide/content/devicepreferences.js +++ /dev/null @@ -1,81 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -var Cu = Components.utils; -const {require} = Cu.import("resource://devtools/shared/Loader.jsm", {}); -const {AppManager} = require("devtools/client/webide/modules/app-manager"); -const {Connection} = require("devtools/shared/client/connection-manager"); -const ConfigView = require("devtools/client/webide/modules/config-view"); - -var configView = new ConfigView(window); - -window.addEventListener("load", function onLoad() { - window.removeEventListener("load", onLoad); - AppManager.on("app-manager-update", OnAppManagerUpdate); - document.getElementById("close").onclick = CloseUI; - document.getElementById("device-fields").onchange = UpdateField; - document.getElementById("device-fields").onclick = CheckReset; - document.getElementById("search-bar").onkeyup = document.getElementById("search-bar").onclick = SearchField; - document.getElementById("custom-value").onclick = UpdateNewField; - document.getElementById("custom-value-type").onchange = ClearNewFields; - document.getElementById("add-custom-field").onkeyup = CheckNewFieldSubmit; - BuildUI(); -}, true); - -window.addEventListener("unload", function onUnload() { - window.removeEventListener("unload", onUnload); - AppManager.off("app-manager-update", OnAppManagerUpdate); -}); - -function CloseUI() { - window.parent.UI.openProject(); -} - -function OnAppManagerUpdate(event, what) { - if (what == "connection" || what == "runtime-global-actors") { - BuildUI(); - } -} - -function CheckNewFieldSubmit(event) { - configView.checkNewFieldSubmit(event); -} - -function UpdateNewField() { - configView.updateNewField(); -} - -function ClearNewFields() { - configView.clearNewFields(); -} - -function CheckReset(event) { - configView.checkReset(event); -} - -function UpdateField(event) { - configView.updateField(event); -} - -function SearchField(event) { - configView.search(event); -} - -var getAllPrefs; // Used by tests -function BuildUI() { - configView.resetTable(); - - if (AppManager.connection && - AppManager.connection.status == Connection.Status.CONNECTED && - AppManager.preferenceFront) { - configView.front = AppManager.preferenceFront; - configView.kind = "Pref"; - configView.includeTypeName = true; - - getAllPrefs = AppManager.preferenceFront.getAllPrefs() - .then(json => configView.generateDisplay(json)); - } else { - CloseUI(); - } -} diff --git a/devtools/client/webide/content/devicepreferences.xhtml b/devtools/client/webide/content/devicepreferences.xhtml deleted file mode 100644 index dafb6f15f..000000000 --- a/devtools/client/webide/content/devicepreferences.xhtml +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - %webideDTD; -]> - - - - - - - - - -
        - -

        &devicepreference_title;

        - -
        - - - - - - -
        - - - - - - -
        - - diff --git a/devtools/client/webide/content/devicesettings.js b/devtools/client/webide/content/devicesettings.js deleted file mode 100644 index 987df5995..000000000 --- a/devtools/client/webide/content/devicesettings.js +++ /dev/null @@ -1,81 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -var Cu = Components.utils; -const {require} = Cu.import("resource://devtools/shared/Loader.jsm", {}); -const {AppManager} = require("devtools/client/webide/modules/app-manager"); -const {Connection} = require("devtools/shared/client/connection-manager"); -const ConfigView = require("devtools/client/webide/modules/config-view"); - -var configView = new ConfigView(window); - -window.addEventListener("load", function onLoad() { - window.removeEventListener("load", onLoad); - AppManager.on("app-manager-update", OnAppManagerUpdate); - document.getElementById("close").onclick = CloseUI; - document.getElementById("device-fields").onchange = UpdateField; - document.getElementById("device-fields").onclick = CheckReset; - document.getElementById("search-bar").onkeyup = document.getElementById("search-bar").onclick = SearchField; - document.getElementById("custom-value").onclick = UpdateNewField; - document.getElementById("custom-value-type").onchange = ClearNewFields; - document.getElementById("add-custom-field").onkeyup = CheckNewFieldSubmit; - BuildUI(); -}, true); - -window.addEventListener("unload", function onUnload() { - window.removeEventListener("unload", onUnload); - AppManager.off("app-manager-update", OnAppManagerUpdate); -}); - -function CloseUI() { - window.parent.UI.openProject(); -} - -function OnAppManagerUpdate(event, what) { - if (what == "connection" || what == "runtime-global-actors") { - BuildUI(); - } -} - -function CheckNewFieldSubmit(event) { - configView.checkNewFieldSubmit(event); -} - -function UpdateNewField() { - configView.updateNewField(); -} - -function ClearNewFields() { - configView.clearNewFields(); -} - -function CheckReset(event) { - configView.checkReset(event); -} - -function UpdateField(event) { - configView.updateField(event); -} - -function SearchField(event) { - configView.search(event); -} - -var getAllSettings; // Used by tests -function BuildUI() { - configView.resetTable(); - - if (AppManager.connection && - AppManager.connection.status == Connection.Status.CONNECTED && - AppManager.settingsFront) { - configView.front = AppManager.settingsFront; - configView.kind = "Setting"; - configView.includeTypeName = false; - - getAllSettings = AppManager.settingsFront.getAllSettings() - .then(json => configView.generateDisplay(json)); - } else { - CloseUI(); - } -} diff --git a/devtools/client/webide/content/devicesettings.xhtml b/devtools/client/webide/content/devicesettings.xhtml deleted file mode 100644 index 0406c6f07..000000000 --- a/devtools/client/webide/content/devicesettings.xhtml +++ /dev/null @@ -1,50 +0,0 @@ - - - - - - %webideDTD; -]> - - - - - - - - - -
        - -

        &devicesetting_title;

        - -
        - - - - - - -
        - - - - - - -
        - - diff --git a/devtools/client/webide/content/jar.mn b/devtools/client/webide/content/jar.mn deleted file mode 100644 index db79fdb51..000000000 --- a/devtools/client/webide/content/jar.mn +++ /dev/null @@ -1,38 +0,0 @@ -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. - -webide.jar: -% content webide %content/ - content/webide.xul (webide.xul) - content/webide.js (webide.js) - content/newapp.xul (newapp.xul) - content/newapp.js (newapp.js) - content/details.xhtml (details.xhtml) - content/details.js (details.js) - content/addons.js (addons.js) - content/addons.xhtml (addons.xhtml) - content/permissionstable.js (permissionstable.js) - content/permissionstable.xhtml (permissionstable.xhtml) - content/runtimedetails.js (runtimedetails.js) - content/runtimedetails.xhtml (runtimedetails.xhtml) - content/prefs.js (prefs.js) - content/prefs.xhtml (prefs.xhtml) - content/monitor.xhtml (monitor.xhtml) - content/monitor.js (monitor.js) - content/devicepreferences.js (devicepreferences.js) - content/devicepreferences.xhtml (devicepreferences.xhtml) - content/devicesettings.js (devicesettings.js) - content/devicesettings.xhtml (devicesettings.xhtml) - content/wifi-auth.js (wifi-auth.js) - content/wifi-auth.xhtml (wifi-auth.xhtml) - content/logs.xhtml (logs.xhtml) - content/logs.js (logs.js) - content/project-listing.xhtml (project-listing.xhtml) - content/project-listing.js (project-listing.js) - content/project-panel.js (project-panel.js) - content/runtime-panel.js (runtime-panel.js) - content/runtime-listing.xhtml (runtime-listing.xhtml) - content/runtime-listing.js (runtime-listing.js) - content/simulator.js (simulator.js) - content/simulator.xhtml (simulator.xhtml) diff --git a/devtools/client/webide/content/logs.js b/devtools/client/webide/content/logs.js deleted file mode 100644 index 157d83b67..000000000 --- a/devtools/client/webide/content/logs.js +++ /dev/null @@ -1,70 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -var Cu = Components.utils; -const {require} = Cu.import("resource://devtools/shared/Loader.jsm", {}); -const {AppManager} = require("devtools/client/webide/modules/app-manager"); - -window.addEventListener("load", function onLoad() { - window.removeEventListener("load", onLoad); - - Logs.init(); -}); - -window.addEventListener("unload", function onUnload() { - window.removeEventListener("unload", onUnload); - - Logs.uninit(); -}); - -const Logs = { - init: function () { - this.list = document.getElementById("logs"); - - Logs.onAppManagerUpdate = Logs.onAppManagerUpdate.bind(this); - AppManager.on("app-manager-update", Logs.onAppManagerUpdate); - - document.getElementById("close").onclick = Logs.close.bind(this); - }, - - uninit: function () { - AppManager.off("app-manager-update", Logs.onAppManagerUpdate); - }, - - onAppManagerUpdate: function (event, what, details) { - switch (what) { - case "pre-package": - this.prePackageLog(details); - break; - } - }, - - close: function () { - window.parent.UI.openProject(); - }, - - prePackageLog: function (msg, details) { - if (msg == "start") { - this.clear(); - } else if (msg == "succeed") { - setTimeout(function () { - Logs.close(); - }, 1000); - } else if (msg == "failed") { - this.log(details); - } else { - this.log(msg); - } - }, - - clear: function () { - this.list.innerHTML = ""; - }, - - log: function (msg) { - let line = document.createElement("li"); - line.textContent = msg; - this.list.appendChild(line); - } -}; diff --git a/devtools/client/webide/content/logs.xhtml b/devtools/client/webide/content/logs.xhtml deleted file mode 100644 index 8d003e509..000000000 --- a/devtools/client/webide/content/logs.xhtml +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - %webideDTD; -]> - - - - - - - - - - - - - - -

        &logs_title;

        - -
          -
        - - - diff --git a/devtools/client/webide/content/monitor.js b/devtools/client/webide/content/monitor.js deleted file mode 100644 index a5d80d460..000000000 --- a/devtools/client/webide/content/monitor.js +++ /dev/null @@ -1,741 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -var Cu = Components.utils; -const {require} = Cu.import("resource://devtools/shared/Loader.jsm", {}); -const Services = require("Services"); -const {AppManager} = require("devtools/client/webide/modules/app-manager"); -const {AppActorFront} = require("devtools/shared/apps/app-actor-front"); -const {Connection} = require("devtools/shared/client/connection-manager"); -const EventEmitter = require("devtools/shared/event-emitter"); - -window.addEventListener("load", function onLoad() { - window.removeEventListener("load", onLoad); - window.addEventListener("resize", Monitor.resize); - window.addEventListener("unload", Monitor.unload); - - document.querySelector("#close").onclick = () => { - window.parent.UI.openProject(); - }; - - Monitor.load(); -}); - - -/** - * The Monitor is a WebIDE tool used to display any kind of time-based data in - * the form of graphs. - * - * The data can come from a Firefox OS device, simulator, or from a WebSockets - * server running locally. - * - * The format of a data update is typically an object like: - * - * { graph: 'mygraph', curve: 'mycurve', value: 42, time: 1234 } - * - * or an array of such objects. For more details on the data format, see the - * `Graph.update(data)` method. - */ -var Monitor = { - - apps: new Map(), - graphs: new Map(), - front: null, - socket: null, - wstimeout: null, - b2ginfo: false, - b2gtimeout: null, - - /** - * Add new data to the graphs, create a new graph if necessary. - */ - update: function (data, fallback) { - if (Array.isArray(data)) { - data.forEach(d => Monitor.update(d, fallback)); - return; - } - - if (Monitor.b2ginfo && data.graph === "USS") { - // If we're polling b2g-info, ignore USS updates from the device's - // USSAgents (see Monitor.pollB2GInfo()). - return; - } - - if (fallback) { - for (let key in fallback) { - if (!data[key]) { - data[key] = fallback[key]; - } - } - } - - let graph = Monitor.graphs.get(data.graph); - if (!graph) { - let element = document.createElement("div"); - element.classList.add("graph"); - document.body.appendChild(element); - - graph = new Graph(data.graph, element); - Monitor.resize(); // a scrollbar might have dis/reappeared - Monitor.graphs.set(data.graph, graph); - } - graph.update(data); - }, - - /** - * Initialize the Monitor. - */ - load: function () { - AppManager.on("app-manager-update", Monitor.onAppManagerUpdate); - Monitor.connectToRuntime(); - Monitor.connectToWebSocket(); - }, - - /** - * Clean up the Monitor. - */ - unload: function () { - AppManager.off("app-manager-update", Monitor.onAppManagerUpdate); - Monitor.disconnectFromRuntime(); - Monitor.disconnectFromWebSocket(); - }, - - /** - * Resize all the graphs. - */ - resize: function () { - for (let graph of Monitor.graphs.values()) { - graph.resize(); - } - }, - - /** - * When WebIDE connects to a new runtime, start its data forwarders. - */ - onAppManagerUpdate: function (event, what, details) { - switch (what) { - case "runtime-global-actors": - Monitor.connectToRuntime(); - break; - case "connection": - if (AppManager.connection.status == Connection.Status.DISCONNECTED) { - Monitor.disconnectFromRuntime(); - } - break; - } - }, - - /** - * Use an AppActorFront on a runtime to watch track its apps. - */ - connectToRuntime: function () { - Monitor.pollB2GInfo(); - let client = AppManager.connection && AppManager.connection.client; - let resp = AppManager._listTabsResponse; - if (client && resp && !Monitor.front) { - Monitor.front = new AppActorFront(client, resp); - Monitor.front.watchApps(Monitor.onRuntimeAppEvent); - } - }, - - /** - * Destroy our AppActorFront. - */ - disconnectFromRuntime: function () { - Monitor.unpollB2GInfo(); - if (Monitor.front) { - Monitor.front.unwatchApps(Monitor.onRuntimeAppEvent); - Monitor.front = null; - } - }, - - /** - * Try connecting to a local websockets server and accept updates from it. - */ - connectToWebSocket: function () { - let webSocketURL = Services.prefs.getCharPref("devtools.webide.monitorWebSocketURL"); - try { - Monitor.socket = new WebSocket(webSocketURL); - Monitor.socket.onmessage = function (event) { - Monitor.update(JSON.parse(event.data)); - }; - Monitor.socket.onclose = function () { - Monitor.wstimeout = setTimeout(Monitor.connectToWebsocket, 1000); - }; - } catch (e) { - Monitor.wstimeout = setTimeout(Monitor.connectToWebsocket, 1000); - } - }, - - /** - * Used when cleaning up. - */ - disconnectFromWebSocket: function () { - clearTimeout(Monitor.wstimeout); - if (Monitor.socket) { - Monitor.socket.onclose = () => {}; - Monitor.socket.close(); - } - }, - - /** - * When an app starts on the runtime, start a monitor actor for its process. - */ - onRuntimeAppEvent: function (type, app) { - if (type !== "appOpen" && type !== "appClose") { - return; - } - - let client = AppManager.connection.client; - app.getForm().then(form => { - if (type === "appOpen") { - app.monitorClient = new MonitorClient(client, form); - app.monitorClient.start(); - app.monitorClient.on("update", Monitor.onRuntimeUpdate); - Monitor.apps.set(form.monitorActor, app); - } else { - let app = Monitor.apps.get(form.monitorActor); - if (app) { - app.monitorClient.stop(() => app.monitorClient.destroy()); - Monitor.apps.delete(form.monitorActor); - } - } - }); - }, - - /** - * Accept data updates from the monitor actors of a runtime. - */ - onRuntimeUpdate: function (type, packet) { - let fallback = {}, app = Monitor.apps.get(packet.from); - if (app) { - fallback.curve = app.manifest.name; - } - Monitor.update(packet.data, fallback); - }, - - /** - * Bug 1047355: If possible, parsing the output of `b2g-info` has several - * benefits over bug 1037465's multi-process USSAgent approach, notably: - * - Works for older Firefox OS devices (pre-2.1), - * - Doesn't need certified-apps debugging, - * - Polling time is synchronized for all processes. - * TODO: After bug 1043324 lands, consider removing this hack. - */ - pollB2GInfo: function () { - if (AppManager.selectedRuntime) { - let device = AppManager.selectedRuntime.device; - if (device && device.shell) { - device.shell("b2g-info").then(s => { - let lines = s.split("\n"); - let line = ""; - - // Find the header row to locate NAME and USS, looks like: - // ' NAME PID NICE USS PSS RSS VSIZE OOM_ADJ USER '. - while (line.indexOf("NAME") < 0) { - if (lines.length < 1) { - // Something is wrong with this output, don't trust b2g-info. - Monitor.unpollB2GInfo(); - return; - } - line = lines.shift(); - } - let namelength = line.indexOf("NAME") + "NAME".length; - let ussindex = line.slice(namelength).split(/\s+/).indexOf("USS"); - - // Get the NAME and USS in each following line, looks like: - // 'Homescreen 375 18 12.6 16.3 27.1 67.8 4 app_375'. - while (lines.length > 0 && lines[0].length > namelength) { - line = lines.shift(); - let name = line.slice(0, namelength); - let uss = line.slice(namelength).split(/\s+/)[ussindex]; - Monitor.update({ - curve: name.trim(), - value: 1024 * 1024 * parseFloat(uss) // Convert MB to bytes. - }, { - // Note: We use the fallback object to set the graph name to 'USS' - // so that Monitor.update() can ignore USSAgent updates. - graph: "USS" - }); - } - }); - } - } - Monitor.b2ginfo = true; - Monitor.b2gtimeout = setTimeout(Monitor.pollB2GInfo, 350); - }, - - /** - * Polling b2g-info doesn't work or is no longer needed. - */ - unpollB2GInfo: function () { - clearTimeout(Monitor.b2gtimeout); - Monitor.b2ginfo = false; - } - -}; - - -/** - * A MonitorClient is used as an actor client of a runtime's monitor actors, - * receiving its updates. - */ -function MonitorClient(client, form) { - this.client = client; - this.actor = form.monitorActor; - this.events = ["update"]; - - EventEmitter.decorate(this); - this.client.registerClient(this); -} -MonitorClient.prototype.destroy = function () { - this.client.unregisterClient(this); -}; -MonitorClient.prototype.start = function () { - this.client.request({ - to: this.actor, - type: "start" - }); -}; -MonitorClient.prototype.stop = function (callback) { - this.client.request({ - to: this.actor, - type: "stop" - }, callback); -}; - - -/** - * A Graph populates a container DOM element with an SVG graph and a legend. - */ -function Graph(name, element) { - this.name = name; - this.element = element; - this.curves = new Map(); - this.events = new Map(); - this.ignored = new Set(); - this.enabled = true; - this.request = null; - - this.x = d3.time.scale(); - this.y = d3.scale.linear(); - - this.xaxis = d3.svg.axis().scale(this.x).orient("bottom"); - this.yaxis = d3.svg.axis().scale(this.y).orient("left"); - - this.xformat = d3.time.format("%I:%M:%S"); - this.yformat = this.formatter(1); - this.yaxis.tickFormat(this.formatter(0)); - - this.line = d3.svg.line().interpolate("linear") - .x(function (d) { return this.x(d.time); }) - .y(function (d) { return this.y(d.value); }); - - this.color = d3.scale.category10(); - - this.svg = d3.select(element).append("svg").append("g") - .attr("transform", "translate(" + this.margin.left + "," + this.margin.top + ")"); - - this.xelement = this.svg.append("g").attr("class", "x axis").call(this.xaxis); - this.yelement = this.svg.append("g").attr("class", "y axis").call(this.yaxis); - - // RULERS on axes - let xruler = this.xruler = this.svg.select(".x.axis").append("g").attr("class", "x ruler"); - xruler.append("line").attr("y2", 6); - xruler.append("line").attr("stroke-dasharray", "1,1"); - xruler.append("text").attr("y", 9).attr("dy", ".71em"); - - let yruler = this.yruler = this.svg.select(".y.axis").append("g").attr("class", "y ruler"); - yruler.append("line").attr("x2", -6); - yruler.append("line").attr("stroke-dasharray", "1,1"); - yruler.append("text").attr("x", -9).attr("dy", ".32em"); - - let self = this; - - d3.select(element).select("svg") - .on("mousemove", function () { - let mouse = d3.mouse(this); - self.mousex = mouse[0] - self.margin.left, - self.mousey = mouse[1] - self.margin.top; - - xruler.attr("transform", "translate(" + self.mousex + ",0)"); - yruler.attr("transform", "translate(0," + self.mousey + ")"); - }); - /* .on('mouseout', function() { - self.xruler.attr('transform', 'translate(-500,0)'); - self.yruler.attr('transform', 'translate(0,-500)'); - });*/ - this.mousex = this.mousey = -500; - - let sidebar = d3.select(this.element).append("div").attr("class", "sidebar"); - let title = sidebar.append("label").attr("class", "graph-title"); - - title.append("input") - .attr("type", "checkbox") - .attr("checked", "true") - .on("click", function () { self.toggle(); }); - title.append("span").text(this.name); - - this.legend = sidebar.append("div").attr("class", "legend"); - - this.resize = this.resize.bind(this); - this.render = this.render.bind(this); - this.averages = this.averages.bind(this); - - setInterval(this.averages, 1000); - - this.resize(); -} - -Graph.prototype = { - - /** - * These margin are used to properly position the SVG graph items inside the - * container element. - */ - margin: { - top: 10, - right: 150, - bottom: 20, - left: 50 - }, - - /** - * A Graph can be collapsed by the user. - */ - toggle: function () { - if (this.enabled) { - this.element.classList.add("disabled"); - this.enabled = false; - } else { - this.element.classList.remove("disabled"); - this.enabled = true; - } - Monitor.resize(); - }, - - /** - * If the container element is resized (e.g. because the window was resized or - * a scrollbar dis/appeared), the graph needs to be resized as well. - */ - resize: function () { - let style = getComputedStyle(this.element), - height = parseFloat(style.height) - this.margin.top - this.margin.bottom, - width = parseFloat(style.width) - this.margin.left - this.margin.right; - - d3.select(this.element).select("svg") - .attr("width", width + this.margin.left) - .attr("height", height + this.margin.top + this.margin.bottom); - - this.x.range([0, width]); - this.y.range([height, 0]); - - this.xelement.attr("transform", "translate(0," + height + ")"); - this.xruler.select("line[stroke-dasharray]").attr("y2", -height); - this.yruler.select("line[stroke-dasharray]").attr("x2", width); - }, - - /** - * If the domain of the Graph's data changes (on the time axis and/or on the - * value axis), the axes' domains need to be updated and the graph items need - * to be rescaled in order to represent all the data. - */ - rescale: function () { - let gettime = v => { return v.time; }, - getvalue = v => { return v.value; }, - ignored = c => { return this.ignored.has(c.id); }; - - let xmin = null, xmax = null, ymin = null, ymax = null; - for (let curve of this.curves.values()) { - if (ignored(curve)) { - continue; - } - if (xmax == null || curve.xmax > xmax) { - xmax = curve.xmax; - } - if (xmin == null || curve.xmin < xmin) { - xmin = curve.xmin; - } - if (ymax == null || curve.ymax > ymax) { - ymax = curve.ymax; - } - if (ymin == null || curve.ymin < ymin) { - ymin = curve.ymin; - } - } - for (let event of this.events.values()) { - if (ignored(event)) { - continue; - } - if (xmax == null || event.xmax > xmax) { - xmax = event.xmax; - } - if (xmin == null || event.xmin < xmin) { - xmin = event.xmin; - } - } - - let oldxdomain = this.x.domain(); - if (xmin != null && xmax != null) { - this.x.domain([xmin, xmax]); - let newxdomain = this.x.domain(); - if (newxdomain[0] !== oldxdomain[0] || newxdomain[1] !== oldxdomain[1]) { - this.xelement.call(this.xaxis); - } - } - - let oldydomain = this.y.domain(); - if (ymin != null && ymax != null) { - this.y.domain([ymin, ymax]).nice(); - let newydomain = this.y.domain(); - if (newydomain[0] !== oldydomain[0] || newydomain[1] !== oldydomain[1]) { - this.yelement.call(this.yaxis); - } - } - }, - - /** - * Add new values to the graph. - */ - update: function (data) { - delete data.graph; - - let time = data.time || Date.now(); - delete data.time; - - let curve = data.curve; - delete data.curve; - - // Single curve value, e.g. { curve: 'memory', value: 42, time: 1234 }. - if ("value" in data) { - this.push(this.curves, curve, [{time: time, value: data.value}]); - delete data.value; - } - - // Several curve values, e.g. { curve: 'memory', values: [{value: 42, time: 1234}] }. - if ("values" in data) { - this.push(this.curves, curve, data.values); - delete data.values; - } - - // Punctual event, e.g. { event: 'gc', time: 1234 }, - // event with duration, e.g. { event: 'jank', duration: 425, time: 1234 }. - if ("event" in data) { - this.push(this.events, data.event, [{time: time, value: data.duration}]); - delete data.event; - delete data.duration; - } - - // Remaining keys are curves, e.g. { time: 1234, memory: 42, battery: 13, temperature: 45 }. - for (let key in data) { - this.push(this.curves, key, [{time: time, value: data[key]}]); - } - - // If no render is currently pending, request one. - if (this.enabled && !this.request) { - this.request = requestAnimationFrame(this.render); - } - }, - - /** - * Insert new data into the graph's data structures. - */ - push: function (collection, id, values) { - - // Note: collection is either `this.curves` or `this.events`. - let item = collection.get(id); - if (!item) { - item = { id: id, values: [], xmin: null, xmax: null, ymin: 0, ymax: null, average: 0 }; - collection.set(id, item); - } - - for (let v of values) { - let time = new Date(v.time), value = +v.value; - // Update the curve/event's domain values. - if (item.xmax == null || time > item.xmax) { - item.xmax = time; - } - if (item.xmin == null || time < item.xmin) { - item.xmin = time; - } - if (item.ymax == null || value > item.ymax) { - item.ymax = value; - } - if (item.ymin == null || value < item.ymin) { - item.ymin = value; - } - // Note: A curve's average is not computed here. Call `graph.averages()`. - item.values.push({ time: time, value: value }); - } - }, - - /** - * Render the SVG graph with curves, events, crosshair and legend. - */ - render: function () { - this.request = null; - this.rescale(); - - - // DATA - - let self = this, - getid = d => { return d.id; }, - gettime = d => { return d.time.getTime(); }, - getline = d => { return self.line(d.values); }, - getcolor = d => { return self.color(d.id); }, - getvalues = d => { return d.values; }, - ignored = d => { return self.ignored.has(d.id); }; - - // Convert our maps to arrays for d3. - let curvedata = [...this.curves.values()], - eventdata = [...this.events.values()], - data = curvedata.concat(eventdata); - - - // CURVES - - // Map curve data to curve elements. - let curves = this.svg.selectAll(".curve").data(curvedata, getid); - - // Create new curves (no element corresponding to the data). - curves.enter().append("g").attr("class", "curve").append("path") - .style("stroke", getcolor); - - // Delete old curves (elements corresponding to data not present anymore). - curves.exit().remove(); - - // Update all curves from data. - this.svg.selectAll(".curve").select("path") - .attr("d", d => { return ignored(d) ? "" : getline(d); }); - - let height = parseFloat(getComputedStyle(this.element).height) - this.margin.top - this.margin.bottom; - - - // EVENTS - - // Map event data to event elements. - let events = this.svg.selectAll(".event-slot").data(eventdata, getid); - - // Create new events. - events.enter().append("g").attr("class", "event-slot"); - - // Remove old events. - events.exit().remove(); - - // Get all occurences of an event, and map its data to them. - let lines = this.svg.selectAll(".event-slot") - .style("stroke", d => { return ignored(d) ? "none" : getcolor(d); }) - .selectAll(".event") - .data(getvalues, gettime); - - // Create new event occurrence. - lines.enter().append("line").attr("class", "event").attr("y2", height); - - // Delete old event occurrence. - lines.exit().remove(); - - // Update all event occurrences from data. - this.svg.selectAll(".event") - .attr("transform", d => { return "translate(" + self.x(d.time) + ",0)"; }); - - - // CROSSHAIR - - // TODO select curves and events, intersect with curves and show values/hovers - // e.g. look like http://code.shutterstock.com/rickshaw/examples/lines.html - - // Update crosshair labels on each axis. - this.xruler.select("text").text(self.xformat(self.x.invert(self.mousex))); - this.yruler.select("text").text(self.yformat(self.y.invert(self.mousey))); - - - // LEGEND - - // Map data to legend elements. - let legends = this.legend.selectAll("label").data(data, getid); - - // Update averages. - legends.attr("title", c => { return "Average: " + self.yformat(c.average); }); - - // Create new legends. - let newlegend = legends.enter().append("label"); - newlegend.append("input").attr("type", "checkbox").attr("checked", "true").on("click", function (c) { - if (ignored(c)) { - this.parentElement.classList.remove("disabled"); - self.ignored.delete(c.id); - } else { - this.parentElement.classList.add("disabled"); - self.ignored.add(c.id); - } - self.update({}); // if no re-render is pending, request one. - }); - newlegend.append("span").attr("class", "legend-color").style("background-color", getcolor); - newlegend.append("span").attr("class", "legend-id").text(getid); - - // Delete old legends. - legends.exit().remove(); - }, - - /** - * Returns a SI value formatter with a given precision. - */ - formatter: function (decimals) { - return value => { - // Don't use sub-unit SI prefixes (milli, micro, etc.). - if (Math.abs(value) < 1) return value.toFixed(decimals); - // SI prefix, e.g. 1234567 will give '1.2M' at precision 1. - let prefix = d3.formatPrefix(value); - return prefix.scale(value).toFixed(decimals) + prefix.symbol; - }; - }, - - /** - * Compute the average of each time series. - */ - averages: function () { - for (let c of this.curves.values()) { - let length = c.values.length; - if (length > 0) { - let total = 0; - c.values.forEach(v => total += v.value); - c.average = (total / length); - } - } - }, - - /** - * Bisect a time serie to find the data point immediately left of `time`. - */ - bisectTime: d3.bisector(d => d.time).left, - - /** - * Get all curve values at a given time. - */ - valuesAt: function (time) { - let values = { time: time }; - - for (let id of this.curves.keys()) { - let curve = this.curves.get(id); - - // Find the closest value just before `time`. - let i = this.bisectTime(curve.values, time); - if (i < 0) { - // Curve starts after `time`, use first value. - values[id] = curve.values[0].value; - } else if (i > curve.values.length - 2) { - // Curve ends before `time`, use last value. - values[id] = curve.values[curve.values.length - 1].value; - } else { - // Curve has two values around `time`, interpolate. - let v1 = curve.values[i], - v2 = curve.values[i + 1], - delta = (time - v1.time) / (v2.time - v1.time); - values[id] = v1.value + (v2.value - v1.time) * delta; - } - } - return values; - } - -}; diff --git a/devtools/client/webide/content/monitor.xhtml b/devtools/client/webide/content/monitor.xhtml deleted file mode 100644 index 552f3826c..000000000 --- a/devtools/client/webide/content/monitor.xhtml +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - %webideDTD; -]> - - - - - - - - - - - - - - -

        &monitor_title;

        - - - diff --git a/devtools/client/webide/content/moz.build b/devtools/client/webide/content/moz.build deleted file mode 100644 index aac3a838c..000000000 --- a/devtools/client/webide/content/moz.build +++ /dev/null @@ -1,7 +0,0 @@ -# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*- -# vim: set filetype=python: -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. - -JAR_MANIFESTS += ['jar.mn'] diff --git a/devtools/client/webide/content/newapp.js b/devtools/client/webide/content/newapp.js deleted file mode 100644 index d47bfabec..000000000 --- a/devtools/client/webide/content/newapp.js +++ /dev/null @@ -1,175 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -"use strict"; - -var Cc = Components.classes; -var Cu = Components.utils; -var Ci = Components.interfaces; - -const {require} = Cu.import("resource://devtools/shared/Loader.jsm", {}); -const {XPCOMUtils} = require("resource://gre/modules/XPCOMUtils.jsm"); -const Services = require("Services"); -const {FileUtils} = require("resource://gre/modules/FileUtils.jsm"); -const {AppProjects} = require("devtools/client/webide/modules/app-projects"); -const {AppManager} = require("devtools/client/webide/modules/app-manager"); -const {getJSON} = require("devtools/client/shared/getjson"); - -XPCOMUtils.defineLazyModuleGetter(this, "ZipUtils", "resource://gre/modules/ZipUtils.jsm"); -XPCOMUtils.defineLazyModuleGetter(this, "Downloads", "resource://gre/modules/Downloads.jsm"); - -const TEMPLATES_URL = "devtools.webide.templatesURL"; - -var gTemplateList = null; - -// See bug 989619 -console.log = console.log.bind(console); -console.warn = console.warn.bind(console); -console.error = console.error.bind(console); - -window.addEventListener("load", function onLoad() { - window.removeEventListener("load", onLoad); - let projectNameNode = document.querySelector("#project-name"); - projectNameNode.addEventListener("input", canValidate, true); - getTemplatesJSON(); -}, true); - -function getTemplatesJSON() { - getJSON(TEMPLATES_URL).then(list => { - if (!Array.isArray(list)) { - throw new Error("JSON response not an array"); - } - if (list.length == 0) { - throw new Error("JSON response is an empty array"); - } - gTemplateList = list; - let templatelistNode = document.querySelector("#templatelist"); - templatelistNode.innerHTML = ""; - for (let template of list) { - let richlistitemNode = document.createElement("richlistitem"); - let imageNode = document.createElement("image"); - imageNode.setAttribute("src", template.icon); - let labelNode = document.createElement("label"); - labelNode.setAttribute("value", template.name); - let descriptionNode = document.createElement("description"); - descriptionNode.textContent = template.description; - let vboxNode = document.createElement("vbox"); - vboxNode.setAttribute("flex", "1"); - richlistitemNode.appendChild(imageNode); - vboxNode.appendChild(labelNode); - vboxNode.appendChild(descriptionNode); - richlistitemNode.appendChild(vboxNode); - templatelistNode.appendChild(richlistitemNode); - } - templatelistNode.selectedIndex = 0; - - /* Chrome mochitest support */ - let testOptions = window.arguments[0].testOptions; - if (testOptions) { - templatelistNode.selectedIndex = testOptions.index; - document.querySelector("#project-name").value = testOptions.name; - doOK(); - } - }, (e) => { - failAndBail("Can't download app templates: " + e); - }); -} - -function failAndBail(msg) { - let promptService = Cc["@mozilla.org/embedcomp/prompt-service;1"].getService(Ci.nsIPromptService); - promptService.alert(window, "error", msg); - window.close(); -} - -function canValidate() { - let projectNameNode = document.querySelector("#project-name"); - let dialogNode = document.querySelector("dialog"); - if (projectNameNode.value.length > 0) { - dialogNode.removeAttribute("buttondisabledaccept"); - } else { - dialogNode.setAttribute("buttondisabledaccept", "true"); - } -} - -function doOK() { - let projectName = document.querySelector("#project-name").value; - - if (!projectName) { - console.error("No project name"); - return false; - } - - if (!gTemplateList) { - console.error("No template index"); - return false; - } - - let templatelistNode = document.querySelector("#templatelist"); - if (templatelistNode.selectedIndex < 0) { - console.error("No template selected"); - return false; - } - - let folder; - - /* Chrome mochitest support */ - let testOptions = window.arguments[0].testOptions; - if (testOptions) { - folder = testOptions.folder; - } else { - let fp = Cc["@mozilla.org/filepicker;1"].createInstance(Ci.nsIFilePicker); - fp.init(window, "Select directory where to create app directory", Ci.nsIFilePicker.modeGetFolder); - let res = fp.show(); - if (res == Ci.nsIFilePicker.returnCancel) { - console.error("No directory selected"); - return false; - } - folder = fp.file; - } - - // Create subfolder with fs-friendly name of project - let subfolder = projectName.replace(/[\\/:*?"<>|]/g, "").toLowerCase(); - let win = Services.wm.getMostRecentWindow("devtools:webide"); - folder.append(subfolder); - - try { - folder.create(Ci.nsIFile.DIRECTORY_TYPE, FileUtils.PERMS_DIRECTORY); - } catch (e) { - win.UI.reportError("error_folderCreationFailed"); - window.close(); - return false; - } - - // Download boilerplate zip - let template = gTemplateList[templatelistNode.selectedIndex]; - let source = template.file; - let target = folder.clone(); - target.append(subfolder + ".zip"); - - let bail = (e) => { - console.error(e); - window.close(); - }; - - Downloads.fetch(source, target).then(() => { - ZipUtils.extractFiles(target, folder); - target.remove(false); - AppProjects.addPackaged(folder).then((project) => { - window.arguments[0].location = project.location; - AppManager.validateAndUpdateProject(project).then(() => { - if (project.manifest) { - project.manifest.name = projectName; - AppManager.writeManifest(project).then(() => { - AppManager.validateAndUpdateProject(project).then( - () => {window.close();}, bail); - }, bail); - } else { - bail("Manifest not found"); - } - }, bail); - }, bail); - }, bail); - - return false; -} diff --git a/devtools/client/webide/content/newapp.xul b/devtools/client/webide/content/newapp.xul deleted file mode 100644 index 7ff083519..000000000 --- a/devtools/client/webide/content/newapp.xul +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - %webideDTD; -]> - - - - - - - - diff --git a/devtools/client/webide/content/permissionstable.js b/devtools/client/webide/content/permissionstable.js deleted file mode 100644 index 22c74bd0d..000000000 --- a/devtools/client/webide/content/permissionstable.js +++ /dev/null @@ -1,78 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -var Cu = Components.utils; -const {require} = Cu.import("resource://devtools/shared/Loader.jsm", {}); -const Services = require("Services"); -const {AppManager} = require("devtools/client/webide/modules/app-manager"); -const {Connection} = require("devtools/shared/client/connection-manager"); - -window.addEventListener("load", function onLoad() { - window.removeEventListener("load", onLoad); - document.querySelector("#close").onclick = CloseUI; - AppManager.on("app-manager-update", OnAppManagerUpdate); - BuildUI(); -}, true); - -window.addEventListener("unload", function onUnload() { - window.removeEventListener("unload", onUnload); - AppManager.off("app-manager-update", OnAppManagerUpdate); -}); - -function CloseUI() { - window.parent.UI.openProject(); -} - -function OnAppManagerUpdate(event, what) { - if (what == "connection" || what == "runtime-global-actors") { - BuildUI(); - } -} - -function generateFields(json) { - let table = document.querySelector("table"); - let permissionsTable = json.rawPermissionsTable; - for (let name in permissionsTable) { - let tr = document.createElement("tr"); - tr.className = "line"; - let td = document.createElement("td"); - td.textContent = name; - tr.appendChild(td); - for (let type of ["app", "privileged", "certified"]) { - let td = document.createElement("td"); - if (permissionsTable[name][type] == json.ALLOW_ACTION) { - td.textContent = "✓"; - td.className = "permallow"; - } - if (permissionsTable[name][type] == json.PROMPT_ACTION) { - td.textContent = "!"; - td.className = "permprompt"; - } - if (permissionsTable[name][type] == json.DENY_ACTION) { - td.textContent = "✕"; - td.className = "permdeny"; - } - tr.appendChild(td); - } - table.appendChild(tr); - } -} - -var getRawPermissionsTablePromise; // Used by tests -function BuildUI() { - let table = document.querySelector("table"); - let lines = table.querySelectorAll(".line"); - for (let line of lines) { - line.remove(); - } - - if (AppManager.connection && - AppManager.connection.status == Connection.Status.CONNECTED && - AppManager.deviceFront) { - getRawPermissionsTablePromise = AppManager.deviceFront.getRawPermissionsTable() - .then(json => generateFields(json)); - } else { - CloseUI(); - } -} diff --git a/devtools/client/webide/content/permissionstable.xhtml b/devtools/client/webide/content/permissionstable.xhtml deleted file mode 100644 index 361cfece8..000000000 --- a/devtools/client/webide/content/permissionstable.xhtml +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - %webideDTD; -]> - - - - - - - - - - - - -

        &permissionstable_title;

        - - - - - - - - -
        &permissionstable_name_header;type:webtype:privilegedtype:certified
        - - diff --git a/devtools/client/webide/content/prefs.js b/devtools/client/webide/content/prefs.js deleted file mode 100644 index 75f6233ba..000000000 --- a/devtools/client/webide/content/prefs.js +++ /dev/null @@ -1,108 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -"use strict"; - -const Cu = Components.utils; -const {Services} = Cu.import("resource://gre/modules/Services.jsm", {}); - -window.addEventListener("load", function onLoad() { - window.removeEventListener("load", onLoad); - - // Listen to preference changes - let inputs = document.querySelectorAll("[data-pref]"); - for (let i of inputs) { - let pref = i.dataset.pref; - Services.prefs.addObserver(pref, FillForm, false); - i.addEventListener("change", SaveForm, false); - } - - // Buttons - document.querySelector("#close").onclick = CloseUI; - document.querySelector("#restore").onclick = RestoreDefaults; - document.querySelector("#manageComponents").onclick = ShowAddons; - - // Initialize the controls - FillForm(); - -}, true); - -window.addEventListener("unload", function onUnload() { - window.removeEventListener("unload", onUnload); - let inputs = document.querySelectorAll("[data-pref]"); - for (let i of inputs) { - let pref = i.dataset.pref; - i.removeEventListener("change", SaveForm, false); - Services.prefs.removeObserver(pref, FillForm, false); - } -}, true); - -function CloseUI() { - window.parent.UI.openProject(); -} - -function ShowAddons() { - window.parent.Cmds.showAddons(); -} - -function FillForm() { - let inputs = document.querySelectorAll("[data-pref]"); - for (let i of inputs) { - let pref = i.dataset.pref; - let val = GetPref(pref); - if (i.type == "checkbox") { - i.checked = val; - } else { - i.value = val; - } - } -} - -function SaveForm(e) { - let inputs = document.querySelectorAll("[data-pref]"); - for (let i of inputs) { - let pref = i.dataset.pref; - if (i.type == "checkbox") { - SetPref(pref, i.checked); - } else { - SetPref(pref, i.value); - } - } -} - -function GetPref(name) { - let type = Services.prefs.getPrefType(name); - switch (type) { - case Services.prefs.PREF_STRING: - return Services.prefs.getCharPref(name); - case Services.prefs.PREF_INT: - return Services.prefs.getIntPref(name); - case Services.prefs.PREF_BOOL: - return Services.prefs.getBoolPref(name); - default: - throw new Error("Unknown type"); - } -} - -function SetPref(name, value) { - let type = Services.prefs.getPrefType(name); - switch (type) { - case Services.prefs.PREF_STRING: - return Services.prefs.setCharPref(name, value); - case Services.prefs.PREF_INT: - return Services.prefs.setIntPref(name, value); - case Services.prefs.PREF_BOOL: - return Services.prefs.setBoolPref(name, value); - default: - throw new Error("Unknown type"); - } -} - -function RestoreDefaults() { - let inputs = document.querySelectorAll("[data-pref]"); - for (let i of inputs) { - let pref = i.dataset.pref; - Services.prefs.clearUserPref(pref); - } -} diff --git a/devtools/client/webide/content/prefs.xhtml b/devtools/client/webide/content/prefs.xhtml deleted file mode 100644 index 726ca772c..000000000 --- a/devtools/client/webide/content/prefs.xhtml +++ /dev/null @@ -1,112 +0,0 @@ - - - - - - %webideDTD; -]> - - - - - - - - - - - -

        &prefs_title;

        - -

        &prefs_general_title;

        - -
          -
        • - -
        • -
        • - -
        • -
        • - -
        • -
        • - -
        • -
        - -

        &prefs_editor_title;

        - -
          -
        • - -
        • -
        • - -
        • -
        • - -
        • -
        • - -
        • -
        • - -
        • -
        • - -
        • -
        • - -
        • -
        - - - diff --git a/devtools/client/webide/content/project-listing.js b/devtools/client/webide/content/project-listing.js deleted file mode 100644 index 5641f6c0c..000000000 --- a/devtools/client/webide/content/project-listing.js +++ /dev/null @@ -1,42 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* eslint-env browser */ - -var Cu = Components.utils; -const {require} = Cu.import("resource://devtools/shared/Loader.jsm", {}); -const ProjectList = require("devtools/client/webide/modules/project-list"); - -var projectList = new ProjectList(window, window.parent); - -window.addEventListener("load", function onLoad() { - window.removeEventListener("load", onLoad, true); - document.getElementById("new-app").onclick = CreateNewApp; - document.getElementById("hosted-app").onclick = ImportHostedApp; - document.getElementById("packaged-app").onclick = ImportPackagedApp; - document.getElementById("refresh-tabs").onclick = RefreshTabs; - projectList.update(); - projectList.updateCommands(); -}, true); - -window.addEventListener("unload", function onUnload() { - window.removeEventListener("unload", onUnload); - projectList.destroy(); -}); - -function RefreshTabs() { - projectList.refreshTabs(); -} - -function CreateNewApp() { - projectList.newApp(); -} - -function ImportHostedApp() { - projectList.importHostedApp(); -} - -function ImportPackagedApp() { - projectList.importPackagedApp(); -} diff --git a/devtools/client/webide/content/project-listing.xhtml b/devtools/client/webide/content/project-listing.xhtml deleted file mode 100644 index 337befe5d..000000000 --- a/devtools/client/webide/content/project-listing.xhtml +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - %webideDTD; -]> - - - - - - - - -
        -
        - - - - -
        - -
        - -
        -
        -
        - - diff --git a/devtools/client/webide/content/project-panel.js b/devtools/client/webide/content/project-panel.js deleted file mode 100644 index 54eab8251..000000000 --- a/devtools/client/webide/content/project-panel.js +++ /dev/null @@ -1,11 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -var ProjectPanel = { - // TODO: Expand function to save toggle state. - toggleSidebar: function () { - document.querySelector("#project-listing-panel").setAttribute("sidebar-displayed", true); - document.querySelector("#project-listing-splitter").setAttribute("sidebar-displayed", true); - } -}; diff --git a/devtools/client/webide/content/runtime-listing.js b/devtools/client/webide/content/runtime-listing.js deleted file mode 100644 index 0a1a40a2a..000000000 --- a/devtools/client/webide/content/runtime-listing.js +++ /dev/null @@ -1,66 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -var Cu = Components.utils; -const {require} = Cu.import("resource://devtools/shared/Loader.jsm", {}); -const RuntimeList = require("devtools/client/webide/modules/runtime-list"); - -var runtimeList = new RuntimeList(window, window.parent); - -window.addEventListener("load", function onLoad() { - window.removeEventListener("load", onLoad, true); - document.getElementById("runtime-screenshot").onclick = TakeScreenshot; - document.getElementById("runtime-permissions").onclick = ShowPermissionsTable; - document.getElementById("runtime-details").onclick = ShowRuntimeDetails; - document.getElementById("runtime-disconnect").onclick = DisconnectRuntime; - document.getElementById("runtime-preferences").onclick = ShowDevicePreferences; - document.getElementById("runtime-settings").onclick = ShowSettings; - document.getElementById("runtime-panel-installsimulator").onclick = ShowAddons; - document.getElementById("runtime-panel-noadbhelper").onclick = ShowAddons; - document.getElementById("runtime-panel-nousbdevice").onclick = ShowTroubleShooting; - document.getElementById("refresh-devices").onclick = RefreshScanners; - runtimeList.update(); - runtimeList.updateCommands(); -}, true); - -window.addEventListener("unload", function onUnload() { - window.removeEventListener("unload", onUnload); - runtimeList.destroy(); -}); - -function TakeScreenshot() { - runtimeList.takeScreenshot(); -} - -function ShowRuntimeDetails() { - runtimeList.showRuntimeDetails(); -} - -function ShowPermissionsTable() { - runtimeList.showPermissionsTable(); -} - -function ShowDevicePreferences() { - runtimeList.showDevicePreferences(); -} - -function ShowSettings() { - runtimeList.showSettings(); -} - -function RefreshScanners() { - runtimeList.refreshScanners(); -} - -function DisconnectRuntime() { - window.parent.Cmds.disconnectRuntime(); -} - -function ShowAddons() { - runtimeList.showAddons(); -} - -function ShowTroubleShooting() { - runtimeList.showTroubleShooting(); -} diff --git a/devtools/client/webide/content/runtime-listing.xhtml b/devtools/client/webide/content/runtime-listing.xhtml deleted file mode 100644 index f648fac12..000000000 --- a/devtools/client/webide/content/runtime-listing.xhtml +++ /dev/null @@ -1,45 +0,0 @@ - - - - - - %webideDTD; -]> - - - - - - - - -
        -
        - - - -
        - -
        - -
        - - -
        -
        - - - - - - -
        -
        -
        - - diff --git a/devtools/client/webide/content/runtime-panel.js b/devtools/client/webide/content/runtime-panel.js deleted file mode 100644 index 3646fa15c..000000000 --- a/devtools/client/webide/content/runtime-panel.js +++ /dev/null @@ -1,11 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -var RuntimePanel = { - // TODO: Expand function to save toggle state. - toggleSidebar: function () { - document.querySelector("#runtime-listing-panel").setAttribute("sidebar-displayed", true); - document.querySelector("#runtime-listing-splitter").setAttribute("sidebar-displayed", true); - } -}; diff --git a/devtools/client/webide/content/runtimedetails.js b/devtools/client/webide/content/runtimedetails.js deleted file mode 100644 index dea423e81..000000000 --- a/devtools/client/webide/content/runtimedetails.js +++ /dev/null @@ -1,153 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -var Cu = Components.utils; -const {require} = Cu.import("resource://devtools/shared/Loader.jsm", {}); -const Services = require("Services"); -const {AppManager} = require("devtools/client/webide/modules/app-manager"); -const {Connection} = require("devtools/shared/client/connection-manager"); -const {RuntimeTypes} = require("devtools/client/webide/modules/runtimes"); -const Strings = Services.strings.createBundle("chrome://devtools/locale/webide.properties"); - -const UNRESTRICTED_HELP_URL = "https://developer.mozilla.org/docs/Tools/WebIDE/Running_and_debugging_apps#Unrestricted_app_debugging_%28including_certified_apps_main_process_etc.%29"; - -window.addEventListener("load", function onLoad() { - window.removeEventListener("load", onLoad); - document.querySelector("#close").onclick = CloseUI; - document.querySelector("#devtools-check button").onclick = EnableCertApps; - document.querySelector("#adb-check button").onclick = RootADB; - document.querySelector("#unrestricted-privileges").onclick = function () { - window.parent.UI.openInBrowser(UNRESTRICTED_HELP_URL); - }; - AppManager.on("app-manager-update", OnAppManagerUpdate); - BuildUI(); - CheckLockState(); -}, true); - -window.addEventListener("unload", function onUnload() { - window.removeEventListener("unload", onUnload); - AppManager.off("app-manager-update", OnAppManagerUpdate); -}); - -function CloseUI() { - window.parent.UI.openProject(); -} - -function OnAppManagerUpdate(event, what) { - if (what == "connection" || what == "runtime-global-actors") { - BuildUI(); - CheckLockState(); - } -} - -function generateFields(json) { - let table = document.querySelector("table"); - for (let name in json) { - let tr = document.createElement("tr"); - let td = document.createElement("td"); - td.textContent = name; - tr.appendChild(td); - td = document.createElement("td"); - td.textContent = json[name]; - tr.appendChild(td); - table.appendChild(tr); - } -} - -var getDescriptionPromise; // Used by tests -function BuildUI() { - let table = document.querySelector("table"); - table.innerHTML = ""; - if (AppManager.connection && - AppManager.connection.status == Connection.Status.CONNECTED && - AppManager.deviceFront) { - getDescriptionPromise = AppManager.deviceFront.getDescription() - .then(json => generateFields(json)); - } else { - CloseUI(); - } -} - -function CheckLockState() { - let adbCheckResult = document.querySelector("#adb-check > .yesno"); - let devtoolsCheckResult = document.querySelector("#devtools-check > .yesno"); - let flipCertPerfButton = document.querySelector("#devtools-check button"); - let adbRootButton = document.querySelector("#adb-check button"); - let flipCertPerfAction = document.querySelector("#devtools-check > .action"); - let adbRootAction = document.querySelector("#adb-check > .action"); - - let sYes = Strings.GetStringFromName("runtimedetails_checkyes"); - let sNo = Strings.GetStringFromName("runtimedetails_checkno"); - let sUnknown = Strings.GetStringFromName("runtimedetails_checkunknown"); - let sNotUSB = Strings.GetStringFromName("runtimedetails_notUSBDevice"); - - flipCertPerfButton.setAttribute("disabled", "true"); - flipCertPerfAction.setAttribute("hidden", "true"); - adbRootAction.setAttribute("hidden", "true"); - - adbCheckResult.textContent = sUnknown; - devtoolsCheckResult.textContent = sUnknown; - - if (AppManager.connection && - AppManager.connection.status == Connection.Status.CONNECTED) { - - // ADB check - if (AppManager.selectedRuntime.type === RuntimeTypes.USB) { - let device = AppManager.selectedRuntime.device; - if (device && device.summonRoot) { - device.isRoot().then(isRoot => { - if (isRoot) { - adbCheckResult.textContent = sYes; - flipCertPerfButton.removeAttribute("disabled"); - } else { - adbCheckResult.textContent = sNo; - adbRootAction.removeAttribute("hidden"); - } - }, e => console.error(e)); - } else { - adbCheckResult.textContent = sUnknown; - } - } else { - adbCheckResult.textContent = sNotUSB; - } - - // forbid-certified-apps check - try { - let prefFront = AppManager.preferenceFront; - prefFront.getBoolPref("devtools.debugger.forbid-certified-apps").then(isForbidden => { - if (isForbidden) { - devtoolsCheckResult.textContent = sNo; - flipCertPerfAction.removeAttribute("hidden"); - } else { - devtoolsCheckResult.textContent = sYes; - } - }, e => console.error(e)); - } catch (e) { - // Exception. pref actor is only accessible if forbird-certified-apps is false - devtoolsCheckResult.textContent = sNo; - flipCertPerfAction.removeAttribute("hidden"); - } - - } - -} - -function EnableCertApps() { - let device = AppManager.selectedRuntime.device; - // TODO: Remove `network.disable.ipc.security` once bug 1125916 is fixed. - device.shell( - "stop b2g && " + - "cd /data/b2g/mozilla/*.default/ && " + - "echo 'user_pref(\"devtools.debugger.forbid-certified-apps\", false);' >> prefs.js && " + - "echo 'user_pref(\"dom.apps.developer_mode\", true);' >> prefs.js && " + - "echo 'user_pref(\"network.disable.ipc.security\", true);' >> prefs.js && " + - "echo 'user_pref(\"dom.webcomponents.enabled\", true);' >> prefs.js && " + - "start b2g" - ); -} - -function RootADB() { - let device = AppManager.selectedRuntime.device; - device.summonRoot().then(CheckLockState, (e) => console.error(e)); -} diff --git a/devtools/client/webide/content/runtimedetails.xhtml b/devtools/client/webide/content/runtimedetails.xhtml deleted file mode 100644 index b2f74728a..000000000 --- a/devtools/client/webide/content/runtimedetails.xhtml +++ /dev/null @@ -1,46 +0,0 @@ - - - - - - %webideDTD; -]> - - - - - - - - - - - - -

        &runtimedetails_title;

        - -
        -

        - &runtimedetails_adbIsRoot; -

        - - &runtimedetails_ADBRootWarning; -
        -

        -

        - &runtimedetails_unrestrictedPrivileges; -

        - - &runtimedetails_privilegesWarning; -
        -

        -
        - -
        - - diff --git a/devtools/client/webide/content/simulator.js b/devtools/client/webide/content/simulator.js deleted file mode 100644 index ddc1cbed1..000000000 --- a/devtools/client/webide/content/simulator.js +++ /dev/null @@ -1,352 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -var Cu = Components.utils; -var Ci = Components.interfaces; - -const { require } = Cu.import("resource://devtools/shared/Loader.jsm", {}); -const { getDevices, getDeviceString } = require("devtools/client/shared/devices"); -const { Simulators, Simulator } = require("devtools/client/webide/modules/simulators"); -const Services = require("Services"); -const EventEmitter = require("devtools/shared/event-emitter"); -const promise = require("promise"); -const utils = require("devtools/client/webide/modules/utils"); - -const Strings = Services.strings.createBundle("chrome://devtools/locale/webide.properties"); - -var SimulatorEditor = { - - // Available Firefox OS Simulator addons (key: `addon.id`). - _addons: {}, - - // Available device simulation profiles (key: `device.name`). - _devices: {}, - - // The names of supported simulation options. - _deviceOptions: [], - - // The
        element used to edit Simulator options. - _form: null, - - // The Simulator object being edited. - _simulator: null, - - // Generate the dynamic form elements. - init() { - let promises = []; - - // Grab the element. - let form = this._form; - if (!form) { - // This is the first time we run `init()`, bootstrap some things. - form = this._form = document.querySelector("#simulator-editor"); - form.addEventListener("change", this.update.bind(this)); - Simulators.on("configure", (e, simulator) => { this.edit(simulator); }); - // Extract the list of device simulation options we'll support. - let deviceFields = form.querySelectorAll("*[data-device]"); - this._deviceOptions = Array.map(deviceFields, field => field.name); - } - - // Append a new
        - - - diff --git a/devtools/client/webide/content/webide.js b/devtools/client/webide/content/webide.js deleted file mode 100644 index c222332e3..000000000 --- a/devtools/client/webide/content/webide.js +++ /dev/null @@ -1,1157 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -var Cc = Components.classes; -var Cu = Components.utils; -var Ci = Components.interfaces; - -const {require} = Cu.import("resource://devtools/shared/Loader.jsm", {}); -const {gDevTools} = require("devtools/client/framework/devtools"); -const {gDevToolsBrowser} = require("devtools/client/framework/devtools-browser"); -const {Toolbox} = require("devtools/client/framework/toolbox"); -const Services = require("Services"); -const {AppProjects} = require("devtools/client/webide/modules/app-projects"); -const {Connection} = require("devtools/shared/client/connection-manager"); -const {AppManager} = require("devtools/client/webide/modules/app-manager"); -const EventEmitter = require("devtools/shared/event-emitter"); -const promise = require("promise"); -const ProjectEditor = require("devtools/client/projecteditor/lib/projecteditor"); -const {GetAvailableAddons} = require("devtools/client/webide/modules/addons"); -const {getJSON} = require("devtools/client/shared/getjson"); -const utils = require("devtools/client/webide/modules/utils"); -const Telemetry = require("devtools/client/shared/telemetry"); -const {RuntimeScanners} = require("devtools/client/webide/modules/runtimes"); -const {showDoorhanger} = require("devtools/client/shared/doorhanger"); -const {Simulators} = require("devtools/client/webide/modules/simulators"); -const {Task} = require("devtools/shared/task"); - -const Strings = Services.strings.createBundle("chrome://devtools/locale/webide.properties"); - -const HTML = "http://www.w3.org/1999/xhtml"; -const HELP_URL = "https://developer.mozilla.org/docs/Tools/WebIDE/Troubleshooting"; - -const MAX_ZOOM = 1.4; -const MIN_ZOOM = 0.6; - -const MS_PER_DAY = 86400000; - -[["AppManager", AppManager], - ["AppProjects", AppProjects], - ["Connection", Connection]].forEach(([key, value]) => { - Object.defineProperty(this, key, { - value: value, - enumerable: true, - writable: false - }); - }); - -// Download remote resources early -getJSON("devtools.webide.addonsURL"); -getJSON("devtools.webide.templatesURL"); -getJSON("devtools.devices.url"); - -// See bug 989619 -console.log = console.log.bind(console); -console.warn = console.warn.bind(console); -console.error = console.error.bind(console); - -window.addEventListener("load", function onLoad() { - window.removeEventListener("load", onLoad); - UI.init(); -}); - -window.addEventListener("unload", function onUnload() { - window.removeEventListener("unload", onUnload); - UI.destroy(); -}); - -var UI = { - init: function () { - this._telemetry = new Telemetry(); - this._telemetry.toolOpened("webide"); - - AppManager.init(); - - this.appManagerUpdate = this.appManagerUpdate.bind(this); - AppManager.on("app-manager-update", this.appManagerUpdate); - - Cmds.showProjectPanel(); - Cmds.showRuntimePanel(); - - this.updateCommands(); - - this.onfocus = this.onfocus.bind(this); - window.addEventListener("focus", this.onfocus, true); - - AppProjects.load().then(() => { - this.autoSelectProject(); - }, e => { - console.error(e); - this.reportError("error_appProjectsLoadFailed"); - }); - - // Auto install the ADB Addon Helper and Tools Adapters. Only once. - // If the user decides to uninstall any of this addon, we won't install it again. - let autoinstallADBHelper = Services.prefs.getBoolPref("devtools.webide.autoinstallADBHelper"); - let autoinstallFxdtAdapters = Services.prefs.getBoolPref("devtools.webide.autoinstallFxdtAdapters"); - if (autoinstallADBHelper) { - GetAvailableAddons().then(addons => { - addons.adb.install(); - }, console.error); - } - if (autoinstallFxdtAdapters) { - GetAvailableAddons().then(addons => { - addons.adapters.install(); - }, console.error); - } - Services.prefs.setBoolPref("devtools.webide.autoinstallADBHelper", false); - Services.prefs.setBoolPref("devtools.webide.autoinstallFxdtAdapters", false); - - if (Services.prefs.getBoolPref("devtools.webide.widget.autoinstall") && - !Services.prefs.getBoolPref("devtools.webide.widget.enabled")) { - Services.prefs.setBoolPref("devtools.webide.widget.enabled", true); - gDevToolsBrowser.moveWebIDEWidgetInNavbar(); - } - - this.setupDeck(); - - this.contentViewer = window.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIWebNavigation) - .QueryInterface(Ci.nsIDocShell) - .contentViewer; - this.contentViewer.fullZoom = Services.prefs.getCharPref("devtools.webide.zoom"); - - gDevToolsBrowser.isWebIDEInitialized.resolve(); - - this.configureSimulator = this.configureSimulator.bind(this); - Simulators.on("configure", this.configureSimulator); - }, - - destroy: function () { - window.removeEventListener("focus", this.onfocus, true); - AppManager.off("app-manager-update", this.appManagerUpdate); - AppManager.destroy(); - Simulators.off("configure", this.configureSimulator); - this.updateConnectionTelemetry(); - this._telemetry.toolClosed("webide"); - this._telemetry.toolClosed("webideProjectEditor"); - this._telemetry.destroy(); - }, - - canCloseProject: function () { - if (this.projecteditor) { - return this.projecteditor.confirmUnsaved(); - } - return true; - }, - - onfocus: function () { - // Because we can't track the activity in the folder project, - // we need to validate the project regularly. Let's assume that - // if a modification happened, it happened when the window was - // not focused. - if (AppManager.selectedProject && - AppManager.selectedProject.type != "mainProcess" && - AppManager.selectedProject.type != "runtimeApp" && - AppManager.selectedProject.type != "tab") { - AppManager.validateAndUpdateProject(AppManager.selectedProject); - } - - // Hook to display promotional Developer Edition doorhanger. Only displayed once. - // Hooked into the `onfocus` event because sometimes does not work - // when run at the end of `init`. ¯\(°_o)/¯ - showDoorhanger({ window, type: "deveditionpromo", anchor: document.querySelector("#deck") }); - }, - - appManagerUpdate: function (event, what, details) { - // Got a message from app-manager.js - // See AppManager.update() for descriptions of what these events mean. - switch (what) { - case "runtime-list": - this.autoConnectRuntime(); - break; - case "connection": - this.updateRuntimeButton(); - this.updateCommands(); - this.updateConnectionTelemetry(); - break; - case "before-project": - if (!this.canCloseProject()) { - details.cancel(); - } - break; - case "project": - this._updatePromise = Task.spawn(function* () { - UI.updateTitle(); - yield UI.destroyToolbox(); - UI.updateCommands(); - UI.openProject(); - yield UI.autoStartProject(); - UI.autoOpenToolbox(); - UI.saveLastSelectedProject(); - UI.updateRemoveProjectButton(); - }); - return; - case "project-started": - this.updateCommands(); - UI.autoOpenToolbox(); - break; - case "project-stopped": - UI.destroyToolbox(); - this.updateCommands(); - break; - case "runtime-global-actors": - // Check runtime version only on runtime-global-actors, - // as we expect to use device actor - this.checkRuntimeVersion(); - this.updateCommands(); - break; - case "runtime-details": - this.updateRuntimeButton(); - break; - case "runtime": - this.updateRuntimeButton(); - this.saveLastConnectedRuntime(); - break; - case "project-validated": - this.updateTitle(); - this.updateCommands(); - this.updateProjectEditorHeader(); - break; - case "install-progress": - this.updateProgress(Math.round(100 * details.bytesSent / details.totalBytes)); - break; - case "runtime-targets": - this.autoSelectProject(); - break; - case "pre-package": - this.prePackageLog(details); - break; - } - this._updatePromise = promise.resolve(); - }, - - configureSimulator: function (event, simulator) { - UI.selectDeckPanel("simulator"); - }, - - openInBrowser: function (url) { - // Open a URL in a Firefox window - let mainWindow = Services.wm.getMostRecentWindow(gDevTools.chromeWindowType); - if (mainWindow) { - mainWindow.openUILinkIn(url, "tab"); - mainWindow.focus() - } else { - window.open(url); - } - }, - - updateTitle: function () { - let project = AppManager.selectedProject; - if (project) { - window.document.title = Strings.formatStringFromName("title_app", [project.name], 1); - } else { - window.document.title = Strings.GetStringFromName("title_noApp"); - } - }, - - /** ******** BUSY UI **********/ - - _busyTimeout: null, - _busyOperationDescription: null, - _busyPromise: null, - - updateProgress: function (percent) { - let progress = document.querySelector("#action-busy-determined"); - progress.mode = "determined"; - progress.value = percent; - this.setupBusyTimeout(); - }, - - busy: function () { - let win = document.querySelector("window"); - win.classList.add("busy"); - win.classList.add("busy-undetermined"); - this.updateCommands(); - this.update("busy"); - }, - - unbusy: function () { - let win = document.querySelector("window"); - win.classList.remove("busy"); - win.classList.remove("busy-determined"); - win.classList.remove("busy-undetermined"); - this.updateCommands(); - this.update("unbusy"); - this._busyPromise = null; - }, - - setupBusyTimeout: function () { - this.cancelBusyTimeout(); - this._busyTimeout = setTimeout(() => { - this.unbusy(); - UI.reportError("error_operationTimeout", this._busyOperationDescription); - }, Services.prefs.getIntPref("devtools.webide.busyTimeout")); - }, - - cancelBusyTimeout: function () { - clearTimeout(this._busyTimeout); - }, - - busyWithProgressUntil: function (promise, operationDescription) { - let busy = this.busyUntil(promise, operationDescription); - let win = document.querySelector("window"); - let progress = document.querySelector("#action-busy-determined"); - progress.mode = "undetermined"; - win.classList.add("busy-determined"); - win.classList.remove("busy-undetermined"); - return busy; - }, - - busyUntil: function (promise, operationDescription) { - // Freeze the UI until the promise is resolved. A timeout will unfreeze the - // UI, just in case the promise never gets resolved. - this._busyPromise = promise; - this._busyOperationDescription = operationDescription; - this.setupBusyTimeout(); - this.busy(); - promise.then(() => { - this.cancelBusyTimeout(); - this.unbusy(); - }, (e) => { - let message; - if (e && e.error && e.message) { - // Some errors come from fronts that are not based on protocol.js. - // Errors are not translated to strings. - message = operationDescription + " (" + e.error + "): " + e.message; - } else { - message = operationDescription + (e ? (": " + e) : ""); - } - this.cancelBusyTimeout(); - let operationCanceled = e && e.canceled; - if (!operationCanceled) { - UI.reportError("error_operationFail", message); - if (e) { - console.error(e); - } - } - this.unbusy(); - }); - return promise; - }, - - reportError: function (l10nProperty, ...l10nArgs) { - let text; - - if (l10nArgs.length > 0) { - text = Strings.formatStringFromName(l10nProperty, l10nArgs, l10nArgs.length); - } else { - text = Strings.GetStringFromName(l10nProperty); - } - - console.error(text); - - let buttons = [{ - label: Strings.GetStringFromName("notification_showTroubleShooting_label"), - accessKey: Strings.GetStringFromName("notification_showTroubleShooting_accesskey"), - callback: function () { - Cmds.showTroubleShooting(); - } - }]; - - let nbox = document.querySelector("#notificationbox"); - nbox.removeAllNotifications(true); - nbox.appendNotification(text, "webide:errornotification", null, - nbox.PRIORITY_WARNING_LOW, buttons); - }, - - dismissErrorNotification: function () { - let nbox = document.querySelector("#notificationbox"); - nbox.removeAllNotifications(true); - }, - - /** ******** COMMANDS **********/ - - /** - * This module emits various events when state changes occur. - * - * The events this module may emit include: - * busy: - * The window is currently busy and certain UI functions may be disabled. - * unbusy: - * The window is not busy and certain UI functions may be re-enabled. - */ - update: function (what, details) { - this.emit("webide-update", what, details); - }, - - updateCommands: function () { - // Action commands - let playCmd = document.querySelector("#cmd_play"); - let stopCmd = document.querySelector("#cmd_stop"); - let debugCmd = document.querySelector("#cmd_toggleToolbox"); - let playButton = document.querySelector("#action-button-play"); - let projectPanelCmd = document.querySelector("#cmd_showProjectPanel"); - - if (document.querySelector("window").classList.contains("busy")) { - playCmd.setAttribute("disabled", "true"); - stopCmd.setAttribute("disabled", "true"); - debugCmd.setAttribute("disabled", "true"); - projectPanelCmd.setAttribute("disabled", "true"); - return; - } - - if (!AppManager.selectedProject || !AppManager.connected) { - playCmd.setAttribute("disabled", "true"); - stopCmd.setAttribute("disabled", "true"); - debugCmd.setAttribute("disabled", "true"); - } else { - let isProjectRunning = AppManager.isProjectRunning(); - if (isProjectRunning) { - playButton.classList.add("reload"); - stopCmd.removeAttribute("disabled"); - debugCmd.removeAttribute("disabled"); - } else { - playButton.classList.remove("reload"); - stopCmd.setAttribute("disabled", "true"); - debugCmd.setAttribute("disabled", "true"); - } - - // If connected and a project is selected - if (AppManager.selectedProject.type == "runtimeApp") { - playCmd.removeAttribute("disabled"); - } else if (AppManager.selectedProject.type == "tab") { - playCmd.removeAttribute("disabled"); - stopCmd.setAttribute("disabled", "true"); - } else if (AppManager.selectedProject.type == "mainProcess") { - playCmd.setAttribute("disabled", "true"); - stopCmd.setAttribute("disabled", "true"); - } else { - if (AppManager.selectedProject.errorsCount == 0 && - AppManager.runtimeCanHandleApps()) { - playCmd.removeAttribute("disabled"); - } else { - playCmd.setAttribute("disabled", "true"); - } - } - } - - // Runtime commands - let monitorCmd = document.querySelector("#cmd_showMonitor"); - let screenshotCmd = document.querySelector("#cmd_takeScreenshot"); - let permissionsCmd = document.querySelector("#cmd_showPermissionsTable"); - let detailsCmd = document.querySelector("#cmd_showRuntimeDetails"); - let disconnectCmd = document.querySelector("#cmd_disconnectRuntime"); - let devicePrefsCmd = document.querySelector("#cmd_showDevicePrefs"); - let settingsCmd = document.querySelector("#cmd_showSettings"); - - if (AppManager.connected) { - if (AppManager.deviceFront) { - monitorCmd.removeAttribute("disabled"); - detailsCmd.removeAttribute("disabled"); - permissionsCmd.removeAttribute("disabled"); - screenshotCmd.removeAttribute("disabled"); - } - if (AppManager.preferenceFront) { - devicePrefsCmd.removeAttribute("disabled"); - } - if (AppManager.settingsFront) { - settingsCmd.removeAttribute("disabled"); - } - disconnectCmd.removeAttribute("disabled"); - } else { - monitorCmd.setAttribute("disabled", "true"); - detailsCmd.setAttribute("disabled", "true"); - permissionsCmd.setAttribute("disabled", "true"); - screenshotCmd.setAttribute("disabled", "true"); - disconnectCmd.setAttribute("disabled", "true"); - devicePrefsCmd.setAttribute("disabled", "true"); - settingsCmd.setAttribute("disabled", "true"); - } - - let runtimePanelButton = document.querySelector("#runtime-panel-button"); - - if (AppManager.connected) { - runtimePanelButton.setAttribute("active", "true"); - runtimePanelButton.removeAttribute("hidden"); - } else { - runtimePanelButton.removeAttribute("active"); - runtimePanelButton.setAttribute("hidden", "true"); - } - - projectPanelCmd.removeAttribute("disabled"); - }, - - updateRemoveProjectButton: function () { - // Remove command - let removeCmdNode = document.querySelector("#cmd_removeProject"); - if (AppManager.selectedProject) { - removeCmdNode.removeAttribute("disabled"); - } else { - removeCmdNode.setAttribute("disabled", "true"); - } - }, - - /** ******** RUNTIME **********/ - - get lastConnectedRuntime() { - return Services.prefs.getCharPref("devtools.webide.lastConnectedRuntime"); - }, - - set lastConnectedRuntime(runtime) { - Services.prefs.setCharPref("devtools.webide.lastConnectedRuntime", runtime); - }, - - autoConnectRuntime: function () { - // Automatically reconnect to the previously selected runtime, - // if available and has an ID and feature is enabled - if (AppManager.selectedRuntime || - !Services.prefs.getBoolPref("devtools.webide.autoConnectRuntime") || - !this.lastConnectedRuntime) { - return; - } - let [_, type, id] = this.lastConnectedRuntime.match(/^(\w+):(.+)$/); - - type = type.toLowerCase(); - - // Local connection is mapped to AppManager.runtimeList.other array - if (type == "local") { - type = "other"; - } - - // We support most runtimes except simulator, that needs to be manually - // launched - if (type == "usb" || type == "wifi" || type == "other") { - for (let runtime of AppManager.runtimeList[type]) { - // Some runtimes do not expose an id and don't support autoconnect (like - // remote connection) - if (runtime.id == id) { - // Only want one auto-connect attempt, so clear last runtime value - this.lastConnectedRuntime = ""; - this.connectToRuntime(runtime); - } - } - } - }, - - connectToRuntime: function (runtime) { - let name = runtime.name; - let promise = AppManager.connectToRuntime(runtime); - promise.then(() => this.initConnectionTelemetry()) - .catch(() => { - // Empty rejection handler to silence uncaught rejection warnings - // |busyUntil| will listen for rejections. - // Bug 1121100 may find a better way to silence these. - }); - promise = this.busyUntil(promise, "Connecting to " + name); - // Stop busy timeout for runtimes that take unknown or long amounts of time - // to connect. - if (runtime.prolongedConnection) { - this.cancelBusyTimeout(); - } - return promise; - }, - - updateRuntimeButton: function () { - let labelNode = document.querySelector("#runtime-panel-button > .panel-button-label"); - if (!AppManager.selectedRuntime) { - labelNode.setAttribute("value", Strings.GetStringFromName("runtimeButton_label")); - } else { - let name = AppManager.selectedRuntime.name; - labelNode.setAttribute("value", name); - } - }, - - saveLastConnectedRuntime: function () { - if (AppManager.selectedRuntime && - AppManager.selectedRuntime.id !== undefined) { - this.lastConnectedRuntime = AppManager.selectedRuntime.type + ":" + - AppManager.selectedRuntime.id; - } else { - this.lastConnectedRuntime = ""; - } - }, - - /** ******** ACTIONS **********/ - - _actionsToLog: new Set(), - - /** - * For each new connection, track whether play and debug were ever used. Only - * one value is collected for each button, even if they are used multiple - * times during a connection. - */ - initConnectionTelemetry: function () { - this._actionsToLog.add("play"); - this._actionsToLog.add("debug"); - }, - - /** - * Action occurred. Log that it happened, and remove it from the loggable - * set. - */ - onAction: function (action) { - if (!this._actionsToLog.has(action)) { - return; - } - this.logActionState(action, true); - this._actionsToLog.delete(action); - }, - - /** - * Connection status changed or we are shutting down. Record any loggable - * actions as having not occurred. - */ - updateConnectionTelemetry: function () { - for (let action of this._actionsToLog.values()) { - this.logActionState(action, false); - } - this._actionsToLog.clear(); - }, - - logActionState: function (action, state) { - let histogramId = "DEVTOOLS_WEBIDE_CONNECTION_" + - action.toUpperCase() + "_USED"; - this._telemetry.log(histogramId, state); - }, - - /** ******** PROJECTS **********/ - - // ProjectEditor & details screen - - destroyProjectEditor: function () { - if (this.projecteditor) { - this.projecteditor.destroy(); - this.projecteditor = null; - } - }, - - /** - * Called when selecting or deselecting the project editor panel. - */ - onChangeProjectEditorSelected: function () { - if (this.projecteditor) { - let panel = document.querySelector("#deck").selectedPanel; - if (panel && panel.id == "deck-panel-projecteditor") { - this.projecteditor.menuEnabled = true; - this._telemetry.toolOpened("webideProjectEditor"); - } else { - this.projecteditor.menuEnabled = false; - this._telemetry.toolClosed("webideProjectEditor"); - } - } - }, - - getProjectEditor: function () { - if (this.projecteditor) { - return this.projecteditor.loaded; - } - - let projecteditorIframe = document.querySelector("#deck-panel-projecteditor"); - this.projecteditor = ProjectEditor.ProjectEditor(projecteditorIframe, { - menubar: document.querySelector("#main-menubar"), - menuindex: 1 - }); - this.projecteditor.on("onEditorSave", () => { - AppManager.validateAndUpdateProject(AppManager.selectedProject); - this._telemetry.actionOccurred("webideProjectEditorSave"); - }); - return this.projecteditor.loaded; - }, - - updateProjectEditorHeader: function () { - let project = AppManager.selectedProject; - if (!project || !this.projecteditor) { - return; - } - let status = project.validationStatus || "unknown"; - if (status == "error warning") { - status = "error"; - } - this.getProjectEditor().then((projecteditor) => { - projecteditor.setProjectToAppPath(project.location, { - name: project.name, - iconUrl: project.icon, - projectOverviewURL: "chrome://webide/content/details.xhtml", - validationStatus: status - }).then(null, console.error); - }, console.error); - }, - - isProjectEditorEnabled: function () { - return Services.prefs.getBoolPref("devtools.webide.showProjectEditor"); - }, - - openProject: function () { - let project = AppManager.selectedProject; - - // Nothing to show - - if (!project) { - this.resetDeck(); - return; - } - - // Make sure the directory exist before we show Project Editor - - let forceDetailsOnly = false; - if (project.type == "packaged") { - forceDetailsOnly = !utils.doesFileExist(project.location); - } - - // Show only the details screen - - if (project.type != "packaged" || - !this.isProjectEditorEnabled() || - forceDetailsOnly) { - this.selectDeckPanel("details"); - return; - } - - // Show ProjectEditor - - this.getProjectEditor().then(() => { - this.updateProjectEditorHeader(); - }, console.error); - - this.selectDeckPanel("projecteditor"); - }, - - autoStartProject: Task.async(function* () { - let project = AppManager.selectedProject; - - if (!project) { - return; - } - if (!(project.type == "runtimeApp" || - project.type == "mainProcess" || - project.type == "tab")) { - return; // For something that is not an editable app, we're done. - } - - // Do not force opening apps that are already running, as they may have - // some activity being opened and don't want to dismiss them. - if (project.type == "runtimeApp" && !AppManager.isProjectRunning()) { - yield UI.busyUntil(AppManager.launchRuntimeApp(), "running app"); - } - }), - - autoOpenToolbox: Task.async(function* () { - let project = AppManager.selectedProject; - - if (!project) { - return; - } - if (!(project.type == "runtimeApp" || - project.type == "mainProcess" || - project.type == "tab")) { - return; // For something that is not an editable app, we're done. - } - - yield UI.createToolbox(); - }), - - importAndSelectApp: Task.async(function* (source) { - let isPackaged = !!source.path; - let project; - try { - project = yield AppProjects[isPackaged ? "addPackaged" : "addHosted"](source); - } catch (e) { - if (e === "Already added") { - // Select project that's already been added, - // and allow it to be revalidated and selected - project = AppProjects.get(isPackaged ? source.path : source); - } else { - throw e; - } - } - - // Select project - AppManager.selectedProject = project; - - this._telemetry.actionOccurred("webideImportProject"); - }), - - // Remember the last selected project on the runtime - saveLastSelectedProject: function () { - let shouldRestore = Services.prefs.getBoolPref("devtools.webide.restoreLastProject"); - if (!shouldRestore) { - return; - } - - // Ignore unselection of project on runtime disconnection - if (!AppManager.connected) { - return; - } - - let project = "", type = ""; - let selected = AppManager.selectedProject; - if (selected) { - if (selected.type == "runtimeApp") { - type = "runtimeApp"; - project = selected.app.manifestURL; - } else if (selected.type == "mainProcess") { - type = "mainProcess"; - } else if (selected.type == "packaged" || - selected.type == "hosted") { - type = "local"; - project = selected.location; - } - } - if (type) { - Services.prefs.setCharPref("devtools.webide.lastSelectedProject", - type + ":" + project); - } else { - Services.prefs.clearUserPref("devtools.webide.lastSelectedProject"); - } - }, - - autoSelectProject: function () { - if (AppManager.selectedProject) { - return; - } - let shouldRestore = Services.prefs.getBoolPref("devtools.webide.restoreLastProject"); - if (!shouldRestore) { - return; - } - let pref = Services.prefs.getCharPref("devtools.webide.lastSelectedProject"); - if (!pref) { - return; - } - let m = pref.match(/^(\w+):(.*)$/); - if (!m) { - return; - } - let [_, type, project] = m; - - if (type == "local") { - let lastProject = AppProjects.get(project); - if (lastProject) { - AppManager.selectedProject = lastProject; - } - } - - // For other project types, we need to be connected to the runtime - if (!AppManager.connected) { - return; - } - - if (type == "mainProcess" && AppManager.isMainProcessDebuggable()) { - AppManager.selectedProject = { - type: "mainProcess", - name: Strings.GetStringFromName("mainProcess_label"), - icon: AppManager.DEFAULT_PROJECT_ICON - }; - } else if (type == "runtimeApp") { - let app = AppManager.apps.get(project); - if (app) { - AppManager.selectedProject = { - type: "runtimeApp", - app: app.manifest, - icon: app.iconURL, - name: app.manifest.name - }; - } - } - }, - - /** ******** DECK **********/ - - setupDeck: function () { - let iframes = document.querySelectorAll("#deck > iframe"); - for (let iframe of iframes) { - iframe.tooltip = "aHTMLTooltip"; - } - }, - - resetFocus: function () { - document.commandDispatcher.focusedElement = document.documentElement; - }, - - selectDeckPanel: function (id) { - let deck = document.querySelector("#deck"); - if (deck.selectedPanel && deck.selectedPanel.id === "deck-panel-" + id) { - // This panel is already displayed. - return; - } - this.resetFocus(); - let panel = deck.querySelector("#deck-panel-" + id); - let lazysrc = panel.getAttribute("lazysrc"); - if (lazysrc) { - panel.removeAttribute("lazysrc"); - panel.setAttribute("src", lazysrc); - } - deck.selectedPanel = panel; - this.onChangeProjectEditorSelected(); - }, - - resetDeck: function () { - this.resetFocus(); - let deck = document.querySelector("#deck"); - deck.selectedPanel = null; - this.onChangeProjectEditorSelected(); - }, - - buildIDToDate(buildID) { - let fields = buildID.match(/(\d{4})(\d{2})(\d{2})/); - // Date expects 0 - 11 for months - return new Date(fields[1], Number.parseInt(fields[2]) - 1, fields[3]); - }, - - checkRuntimeVersion: Task.async(function* () { - if (AppManager.connected && AppManager.deviceFront) { - let desc = yield AppManager.deviceFront.getDescription(); - // Compare device and firefox build IDs - // and only compare by day (strip hours/minutes) to prevent - // warning against builds of the same day. - let deviceID = desc.appbuildid.substr(0, 8); - let localID = Services.appinfo.appBuildID.substr(0, 8); - let deviceDate = this.buildIDToDate(deviceID); - let localDate = this.buildIDToDate(localID); - // Allow device to be newer by up to a week. This accommodates those with - // local device builds, since their devices will almost always be newer - // than the client. - if (deviceDate - localDate > 7 * MS_PER_DAY) { - this.reportError("error_runtimeVersionTooRecent", deviceID, localID); - } - } - }), - - /** ******** TOOLBOX **********/ - - /** - * There are many ways to close a toolbox: - * * Close button inside the toolbox - * * Toggle toolbox wrench in WebIDE - * * Disconnect the current runtime gracefully - * * Yank cord out of device - * * Close or crash the app/tab - * We can't know for sure which one was used here, so reset the - * |toolboxPromise| since someone must be destroying it to reach here, - * and call our own close method. - */ - _onToolboxClosed: function (promise, iframe) { - // Only save toolbox size, disable wrench button, workaround focus issue... - // if we are closing the last toolbox: - // - toolboxPromise is nullified by destroyToolbox and is still null here - // if no other toolbox has been opened in between, - // - having two distinct promise means we are receiving closed event - // for a previous, non-current, toolbox. - if (!this.toolboxPromise || this.toolboxPromise === promise) { - this.toolboxPromise = null; - this.resetFocus(); - Services.prefs.setIntPref("devtools.toolbox.footer.height", iframe.height); - - let splitter = document.querySelector(".devtools-horizontal-splitter"); - splitter.setAttribute("hidden", "true"); - document.querySelector("#action-button-debug").removeAttribute("active"); - } - // We have to destroy the iframe, otherwise, the keybindings of webide don't work - // properly anymore. - iframe.remove(); - }, - - destroyToolbox: function () { - // Only have a live toolbox if |this.toolboxPromise| exists - if (this.toolboxPromise) { - let toolboxPromise = this.toolboxPromise; - this.toolboxPromise = null; - return toolboxPromise.then(toolbox => toolbox.destroy()); - } - return promise.resolve(); - }, - - createToolbox: function () { - // If |this.toolboxPromise| exists, there is already a live toolbox - if (this.toolboxPromise) { - return this.toolboxPromise; - } - - let iframe = document.createElement("iframe"); - iframe.id = "toolbox"; - - // Compute a uid on the iframe in order to identify toolbox iframe - // when receiving toolbox-close event - iframe.uid = new Date().getTime(); - - let height = Services.prefs.getIntPref("devtools.toolbox.footer.height"); - iframe.height = height; - - let promise = this.toolboxPromise = AppManager.getTarget().then(target => { - return this._showToolbox(target, iframe); - }).then(toolbox => { - // Destroy the toolbox on WebIDE side before - // toolbox.destroy's promise resolves. - toolbox.once("destroyed", this._onToolboxClosed.bind(this, promise, iframe)); - return toolbox; - }, console.error); - - return this.busyUntil(this.toolboxPromise, "opening toolbox"); - }, - - _showToolbox: function (target, iframe) { - let splitter = document.querySelector(".devtools-horizontal-splitter"); - splitter.removeAttribute("hidden"); - - document.querySelector("notificationbox").insertBefore(iframe, splitter.nextSibling); - let host = Toolbox.HostType.CUSTOM; - let options = { customIframe: iframe, zoom: false, uid: iframe.uid }; - - document.querySelector("#action-button-debug").setAttribute("active", "true"); - - return gDevTools.showToolbox(target, null, host, options); - }, - - prePackageLog: function (msg) { - if (msg == "start") { - UI.selectDeckPanel("logs"); - } - } -}; - -EventEmitter.decorate(UI); - -var Cmds = { - quit: function () { - if (UI.canCloseProject()) { - window.close(); - } - }, - - showProjectPanel: function () { - ProjectPanel.toggleSidebar(); - return promise.resolve(); - }, - - showRuntimePanel: function () { - RuntimeScanners.scan(); - RuntimePanel.toggleSidebar(); - }, - - disconnectRuntime: function () { - let disconnecting = Task.spawn(function* () { - yield UI.destroyToolbox(); - yield AppManager.disconnectRuntime(); - }); - return UI.busyUntil(disconnecting, "disconnecting from runtime"); - }, - - takeScreenshot: function () { - let url = AppManager.deviceFront.screenshotToDataURL(); - return UI.busyUntil(url.then(longstr => { - return longstr.string().then(dataURL => { - longstr.release().then(null, console.error); - UI.openInBrowser(dataURL); - }); - }), "taking screenshot"); - }, - - showPermissionsTable: function () { - UI.selectDeckPanel("permissionstable"); - }, - - showRuntimeDetails: function () { - UI.selectDeckPanel("runtimedetails"); - }, - - showDevicePrefs: function () { - UI.selectDeckPanel("devicepreferences"); - }, - - showSettings: function () { - UI.selectDeckPanel("devicesettings"); - }, - - showMonitor: function () { - UI.selectDeckPanel("monitor"); - }, - - play: Task.async(function* () { - let busy; - switch (AppManager.selectedProject.type) { - case "packaged": - let autosave = - Services.prefs.getBoolPref("devtools.webide.autosaveFiles"); - if (autosave && UI.projecteditor) { - yield UI.projecteditor.saveAllFiles(); - } - busy = UI.busyWithProgressUntil(AppManager.installAndRunProject(), - "installing and running app"); - break; - case "hosted": - busy = UI.busyUntil(AppManager.installAndRunProject(), - "installing and running app"); - break; - case "runtimeApp": - busy = UI.busyUntil(AppManager.launchOrReloadRuntimeApp(), "launching / reloading app"); - break; - case "tab": - busy = UI.busyUntil(AppManager.reloadTab(), "reloading tab"); - break; - } - if (!busy) { - return promise.reject(); - } - UI.onAction("play"); - return busy; - }), - - stop: function () { - return UI.busyUntil(AppManager.stopRunningApp(), "stopping app"); - }, - - toggleToolbox: function () { - UI.onAction("debug"); - if (UI.toolboxPromise) { - UI.destroyToolbox(); - return promise.resolve(); - } else { - return UI.createToolbox(); - } - }, - - removeProject: function () { - AppManager.removeSelectedProject(); - }, - - toggleEditors: function () { - let isNowEnabled = !UI.isProjectEditorEnabled(); - Services.prefs.setBoolPref("devtools.webide.showProjectEditor", isNowEnabled); - if (!isNowEnabled) { - UI.destroyProjectEditor(); - } - UI.openProject(); - }, - - showTroubleShooting: function () { - UI.openInBrowser(HELP_URL); - }, - - showAddons: function () { - UI.selectDeckPanel("addons"); - }, - - showPrefs: function () { - UI.selectDeckPanel("prefs"); - }, - - zoomIn: function () { - if (UI.contentViewer.fullZoom < MAX_ZOOM) { - UI.contentViewer.fullZoom += 0.1; - Services.prefs.setCharPref("devtools.webide.zoom", UI.contentViewer.fullZoom); - } - }, - - zoomOut: function () { - if (UI.contentViewer.fullZoom > MIN_ZOOM) { - UI.contentViewer.fullZoom -= 0.1; - Services.prefs.setCharPref("devtools.webide.zoom", UI.contentViewer.fullZoom); - } - }, - - resetZoom: function () { - UI.contentViewer.fullZoom = 1; - Services.prefs.setCharPref("devtools.webide.zoom", 1); - } -}; diff --git a/devtools/client/webide/content/webide.xul b/devtools/client/webide/content/webide.xul deleted file mode 100644 index a3e4355b9..000000000 --- a/devtools/client/webide/content/webide.xul +++ /dev/null @@ -1,178 +0,0 @@ - - - - - - %webideDTD; -]> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        - -
        -