import changes from `dev' branch of rmottola/Arctic-Fox:

- Bug 1194923 - Call glFlush before glDeleteFramebuffers on Adreno 420 devices. r=snorp (cc1597d3f1)
- Bug 1150668 - Assume EXT_texture_format_BGRA8888 supported on Android emulator; r=jgilbert (d6e1884d28)
- Bug 1140459 - Skip IsRenderbuffer assertions on Android emulator; r=jgilbert (2163e7c66b)
- Bug 683218 - Disable __noSuchMethod__ support. r=jorendorff (b00cc0c8ae)
- Bug 1206168 - Rename JS_DefaultValue to JS::ToPrimitive. r=jandem. (0815b56474)
- pointer style (d5a0b0f1cc)
- Bug 1133191 - Part 0: Add indentation variant to JS::BuildStackString. r=jandem (2383f33b84)
- Bug 1133191 - Part 1: Display JS stack trace on exception in js shell. r=jandem,jorendorff (5000cb3ec8)
- fix patch order (a84ffb1d33)
This commit is contained in:
2022-08-23 10:46:53 +08:00
parent 7d7e0c2428
commit 5b013d1328
19 changed files with 141 additions and 28 deletions
+3 -3
View File
@@ -2305,14 +2305,14 @@ NPObjectMember_toPrimitive(JSContext *cx, unsigned argc, JS::Value *vp)
if (!memberPrivate)
return false;
JSType type;
if (!JS::GetFirstArgumentAsTypeHint(cx, args, &type))
JSType hint;
if (!JS::GetFirstArgumentAsTypeHint(cx, args, &hint))
return false;
args.rval().set(memberPrivate->fieldValue);
if (args.rval().isObject()) {
JS::Rooted<JSObject*> objVal(cx, &args.rval().toObject());
return JS_DefaultValue(cx, objVal, type, args.rval());
return JS::ToPrimitive(cx, objVal, hint, args.rval());
}
return true;
}
+20 -3
View File
@@ -315,6 +315,7 @@ GLContext::GLContext(const SurfaceCaps& caps,
mMaxTextureImageSize(0),
mMaxRenderbufferSize(0),
mNeedsTextureSizeChecks(false),
mNeedsFlushBeforeDeleteFB(false),
mWorkAroundDriverBugs(true),
mHeavyGLCallsSinceLastFlush(false)
{
@@ -612,6 +613,7 @@ GLContext::InitWithPrefix(const char *prefix, bool trygl)
"Adreno (TM) 200",
"Adreno (TM) 205",
"Adreno (TM) 320",
"Adreno (TM) 420",
"PowerVR SGX 530",
"PowerVR SGX 540",
"NVIDIA Tegra",
@@ -1603,6 +1605,12 @@ GLContext::InitWithPrefix(const char *prefix, bool trygl)
mNeedsTextureSizeChecks = true;
}
#endif
if (mWorkAroundDriverBugs &&
Renderer() == GLRenderer::AdrenoTM420) {
// see bug 1194923. Calling glFlush before glDeleteFramebuffers
// prevents occasional driver crash.
mNeedsFlushBeforeDeleteFB = true;
}
mMaxTextureImageSize = mMaxTextureSize;
@@ -1801,6 +1809,9 @@ GLContext::InitExtensions()
// doesn't expose the OES_rgb8_rgba8 extension, but it seems to
// support it (tautologically, as it only runs on desktop GL).
MarkExtensionSupported(OES_rgb8_rgba8);
// there seems to be a similar issue for EXT_texture_format_BGRA8888
// on the Android 4.3 emulator
MarkExtensionSupported(EXT_texture_format_BGRA8888);
}
if (Vendor() == GLVendor::VMware &&
@@ -2000,7 +2011,8 @@ GLContext::AttachBuffersToFB(GLuint colorTex, GLuint colorRB,
colorTex,
0);
} else if (colorRB) {
MOZ_ASSERT(fIsRenderbuffer(colorRB));
// On the Android 4.3 emulator, IsRenderbuffer may return false incorrectly.
MOZ_ASSERT_IF(Renderer() != GLRenderer::AndroidEmulator, fIsRenderbuffer(colorRB));
fFramebufferRenderbuffer(LOCAL_GL_FRAMEBUFFER,
LOCAL_GL_COLOR_ATTACHMENT0,
LOCAL_GL_RENDERBUFFER,
@@ -2008,7 +2020,7 @@ GLContext::AttachBuffersToFB(GLuint colorTex, GLuint colorRB,
}
if (depthRB) {
MOZ_ASSERT(fIsRenderbuffer(depthRB));
MOZ_ASSERT_IF(Renderer() != GLRenderer::AndroidEmulator, fIsRenderbuffer(depthRB));
fFramebufferRenderbuffer(LOCAL_GL_FRAMEBUFFER,
LOCAL_GL_DEPTH_ATTACHMENT,
LOCAL_GL_RENDERBUFFER,
@@ -2016,7 +2028,7 @@ GLContext::AttachBuffersToFB(GLuint colorTex, GLuint colorRB,
}
if (stencilRB) {
MOZ_ASSERT(fIsRenderbuffer(stencilRB));
MOZ_ASSERT_IF(Renderer() != GLRenderer::AndroidEmulator, fIsRenderbuffer(stencilRB));
fFramebufferRenderbuffer(LOCAL_GL_FRAMEBUFFER,
LOCAL_GL_STENCIL_ATTACHMENT,
LOCAL_GL_RENDERBUFFER,
@@ -2842,6 +2854,11 @@ GLContext::fDeleteFramebuffers(GLsizei n, const GLuint* names)
}
}
// Avoid crash by flushing before glDeleteFramebuffers. See bug 1194923.
if (mNeedsFlushBeforeDeleteFB) {
fFlush();
}
if (n == 1 && *names == 0) {
// Deleting framebuffer 0 causes hangs on the DROID. See bug 623228.
} else {
+2
View File
@@ -169,6 +169,7 @@ enum class GLRenderer {
AdrenoTM200,
AdrenoTM205,
AdrenoTM320,
AdrenoTM420,
SGX530,
SGX540,
Tegra,
@@ -3504,6 +3505,7 @@ protected:
GLint mMaxViewportDims[2];
GLsizei mMaxSamples;
bool mNeedsTextureSizeChecks;
bool mNeedsFlushBeforeDeleteFB;
bool mWorkAroundDriverBugs;
bool IsTextureSizeSafeToPassToDriver(GLenum target, GLsizei width, GLsizei height) const {
+13
View File
@@ -2829,6 +2829,15 @@ GetLcovInfo(JSContext* cx, unsigned argc, Value* vp)
return true;
}
static bool
EnableNoSuchMethod(JSContext* cx, unsigned argc, Value* vp)
{
CallArgs args = CallArgsFromVp(argc, vp);
cx->runtime()->options().setNoSuchMethod(true);
args.rval().setUndefined();
return true;
}
#ifdef DEBUG
static bool
SetRNGState(JSContext* cx, unsigned argc, Value* vp)
@@ -3309,6 +3318,10 @@ gc::ZealModeHelpText),
" Generate LCOV tracefile for the given compartment. If no global are provided then\n"
" the current global is used as the default one.\n"),
JS_FN_HELP("enableNoSuchMethod", EnableNoSuchMethod, 0, 0,
"enableNoSuchMethod()",
" Enables the deprecated, non-standard __noSuchMethod__ feature.\n"),
#ifdef DEBUG
JS_FN_HELP("setRNGState", SetRNGState, 1, 0,
"setRNGState(seed)",
@@ -17,6 +17,8 @@
if (getJitCompilerOptions()["ion.forceinlineCaches"])
setJitCompilerOption("ion.forceinlineCaches", 0);
enableNoSuchMethod();
Array.prototype.__proto__ = Proxy.create({
getPropertyDescriptor: function(name) {
return (560566);
+2
View File
@@ -1,3 +1,5 @@
enableNoSuchMethod();
var count = 0;
var a = {__noSuchMethod__: function() { count++; } }
+1
View File
@@ -1,3 +1,4 @@
enableNoSuchMethod();
gczeal(2,1);
var count = 0;
var a = {__noSuchMethod__: function() { count++; } }
+2
View File
@@ -1,3 +1,5 @@
enableNoSuchMethod();
var res = 0;
var o = {};
o.__noSuchMethod__ = function(x) { res += x; };
+3 -3
View File
@@ -1,6 +1,7 @@
enableNoSuchMethod();
(function() {
{
let z;
let(z) {
for each(b in [{}]) { ({
get __noSuchMethod__() { return Function }
}).w()
@@ -9,4 +10,3 @@
})()
/* Don't crash/assert. */
@@ -1,3 +1,5 @@
enableNoSuchMethod();
function testStuff(x, y) {
for (var i = 0; i < 60; i++) {
x[y]();
+9 -8
View File
@@ -1,4 +1,5 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- * vim: set ts=8 sts=4 et sw=4 tw=99:
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* vim: set ts=8 sts=4 et sw=4 tw=99:
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
@@ -1837,7 +1838,7 @@ JS_IdToValue(JSContext* cx, jsid id, MutableHandleValue vp)
}
JS_PUBLIC_API(bool)
JS_DefaultValue(JSContext* cx, HandleObject obj, JSType hint, MutableHandleValue vp)
JS::ToPrimitive(JSContext* cx, HandleObject obj, JSType hint, MutableHandleValue vp)
{
AssertHeapIsIdle(cx);
CHECK_REQUEST(cx);
@@ -2936,10 +2937,10 @@ JS_GetOwnPropertyDescriptorById(JSContext* cx, HandleObject obj, HandleId id,
}
JS_PUBLIC_API(bool)
JS_GetOwnUCPropertyDescriptor(JSContext* cx, HandleObject obj, const char16_t* name,
MutableHandle<JSPropertyDescriptor> desc)
JS_GetOwnPropertyDescriptor(JSContext* cx, HandleObject obj, const char* name,
MutableHandle<JSPropertyDescriptor> desc)
{
JSAtom* atom = AtomizeChars(cx, name, js_strlen(name));
JSAtom* atom = Atomize(cx, name, strlen(name));
if (!atom)
return false;
RootedId id(cx, AtomToId(atom));
@@ -2947,10 +2948,10 @@ JS_GetOwnUCPropertyDescriptor(JSContext* cx, HandleObject obj, const char16_t* n
}
JS_PUBLIC_API(bool)
JS_GetOwnPropertyDescriptor(JSContext* cx, HandleObject obj, const char* name,
MutableHandle<JSPropertyDescriptor> desc)
JS_GetOwnUCPropertyDescriptor(JSContext* cx, HandleObject obj, const char16_t* name,
MutableHandle<JSPropertyDescriptor> desc)
{
JSAtom* atom = Atomize(cx, name, strlen(name));
JSAtom* atom = AtomizeChars(cx, name, js_strlen(name));
if (!atom)
return false;
RootedId id(cx, AtomToId(atom));
+18 -8
View File
@@ -1149,7 +1149,8 @@ class JS_PUBLIC_API(RuntimeOptions) {
asyncStack_(true),
werror_(false),
strictMode_(false),
extraWarnings_(false)
extraWarnings_(false),
noSuchMethod_(false)
{
}
@@ -1241,6 +1242,12 @@ class JS_PUBLIC_API(RuntimeOptions) {
return *this;
}
bool noSuchMethod() const { return noSuchMethod_; }
RuntimeOptions& setNoSuchMethod(bool flag) {
noSuchMethod_ = flag;
return *this;
}
private:
bool baseline_ : 1;
bool ion_ : 1;
@@ -1252,6 +1259,7 @@ class JS_PUBLIC_API(RuntimeOptions) {
bool werror_ : 1;
bool strictMode_ : 1;
bool extraWarnings_ : 1;
bool noSuchMethod_ : 1;
};
JS_PUBLIC_API(RuntimeOptions&)
@@ -1894,6 +1902,8 @@ JS_StringToId(JSContext* cx, JS::HandleString s, JS::MutableHandleId idp);
extern JS_PUBLIC_API(bool)
JS_IdToValue(JSContext* cx, jsid id, JS::MutableHandle<JS::Value> vp);
namespace JS {
/**
* Convert obj to a primitive value. On success, store the result in vp and
* return true.
@@ -1904,10 +1914,7 @@ JS_IdToValue(JSContext* cx, jsid id, JS::MutableHandle<JS::Value> vp);
* Implements: ES6 7.1.1 ToPrimitive(input, [PreferredType]).
*/
extern JS_PUBLIC_API(bool)
JS_DefaultValue(JSContext* cx, JS::HandleObject obj, JSType hint,
JS::MutableHandleValue vp);
namespace JS {
ToPrimitive(JSContext* cx, JS::HandleObject obj, JSType hint, JS::MutableHandleValue vp);
/**
* If args.get(0) is one of the strings "string", "number", or "default", set
@@ -1926,8 +1933,8 @@ JS_PropertyStub(JSContext* cx, JS::HandleObject obj, JS::HandleId id,
JS::MutableHandleValue vp);
extern JS_PUBLIC_API(bool)
JS_StrictPropertyStub(JSContext *cx, JS::HandleObject obj, JS::HandleId id,
JS::MutableHandleValue vp, JS::ObjectOpResult &result);
JS_StrictPropertyStub(JSContext* cx, JS::HandleObject obj, JS::HandleId id,
JS::MutableHandleValue vp, JS::ObjectOpResult& result);
template<typename T>
struct JSConstScalarSpec {
@@ -5425,9 +5432,12 @@ GetSavedFrameParent(JSContext* cx, HandleObject savedFrame, MutableHandleObject
* The same notes above about SavedFrame accessors applies here as well: cx
* doesn't need to be in stack's compartment, and stack can be null, a
* SavedFrame object, or a wrapper (CCW or Xray) around a SavedFrame object.
*
* Optional indent parameter specifies the number of white spaces to indent
* each line.
*/
extern JS_PUBLIC_API(bool)
BuildStackString(JSContext* cx, HandleObject stack, MutableHandleString stringp);
BuildStackString(JSContext* cx, HandleObject stack, MutableHandleString stringp, size_t indent = 0);
} /* namespace JS */
+48
View File
@@ -84,6 +84,7 @@
#include "jscompartmentinlines.h"
#include "jsobjinlines.h"
#include "vm/ErrorObject-inl.h"
#include "vm/Interpreter-inl.h"
#include "vm/Stack-inl.h"
@@ -5141,6 +5142,41 @@ CreateLastWarningObject(JSContext* cx, JSErrorReport* report)
return true;
}
static bool
PrintStackTrace(JSContext* cx, HandleValue exn)
{
if (!exn.isObject())
return false;
Maybe<JSAutoCompartment> ac;
RootedObject exnObj(cx, &exn.toObject());
if (IsCrossCompartmentWrapper(exnObj)) {
exnObj = UncheckedUnwrap(exnObj);
ac.emplace(cx, exnObj);
}
// Ignore non-ErrorObject thrown by |throw| statement.
if (!exnObj->is<ErrorObject>())
return true;
RootedObject stackObj(cx, exnObj->as<ErrorObject>().stack());
if (!stackObj)
return false;
RootedString stackStr(cx);
if (!BuildStackString(cx, stackObj, &stackStr, 2))
return false;
UniquePtr<char[], JS::FreePolicy> stack(JS_EncodeStringToUTF8(cx, stackStr));
if (!stack)
return false;
fputs("Stack:\n", gErrFile);
fputs(stack.get(), gErrFile);
return true;
}
void
js::shell::my_ErrorReporter(JSContext* cx, const char* message, JSErrorReport* report)
{
@@ -5153,7 +5189,19 @@ js::shell::my_ErrorReporter(JSContext* cx, const char* message, JSErrorReport* r
savedExc.restore();
}
// Get exception object before printing and clearing exception.
RootedValue exn(cx);
if (JS_IsExceptionPending(cx))
(void) JS_GetPendingException(cx, &exn);
gGotError = PrintError(cx, gErrFile, message, report, reportWarnings);
if (!exn.isUndefined()) {
JS::AutoSaveExceptionState savedExc(cx);
if (!PrintStackTrace(cx, exn))
fputs("(Unable to print stack trace)\n", gOutFile);
savedExc.restore();
}
if (report->exnType != JSEXN_NONE && !JSREPORT_IS_WARNING(report->flags)) {
if (report->errorNumber == JSMSG_OUT_OF_MEMORY) {
gExitCode = EXITCODE_OUT_OF_MEMORY;
@@ -1,3 +1,4 @@
// |reftest| skip-if(!xulRuntime.shell)
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -9,6 +10,8 @@ var summary = '__noSuchMethod__ handler';
var actual = '';
var expect = '';
enableNoSuchMethod();
printBugNumber(BUGNUMBER);
printStatus (summary);
@@ -1,3 +1,4 @@
// |reftest| skip-if(!xulRuntime.shell)
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/*
* Any copyright is dedicated to the Public Domain.
@@ -12,8 +13,8 @@ var summary = '__noSuchMethod__ when property exists';
var actual = '';
var expect = '';
//-----------------------------------------------------------------------------
enableNoSuchMethod();
test();
//-----------------------------------------------------------------------------
@@ -1,3 +1,4 @@
// |reftest| skip-if(!xulRuntime.shell)
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -11,6 +12,7 @@ var expect = '';
//-----------------------------------------------------------------------------
enableNoSuchMethod();
test();
//-----------------------------------------------------------------------------
@@ -1,6 +1,9 @@
// |reftest| skip-if(!xulRuntime.shell)
// Any copyright is dedicated to the Public Domain.
// http://creativecommons.org/licenses/publicdomain/
enableNoSuchMethod();
var sym = Symbol("method");
var hits = 0;
var obj = {
+3
View File
@@ -169,6 +169,9 @@ static const Class js_NoSuchMethodClass = {
bool
js::OnUnknownMethod(JSContext* cx, HandleObject obj, Value idval_, MutableHandleValue vp)
{
if (!cx->runtime()->options().noSuchMethod())
return true;
RootedValue idval(cx, idval_);
RootedValue value(cx);
+3 -2
View File
@@ -734,7 +734,7 @@ GetSavedFrameParent(JSContext* cx, HandleObject savedFrame, MutableHandleObject
}
JS_PUBLIC_API(bool)
BuildStackString(JSContext* cx, HandleObject stack, MutableHandleString stringp)
BuildStackString(JSContext* cx, HandleObject stack, MutableHandleString stringp, size_t indent)
{
js::StringBuffer sb(cx);
@@ -761,7 +761,8 @@ BuildStackString(JSContext* cx, HandleObject stack, MutableHandleString stringp)
asyncCause.set(cx->names().Async);
js::RootedAtom name(cx, frame->getFunctionDisplayName());
if ((asyncCause && (!sb.append(asyncCause) || !sb.append('*')))
if ((indent && !sb.appendN(' ', indent))
|| (asyncCause && (!sb.append(asyncCause) || !sb.append('*')))
|| (name && !sb.append(name))
|| !sb.append('@')
|| !sb.append(frame->getSource())