diff --git a/gfx/2d/DataSurfaceHelpers.cpp b/gfx/2d/DataSurfaceHelpers.cpp index 5b8f2a8562..e2813f180e 100644 --- a/gfx/2d/DataSurfaceHelpers.cpp +++ b/gfx/2d/DataSurfaceHelpers.cpp @@ -21,7 +21,7 @@ DataAtOffset(DataSourceSurface* aSurface, IntPoint aPoint) { if (!SurfaceContainsPoint(aSurface, aPoint)) { - MOZ_CRASH("sample position needs to be inside surface!"); + MOZ_CRASH("GFX: sample position needs to be inside surface!"); } MOZ_ASSERT(Factory::CheckSurfaceSize(aSurface->GetSize()), @@ -31,7 +31,7 @@ DataAtOffset(DataSourceSurface* aSurface, aPoint.x * BytesPerPixel(aSurface->GetFormat()); if (data < aMap->mData) { - MOZ_CRASH("out-of-range data access"); + MOZ_CRASH("GFX: out-of-range data access"); } return data; @@ -238,7 +238,7 @@ CopyRect(DataSourceSurface* aSrc, DataSourceSurface* aDest, { if (aSrcRect.Overflows() || IntRect(aDestPoint, aSrcRect.Size()).Overflows()) { - MOZ_CRASH("we should never be getting invalid rects at this point"); + MOZ_CRASH("GFX: we should never be getting invalid rects at this point"); } MOZ_RELEASE_ASSERT(aSrc->GetFormat() == aDest->GetFormat(), diff --git a/gfx/2d/DrawTargetCG.cpp b/gfx/2d/DrawTargetCG.cpp index 45683dc7a0..53d64acc7f 100644 --- a/gfx/2d/DrawTargetCG.cpp +++ b/gfx/2d/DrawTargetCG.cpp @@ -257,7 +257,7 @@ GetRetainedImageFromSourceSurface(SourceSurface *aSurface) { RefPtr data = aSurface->GetDataSurface(); if (!data) { - MOZ_CRASH("unsupported source surface"); + MOZ_CRASH("GFX: unsupported source CG surface"); } data.get()->AddRef(); return CreateCGImage(releaseDataSurface, data.get(), @@ -1554,7 +1554,8 @@ DrawTargetCG::FillGlyphs(ScaledFont *aFont, const GlyphBuffer &aBuffer, const Pa Vector positions; if (!glyphs.resizeUninitialized(aBuffer.mNumGlyphs) || !positions.resizeUninitialized(aBuffer.mNumGlyphs)) { - MOZ_CRASH("glyphs/positions allocation failed"); + gfxDevCrash(LogReason::GlyphAllocFailedCG) << "glyphs/positions allocation failed"; + return; } // Handle the flip diff --git a/gfx/2d/DrawTargetCairo.cpp b/gfx/2d/DrawTargetCairo.cpp index 8e69bf1289..f9d7e5bca5 100644 --- a/gfx/2d/DrawTargetCairo.cpp +++ b/gfx/2d/DrawTargetCairo.cpp @@ -333,6 +333,10 @@ GetCairoSurfaceForSourceSurface(SourceSurface *aSurface, bool aExistingOnly = false, const IntRect& aSubImage = IntRect()) { + if (!aSurface) { + return nullptr; + } + IntRect subimage = IntRect(IntPoint(), aSurface->GetSize()); if (!aSubImage.IsEmpty()) { MOZ_ASSERT(!aExistingOnly); @@ -656,7 +660,7 @@ DrawTargetCairo::GetType() const case CAIRO_SURFACE_TYPE_TEE: // included to silence warning about unhandled enum value return DrawTargetType::SOFTWARE_RASTER; default: - MOZ_CRASH("Unsupported cairo surface type"); + MOZ_CRASH("GFX: Unsupported cairo surface type"); } } MOZ_ASSERT(false, "Could not determine DrawTargetType for DrawTargetCairo"); @@ -792,7 +796,7 @@ DrawTargetCairo::DrawSurface(SourceSurface *aSurface, return; } - if (!IsValid()) { + if (!IsValid() || !aSurface) { gfxCriticalNote << "DrawSurface with bad surface " << cairo_surface_status(mSurface); return; } @@ -1279,7 +1283,8 @@ DrawTargetCairo::FillGlyphs(ScaledFont *aFont, // allocation in ~99% of cases. Vector glyphs; if (!glyphs.resizeUninitialized(aBuffer.mNumGlyphs)) { - MOZ_CRASH("glyphs allocation failed"); + gfxDevCrash(LogReason::GlyphAllocFailedCairo) << "glyphs allocation failed"; + return; } for (uint32_t i = 0; i < aBuffer.mNumGlyphs; ++i) { glyphs[i].index = aBuffer.mGlyphs[i].mIndex; diff --git a/gfx/2d/DrawTargetD2D.h b/gfx/2d/DrawTargetD2D.h index eae24d73f4..7c0a5b403e 100644 --- a/gfx/2d/DrawTargetD2D.h +++ b/gfx/2d/DrawTargetD2D.h @@ -39,97 +39,97 @@ struct PrivateD3D10DataD2D class DrawTargetD2D : public DrawTarget { public: - MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(DrawTargetD2D) + MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(DrawTargetD2D, override) DrawTargetD2D(); virtual ~DrawTargetD2D(); virtual DrawTargetType GetType() const override { return DrawTargetType::HARDWARE_RASTER; } - virtual BackendType GetBackendType() const { return BackendType::DIRECT2D; } - virtual already_AddRefed Snapshot(); - virtual IntSize GetSize() { return mSize; } + virtual BackendType GetBackendType() const override { return BackendType::DIRECT2D; } + virtual already_AddRefed Snapshot() override; + virtual IntSize GetSize() override { return mSize; } - virtual void Flush(); + virtual void Flush() override; virtual void DrawSurface(SourceSurface *aSurface, const Rect &aDest, const Rect &aSource, const DrawSurfaceOptions &aSurfOptions = DrawSurfaceOptions(), - const DrawOptions &aOptions = DrawOptions()); + const DrawOptions &aOptions = DrawOptions()) override; virtual void DrawFilter(FilterNode *aNode, const Rect &aSourceRect, const Point &aDestPoint, - const DrawOptions &aOptions = DrawOptions()); + const DrawOptions &aOptions = DrawOptions()) override; virtual void DrawSurfaceWithShadow(SourceSurface *aSurface, const Point &aDest, const Color &aColor, const Point &aOffset, Float aSigma, - CompositionOp aOperator); - virtual void ClearRect(const Rect &aRect); + CompositionOp aOperator) override; + virtual void ClearRect(const Rect &aRect) override; virtual void MaskSurface(const Pattern &aSource, SourceSurface *aMask, Point aOffset, - const DrawOptions &aOptions = DrawOptions()); + const DrawOptions &aOptions = DrawOptions()) override; virtual void CopySurface(SourceSurface *aSurface, const IntRect &aSourceRect, - const IntPoint &aDestination); + const IntPoint &aDestination) override; virtual void FillRect(const Rect &aRect, const Pattern &aPattern, - const DrawOptions &aOptions = DrawOptions()); + const DrawOptions &aOptions = DrawOptions()) override; virtual void StrokeRect(const Rect &aRect, const Pattern &aPattern, const StrokeOptions &aStrokeOptions = StrokeOptions(), - const DrawOptions &aOptions = DrawOptions()); + const DrawOptions &aOptions = DrawOptions()) override; virtual void StrokeLine(const Point &aStart, const Point &aEnd, const Pattern &aPattern, const StrokeOptions &aStrokeOptions = StrokeOptions(), - const DrawOptions &aOptions = DrawOptions()); + const DrawOptions &aOptions = DrawOptions()) override; virtual void Stroke(const Path *aPath, const Pattern &aPattern, const StrokeOptions &aStrokeOptions = StrokeOptions(), - const DrawOptions &aOptions = DrawOptions()); + const DrawOptions &aOptions = DrawOptions()) override; virtual void Fill(const Path *aPath, const Pattern &aPattern, - const DrawOptions &aOptions = DrawOptions()); + const DrawOptions &aOptions = DrawOptions()) override; virtual void FillGlyphs(ScaledFont *aFont, const GlyphBuffer &aBuffer, const Pattern &aPattern, const DrawOptions &aOptions = DrawOptions(), - const GlyphRenderingOptions *aRenderingOptions = nullptr); + const GlyphRenderingOptions *aRenderingOptions = nullptr) override; virtual void Mask(const Pattern &aSource, const Pattern &aMask, - const DrawOptions &aOptions = DrawOptions()); - virtual void PushClip(const Path *aPath); - virtual void PushClipRect(const Rect &aRect); - virtual void PopClip(); + const DrawOptions &aOptions = DrawOptions()) override; + virtual void PushClip(const Path *aPath) override; + virtual void PushClipRect(const Rect &aRect) override; + virtual void PopClip() override; virtual already_AddRefed CreateSourceSurfaceFromData(unsigned char *aData, const IntSize &aSize, int32_t aStride, - SurfaceFormat aFormat) const; - virtual already_AddRefed OptimizeSourceSurface(SourceSurface *aSurface) const; + SurfaceFormat aFormat) const override; + virtual already_AddRefed OptimizeSourceSurface(SourceSurface *aSurface) const override; virtual already_AddRefed - CreateSourceSurfaceFromNativeSurface(const NativeSurface &aSurface) const; + CreateSourceSurfaceFromNativeSurface(const NativeSurface &aSurface) const override; virtual already_AddRefed - CreateSimilarDrawTarget(const IntSize &aSize, SurfaceFormat aFormat) const; + CreateSimilarDrawTarget(const IntSize &aSize, SurfaceFormat aFormat) const override; - virtual already_AddRefed CreatePathBuilder(FillRule aFillRule = FillRule::FILL_WINDING) const; + virtual already_AddRefed CreatePathBuilder(FillRule aFillRule = FillRule::FILL_WINDING) const override; virtual already_AddRefed CreateGradientStops(GradientStop *aStops, uint32_t aNumStops, - ExtendMode aExtendMode = ExtendMode::CLAMP) const; + ExtendMode aExtendMode = ExtendMode::CLAMP) const override; - virtual already_AddRefed CreateFilter(FilterType aType); + virtual already_AddRefed CreateFilter(FilterType aType) override; - virtual bool SupportsRegionClipping() const { return false; } + virtual bool SupportsRegionClipping() const override { return false; } - virtual void *GetNativeSurface(NativeSurfaceType aType); + virtual void *GetNativeSurface(NativeSurfaceType aType) override; bool Init(const IntSize &aSize, SurfaceFormat aFormat); bool Init(ID3D10Texture2D *aTexture, SurfaceFormat aFormat); diff --git a/gfx/2d/DrawTargetD2D1.h b/gfx/2d/DrawTargetD2D1.h index c015b48585..94a2092c97 100644 --- a/gfx/2d/DrawTargetD2D1.h +++ b/gfx/2d/DrawTargetD2D1.h @@ -29,96 +29,96 @@ const int32_t kLayerCacheSize1 = 5; class DrawTargetD2D1 : public DrawTarget { public: - MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(DrawTargetD2D1) + MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(DrawTargetD2D1, override) DrawTargetD2D1(); virtual ~DrawTargetD2D1(); virtual DrawTargetType GetType() const override { return DrawTargetType::HARDWARE_RASTER; } - virtual BackendType GetBackendType() const { return BackendType::DIRECT2D1_1; } - virtual already_AddRefed Snapshot(); - virtual IntSize GetSize() { return mSize; } + virtual BackendType GetBackendType() const override { return BackendType::DIRECT2D1_1; } + virtual already_AddRefed Snapshot() override; + virtual IntSize GetSize() override { return mSize; } - virtual void Flush(); + virtual void Flush() override; virtual void DrawSurface(SourceSurface *aSurface, const Rect &aDest, const Rect &aSource, const DrawSurfaceOptions &aSurfOptions, - const DrawOptions &aOptions); + const DrawOptions &aOptions) override; virtual void DrawFilter(FilterNode *aNode, const Rect &aSourceRect, const Point &aDestPoint, - const DrawOptions &aOptions = DrawOptions()); + const DrawOptions &aOptions = DrawOptions()) override; virtual void DrawSurfaceWithShadow(SourceSurface *aSurface, const Point &aDest, const Color &aColor, const Point &aOffset, Float aSigma, - CompositionOp aOperator); - virtual void ClearRect(const Rect &aRect); + CompositionOp aOperator) override; + virtual void ClearRect(const Rect &aRect) override; virtual void MaskSurface(const Pattern &aSource, SourceSurface *aMask, Point aOffset, - const DrawOptions &aOptions = DrawOptions()); + const DrawOptions &aOptions = DrawOptions()) override; virtual void CopySurface(SourceSurface *aSurface, const IntRect &aSourceRect, - const IntPoint &aDestination); + const IntPoint &aDestination) override; virtual void FillRect(const Rect &aRect, const Pattern &aPattern, - const DrawOptions &aOptions = DrawOptions()); + const DrawOptions &aOptions = DrawOptions()) override; virtual void StrokeRect(const Rect &aRect, const Pattern &aPattern, const StrokeOptions &aStrokeOptions = StrokeOptions(), - const DrawOptions &aOptions = DrawOptions()); + const DrawOptions &aOptions = DrawOptions()) override; virtual void StrokeLine(const Point &aStart, const Point &aEnd, const Pattern &aPattern, const StrokeOptions &aStrokeOptions = StrokeOptions(), - const DrawOptions &aOptions = DrawOptions()); + const DrawOptions &aOptions = DrawOptions()) override; virtual void Stroke(const Path *aPath, const Pattern &aPattern, const StrokeOptions &aStrokeOptions = StrokeOptions(), - const DrawOptions &aOptions = DrawOptions()); + const DrawOptions &aOptions = DrawOptions()) override; virtual void Fill(const Path *aPath, const Pattern &aPattern, - const DrawOptions &aOptions = DrawOptions()); + const DrawOptions &aOptions = DrawOptions()) override; virtual void FillGlyphs(ScaledFont *aFont, const GlyphBuffer &aBuffer, const Pattern &aPattern, const DrawOptions &aOptions = DrawOptions(), - const GlyphRenderingOptions *aRenderingOptions = nullptr); + const GlyphRenderingOptions *aRenderingOptions = nullptr) override; virtual void Mask(const Pattern &aSource, const Pattern &aMask, - const DrawOptions &aOptions = DrawOptions()); - virtual void PushClip(const Path *aPath); - virtual void PushClipRect(const Rect &aRect); - virtual void PopClip(); + const DrawOptions &aOptions = DrawOptions()) override; + virtual void PushClip(const Path *aPath) override; + virtual void PushClipRect(const Rect &aRect) override; + virtual void PopClip() override; virtual already_AddRefed CreateSourceSurfaceFromData(unsigned char *aData, const IntSize &aSize, int32_t aStride, - SurfaceFormat aFormat) const; - virtual already_AddRefed OptimizeSourceSurface(SourceSurface *aSurface) const; + SurfaceFormat aFormat) const override; + virtual already_AddRefed OptimizeSourceSurface(SourceSurface *aSurface) const override; virtual already_AddRefed - CreateSourceSurfaceFromNativeSurface(const NativeSurface &aSurface) const { return nullptr; } + CreateSourceSurfaceFromNativeSurface(const NativeSurface &aSurface) const override { return nullptr; } virtual already_AddRefed - CreateSimilarDrawTarget(const IntSize &aSize, SurfaceFormat aFormat) const; + CreateSimilarDrawTarget(const IntSize &aSize, SurfaceFormat aFormat) const override; - virtual already_AddRefed CreatePathBuilder(FillRule aFillRule = FillRule::FILL_WINDING) const; + virtual already_AddRefed CreatePathBuilder(FillRule aFillRule = FillRule::FILL_WINDING) const override; virtual already_AddRefed CreateGradientStops(GradientStop *aStops, uint32_t aNumStops, - ExtendMode aExtendMode = ExtendMode::CLAMP) const; + ExtendMode aExtendMode = ExtendMode::CLAMP) const override; - virtual already_AddRefed CreateFilter(FilterType aType); + virtual already_AddRefed CreateFilter(FilterType aType) override; - virtual bool SupportsRegionClipping() const { return false; } + virtual bool SupportsRegionClipping() const override { return false; } - virtual void *GetNativeSurface(NativeSurfaceType aType) { return nullptr; } + virtual void *GetNativeSurface(NativeSurfaceType aType) override { return nullptr; } bool Init(const IntSize &aSize, SurfaceFormat aFormat); bool Init(ID3D11Texture2D* aTexture, SurfaceFormat aFormat); diff --git a/gfx/2d/DrawTargetSkia.cpp b/gfx/2d/DrawTargetSkia.cpp index ab565a2498..0f752b25e9 100644 --- a/gfx/2d/DrawTargetSkia.cpp +++ b/gfx/2d/DrawTargetSkia.cpp @@ -96,7 +96,8 @@ GetBitmapForSurface(SourceSurface* aSurface) RefPtr surf = aSurface->GetDataSurface(); if (!surf) { - MOZ_CRASH("Non-skia SourceSurfaces need to be DataSourceSurfaces"); + gfxDevCrash(LogReason::SourceSurfaceIncompatible) << "Non-skia SourceSurfaces need to be DataSourceSurfaces"; + return result; } SkAlphaType alphaType = (surf->GetFormat() == SurfaceFormat::B8G8R8X8) ? @@ -589,6 +590,7 @@ DrawTargetSkia::FillGlyphs(ScaledFont *aFont, bool shouldLCDRenderText = ShouldLCDRenderText(aFont->GetType(), aOptions.mAntialiasMode); paint.mPaint.setLCDRenderText(shouldLCDRenderText); + paint.mPaint.setSubpixelText(true); if (aRenderingOptions && aRenderingOptions->GetType() == FontType::CAIRO) { const GlyphRenderingOptionsCairo* cairoOptions = @@ -655,16 +657,20 @@ DrawTargetSkia::MaskSurface(const Pattern &aSource, TempBitmap bitmap = GetBitmapForSurface(aMask); if (bitmap.mBitmap.colorType() == kAlpha_8_SkColorType) { + if (aOffset != Point(0, 0)) { + SkMatrix transform; + transform.setTranslate(SkFloatToScalar(-aOffset.x), SkFloatToScalar(-aOffset.y)); + SkShader* matrixShader = SkShader::CreateLocalMatrixShader(paint.mPaint.getShader(), transform); + SkSafeUnref(paint.mPaint.setShader(matrixShader)); + } + mCanvas->drawBitmap(bitmap.mBitmap, aOffset.x, aOffset.y, &paint.mPaint); } else { SkPaint maskPaint; TempBitmap tmpBitmap; - SetPaintPattern(maskPaint, SurfacePattern(aMask, ExtendMode::CLAMP), tmpBitmap); - - SkMatrix transform = maskPaint.getShader()->getLocalMatrix(); - transform.postTranslate(SkFloatToScalar(aOffset.x), SkFloatToScalar(aOffset.y)); - SkShader* matrixShader = SkShader::CreateLocalMatrixShader(maskPaint.getShader(), transform); - SkSafeUnref(maskPaint.setShader(matrixShader)); + SetPaintPattern(maskPaint, + SurfacePattern(aMask, ExtendMode::CLAMP, Matrix::Translation(aOffset)), + tmpBitmap); SkLayerRasterizer::Builder builder; builder.addLayer(maskPaint); diff --git a/gfx/2d/FilterNodeD2D1.cpp b/gfx/2d/FilterNodeD2D1.cpp index 114e504017..1a29b2bdb6 100644 --- a/gfx/2d/FilterNodeD2D1.cpp +++ b/gfx/2d/FilterNodeD2D1.cpp @@ -25,7 +25,7 @@ D2D1_COLORMATRIX_ALPHA_MODE D2DAlphaMode(uint32_t aMode) case ALPHA_MODE_STRAIGHT: return D2D1_COLORMATRIX_ALPHA_MODE_STRAIGHT; default: - MOZ_CRASH("Unknown enum value!"); + MOZ_CRASH("GFX: Unknown enum value D2DAlphaMode!"); } return D2D1_COLORMATRIX_ALPHA_MODE_PREMULTIPLIED; @@ -41,7 +41,7 @@ D2D1_2DAFFINETRANSFORM_INTERPOLATION_MODE D2DAffineTransformInterpolationMode(Fi case Filter::POINT: return D2D1_2DAFFINETRANSFORM_INTERPOLATION_MODE_NEAREST_NEIGHBOR; default: - MOZ_CRASH("Unknown enum value!"); + MOZ_CRASH("GFX: Unknown enum value D2DAffineTIM!"); } return D2D1_2DAFFINETRANSFORM_INTERPOLATION_MODE_LINEAR; @@ -82,7 +82,7 @@ D2D1_BLEND_MODE D2DBlendMode(uint32_t aMode) return D2D1_BLEND_MODE_LUMINOSITY; default: - MOZ_CRASH("Unknown enum value!"); + MOZ_CRASH("GFX: Unknown enum value D2DBlendMode!"); } return D2D1_BLEND_MODE_DARKEN; @@ -97,7 +97,7 @@ D2D1_MORPHOLOGY_MODE D2DMorphologyMode(uint32_t aMode) return D2D1_MORPHOLOGY_MODE_ERODE; } - MOZ_CRASH("Unknown enum value!"); + MOZ_CRASH("GFX: Unknown enum value D2DMorphologyMode!"); return D2D1_MORPHOLOGY_MODE_DILATE; } @@ -110,7 +110,7 @@ D2D1_TURBULENCE_NOISE D2DTurbulenceNoise(uint32_t aMode) return D2D1_TURBULENCE_NOISE_TURBULENCE; } - MOZ_CRASH("Unknown enum value!"); + MOZ_CRASH("GFX: Unknown enum value D2DTurbulenceNoise!"); return D2D1_TURBULENCE_NOISE_TURBULENCE; } @@ -129,7 +129,7 @@ D2D1_COMPOSITE_MODE D2DFilterCompositionMode(uint32_t aMode) return D2D1_COMPOSITE_MODE_XOR; } - MOZ_CRASH("Unknown enum value!"); + MOZ_CRASH("GFX: Unknown enum value D2DFilterCompositionMode!"); return D2D1_COMPOSITE_MODE_SOURCE_OVER; } @@ -146,15 +146,15 @@ D2D1_CHANNEL_SELECTOR D2DChannelSelector(uint32_t aMode) return D2D1_CHANNEL_SELECTOR_A; } - MOZ_CRASH("Unknown enum value!"); + MOZ_CRASH("GFX: Unknown enum value D2DChannelSelector!"); return D2D1_CHANNEL_SELECTOR_R; } already_AddRefed GetImageForSourceSurface(DrawTarget *aDT, SourceSurface *aSurface) { if (aDT->IsTiledDrawTarget() || aDT->IsDualDrawTarget()) { - MOZ_CRASH("Incompatible draw target type!"); - return nullptr; + gfxDevCrash(LogReason::FilterNodeD2D1Target) << "Incompatible draw target type! " << (int)aDT->IsTiledDrawTarget() << " " << (int)aDT->IsDualDrawTarget(); + return nullptr; } switch (aDT->GetBackendType()) { case BackendType::DIRECT2D1_1: @@ -162,7 +162,7 @@ already_AddRefed GetImageForSourceSurface(DrawTarget *aDT, SourceSur case BackendType::DIRECT2D: return static_cast(aDT)->GetImageForSurface(aSurface); default: - MOZ_CRASH("Unknown draw target type!"); + gfxDevCrash(LogReason::FilterNodeD2D1Backend) << "Unknown draw target type! " << (int)aDT->GetBackendType(); return nullptr; } } diff --git a/gfx/2d/FilterNodeD2D1.h b/gfx/2d/FilterNodeD2D1.h index 1f06dda6f5..8c4c6df308 100644 --- a/gfx/2d/FilterNodeD2D1.h +++ b/gfx/2d/FilterNodeD2D1.h @@ -74,15 +74,15 @@ protected: class FilterNodeConvolveD2D1 : public FilterNodeD2D1 { public: - MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(FilterNodeConvolveD2D1) + MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(FilterNodeConvolveD2D1, override) FilterNodeConvolveD2D1(ID2D1DeviceContext *aDC); - virtual void SetInput(uint32_t aIndex, FilterNode *aFilter); + virtual void SetInput(uint32_t aIndex, FilterNode *aFilter) override; - virtual void SetAttribute(uint32_t aIndex, uint32_t aValue); - virtual void SetAttribute(uint32_t aIndex, const IntSize &aValue); - virtual void SetAttribute(uint32_t aIndex, const IntPoint &aValue); - virtual void SetAttribute(uint32_t aIndex, const IntRect &aValue); + virtual void SetAttribute(uint32_t aIndex, uint32_t aValue) override; + virtual void SetAttribute(uint32_t aIndex, const IntSize &aValue) override; + virtual void SetAttribute(uint32_t aIndex, const IntPoint &aValue) override; + virtual void SetAttribute(uint32_t aIndex, const IntRect &aValue) override; virtual ID2D1Effect* InputEffect() override; @@ -102,7 +102,7 @@ private: class FilterNodeExtendInputAdapterD2D1 : public FilterNodeD2D1 { public: - MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(FilterNodeExtendInputAdapterD2D1) + MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(FilterNodeExtendInputAdapterD2D1, override) FilterNodeExtendInputAdapterD2D1(ID2D1DeviceContext *aDC, FilterNodeD2D1 *aFilterNode, FilterType aType); virtual ID2D1Effect* InputEffect() override { return mExtendInputEffect.get(); } @@ -116,7 +116,7 @@ private: class FilterNodePremultiplyAdapterD2D1 : public FilterNodeD2D1 { public: - MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(FilterNodePremultiplyAdapterD2D1) + MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(FilterNodePremultiplyAdapterD2D1, override) FilterNodePremultiplyAdapterD2D1(ID2D1DeviceContext *aDC, FilterNodeD2D1 *aFilterNode, FilterType aType); virtual ID2D1Effect* InputEffect() override { return mPrePremultiplyEffect.get(); } diff --git a/gfx/2d/FilterNodeSoftware.cpp b/gfx/2d/FilterNodeSoftware.cpp index 17b58e97f5..caf41d3c51 100644 --- a/gfx/2d/FilterNodeSoftware.cpp +++ b/gfx/2d/FilterNodeSoftware.cpp @@ -646,7 +646,8 @@ FilterNodeSoftware::RequestInputRect(uint32_t aInputEnumIndex, const IntRect &aR int32_t inputIndex = InputIndex(aInputEnumIndex); if (inputIndex < 0 || (uint32_t)inputIndex >= NumberOfSetInputs()) { - MOZ_CRASH(); + gfxDevCrash(LogReason::FilterInputError) << "Invalid input " << inputIndex << " vs. " << NumberOfSetInputs(); + return; } if (mInputSurfaces[inputIndex]) { return; @@ -683,7 +684,7 @@ FilterNodeSoftware::GetInputDataSourceSurface(uint32_t aInputEnumIndex, #endif int32_t inputIndex = InputIndex(aInputEnumIndex); if (inputIndex < 0 || (uint32_t)inputIndex >= NumberOfSetInputs()) { - MOZ_CRASH(); + gfxDevCrash(LogReason::FilterInputData) << "Invalid data " << inputIndex << " vs. " << NumberOfSetInputs(); return nullptr; } @@ -794,7 +795,7 @@ FilterNodeSoftware::GetInputRectInRect(uint32_t aInputEnumIndex, int32_t inputIndex = InputIndex(aInputEnumIndex); if (inputIndex < 0 || (uint32_t)inputIndex >= NumberOfSetInputs()) { - MOZ_CRASH(); + gfxDevCrash(LogReason::FilterInputRect) << "Invalid rect " << inputIndex << " vs. " << NumberOfSetInputs(); return IntRect(); } if (mInputSurfaces[inputIndex]) { @@ -881,7 +882,7 @@ FilterNodeSoftware::SetInput(uint32_t aInputEnumIndex, { int32_t inputIndex = InputIndex(aInputEnumIndex); if (inputIndex < 0) { - MOZ_CRASH(); + gfxDevCrash(LogReason::FilterInputSet) << "Invalid set " << inputIndex; return; } if ((uint32_t)inputIndex >= NumberOfSetInputs()) { @@ -1499,7 +1500,8 @@ FilterNodeFloodSoftware::Render(const IntRect& aRect) targetData += stride; } } else { - MOZ_CRASH(); + gfxDevCrash(LogReason::FilterInputFormat) << "Bad format in flood render " << (int)format; + return nullptr; } return target.forget(); @@ -1667,7 +1669,7 @@ FilterNodeComponentTransferSoftware::SetAttribute(uint32_t aIndex, mDisableA = aDisable; break; default: - MOZ_CRASH(); + MOZ_CRASH("GFX: FilterNodeComponentTransferSoftware::SetAttribute"); } Invalidate(); } @@ -1834,7 +1836,7 @@ FilterNodeTableTransferSoftware::SetAttribute(uint32_t aIndex, mTableA = table; break; default: - MOZ_CRASH(); + MOZ_CRASH("GFX: FilterNodeTableTransferSoftware::SetAttribute"); } Invalidate(); } @@ -1903,7 +1905,7 @@ FilterNodeDiscreteTransferSoftware::SetAttribute(uint32_t aIndex, mTableA = discrete; break; default: - MOZ_CRASH(); + MOZ_CRASH("GFX: FilterNodeDiscreteTransferSoftware::SetAttribute"); } Invalidate(); } @@ -1992,7 +1994,7 @@ FilterNodeLinearTransferSoftware::SetAttribute(uint32_t aIndex, mInterceptA = aValue; break; default: - MOZ_CRASH(); + MOZ_CRASH("GFX: FilterNodeLinearTransferSoftware::SetAttribute"); } Invalidate(); } @@ -2086,7 +2088,7 @@ FilterNodeGammaTransferSoftware::SetAttribute(uint32_t aIndex, mOffsetA = aValue; break; default: - MOZ_CRASH(); + MOZ_CRASH("GFX: FilterNodeGammaTransferSoftware::SetAttribute"); } Invalidate(); } @@ -2174,7 +2176,7 @@ FilterNodeConvolveMatrixSoftware::SetAttribute(uint32_t aIndex, Float aValue) mBias = aValue; break; default: - MOZ_CRASH(); + MOZ_CRASH("GFX: FilterNodeConvolveMatrixSoftware::SetAttribute"); } Invalidate(); } @@ -2187,7 +2189,7 @@ FilterNodeConvolveMatrixSoftware::SetAttribute(uint32_t aIndex, const Size &aKer mKernelUnitLength = aKernelUnitLength; break; default: - MOZ_CRASH(); + MOZ_CRASH("GFX: FilterNodeConvolveMatrixSoftware::SetAttribute"); } Invalidate(); } @@ -2400,7 +2402,7 @@ TranslateDoubleToShifts(double aDouble, int32_t &aShiftL, int32_t &aShiftR) aShiftL = 0; aShiftR = 0; if (aDouble <= 0) { - MOZ_CRASH(); + MOZ_CRASH("GFX: TranslateDoubleToShifts"); } if (aDouble < 1) { while (1 << (aShiftR + 1) < 1 / aDouble) { @@ -2580,7 +2582,7 @@ FilterNodeDisplacementMapSoftware::SetAttribute(uint32_t aIndex, uint32_t aValue mChannelY = static_cast(aValue); break; default: - MOZ_CRASH(); + MOZ_CRASH("GFX: FilterNodeDisplacementMapSoftware::SetAttribute"); } Invalidate(); } @@ -2686,7 +2688,7 @@ FilterNodeTurbulenceSoftware::SetAttribute(uint32_t aIndex, const Size &aBaseFre mBaseFrequency = aBaseFrequency; break; default: - MOZ_CRASH(); + MOZ_CRASH("GFX: FilterNodeTurbulenceSoftware::SetAttribute"); break; } Invalidate(); @@ -2700,7 +2702,7 @@ FilterNodeTurbulenceSoftware::SetAttribute(uint32_t aIndex, const IntRect &aRect mRenderRect = aRect; break; default: - MOZ_CRASH(); + MOZ_CRASH("GFX: FilterNodeTurbulenceSoftware::SetAttribute"); break; } Invalidate(); @@ -2728,7 +2730,7 @@ FilterNodeTurbulenceSoftware::SetAttribute(uint32_t aIndex, uint32_t aValue) mType = static_cast(aValue); break; default: - MOZ_CRASH(); + MOZ_CRASH("GFX: FilterNodeTurbulenceSoftware::SetAttribute"); break; } Invalidate(); @@ -3034,7 +3036,7 @@ FilterNodeGaussianBlurSoftware::SetAttribute(uint32_t aIndex, mStdDeviation = ClampStdDeviation(aStdDeviation); break; default: - MOZ_CRASH(); + MOZ_CRASH("GFX: FilterNodeGaussianBlurSoftware::SetAttribute"); } Invalidate(); } @@ -3058,7 +3060,7 @@ FilterNodeDirectionalBlurSoftware::SetAttribute(uint32_t aIndex, mStdDeviation = ClampStdDeviation(aStdDeviation); break; default: - MOZ_CRASH(); + MOZ_CRASH("GFX: FilterNodeDirectionalBlurSoftware::SetAttribute"); } Invalidate(); } @@ -3072,7 +3074,7 @@ FilterNodeDirectionalBlurSoftware::SetAttribute(uint32_t aIndex, mBlurDirection = (BlurDirection)aBlurDirection; break; default: - MOZ_CRASH(); + MOZ_CRASH("GFX: FilterNodeDirectionalBlurSoftware::SetAttribute"); } Invalidate(); } @@ -3289,7 +3291,7 @@ FilterNodeLightingSoftware::SetAttribute(uint32_t aInde Invalidate(); return; } - MOZ_CRASH(); + MOZ_CRASH("GFX: FilterNodeLightingSoftware::SetAttribute point"); } template @@ -3306,7 +3308,7 @@ FilterNodeLightingSoftware::SetAttribute(uint32_t aInde mSurfaceScale = std::fpclassify(aValue) == FP_SUBNORMAL ? 0.0 : aValue; break; default: - MOZ_CRASH(); + MOZ_CRASH("GFX: FilterNodeLightingSoftware::SetAttribute float"); } Invalidate(); } @@ -3320,7 +3322,7 @@ FilterNodeLightingSoftware::SetAttribute(uint32_t aInde mKernelUnitLength = aKernelUnitLength; break; default: - MOZ_CRASH(); + MOZ_CRASH("GFX: FilterNodeLightingSoftware::SetAttribute size"); } Invalidate(); } diff --git a/gfx/2d/JobScheduler.cpp b/gfx/2d/JobScheduler.cpp index 2294380d0b..fad2f21560 100644 --- a/gfx/2d/JobScheduler.cpp +++ b/gfx/2d/JobScheduler.cpp @@ -4,6 +4,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "JobScheduler.h" +#include "Logging.h" namespace mozilla { namespace gfx { @@ -270,7 +271,7 @@ WorkerThread::Run() if (status == JobStatus::Error) { // Don't try to handle errors for now, but that's open to discussions. // I expect errors to be mostly OOM issues. - MOZ_CRASH(); + gfxDevCrash(LogReason::JobStatusError) << "Invalid job status " << (int)status; } } } diff --git a/gfx/2d/Logging.h b/gfx/2d/Logging.h index a2d16567c3..63ec25b24b 100644 --- a/gfx/2d/Logging.h +++ b/gfx/2d/Logging.h @@ -140,6 +140,19 @@ enum class LogReason : int { D3D11FinalizeFrame, D3D10SyncLock, D3D11SyncLock, + D2D1NoWriteMap, + JobStatusError, + FilterInputError, + FilterInputData, // 10 + FilterInputRect, + FilterInputSet, + FilterInputFormat, + FilterNodeD2D1Target, + FilterNodeD2D1Backend, + SourceSurfaceIncompatible, + GlyphAllocFailedCairo, + GlyphAllocFailedCG, + InvalidRect, // End MustBeLessThanThis = 101, }; diff --git a/gfx/2d/ScaledFontBase.cpp b/gfx/2d/ScaledFontBase.cpp index 0e5fbd38e1..d1706e1706 100644 --- a/gfx/2d/ScaledFontBase.cpp +++ b/gfx/2d/ScaledFontBase.cpp @@ -165,7 +165,7 @@ ScaledFontBase::CopyGlyphsToBuilder(const GlyphBuffer &aBuffer, PathBuilder *aBu } #endif - MOZ_CRASH("The specified backend type is not supported by CopyGlyphsToBuilder"); + MOZ_CRASH("GFX: The specified backend type is not supported by CopyGlyphsToBuilder"); } #ifdef USE_CAIRO_SCALED_FONT diff --git a/gfx/2d/ScaledFontMac.cpp b/gfx/2d/ScaledFontMac.cpp index 75180b913f..65ae92c22d 100644 --- a/gfx/2d/ScaledFontMac.cpp +++ b/gfx/2d/ScaledFontMac.cpp @@ -105,7 +105,7 @@ ScaledFontMac::GetPathForGlyphs(const GlyphBuffer &aBuffer, const DrawTarget *aT return ret.forget(); #else //TODO: probably want CTFontCreatePathForGlyph - MOZ_CRASH("This needs implemented"); + MOZ_CRASH("GFX: This needs implemented 1"); #endif } return ScaledFontBase::GetPathForGlyphs(aBuffer, aTarget); @@ -135,7 +135,7 @@ ScaledFontMac::CopyGlyphsToBuilder(const GlyphBuffer &aBuffer, PathBuilder *aBui } #else //TODO: probably want CTFontCreatePathForGlyph - MOZ_CRASH("This needs implemented"); + MOZ_CRASH("GFX: This needs implemented 2"); #endif } diff --git a/gfx/2d/SourceSurfaceCG.cpp b/gfx/2d/SourceSurfaceCG.cpp index fdfde62d8c..c116170d60 100644 --- a/gfx/2d/SourceSurfaceCG.cpp +++ b/gfx/2d/SourceSurfaceCG.cpp @@ -105,7 +105,7 @@ CreateCGImage(CGDataProviderReleaseDataCallback aCallback, break; default: - MOZ_CRASH(); + MOZ_CRASH("GFX: CreateCGImage"); } size_t bufLen = BufferSizeFromStrideAndHeight(aStride, aSize.height); diff --git a/gfx/2d/SourceSurfaceD2D1.cpp b/gfx/2d/SourceSurfaceD2D1.cpp index bab1fc8dad..0d4b287c4f 100644 --- a/gfx/2d/SourceSurfaceD2D1.cpp +++ b/gfx/2d/SourceSurfaceD2D1.cpp @@ -189,7 +189,8 @@ DataSourceSurfaceD2D1::Map(MapType aMapType, MappedSurface *aMappedSurface) if (aMapType == MapType::READ) { options = D2D1_MAP_OPTIONS_READ; } else { - MOZ_CRASH("No support for Write maps on D2D1 DataSourceSurfaces yet!"); + gfxDevCrash(LogReason::D2D1NoWriteMap) << "No support for Write maps on D2D1 DataSourceSurfaces yet!"; + return false; } D2D1_MAPPED_RECT map; diff --git a/gfx/layers/d3d11/TextureD3D11.h b/gfx/layers/d3d11/TextureD3D11.h index 143c960d3e..73cb7fa5ba 100644 --- a/gfx/layers/d3d11/TextureD3D11.h +++ b/gfx/layers/d3d11/TextureD3D11.h @@ -185,11 +185,11 @@ public: virtual gfx::IntSize GetSize() const override { return mSize; } - virtual gfx::SurfaceFormat GetFormat() const { return gfx::SurfaceFormat::YUV; } + virtual gfx::SurfaceFormat GetFormat() const override { return gfx::SurfaceFormat::YUV; } - virtual bool SupportsMoz2D() const { return false; } + virtual bool SupportsMoz2D() const override { return false; } - virtual already_AddRefed BorrowDrawTarget() { return nullptr; } + virtual already_AddRefed BorrowDrawTarget() override { return nullptr; } // This TextureData should not be used in a context where we use CreateSimilar // (ex. component alpha) because the underlying texture is always created by diff --git a/gfx/layers/d3d9/CompositorD3D9.h b/gfx/layers/d3d9/CompositorD3D9.h index 70cbc82677..c050b15447 100644 --- a/gfx/layers/d3d9/CompositorD3D9.h +++ b/gfx/layers/d3d9/CompositorD3D9.h @@ -44,7 +44,7 @@ public: const CompositingRenderTarget *aSource, const gfx::IntPoint &aSourcePoint) override; - virtual void SetRenderTarget(CompositingRenderTarget *aSurface); + virtual void SetRenderTarget(CompositingRenderTarget *aSurface) override; virtual CompositingRenderTarget* GetCurrentRenderTarget() const override { return mCurrentRT; diff --git a/gfx/layers/d3d9/TextureD3D9.h b/gfx/layers/d3d9/TextureD3D9.h index f4651248bc..bc152648a4 100644 --- a/gfx/layers/d3d9/TextureD3D9.h +++ b/gfx/layers/d3d9/TextureD3D9.h @@ -206,7 +206,7 @@ public: static D3D9TextureData* Create(gfx::IntSize aSize, gfx::SurfaceFormat aFormat, TextureAllocationFlags aFlags); - virtual void Deallocate(ISurfaceAllocator* aAllocator) {} + virtual void Deallocate(ISurfaceAllocator* aAllocator) override {} protected: D3D9TextureData(gfx::IntSize aSize, gfx::SurfaceFormat aFormat, @@ -234,7 +234,7 @@ public: ~DXGID3D9TextureData(); - virtual gfx::IntSize GetSize() const { return gfx::IntSize(mDesc.Width, mDesc.Height); } + virtual gfx::IntSize GetSize() const override { return gfx::IntSize(mDesc.Width, mDesc.Height); } virtual gfx::SurfaceFormat GetFormat() const override { return mFormat; } @@ -246,7 +246,7 @@ public: virtual bool HasInternalBuffer() const override { return false; } - virtual void Deallocate(ISurfaceAllocator* aAllocator) {} + virtual void Deallocate(ISurfaceAllocator* aAllocator) override {} IDirect3DDevice9* GetD3D9Device() { return mDevice; } IDirect3DTexture9* GetD3D9Texture() { return mTexture; } diff --git a/gfx/skia/skia/src/core/SkVarAlloc.cpp b/gfx/skia/skia/src/core/SkVarAlloc.cpp index 840cf28347..149f0515b0 100644 --- a/gfx/skia/skia/src/core/SkVarAlloc.cpp +++ b/gfx/skia/skia/src/core/SkVarAlloc.cpp @@ -11,7 +11,7 @@ #if defined(SK_BUILD_FOR_MAC) #include #elif defined(SK_BUILD_FOR_UNIX) || defined(SK_BUILD_FOR_WIN32) - #include +// #include #endif struct SkVarAlloc::Block { diff --git a/gfx/skia/skia/src/ports/SkTime_Unix.cpp b/gfx/skia/skia/src/ports/SkTime_Unix.cpp index 1ea3b8fbd0..396abc0436 100644 --- a/gfx/skia/skia/src/ports/SkTime_Unix.cpp +++ b/gfx/skia/skia/src/ports/SkTime_Unix.cpp @@ -24,7 +24,11 @@ void SkTime::GetDateTime(DateTime* dt) int offset = tstruct->tm_isdst == 1 ? 60 : 0; // http://pubs.opengroup.org/onlinepubs/009695399/basedefs/time.h.html +#if defined(__FreeBSD__) + dt->fTimeZoneMinutes = SkToS16(offset - tstruct->tm_gmtoff / 60); +#else dt->fTimeZoneMinutes = SkToS16(offset - timezone / 60); +#endif dt->fYear = tstruct->tm_year + 1900; dt->fMonth = SkToU8(tstruct->tm_mon + 1); dt->fDayOfWeek = SkToU8(tstruct->tm_wday); diff --git a/gfx/src/FilterSupport.cpp b/gfx/src/FilterSupport.cpp index 3040b0e026..ed7072e1c0 100644 --- a/gfx/src/FilterSupport.cpp +++ b/gfx/src/FilterSupport.cpp @@ -1665,7 +1665,7 @@ SourceNeededRegionForPrimitive(const FilterPrimitiveDescription& aDescription, case PrimitiveType::Flood: case PrimitiveType::Turbulence: case PrimitiveType::Image: - MOZ_CRASH("this shouldn't be called for filters without inputs"); + MOZ_CRASH("GFX: this shouldn't be called for filters without inputs"); return nsIntRegion(); case PrimitiveType::Empty: diff --git a/gfx/thebes/gfxDWriteFonts.h b/gfx/thebes/gfxDWriteFonts.h index 89c085e6d6..58de169df3 100644 --- a/gfx/thebes/gfxDWriteFonts.h +++ b/gfx/thebes/gfxDWriteFonts.h @@ -63,11 +63,11 @@ public: GetGlyphRenderingOptions(const TextRunDrawParams* aRunParams = nullptr) override; virtual void AddSizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf, - FontCacheSizes* aSizes) const; + FontCacheSizes* aSizes) const override; virtual void AddSizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf, - FontCacheSizes* aSizes) const; + FontCacheSizes* aSizes) const override; - virtual FontType GetType() const { return FONT_TYPE_DWRITE; } + virtual FontType GetType() const override { return FONT_TYPE_DWRITE; } virtual already_AddRefed GetScaledFont(mozilla::gfx::DrawTarget *aTarget) override; diff --git a/gfx/thebes/gfxPlatform.cpp b/gfx/thebes/gfxPlatform.cpp index 5952787c3a..80b9c68074 100644 --- a/gfx/thebes/gfxPlatform.cpp +++ b/gfx/thebes/gfxPlatform.cpp @@ -814,7 +814,7 @@ gfxPlatform::CreateDrawTargetForUpdateSurface(gfxASurface *aSurface, const IntSi return Factory::CreateDrawTargetForCairoCGContext(static_cast(aSurface)->GetCGContext(), aSize); } #endif - MOZ_CRASH("unused function"); + MOZ_CRASH("GFX: unused function"); return nullptr; } diff --git a/gfx/thebes/gfxWindowsPlatform.h b/gfx/thebes/gfxWindowsPlatform.h index 6460e3bde7..20ec4c5fc2 100644 --- a/gfx/thebes/gfxWindowsPlatform.h +++ b/gfx/thebes/gfxWindowsPlatform.h @@ -114,14 +114,14 @@ public: return (gfxWindowsPlatform*) gfxPlatform::GetPlatform(); } - virtual gfxPlatformFontList* CreatePlatformFontList(); + virtual gfxPlatformFontList* CreatePlatformFontList() override; virtual already_AddRefed CreateOffscreenSurface(const IntSize& aSize, gfxImageFormat aFormat) override; virtual already_AddRefed - GetScaledFontForFont(mozilla::gfx::DrawTarget* aTarget, gfxFont *aFont); + GetScaledFontForFont(mozilla::gfx::DrawTarget* aTarget, gfxFont *aFont) override; enum RenderMode { /* Use GDI and windows surfaces */ @@ -171,15 +171,15 @@ public: nsresult GetFontList(nsIAtom *aLangGroup, const nsACString& aGenericFamily, - nsTArray& aListOfFonts); + nsTArray& aListOfFonts) override; nsresult UpdateFontList(); virtual void GetCommonFallbackFonts(uint32_t aCh, uint32_t aNextCh, int32_t aRunScript, - nsTArray& aFontList); + nsTArray& aFontList) override; - nsresult GetStandardFamilyName(const nsAString& aFontName, nsAString& aFamilyName); + nsresult GetStandardFamilyName(const nsAString& aFontName, nsAString& aFamilyName) override; gfxFontGroup* CreateFontGroup(const mozilla::FontFamilyList& aFontFamilyList, @@ -194,7 +194,7 @@ public: virtual gfxFontEntry* LookupLocalFont(const nsAString& aFontName, uint16_t aWeight, int16_t aStretch, - uint8_t aStyle); + uint8_t aStyle) override; /** * Activate a platform font (needed to support @font-face src url() ) @@ -204,16 +204,16 @@ public: int16_t aStretch, uint8_t aStyle, const uint8_t* aFontData, - uint32_t aLength); + uint32_t aLength) override; virtual bool CanUseHardwareVideoDecoding() override; /** * Check whether format is supported on a platform or not (if unclear, returns true) */ - virtual bool IsFontFormatSupported(nsIURI *aFontURI, uint32_t aFormatFlags); + virtual bool IsFontFormatSupported(nsIURI *aFontURI, uint32_t aFormatFlags) override; - virtual bool DidRenderingDeviceReset(DeviceResetReason* aResetReason = nullptr); + virtual bool DidRenderingDeviceReset(DeviceResetReason* aResetReason = nullptr) override; mozilla::gfx::BackendType GetContentBackendFor(mozilla::layers::LayersBackend aLayers) override; @@ -227,7 +227,7 @@ public: // returns ClearType tuning information for each display static void GetCleartypeParams(nsTArray& aParams); - virtual void FontsPrefsChanged(const char *aPref); + virtual void FontsPrefsChanged(const char *aPref) override; void SetupClearTypeParams(); @@ -304,8 +304,8 @@ protected: bool AccelerateLayersByDefault() override { return true; } - void GetAcceleratedCompositorBackends(nsTArray& aBackends); - virtual void GetPlatformCMSOutputProfile(void* &mem, size_t &size); + void GetAcceleratedCompositorBackends(nsTArray& aBackends) override; + virtual void GetPlatformCMSOutputProfile(void* &mem, size_t &size) override; void SetDeviceInitData(mozilla::gfx::DeviceInitData& aData) override; protected: diff --git a/js/src/frontend/TokenStream.cpp b/js/src/frontend/TokenStream.cpp index b82d5a89a3..64d8b0d06e 100644 --- a/js/src/frontend/TokenStream.cpp +++ b/js/src/frontend/TokenStream.cpp @@ -987,16 +987,8 @@ TokenStream::putIdentInTokenbuf(const char16_t* identStart) bool TokenStream::checkForKeyword(const KeywordInfo* kw, TokenKind* ttp) { - if (kw->tokentype == TOK_RESERVED -#ifndef JS_HAS_CLASSES - || kw->tokentype == TOK_CLASS - || kw->tokentype == TOK_EXTENDS - || kw->tokentype == TOK_SUPER -#endif - ) - { + if (kw->tokentype == TOK_RESERVED) return reportError(JSMSG_RESERVED_ID, kw->chars); - } if (kw->tokentype == TOK_RESERVED) return reportError(JSMSG_RESERVED_ID, kw->chars); diff --git a/js/src/gc/Statistics.cpp b/js/src/gc/Statistics.cpp index a516bc3e5f..d9bcdaf9e7 100644 --- a/js/src/gc/Statistics.cpp +++ b/js/src/gc/Statistics.cpp @@ -756,64 +756,6 @@ Statistics::Statistics(JSRuntime* rt) for (auto d : MakeRange(NumTimingArrays)) PodArrayZero(phaseTimes[d]); - static bool initialized = false; - if (!initialized) { - initialized = true; - - for (size_t i = 0; i < PHASE_LIMIT; i++) { - MOZ_ASSERT(phases[i].index == i); - for (size_t j = 0; j < PHASE_LIMIT; j++) - MOZ_ASSERT_IF(i != j, phases[i].telemetryBucket != phases[j].telemetryBucket); - } - - // Create a static table of descendants for every phase with multiple - // children. This assumes that all descendants come linearly in the - // list, which is reasonable since full dags are not supported; any - // path from the leaf to the root must encounter at most one node with - // multiple parents. - size_t dagSlot = 0; - for (size_t i = 0; i < mozilla::ArrayLength(dagChildEdges); i++) { - Phase parent = dagChildEdges[i].parent; - if (!phaseExtra[parent].dagSlot) - phaseExtra[parent].dagSlot = ++dagSlot; - - Phase child = dagChildEdges[i].child; - MOZ_ASSERT(phases[child].parent == PHASE_MULTI_PARENTS); - int j = child; - do { - if (!dagDescendants[phaseExtra[parent].dagSlot].append(Phase(j))) { - initialized = false; - return; - } - j++; - } while (j != PHASE_LIMIT && phases[j].parent != PHASE_MULTI_PARENTS); - } - MOZ_ASSERT(dagSlot <= MaxMultiparentPhases - 1); - - // Fill in the depth of each node in the tree. Multi-parented nodes - // have depth 0. - mozilla::Vector stack; - if (!stack.append(PHASE_LIMIT)) { // Dummy entry to avoid special-casing the first node - initialized = false; - return; - } - for (int i = 0; i < PHASE_LIMIT; i++) { - if (phases[i].parent == PHASE_NO_PARENT || - phases[i].parent == PHASE_MULTI_PARENTS) - { - stack.clear(); - } else { - while (stack.back() != phases[i].parent) - stack.popBack(); - } - phaseExtra[i].depth = stack.length(); - if (!stack.append(Phase(i))) { - initialized = false; - return; - } - } - } - char* env = getenv("MOZ_GCTIMER"); if (env) { if (strcmp(env, "none") == 0) { @@ -836,6 +778,55 @@ Statistics::~Statistics() fclose(fp); } +/* static */ void +Statistics::initialize() +{ + for (size_t i = 0; i < PHASE_LIMIT; i++) { + MOZ_ASSERT(phases[i].index == i); + for (size_t j = 0; j < PHASE_LIMIT; j++) + MOZ_ASSERT_IF(i != j, phases[i].telemetryBucket != phases[j].telemetryBucket); + } + + // Create a static table of descendants for every phase with multiple + // children. This assumes that all descendants come linearly in the + // list, which is reasonable since full dags are not supported; any + // path from the leaf to the root must encounter at most one node with + // multiple parents. + size_t dagSlot = 0; + for (size_t i = 0; i < mozilla::ArrayLength(dagChildEdges); i++) { + Phase parent = dagChildEdges[i].parent; + if (!phaseExtra[parent].dagSlot) + phaseExtra[parent].dagSlot = ++dagSlot; + + Phase child = dagChildEdges[i].child; + MOZ_ASSERT(phases[child].parent == PHASE_MULTI_PARENTS); + int j = child; + do { + dagDescendants[phaseExtra[parent].dagSlot].append(Phase(j)); + j++; + } while (j != PHASE_LIMIT && phases[j].parent != PHASE_MULTI_PARENTS); + } + MOZ_ASSERT(dagSlot <= MaxMultiparentPhases - 1); + + // Fill in the depth of each node in the tree. Multi-parented nodes + // have depth 0. + mozilla::Vector stack; + stack.append(PHASE_LIMIT); // Dummy entry to avoid special-casing the first node + for (int i = 0; i < PHASE_LIMIT; i++) { + if (phases[i].parent == PHASE_NO_PARENT || + phases[i].parent == PHASE_MULTI_PARENTS) + { + stack.clear(); + } else { + while (stack.back() != phases[i].parent) + stack.popBack(); + } + phaseExtra[i].depth = stack.length(); + stack.append(Phase(i)); + } + +} + JS::GCSliceCallback Statistics::setSliceCallback(JS::GCSliceCallback newCallback) { diff --git a/js/src/gc/Statistics.h b/js/src/gc/Statistics.h index 722e1f8a22..3f78225ef6 100644 --- a/js/src/gc/Statistics.h +++ b/js/src/gc/Statistics.h @@ -162,6 +162,8 @@ struct Statistics /* Create a convenient type for referring to tables of phase times. */ using PhaseTimeTable = int64_t[NumTimingArrays][PHASE_LIMIT]; + static void initialize(); + explicit Statistics(JSRuntime* rt); ~Statistics(); diff --git a/js/src/irregexp/NativeRegExpMacroAssembler.cpp b/js/src/irregexp/NativeRegExpMacroAssembler.cpp index d0b47f7fb8..9cf9bfe534 100644 --- a/js/src/irregexp/NativeRegExpMacroAssembler.cpp +++ b/js/src/irregexp/NativeRegExpMacroAssembler.cpp @@ -122,8 +122,7 @@ NativeRegExpMacroAssembler::GenerateCode(JSContext* cx, bool match_only) #ifdef JS_CODEGEN_ARM64 // ARM64 communicates stack address via sp, but uses a pseudo-sp for addressing. - MOZ_ASSERT(!masm.GetStackPointer64().Is(sp)); - masm.Mov(masm.GetStackPointer64(), sp); + masm.initStackPtr(); #endif // Push non-volatile registers which might be modified by jitcode. diff --git a/js/src/jit-test/lib/syntax.js b/js/src/jit-test/lib/syntax.js index 2a847bf6eb..86f8b4e197 100644 --- a/js/src/jit-test/lib/syntax.js +++ b/js/src/jit-test/lib/syntax.js @@ -1,13 +1,15 @@ -load(libdir + "class.js"); - -function test_syntax(replacements, check_error, ignore_opts) { - function test_reflect(code) { - for (var repl of replacements) { - var cur_code = code.replace(/@/, repl); +function test_syntax(postfixes, check_error, ignore_opts) { + function test_reflect(code, module) { + var options = undefined; + if (module) { + options = {target: "module"}; + } + for (var postfix of postfixes) { + var cur_code = code + postfix; var caught = false; try { - Reflect.parse(cur_code); + Reflect.parse(cur_code, options); } catch (e) { caught = true; check_error(e, cur_code, "reflect"); @@ -17,8 +19,8 @@ function test_syntax(replacements, check_error, ignore_opts) { } function test_eval(code) { - for (var repl of replacements) { - var cur_code = code.replace(/@/, repl); + for (var postfix of postfixes) { + var cur_code = code + postfix; var caught = false; try { @@ -39,15 +41,16 @@ function test_syntax(replacements, check_error, ignore_opts) { let no_strict = "no_strict" in opts && opts.no_strict; let no_fun = "no_fun" in opts && opts.no_fun; let no_eval = "no_eval" in opts && opts.no_eval; + let module = "module" in opts && opts.module; - test_reflect(code); + test_reflect(code, module); if (!no_strict) { - test_reflect("'use strict'; " + code); + test_reflect("'use strict'; " + code, module); } if (!no_fun) { - test_reflect("(function() { " + code); + test_reflect("(function() { " + code, module); if (!no_strict) { - test_reflect("(function() { 'use strict'; " + code); + test_reflect("(function() { 'use strict'; " + code, module); } } @@ -65,17 +68,9 @@ function test_syntax(replacements, check_error, ignore_opts) { } } - function test_no_strict(code) { - test(code, { no_strict: true }); - } - - function test_no_fun_no_eval(code) { - test(code, { no_fun: true, no_eval: true }); - } - function test_fun_arg(arg) { - for (var repl of replacements) { - var cur_arg = arg.replace(/@/, repl); + for (var postfix of postfixes) { + var cur_arg = arg + postfix; var caught = false; try { @@ -94,523 +89,521 @@ function test_syntax(replacements, check_error, ignore_opts) { // Block - test("{ @"); - test("{ } @"); + test("{ "); + test("{ } "); - test("{ 1 @"); - test("{ 1; @"); - test("{ 1; } @"); + test("{ 1 "); + test("{ 1; "); + test("{ 1; } "); // break - test("a: for (;;) { break @"); - test("a: for (;;) { break; @"); - test("a: for (;;) { break a @"); - test("a: for (;;) { break a; @"); + test("a: for (;;) { break "); + test("a: for (;;) { break; "); + test("a: for (;;) { break a "); + test("a: for (;;) { break a; "); - test("a: for (;;) { break\n@"); + test("a: for (;;) { break\n"); // continue - test("a: for (;;) { continue @"); - test("a: for (;;) { continue; @"); - test("a: for (;;) { continue a @"); - test("a: for (;;) { continue a; @"); + test("a: for (;;) { continue "); + test("a: for (;;) { continue; "); + test("a: for (;;) { continue a "); + test("a: for (;;) { continue a; "); - test("a: for (;;) { continue\n@"); + test("a: for (;;) { continue\n"); // Empty - test("@"); - test("; @"); + test(""); + test("; "); // if...else - test("if @"); - test("if (@"); - test("if (x @"); - test("if (x) @"); - test("if (x) { @"); - test("if (x) {} @"); - test("if (x) {} else @"); - test("if (x) {} else { @"); - test("if (x) {} else {} @"); - test("if (x) x @"); - test("if (x) x; @"); - test("if (x) x; else @"); - test("if (x) x; else y @"); - test("if (x) x; else y; @"); + test("if "); + test("if ("); + test("if (x "); + test("if (x) "); + test("if (x) { "); + test("if (x) {} "); + test("if (x) {} else "); + test("if (x) {} else { "); + test("if (x) {} else {} "); + test("if (x) x "); + test("if (x) x; "); + test("if (x) x; else "); + test("if (x) x; else y "); + test("if (x) x; else y; "); // switch - test("switch @"); - test("switch (@"); - test("switch (x @"); - test("switch (x) @"); - test("switch (x) { @"); - test("switch (x) { case @"); - test("switch (x) { case 1 @"); - test("switch (x) { case 1: @"); - test("switch (x) { case 1: case @"); - test("switch (x) { case 1: case 2 @"); - test("switch (x) { case 1: case 2: @"); - test("switch (x) { case 1: case 2: x @"); - test("switch (x) { case 1: case 2: x; @"); - test("switch (x) { case 1: case 2: x; break @"); - test("switch (x) { case 1: case 2: x; break; @"); - test("switch (x) { case 1: case 2: x; break; case @"); - test("switch (x) { case 1: case 2: x; break; case 3 @"); - test("switch (x) { case 1: case 2: x; break; case 3: y @"); - test("switch (x) { case 1: case 2: x; break; case 3: y; @"); - test("switch (x) { case 1: case 2: x; break; case 3: y; default @"); - test("switch (x) { case 1: case 2: x; break; case 3: y; default: @"); - test("switch (x) { case 1: case 2: x; break; case 3: y; default: z @"); - test("switch (x) { case 1: case 2: x; break; case 3: y; default: z; @"); - test("switch (x) { case 1: case 2: x; break; case 3: y; default: z; } @"); + test("switch "); + test("switch ("); + test("switch (x "); + test("switch (x) "); + test("switch (x) { "); + test("switch (x) { case "); + test("switch (x) { case 1 "); + test("switch (x) { case 1: "); + test("switch (x) { case 1: case "); + test("switch (x) { case 1: case 2 "); + test("switch (x) { case 1: case 2: "); + test("switch (x) { case 1: case 2: x "); + test("switch (x) { case 1: case 2: x; "); + test("switch (x) { case 1: case 2: x; break "); + test("switch (x) { case 1: case 2: x; break; "); + test("switch (x) { case 1: case 2: x; break; case "); + test("switch (x) { case 1: case 2: x; break; case 3 "); + test("switch (x) { case 1: case 2: x; break; case 3: y "); + test("switch (x) { case 1: case 2: x; break; case 3: y; "); + test("switch (x) { case 1: case 2: x; break; case 3: y; default "); + test("switch (x) { case 1: case 2: x; break; case 3: y; default: "); + test("switch (x) { case 1: case 2: x; break; case 3: y; default: z "); + test("switch (x) { case 1: case 2: x; break; case 3: y; default: z; "); + test("switch (x) { case 1: case 2: x; break; case 3: y; default: z; } "); // throw - test("throw @"); - test("throw x @"); - test("throw x; @"); + test("throw "); + test("throw x "); + test("throw x; "); // try...catch - test("try @"); - test("try { @"); - test("try {} @"); - test("try {} catch @"); - test("try {} catch ( @"); - test("try {} catch (e @"); - test("try {} catch (e) @"); - test("try {} catch (e) { @"); - test("try {} catch (e) {} @"); - test("try {} catch (e) {} finally @"); - test("try {} catch (e) {} finally { @"); - test("try {} catch (e) {} finally {} @"); + test("try "); + test("try { "); + test("try {} "); + test("try {} catch "); + test("try {} catch ( "); + test("try {} catch (e "); + test("try {} catch (e) "); + test("try {} catch (e) { "); + test("try {} catch (e) {} "); + test("try {} catch (e) {} finally "); + test("try {} catch (e) {} finally { "); + test("try {} catch (e) {} finally {} "); - test("try {} catch (e if @"); - test("try {} catch (e if e @"); - test("try {} catch (e if e instanceof @"); - test("try {} catch (e if e instanceof x @"); - test("try {} catch (e if e instanceof x) @"); - test("try {} catch (e if e instanceof x) { @"); - test("try {} catch (e if e instanceof x) {} @"); + test("try {} catch (e if "); + test("try {} catch (e if e "); + test("try {} catch (e if e instanceof "); + test("try {} catch (e if e instanceof x "); + test("try {} catch (e if e instanceof x) "); + test("try {} catch (e if e instanceof x) { "); + test("try {} catch (e if e instanceof x) {} "); // ---- Declarations ---- // var - test("var @"); - test("var x @"); - test("var x = @"); - test("var x = 1 @"); - test("var x = 1 + @"); - test("var x = 1 + 2 @"); - test("var x = 1 + 2, @"); - test("var x = 1 + 2, y @"); - test("var x = 1 + 2, y, @"); - test("var x = 1 + 2, y, z @"); - test("var x = 1 + 2, y, z; @"); + test("var "); + test("var x "); + test("var x = "); + test("var x = 1 "); + test("var x = 1 + "); + test("var x = 1 + 2 "); + test("var x = 1 + 2, "); + test("var x = 1 + 2, y "); + test("var x = 1 + 2, y, "); + test("var x = 1 + 2, y, z "); + test("var x = 1 + 2, y, z; "); - test("var [ @"); - test("var [ x @"); - test("var [ x, @"); - test("var [ x, ... @"); - test("var { @"); - test("var { x @"); - test("var { x: @"); - test("var { x: y @"); - test("var { x: y, @"); - test("var { x: y } @"); - test("var { x: y } = @"); + test("var [ "); + test("var [ x "); + test("var [ x, "); + test("var [ x, ... "); + test("var { "); + test("var { x "); + test("var { x: "); + test("var { x: y "); + test("var { x: y, "); + test("var { x: y } "); + test("var { x: y } = "); // let - test("let @"); - test("let x @"); - test("let x = @"); - test("let x = 1 @"); - test("let x = 1 + @"); - test("let x = 1 + 2 @"); - test("let x = 1 + 2, @"); - test("let x = 1 + 2, y @"); - test("let x = 1 + 2, y, @"); - test("let x = 1 + 2, y, z @"); - test("let x = 1 + 2, y, z; @"); + test("let "); + test("let x "); + test("let x = "); + test("let x = 1 "); + test("let x = 1 + "); + test("let x = 1 + 2 "); + test("let x = 1 + 2, "); + test("let x = 1 + 2, y "); + test("let x = 1 + 2, y, "); + test("let x = 1 + 2, y, z "); + test("let x = 1 + 2, y, z; "); - test("let [ @"); - test("let [ x @"); - test("let [ x, @"); - test("let [ x, ... @"); - test("let { @"); - test("let { x @"); - test("let { x: @"); - test("let { x: y @"); - test("let { x: y, @"); - test("let { x: y } @"); - test("let { x: y } = @"); + test("let [ "); + test("let [ x "); + test("let [ x, "); + test("let [ x, ... "); + test("let { "); + test("let { x "); + test("let { x: "); + test("let { x: y "); + test("let { x: y, "); + test("let { x: y } "); + test("let { x: y } = "); // const - test("const @"); - test("const x @"); - test("const x = @"); - test("const x = 1 @"); - test("const x = 1 + @"); - test("const x = 1 + 2 @"); - test("const x = 1 + 2, @"); - test("const x = 1 + 2, y = 0@"); - test("const x = 1 + 2, y = 0, @"); - test("const x = 1 + 2, y = 0, z = 0 @"); - test("const x = 1 + 2, y = 0, z = 0; @"); + test("const "); + test("const x "); + test("const x = "); + test("const x = 1 "); + test("const x = 1 + "); + test("const x = 1 + 2 "); + test("const x = 1 + 2, "); + test("const x = 1 + 2, y = 0"); + test("const x = 1 + 2, y = 0, "); + test("const x = 1 + 2, y = 0, z = 0 "); + test("const x = 1 + 2, y = 0, z = 0; "); - test("const [ @"); - test("const [ x @"); - test("const [ x, @"); - test("const [ x, ... @"); - test("const { @"); - test("const { x @"); - test("const { x: @"); - test("const { x: y @"); - test("const { x: y, @"); - test("const { x: y } @"); - test("const { x: y } = @"); + test("const [ "); + test("const [ x "); + test("const [ x, "); + test("const [ x, ... "); + test("const { "); + test("const { x "); + test("const { x: "); + test("const { x: y "); + test("const { x: y, "); + test("const { x: y } "); + test("const { x: y } = "); // ---- Functions ---- // function - test("function @"); - test("function f @"); - test("function f( @"); - test("function f(x @"); - test("function f(x, @"); - test("function f(x, [ @"); - test("function f(x, [y @"); - test("function f(x, [y, @"); - test("function f(x, [y, { @"); - test("function f(x, [y, {z @"); - test("function f(x, [y, {z: @"); - test("function f(x, [y, {z: zz @"); - test("function f(x, [y, {z: zz, @"); - test("function f(x, [y, {z: zz, w @"); - test("function f(x, [y, {z: zz, w} @"); - test("function f(x, [y, {z: zz, w}] @"); - test("function f(x, [y, {z: zz, w}], @"); - test("function f(x, [y, {z: zz, w}], v @"); - test("function f(x, [y, {z: zz, w}], v= @"); - test("function f(x, [y, {z: zz, w}], v=1 @"); - test("function f(x, [y, {z: zz, w}], v=1, @"); - test("function f(x, [y, {z: zz, w}], v=1, ... @"); - test("function f(x, [y, {z: zz, w}], v=1, ...t @"); - test("function f(x, [y, {z: zz, w}], v=1, ...t) @"); - test("function f(x, [y, {z: zz, w}], v=1, ...t) {@"); - test("function f(x, [y, {z: zz, w}], v=1, ...t) { x @"); - test("function f(x, [y, {z: zz, w}], v=1, ...t) { x; @"); - test("function f(x, [y, {z: zz, w}], v=1, ...t) { x; } @"); + test("function "); + test("function f "); + test("function f( "); + test("function f(x "); + test("function f(x, "); + test("function f(x, [ "); + test("function f(x, [y "); + test("function f(x, [y, "); + test("function f(x, [y, { "); + test("function f(x, [y, {z "); + test("function f(x, [y, {z: "); + test("function f(x, [y, {z: zz "); + test("function f(x, [y, {z: zz, "); + test("function f(x, [y, {z: zz, w "); + test("function f(x, [y, {z: zz, w} "); + test("function f(x, [y, {z: zz, w}] "); + test("function f(x, [y, {z: zz, w}], "); + test("function f(x, [y, {z: zz, w}], v "); + test("function f(x, [y, {z: zz, w}], v= "); + test("function f(x, [y, {z: zz, w}], v=1 "); + test("function f(x, [y, {z: zz, w}], v=1, "); + test("function f(x, [y, {z: zz, w}], v=1, ... "); + test("function f(x, [y, {z: zz, w}], v=1, ...t "); + test("function f(x, [y, {z: zz, w}], v=1, ...t) "); + test("function f(x, [y, {z: zz, w}], v=1, ...t) {"); + test("function f(x, [y, {z: zz, w}], v=1, ...t) { x "); + test("function f(x, [y, {z: zz, w}], v=1, ...t) { x; "); + test("function f(x, [y, {z: zz, w}], v=1, ...t) { x; } "); // star function - test("function* @"); - test("function* f @"); - test("function* f( @"); - test("function* f(x @"); - test("function* f(x, @"); - test("function* f(x, ... @"); - test("function* f(x, ...t @"); - test("function* f(x, ...t) @"); - test("function* f(x, ...t) {@"); - test("function* f(x, ...t) { x @"); - test("function* f(x, ...t) { x; @"); - test("function* f(x, ...t) { x; } @"); + test("function* "); + test("function* f "); + test("function* f( "); + test("function* f(x "); + test("function* f(x, "); + test("function* f(x, ... "); + test("function* f(x, ...t "); + test("function* f(x, ...t) "); + test("function* f(x, ...t) {"); + test("function* f(x, ...t) { x "); + test("function* f(x, ...t) { x; "); + test("function* f(x, ...t) { x; } "); // return - test("function f() { return @"); - test("function f() { return 1 @"); - test("function f() { return 1; @"); - test("function f() { return 1; } @"); - test("function f() { return; @"); - test("function f() { return\n@"); + test("function f() { return "); + test("function f() { return 1 "); + test("function f() { return 1; "); + test("function f() { return 1; } "); + test("function f() { return; "); + test("function f() { return\n"); // yield - test("function* f() { yield @"); - test("function* f() { yield 1 @"); - test("function* f() { yield* @"); - test("function* f() { yield* 1 @"); + test("function* f() { yield "); + test("function* f() { yield 1 "); + test("function* f() { yield* "); + test("function* f() { yield* 1 "); - test("function* f() { yield\n@"); - test("function* f() { yield*\n@"); + test("function* f() { yield\n"); + test("function* f() { yield*\n"); // ---- Iterations ---- // do...while - test("do @"); - test("do {@"); - test("do {} @"); - test("do {} while @"); - test("do {} while ( @"); - test("do {} while (x @"); - test("do {} while (x) @"); - test("do {} while (x); @"); + test("do "); + test("do {"); + test("do {} "); + test("do {} while "); + test("do {} while ( "); + test("do {} while (x "); + test("do {} while (x) "); + test("do {} while (x); "); - test("do x @"); - test("do x; @"); - test("do x; while @"); + test("do x "); + test("do x; "); + test("do x; while "); // for - test("for @"); - test("for (@"); - test("for (x @"); - test("for (x; @"); - test("for (x; y @"); - test("for (x; y; @"); - test("for (x; y; z @"); - test("for (x; y; z) @"); - test("for (x; y; z) { @"); - test("for (x; y; z) {} @"); + test("for "); + test("for ("); + test("for (x "); + test("for (x; "); + test("for (x; y "); + test("for (x; y; "); + test("for (x; y; z "); + test("for (x; y; z) "); + test("for (x; y; z) { "); + test("for (x; y; z) {} "); - test("for (x; y; z) x @"); - test("for (x; y; z) x; @"); + test("for (x; y; z) x "); + test("for (x; y; z) x; "); - test("for (var @"); - test("for (var x @"); - test("for (var x = @"); - test("for (var x = y @"); - test("for (var x = y; @"); + test("for (var "); + test("for (var x "); + test("for (var x = "); + test("for (var x = y "); + test("for (var x = y; "); - test("for (let @"); - test("for (let x @"); - test("for (let x = @"); - test("for (let x = y @"); - test("for (let x = y; @"); + test("for (let "); + test("for (let x "); + test("for (let x = "); + test("for (let x = y "); + test("for (let x = y; "); // for...in - test("for (x in @"); - test("for (x in y @"); - test("for (x in y) @"); + test("for (x in "); + test("for (x in y "); + test("for (x in y) "); - test("for (var x in @"); - test("for (var x in y @"); - test("for (var x in y) @"); + test("for (var x in "); + test("for (var x in y "); + test("for (var x in y) "); - test("for (let x in @"); - test("for (let x in y @"); - test("for (let x in y) @"); + test("for (let x in "); + test("for (let x in y "); + test("for (let x in y) "); // for...of - test("for (x of @"); - test("for (x of y @"); - test("for (x of y) @"); + test("for (x of "); + test("for (x of y "); + test("for (x of y) "); - test("for (var x of @"); - test("for (var x of y @"); - test("for (var x of y) @"); + test("for (var x of "); + test("for (var x of y "); + test("for (var x of y) "); - test("for (let x of @"); - test("for (let x of y @"); - test("for (let x of y) @"); + test("for (let x of "); + test("for (let x of y "); + test("for (let x of y) "); // while - test("while @"); - test("while (@"); - test("while (x @"); - test("while (x) @"); - test("while (x) { @"); - test("while (x) {} @"); + test("while "); + test("while ("); + test("while (x "); + test("while (x) "); + test("while (x) { "); + test("while (x) {} "); - test("while (x) x @"); - test("while (x) x; @"); + test("while (x) x "); + test("while (x) x; "); // ---- Others ---- // debugger - test("debugger @"); - test("debugger; @"); + test("debugger "); + test("debugger; "); // export - test_no_fun_no_eval("export @"); - test_no_fun_no_eval("export { @"); - test_no_fun_no_eval("export { x @"); - test_no_fun_no_eval("export { x, @"); - test_no_fun_no_eval("export { x, y @"); - test_no_fun_no_eval("export { x, y as @"); - test_no_fun_no_eval("export { x, y as z @"); - test_no_fun_no_eval("export { x, y as z } @"); - test_no_fun_no_eval("export { x, y as z } from @"); - test_no_fun_no_eval("export { x, y as z } from 'a' @"); - test_no_fun_no_eval("export { x, y as z } from 'a'; @"); + var opts = { no_fun: true, no_eval: true, module: true }; + test("export ", opts); + test("export { ", opts); + test("export { x ", opts); + test("export { x, ", opts); + test("export { x, y ", opts); + test("export { x, y as ", opts); + test("export { x, y as z ", opts); + test("export { x, y as z } ", opts); + test("export { x, y as z } from ", opts); + test("export { x, y as z } from 'a' ", opts); + test("export { x, y as z } from 'a'; ", opts); - test_no_fun_no_eval("export * @"); - test_no_fun_no_eval("export * from @"); - test_no_fun_no_eval("export * from 'a' @"); - test_no_fun_no_eval("export * from 'a'; @"); + test("export * ", opts); + test("export * from ", opts); + test("export * from 'a' ", opts); + test("export * from 'a'; ", opts); - test_no_fun_no_eval("export function @"); - test_no_fun_no_eval("export function f @"); - test_no_fun_no_eval("export function f( @"); - test_no_fun_no_eval("export function f() @"); - test_no_fun_no_eval("export function f() { @"); - test_no_fun_no_eval("export function f() {} @"); - test_no_fun_no_eval("export function f() {}; @"); + test("export function ", opts); + test("export function f ", opts); + test("export function f( ", opts); + test("export function f() ", opts); + test("export function f() { ", opts); + test("export function f() {} ", opts); + test("export function f() {}; ", opts); - test_no_fun_no_eval("export var @"); - test_no_fun_no_eval("export var a @"); - test_no_fun_no_eval("export var a = @"); - test_no_fun_no_eval("export var a = 1 @"); - test_no_fun_no_eval("export var a = 1, @"); - test_no_fun_no_eval("export var a = 1, b @"); - test_no_fun_no_eval("export var a = 1, b = @"); - test_no_fun_no_eval("export var a = 1, b = 2 @"); - test_no_fun_no_eval("export var a = 1, b = 2; @"); + test("export var ", opts); + test("export var a ", opts); + test("export var a = ", opts); + test("export var a = 1 ", opts); + test("export var a = 1, ", opts); + test("export var a = 1, b ", opts); + test("export var a = 1, b = ", opts); + test("export var a = 1, b = 2 ", opts); + test("export var a = 1, b = 2; ", opts); - test_no_fun_no_eval("export let @"); - test_no_fun_no_eval("export let a @"); - test_no_fun_no_eval("export let a = @"); - test_no_fun_no_eval("export let a = 1 @"); - test_no_fun_no_eval("export let a = 1, @"); - test_no_fun_no_eval("export let a = 1, b @"); - test_no_fun_no_eval("export let a = 1, b = @"); - test_no_fun_no_eval("export let a = 1, b = 2 @"); - test_no_fun_no_eval("export let a = 1, b = 2; @"); + test("export let ", opts); + test("export let a ", opts); + test("export let a = ", opts); + test("export let a = 1 ", opts); + test("export let a = 1, ", opts); + test("export let a = 1, b ", opts); + test("export let a = 1, b = ", opts); + test("export let a = 1, b = 2 ", opts); + test("export let a = 1, b = 2; ", opts); - test_no_fun_no_eval("export const @"); - test_no_fun_no_eval("export const a @"); - test_no_fun_no_eval("export const a = @"); - test_no_fun_no_eval("export const a = 1 @"); - test_no_fun_no_eval("export const a = 1, @"); - test_no_fun_no_eval("export const a = 1, b @"); - test_no_fun_no_eval("export const a = 1, b = @"); - test_no_fun_no_eval("export const a = 1, b = 2 @"); - test_no_fun_no_eval("export const a = 1, b = 2; @"); + test("export const ", opts); + test("export const a ", opts); + test("export const a = ", opts); + test("export const a = 1 ", opts); + test("export const a = 1, ", opts); + test("export const a = 1, b ", opts); + test("export const a = 1, b = ", opts); + test("export const a = 1, b = 2 ", opts); + test("export const a = 1, b = 2; ", opts); - if (classesEnabled()) { - test_no_fun_no_eval("export class @"); - test_no_fun_no_eval("export class Foo @"); - test_no_fun_no_eval("export class Foo { @"); - test_no_fun_no_eval("export class Foo { constructor @"); - test_no_fun_no_eval("export class Foo { constructor( @"); - test_no_fun_no_eval("export class Foo { constructor() @"); - test_no_fun_no_eval("export class Foo { constructor() { @"); - test_no_fun_no_eval("export class Foo { constructor() {} @"); - test_no_fun_no_eval("export class Foo { constructor() {} } @"); - test_no_fun_no_eval("export class Foo { constructor() {} }; @"); - } + test("export class ", opts); + test("export class Foo ", opts); + test("export class Foo { ", opts); + test("export class Foo { constructor ", opts); + test("export class Foo { constructor( ", opts); + test("export class Foo { constructor() ", opts); + test("export class Foo { constructor() { ", opts); + test("export class Foo { constructor() {} ", opts); + test("export class Foo { constructor() {} } ", opts); + test("export class Foo { constructor() {} }; ", opts); - test_no_fun_no_eval("export default @"); - test_no_fun_no_eval("export default 1 @"); - test_no_fun_no_eval("export default 1; @"); + test("export default ", opts); + test("export default 1 ", opts); + test("export default 1; ", opts); - test_no_fun_no_eval("export default function @"); - test_no_fun_no_eval("export default function() @"); - test_no_fun_no_eval("export default function() { @"); - test_no_fun_no_eval("export default function() {} @"); - test_no_fun_no_eval("export default function() {}; @"); + test("export default function ", opts); + test("export default function() ", opts); + test("export default function() { ", opts); + test("export default function() {} ", opts); + test("export default function() {}; ", opts); - test_no_fun_no_eval("export default function foo @"); - test_no_fun_no_eval("export default function foo( @"); - test_no_fun_no_eval("export default function foo() @"); - test_no_fun_no_eval("export default function foo() { @"); - test_no_fun_no_eval("export default function foo() {} @"); - test_no_fun_no_eval("export default function foo() {}; @"); + test("export default function foo ", opts); + test("export default function foo( ", opts); + test("export default function foo() ", opts); + test("export default function foo() { ", opts); + test("export default function foo() {} ", opts); + test("export default function foo() {}; ", opts); - if (classesEnabled()) { - test_no_fun_no_eval("export default class @"); - test_no_fun_no_eval("export default class { @"); - test_no_fun_no_eval("export default class { constructor @"); - test_no_fun_no_eval("export default class { constructor( @"); - test_no_fun_no_eval("export default class { constructor() @"); - test_no_fun_no_eval("export default class { constructor() { @"); - test_no_fun_no_eval("export default class { constructor() {} @"); - test_no_fun_no_eval("export default class { constructor() {} } @"); - test_no_fun_no_eval("export default class { constructor() {} }; @"); + test("export default class ", opts); + test("export default class { ", opts); + test("export default class { constructor ", opts); + test("export default class { constructor( ", opts); + test("export default class { constructor() ", opts); + test("export default class { constructor() { ", opts); + test("export default class { constructor() {} ", opts); + test("export default class { constructor() {} } ", opts); + test("export default class { constructor() {} }; ", opts); - test_no_fun_no_eval("export default class Foo @"); - test_no_fun_no_eval("export default class Foo { @"); - test_no_fun_no_eval("export default class Foo { constructor @"); - test_no_fun_no_eval("export default class Foo { constructor( @"); - test_no_fun_no_eval("export default class Foo { constructor() @"); - test_no_fun_no_eval("export default class Foo { constructor() { @"); - test_no_fun_no_eval("export default class Foo { constructor() {} @"); - test_no_fun_no_eval("export default class Foo { constructor() {} } @"); - test_no_fun_no_eval("export default class Foo { constructor() {} }; @"); - } + test("export default class Foo ", opts); + test("export default class Foo { ", opts); + test("export default class Foo { constructor ", opts); + test("export default class Foo { constructor( ", opts); + test("export default class Foo { constructor() ", opts); + test("export default class Foo { constructor() { ", opts); + test("export default class Foo { constructor() {} ", opts); + test("export default class Foo { constructor() {} } ", opts); + test("export default class Foo { constructor() {} }; ", opts); // import - test_no_fun_no_eval("import @"); - test_no_fun_no_eval("import x @"); - test_no_fun_no_eval("import x from @"); - test_no_fun_no_eval("import x from 'a' @"); - test_no_fun_no_eval("import x from 'a'; @"); + test("import ", opts); + test("import x ", opts); + test("import x from ", opts); + test("import x from 'a' ", opts); + test("import x from 'a'; ", opts); - test_no_fun_no_eval("import { @"); - test_no_fun_no_eval("import { x @"); - test_no_fun_no_eval("import { x, @"); - test_no_fun_no_eval("import { x, y @"); - test_no_fun_no_eval("import { x, y } @"); - test_no_fun_no_eval("import { x, y } from @"); - test_no_fun_no_eval("import { x, y } from 'a' @"); - test_no_fun_no_eval("import { x, y } from 'a'; @"); + test("import { ", opts); + test("import { x ", opts); + test("import { x, ", opts); + test("import { x, y ", opts); + test("import { x, y } ", opts); + test("import { x, y } from ", opts); + test("import { x, y } from 'a' ", opts); + test("import { x, y } from 'a'; ", opts); - test_no_fun_no_eval("import { x as @"); - test_no_fun_no_eval("import { x as y @"); - test_no_fun_no_eval("import { x as y } @"); - test_no_fun_no_eval("import { x as y } from @"); - test_no_fun_no_eval("import { x as y } from 'a' @"); - test_no_fun_no_eval("import { x as y } from 'a'; @"); + test("import { x as ", opts); + test("import { x as y ", opts); + test("import { x as y } ", opts); + test("import { x as y } from ", opts); + test("import { x as y } from 'a' ", opts); + test("import { x as y } from 'a'; ", opts); - test_no_fun_no_eval("import 'a' @"); - test_no_fun_no_eval("import 'a'; @"); + test("import 'a' ", opts); + test("import 'a'; ", opts); - test_no_fun_no_eval("import * @"); - test_no_fun_no_eval("import * as @"); - test_no_fun_no_eval("import * as a @"); - test_no_fun_no_eval("import * as a from @"); - test_no_fun_no_eval("import * as a from 'a' @"); - test_no_fun_no_eval("import * as a from 'a'; @"); + test("import * ", opts); + test("import * as ", opts); + test("import * as a ", opts); + test("import * as a from ", opts); + test("import * as a from 'a' ", opts); + test("import * as a from 'a'; ", opts); - test_no_fun_no_eval("import a @"); - test_no_fun_no_eval("import a, @"); - test_no_fun_no_eval("import a, * @"); - test_no_fun_no_eval("import a, * as @"); - test_no_fun_no_eval("import a, * as b @"); - test_no_fun_no_eval("import a, * as b from @"); - test_no_fun_no_eval("import a, * as b from 'c' @"); - test_no_fun_no_eval("import a, * as b from 'c'; @"); + test("import a ", opts); + test("import a, ", opts); + test("import a, * ", opts); + test("import a, * as ", opts); + test("import a, * as b ", opts); + test("import a, * as b from ", opts); + test("import a, * as b from 'c' ", opts); + test("import a, * as b from 'c'; ", opts); - test_no_fun_no_eval("import a, { @"); - test_no_fun_no_eval("import a, { b @"); - test_no_fun_no_eval("import a, { b } @"); - test_no_fun_no_eval("import a, { b } from @"); - test_no_fun_no_eval("import a, { b } from 'c' @"); - test_no_fun_no_eval("import a, { b } from 'c'; @"); + test("import a, { ", opts); + test("import a, { b ", opts); + test("import a, { b } ", opts); + test("import a, { b } from ", opts); + test("import a, { b } from 'c' ", opts); + test("import a, { b } from 'c'; ", opts); // label - test("a @"); - test("a: @"); + test("a "); + test("a: "); // with - test_no_strict("with @"); - test_no_strict("with (@"); - test_no_strict("with (x @"); - test_no_strict("with (x) @"); - test_no_strict("with (x) { @"); - test_no_strict("with (x) {} @"); + opts = { no_strict: true }; + test("with ", opts); + test("with (", opts); + test("with (x ", opts); + test("with (x) ", opts); + test("with (x) { ", opts); + test("with (x) {} ", opts); - test_no_strict("with (x) x @"); - test_no_strict("with (x) x; @"); + test("with (x) x ", opts); + test("with (x) x; ", opts); // ==== Expressions and operators ==== @@ -618,659 +611,657 @@ function test_syntax(replacements, check_error, ignore_opts) { // this - test("this @"); + test("this "); // function - test("(function @"); - test("(function ( @"); - test("(function (x @"); - test("(function (x, @"); - test("(function (x, ... @"); - test("(function (x, ...t @"); - test("(function (x, ...t) @"); - test("(function (x, ...t) {@"); - test("(function (x, ...t) { x @"); - test("(function (x, ...t) { x; @"); - test("(function (x, ...t) { x; } @"); - test("(function (x, ...t) { x; }) @"); + test("(function "); + test("(function ( "); + test("(function (x "); + test("(function (x, "); + test("(function (x, ... "); + test("(function (x, ...t "); + test("(function (x, ...t) "); + test("(function (x, ...t) {"); + test("(function (x, ...t) { x "); + test("(function (x, ...t) { x; "); + test("(function (x, ...t) { x; } "); + test("(function (x, ...t) { x; }) "); // star function - test("(function* @"); - test("(function* ( @"); - test("(function* (x @"); - test("(function* (x, @"); - test("(function* (x, ... @"); - test("(function* (x, ...t @"); - test("(function* (x, ...t) @"); - test("(function* (x, ...t) {@"); - test("(function* (x, ...t) { x @"); - test("(function* (x, ...t) { x; @"); - test("(function* (x, ...t) { x; } @"); - test("(function* (x, ...t) { x; }) @"); + test("(function* "); + test("(function* ( "); + test("(function* (x "); + test("(function* (x, "); + test("(function* (x, ... "); + test("(function* (x, ...t "); + test("(function* (x, ...t) "); + test("(function* (x, ...t) {"); + test("(function* (x, ...t) { x "); + test("(function* (x, ...t) { x; "); + test("(function* (x, ...t) { x; } "); + test("(function* (x, ...t) { x; }) "); // Array literal - test("[ @"); - test("[] @"); - test("[1 @"); - test("[1, @"); - test("[1, ... @"); - test("[1, ...x @"); - test("[1, ...x] @"); + test("[ "); + test("[] "); + test("[1 "); + test("[1, "); + test("[1, ... "); + test("[1, ...x "); + test("[1, ...x] "); // object - test("({ @"); - test("({ x @"); - test("({ x: @"); - test("({ x: 1 @"); - test("({ x: 1, @"); - test("({ x: 1, y @"); - test("({ x: 1, y: @"); - test("({ x: 1, y: 2 @"); - test("({ x: 1, y: 2, @"); - test("({ x: 1, y: 2, z @"); - test("({ x: 1, y: 2, z, @"); - test("({ x: 1, y: 2, z, w @"); - test("({ x: 1, y: 2, z, w } @"); - test("({ x: 1, y: 2, z, w }) @"); + test("({ "); + test("({ x "); + test("({ x: "); + test("({ x: 1 "); + test("({ x: 1, "); + test("({ x: 1, y "); + test("({ x: 1, y: "); + test("({ x: 1, y: 2 "); + test("({ x: 1, y: 2, "); + test("({ x: 1, y: 2, z "); + test("({ x: 1, y: 2, z, "); + test("({ x: 1, y: 2, z, w "); + test("({ x: 1, y: 2, z, w } "); + test("({ x: 1, y: 2, z, w }) "); // object: computed property - test("({ [@"); - test("({ [k @"); - test("({ [k] @"); - test("({ [k]: @"); - test("({ [k]: 1 @"); - test("({ [k]: 1, @"); + test("({ ["); + test("({ [k "); + test("({ [k] "); + test("({ [k]: "); + test("({ [k]: 1 "); + test("({ [k]: 1, "); // object: getter - test("({ get @"); - test("({ get p @"); - test("({ get p( @"); - test("({ get p() @"); - test("({ get p() { @"); - test("({ get p() {} @"); - test("({ get p() {}, @"); - test("({ get p() {}, } @"); + test("({ get "); + test("({ get p "); + test("({ get p( "); + test("({ get p() "); + test("({ get p() { "); + test("({ get p() {} "); + test("({ get p() {}, "); + test("({ get p() {}, } "); - test("({ get [ @"); - test("({ get [p @"); - test("({ get [p] @"); - test("({ get [p]( @"); - test("({ get [p]() @"); + test("({ get [ "); + test("({ get [p "); + test("({ get [p] "); + test("({ get [p]( "); + test("({ get [p]() "); // object: setter - test("({ set @"); - test("({ set p @"); - test("({ set p( @"); - test("({ set p(v @"); - test("({ set p(v) @"); - test("({ set p(v) { @"); - test("({ set p(v) {} @"); + test("({ set "); + test("({ set p "); + test("({ set p( "); + test("({ set p(v "); + test("({ set p(v) "); + test("({ set p(v) { "); + test("({ set p(v) {} "); - test("({ set [ @"); - test("({ set [p @"); - test("({ set [p] @"); - test("({ set [p]( @"); - test("({ set [p](v @"); - test("({ set [p](v) @"); + test("({ set [ "); + test("({ set [p "); + test("({ set [p] "); + test("({ set [p]( "); + test("({ set [p](v "); + test("({ set [p](v) "); // object: method - test("({ m @"); - test("({ m( @"); - test("({ m() @"); - test("({ m() { @"); - test("({ m() {} @"); - test("({ m() {}, @"); + test("({ m "); + test("({ m( "); + test("({ m() "); + test("({ m() { "); + test("({ m() {} "); + test("({ m() {}, "); - test("({ [ @"); - test("({ [m @"); - test("({ [m] @"); - test("({ [m]( @"); - test("({ [m]() @"); - test("({ [m]() { @"); - test("({ [m]() {} @"); - test("({ [m]() {}, @"); + test("({ [ "); + test("({ [m "); + test("({ [m] "); + test("({ [m]( "); + test("({ [m]() "); + test("({ [m]() { "); + test("({ [m]() {} "); + test("({ [m]() {}, "); - test("({ * @"); - test("({ *m @"); - test("({ *m( @"); - test("({ *m() @"); - test("({ *m() { @"); - test("({ *m() {} @"); - test("({ *m() {}, @"); + test("({ * "); + test("({ *m "); + test("({ *m( "); + test("({ *m() "); + test("({ *m() { "); + test("({ *m() {} "); + test("({ *m() {}, "); - test("({ *[ @"); - test("({ *[m @"); - test("({ *[m] @"); - test("({ *[m]( @"); - test("({ *[m]() @"); - test("({ *[m]() { @"); - test("({ *[m]() {} @"); - test("({ *[m]() {}, @"); + test("({ *[ "); + test("({ *[m "); + test("({ *[m] "); + test("({ *[m]( "); + test("({ *[m]() "); + test("({ *[m]() { "); + test("({ *[m]() {} "); + test("({ *[m]() {}, "); - test("({ * get @"); - test("({ * get ( @"); - test("({ * get () @"); - test("({ * get () { @"); - test("({ * get () {} @"); - test("({ * get () {}, @"); + test("({ * get "); + test("({ * get ( "); + test("({ * get () "); + test("({ * get () { "); + test("({ * get () {} "); + test("({ * get () {}, "); - test("({ * set @"); - test("({ * set ( @"); - test("({ * set () @"); - test("({ * set () { @"); - test("({ * set () {} @"); - test("({ * set () {}, @"); + test("({ * set "); + test("({ * set ( "); + test("({ * set () "); + test("({ * set () { "); + test("({ * set () {} "); + test("({ * set () {}, "); // Regular expression literal - test("/a/ @"); - test("/a/g @"); + test("/a/ "); + test("/a/g "); // Array comprehensions - test("[for @"); - test("[for ( @"); - test("[for (x @"); - test("[for (x of @"); - test("[for (x of y @"); - test("[for (x of y) @"); - test("[for (x of y) x @"); - test("[for (x of y) if @"); - test("[for (x of y) if ( @"); - test("[for (x of y) if (x @"); - test("[for (x of y) if (x == @"); - test("[for (x of y) if (x == 1 @"); - test("[for (x of y) if (x == 1) @"); - test("[for (x of y) if (x == 1) x @"); - test("[for (x of y) if (x == 1) x] @"); + test("[for "); + test("[for ( "); + test("[for (x "); + test("[for (x of "); + test("[for (x of y "); + test("[for (x of y) "); + test("[for (x of y) x "); + test("[for (x of y) if "); + test("[for (x of y) if ( "); + test("[for (x of y) if (x "); + test("[for (x of y) if (x == "); + test("[for (x of y) if (x == 1 "); + test("[for (x of y) if (x == 1) "); + test("[for (x of y) if (x == 1) x "); + test("[for (x of y) if (x == 1) x] "); // Generator comprehensions - test("(for @"); - test("(for ( @"); - test("(for (x @"); - test("(for (x of @"); - test("(for (x of y @"); - test("(for (x of y) @"); - test("(for (x of y) x @"); - test("(for (x of y) if @"); - test("(for (x of y) if ( @"); - test("(for (x of y) if (x @"); - test("(for (x of y) if (x == @"); - test("(for (x of y) if (x == 1 @"); - test("(for (x of y) if (x == 1) @"); - test("(for (x of y) if (x == 1) x @"); - test("(for (x of y) if (x == 1) x) @"); + test("(for "); + test("(for ( "); + test("(for (x "); + test("(for (x of "); + test("(for (x of y "); + test("(for (x of y) "); + test("(for (x of y) x "); + test("(for (x of y) if "); + test("(for (x of y) if ( "); + test("(for (x of y) if (x "); + test("(for (x of y) if (x == "); + test("(for (x of y) if (x == 1 "); + test("(for (x of y) if (x == 1) "); + test("(for (x of y) if (x == 1) x "); + test("(for (x of y) if (x == 1) x) "); // ---- Left-hand-side expressions ---- // property access - test("a[ @"); - test("a[1 @"); - test("a[1] @"); + test("a[ "); + test("a[1 "); + test("a[1] "); - test("a. @"); - test("a.b @"); - test("a.b; @"); + test("a. "); + test("a.b "); + test("a.b; "); // new - test("new @"); - test("new f @"); - test("new f( @"); - test("new f() @"); - test("new f(); @"); + test("new "); + test("new f "); + test("new f( "); + test("new f() "); + test("new f(); "); // ---- Increment and decrement ---- - test("a ++ @"); - test("a ++; @"); + test("a ++ "); + test("a ++; "); - test("-- @"); - test("-- a @"); - test("-- a; @"); + test("-- "); + test("-- a "); + test("-- a; "); // ---- Unary operators ---- // delete - test("delete @"); - test("delete a @"); - test("delete a[ @"); - test("delete a[b @"); - test("delete a[b] @"); - test("delete a[b]; @"); + test("delete "); + test("delete a "); + test("delete a[ "); + test("delete a[b "); + test("delete a[b] "); + test("delete a[b]; "); - test("delete ( @"); - test("delete (a @"); - test("delete (a[ @"); - test("delete (a[b @"); - test("delete (a[b] @"); - test("delete (a[b]) @"); - test("delete (a[b]); @"); + test("delete ( "); + test("delete (a "); + test("delete (a[ "); + test("delete (a[b "); + test("delete (a[b] "); + test("delete (a[b]) "); + test("delete (a[b]); "); // void - test("void @"); - test("void a @"); - test("void a; @"); + test("void "); + test("void a "); + test("void a; "); - test("void (@"); - test("void (a @"); - test("void (a) @"); - test("void (a); @"); + test("void ("); + test("void (a "); + test("void (a) "); + test("void (a); "); // typeof - test("typeof @"); - test("typeof a @"); - test("typeof a; @"); + test("typeof "); + test("typeof a "); + test("typeof a; "); - test("typeof (@"); - test("typeof (a @"); - test("typeof (a) @"); - test("typeof (a); @"); + test("typeof ("); + test("typeof (a "); + test("typeof (a) "); + test("typeof (a); "); // - - test("- @"); - test("- 1 @"); - test("- 1; @"); + test("- "); + test("- 1 "); + test("- 1; "); // + - test("+ @"); - test("+ 1 @"); - test("+ 1; @"); + test("+ "); + test("+ 1 "); + test("+ 1; "); // ---- Arithmetic operators ---- // + - test("1 + @"); - test("1 + 1 @"); - test("1 + 1; @"); + test("1 + "); + test("1 + 1 "); + test("1 + 1; "); // ---- Relational operators ---- // in - test("a in @"); - test("a in b @"); - test("a in b; @"); + test("a in "); + test("a in b "); + test("a in b; "); // instanceof - test("a instanceof @"); - test("a instanceof b @"); - test("a instanceof b; @"); + test("a instanceof "); + test("a instanceof b "); + test("a instanceof b; "); // ---- Equality operators ---- // == - test("1 == @"); - test("1 == 1 @"); - test("1 == 1; @"); + test("1 == "); + test("1 == 1 "); + test("1 == 1; "); // ---- Bitwise shift operators ---- // << - test("1 << @"); - test("1 << 1 @"); - test("1 << 1; @"); + test("1 << "); + test("1 << 1 "); + test("1 << 1; "); // ---- Binary bitwise operators ---- // & - test("1 & @"); - test("1 & 1 @"); - test("1 & 1; @"); + test("1 & "); + test("1 & 1 "); + test("1 & 1; "); // ---- Binary logical operators ---- // || - test("1 || @"); - test("1 || 1 @"); - test("1 || 1; @"); + test("1 || "); + test("1 || 1 "); + test("1 || 1; "); // ---- Conditional (ternary) operator ---- - test("1 ? @"); - test("1 ? 2 @"); - test("1 ? 2 : @"); - test("1 ? 2 : 3 @"); - test("1 ? 2 : 3; @"); + test("1 ? "); + test("1 ? 2 "); + test("1 ? 2 : "); + test("1 ? 2 : 3 "); + test("1 ? 2 : 3; "); // ---- Assignment operators ---- - test("x = @"); - test("x = 1 @"); - test("x = 1 + @"); - test("x = 1 + 2 @"); - test("x = 1 + 2; @"); + test("x = "); + test("x = 1 "); + test("x = 1 + "); + test("x = 1 + 2 "); + test("x = 1 + 2; "); // ---- Comma operator ---- - test("1, @"); - test("1, 2 @"); - test("1, 2; @"); + test("1, "); + test("1, 2 "); + test("1, 2; "); // ---- Functions ---- // Arrow functions - test("a => @"); - test("a => 1 @"); - test("a => 1; @"); - test("a => { @"); - test("a => {} @"); - test("a => {}; @"); + test("a => "); + test("a => 1 "); + test("a => 1; "); + test("a => { "); + test("a => {} "); + test("a => {}; "); - test("( @"); - test("() @"); - test("() => @"); + test("( "); + test("() "); + test("() => "); - test("(...@"); - test("(...a @"); - test("(...a) @"); - test("(...a) => @"); + test("(..."); + test("(...a "); + test("(...a) "); + test("(...a) => "); - test("([ @"); - test("([a @"); - test("([a] @"); - test("([a]) @"); - test("([a]) => @"); + test("([ "); + test("([a "); + test("([a] "); + test("([a]) "); + test("([a]) => "); - test("({ @"); - test("({a @"); - test("({a} @"); - test("({a}) @"); - test("({a}) => @"); - test("({a: @"); - test("({a: b @"); - test("({a: b, @"); - test("({a: b} @"); - test("({a: b}) @"); - test("({a: b}) => @"); + test("({ "); + test("({a "); + test("({a} "); + test("({a}) "); + test("({a}) => "); + test("({a: "); + test("({a: b "); + test("({a: b, "); + test("({a: b} "); + test("({a: b}) "); + test("({a: b}) => "); - if (classesEnabled()) { - // ---- Class declaration ---- + // ---- Class declaration ---- - test("class @"); - test("class a @"); - test("class a { @"); - test("class a { constructor @"); - test("class a { constructor( @"); - test("class a { constructor() @"); - test("class a { constructor() { @"); - test("class a { constructor() { } @"); - test("class a { constructor() { } } @"); + test("class "); + test("class a "); + test("class a { "); + test("class a { constructor "); + test("class a { constructor( "); + test("class a { constructor() "); + test("class a { constructor() { "); + test("class a { constructor() { } "); + test("class a { constructor() { } } "); - test("class a { constructor() { } static @"); - test("class a { constructor() { } static m @"); - test("class a { constructor() { } static m( @"); - test("class a { constructor() { } static m() @"); - test("class a { constructor() { } static m() { @"); - test("class a { constructor() { } static m() {} @"); - test("class a { constructor() { } static m() {} } @"); + test("class a { constructor() { } static "); + test("class a { constructor() { } static m "); + test("class a { constructor() { } static m( "); + test("class a { constructor() { } static m() "); + test("class a { constructor() { } static m() { "); + test("class a { constructor() { } static m() {} "); + test("class a { constructor() { } static m() {} } "); - test("class a { constructor() { } static ( @"); - test("class a { constructor() { } static () @"); - test("class a { constructor() { } static () { @"); - test("class a { constructor() { } static () {} @"); - test("class a { constructor() { } static () {} } @"); + test("class a { constructor() { } static ( "); + test("class a { constructor() { } static () "); + test("class a { constructor() { } static () { "); + test("class a { constructor() { } static () {} "); + test("class a { constructor() { } static () {} } "); - test("class a { constructor() { } static get @"); - test("class a { constructor() { } static get p @"); - test("class a { constructor() { } static get p( @"); - test("class a { constructor() { } static get p() @"); - test("class a { constructor() { } static get p() { @"); - test("class a { constructor() { } static get p() {} @"); - test("class a { constructor() { } static get p() {} } @"); + test("class a { constructor() { } static get "); + test("class a { constructor() { } static get p "); + test("class a { constructor() { } static get p( "); + test("class a { constructor() { } static get p() "); + test("class a { constructor() { } static get p() { "); + test("class a { constructor() { } static get p() {} "); + test("class a { constructor() { } static get p() {} } "); - test("class a { constructor() { } static set @"); - test("class a { constructor() { } static set p @"); - test("class a { constructor() { } static set p( @"); - test("class a { constructor() { } static set p(v @"); - test("class a { constructor() { } static set p(v) @"); - test("class a { constructor() { } static set p(v) { @"); - test("class a { constructor() { } static set p(v) {} @"); - test("class a { constructor() { } static set p(v) {} } @"); + test("class a { constructor() { } static set "); + test("class a { constructor() { } static set p "); + test("class a { constructor() { } static set p( "); + test("class a { constructor() { } static set p(v "); + test("class a { constructor() { } static set p(v) "); + test("class a { constructor() { } static set p(v) { "); + test("class a { constructor() { } static set p(v) {} "); + test("class a { constructor() { } static set p(v) {} } "); - test("class a { constructor() { } * @"); - test("class a { constructor() { } *m @"); - test("class a { constructor() { } *m( @"); - test("class a { constructor() { } *m() @"); - test("class a { constructor() { } *m() { @"); - test("class a { constructor() { } *m() {} @"); - test("class a { constructor() { } *m() {} } @"); + test("class a { constructor() { } * "); + test("class a { constructor() { } *m "); + test("class a { constructor() { } *m( "); + test("class a { constructor() { } *m() "); + test("class a { constructor() { } *m() { "); + test("class a { constructor() { } *m() {} "); + test("class a { constructor() { } *m() {} } "); - test("class a { constructor() { } static * @"); - test("class a { constructor() { } static *m @"); - test("class a { constructor() { } static *m( @"); - test("class a { constructor() { } static *m() @"); - test("class a { constructor() { } static *m() { @"); - test("class a { constructor() { } static *m() {} @"); - test("class a { constructor() { } static *m() {} } @"); + test("class a { constructor() { } static * "); + test("class a { constructor() { } static *m "); + test("class a { constructor() { } static *m( "); + test("class a { constructor() { } static *m() "); + test("class a { constructor() { } static *m() { "); + test("class a { constructor() { } static *m() {} "); + test("class a { constructor() { } static *m() {} } "); - test("class a extends @"); - test("class a extends b @"); - test("class a extends b { @"); + test("class a extends "); + test("class a extends b "); + test("class a extends b { "); - test("class a extends ( @"); - test("class a extends ( b @"); - test("class a extends ( b ) @"); - test("class a extends ( b ) { @"); + test("class a extends ( "); + test("class a extends ( b "); + test("class a extends ( b ) "); + test("class a extends ( b ) { "); - // ---- Class expression ---- + // ---- Class expression ---- - test("( class @"); - test("( class a @"); - test("( class a { @"); - test("( class a { constructor @"); - test("( class a { constructor( @"); - test("( class a { constructor() @"); - test("( class a { constructor() { @"); - test("( class a { constructor() { } @"); - test("( class a { constructor() { } } @"); - test("( class a { constructor() { } } ) @"); + test("( class "); + test("( class a "); + test("( class a { "); + test("( class a { constructor "); + test("( class a { constructor( "); + test("( class a { constructor() "); + test("( class a { constructor() { "); + test("( class a { constructor() { } "); + test("( class a { constructor() { } } "); + test("( class a { constructor() { } } ) "); - test("(class a extends @"); - test("(class a extends b @"); - test("(class a extends b { @"); + test("(class a extends "); + test("(class a extends b "); + test("(class a extends b { "); - test("(class a extends ( @"); - test("(class a extends ( b @"); - test("(class a extends ( b ) @"); - test("(class a extends ( b ) { @"); + test("(class a extends ( "); + test("(class a extends ( b "); + test("(class a extends ( b ) "); + test("(class a extends ( b ) { "); - test("( class { @"); - test("( class { constructor @"); - test("( class { constructor( @"); - test("( class { constructor() @"); - test("( class { constructor() { @"); - test("( class { constructor() { } @"); - test("( class { constructor() { } } @"); - test("( class { constructor() { } } ) @"); + test("( class { "); + test("( class { constructor "); + test("( class { constructor( "); + test("( class { constructor() "); + test("( class { constructor() { "); + test("( class { constructor() { } "); + test("( class { constructor() { } } "); + test("( class { constructor() { } } ) "); - test("(class extends @"); - test("(class extends b @"); - test("(class extends b { @"); + test("(class extends "); + test("(class extends b "); + test("(class extends b { "); - test("(class extends ( @"); - test("(class extends ( b @"); - test("(class extends ( b ) @"); - test("(class extends ( b ) { @"); - } + test("(class extends ( "); + test("(class extends ( b "); + test("(class extends ( b ) "); + test("(class extends ( b ) { "); // ---- Other ---- // Literals - test("a @"); - test("1 @"); - test("1. @"); - test("1.2 @"); - test("true @"); - test("false @"); - test("\"a\" @"); - test("'a' @"); - test("null @"); + test("a "); + test("1 "); + test("1. "); + test("1.2 "); + test("true "); + test("false "); + test("\"a\" "); + test("'a' "); + test("null "); // Template strings - test("`${ @"); - test("`${a @"); - test("`${a}` @"); + test("`${ "); + test("`${a "); + test("`${a}` "); // Function calls - test("f( @"); - test("f() @"); - test("f(); @"); + test("f( "); + test("f() "); + test("f(); "); - test("f(... @"); - test("f(...x @"); - test("f(...x) @"); + test("f(... "); + test("f(...x "); + test("f(...x) "); // Function constructors - test_fun_arg("@"); - test_fun_arg("a @"); - test_fun_arg("... @"); - test_fun_arg("...a @"); + test_fun_arg(""); + test_fun_arg("a "); + test_fun_arg("... "); + test_fun_arg("...a "); // ==== Legacy ==== // Expression closures - test("function f() 1 @"); - test("function f() 1; @"); - test("(function () 1 @"); - test("(function () 1); @"); + test("function f() 1 "); + test("function f() 1; "); + test("(function () 1 "); + test("(function () 1); "); // Legacy generator - test("function f() { (yield @"); - test("function f() { (yield 1 @"); - test("function f() { f(yield @"); - test("function f() { f(yield 1 @"); + test("function f() { (yield "); + test("function f() { (yield 1 "); + test("function f() { f(yield "); + test("function f() { f(yield 1 "); // for each...in - test("for each @"); - test("for each (@"); - test("for each (x @"); - test("for each (x in @"); - test("for each (x in y @"); - test("for each (x in y) @"); + test("for each "); + test("for each ("); + test("for each (x "); + test("for each (x in "); + test("for each (x in y "); + test("for each (x in y) "); - test("for each (var @"); - test("for each (var x @"); - test("for each (var x in @"); - test("for each (var x in y @"); - test("for each (var x in y) @"); + test("for each (var "); + test("for each (var x "); + test("for each (var x in "); + test("for each (var x in y "); + test("for each (var x in y) "); - test("for each (let @"); - test("for each (let x @"); - test("for each (let x in @"); - test("for each (let x in y @"); - test("for each (let x in y) @"); + test("for each (let "); + test("for each (let x "); + test("for each (let x in "); + test("for each (let x in y "); + test("for each (let x in y) "); // Legacy array comprehensions - test("[x @"); - test("[x for @"); - test("[x for ( @"); - test("[x for (x @"); - test("[x for (x of @"); - test("[x for (x of y @"); - test("[x for (x of y) @"); - test("[x for (x of y) if @"); - test("[x for (x of y) if ( @"); - test("[x for (x of y) if (x @"); - test("[x for (x of y) if (x == @"); - test("[x for (x of y) if (x == 1 @"); - test("[x for (x of y) if (x == 1) @"); - test("[x for (x of y) if (x == 1)] @"); + test("[x "); + test("[x for "); + test("[x for ( "); + test("[x for (x "); + test("[x for (x of "); + test("[x for (x of y "); + test("[x for (x of y) "); + test("[x for (x of y) if "); + test("[x for (x of y) if ( "); + test("[x for (x of y) if (x "); + test("[x for (x of y) if (x == "); + test("[x for (x of y) if (x == 1 "); + test("[x for (x of y) if (x == 1) "); + test("[x for (x of y) if (x == 1)] "); - test("[x for (x in @"); - test("[x for (x in y @"); - test("[x for (x in y) @"); + test("[x for (x in "); + test("[x for (x in y "); + test("[x for (x in y) "); - test("[x for each @"); - test("[x for each ( @"); - test("[x for each (x @"); - test("[x for each (x in @"); - test("[x for each (x in y @"); - test("[x for each (x in y) @"); + test("[x for each "); + test("[x for each ( "); + test("[x for each (x "); + test("[x for each (x in "); + test("[x for each (x in y "); + test("[x for each (x in y) "); // Generator expressions - test("(x @"); - test("(x for @"); - test("(x for ( @"); - test("(x for (x @"); - test("(x for (x of @"); - test("(x for (x of y @"); - test("(x for (x of y) @"); - test("(x for (x of y) if @"); - test("(x for (x of y) if ( @"); - test("(x for (x of y) if (x @"); - test("(x for (x of y) if (x == @"); - test("(x for (x of y) if (x == 1 @"); - test("(x for (x of y) if (x == 1) @"); - test("(x for (x of y) if (x == 1)) @"); + test("(x "); + test("(x for "); + test("(x for ( "); + test("(x for (x "); + test("(x for (x of "); + test("(x for (x of y "); + test("(x for (x of y) "); + test("(x for (x of y) if "); + test("(x for (x of y) if ( "); + test("(x for (x of y) if (x "); + test("(x for (x of y) if (x == "); + test("(x for (x of y) if (x == 1 "); + test("(x for (x of y) if (x == 1) "); + test("(x for (x of y) if (x == 1)) "); - test("(x for (x in @"); - test("(x for (x in y @"); - test("(x for (x in y) @"); + test("(x for (x in "); + test("(x for (x in y "); + test("(x for (x in y) "); - test("(x for each @"); - test("(x for each ( @"); - test("(x for each (x @"); - test("(x for each (x in @"); - test("(x for each (x in y @"); - test("(x for each (x in y) @"); + test("(x for each "); + test("(x for each ( "); + test("(x for each (x "); + test("(x for each (x in "); + test("(x for each (x in y "); + test("(x for each (x in y) "); // asm.js - test("(function() { 'use asm'; @"); - test("(function() { 'use asm'; var @"); - test("(function() { 'use asm'; var a @"); - test("(function() { 'use asm'; var a = @"); - test("(function() { 'use asm'; var a = 1 @"); - test("(function() { 'use asm'; var a = 1; @"); - test("(function() { 'use asm'; var a = 1; function @"); - test("(function() { 'use asm'; var a = 1; function f @"); - test("(function() { 'use asm'; var a = 1; function f( @"); - test("(function() { 'use asm'; var a = 1; function f() @"); - test("(function() { 'use asm'; var a = 1; function f() { @"); - test("(function() { 'use asm'; var a = 1; function f() { } @"); - test("(function() { 'use asm'; var a = 1; function f() { } var @"); - test("(function() { 'use asm'; var a = 1; function f() { } var tbl @"); - test("(function() { 'use asm'; var a = 1; function f() { } var tbl = @"); - test("(function() { 'use asm'; var a = 1; function f() { } var tbl = [ @"); - test("(function() { 'use asm'; var a = 1; function f() { } var tbl = [f @"); - test("(function() { 'use asm'; var a = 1; function f() { } var tbl = [f] @"); - test("(function() { 'use asm'; var a = 1; function f() { } var tbl = [f]; @"); - test("(function() { 'use asm'; var a = 1; function f() { } var tbl = [f]; return @"); - test("(function() { 'use asm'; var a = 1; function f() { } var tbl = [f]; return f @"); - test("(function() { 'use asm'; var a = 1; function f() { } var tbl = [f]; return f; @"); - test("(function() { 'use asm'; var a = 1; function f() { } var tbl = [f]; return f; } @"); - test("(function() { 'use asm'; var a = 1; function f() { } var tbl = [f]; return f; }) @"); - test("(function() { 'use asm'; var a = 1; function f() { } var tbl = [f]; return f; }); @"); + test("(function() { 'use asm'; "); + test("(function() { 'use asm'; var "); + test("(function() { 'use asm'; var a "); + test("(function() { 'use asm'; var a = "); + test("(function() { 'use asm'; var a = 1 "); + test("(function() { 'use asm'; var a = 1; "); + test("(function() { 'use asm'; var a = 1; function "); + test("(function() { 'use asm'; var a = 1; function f "); + test("(function() { 'use asm'; var a = 1; function f( "); + test("(function() { 'use asm'; var a = 1; function f() "); + test("(function() { 'use asm'; var a = 1; function f() { "); + test("(function() { 'use asm'; var a = 1; function f() { } "); + test("(function() { 'use asm'; var a = 1; function f() { } var "); + test("(function() { 'use asm'; var a = 1; function f() { } var tbl "); + test("(function() { 'use asm'; var a = 1; function f() { } var tbl = "); + test("(function() { 'use asm'; var a = 1; function f() { } var tbl = [ "); + test("(function() { 'use asm'; var a = 1; function f() { } var tbl = [f "); + test("(function() { 'use asm'; var a = 1; function f() { } var tbl = [f] "); + test("(function() { 'use asm'; var a = 1; function f() { } var tbl = [f]; "); + test("(function() { 'use asm'; var a = 1; function f() { } var tbl = [f]; return "); + test("(function() { 'use asm'; var a = 1; function f() { } var tbl = [f]; return f "); + test("(function() { 'use asm'; var a = 1; function f() { } var tbl = [f]; return f; "); + test("(function() { 'use asm'; var a = 1; function f() { } var tbl = [f]; return f; } "); + test("(function() { 'use asm'; var a = 1; function f() { } var tbl = [f]; return f; }) "); + test("(function() { 'use asm'; var a = 1; function f() { } var tbl = [f]; return f; }); "); } diff --git a/js/src/jit-test/tests/baseline/classConstructor-AnyScripted.js b/js/src/jit-test/tests/baseline/classConstructor-AnyScripted.js index 976dc7f9f4..8acb052c74 100644 --- a/js/src/jit-test/tests/baseline/classConstructor-AnyScripted.js +++ b/js/src/jit-test/tests/baseline/classConstructor-AnyScripted.js @@ -1,7 +1,3 @@ -load(libdir + "class.js"); - -var test = ` - function test(fun) { fun(); } @@ -23,8 +19,3 @@ try { test(foo); throw new Error("Invoking a class constructor without new must throw"); } catch (e if e instanceof TypeError) { } - -`; - -if (classesEnabled()) - eval(test); diff --git a/js/src/jit-test/tests/basic/bug1232269.js b/js/src/jit-test/tests/basic/bug1232269.js new file mode 100644 index 0000000000..c979d3b400 --- /dev/null +++ b/js/src/jit-test/tests/basic/bug1232269.js @@ -0,0 +1,30 @@ + +function f() { + for (var i=0; i<100; i++) { + var obj = {data: {id:1}}; + } + Object.defineProperty(obj, "id", { + configurable: true, + enumerable: false, + get: function() { + return this.data.id; + } + }); + return obj.id; +} +assertEq(f(), 1); + +function f2() { + for (var i=0; i<100; i++) { + var obj = {data: {id:1}}; + } + Object.defineProperty(obj, "id", { + configurable: true, + enumerable: false, + get: function() { return this.data.id; }, + set: function(v) { this.data.id = v; } + }); + obj.id = 3; + return obj.id; +} +assertEq(f2(), 3); diff --git a/js/src/jit-test/tests/basic/statement-after-return.js b/js/src/jit-test/tests/basic/statement-after-return.js index 6979ee8b77..24c8ddc753 100644 --- a/js/src/jit-test/tests/basic/statement-after-return.js +++ b/js/src/jit-test/tests/basic/statement-after-return.js @@ -1,7 +1,5 @@ // Warning should be shown for unreachable statement after return (bug 1151931). -load(libdir + "class.js"); - function testWarn(code, lineNumber, columnNumber) { enableLastWarning(); eval(code); @@ -213,14 +211,12 @@ function* f() { `, 4, 4); // class -if (classesEnabled()) { - testWarn(` +testWarn(` function f() { return class A { constructor() {} }; } `, 4, 4); -} // unary expression testWarn(` diff --git a/js/src/jit-test/tests/ion/bug1185957.js b/js/src/jit-test/tests/ion/bug1185957.js index f5fe015ec7..f9ad9c9d7b 100644 --- a/js/src/jit-test/tests/ion/bug1185957.js +++ b/js/src/jit-test/tests/ion/bug1185957.js @@ -1,15 +1,9 @@ // |jit-test| error: TypeError -load(libdir + "class.js"); - -var test = ` class test { constructor() {}; } + (function() { test() })(); -`; - -if (classesEnabled()) - eval(test); diff --git a/js/src/jit-test/tests/modules/duplicate-exports.js b/js/src/jit-test/tests/modules/duplicate-exports.js index 2dfabebc13..a34b1024c4 100644 --- a/js/src/jit-test/tests/modules/duplicate-exports.js +++ b/js/src/jit-test/tests/modules/duplicate-exports.js @@ -1,5 +1,4 @@ // Test errors due to duplicate exports - load(libdir + "asserts.js"); function testSyntaxError(source) { @@ -10,11 +9,13 @@ function testSyntaxError(source) { testSyntaxError("export var v; export var v;"); testSyntaxError("export var x, y, z; export var y;"); + testSyntaxError("export default 1; export default 2;"); testSyntaxError("export var default; export default 1;"); testSyntaxError("export var default; export default function() {};"); testSyntaxError("export var default; export default function foo() {};"); testSyntaxError("export var default; export default export class { constructor() {} };"); testSyntaxError("export var default; export default export class foo { constructor() {} };"); + testSyntaxError("var v; export {v}; export {v};"); testSyntaxError("var v, x; export {v}; export {x as v};"); diff --git a/js/src/jit-test/tests/modules/export-declaration.js b/js/src/jit-test/tests/modules/export-declaration.js index 145e91f56d..a3c931eb6c 100644 --- a/js/src/jit-test/tests/modules/export-declaration.js +++ b/js/src/jit-test/tests/modules/export-declaration.js @@ -1,6 +1,5 @@ load(libdir + "match.js"); load(libdir + "asserts.js"); -load(libdir + "class.js"); var { Pattern, MatchError } = Match; @@ -208,18 +207,16 @@ program([ ) ]).assert(parseAsModule("export function f() {}")); -if (classesEnabled()) { - program([ - exportDeclaration( - classDeclaration( - ident("Foo") - ), - null, - null, - false - ) - ]).assert(parseAsModule("export class Foo { constructor() {} }")); -} +program([ + exportDeclaration( + classDeclaration( + ident("Foo") + ), + null, + null, + false + ) +]).assert(parseAsModule("export class Foo { constructor() {} }")); program([ exportDeclaration( @@ -298,29 +295,27 @@ program([ ) ]).assert(parseAsModule("export default function foo() {}")); -if (classesEnabled()) { - program([ - exportDeclaration( - classDeclaration( - ident("*default*") - ), - null, - null, - true - ) - ]).assert(parseAsModule("export default class { constructor() {} }")); +program([ + exportDeclaration( + classDeclaration( + ident("*default*") + ), + null, + null, + true + ) +]).assert(parseAsModule("export default class { constructor() {} }")); - program([ - exportDeclaration( - classDeclaration( - ident("Foo") - ), - null, - null, - true - ) - ]).assert(parseAsModule("export default class Foo { constructor() {} }")); -} +program([ + exportDeclaration( + classDeclaration( + ident("Foo") + ), + null, + null, + true + ) +]).assert(parseAsModule("export default class Foo { constructor() {} }")); program([ exportDeclaration( diff --git a/js/src/jit-test/tests/modules/module-environment.js b/js/src/jit-test/tests/modules/module-environment.js index 424eaf1ea7..c6aff4e9c5 100644 --- a/js/src/jit-test/tests/modules/module-environment.js +++ b/js/src/jit-test/tests/modules/module-environment.js @@ -23,3 +23,6 @@ testInitialEnvironment('export default function x() {};', ['x']); testInitialEnvironment('export default 1;', ['*default*']); testInitialEnvironment('export default class { constructor() {} };', ['*default*']); testInitialEnvironment('export default function() {};', ['*default*']); +testInitialEnvironment("class x { constructor() {} }", ['x']); +testInitialEnvironment('export default class x { constructor() {} };', ['x']); +testInitialEnvironment('export default class { constructor() {} };', ['*default*']); diff --git a/js/src/jit-test/tests/modules/module-evaluation.js b/js/src/jit-test/tests/modules/module-evaluation.js index 7848e4523a..f0a570f770 100644 --- a/js/src/jit-test/tests/modules/module-evaluation.js +++ b/js/src/jit-test/tests/modules/module-evaluation.js @@ -1,13 +1,7 @@ // Exercise ModuleEvaluation() concrete method. load(libdir + "asserts.js"); - -let moduleRepo = new Map(); -setModuleResolveHook(function(module, specifier) { - if (specifier in moduleRepo) - return moduleRepo[specifier]; - throw "Module " + specifier + " not found"; -}); +load(libdir + "dummyModuleResolveHook.js"); function parseAndEvaluate(source) { let m = parseModule(source); @@ -64,6 +58,8 @@ parseAndEvaluate("import a from 'a';"); parseAndEvaluate("import { x } from 'a';"); parseAndEvaluate("import * as ns from 'a';"); parseAndEvaluate("export * from 'a'"); +parseAndEvaluate("export default class { constructor() {} };"); +parseAndEvaluate("export default class foo { constructor() {} };"); // Test default import m = parseModule("import a from 'a'; a;") @@ -87,7 +83,7 @@ assertEq(parseAndEvaluate("import { z } from 'b'; z"), 1); // Test cyclic dependencies moduleRepo['c1'] = parseModule("export var x = 1; export {y} from 'c2'"); moduleRepo['c2'] = parseModule("export var y = 2; export {x} from 'c1'"); -assertDeepEq(parseAndEvaluate(`import { x as x1, y as y1 } from 'c1'; +assertDeepEq(parseAndEvaluate(`import { x as x1, y as y1 } from 'c1'; import { x as x2, y as y2 } from 'c2'; [x1, y1, x2, y2]`), [1, 2, 1, 2]); diff --git a/js/src/jit-test/tests/parser/arrow-rest.js b/js/src/jit-test/tests/parser/arrow-rest.js index 29bc89178a..dd8534564a 100644 --- a/js/src/jit-test/tests/parser/arrow-rest.js +++ b/js/src/jit-test/tests/parser/arrow-rest.js @@ -1,8 +1,6 @@ // The parser should throw SyntaxError immediately if it finds "..." in a // context where it's not allowed. -load(libdir + "class.js"); - function testThrow(code, column) { var caught = false; try { @@ -143,11 +141,9 @@ try {} catch (x if ...a) => // class -if (classesEnabled()) { testThrow(` class A extends ...a) => `, 16); -} // conditional expression diff --git a/js/src/jit-test/tests/sharedbuf/subtypes.js b/js/src/jit-test/tests/sharedbuf/subtypes.js new file mode 100644 index 0000000000..ce893cc451 --- /dev/null +++ b/js/src/jit-test/tests/sharedbuf/subtypes.js @@ -0,0 +1,53 @@ +// Test cases for subclasses of SharedArrayBuffer. + +if (!this.SharedArrayBuffer) + quit(0); + +load(libdir + "asserts.js"); + +// Basic subclassing. + +class MySharedArrayBuffer1 extends SharedArrayBuffer { + constructor(n) { super(n) } +} + +let mv1 = new MySharedArrayBuffer1(1024); +assertEq(mv1 instanceof SharedArrayBuffer, true); +assertEq(mv1 instanceof MySharedArrayBuffer1, true); +assertEq(mv1.byteLength, 1024); + +// Can construct views on the subclasses and read/write elements. + +let mva1 = new Int8Array(mv1); +assertEq(mva1.length, mv1.byteLength); +assertEq(mva1.buffer, mv1); + +for ( let i=1 ; i < mva1.length ; i++ ) + mva1[i] = i; + +for ( let i=1 ; i < mva1.length ; i++ ) + assertEq(mva1[i], (i << 24) >> 24); + +// Passing modified arguments to superclass to get a different length. + +class MySharedArrayBuffer2 extends SharedArrayBuffer { + constructor(n) { super(n-1) } +} + +let mv2 = new MySharedArrayBuffer2(10); +assertEq(mv2 instanceof SharedArrayBuffer, true); +assertEq(mv2 instanceof MySharedArrayBuffer2, true); +assertEq(mv2.byteLength, 9); + +// Returning a different object altogether. + +class MySharedArrayBuffer3 extends SharedArrayBuffer { + constructor(n) { + return new Array(n); + } +} + +let mv3 = new MySharedArrayBuffer3(10); +assertEq(mv3 instanceof Array, true); +assertEq(mv3 instanceof MySharedArrayBuffer3, false); +assertEq(mv3.length, 10); diff --git a/js/src/jit-test/tests/xdr/classes.js b/js/src/jit-test/tests/xdr/classes.js index e91da04eb0..a5dc527f1c 100644 --- a/js/src/jit-test/tests/xdr/classes.js +++ b/js/src/jit-test/tests/xdr/classes.js @@ -1,8 +1,4 @@ load(libdir + 'bytecode-cache.js'); -load(libdir + 'class.js'); - -if (!classesEnabled()) - quit(); var test = "new class extends class { } { constructor() { super(); } }()"; evalWithCache(test, { assertEqBytecode : true }); diff --git a/js/src/js-confdefs.h.in b/js/src/js-confdefs.h.in index e4908a94a8..b46357b552 100644 --- a/js/src/js-confdefs.h.in +++ b/js/src/js-confdefs.h.in @@ -6,7 +6,8 @@ #ifndef js_confdefs_h #define js_confdefs_h -@ALLDEFINES@ +// Expands to all the defines from configure. +#undef ALLDEFINES #include "js/RequiredDefines.h" diff --git a/js/src/js.msg b/js/src/js.msg index 16926cbf66..47ecefabed 100644 --- a/js/src/js.msg +++ b/js/src/js.msg @@ -489,7 +489,6 @@ MSG_DEF(JSMSG_TYPED_ARRAY_NEGATIVE_ARG,1, JSEXN_RANGEERR, "argument {0} must be MSG_DEF(JSMSG_TYPED_ARRAY_DETACHED, 0, JSEXN_TYPEERR, "attempting to access detached ArrayBuffer") // Shared array buffer -MSG_DEF(JSMSG_SHARED_ARRAY_BAD_OBJECT, 0, JSEXN_TYPEERR, "invalid object argument") MSG_DEF(JSMSG_SHARED_ARRAY_BAD_LENGTH, 0, JSEXN_RANGEERR, "length argument out of range") // Shared typed array diff --git a/js/src/moz.build b/js/src/moz.build index 4026c07921..1f884cddcb 100644 --- a/js/src/moz.build +++ b/js/src/moz.build @@ -64,10 +64,12 @@ TEST_DIRS += ['jsapi-tests', 'tests', 'gdb'] CONFIGURE_SUBST_FILES += [ 'devtools/rootAnalysis/Makefile', - 'js-confdefs.h', 'js-config', 'js.pc', ] +CONFIGURE_DEFINE_FILES += [ + 'js-confdefs.h', +] if CONFIG['JS_STANDALONE']: DEFINES['IMPL_MFBT'] = True diff --git a/js/src/tests/ecma_6/Class/boundFunctionSubclassing.js b/js/src/tests/ecma_6/Class/boundFunctionSubclassing.js index fa5544f8d3..298ab11b33 100644 --- a/js/src/tests/ecma_6/Class/boundFunctionSubclassing.js +++ b/js/src/tests/ecma_6/Class/boundFunctionSubclassing.js @@ -1,5 +1,3 @@ -var test = ` - class func extends Function { } let inst = new func("x", "return this.bar + x"); @@ -15,10 +13,5 @@ bound = Function.prototype.bind.call(inst, {bar:1}, 3); assertEq(Object.getPrototypeOf(bound), null); assertEq(bound(), 4); -`; - -if (classesEnabled()) - eval(test); - if (typeof reportCompare === 'function') reportCompare(0,0,"OK"); diff --git a/js/src/tests/ecma_6/Class/bytecodePatternMatching.js b/js/src/tests/ecma_6/Class/bytecodePatternMatching.js index 0c16069911..446184f805 100644 --- a/js/src/tests/ecma_6/Class/bytecodePatternMatching.js +++ b/js/src/tests/ecma_6/Class/bytecodePatternMatching.js @@ -1,6 +1,5 @@ // Constructors can't be called so we can't pattern match // them in replace and sort. -var test = ` function a() { var b = {a: "A"}; @@ -25,10 +24,6 @@ function b() { a(); b(); -`; - -if (classesEnabled()) - eval(test); if (typeof reportCompare === "function") reportCompare(0, 0, "OK"); diff --git a/js/src/tests/ecma_6/Class/classConstructorNoCall.js b/js/src/tests/ecma_6/Class/classConstructorNoCall.js index 4d01cf53d5..f59f87b9c5 100644 --- a/js/src/tests/ecma_6/Class/classConstructorNoCall.js +++ b/js/src/tests/ecma_6/Class/classConstructorNoCall.js @@ -1,6 +1,4 @@ // Class constructors don't have a [[Call]] -var test = ` - class Foo { constructor() { } } @@ -19,10 +17,5 @@ assertThrowsInstanceOf(class extends Foo { constructor() { } }, TypeError); assertThrowsInstanceOf(class foo { constructor() { } }, TypeError); assertThrowsInstanceOf(class foo extends Foo { constructor() { } }, TypeError); -`; - -if (classesEnabled()) - eval(test); - if (typeof reportCompare === 'function') reportCompare(0,0,"OK"); diff --git a/js/src/tests/ecma_6/Class/classHeritage.js b/js/src/tests/ecma_6/Class/classHeritage.js index 0b01612cf5..478c23fc21 100644 --- a/js/src/tests/ecma_6/Class/classHeritage.js +++ b/js/src/tests/ecma_6/Class/classHeritage.js @@ -1,12 +1,10 @@ -var test = ` - // It's an error to have a non-constructor as your heritage -assertThrowsInstanceOf(() => eval(\`class a extends Math.sin { +assertThrowsInstanceOf(() => eval(`class a extends Math.sin { constructor() { } - }\`), TypeError); -assertThrowsInstanceOf(() => eval(\`(class a extends Math.sin { + }`), TypeError); +assertThrowsInstanceOf(() => eval(`(class a extends Math.sin { constructor() { } - })\`), TypeError); + })`), TypeError); // Unless it's null, in which case it works like a normal class, except that // the prototype object does not inherit from Object.prototype. @@ -95,10 +93,5 @@ function stillNoExpr() { assertThrowsInstanceOf(stillNo, TypeError); assertThrowsInstanceOf(stillNoExpr, TypeError); -`; - -if (classesEnabled()) - eval(test); - if (typeof reportCompare === "function") reportCompare(0, 0, "OK"); diff --git a/js/src/tests/ecma_6/Class/className.js b/js/src/tests/ecma_6/Class/className.js index 645e505dd7..a33397a8a3 100644 --- a/js/src/tests/ecma_6/Class/className.js +++ b/js/src/tests/ecma_6/Class/className.js @@ -56,7 +56,6 @@ function testName(C, name, hasValue, hasGetter, hasSetter, isFunction=false) { } } -var test = ` // ---- declaration --- class Decl { @@ -243,10 +242,6 @@ let ExtendedExpr5 = class ExtendedExpr5 extends AnonWithGetterSetter { testName(ExtendedExpr5, "extend", false, true, false); delete ExtendedExpr5.name; testName(ExtendedExpr5, "base", false, false, false); -`; - -if (classesEnabled()) - eval(test); if (typeof reportCompare === "function") reportCompare(0, 0, "OK"); diff --git a/js/src/tests/ecma_6/Class/classPrototype.js b/js/src/tests/ecma_6/Class/classPrototype.js index 8f23b18c92..0d2296037c 100644 --- a/js/src/tests/ecma_6/Class/classPrototype.js +++ b/js/src/tests/ecma_6/Class/classPrototype.js @@ -1,5 +1,3 @@ -var test = ` - // The prototype of a class is a non-writable, non-configurable, non-enumerable data property. class a { constructor() { } } let b = class { constructor() { } }; @@ -25,47 +23,43 @@ for (let test of [a,b]) { // As such, it should by a TypeError to try and overwrite "prototype" with a // static member. The only way to try is with a computed property name; the rest // are early errors. -assertThrowsInstanceOf(() => eval(\` +assertThrowsInstanceOf(() => eval(` class a { constructor() { }; static ["prototype"]() { } } - \`), TypeError); -assertThrowsInstanceOf(() => eval(\` + `), TypeError); +assertThrowsInstanceOf(() => eval(` class a { constructor() { }; static get ["prototype"]() { } } - \`), TypeError); -assertThrowsInstanceOf(() => eval(\` + `), TypeError); +assertThrowsInstanceOf(() => eval(` class a { constructor() { }; static set ["prototype"](x) { } } - \`), TypeError); + `), TypeError); -assertThrowsInstanceOf(() => eval(\`( +assertThrowsInstanceOf(() => eval(`( class a { constructor() { }; static ["prototype"]() { } } - )\`), TypeError); -assertThrowsInstanceOf(() => eval(\`( + )`), TypeError); +assertThrowsInstanceOf(() => eval(`( class a { constructor() { }; static get ["prototype"]() { } } - )\`), TypeError); -assertThrowsInstanceOf(() => eval(\`( + )`), TypeError); +assertThrowsInstanceOf(() => eval(`( class a { constructor() { }; static set ["prototype"](x) { } } - )\`), TypeError); -`; - -if (classesEnabled()) - eval(test); + )`), TypeError); if (typeof reportCompare === "function") reportCompare(0, 0, "OK"); diff --git a/js/src/tests/ecma_6/Class/compPropDestr.js b/js/src/tests/ecma_6/Class/compPropDestr.js index 6ef9bf1939..2bd8cbd49a 100644 --- a/js/src/tests/ecma_6/Class/compPropDestr.js +++ b/js/src/tests/ecma_6/Class/compPropDestr.js @@ -7,5 +7,5 @@ var key = "z"; var { [key]: foo } = { z: "bar" }; assertEq(foo, "bar"); - -reportCompare(0, 0, "ok"); +if (typeof reportCompare === 'function') + reportCompare(0, 0, "ok"); diff --git a/js/src/tests/ecma_6/Class/compPropNames.js b/js/src/tests/ecma_6/Class/compPropNames.js index a79f456846..1c4064d8a5 100644 --- a/js/src/tests/ecma_6/Class/compPropNames.js +++ b/js/src/tests/ecma_6/Class/compPropNames.js @@ -239,5 +239,5 @@ assertEq(obj.hey, 1); assertEq(obj[4], 2); assertThrowsValue(() => { obj.x = 7; }, 3); - -reportCompare(0, 0, "ok"); +if (typeof reportCompare === 'function') + reportCompare(0, 0, "ok"); diff --git a/js/src/tests/ecma_6/Class/constructorCalled.js b/js/src/tests/ecma_6/Class/constructorCalled.js index b57e38e446..144cc08c79 100644 --- a/js/src/tests/ecma_6/Class/constructorCalled.js +++ b/js/src/tests/ecma_6/Class/constructorCalled.js @@ -1,8 +1,6 @@ // The constructor specified should get called, regardless of order, or // other distractions -var test = ` - var called = false; class a { constructor(x) { assertEq(x, 4); called = true } } new a(4); @@ -34,18 +32,14 @@ new cExpr(); assertEq(called, true); called = false; -class d { [\"constructor\"]() { throw new Error(\"NO\"); } constructor() { called = true; } } +class d { ["constructor"]() { throw new Error("NO"); } constructor() { called = true; } } new d(); assertEq(called, true); called = false; -var dExpr = class { [\"constructor\"]() { throw new Error(\"NO\"); } constructor() { called = true; } } +var dExpr = class { ["constructor"]() { throw new Error("NO"); } constructor() { called = true; } } new dExpr(); assertEq(called, true); -`; - -if (classesEnabled()) - eval(test); if (typeof reportCompare === "function") reportCompare(0, 0, "OK"); diff --git a/js/src/tests/ecma_6/Class/defaultConstructorBase.js b/js/src/tests/ecma_6/Class/defaultConstructorBase.js index 851cf10672..2d977935dd 100644 --- a/js/src/tests/ecma_6/Class/defaultConstructorBase.js +++ b/js/src/tests/ecma_6/Class/defaultConstructorBase.js @@ -1,5 +1,3 @@ -var test = ` - class base { method() { return 1; } *gen() { return 2; } @@ -16,10 +14,5 @@ assertEq(new base().gen().next().value, 2); assertEq(base.sMethod(), 3); assertEq(new base().answer, 42); -`; - -if (classesEnabled()) - eval(test); - if (typeof reportCompare === 'function') reportCompare(0,0,"OK"); diff --git a/js/src/tests/ecma_6/Class/defaultConstructorNotCallable.js b/js/src/tests/ecma_6/Class/defaultConstructorNotCallable.js index 0df212bb22..558f8dcc2f 100644 --- a/js/src/tests/ecma_6/Class/defaultConstructorNotCallable.js +++ b/js/src/tests/ecma_6/Class/defaultConstructorNotCallable.js @@ -1,15 +1,8 @@ -var test = ` - class badBase {} assertThrowsInstanceOf(badBase, TypeError); class badSub extends (class {}) {} assertThrowsInstanceOf(badSub, TypeError); -`; - -if (classesEnabled()) - eval(test); - if (typeof reportCompare === 'function') reportCompare(0,0,"OK"); diff --git a/js/src/tests/ecma_6/Class/derivedConstructorArrowEvalBinding.js b/js/src/tests/ecma_6/Class/derivedConstructorArrowEvalBinding.js index bd87f8f477..d6b15baab3 100644 --- a/js/src/tests/ecma_6/Class/derivedConstructorArrowEvalBinding.js +++ b/js/src/tests/ecma_6/Class/derivedConstructorArrowEvalBinding.js @@ -1,6 +1,4 @@ // Make sure it doesn't matter when we make the arrow function -var test = ` - new class extends class { } { constructor() { let arrow = () => this; @@ -10,10 +8,5 @@ new class extends class { } { } }(); -`; - -if (classesEnabled()) - eval(test); - if (typeof reportCompare === 'function') reportCompare(0,0,"OK"); diff --git a/js/src/tests/ecma_6/Class/derivedConstructorArrowEvalClosed.js b/js/src/tests/ecma_6/Class/derivedConstructorArrowEvalClosed.js index 7899aeabdd..431a73c92f 100644 --- a/js/src/tests/ecma_6/Class/derivedConstructorArrowEvalClosed.js +++ b/js/src/tests/ecma_6/Class/derivedConstructorArrowEvalClosed.js @@ -1,5 +1,3 @@ -var test = ` - new class extends class { } { constructor() { let a1 = () => this; @@ -9,10 +7,5 @@ new class extends class { } { } }(); -`; - -if (classesEnabled()) - eval(test); - if (typeof reportCompare === 'function') reportCompare(0,0,"OK"); diff --git a/js/src/tests/ecma_6/Class/derivedConstructorArrowEvalEscape.js b/js/src/tests/ecma_6/Class/derivedConstructorArrowEvalEscape.js index 8284bac9d5..2676d4b946 100644 --- a/js/src/tests/ecma_6/Class/derivedConstructorArrowEvalEscape.js +++ b/js/src/tests/ecma_6/Class/derivedConstructorArrowEvalEscape.js @@ -1,5 +1,3 @@ -var test = ` - let arrow; class foo extends class { } { @@ -11,10 +9,5 @@ class foo extends class { } { assertEq(new foo(), arrow()); -`; - -if (classesEnabled()) - eval(test); - if (typeof reportCompare === 'function') reportCompare(0,0,"OK"); diff --git a/js/src/tests/ecma_6/Class/derivedConstructorArrowEvalEscapeUninitialized.js b/js/src/tests/ecma_6/Class/derivedConstructorArrowEvalEscapeUninitialized.js index 010f0dd1b7..970beb0436 100644 --- a/js/src/tests/ecma_6/Class/derivedConstructorArrowEvalEscapeUninitialized.js +++ b/js/src/tests/ecma_6/Class/derivedConstructorArrowEvalEscapeUninitialized.js @@ -1,5 +1,3 @@ -var test = ` - let superArrow; let thisArrow; @@ -36,10 +34,5 @@ assertThrowsInstanceOf(superArrow, ReferenceError); // Oh look, |this| is populated, now. assertEq(thisArrow(), thisStash); -`; - -if (classesEnabled()) - eval(test); - if (typeof reportCompare === 'function') reportCompare(0,0,"OK"); diff --git a/js/src/tests/ecma_6/Class/derivedConstructorArrowEvalGetThis.js b/js/src/tests/ecma_6/Class/derivedConstructorArrowEvalGetThis.js index dbc69beb8a..26f9843d2c 100644 --- a/js/src/tests/ecma_6/Class/derivedConstructorArrowEvalGetThis.js +++ b/js/src/tests/ecma_6/Class/derivedConstructorArrowEvalGetThis.js @@ -1,5 +1,3 @@ -var test = ` - new class extends class { } { constructor() { super(); @@ -8,10 +6,5 @@ new class extends class { } { } }(); -`; - -if (classesEnabled()) - eval(test); - if (typeof reportCompare === 'function') reportCompare(0,0,"OK"); diff --git a/js/src/tests/ecma_6/Class/derivedConstructorArrowEvalNestedSuperCall.js b/js/src/tests/ecma_6/Class/derivedConstructorArrowEvalNestedSuperCall.js index 60acffd14a..d81f186485 100644 --- a/js/src/tests/ecma_6/Class/derivedConstructorArrowEvalNestedSuperCall.js +++ b/js/src/tests/ecma_6/Class/derivedConstructorArrowEvalNestedSuperCall.js @@ -1,5 +1,3 @@ -var test = ` - new class extends class { } { constructor() { (()=>eval("super()"))(); @@ -32,10 +30,5 @@ new class extends class { } { } }(); -`; - -if (classesEnabled()) - eval(test); - if (typeof reportCompare === 'function') reportCompare(0,0,"OK"); diff --git a/js/src/tests/ecma_6/Class/derivedConstructorArrowEvalSuperCall.js b/js/src/tests/ecma_6/Class/derivedConstructorArrowEvalSuperCall.js index 76bb184243..0f60df7465 100644 --- a/js/src/tests/ecma_6/Class/derivedConstructorArrowEvalSuperCall.js +++ b/js/src/tests/ecma_6/Class/derivedConstructorArrowEvalSuperCall.js @@ -1,5 +1,3 @@ -var test = ` - new class extends class { } { constructor() { assertEq(eval("super(); this"), this); @@ -16,10 +14,5 @@ new class extends class { } { } }(); -`; - -if (classesEnabled()) - eval(test); - if (typeof reportCompare === 'function') reportCompare(0,0,"OK"); diff --git a/js/src/tests/ecma_6/Class/derivedConstructorTDZExplicitThis.js b/js/src/tests/ecma_6/Class/derivedConstructorTDZExplicitThis.js index 8ef9e48eea..fc5dd3858b 100644 --- a/js/src/tests/ecma_6/Class/derivedConstructorTDZExplicitThis.js +++ b/js/src/tests/ecma_6/Class/derivedConstructorTDZExplicitThis.js @@ -1,12 +1,6 @@ -function pleaseRunMyCode() { } - class foo extends null { constructor() { - // Just bareword |this| is DCEd by the BytecodeEmitter. Your guess as - // to why we think this is a good idea is as good as mine. In order to - // combat this inanity, make it a function arg, so we have to compute - // it. - pleaseRunMyCode(this); + this; assertEq(false, true); } } diff --git a/js/src/tests/ecma_6/Class/extendBuiltinConstructors.js b/js/src/tests/ecma_6/Class/extendBuiltinConstructors.js index 4715dc412d..55770b86ea 100644 --- a/js/src/tests/ecma_6/Class/extendBuiltinConstructors.js +++ b/js/src/tests/ecma_6/Class/extendBuiltinConstructors.js @@ -1,5 +1,3 @@ -var test = ` - function testBuiltinInstanceIsInstanceOf(instance, builtin, class_) { assertEq(instance instanceof class_, true); assertEq(instance instanceof builtin, true); @@ -103,10 +101,8 @@ testBuiltin(Array, 3.0); testBuiltin(Array, "non-length one-arg"); testBuiltin(Array, 5, 10, 15, "these are elements"); -`; - -if (classesEnabled()) - eval(test); +if (this.SharedArrayBuffer) + testBuiltin(SharedArrayBuffer); if (typeof reportCompare === 'function') reportCompare(0,0,"OK"); diff --git a/js/src/tests/ecma_6/Class/geterNoExprClosure.js b/js/src/tests/ecma_6/Class/geterNoExprClosure.js index b447d08576..e37cb287a9 100644 --- a/js/src/tests/ecma_6/Class/geterNoExprClosure.js +++ b/js/src/tests/ecma_6/Class/geterNoExprClosure.js @@ -1,24 +1,20 @@ // getter/setter with expression closure is allowed only in object literal. -function test() { - assertThrowsInstanceOf(() => eval(` -class foo { - constructor() {} +assertThrowsInstanceOf(() => eval(` + class foo { + constructor() {} - get a() 1 -} + get a() 1 + } `), SyntaxError); - assertThrowsInstanceOf(() => eval(` -class foo { - constructor() {} - set a(v) 1 -} +assertThrowsInstanceOf(() => eval(` + class foo { + constructor() {} + + set a(v) 1 + } `), SyntaxError); -} - -if (classesEnabled()) - test(); if (typeof reportCompare === 'function') reportCompare(0,0,"OK"); diff --git a/js/src/tests/ecma_6/Class/innerBinding.js b/js/src/tests/ecma_6/Class/innerBinding.js index 30985fd37d..b1afa177e0 100644 --- a/js/src/tests/ecma_6/Class/innerBinding.js +++ b/js/src/tests/ecma_6/Class/innerBinding.js @@ -1,52 +1,26 @@ // Named class definitions should create an immutable inner binding. // Since all code in classes is in strict mode, attempts to mutate it // should throw. - -if (classesEnabled()) { - -// XXXefaust Because we currently try to do assignment to const as an early -// error, sometimes, maybe, this is almost sometimes a syntax error. -// It is specced to be a TypeError - -function statementWrapper() { - eval("class Foo { constructor() { } tryBreak() { Foo = 4; } }"); -} - -function expressionWrapper() { - // Mmmmm. Lazy parseing means we don't see this as an error until later. - eval(`var x = class Foo { constructor() { }; tryBreak() { Foo = 4; } }; - new x().tryBreak();`); -} - -assertThrowsInstanceOf(statementWrapper, SyntaxError); -assertThrowsInstanceOf(expressionWrapper, TypeError); - -/* -var test = ` -class Foo { constructor() { }; tryBreak() { Foo = 4; } } -for (let result of [Foo, class Bar { constructor() { }; tryBreak() { Bar = 4; } }]) +class Foof { constructor() { }; tryBreak() { Foof = 4; } } +for (let result of [Foof, class Bar { constructor() { }; tryBreak() { Bar = 4; } }]) assertThrowsInstanceOf(() => new result().tryBreak(), TypeError); { class foo { constructor() { }; tryBreak() { foo = 4; } } - for (let result of [foo, class Bar { constructor() { }; tryBreak() { Bar = 4 }]) + for (let result of [foo, class Bar { constructor() { }; tryBreak() { Bar = 4 } }]) assertThrowsInstanceOf(() => new result().tryBreak(), TypeError); } -`; -*/ - -var test = ` // TDZ applies to inner bindings -assertThrowsInstanceOf(()=>eval(\`class Bar { +assertThrowsInstanceOf(()=>eval(`class Bar { constructor() { }; [Bar] () { }; - }\`), ReferenceError); + }`), ReferenceError); -assertThrowsInstanceOf(()=>eval(\`(class Bar { +assertThrowsInstanceOf(()=>eval(`(class Bar { constructor() { }; [Bar] () { }; - })\`), ReferenceError); + })`), ReferenceError); // There's no magic "inner binding" global { @@ -108,12 +82,5 @@ assertEq(new class Foo { new orig_X().f(); } - -`; - -eval(test); - -} - if (typeof reportCompare === "function") reportCompare(0, 0, "OK"); diff --git a/js/src/tests/ecma_6/Class/methDefn.js b/js/src/tests/ecma_6/Class/methDefn.js index bbce2f2789..9513bdfb30 100644 --- a/js/src/tests/ecma_6/Class/methDefn.js +++ b/js/src/tests/ecma_6/Class/methDefn.js @@ -200,5 +200,5 @@ testStrictMode(); assertEq(({ method() {} }).method.name, "method"); assertThrowsInstanceOf(function() {({ method() { method() } }).method() }, ReferenceError); - -reportCompare(0, 0, "ok"); +if (typeof reportCompare === 'function') + reportCompare(0, 0, "ok"); diff --git a/js/src/tests/ecma_6/Class/methDefnGen.js b/js/src/tests/ecma_6/Class/methDefnGen.js index 5972b013ff..3165ed4481 100644 --- a/js/src/tests/ecma_6/Class/methDefnGen.js +++ b/js/src/tests/ecma_6/Class/methDefnGen.js @@ -79,4 +79,5 @@ assertEq(a.b(1).next().value, 1); a = {*g() { yield 1; }} assertThrowsInstanceOf(() => { new a.g }, TypeError); -reportCompare(0, 0, "ok"); +if (typeof reportCompare === 'function') + reportCompare(0, 0, "ok"); diff --git a/js/src/tests/ecma_6/Class/methodInstallation.js b/js/src/tests/ecma_6/Class/methodInstallation.js index cceb0bfbc7..bbb6c2f727 100644 --- a/js/src/tests/ecma_6/Class/methodInstallation.js +++ b/js/src/tests/ecma_6/Class/methodInstallation.js @@ -1,7 +1,5 @@ // Do the things we write in classes actually appear as they are supposed to? -var test= ` - var methodCalled; var getterCalled; var setterCalled; @@ -40,7 +38,7 @@ for (let a of [testClass, staticGetterCalled = false; staticSetterCalled = false; - var aConstDesc = Object.getOwnPropertyDescriptor(a.prototype, \"constructor\"); + var aConstDesc = Object.getOwnPropertyDescriptor(a.prototype, "constructor"); assertEq(aConstDesc.writable, true); assertEq(aConstDesc.configurable, true); assertEq(aConstDesc.enumerable, false); @@ -49,30 +47,30 @@ for (let a of [testClass, // __proto__ is just an identifier for classes. No prototype changes are made. assertEq(Object.getPrototypeOf(a.prototype), Object.prototype); - var aMethDesc = Object.getOwnPropertyDescriptor(a.prototype, \"__proto__\"); + var aMethDesc = Object.getOwnPropertyDescriptor(a.prototype, "__proto__"); assertEq(aMethDesc.writable, true); assertEq(aMethDesc.configurable, true); assertEq(aMethDesc.enumerable, false); aMethDesc.value(); assertEq(methodCalled, true); - var aGetDesc = Object.getOwnPropertyDescriptor(a.prototype, \"getter\"); + var aGetDesc = Object.getOwnPropertyDescriptor(a.prototype, "getter"); assertEq(aGetDesc.configurable, true); assertEq(aGetDesc.enumerable, false); aGetDesc.get(); assertThrowsInstanceOf(() => new aGetDesc.get, TypeError); assertEq(getterCalled, true); - var aSetDesc = Object.getOwnPropertyDescriptor(a.prototype, \"setter\"); + var aSetDesc = Object.getOwnPropertyDescriptor(a.prototype, "setter"); assertEq(aSetDesc.configurable, true); assertEq(aSetDesc.enumerable, false); aSetDesc.set(); assertThrowsInstanceOf(() => new aSetDesc.set, TypeError); assertEq(setterCalled, true); - assertDeepEq(aSetDesc, Object.getOwnPropertyDescriptor(a.prototype, \"setter\")); + assertDeepEq(aSetDesc, Object.getOwnPropertyDescriptor(a.prototype, "setter")); - assertEq(Object.getOwnPropertyDescriptor(new a(), \"staticMethod\"), undefined); - var aStaticMethDesc = Object.getOwnPropertyDescriptor(a, \"staticMethod\"); + assertEq(Object.getOwnPropertyDescriptor(new a(), "staticMethod"), undefined); + var aStaticMethDesc = Object.getOwnPropertyDescriptor(a, "staticMethod"); assertEq(aStaticMethDesc.configurable, true); assertEq(aStaticMethDesc.enumerable, false); assertEq(aStaticMethDesc.writable, true); @@ -80,16 +78,16 @@ for (let a of [testClass, assertThrowsInstanceOf(() => new aStaticMethDesc.value, TypeError); assertEq(staticMethodCalled, true); - assertEq(Object.getOwnPropertyDescriptor(new a(), \"staticGetter\"), undefined); - var aStaticGetDesc = Object.getOwnPropertyDescriptor(a, \"staticGetter\"); + assertEq(Object.getOwnPropertyDescriptor(new a(), "staticGetter"), undefined); + var aStaticGetDesc = Object.getOwnPropertyDescriptor(a, "staticGetter"); assertEq(aStaticGetDesc.configurable, true); assertEq(aStaticGetDesc.enumerable, false); aStaticGetDesc.get(); assertThrowsInstanceOf(() => new aStaticGetDesc.get, TypeError); assertEq(staticGetterCalled, true); - assertEq(Object.getOwnPropertyDescriptor(new a(), \"staticSetter\"), undefined); - var aStaticSetDesc = Object.getOwnPropertyDescriptor(a, \"staticSetter\"); + assertEq(Object.getOwnPropertyDescriptor(new a(), "staticSetter"), undefined); + var aStaticSetDesc = Object.getOwnPropertyDescriptor(a, "staticSetter"); assertEq(aStaticSetDesc.configurable, true); assertEq(aStaticSetDesc.enumerable, false); aStaticSetDesc.set(); @@ -98,10 +96,6 @@ for (let a of [testClass, assertEq([...new a()].join(), "cow,pig"); } -`; - -if (classesEnabled()) - eval(test); if (typeof reportCompare === "function") reportCompare(0, 0, "OK"); diff --git a/js/src/tests/ecma_6/Class/methodOverwrites.js b/js/src/tests/ecma_6/Class/methodOverwrites.js index 87cd371961..c1c460a28c 100644 --- a/js/src/tests/ecma_6/Class/methodOverwrites.js +++ b/js/src/tests/ecma_6/Class/methodOverwrites.js @@ -1,18 +1,15 @@ // Ensure that we can overwrite methods when more tha one is present. - -var test = ` - { var result = 0; // Regardless of order, the constructor is overridden by any CPN, because it's // processed seperately. - class a { [\"constructor\"]() { result += 1; }; constructor() { result += 2; } } + class a { ["constructor"]() { result += 1; }; constructor() { result += 2; } } var aInst = new a(); assertEq(result, 2); aInst.constructor(); assertEq(result, 3); - class b { constructor() { result += 2; } [\"constructor\"]() { result += 1; }; } + class b { constructor() { result += 2; } ["constructor"]() { result += 1; }; } var bInst = new b(); assertEq(result, 5); bInst.constructor(); @@ -45,13 +42,13 @@ var test = ` var result = 0; // Regardless of order, the constructor is overridden by any CPN, because it's // processed seperately. - let a = class { [\"constructor\"]() { result += 1; }; constructor() { result += 2; } }; + let a = class { ["constructor"]() { result += 1; }; constructor() { result += 2; } }; var aInst = new a(); assertEq(result, 2); aInst.constructor(); assertEq(result, 3); - let b = class { constructor() { result += 2; } [\"constructor\"]() { result += 1; }; }; + let b = class { constructor() { result += 2; } ["constructor"]() { result += 1; }; }; var bInst = new b(); assertEq(result, 5); bInst.constructor(); @@ -78,10 +75,6 @@ var test = ` new f().method(); assertEq(result, 12); } -`; - -if (classesEnabled()) - eval(test); if (typeof reportCompare === "function") reportCompare(0, 0, "OK"); diff --git a/js/src/tests/ecma_6/Class/methodsPrototype.js b/js/src/tests/ecma_6/Class/methodsPrototype.js index 65d5f465d7..07a565ceb6 100644 --- a/js/src/tests/ecma_6/Class/methodsPrototype.js +++ b/js/src/tests/ecma_6/Class/methodsPrototype.js @@ -1,4 +1,3 @@ -var test = ` class TestClass { constructor() { } method() { } @@ -36,10 +35,5 @@ for (var fun of hasNoPrototype) { assertEq(fun.hasOwnProperty('prototype'), false); } -`; - -if (classesEnabled()) - eval(test); - if (typeof reportCompare === "function") reportCompare(0, 0, "OK"); diff --git a/js/src/tests/ecma_6/Class/newTargetMethods.js b/js/src/tests/ecma_6/Class/newTargetMethods.js index 055ec0bf19..2383dc8bd8 100644 --- a/js/src/tests/ecma_6/Class/newTargetMethods.js +++ b/js/src/tests/ecma_6/Class/newTargetMethods.js @@ -1,5 +1,3 @@ -var test = ` - // Just like newTargetDirectInvoke, except to prove it works in functions // defined with method syntax as well. Note that methods, getters, and setters // are not constructible. @@ -48,10 +46,6 @@ for (let i = 0; i < TEST_ITERATIONS; i++) clInst.cl; for (let i = 0; i < TEST_ITERATIONS; i++) clInst.cl = 4; -`; - -if (classesEnabled()) - eval(test); if (typeof reportCompare === "function") reportCompare(0,0,"OK"); diff --git a/js/src/tests/ecma_6/Class/outerBinding.js b/js/src/tests/ecma_6/Class/outerBinding.js index 13e7b3951f..d34df015f1 100644 --- a/js/src/tests/ecma_6/Class/outerBinding.js +++ b/js/src/tests/ecma_6/Class/outerBinding.js @@ -5,15 +5,14 @@ // // A class statement creates a mutable lexical outer binding. -var test = ` class Foo { constructor() { } } -assertEq(typeof Foo, \"function\"); +assertEq(typeof Foo, "function"); Foo = 5; assertEq(Foo, 5); { class foo { constructor() { } } - assertEq(typeof foo, \"function\"); + assertEq(typeof foo, "function"); foo = 4; assertEq(foo, 4); } @@ -35,16 +34,12 @@ assertEq(earlyError, true); function strictEvalShadows() { "use strict"; let x = 4; - eval(\`class x { constructor() { } } + eval(`class x { constructor() { } } assertEq(typeof x, "function"); - \`); + `); assertEq(x, 4); } strictEvalShadows() -`; - -if (classesEnabled()) - eval(test); if (typeof reportCompare === "function") reportCompare(0, 0, "OK"); diff --git a/js/src/tests/ecma_6/Class/staticConstructor.js b/js/src/tests/ecma_6/Class/staticConstructor.js index 698c4eebf7..bd79c22005 100644 --- a/js/src/tests/ecma_6/Class/staticConstructor.js +++ b/js/src/tests/ecma_6/Class/staticConstructor.js @@ -1,10 +1,9 @@ -var test = ` -class test { +class testBasic { constructor() { } static constructor() { } } -class testWithExtends { +class testWithExtends extends null { constructor() { }; static constructor() { }; } @@ -18,10 +17,6 @@ class testOrderWithExtends extends null { static constructor() { }; constructor() { }; } -`; - -if (classesEnabled()) - eval(test); if (typeof reportCompare === "function") reportCompare(0,0,"OK"); diff --git a/js/src/tests/ecma_6/Class/staticMethods.js b/js/src/tests/ecma_6/Class/staticMethods.js index a22640e22d..756e5abf56 100644 --- a/js/src/tests/ecma_6/Class/staticMethods.js +++ b/js/src/tests/ecma_6/Class/staticMethods.js @@ -1,5 +1,3 @@ -var test = ` - // basic static method test class X { static count() { return ++this.hits; } @@ -13,10 +11,5 @@ assertEq(X.count instanceof Function, true); assertEq(X.count.length, 0); assertEq(X.count.bind({hits: 77})(), 78); -`; - -if (classesEnabled()) - eval(test); - if (typeof reportCompare === "function") reportCompare(0, 0, "OK"); diff --git a/js/src/tests/ecma_6/Class/strictExecution.js b/js/src/tests/ecma_6/Class/strictExecution.js index 9608d47e1f..f459311e55 100644 --- a/js/src/tests/ecma_6/Class/strictExecution.js +++ b/js/src/tests/ecma_6/Class/strictExecution.js @@ -1,7 +1,6 @@ // Classes are always strict mode. Check computed property names and heritage // expressions as well. -var test = ` class a { constructor() { Object.preventExtensions({}).prop = 0; } } assertThrowsInstanceOf(() => new a(), TypeError); var aExpr = class { constructor() { Object.preventExtensions().prop = 0; } }; @@ -34,10 +33,6 @@ function shouldThrowHeritageExpr() { } assertThrowsInstanceOf(shouldThrowHeritage, TypeError); assertThrowsInstanceOf(shouldThrowHeritageExpr, TypeError); -`; - -if (classesEnabled()) - eval(test); if (typeof reportCompare === "function") reportCompare(0, 0, "OK"); diff --git a/js/src/tests/ecma_6/Class/subclassedArrayUnboxed.js b/js/src/tests/ecma_6/Class/subclassedArrayUnboxed.js index 00e812e945..eb27a960d0 100644 --- a/js/src/tests/ecma_6/Class/subclassedArrayUnboxed.js +++ b/js/src/tests/ecma_6/Class/subclassedArrayUnboxed.js @@ -1,5 +1,3 @@ -var test = ` - class foo extends Array { } function testArrs(arrs) { @@ -20,10 +18,5 @@ arrs.push(new foo(1)); testArrs(arrs); -`; - -if (classesEnabled()) - eval(test); - if (typeof reportCompare === 'function') reportCompare(0,0,"OK"); diff --git a/js/src/tests/ecma_6/Class/superCallBadDynamicSuperClass.js b/js/src/tests/ecma_6/Class/superCallBadDynamicSuperClass.js index 1792434538..f5b3ac3c0c 100644 --- a/js/src/tests/ecma_6/Class/superCallBadDynamicSuperClass.js +++ b/js/src/tests/ecma_6/Class/superCallBadDynamicSuperClass.js @@ -1,5 +1,3 @@ -var test = ` - class base { constructor() { } } class inst extends base { constructor() { super(); } } @@ -10,10 +8,5 @@ class defaultInst extends base { } Object.setPrototypeOf(inst, Math.sin); assertThrowsInstanceOf(() => new inst(), TypeError); -`; - -if (classesEnabled()) - eval(test); - if (typeof reportCompare === 'function') reportCompare(0,0,"OK"); diff --git a/js/src/tests/ecma_6/Class/superCallBadNewTargetPrototype.js b/js/src/tests/ecma_6/Class/superCallBadNewTargetPrototype.js index cc79da2a1a..43d1eb60d1 100644 --- a/js/src/tests/ecma_6/Class/superCallBadNewTargetPrototype.js +++ b/js/src/tests/ecma_6/Class/superCallBadNewTargetPrototype.js @@ -1,5 +1,3 @@ -var test = ` - class base { constructor() { } } // lies and the lying liars who tell them @@ -23,10 +21,5 @@ assertThrowsInstanceOf(()=>new new Proxy(inst, {get})(), TypeError); class defaultInst extends base {} assertThrowsInstanceOf(()=>new new Proxy(defaultInst, {get})(), TypeError); -`; - -if (classesEnabled()) - eval(test); - if (typeof reportCompare === 'function') reportCompare(0,0,"OK"); diff --git a/js/src/tests/ecma_6/Class/superCallBaseInvoked.js b/js/src/tests/ecma_6/Class/superCallBaseInvoked.js index 59ef23650d..b66f9be170 100644 --- a/js/src/tests/ecma_6/Class/superCallBaseInvoked.js +++ b/js/src/tests/ecma_6/Class/superCallBaseInvoked.js @@ -1,5 +1,3 @@ -var test = ` - function testBase(base) { class instance extends base { constructor(inst, one) { @@ -53,10 +51,5 @@ testBase(p); handler.construct = (target, args, nt) => Reflect.construct(target, args, nt); testBase(p); -`; - -if (classesEnabled()) - eval(test); - if (typeof reportCompare === 'function') reportCompare(0,0,"OK"); diff --git a/js/src/tests/ecma_6/Class/superCallInvalidBase.js b/js/src/tests/ecma_6/Class/superCallInvalidBase.js index 3f15ae6927..86b24f96c5 100644 --- a/js/src/tests/ecma_6/Class/superCallInvalidBase.js +++ b/js/src/tests/ecma_6/Class/superCallInvalidBase.js @@ -1,5 +1,3 @@ -var test = ` - class instance extends null { constructor() { super(); } } @@ -7,11 +5,5 @@ class instance extends null { assertThrowsInstanceOf(() => new instance(), TypeError); assertThrowsInstanceOf(() => new class extends null { }(), TypeError); - -`; - -if (classesEnabled()) - eval(test); - if (typeof reportCompare === 'function') reportCompare(0,0,"OK"); diff --git a/js/src/tests/ecma_6/Class/superCallOrder.js b/js/src/tests/ecma_6/Class/superCallOrder.js index 1c71785b38..051658eef3 100644 --- a/js/src/tests/ecma_6/Class/superCallOrder.js +++ b/js/src/tests/ecma_6/Class/superCallOrder.js @@ -1,5 +1,3 @@ -var test = ` - function base() { } class beforeSwizzle extends base { @@ -24,10 +22,5 @@ Object.setPrototypeOf(beforeThrow, Math.sin); // Will throw that Math.sin is not a constructor before evaluating the args assertThrowsInstanceOf(() => new beforeThrow(), TypeError); -`; - -if (classesEnabled()) - eval(test); - if (typeof reportCompare === 'function') reportCompare(0,0,"OK"); diff --git a/js/src/tests/ecma_6/Class/superCallProperBase.js b/js/src/tests/ecma_6/Class/superCallProperBase.js index 262cdc5e83..cc03f57d08 100644 --- a/js/src/tests/ecma_6/Class/superCallProperBase.js +++ b/js/src/tests/ecma_6/Class/superCallProperBase.js @@ -1,5 +1,3 @@ -var test = ` - class base1 { constructor() { this.base = 1; @@ -32,10 +30,5 @@ assertEq(new defaultInst().base, 1); Object.setPrototypeOf(defaultInst, base2); assertEq(new defaultInst().base, 2); -`; - -if (classesEnabled()) - eval(test); - if (typeof reportCompare === 'function') reportCompare(0,0,"OK"); diff --git a/js/src/tests/ecma_6/Class/superCallSpreadCall.js b/js/src/tests/ecma_6/Class/superCallSpreadCall.js index e20f9627d6..1045f1a22a 100644 --- a/js/src/tests/ecma_6/Class/superCallSpreadCall.js +++ b/js/src/tests/ecma_6/Class/superCallSpreadCall.js @@ -1,5 +1,3 @@ -var test = ` - class base { constructor(a, b, c) { assertEq(a, 1); @@ -9,13 +7,13 @@ class base { } } -class test extends base { +class doTest extends base { constructor(arr) { super(...arr); } } -assertEq(new test([1,2,3]).calledBase, true); +assertEq(new doTest([1,2,3]).calledBase, true); class testRest extends base { constructor(...args) { @@ -25,10 +23,5 @@ class testRest extends base { assertEq(new testRest(1,2,3).calledBase, true); -`; - -if (classesEnabled()) - eval(test); - if (typeof reportCompare === 'function') reportCompare(0,0,"OK"); diff --git a/js/src/tests/ecma_6/Class/superCallThisInit.js b/js/src/tests/ecma_6/Class/superCallThisInit.js index b2442d91d0..4154b36119 100644 --- a/js/src/tests/ecma_6/Class/superCallThisInit.js +++ b/js/src/tests/ecma_6/Class/superCallThisInit.js @@ -1,5 +1,3 @@ -var test = ` - function base() { this.prop = 42; } class testInitialize extends base { @@ -43,10 +41,5 @@ class canCatchThrow extends base { } assertEq(new canCatchThrow().prop, 42); -`; - -if (classesEnabled()) - eval(test); - if (typeof reportCompare === 'function') reportCompare(0,0,"OK"); diff --git a/js/src/tests/ecma_6/Class/superPropBasicCalls.js b/js/src/tests/ecma_6/Class/superPropBasicCalls.js index b101311f1b..29ed49319b 100644 --- a/js/src/tests/ecma_6/Class/superPropBasicCalls.js +++ b/js/src/tests/ecma_6/Class/superPropBasicCalls.js @@ -1,5 +1,3 @@ -var test = ` - // Super property (and calls) works in non-extending classes and object // litterals. class toStringTest { @@ -25,10 +23,5 @@ let toStrOL = { toStrOL.test(); -`; - -if (classesEnabled()) - eval(test); - if (typeof reportCompare === 'function') reportCompare(0,0,"OK"); diff --git a/js/src/tests/ecma_6/Class/superPropBasicChain.js b/js/src/tests/ecma_6/Class/superPropBasicChain.js index 20c034d2c0..12bf84820e 100644 --- a/js/src/tests/ecma_6/Class/superPropBasicChain.js +++ b/js/src/tests/ecma_6/Class/superPropBasicChain.js @@ -1,5 +1,3 @@ -var test = ` - var o = { access() { super.foo.bar; @@ -9,10 +7,5 @@ var o = { // Delazify assertThrowsInstanceOf(o.access, TypeError); -`; - -if (classesEnabled()) - eval(test); - if (typeof reportCompare === 'function') reportCompare(0,0,"OK"); diff --git a/js/src/tests/ecma_6/Class/superPropBasicGetter.js b/js/src/tests/ecma_6/Class/superPropBasicGetter.js index 88c9c64f35..fe1f4eeee8 100644 --- a/js/src/tests/ecma_6/Class/superPropBasicGetter.js +++ b/js/src/tests/ecma_6/Class/superPropBasicGetter.js @@ -1,5 +1,3 @@ -var test = ` - class base { constructor() {} @@ -34,10 +32,5 @@ class derived extends base { var derivedInstance = new derived(); derivedInstance.test(); -`; - -if (classesEnabled()) - eval(test); - if (typeof reportCompare === 'function') reportCompare(0,0,"OK"); diff --git a/js/src/tests/ecma_6/Class/superPropBasicNew.js b/js/src/tests/ecma_6/Class/superPropBasicNew.js index e12cdea56d..e1ca9b4ae1 100644 --- a/js/src/tests/ecma_6/Class/superPropBasicNew.js +++ b/js/src/tests/ecma_6/Class/superPropBasicNew.js @@ -1,5 +1,3 @@ -var test = ` - class Base { constructor() {} } @@ -15,10 +13,5 @@ let d = new Derived(); var df = d.f(); assertEq(df.constructor, Base); -`; - -if (classesEnabled()) - eval(test); - if (typeof reportCompare === 'function') reportCompare(0,0,"OK"); diff --git a/js/src/tests/ecma_6/Class/superPropChains.js b/js/src/tests/ecma_6/Class/superPropChains.js index 8770e9eac3..e8c0de05cd 100644 --- a/js/src/tests/ecma_6/Class/superPropChains.js +++ b/js/src/tests/ecma_6/Class/superPropChains.js @@ -1,5 +1,3 @@ -var test = ` - // First, let's test the trivial. A chain of three works. class base { constructor() { } @@ -56,10 +54,5 @@ assertEq(inst.baseCalled, true); assertEq(inst.x, "yeehaw"); -`; - -if (classesEnabled()) - eval(test); - if (typeof reportCompare === 'function') reportCompare(0,0,"OK"); diff --git a/js/src/tests/ecma_6/Class/superPropDVG.js b/js/src/tests/ecma_6/Class/superPropDVG.js index e0a08f20ca..f187cb6ea1 100644 --- a/js/src/tests/ecma_6/Class/superPropDVG.js +++ b/js/src/tests/ecma_6/Class/superPropDVG.js @@ -1,7 +1,4 @@ // Super property accesses should play nice with the pretty printer. - -var test = ` - class testNonExistent { constructor() { super["prop"](); @@ -16,10 +13,5 @@ assertThrownErrorContains(() => ol.testNonExistent(), "super.prop"); var olElem = { testNonExistent() { var prop = "prop"; super[prop](); } }; assertThrownErrorContains(() => olElem.testNonExistent(), "super[prop]"); -`; - -if (classesEnabled()) - eval(test); - if (typeof reportCompare === 'function') reportCompare(0,0,"OK"); diff --git a/js/src/tests/ecma_6/Class/superPropDelete.js b/js/src/tests/ecma_6/Class/superPropDelete.js index 68e1331365..44bf0d3f6d 100644 --- a/js/src/tests/ecma_6/Class/superPropDelete.js +++ b/js/src/tests/ecma_6/Class/superPropDelete.js @@ -1,7 +1,5 @@ -var test = ` - +// Make sure we get the proper side effects. // |delete super.prop| and |delete super[expr]| throw universally. -// Even so, we should make sure we get proper side effects class base { constructor() { } @@ -44,10 +42,5 @@ Object.setPrototypeOf(thing2, new Proxy({}, { })); assertThrowsInstanceOf(() => thing2.go(), ReferenceError); -`; - -if (classesEnabled()) - eval(test); - if (typeof reportCompare === 'function') reportCompare(0,0,"OK"); diff --git a/js/src/tests/ecma_6/Class/superPropDerivedCalls.js b/js/src/tests/ecma_6/Class/superPropDerivedCalls.js index 3b0ef4def3..1a8a036057 100644 --- a/js/src/tests/ecma_6/Class/superPropDerivedCalls.js +++ b/js/src/tests/ecma_6/Class/superPropDerivedCalls.js @@ -1,5 +1,3 @@ -var test = ` - let derivedInstance; class base { @@ -75,10 +73,5 @@ derivedInstance.test(); derivedInstance.testInEval(); derivedInstance.testInArrow(); -`; - -if (classesEnabled()) - eval(test); - if (typeof reportCompare === 'function') reportCompare(0,0,"OK"); diff --git a/js/src/tests/ecma_6/Class/superPropDestructuring.js b/js/src/tests/ecma_6/Class/superPropDestructuring.js index f6bc0c5925..84d1bb517a 100644 --- a/js/src/tests/ecma_6/Class/superPropDestructuring.js +++ b/js/src/tests/ecma_6/Class/superPropDestructuring.js @@ -1,5 +1,3 @@ -var test = ` - class base { constructor() { } } @@ -41,10 +39,5 @@ let d = new derived(); d.testProps(); d.testElems(); -`; - -if (classesEnabled()) - eval(test); - if (typeof reportCompare === 'function') reportCompare(0,0,"OK"); diff --git a/js/src/tests/ecma_6/Class/superPropEvalInsideArrow.js b/js/src/tests/ecma_6/Class/superPropEvalInsideArrow.js index c81d86c3dc..882f93ba0a 100644 --- a/js/src/tests/ecma_6/Class/superPropEvalInsideArrow.js +++ b/js/src/tests/ecma_6/Class/superPropEvalInsideArrow.js @@ -1,5 +1,3 @@ -var test = ` - class foo { constructor() { } @@ -8,10 +6,6 @@ class foo { } } assertEq(new foo().method()(), Object.prototype.toString); -`; - -if (classesEnabled()) - eval(test); if (typeof reportCompare === "function") reportCompare(0,0,"OK"); diff --git a/js/src/tests/ecma_6/Class/superPropFor.js b/js/src/tests/ecma_6/Class/superPropFor.js index ac56382c28..23b222cb3e 100644 --- a/js/src/tests/ecma_6/Class/superPropFor.js +++ b/js/src/tests/ecma_6/Class/superPropFor.js @@ -1,7 +1,5 @@ -var test = ` - class testForIn { - constructor() { + constructor() { let hits = 0; for (super.prop in { prop1: 1, prop2: 2 }) hits++; @@ -23,11 +21,5 @@ new testForIn(); } }).testForOf(); -`; - -if (classesEnabled()) - eval(test); - - if (typeof reportCompare === 'function') reportCompare(0,0,"OK"); diff --git a/js/src/tests/ecma_6/Class/superPropHeavyweightArrow.js b/js/src/tests/ecma_6/Class/superPropHeavyweightArrow.js index dda69edc0c..ce30690d53 100644 --- a/js/src/tests/ecma_6/Class/superPropHeavyweightArrow.js +++ b/js/src/tests/ecma_6/Class/superPropHeavyweightArrow.js @@ -1,5 +1,3 @@ -var test = ` - class foo { constructor() { } @@ -9,10 +7,6 @@ class foo { } assertEq(new foo().method()(), Object.prototype.toString); -`; - -if (classesEnabled()) - eval(test); if (typeof reportCompare === "function") reportCompare(0,0,"OK"); diff --git a/js/src/tests/ecma_6/Class/superPropHomeObject.js b/js/src/tests/ecma_6/Class/superPropHomeObject.js index 6fee180701..7694ae8523 100644 --- a/js/src/tests/ecma_6/Class/superPropHomeObject.js +++ b/js/src/tests/ecma_6/Class/superPropHomeObject.js @@ -1,5 +1,3 @@ -var test = ` - // This is super weird. A super property reference in the spec contains two // things. The first is the object to do the lookup on, the super base. This // should be unchanged, no matter what's going on: I can move the method to @@ -27,10 +25,10 @@ derivedInstance.testCPN(derivedInstance); let obj = { test: derivedInstance.test }; obj.test(obj); -let test = derivedInstance.test; +let testSolo = derivedInstance.test; // Hah! The engine is not prepared for non-object receivers, since this couldn't // happen before. Hope Waldo fixes this soon as he claims he will :) -assertThrowsInstanceOf(() =>test(undefined), TypeError); +assertThrowsInstanceOf(() =>testSolo(undefined), TypeError); let anotherObject = { }; derivedInstance.test.call(anotherObject, anotherObject); @@ -60,10 +58,5 @@ for (let exprBase of [base1, base2]) }().test(); assertDeepEq(animals, ["llama", "alpaca"]); -`; - -if (classesEnabled()) - eval(test); - if (typeof reportCompare === 'function') reportCompare(0,0,"OK"); diff --git a/js/src/tests/ecma_6/Class/superPropIncDecElem.js b/js/src/tests/ecma_6/Class/superPropIncDecElem.js index 12b369d3ed..a7b93eb371 100644 --- a/js/src/tests/ecma_6/Class/superPropIncDecElem.js +++ b/js/src/tests/ecma_6/Class/superPropIncDecElem.js @@ -1,5 +1,3 @@ -var test = ` - // #1 function base() { } @@ -22,10 +20,5 @@ class test2 { var d = new test2(); d.test() -`; - -if (classesEnabled()) - eval(test); - if (typeof reportCompare === 'function') reportCompare(0,0,"OK"); diff --git a/js/src/tests/ecma_6/Class/superPropLazyInnerFunction.js b/js/src/tests/ecma_6/Class/superPropLazyInnerFunction.js index d5f90e081b..d7a441f93b 100644 --- a/js/src/tests/ecma_6/Class/superPropLazyInnerFunction.js +++ b/js/src/tests/ecma_6/Class/superPropLazyInnerFunction.js @@ -1,4 +1,3 @@ -var test = ` testcase(); function testcase() { var tokenCodes = { @@ -15,10 +14,6 @@ function testcase() { if (tokenCodes[arr[i]] !== i) {}; } } -`; - -if (classesEnabled()) - eval(test); if (typeof reportCompare === 'function') reportCompare(0,0,"OK"); diff --git a/js/src/tests/ecma_6/Class/superPropNoOverwriting.js b/js/src/tests/ecma_6/Class/superPropNoOverwriting.js index b5dc772dfe..db44b509c5 100644 --- a/js/src/tests/ecma_6/Class/superPropNoOverwriting.js +++ b/js/src/tests/ecma_6/Class/superPropNoOverwriting.js @@ -1,5 +1,3 @@ -var test = ` - class X { constructor() { Object.defineProperty(this, "prop1", { @@ -56,10 +54,5 @@ assertEq(x.prop3, undefined); assertThrowsInstanceOf(() => x.f4(), TypeError); assertEq(x.prop4, 20); -`; - -if (classesEnabled()) - eval(test); - if (typeof reportCompare === 'function') reportCompare(0,0,"OK"); diff --git a/js/src/tests/ecma_6/Class/superPropOrdering.js b/js/src/tests/ecma_6/Class/superPropOrdering.js index 6898190202..1374d52c1c 100644 --- a/js/src/tests/ecma_6/Class/superPropOrdering.js +++ b/js/src/tests/ecma_6/Class/superPropOrdering.js @@ -1,5 +1,3 @@ -var test = ` - class base { constructor() { } method() { this.methodCalled++; } @@ -91,10 +89,5 @@ instance.testAssignProp(); instance.testCompoundAssignProp(); -`; - -if (classesEnabled()) - eval(test); - if (typeof reportCompare === 'function') reportCompare(0,0,"OK"); diff --git a/js/src/tests/ecma_6/Class/superPropProtoChanges.js b/js/src/tests/ecma_6/Class/superPropProtoChanges.js index bca849ee11..d16ca16659 100644 --- a/js/src/tests/ecma_6/Class/superPropProtoChanges.js +++ b/js/src/tests/ecma_6/Class/superPropProtoChanges.js @@ -1,5 +1,3 @@ -var test = ` - class base { constructor() { } test() { @@ -20,10 +18,5 @@ class derived extends base { new derived().test(); -`; - -if (classesEnabled()) - eval(test); - if (typeof reportCompare === 'function') reportCompare(0,0,"OK"); diff --git a/js/src/tests/ecma_6/Class/superPropProxies.js b/js/src/tests/ecma_6/Class/superPropProxies.js index 926205600d..3ec43b279c 100644 --- a/js/src/tests/ecma_6/Class/superPropProxies.js +++ b/js/src/tests/ecma_6/Class/superPropProxies.js @@ -1,5 +1,3 @@ -var test = ` - class base { constructor() { } } @@ -81,10 +79,5 @@ var unwrappedDerived = { __secretProp__: 42, method() { return super.method(); } Object.setPrototypeOf(unwrappedDerived, wrappedBase); assertEq(unwrappedDerived.method(), 42); -`; - -if (classesEnabled()) - eval(test); - if (typeof reportCompare === 'function') reportCompare(0,0,"OK"); diff --git a/js/src/tests/ecma_6/Class/superPropSkips.js b/js/src/tests/ecma_6/Class/superPropSkips.js index 408e53b0b4..c9587c72f1 100644 --- a/js/src/tests/ecma_6/Class/superPropSkips.js +++ b/js/src/tests/ecma_6/Class/superPropSkips.js @@ -1,5 +1,3 @@ -var test = ` - // Ensure that super lookups and sets skip over properties on the |this| object. // That is, super lookups start with the superclass, not the current class. @@ -43,10 +41,5 @@ instance.testSkipGet(); instance.testSkipDerivedOverrides(); instance.testSkipSet(); -`; - -if (classesEnabled()) - eval(test); - if (typeof reportCompare === 'function') reportCompare(0,0,"OK"); diff --git a/js/src/tests/ecma_6/Class/superPropStatics.js b/js/src/tests/ecma_6/Class/superPropStatics.js index 1b44720d53..32624b5d28 100644 --- a/js/src/tests/ecma_6/Class/superPropStatics.js +++ b/js/src/tests/ecma_6/Class/superPropStatics.js @@ -1,5 +1,3 @@ -var test = ` - class base { constructor() { } static found() { @@ -21,7 +19,7 @@ class derived extends base { static test() { assertEq(super["notFound"], undefined); super.found(); - + // foundCalled is set on |derived| specifically. let calledDesc = Object.getOwnPropertyDescriptor(derived, "foundCalled"); assertEq(calledDesc.value, true); @@ -32,10 +30,5 @@ class derived extends base { derived.test(); -`; - -if (classesEnabled()) - eval(test); - if (typeof reportCompare === 'function') reportCompare(0,0,"OK"); diff --git a/js/src/tests/ecma_6/Class/superPropStrictAssign.js b/js/src/tests/ecma_6/Class/superPropStrictAssign.js index 62bc5002af..4b5444a3cf 100644 --- a/js/src/tests/ecma_6/Class/superPropStrictAssign.js +++ b/js/src/tests/ecma_6/Class/superPropStrictAssign.js @@ -2,13 +2,11 @@ // where there is no guarantee of strict mode. Check that we do not somehow // get strict mode semantics when they were not called for -var test = ` - // |undefined|, writable: false Object.defineProperty(Object.prototype, "prop", { writable: false }); class strictAssignmentTest { - constructor() { + constructor() { // Strict mode. Throws. super.prop = 14; } @@ -21,10 +19,5 @@ assertThrowsInstanceOf(()=>new strictAssignmentTest(), TypeError); assertEq(Object.prototype.prop, undefined); -`; - -if (classesEnabled()) - eval(test); - if (typeof reportCompare === 'function') reportCompare(0,0,"OK"); diff --git a/js/src/tests/ecma_6/Expressions/ToPropertyKey-symbols.js b/js/src/tests/ecma_6/Expressions/ToPropertyKey-symbols.js index c89edede2d..32b3994b3c 100644 --- a/js/src/tests/ecma_6/Expressions/ToPropertyKey-symbols.js +++ b/js/src/tests/ecma_6/Expressions/ToPropertyKey-symbols.js @@ -39,38 +39,34 @@ for (var sym of symbols) { assertEq(Math.PI[key], "success"); delete Number.prototype[sym]; - if (classesEnabled()) { - eval(` - // Getting a super property. - class X { - [sym]() { return "X"; } - } - class Y extends X { - [sym]() { return super[key]() + "Y"; } - } - var y = new Y(); - assertEq(y[sym](), "XY"); - - // Setting a super property. - class Z { - set [sym](v) { - this.self = this; - this.value = v; - } - } - class W extends Z { - set [sym](v) { - this.isW = true; - super[key] = v; - } - } - var w = new W(); - w[key] = "ok"; - assertEq(w.self, w); - assertEq(w.value, "ok"); - assertEq(w.isW, true); - `); + // Getting a super property. + class X { + [sym]() { return "X"; } } + class Y extends X { + [sym]() { return super[key]() + "Y"; } + } + var y = new Y(); + assertEq(y[sym](), "XY"); + + // Setting a super property. + class Z { + set [sym](v) { + this.self = this; + this.value = v; + } + } + class W extends Z { + set [sym](v) { + this.isW = true; + super[key] = v; + } + } + var w = new W(); + w[key] = "ok"; + assertEq(w.self, w); + assertEq(w.value, "ok"); + assertEq(w.isW, true); // Deleting properties. obj = {[sym]: 1}; diff --git a/js/src/tests/ecma_6/Reflect/apply.js b/js/src/tests/ecma_6/Reflect/apply.js index d3702e6cc3..fbd9db2a4b 100644 --- a/js/src/tests/ecma_6/Reflect/apply.js +++ b/js/src/tests/ecma_6/Reflect/apply.js @@ -5,8 +5,7 @@ assertEq(Reflect.apply(Math.floor, undefined, [1.75]), 1); // Reflect.apply requires a target object that's callable. -class clsX { constructor() {} } // classes are not callable -var nonCallable = [{}, [], clsX]; +var nonCallable = [{}, [], (class clsX { constructor() {} })]; for (var value of nonCallable) { assertThrowsInstanceOf(() => Reflect.apply(nonCallable), TypeError); } diff --git a/js/src/tests/ecma_6/Syntax/keyword-unescaped-requirement.js b/js/src/tests/ecma_6/Syntax/keyword-unescaped-requirement.js index 84a569e9d2..eb6edd57db 100644 --- a/js/src/tests/ecma_6/Syntax/keyword-unescaped-requirement.js +++ b/js/src/tests/ecma_6/Syntax/keyword-unescaped-requirement.js @@ -15,28 +15,23 @@ print(BUGNUMBER + ": " + summary); * BEGIN TEST * **************/ -function classSyntax(code) -{ - return classesEnabled() ? "(class { constructor() {} " + code + " });" : "@"; -} - function memberVariants(code) { - return [classesEnabled() ? "(class { constructor() {} " + code + " });" : "@", + return ["(class { constructor() {} " + code + " });", "({ " + code + " })"]; } var badScripts = [ - classSyntax("st\\u0061tic m() { return 0; }"), - classSyntax("st\\u0061tic get foo() { return 0; }"), - classSyntax("st\\u0061tic set foo(v) {}"), - classSyntax("st\\u0061tic get ['hi']() { return 0; }"), - classSyntax("st\\u0061tic set ['hi'](v) {}"), - classSyntax("st\\u0061tic get 'hi'() { return 0; }"), - classSyntax("st\\u0061tic set 'hi'(v) {}"), - classSyntax("st\\u0061tic get 42() { return 0; }"), - classSyntax("st\\u0061tic set 42(v) {}"), + "class { st\\u0061tic m() { return 0; } }", + "class { st\\u0061tic get foo() { return 0; } }", + "class { st\\u0061tic set foo(v) {} }", + "class { st\\u0061tic get ['hi']() { return 0; } }", + "class { st\\u0061tic set ['hi'](v) {} }", + "class { st\\u0061tic get 'hi'() { return 0; } }", + "class { st\\u0061tic set 'hi'(v) {} }", + "class { st\\u0061tic get 42() { return 0; } }", + "class { st\\u0061tic set 42(v) {} }", ...memberVariants("\\u0067et foo() { return 0; }"), ...memberVariants("\\u0073et foo() {}"), ...memberVariants("g\\u0065t foo() { return 0; }"), diff --git a/js/src/tests/js1_8_5/extensions/sharedtypedarray.js b/js/src/tests/js1_8_5/extensions/sharedtypedarray.js index ce56dbc387..bbff9caa9a 100644 --- a/js/src/tests/js1_8_5/extensions/sharedtypedarray.js +++ b/js/src/tests/js1_8_5/extensions/sharedtypedarray.js @@ -30,10 +30,10 @@ function testSharedArrayBuffer() { SharedArrayBuffer.prototype.abracadabra = "no wishing for wishes!"; assertEq(b.abracadabra, "no wishing for wishes!"); - // can "convert" a buffer (really works as an assertion) - assertEq(SharedArrayBuffer(b), b); + // SharedArrayBuffer is not a conversion operator, not even for instances of itself + assertThrowsInstanceOf(() => SharedArrayBuffer(b), TypeError); - // can't convert any other object + // can't convert any other object either assertThrowsInstanceOf(() => SharedArrayBuffer({}), TypeError); // byteLength can be invoked as per normal, indirectly diff --git a/js/src/tests/js1_8_5/reflect-parse/classes.js b/js/src/tests/js1_8_5/reflect-parse/classes.js index 5fc2bc4fdf..10bedf43d7 100644 --- a/js/src/tests/js1_8_5/reflect-parse/classes.js +++ b/js/src/tests/js1_8_5/reflect-parse/classes.js @@ -1,15 +1,5 @@ // |reftest| skip-if(!xulRuntime.shell) // Classes -function classesEnabled() { - try { - Reflect.parse("class foo { constructor() { } }"); - return true; - } catch (e) { - assertEq(e instanceof SyntaxError, true); - return false; - } -} - function testClasses() { function methodFun(id, kind, generator, args, body = []) { assertEq(generator && kind === "method", generator); @@ -509,7 +499,4 @@ function testClasses() { } -if (classesEnabled()) - runtest(testClasses); -else if (typeof reportCompare === 'function') - reportCompare(true, true); +runtest(testClasses); diff --git a/js/src/vm/Initialization.cpp b/js/src/vm/Initialization.cpp index cf5d21aa23..6001808180 100644 --- a/js/src/vm/Initialization.cpp +++ b/js/src/vm/Initialization.cpp @@ -15,6 +15,7 @@ #include "jstypes.h" #include "builtin/AtomicsObject.h" +#include "gc/Statistics.h" #include "jit/ExecutableAllocator.h" #include "jit/Ion.h" #include "js/Utility.h" @@ -103,6 +104,8 @@ JS_Init(void) if (!FutexRuntime::initialize()) return false; + js::gcstats::Statistics::initialize(); + libraryInitState = InitState::Running; return true; } diff --git a/js/src/vm/JSONParser.cpp b/js/src/vm/JSONParser.cpp index 4ac4d25455..2bc07fadb9 100644 --- a/js/src/vm/JSONParser.cpp +++ b/js/src/vm/JSONParser.cpp @@ -90,9 +90,9 @@ JSONParser::error(const char* msg) const size_t MaxWidth = sizeof("4294967295"); char columnNumber[MaxWidth]; - JS_snprintf(columnNumber, sizeof columnNumber, "%lu", column); + JS_snprintf(columnNumber, sizeof columnNumber, "%" PRIu32, column); char lineNumber[MaxWidth]; - JS_snprintf(lineNumber, sizeof lineNumber, "%lu", line); + JS_snprintf(lineNumber, sizeof lineNumber, "%" PRIu32, line); JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_JSON_BAD_PARSE, msg, lineNumber, columnNumber); diff --git a/js/src/vm/Opcodes.h b/js/src/vm/Opcodes.h index 12e2944b19..fa6989bbd1 100644 --- a/js/src/vm/Opcodes.h +++ b/js/src/vm/Opcodes.h @@ -1809,6 +1809,14 @@ * Stack: => val */ \ macro(JSOP_GETIMPORT, 176,"getimport", NULL, 5, 0, 1, JOF_ATOM|JOF_NAME|JOF_TYPESET) \ + /* + * Examines the top stack value, asserting that it's either a self-hosted + * function or a self-hosted intrinsic. This opcode does nothing in a + * non-debug build. + * Category: Other + * Operands: + * Stack: checkVal => checkVal + */ \ macro(JSOP_DEBUGCHECKSELFHOSTED, 177,"debug-checkselfhosted", NULL, 1, 1, 1, JOF_BYTE) \ macro(JSOP_UNUSED178, 178,"unused178", NULL, 1, 0, 0, JOF_BYTE) \ macro(JSOP_UNUSED179, 179,"unused179", NULL, 1, 0, 0, JOF_BYTE) \ diff --git a/js/src/vm/RegExpStatics.h b/js/src/vm/RegExpStatics.h index 3182940002..0823640977 100644 --- a/js/src/vm/RegExpStatics.h +++ b/js/src/vm/RegExpStatics.h @@ -63,8 +63,6 @@ class RegExpStatics struct InitBuffer {}; explicit RegExpStatics(InitBuffer) {} - friend class AutoRegExpStaticsBuffer; - public: /* Mutators. */ inline void updateLazily(JSContext* cx, JSLinearString* input, @@ -160,38 +158,6 @@ class RegExpStatics } }; -class MOZ_RAII AutoRegExpStaticsBuffer : private JS::CustomAutoRooter -{ - public: - explicit AutoRegExpStaticsBuffer(JSContext* cx - MOZ_GUARD_OBJECT_NOTIFIER_PARAM) - : CustomAutoRooter(cx), statics(RegExpStatics::InitBuffer()) - { - MOZ_GUARD_OBJECT_NOTIFIER_INIT; - } - - RegExpStatics& getStatics() { return statics; } - - private: - virtual void trace(JSTracer* trc) { - if (statics.matchesInput) { - TraceRoot(trc, reinterpret_cast(&statics.matchesInput), - "AutoRegExpStaticsBuffer matchesInput"); - } - if (statics.lazySource) { - TraceRoot(trc, reinterpret_cast(&statics.lazySource), - "AutoRegExpStaticsBuffer lazySource"); - } - if (statics.pendingInput) { - TraceRoot(trc, reinterpret_cast(&statics.pendingInput), - "AutoRegExpStaticsBuffer pendingInput"); - } - } - - RegExpStatics statics; - MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER -}; - inline bool RegExpStatics::createDependent(JSContext* cx, size_t start, size_t end, MutableHandleValue out) { diff --git a/js/src/vm/SavedStacks.cpp b/js/src/vm/SavedStacks.cpp index f5e8d4f27e..46c50db486 100644 --- a/js/src/vm/SavedStacks.cpp +++ b/js/src/vm/SavedStacks.cpp @@ -987,10 +987,6 @@ SavedFrame::toStringMethod(JSContext* cx, unsigned argc, Value* vp) bool SavedStacks::init() { - mozilla::Array seed; - GenerateXorShift128PlusSeed(seed); - bernoulli.setRandomState(seed[0], seed[1]); - if (!pcLocationMap.init()) return false; @@ -1122,7 +1118,7 @@ SavedStacks::insertFrames(JSContext* cx, FrameIter& iter, MutableHandleSavedFram } } - AutoLocationValueRooter location(cx); + Rooted location(cx); { AutoCompartment ac(cx, iter.compartment()); if (!cx->compartment()->savedStacks().getLocation(cx, iter, &location)) @@ -1135,9 +1131,9 @@ SavedStacks::insertFrames(JSContext* cx, FrameIter& iter, MutableHandleSavedFram parentIsInCache = iter.hasCachedSavedFrame(); auto displayAtom = iter.isNonEvalFunctionFrame() ? iter.functionDisplayAtom() : nullptr; - if (!stackChain->emplaceBack(location->source, - location->line, - location->column, + if (!stackChain->emplaceBack(location.source(), + location.line(), + location.column(), displayAtom, nullptr, nullptr, @@ -1325,7 +1321,8 @@ SavedStacks::sweepPCLocationMap() } bool -SavedStacks::getLocation(JSContext* cx, const FrameIter& iter, MutableHandleLocationValue locationp) +SavedStacks::getLocation(JSContext* cx, const FrameIter& iter, + MutableHandle locationp) { // We should only ever be caching location values for scripts in this // compartment. Otherwise, we would get dead cross-compartment scripts in @@ -1340,19 +1337,20 @@ SavedStacks::getLocation(JSContext* cx, const FrameIter& iter, MutableHandleLoca if (!iter.hasScript()) { if (const char16_t* displayURL = iter.scriptDisplayURL()) { - locationp->source = AtomizeChars(cx, displayURL, js_strlen(displayURL)); + locationp.setSource(AtomizeChars(cx, displayURL, js_strlen(displayURL))); } else { const char* filename = iter.scriptFilename() ? iter.scriptFilename() : ""; - locationp->source = Atomize(cx, filename, strlen(filename)); + locationp.setSource(Atomize(cx, filename, strlen(filename))); } - if (!locationp->source) + if (!locationp.source()) return false; - locationp->line = iter.computeLine(&locationp->column); + uint32_t column = 0; + locationp.setLine(iter.computeLine(&column)); // XXX: Make the column 1-based as in other browsers, instead of 0-based // which is how SpiderMonkey stores it internally. This will be // unnecessary once bug 1144340 is fixed. - locationp->column++; + locationp.setColumn(column + 1); return true; } @@ -1416,6 +1414,13 @@ SavedStacks::chooseSamplingProbability(JSCompartment* compartment) } MOZ_ASSERT(foundAnyDebuggers); + if (!bernoulliSeeded) { + mozilla::Array seed; + GenerateXorShift128PlusSeed(seed); + bernoulli.setRandomState(seed[0], seed[1]); + bernoulliSeeded = true; + } + bernoulli.setProbability(probability); } diff --git a/js/src/vm/SavedStacks.h b/js/src/vm/SavedStacks.h index 9d343aa360..3e26b3fc58 100644 --- a/js/src/vm/SavedStacks.h +++ b/js/src/vm/SavedStacks.h @@ -157,6 +157,7 @@ class SavedStacks { public: SavedStacks() : frames(), + bernoulliSeeded(false), bernoulli(1.0, 0x59fdad7f6b4cc573, 0x91adf38db96a9354), creatingSavedFrame(false) { } @@ -181,6 +182,7 @@ class SavedStacks { private: SavedFrame::Set frames; + bool bernoulliSeeded; mozilla::FastBernoulliTrial bernoulli; bool creatingSavedFrame; @@ -222,7 +224,8 @@ class SavedStacks { jsbytecode* pc; }; - struct LocationValue { + public: + struct LocationValue : public JS::Traceable { LocationValue() : source(nullptr), line(0), column(0) { } LocationValue(JSAtom* source, size_t line, uint32_t column) : source(source), @@ -230,6 +233,7 @@ class SavedStacks { column(column) { } + static void trace(LocationValue* self, JSTracer* trc) { self->trace(trc); } void trace(JSTracer* trc) { if (source) TraceEdge(trc, &source, "SavedStacks::LocationValue::source"); @@ -240,38 +244,25 @@ class SavedStacks { uint32_t column; }; - class MOZ_STACK_CLASS AutoLocationValueRooter : public JS::CustomAutoRooter - { - public: - explicit AutoLocationValueRooter(JSContext* cx) - : JS::CustomAutoRooter(cx), - value() {} - - inline LocationValue* operator->() { return &value; } - void set(LocationValue& loc) { value = loc; } - LocationValue& get() { return value; } - + template + struct LocationValueOperations { + JSAtom* source() const { return loc().source; } + size_t line() const { return loc().line; } + uint32_t column() const { return loc().column; } private: - virtual void trace(JSTracer* trc) { - value.trace(trc); - } - - SavedStacks::LocationValue value; + const LocationValue& loc() const { return static_cast(this)->get(); } }; - class MOZ_STACK_CLASS MutableHandleLocationValue - { - public: - inline MOZ_IMPLICIT MutableHandleLocationValue(AutoLocationValueRooter* location) - : location(location) {} - - inline LocationValue* operator->() { return &location->get(); } - void set(LocationValue& loc) { location->set(loc); } - + template + struct MutableLocationValueOperations : public LocationValueOperations { + void setSource(JSAtom* v) { loc().source = v; } + void setLine(size_t v) { loc().line = v; } + void setColumn(uint32_t v) { loc().column = v; } private: - AutoLocationValueRooter* location; + LocationValue& loc() { return static_cast(this)->get(); } }; + private: struct PCLocationHasher : public DefaultHasher { typedef PointerHasher ScriptPtrHasher; typedef PointerHasher BytecodePtrHasher; @@ -291,11 +282,21 @@ class SavedStacks { PCLocationMap pcLocationMap; void sweepPCLocationMap(); - bool getLocation(JSContext* cx, const FrameIter& iter, MutableHandleLocationValue locationp); + bool getLocation(JSContext* cx, const FrameIter& iter, MutableHandle locationp); }; JSObject* SavedStacksMetadataCallback(JSContext* cx, JSObject* target); +template <> +class RootedBase + : public SavedStacks::MutableLocationValueOperations> +{}; + +template <> +class MutableHandleBase + : public SavedStacks::MutableLocationValueOperations> +{}; + } /* namespace js */ #endif /* vm_SavedStacks_h */ diff --git a/js/src/vm/SelfHosting.cpp b/js/src/vm/SelfHosting.cpp index 917699ac8b..c0c2b9de96 100644 --- a/js/src/vm/SelfHosting.cpp +++ b/js/src/vm/SelfHosting.cpp @@ -1453,13 +1453,13 @@ intrinsic_ModuleNamespaceExports(JSContext* cx, unsigned argc, Value* vp) // Additionally, a set of C++-implemented helper functions is defined on the // self-hosting global. static const JSFunctionSpec intrinsic_functions[] = { - JS_FN("std_Array", ArrayConstructor, 1,0), + JS_INLINABLE_FN("std_Array", ArrayConstructor, 1,0, Array), JS_FN("std_Array_join", array_join, 1,0), - JS_FN("std_Array_push", array_push, 1,0), - JS_FN("std_Array_pop", array_pop, 0,0), - JS_FN("std_Array_shift", array_shift, 0,0), + JS_INLINABLE_FN("std_Array_push", array_push, 1,0, ArrayPush), + JS_INLINABLE_FN("std_Array_pop", array_pop, 0,0, ArrayPop), + JS_INLINABLE_FN("std_Array_shift", array_shift, 0,0, ArrayShift), JS_FN("std_Array_unshift", array_unshift, 1,0), - JS_FN("std_Array_slice", array_slice, 2,0), + JS_INLINABLE_FN("std_Array_slice", array_slice, 2,0, ArraySlice), JS_FN("std_Array_sort", array_sort, 1,0), JS_FN("std_Date_now", date_now, 0,0), @@ -1468,19 +1468,19 @@ static const JSFunctionSpec intrinsic_functions[] = { JS_FN("std_Function_bind", fun_bind, 1,0), JS_FN("std_Function_apply", fun_apply, 2,0), - JS_FN("std_Math_floor", math_floor, 1,0), - JS_FN("std_Math_max", math_max, 2,0), - JS_FN("std_Math_min", math_min, 2,0), - JS_FN("std_Math_abs", math_abs, 1,0), - JS_FN("std_Math_imul", math_imul, 2,0), - JS_FN("std_Math_log2", math_log2, 1,0), + JS_INLINABLE_FN("std_Math_floor", math_floor, 1,0, MathFloor), + JS_INLINABLE_FN("std_Math_max", math_max, 2,0, MathMax), + JS_INLINABLE_FN("std_Math_min", math_min, 2,0, MathMin), + JS_INLINABLE_FN("std_Math_abs", math_abs, 1,0, MathAbs), + JS_INLINABLE_FN("std_Math_imul", math_imul, 2,0, MathImul), + JS_INLINABLE_FN("std_Math_log2", math_log2, 1,0, MathLog2), JS_FN("std_Map_has", MapObject::has, 1,0), JS_FN("std_Map_iterator", MapObject::entries, 0,0), JS_FN("std_Number_valueOf", num_valueOf, 0,0), - JS_FN("std_Object_create", obj_create, 2,0), + JS_INLINABLE_FN("std_Object_create", obj_create, 2, 0, ObjectCreate), JS_FN("std_Object_propertyIsEnumerable", obj_propertyIsEnumerable, 1,0), JS_FN("std_Object_defineProperty", obj_defineProperty, 3,0), JS_FN("std_Object_getOwnPropertyNames", obj_getOwnPropertyNames, 1,0), @@ -1494,13 +1494,13 @@ static const JSFunctionSpec intrinsic_functions[] = { JS_FN("std_Set_has", SetObject::has, 1,0), JS_FN("std_Set_iterator", SetObject::values, 0,0), - JS_FN("std_String_fromCharCode", str_fromCharCode, 1,0), - JS_FN("std_String_charCodeAt", str_charCodeAt, 1,0), + JS_INLINABLE_FN("std_String_fromCharCode", str_fromCharCode, 1,0, StringFromCharCode), + JS_INLINABLE_FN("std_String_charCodeAt", str_charCodeAt, 1,0, StringCharCodeAt), JS_FN("std_String_indexOf", str_indexOf, 1,0), JS_FN("std_String_lastIndexOf", str_lastIndexOf, 1,0), JS_FN("std_String_match", str_match, 1,0), - JS_FN("std_String_replace", str_replace, 2,0), - JS_FN("std_String_split", str_split, 2,0), + JS_INLINABLE_FN("std_String_replace", str_replace, 2,0, StringReplace), + JS_INLINABLE_FN("std_String_split", str_split, 2,0, StringSplit), JS_FN("std_String_startsWith", str_startsWith, 1,0), JS_FN("std_String_toLowerCase", str_toLowerCase, 0,0), JS_FN("std_String_toUpperCase", str_toUpperCase, 0,0), @@ -1511,8 +1511,8 @@ static const JSFunctionSpec intrinsic_functions[] = { JS_FN("std_WeakMap_delete", WeakMap_delete, 1,0), JS_FN("std_WeakMap_clear", WeakMap_clear, 0,0), - JS_FN("std_SIMD_Int32x4_extractLane", simd_int32x4_extractLane, 2,0), - JS_FN("std_SIMD_Float32x4_extractLane", simd_float32x4_extractLane, 2,0), + JS_INLINABLE_FN("std_SIMD_Int32x4_extractLane", simd_int32x4_extractLane, 2,0, SimdInt32x4), + JS_INLINABLE_FN("std_SIMD_Float32x4_extractLane", simd_float32x4_extractLane,2,0, SimdFloat32x4), JS_FN("std_SIMD_Float64x2_extractLane", simd_float64x2_extractLane, 2,0), // Helper funtions after this point. diff --git a/js/src/vm/SharedArrayObject.cpp b/js/src/vm/SharedArrayObject.cpp index 21e446efa2..6c30a8ed8d 100644 --- a/js/src/vm/SharedArrayObject.cpp +++ b/js/src/vm/SharedArrayObject.cpp @@ -228,19 +228,8 @@ SharedArrayBufferObject::class_constructor(JSContext* cx, unsigned argc, Value* { CallArgs args = CallArgsFromVp(argc, vp); - if (!args.isConstructing()) { - if (args.hasDefined(0)) { - ESClassValue cls; - if (!GetClassOfValue(cx, args[0], &cls)) - return false; - if (cls == ESClass_SharedArrayBuffer) { - args.rval().set(args[0]); - return true; - } - } - JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_SHARED_ARRAY_BAD_OBJECT); + if (!ThrowIfNotConstructing(cx, args, "SharedArrayBuffer")) return false; - } // Bugs 1068458, 1161298: Limit length to 2^31-1. uint32_t length; @@ -250,7 +239,12 @@ SharedArrayBufferObject::class_constructor(JSContext* cx, unsigned argc, Value* return false; } - JSObject* bufobj = New(cx, length); + RootedObject proto(cx); + RootedObject newTarget(cx, &args.newTarget().toObject()); + if (!GetPrototypeFromConstructor(cx, newTarget, &proto)) + return false; + + JSObject* bufobj = New(cx, length, proto); if (!bufobj) return false; args.rval().setObject(*bufobj); @@ -258,20 +252,21 @@ SharedArrayBufferObject::class_constructor(JSContext* cx, unsigned argc, Value* } SharedArrayBufferObject* -SharedArrayBufferObject::New(JSContext* cx, uint32_t length) +SharedArrayBufferObject::New(JSContext* cx, uint32_t length, HandleObject proto) { SharedArrayRawBuffer* buffer = SharedArrayRawBuffer::New(cx, length); if (!buffer) return nullptr; - return New(cx, buffer); + return New(cx, buffer, proto); } SharedArrayBufferObject* -SharedArrayBufferObject::New(JSContext* cx, SharedArrayRawBuffer* buffer) +SharedArrayBufferObject::New(JSContext* cx, SharedArrayRawBuffer* buffer, HandleObject proto) { AutoSetNewObjectMetadata metadata(cx); - Rooted obj(cx, NewBuiltinClassInstance(cx)); + Rooted obj(cx, + NewObjectWithClassProto(cx, proto)); if (!obj) return nullptr; @@ -434,7 +429,7 @@ JS_FRIEND_API(JSObject*) JS_NewSharedArrayBuffer(JSContext* cx, uint32_t nbytes) { MOZ_ASSERT(nbytes <= INT32_MAX); - return SharedArrayBufferObject::New(cx, nbytes); + return SharedArrayBufferObject::New(cx, nbytes, /* proto = */ nullptr); } JS_FRIEND_API(bool) diff --git a/js/src/vm/SharedArrayObject.h b/js/src/vm/SharedArrayObject.h index 5bfc1ef3cc..d3fa3fbaa2 100644 --- a/js/src/vm/SharedArrayObject.h +++ b/js/src/vm/SharedArrayObject.h @@ -130,10 +130,14 @@ class SharedArrayBufferObject : public ArrayBufferObjectMaybeShared static bool class_constructor(JSContext* cx, unsigned argc, Value* vp); // Create a SharedArrayBufferObject with a new SharedArrayRawBuffer. - static SharedArrayBufferObject* New(JSContext* cx, uint32_t length); + static SharedArrayBufferObject* New(JSContext* cx, + uint32_t length, + HandleObject proto = nullptr); // Create a SharedArrayBufferObject using an existing SharedArrayRawBuffer. - static SharedArrayBufferObject* New(JSContext* cx, SharedArrayRawBuffer* buffer); + static SharedArrayBufferObject* New(JSContext* cx, + SharedArrayRawBuffer* buffer, + HandleObject proto = nullptr); static void Finalize(FreeOp* fop, JSObject* obj); diff --git a/js/src/vm/TypedArrayCommon.h b/js/src/vm/TypedArrayCommon.h index 393e0d64f7..3cc826c011 100644 --- a/js/src/vm/TypedArrayCommon.h +++ b/js/src/vm/TypedArrayCommon.h @@ -349,7 +349,7 @@ class ElementSpecific MOZ_ASSERT(SpecificArray::ArrayTypeID() == target->type(), "calling wrong setFromTypedArray specialization"); MOZ_ASSERT(SomeTypedArray::sameBuffer(target, source), - "provided arrays don't actually overlap, so it's " + "the provided arrays don't actually overlap, so it's " "undesirable to use this method"); MOZ_ASSERT(offset <= target->length()); diff --git a/js/src/vm/TypedArrayObject.cpp b/js/src/vm/TypedArrayObject.cpp index 8a411a76c7..4c294cedf0 100644 --- a/js/src/vm/TypedArrayObject.cpp +++ b/js/src/vm/TypedArrayObject.cpp @@ -370,8 +370,18 @@ class TypedArrayObjectTemplate : public TypedArrayObject // may be in the nursery, so include a barrier to make sure this // object is updated if that typed object moves. if (!IsInsideNursery(obj) && cx->runtime()->gc.nursery.isInside(buffer->dataPointerEither())) { - MOZ_ASSERT(!isSharedMemory); - cx->runtime()->gc.storeBuffer.putWholeCell(obj); + // Shared buffer data should never be nursery-allocated, so + // we need to fail here if isSharedMemory. However, mmap() + // can place a SharedArrayRawBuffer up against the bottom end + // of the nursery, and a zero-length buffer will erroneously be + // perceived as being inside the nursery; sidestep that. + if (isSharedMemory) { + MOZ_ASSERT(buffer->byteLength() == 0 && + cx->runtime()->gc.nursery.start() == + buffer->dataPointerEither().unwrapValue()); + } else { + cx->runtime()->gc.storeBuffer.putWholeCell(obj); + } } } else { void* data = obj->fixedData(FIXED_DATA_START); diff --git a/js/src/vm/TypedArrayObject.h b/js/src/vm/TypedArrayObject.h index 018060140b..354368956f 100644 --- a/js/src/vm/TypedArrayObject.h +++ b/js/src/vm/TypedArrayObject.h @@ -69,6 +69,16 @@ class TypedArrayObject : public NativeObject template struct OfType; static bool sameBuffer(Handle a, Handle b) { + // Inline buffers. + if (!a->hasBuffer() || !b->hasBuffer()) + return a.get() == b.get(); + + // Shared buffers. + if (a->isSharedMemory() && b->isSharedMemory()) { + return (a->bufferObject()->as().globalID() == + b->bufferObject()->as().globalID()); + } + return a->bufferObject() == b->bufferObject(); } diff --git a/js/src/vm/UbiNode.cpp b/js/src/vm/UbiNode.cpp index 590c64989a..a96dcd2a0f 100644 --- a/js/src/vm/UbiNode.cpp +++ b/js/src/vm/UbiNode.cpp @@ -497,7 +497,7 @@ RootList::addRoot(Node node, const char16_t* edgeName) return edges.append(mozilla::Move(Edge(name.release(), node))); } -const char16_t Concrete::concreteTypeName[] = MOZ_UTF16("RootList"); +const char16_t Concrete::concreteTypeName[] = MOZ_UTF16("JS::ubi::RootList"); UniquePtr Concrete::edges(JSRuntime* rt, bool wantNames) const { diff --git a/js/src/vm/UnboxedObject.cpp b/js/src/vm/UnboxedObject.cpp index 1961ec82af..7e41a8c6c3 100644 --- a/js/src/vm/UnboxedObject.cpp +++ b/js/src/vm/UnboxedObject.cpp @@ -105,6 +105,11 @@ UnboxedLayout::makeConstructorCode(JSContext* cx, HandleObjectGroup group) newKindReg = IntArgReg1; #endif +#ifdef JS_CODEGEN_ARM64 + // ARM64 communicates stack address via sp, but uses a pseudo-sp for addressing. + masm.initStackPtr(); +#endif + MOZ_ASSERT(propertiesReg.volatile_()); MOZ_ASSERT(newKindReg.volatile_()); @@ -793,10 +798,7 @@ UnboxedPlainObject::obj_getProperty(JSContext* cx, HandleObject obj, HandleValue if (UnboxedExpandoObject* expando = obj->as().maybeExpando()) { if (expando->containsShapeOrElement(cx, id)) { RootedObject nexpando(cx, expando); - RootedValue nreceiver(cx, receiver); - if (receiver.isObject() && &receiver.toObject() == obj) - nreceiver.setObject(*expando); - return GetProperty(cx, nexpando, nreceiver, id, vp); + return GetProperty(cx, nexpando, receiver, id, vp); } } @@ -834,10 +836,7 @@ UnboxedPlainObject::obj_setProperty(JSContext* cx, HandleObject obj, HandleId id AddTypePropertyId(cx, obj, id, v); RootedObject nexpando(cx, expando); - RootedValue nreceiver(cx, (receiver.isObject() && obj == &receiver.toObject()) - ? ObjectValue(*expando) - : receiver); - return SetProperty(cx, nexpando, id, v, nreceiver, result); + return SetProperty(cx, nexpando, id, v, receiver, result); } } diff --git a/js/src/vm/Xdr.h b/js/src/vm/Xdr.h index eb70d76d31..e11cdf563c 100644 --- a/js/src/vm/Xdr.h +++ b/js/src/vm/Xdr.h @@ -29,11 +29,11 @@ namespace js { * * https://developer.mozilla.org/en-US/docs/SpiderMonkey/Internals/Bytecode */ -static const uint32_t XDR_BYTECODE_VERSION_SUBTRAHEND = 324; +static const uint32_t XDR_BYTECODE_VERSION_SUBTRAHEND = 325; static const uint32_t XDR_BYTECODE_VERSION = uint32_t(0xb973c0de - XDR_BYTECODE_VERSION_SUBTRAHEND); -static_assert(JSErr_Limit == 433, +static_assert(JSErr_Limit == 432, "GREETINGS, POTENTIAL SUBTRAHEND INCREMENTER! If you added or " "removed MSG_DEFs from js.msg, you should increment " "XDR_BYTECODE_VERSION_SUBTRAHEND and update this assertion's " diff --git a/moz.build b/moz.build index f35ff1ce24..7b4d1c2249 100644 --- a/moz.build +++ b/moz.build @@ -23,9 +23,11 @@ DIRS += [ if not CONFIG['JS_STANDALONE']: CONFIGURE_SUBST_FILES += [ - 'mozilla-config.h', 'tools/update-packaging/Makefile', ] + CONFIGURE_DEFINE_FILES += [ + 'mozilla-config.h', + ] DIRS += [ 'build', diff --git a/mozilla-config.h.in b/mozilla-config.h.in index 8d2c857a65..7484180b0d 100644 --- a/mozilla-config.h.in +++ b/mozilla-config.h.in @@ -13,7 +13,8 @@ #endif #endif -@ALLDEFINES@ +// Expands to all the defines from configure. +#undef ALLDEFINES /* * The c99 defining the limit macros (UINT32_MAX for example), says: diff --git a/python/mozbuild/mozbuild/backend/common.py b/python/mozbuild/mozbuild/backend/common.py index 723a2ad106..a6e134c057 100644 --- a/python/mozbuild/mozbuild/backend/common.py +++ b/python/mozbuild/mozbuild/backend/common.py @@ -382,6 +382,9 @@ class CommonBackend(BuildBackend): "#define NAME ORIGINAL_VALUE" is turned into "#define NAME VALUE" "#undef UNKNOWN_NAME" is turned into "/* #undef UNKNOWN_NAME */" Whitespaces are preserved. + + As a special rule, "#undef ALLDEFINES" is turned into "#define NAME + VALUE" for all the defined variables. ''' with self._write_file(obj.output_path) as fh, \ open(obj.input_path, 'rU') as input: @@ -393,7 +396,18 @@ class CommonBackend(BuildBackend): name = m.group('name') value = m.group('value') if name: - if name in obj.config.defines: + if name == 'ALLDEFINES': + if cmd == 'define': + raise Exception( + '`#define ALLDEFINES` is not allowed in a ' + 'CONFIGURE_DEFINE_FILE') + defines = '\n'.join(sorted( + '#define %s %s' % (name, val) + for name, val in obj.config.defines.iteritems() + if name not in obj.config.non_global_defines)) + l = l[:m.start('cmd') - 1] \ + + defines + l[m.end('name'):] + elif name in obj.config.defines: if cmd == 'define' and value: l = l[:m.start('value')] \ + str(obj.config.defines[name]) \ diff --git a/python/mozbuild/mozbuild/backend/configenvironment.py b/python/mozbuild/mozbuild/backend/configenvironment.py index 7c3527f7a1..955f6c4605 100644 --- a/python/mozbuild/mozbuild/backend/configenvironment.py +++ b/python/mozbuild/mozbuild/backend/configenvironment.py @@ -83,24 +83,20 @@ class ConfigEnvironment(object): - defines is a list of (name, value) tuples. In autoconf, these are set with AC_DEFINE and AC_DEFINE_UNQUOTED - non_global_defines are a list of names appearing in defines above - that are not meant to be exported in ACDEFINES and ALLDEFINES (see - below) + that are not meant to be exported in ACDEFINES (see below) - substs is a list of (name, value) tuples. In autoconf, these are set with AC_SUBST. - ConfigEnvironment automatically defines two additional substs variables + ConfigEnvironment automatically defines one additional substs variable from all the defines not appearing in non_global_defines: - ACDEFINES contains the defines in the form -DNAME=VALUE, for use on preprocessor command lines. The order in which defines were given when creating the ConfigEnvironment is preserved. - - ALLDEFINES contains the defines in the form #define NAME VALUE, in - sorted order, for use in config files, for an automatic listing of - defines. and two other additional subst variables from all the other substs: - ALLSUBSTS contains the substs in the form NAME = VALUE, in sorted - order, for use in autoconf.mk. It includes ACDEFINES, but doesn't - include ALLDEFINES. Only substs with a VALUE are included, such that - the resulting file doesn't change when new empty substs are added. + order, for use in autoconf.mk. It includes ACDEFINES + Only substs with a VALUE are included, such that the resulting file + doesn't change when new empty substs are added. This results in less invalidation of build dependencies in the case of autoconf.mk.. - ALLEMPTYSUBSTS contains the substs with an empty value, in the form @@ -119,6 +115,7 @@ class ConfigEnvironment(object): source = mozpath.join(topobjdir, 'config.status') self.source = source self.defines = ReadOnlyDict(defines) + self.non_global_defines = non_global_defines self.substs = dict(substs) self.topsrcdir = mozpath.abspath(topsrcdir) self.topobjdir = mozpath.abspath(topobjdir) @@ -148,8 +145,6 @@ class ConfigEnvironment(object): serialize(self.substs[name])) for name in self.substs if self.substs[name]])) self.substs['ALLEMPTYSUBSTS'] = '\n'.join(sorted(['%s =' % name for name in self.substs if not self.substs[name]])) - self.substs['ALLDEFINES'] = '\n'.join(sorted(['#define %s %s' % (name, - self.defines[name]) for name in global_defines])) self.substs = ReadOnlyDict(self.substs) diff --git a/python/mozbuild/mozbuild/test/backend/test_configenvironment.py b/python/mozbuild/mozbuild/test/backend/test_configenvironment.py index 10d50154e1..9f4c1f1a0a 100644 --- a/python/mozbuild/mozbuild/test/backend/test_configenvironment.py +++ b/python/mozbuild/mozbuild/test/backend/test_configenvironment.py @@ -35,8 +35,8 @@ class ConfigEnvironment(ConfigStatus.ConfigEnvironment): class TestEnvironment(unittest.TestCase): def test_auto_substs(self): - '''Test the automatically set values of ACDEFINES, ALLDEFINES, - ALLSUBSTS and ALLEMPTYSUBSTS. + '''Test the automatically set values of ACDEFINES, ALLSUBSTS + and ALLEMPTYSUBSTS. ''' env = ConfigEnvironment('.', '.', defines = [ ('foo', 'bar'), ('baz', 'qux 42'), @@ -45,16 +45,10 @@ class TestEnvironment(unittest.TestCase): substs = [ ('FOO', 'bar'), ('FOOBAR', ''), ('ABC', 'def'), ('bar', 'baz qux'), ('zzz', '"abc def"'), ('qux', '') ]) - # non_global_defines should be filtered out in ACDEFINES and - # ALLDEFINES. + # non_global_defines should be filtered out in ACDEFINES. # Original order of the defines need to be respected in ACDEFINES self.assertEqual(env.substs['ACDEFINES'], """-Dfoo='bar' -Dbaz='qux 42' -Dabc='d'\\''e'\\''f'""") - # ALLDEFINES, on the other hand, needs to be sorted - self.assertEqual(env.substs['ALLDEFINES'], '''#define abc d'e'f -#define baz qux 42 -#define foo bar''') - # Likewise for ALLSUBSTS, which also mustn't contain ALLDEFINES - # but contain ACDEFINES + # Likewise for ALLSUBSTS, which also must contain ACDEFINES self.assertEqual(env.substs['ALLSUBSTS'], '''ABC = def ACDEFINES = -Dfoo='bar' -Dbaz='qux 42' -Dabc='d'\\''e'\\''f' FOO = bar