Merge inbound to mozilla-central. a=merge

This commit is contained in:
Noemi Erli 2018-03-23 00:53:07 +02:00
commit b32b2756aa
58 changed files with 540 additions and 637 deletions

View File

@ -22,3 +22,6 @@ origin install 1 https://testpilot.firefox.com
# Remote troubleshooting
origin remote-troubleshooting 1 https://input.mozilla.org
origin remote-troubleshooting 1 https://support.mozilla.org
# Hybrid Content Telemetry - https://firefox-source-docs.mozilla.org/toolkit/components/telemetry/telemetry/collection/hybrid-content.html
origin hc_telemetry 1 https://discovery.addons.mozilla.org

View File

@ -705,6 +705,9 @@ BrowserGlue.prototype = {
iconURL: "resource:///chrome/browser/content/browser/defaultthemes/dark.icon.svg",
textcolor: "white",
accentcolor: "black",
popup: "hsl(240, 5%, 5%)",
popup_text: "rgb(249, 249, 250)",
popup_border: "rgba(24, 26, 27, 0.14)",
author: vendorShortName,
});

View File

@ -349,19 +349,6 @@
fun:_ZN7mozilla13ServoStyleSet38InvalidateStyleForDocumentStateChangesENS_11EventStatesE
}
# Issues triggered by enabling stylo-only.
# Conditional jump or move depends on uninitialised value(s)
# at 0x104E7B44: nsFrame::ComputeSize(gfxContext*, mozilla::WritingMode, mozilla::LogicalSize const&, int, mozilla::LogicalSize const&, mozilla::LogicalSize const&, mozilla::LogicalSize const&, nsIFrame::ComputeSizeFlags) (nsFrame.cpp:5742)
# by 0x105A9865: nsSubDocumentFrame::ComputeSize(gfxContext*, mozilla::WritingMode, mozilla::LogicalSize const&, int, mozilla::LogicalSize const&, mozilla::LogicalSize const&, mozilla::LogicalSize const&, nsIFrame::ComputeSizeFlags) (nsSubDocumentFrame.cpp:778)
# by 0x10502714: nsFrame::BoxReflow(nsBoxLayoutState&, nsPresContext*, mozilla::ReflowOutput&, gfxContext*, int, int, int, int, bool) (nsFrame.cpp:10627)
{
Bug 1447405 nsFrame::ComputeSize, March 2018
Memcheck:Cond
fun:_ZN7nsFrame11ComputeSizeEP10gfxContextN7mozilla11WritingModeERKNS2_11LogicalSizeEiS6_S6_S6_N8nsIFrame16ComputeSizeFlagsE
}
###################################################
# For valgrind-mochitest ("tc-M-V [tier 2]") runs on taskcluster.
# See bug 1248365.

View File

@ -47,7 +47,7 @@ LOCAL_INCLUDES += [
'../../checkout/src/',
'../../checkout/src/common/third_party/base/',
]
#
#CXXFLAGS += [
# '/bigobj',
# '/d2FastFail',
@ -118,19 +118,22 @@ SOURCES += [
'../../checkout/src/common/uniform_type_info_autogen.cpp',
'../../checkout/src/common/utilities.cpp',
]
if CONFIG['OS_ARCH'] == 'Darwin':
SOURCES += [
'../../checkout/src/common/system_utils_mac.cpp',
]
if CONFIG['OS_ARCH'] == 'Linux':
SOURCES += [
'../../checkout/src/common/system_utils_linux.cpp',
]
if CONFIG['OS_ARCH'] == 'WINNT':
SOURCES += [
'../../checkout/src/common/system_utils_win.cpp',
]
#
if CONFIG['OS_ARCH'] not in ('Darwin', 'WINNT'):
SOURCES += [
'../../checkout/src/common/system_utils_linux.cpp',
]
#LDFLAGS += [
# '/DEBUG',
# '/WX',

View File

@ -47,7 +47,7 @@ LOCAL_INCLUDES += [
'../../checkout/src/',
'../../checkout/src/common/third_party/base/',
]
#
#CXXFLAGS += [
# '/bigobj',
# '/d2FastFail',
@ -105,6 +105,7 @@ LOCAL_INCLUDES += [
SOURCES += [
'../../checkout/src/gpu_info_util/SystemInfo.cpp',
]
if CONFIG['OS_ARCH'] == 'WINNT':
SOURCES += [
'../../checkout/src/gpu_info_util/SystemInfo_win.cpp',
@ -121,7 +122,7 @@ DIRS += [
OS_LIBS += [
'setupapi',
]
#
#LDFLAGS += [
# '/DEBUG',
# '/WX',

View File

@ -46,7 +46,7 @@ LOCAL_INCLUDES += [
'../../checkout/src/',
'../../checkout/src/common/third_party/base/',
]
#
#CXXFLAGS += [
# '/bigobj',
# '/d2FastFail',
@ -115,7 +115,7 @@ USE_LIBS += [
DIRS += [
'../angle_common',
]
#
#LDFLAGS += [
# '/DEBUG',
# '/WX',

View File

@ -52,7 +52,7 @@ LOCAL_INCLUDES += [
'../../checkout/src/',
'../../checkout/src/common/third_party/base/',
]
#
#CXXFLAGS += [
# '/bigobj',
# '/d2FastFail',
@ -274,7 +274,7 @@ OS_LIBS += [
'dxguid',
'setupapi',
]
#
#LDFLAGS += [
# '/DEBUG',
# '/WX',

View File

@ -49,7 +49,7 @@ LOCAL_INCLUDES += [
'../../checkout/src/',
'../../checkout/src/common/third_party/base/',
]
#
#CXXFLAGS += [
# '/bigobj',
# '/d2FastFail',
@ -141,7 +141,7 @@ OS_LIBS += [
'winspool',
'ws2_32',
]
#
#LDFLAGS += [
# '/DEBUG',
# '/DYNAMICBASE:NO',
@ -155,7 +155,7 @@ OS_LIBS += [
# '/SUBSYSTEM:CONSOLE,5.02',
# '/WX',
#]
DEFFILE = SRCDIR + '/../../checkout/src/libEGL/libEGL.def'
RCFILE = '../../checkout/src/libEGL/libEGL.rc'
GeckoSharedLibrary('libEGL', linkage=None)

View File

@ -53,7 +53,7 @@ LOCAL_INCLUDES += [
'../../checkout/src/',
'../../checkout/src/common/third_party/base/',
]
#
#CXXFLAGS += [
# '/bigobj',
# '/d2FastFail',
@ -159,7 +159,7 @@ OS_LIBS += [
'winspool',
'ws2_32',
]
#
#LDFLAGS += [
# '/DEBUG',
# '/DYNAMICBASE:NO',
@ -173,7 +173,7 @@ OS_LIBS += [
# '/SUBSYSTEM:CONSOLE,5.02',
# '/WX',
#]
DEFFILE = SRCDIR + '/../../checkout/src/libGLESv2/libGLESv2.def'
RCFILE = '../../checkout/src/libGLESv2/libGLESv2.rc'
GeckoSharedLibrary('libGLESv2', linkage=None)

View File

@ -46,7 +46,7 @@ LOCAL_INCLUDES += [
'../../checkout/src/',
'../../checkout/src/common/third_party/base/',
]
#
#CXXFLAGS += [
# '/bigobj',
# '/d2FastFail',
@ -122,7 +122,7 @@ USE_LIBS += [
DIRS += [
'../angle_common',
]
#
#LDFLAGS += [
# '/DEBUG',
# '/WX',

View File

@ -49,7 +49,7 @@ LOCAL_INCLUDES += [
'../../checkout/src/',
'../../checkout/src/common/third_party/base/',
]
#
#CXXFLAGS += [
# '/bigobj',
# '/d2FastFail',
@ -228,7 +228,7 @@ DIRS += [
'../angle_common',
'../preprocessor',
]
#
#LDFLAGS += [
# '/DEBUG',
# '/WX',

View File

@ -218,15 +218,15 @@ checkout_dir.mkdir(exist_ok=True)
def sortedi(x):
return sorted(x, key=str.lower)
def append_arr(dest, name, vals):
def append_arr(dest, name, vals, indent=0):
if not vals:
return
dest.append('')
dest.append('{} += ['.format(name))
dest.append('{}{} += ['.format(' '*4*indent, name))
for x in sortedi(vals):
dest.append(" '{}',".format(x))
dest.append(']')
dest.append("{}'{}',".format(' '*4*(indent+1), x))
dest.append('{}]'.format(' '*4*indent))
dest.append('')
return
INCLUDE_REGEX = re.compile('# *include *"(.+)"')
@ -395,8 +395,8 @@ def export_target(root):
target_dir.mkdir(exist_ok=True)
lines = COMMON_HEADER[:]
lines.append('')
for x in sorted(set(accum_desc['defines'])):
try:
(k, v) = x.split('=', 1)
@ -410,6 +410,7 @@ def export_target(root):
lines.append(line)
except KeyError:
print('[{}] Unrecognized define: {}'.format(name, k))
lines.append('')
cxxflags = set(accum_desc['cflags'] + accum_desc['cflags_cc'])
@ -418,8 +419,7 @@ def export_target(root):
assert x.startswith('//'), x
yield '../../checkout/' + x[2:]
sources = []
sources_by_os_arch = {}
sources_by_config = {}
extras = dict()
for x in fixup_paths(accum_desc['sources']):
(b, e) = x.rsplit('.', 1)
@ -427,13 +427,16 @@ def export_target(root):
continue
elif e in ['cpp', 'cc']:
if b.endswith('_win'):
sources_by_os_arch.setdefault('WINNT', []).append(x)
config = "CONFIG['OS_ARCH'] == 'WINNT'"
elif b.endswith('_linux'):
sources_by_os_arch.setdefault('Linux', []).append(x)
# Include these on BSDs too.
config = "CONFIG['OS_ARCH'] not in ('Darwin', 'WINNT')"
elif b.endswith('_mac'):
sources_by_os_arch.setdefault('Darwin', []).append(x)
config = "CONFIG['OS_ARCH'] == 'Darwin'"
else:
sources.append(x)
config = '' # None can't compare against str.
sources_by_config.setdefault(config, []).append(x)
continue
elif e == 'rc':
assert 'RCFILE' not in extras
@ -452,20 +455,22 @@ def export_target(root):
def append_arr_commented(dest, name, src):
lines = []
append_arr(lines, name, src)
lines = map(lambda x: '#' + x, lines)
def comment(x):
if x:
x = '#' + x
return x
lines = map(comment, lines)
dest += lines
append_arr(lines, 'LOCAL_INCLUDES', fixup_paths(accum_desc['include_dirs']))
append_arr_commented(lines, 'CXXFLAGS', cxxflags)
append_arr(lines, 'SOURCES', sources)
for (os_arch,v) in sorted_items(sources_by_os_arch):
lines += [
"if CONFIG['OS_ARCH'] == '{}':".format(os_arch),
" SOURCES += [",
]
lines += ("{}'{}',".format(' '*8, x) for x in sorted(set(v)))
lines += [" ]"]
for (config,v) in sorted_items(sources_by_config):
indent = 0
if config:
lines.append("if {}:".format(config))
indent = 1
append_arr(lines, 'SOURCES', v, indent=indent)
append_arr(lines, 'USE_LIBS', use_libs)
append_arr(lines, 'DIRS', ['../' + x for x in use_libs])
@ -477,9 +482,9 @@ def export_target(root):
lib_type = root['type']
if lib_type == 'shared_library':
lines.append("\nGeckoSharedLibrary('{}', linkage=None)".format(name))
lines.append("GeckoSharedLibrary('{}', linkage=None)".format(name))
elif lib_type == 'static_library':
lines.append("\nLibrary('{}')".format(name))
lines.append("Library('{}')".format(name))
else:
assert False, lib_type

View File

@ -1059,14 +1059,24 @@ js::intl_toLocaleLowerCase(JSContext* cx, unsigned argc, Value* vp)
static_assert(JSString::MAX_LENGTH < INT32_MAX / 3,
"Case conversion doesn't overflow int32_t indices");
JSString* str =
intl::CallICU(cx, [&input, locale](UChar* chars, int32_t size, UErrorCode* status) {
return u_strToLower(chars, size, input.begin().get(), input.length(), locale, status);
});
if (!str)
static const size_t INLINE_CAPACITY = js::intl::INITIAL_CHAR_BUFFER_SIZE;
Vector<char16_t, INLINE_CAPACITY> chars(cx);
if (!chars.resize(Max(INLINE_CAPACITY, input.length())))
return false;
args.rval().setString(str);
int32_t size =
intl::CallICU(cx, [&input, locale](UChar* chars, int32_t size, UErrorCode* status) {
return u_strToLower(chars, size, input.begin().get(), input.length(), locale, status);
}, chars);
if (size < 0)
return false;
JSString* result = NewStringCopyN<CanGC>(cx, chars.begin(), size);
if (!result)
return false;
args.rval().setString(result);
return true;
}
@ -1447,14 +1457,24 @@ js::intl_toLocaleUpperCase(JSContext* cx, unsigned argc, Value* vp)
static_assert(JSString::MAX_LENGTH < INT32_MAX / 3,
"Case conversion doesn't overflow int32_t indices");
JSString* str =
intl::CallICU(cx, [&input, locale](UChar* chars, int32_t size, UErrorCode* status) {
return u_strToUpper(chars, size, input.begin().get(), input.length(), locale, status);
});
if (!str)
static const size_t INLINE_CAPACITY = js::intl::INITIAL_CHAR_BUFFER_SIZE;
Vector<char16_t, INLINE_CAPACITY> chars(cx);
if (!chars.resize(Max(INLINE_CAPACITY, input.length())))
return false;
args.rval().setString(str);
int32_t size =
intl::CallICU(cx, [&input, locale](UChar* chars, int32_t size, UErrorCode* status) {
return u_strToUpper(chars, size, input.begin().get(), input.length(), locale, status);
}, chars);
if (size < 0)
return false;
JSString* result = NewStringCopyN<CanGC>(cx, chars.begin(), size);
if (!result)
return false;
args.rval().setString(result);
return true;
}
@ -1631,7 +1651,7 @@ js::str_normalize(JSContext* cx, unsigned argc, Value* vp)
return true;
}
static const size_t INLINE_CAPACITY = 32;
static const size_t INLINE_CAPACITY = js::intl::INITIAL_CHAR_BUFFER_SIZE;
Vector<char16_t, INLINE_CAPACITY> chars(cx);
if (!chars.resize(Max(INLINE_CAPACITY, srcChars.length())))

View File

@ -4990,24 +4990,6 @@ SetTimeResolution(JSContext* cx, unsigned argc, Value* vp)
return true;
}
static bool
EnableExpressionClosures(JSContext* cx, unsigned argc, Value* vp)
{
CallArgs args = CallArgsFromVp(argc, vp);
JS::ContextOptionsRef(cx).setExpressionClosures(true);
args.rval().setUndefined();
return true;
}
static bool
DisableExpressionClosures(JSContext* cx, unsigned argc, Value* vp)
{
CallArgs args = CallArgsFromVp(argc, vp);
JS::ContextOptionsRef(cx).setExpressionClosures(false);
args.rval().setUndefined();
return true;
}
JSScript*
js::TestingFunctionArgumentToScript(JSContext* cx,
HandleValue v,
@ -5781,14 +5763,6 @@ gc::ZealModeHelpText),
" Enables time clamping and jittering. Specify a time resolution in\n"
" microseconds and whether or not to jitter\n"),
JS_FN_HELP("enableExpressionClosures", EnableExpressionClosures, 0, 0,
"enableExpressionClosures()",
" Enables the deprecated, non-standard expression closures.\n"),
JS_FN_HELP("disableExpressionClosures", DisableExpressionClosures, 0, 0,
"disableExpressionClosures()",
" Disables the deprecated, non-standard expression closures.\n"),
JS_FN_HELP("baselineCompile", BaselineCompile, 2, 0,
"baselineCompile([fun/code], forceDebugInstrumentation=false)",
" Baseline-compiles the given JS function or script.\n"

View File

@ -1010,18 +1010,13 @@ ComputeBinary(ParseNodeKind kind, double left, double right)
return left * right;
if (kind == ParseNodeKind::Mod)
return right == 0 ? GenericNaN() : js_fmod(left, right);
return right == 0 ? GenericNaN() : fmod(left, right);
if (kind == ParseNodeKind::Ursh)
return ToUint32(left) >> (ToUint32(right) & 31);
if (kind == ParseNodeKind::Div) {
if (right == 0) {
#if defined(XP_WIN)
/* XXX MSVC miscompiles such that (NaN == 0) */
if (IsNaN(right))
return GenericNaN();
#endif
if (left == 0 || IsNaN(left))
return GenericNaN();
if (IsNegative(left) != IsNegative(right))

View File

@ -3262,16 +3262,6 @@ Parser<FullParseHandler, CharT>::skipLazyInnerFunction(ParseNode* funcNode, uint
if (!tokenStream.advance(fun->lazyScript()->end()))
return false;
if (allowExpressionClosures()) {
// Only expression closure can be Statement kind.
// If we remove expression closure, we can remove isExprBody flag from
// LazyScript and JSScript.
if (kind == Statement && funbox->isExprBody()) {
if (!matchOrInsertSemicolon())
return false;
}
}
// Append possible Annex B function box only upon successfully parsing.
if (tryAnnexB && !pc->innermostScope()->addPossibleAnnexBFunctionBox(pc, funbox))
return false;
@ -3785,23 +3775,8 @@ GeneralParser<ParseHandler, CharT>::functionFormalParametersAndBody(InHandling i
uint32_t openedPos = 0;
if (tt != TokenKind::Lc) {
if (kind != Arrow) {
if (funbox->isGenerator() || funbox->isAsync() || kind == Method ||
kind == GetterNoExpressionClosure || kind == SetterNoExpressionClosure ||
IsConstructorKind(kind) || kind == PrimaryExpression)
{
error(JSMSG_CURLY_BEFORE_BODY);
return false;
}
if (allowExpressionClosures()) {
this->addTelemetry(DeprecatedLanguageExtension::ExpressionClosure);
if (!warnOnceAboutExprClosure())
return false;
handler.noteExpressionClosure(pn);
} else {
error(JSMSG_CURLY_BEFORE_BODY);
return false;
}
error(JSMSG_CURLY_BEFORE_BODY);
return false;
}
anyChars.ungetToken();
@ -3863,7 +3838,7 @@ GeneralParser<ParseHandler, CharT>::functionFormalParametersAndBody(InHandling i
JSMSG_CURLY_OPENED, openedPos));
funbox->setEnd(anyChars);
} else {
MOZ_ASSERT_IF(!allowExpressionClosures(), kind == Arrow);
MOZ_ASSERT(kind == Arrow);
if (anyChars.hadError())
return false;

View File

@ -340,9 +340,6 @@ class ParserBase
bool hasValidSimpleStrictParameterNames();
bool allowExpressionClosures() const {
return options().expressionClosuresOption;
}
/*
* Create a new function object given a name (which is optional if this is
* a function expression).
@ -705,7 +702,6 @@ class GeneralParser
using Base::isValidSimpleAssignmentTarget;
using Base::pc;
using Base::usedNames;
using Base::allowExpressionClosures;
private:
using Base::checkAndMarkSuperScope;
@ -1408,7 +1404,6 @@ class Parser<FullParseHandler, CharT> final
using Base::pos;
using Base::ss;
using Base::tokenStream;
using Base::allowExpressionClosures;
private:
using Base::alloc;

View File

@ -1102,14 +1102,6 @@ function test_syntax(postfixes, check_error, ignore_opts) {
// ==== Legacy ====
// Expression closures
enableExpressionClosures();
test("function f() 1 ");
test("function f() 1; ");
test("(function () 1 ");
test("(function () 1); ");
// ==== asm.js ====
test("(function() { 'use asm'; ");

View File

@ -1,12 +1,6 @@
load(libdir + "asm.js");
load(libdir + "asserts.js");
enableExpressionClosures();
assertAsmTypeFail(USE_ASM + 'function f() 0');
assertAsmTypeFail(USE_ASM + 'function f() 0; return 0');
assertAsmTypeFail(USE_ASM + 'function f() 0; return f');
assertAsmTypeFail(USE_ASM);
assertAsmTypeFail(USE_ASM + 'return');
assertAsmTypeFail(USE_ASM + 'function f(){}');

View File

@ -10,7 +10,3 @@ f = Function("");
assertEq(f.toString(), "function anonymous(\n) {\n\n}");
f = Function("", "(abc)");
assertEq(f.toString(), "function anonymous(\n) {\n(abc)\n}");
enableExpressionClosures();
f = Function("", "return function (a,b) a + b;")();
assertEq(f.toString(), "function (a,b) a + b");

View File

@ -1,34 +0,0 @@
enableExpressionClosures();
eval(`
function f1(foo, bar) foo + bar;
assertEq(f1.toString(), "function f1(foo, bar) foo + bar");
assertEq(f1.toString(), f1.toSource());
assertEq(decompileFunction(f1), f1.toString());
// No semicolon on purpose
function f2(foo, bar) foo + bar
assertEq(f2.toString(), "function f2(foo, bar) foo + bar");
assertEq(f2.toString(), f2.toSource());
var f3 = function (foo, bar) foo + bar;
assertEq(f3.toSource(), "(function (foo, bar) foo + bar)");
assertEq(f3.toString(), "function (foo, bar) foo + bar");
// No semicolon on purpose
var f4 = function (foo, bar) foo + bar
assertEq(f4.toSource(), "(function (foo, bar) foo + bar)");
assertEq(f4.toString(), "function (foo, bar) foo + bar");
var f5 = function (foo, bar) foo + bar ;
assertEq(f5.toSource(), "(function (foo, bar) foo + bar)");
assertEq(f5.toString(), "function (foo, bar) foo + bar");
var f6 = function (foo, bar) foo + bar; var a = 42
assertEq(f6.toSource(), "(function (foo, bar) foo + bar)");
assertEq(f6.toString(), "function (foo, bar) foo + bar");
var f7 = function (foo, bar) foo + bar + '\
long\
string\
test\
'
// a comment followed by some space
assertEq(f7.toString(), "function (foo, bar) foo + bar + '\\\nlong\\\nstring\\\ntest\\\n'");
assertEq(f7.toSource(), "(" + f7.toString() + ")");
`);

View File

@ -1,44 +0,0 @@
enableExpressionClosures();
eval(`
m = {
i() {},
n() {},
d() {},
n() {},
n() {},
n() {},
s() {}
};
function c()
function ()
function ()
function ()
function ()[{
f() {}
}, {
v() {}
}, {
n() {}
}, {
v() {}
}, {
f() {}
}, {
n() {}
}, {
n() {}
}, {
n() {}
}, {
n() {}
}, {
v() {}
}, {
n() {}
}, {
n() {}
}];
t = function () {};
getLcovInfo();
relazifyFunctions();
`);

View File

@ -1,11 +0,0 @@
enableExpressionClosures();
eval(`
function f() {
// The expression closure is deliberate here, testing the semicolon after
// one when it appears as a FunctionDeclaration from B.3.4
// FunctionDeclarations in IfStatement Statement Clauses.
if (0)
function g() x;
else;
}
f();`)

View File

@ -1,65 +0,0 @@
// Expression closure should be warned once and only once.
var release_or_beta = getBuildConfiguration().release_or_beta;
enableExpressionClosures();
function testWarn(code) {
if (release_or_beta) {
// Warning for expression closure is non-release-only (not Release/Beta).
testPass(code);
return;
}
enableLastWarning();
var g = newGlobal();
g.code = code;
g.eval('eval(code)');
var warning = getLastWarning();
assertEq(warning !== null, true, "warning should be caught for " + code);
assertEq(warning.name, "Warning");
clearLastWarning();
g.eval('eval(code)');
warning = getLastWarning();
assertEq(warning, null, "warning should not be caught for 2nd ocurrence");
clearLastWarning();
g = newGlobal();
g.code = code;
g.eval('Reflect.parse(code);');
warning = getLastWarning();
assertEq(warning !== null, true, "warning should be caught for " + code);
assertEq(warning.name, "Warning");
clearLastWarning();
g.eval('Reflect.parse(code);');
warning = getLastWarning();
assertEq(warning, null, "warning should not be caught for 2nd ocurrence");
disableLastWarning();
}
function testPass(code) {
enableLastWarning();
var g = newGlobal();
g.code = code;
g.eval('eval(code)');
var warning = getLastWarning();
assertEq(warning, null, "warning should not be caught for " + code);
clearLastWarning();
g = newGlobal();
g.code = code;
g.eval('Reflect.parse(code);');
warning = getLastWarning();
assertEq(warning, null, "warning should not be caught for " + code);
disableLastWarning();
}
testWarn("function f() 1");
testWarn("(function() 1)");
testWarn("({ get x() 1 })");
testWarn("({ set x(v) 1 })");
testPass("function f() { 1 }");
testPass("() => 1");

View File

@ -317,36 +317,67 @@ if (typeof WebAssembly.Global === "function") {
assertEq((new WebAssembly.Global({type: "i32", value: 3.14})).value, 3);
assertEq((new WebAssembly.Global({type: "f32", value: { valueOf: () => 33.5 }})).value, 33.5);
// Misc internal conversions
let g = new WebAssembly.Global({type: "i32", value: 42});
// Nothing special about NaN, it coerces just fine
assertEq((new WebAssembly.Global({type: "i32", value: NaN})).value, 0);
// @@toPrimitive
assertEq(g - 5, 37);
assertEq(String(g), "42");
{
// "value" is enumerable
let x = new WebAssembly.Global({type: "i32"});
let s = "";
for ( let i in x )
s = s + i + ",";
assertEq(s, "value,");
}
// @@toStringTag
assertEq(g.toString(), "[object WebAssembly.Global]");
// "value" is defined on the prototype, not on the object
assertEq("value" in WebAssembly.Global.prototype, true);
// An exported global should appear as a WebAssembly.Global instance:
let i =
new WebAssembly.Instance(
new WebAssembly.Module(
wasmTextToBinary(`(module (global (export "g") i32 (i32.const 42)))`)));
// Can't set the value of an immutable global
assertErrorMessage(() => (new WebAssembly.Global({type: "i32"})).value = 10,
TypeError,
/can't set value of immutable global/);
assertEq(typeof i.exports.g, "object");
assertEq(i.exports.g instanceof WebAssembly.Global, true);
{
// Misc internal conversions
let g = new WebAssembly.Global({type: "i32", value: 42});
// An exported global can be imported into another instance even if
// it is an object:
let j =
new WebAssembly.Instance(
new WebAssembly.Module(
wasmTextToBinary(`(module
(global (import "" "g") i32)
(func (export "f") (result i32)
(get_global 0)))`)),
{ "": { "g": i.exports.g }});
// valueOf
assertEq(g - 5, 37);
// And when it is then accessed it has the right value:
assertEq(j.exports.f(), 42);
// @@toStringTag
assertEq(g.toString(), "[object WebAssembly.Global]");
}
{
// An exported global should appear as a WebAssembly.Global instance:
let i =
new WebAssembly.Instance(
new WebAssembly.Module(
wasmTextToBinary(`(module (global (export "g") i32 (i32.const 42)))`)));
assertEq(typeof i.exports.g, "object");
assertEq(i.exports.g instanceof WebAssembly.Global, true);
// An exported global can be imported into another instance even if
// it is an object:
let j =
new WebAssembly.Instance(
new WebAssembly.Module(
wasmTextToBinary(`(module
(global (import "" "g") i32)
(func (export "f") (result i32)
(get_global 0)))`)),
{ "": { "g": i.exports.g }});
// And when it is then accessed it has the right value:
assertEq(j.exports.f(), 42);
}
// TEST THIS LAST
// "value" is deletable
assertEq(delete WebAssembly.Global.prototype.value, true);
assertEq("value" in WebAssembly.Global.prototype, false);
// ADD NO MORE TESTS HERE!
}

View File

@ -0,0 +1,47 @@
if (!wasmSignExtensionSupported())
quit(0);
// extend32.wast:3
let $1 = instance("\x00\x61\x73\x6d\x01\x00\x00\x00\x01\x86\x80\x80\x80\x00\x01\x60\x01\x7f\x01\x7f\x03\x83\x80\x80\x80\x00\x02\x00\x00\x07\x9a\x80\x80\x80\x00\x02\x09\x65\x78\x74\x65\x6e\x64\x38\x5f\x73\x00\x00\x0a\x65\x78\x74\x65\x6e\x64\x31\x36\x5f\x73\x00\x01\x0a\x95\x80\x80\x80\x00\x02\x85\x80\x80\x80\x00\x00\x20\x00\xc0\x0b\x85\x80\x80\x80\x00\x00\x20\x00\xc1\x0b");
// extend32.wast:8
assert_return(() => call($1, "extend8_s", [0]), 0);
// extend32.wast:9
assert_return(() => call($1, "extend8_s", [127]), 127);
// extend32.wast:10
assert_return(() => call($1, "extend8_s", [128]), -128);
// extend32.wast:11
assert_return(() => call($1, "extend8_s", [255]), -1);
// extend32.wast:12
assert_return(() => call($1, "extend8_s", [19088640]), 0);
// extend32.wast:13
assert_return(() => call($1, "extend8_s", [-19088768]), -128);
// extend32.wast:14
assert_return(() => call($1, "extend8_s", [-1]), -1);
// extend32.wast:16
assert_return(() => call($1, "extend16_s", [0]), 0);
// extend32.wast:17
assert_return(() => call($1, "extend16_s", [32767]), 32767);
// extend32.wast:18
assert_return(() => call($1, "extend16_s", [32768]), -32768);
// extend32.wast:19
assert_return(() => call($1, "extend16_s", [65535]), -1);
// extend32.wast:20
assert_return(() => call($1, "extend16_s", [19070976]), 0);
// extend32.wast:21
assert_return(() => call($1, "extend16_s", [-19103744]), -32768);
// extend32.wast:22
assert_return(() => call($1, "extend16_s", [-1]), -1);

View File

@ -0,0 +1,77 @@
if (!wasmSignExtensionSupported())
quit(0);
// extend64.wast:3
let $1 = instance("\x00\x61\x73\x6d\x01\x00\x00\x00\x01\x86\x80\x80\x80\x00\x01\x60\x01\x7e\x01\x7e\x03\x84\x80\x80\x80\x00\x03\x00\x00\x00\x07\xa7\x80\x80\x80\x00\x03\x09\x65\x78\x74\x65\x6e\x64\x38\x5f\x73\x00\x00\x0a\x65\x78\x74\x65\x6e\x64\x31\x36\x5f\x73\x00\x01\x0a\x65\x78\x74\x65\x6e\x64\x33\x32\x5f\x73\x00\x02\x0a\x9f\x80\x80\x80\x00\x03\x85\x80\x80\x80\x00\x00\x20\x00\xc2\x0b\x85\x80\x80\x80\x00\x00\x20\x00\xc3\x0b\x85\x80\x80\x80\x00\x00\x20\x00\xc4\x0b");
// extend64.wast:9
run(() => call(instance("\x00\x61\x73\x6d\x01\x00\x00\x00\x01\x89\x80\x80\x80\x00\x02\x60\x00\x00\x60\x01\x7e\x01\x7e\x02\x90\x80\x80\x80\x00\x01\x02\x24\x31\x09\x65\x78\x74\x65\x6e\x64\x38\x5f\x73\x00\x01\x03\x82\x80\x80\x80\x00\x01\x00\x07\x87\x80\x80\x80\x00\x01\x03\x72\x75\x6e\x00\x01\x0a\x99\x80\x80\x80\x00\x01\x93\x80\x80\x80\x00\x00\x02\x40\x42\x00\x10\x00\x01\x42\x00\x01\x51\x45\x0d\x00\x0f\x0b\x00\x0b", exports("$1", $1)), "run", [])); // assert_return(() => call($1, "extend8_s", [int64("0")]), int64("0"))
// extend64.wast:10
run(() => call(instance("\x00\x61\x73\x6d\x01\x00\x00\x00\x01\x89\x80\x80\x80\x00\x02\x60\x00\x00\x60\x01\x7e\x01\x7e\x02\x90\x80\x80\x80\x00\x01\x02\x24\x31\x09\x65\x78\x74\x65\x6e\x64\x38\x5f\x73\x00\x01\x03\x82\x80\x80\x80\x00\x01\x00\x07\x87\x80\x80\x80\x00\x01\x03\x72\x75\x6e\x00\x01\x0a\x9b\x80\x80\x80\x00\x01\x95\x80\x80\x80\x00\x00\x02\x40\x42\xff\x00\x10\x00\x01\x42\xff\x00\x01\x51\x45\x0d\x00\x0f\x0b\x00\x0b", exports("$1", $1)), "run", [])); // assert_return(() => call($1, "extend8_s", [int64("127")]), int64("127"))
// extend64.wast:11
run(() => call(instance("\x00\x61\x73\x6d\x01\x00\x00\x00\x01\x89\x80\x80\x80\x00\x02\x60\x00\x00\x60\x01\x7e\x01\x7e\x02\x90\x80\x80\x80\x00\x01\x02\x24\x31\x09\x65\x78\x74\x65\x6e\x64\x38\x5f\x73\x00\x01\x03\x82\x80\x80\x80\x00\x01\x00\x07\x87\x80\x80\x80\x00\x01\x03\x72\x75\x6e\x00\x01\x0a\x9b\x80\x80\x80\x00\x01\x95\x80\x80\x80\x00\x00\x02\x40\x42\x80\x01\x10\x00\x01\x42\x80\x7f\x01\x51\x45\x0d\x00\x0f\x0b\x00\x0b", exports("$1", $1)), "run", [])); // assert_return(() => call($1, "extend8_s", [int64("128")]), int64("-128"))
// extend64.wast:12
run(() => call(instance("\x00\x61\x73\x6d\x01\x00\x00\x00\x01\x89\x80\x80\x80\x00\x02\x60\x00\x00\x60\x01\x7e\x01\x7e\x02\x90\x80\x80\x80\x00\x01\x02\x24\x31\x09\x65\x78\x74\x65\x6e\x64\x38\x5f\x73\x00\x01\x03\x82\x80\x80\x80\x00\x01\x00\x07\x87\x80\x80\x80\x00\x01\x03\x72\x75\x6e\x00\x01\x0a\x9a\x80\x80\x80\x00\x01\x94\x80\x80\x80\x00\x00\x02\x40\x42\xff\x01\x10\x00\x01\x42\x7f\x01\x51\x45\x0d\x00\x0f\x0b\x00\x0b", exports("$1", $1)), "run", [])); // assert_return(() => call($1, "extend8_s", [int64("255")]), int64("-1"))
// extend64.wast:13
run(() => call(instance("\x00\x61\x73\x6d\x01\x00\x00\x00\x01\x89\x80\x80\x80\x00\x02\x60\x00\x00\x60\x01\x7e\x01\x7e\x02\x90\x80\x80\x80\x00\x01\x02\x24\x31\x09\x65\x78\x74\x65\x6e\x64\x38\x5f\x73\x00\x01\x03\x82\x80\x80\x80\x00\x01\x00\x07\x87\x80\x80\x80\x00\x01\x03\x72\x75\x6e\x00\x01\x0a\xa1\x80\x80\x80\x00\x01\x9b\x80\x80\x80\x00\x00\x02\x40\x42\x80\x9a\xaf\xcd\xf8\xac\xd1\x91\x01\x10\x00\x01\x42\x00\x01\x51\x45\x0d\x00\x0f\x0b\x00\x0b", exports("$1", $1)), "run", [])); // assert_return(() => call($1, "extend8_s", [int64("81985529216486656")]), int64("0"))
// extend64.wast:14
run(() => call(instance("\x00\x61\x73\x6d\x01\x00\x00\x00\x01\x89\x80\x80\x80\x00\x02\x60\x00\x00\x60\x01\x7e\x01\x7e\x02\x90\x80\x80\x80\x00\x01\x02\x24\x31\x09\x65\x78\x74\x65\x6e\x64\x38\x5f\x73\x00\x01\x03\x82\x80\x80\x80\x00\x01\x00\x07\x87\x80\x80\x80\x00\x01\x03\x72\x75\x6e\x00\x01\x0a\xa2\x80\x80\x80\x00\x01\x9c\x80\x80\x80\x00\x00\x02\x40\x42\x80\xe5\xd0\xb2\x87\xd3\xae\xee\x7e\x10\x00\x01\x42\x80\x7f\x01\x51\x45\x0d\x00\x0f\x0b\x00\x0b", exports("$1", $1)), "run", [])); // assert_return(() => call($1, "extend8_s", [int64("-81985529216486784")]), int64("-128"))
// extend64.wast:15
run(() => call(instance("\x00\x61\x73\x6d\x01\x00\x00\x00\x01\x89\x80\x80\x80\x00\x02\x60\x00\x00\x60\x01\x7e\x01\x7e\x02\x90\x80\x80\x80\x00\x01\x02\x24\x31\x09\x65\x78\x74\x65\x6e\x64\x38\x5f\x73\x00\x01\x03\x82\x80\x80\x80\x00\x01\x00\x07\x87\x80\x80\x80\x00\x01\x03\x72\x75\x6e\x00\x01\x0a\x99\x80\x80\x80\x00\x01\x93\x80\x80\x80\x00\x00\x02\x40\x42\x7f\x10\x00\x01\x42\x7f\x01\x51\x45\x0d\x00\x0f\x0b\x00\x0b", exports("$1", $1)), "run", [])); // assert_return(() => call($1, "extend8_s", [int64("-1")]), int64("-1"))
// extend64.wast:17
run(() => call(instance("\x00\x61\x73\x6d\x01\x00\x00\x00\x01\x89\x80\x80\x80\x00\x02\x60\x00\x00\x60\x01\x7e\x01\x7e\x02\x91\x80\x80\x80\x00\x01\x02\x24\x31\x0a\x65\x78\x74\x65\x6e\x64\x31\x36\x5f\x73\x00\x01\x03\x82\x80\x80\x80\x00\x01\x00\x07\x87\x80\x80\x80\x00\x01\x03\x72\x75\x6e\x00\x01\x0a\x99\x80\x80\x80\x00\x01\x93\x80\x80\x80\x00\x00\x02\x40\x42\x00\x10\x00\x01\x42\x00\x01\x51\x45\x0d\x00\x0f\x0b\x00\x0b", exports("$1", $1)), "run", [])); // assert_return(() => call($1, "extend16_s", [int64("0")]), int64("0"))
// extend64.wast:18
run(() => call(instance("\x00\x61\x73\x6d\x01\x00\x00\x00\x01\x89\x80\x80\x80\x00\x02\x60\x00\x00\x60\x01\x7e\x01\x7e\x02\x91\x80\x80\x80\x00\x01\x02\x24\x31\x0a\x65\x78\x74\x65\x6e\x64\x31\x36\x5f\x73\x00\x01\x03\x82\x80\x80\x80\x00\x01\x00\x07\x87\x80\x80\x80\x00\x01\x03\x72\x75\x6e\x00\x01\x0a\x9d\x80\x80\x80\x00\x01\x97\x80\x80\x80\x00\x00\x02\x40\x42\xff\xff\x01\x10\x00\x01\x42\xff\xff\x01\x01\x51\x45\x0d\x00\x0f\x0b\x00\x0b", exports("$1", $1)), "run", [])); // assert_return(() => call($1, "extend16_s", [int64("32767")]), int64("32767"))
// extend64.wast:19
run(() => call(instance("\x00\x61\x73\x6d\x01\x00\x00\x00\x01\x89\x80\x80\x80\x00\x02\x60\x00\x00\x60\x01\x7e\x01\x7e\x02\x91\x80\x80\x80\x00\x01\x02\x24\x31\x0a\x65\x78\x74\x65\x6e\x64\x31\x36\x5f\x73\x00\x01\x03\x82\x80\x80\x80\x00\x01\x00\x07\x87\x80\x80\x80\x00\x01\x03\x72\x75\x6e\x00\x01\x0a\x9d\x80\x80\x80\x00\x01\x97\x80\x80\x80\x00\x00\x02\x40\x42\x80\x80\x02\x10\x00\x01\x42\x80\x80\x7e\x01\x51\x45\x0d\x00\x0f\x0b\x00\x0b", exports("$1", $1)), "run", [])); // assert_return(() => call($1, "extend16_s", [int64("32768")]), int64("-32768"))
// extend64.wast:20
run(() => call(instance("\x00\x61\x73\x6d\x01\x00\x00\x00\x01\x89\x80\x80\x80\x00\x02\x60\x00\x00\x60\x01\x7e\x01\x7e\x02\x91\x80\x80\x80\x00\x01\x02\x24\x31\x0a\x65\x78\x74\x65\x6e\x64\x31\x36\x5f\x73\x00\x01\x03\x82\x80\x80\x80\x00\x01\x00\x07\x87\x80\x80\x80\x00\x01\x03\x72\x75\x6e\x00\x01\x0a\x9b\x80\x80\x80\x00\x01\x95\x80\x80\x80\x00\x00\x02\x40\x42\xff\xff\x03\x10\x00\x01\x42\x7f\x01\x51\x45\x0d\x00\x0f\x0b\x00\x0b", exports("$1", $1)), "run", [])); // assert_return(() => call($1, "extend16_s", [int64("65535")]), int64("-1"))
// extend64.wast:21
run(() => call(instance("\x00\x61\x73\x6d\x01\x00\x00\x00\x01\x89\x80\x80\x80\x00\x02\x60\x00\x00\x60\x01\x7e\x01\x7e\x02\x91\x80\x80\x80\x00\x01\x02\x24\x31\x0a\x65\x78\x74\x65\x6e\x64\x31\x36\x5f\x73\x00\x01\x03\x82\x80\x80\x80\x00\x01\x00\x07\x87\x80\x80\x80\x00\x01\x03\x72\x75\x6e\x00\x01\x0a\xa1\x80\x80\x80\x00\x01\x9b\x80\x80\x80\x00\x00\x02\x40\x42\x80\x80\xf0\xd5\x89\xcf\x95\x9a\x12\x10\x00\x01\x42\x00\x01\x51\x45\x0d\x00\x0f\x0b\x00\x0b", exports("$1", $1)), "run", [])); // assert_return(() => call($1, "extend16_s", [int64("1311768467463733248")]), int64("0"))
// extend64.wast:22
run(() => call(instance("\x00\x61\x73\x6d\x01\x00\x00\x00\x01\x89\x80\x80\x80\x00\x02\x60\x00\x00\x60\x01\x7e\x01\x7e\x02\x91\x80\x80\x80\x00\x01\x02\x24\x31\x0a\x65\x78\x74\x65\x6e\x64\x31\x36\x5f\x73\x00\x01\x03\x82\x80\x80\x80\x00\x01\x00\x07\x87\x80\x80\x80\x00\x01\x03\x72\x75\x6e\x00\x01\x0a\xa3\x80\x80\x80\x00\x01\x9d\x80\x80\x80\x00\x00\x02\x40\x42\x80\x80\xd2\xb2\x87\xd3\xae\xee\x7e\x10\x00\x01\x42\x80\x80\x7e\x01\x51\x45\x0d\x00\x0f\x0b\x00\x0b", exports("$1", $1)), "run", [])); // assert_return(() => call($1, "extend16_s", [int64("-81985529216466944")]), int64("-32768"))
// extend64.wast:23
run(() => call(instance("\x00\x61\x73\x6d\x01\x00\x00\x00\x01\x89\x80\x80\x80\x00\x02\x60\x00\x00\x60\x01\x7e\x01\x7e\x02\x91\x80\x80\x80\x00\x01\x02\x24\x31\x0a\x65\x78\x74\x65\x6e\x64\x31\x36\x5f\x73\x00\x01\x03\x82\x80\x80\x80\x00\x01\x00\x07\x87\x80\x80\x80\x00\x01\x03\x72\x75\x6e\x00\x01\x0a\x99\x80\x80\x80\x00\x01\x93\x80\x80\x80\x00\x00\x02\x40\x42\x7f\x10\x00\x01\x42\x7f\x01\x51\x45\x0d\x00\x0f\x0b\x00\x0b", exports("$1", $1)), "run", [])); // assert_return(() => call($1, "extend16_s", [int64("-1")]), int64("-1"))
// extend64.wast:25
run(() => call(instance("\x00\x61\x73\x6d\x01\x00\x00\x00\x01\x89\x80\x80\x80\x00\x02\x60\x00\x00\x60\x01\x7e\x01\x7e\x02\x91\x80\x80\x80\x00\x01\x02\x24\x31\x0a\x65\x78\x74\x65\x6e\x64\x33\x32\x5f\x73\x00\x01\x03\x82\x80\x80\x80\x00\x01\x00\x07\x87\x80\x80\x80\x00\x01\x03\x72\x75\x6e\x00\x01\x0a\x99\x80\x80\x80\x00\x01\x93\x80\x80\x80\x00\x00\x02\x40\x42\x00\x10\x00\x01\x42\x00\x01\x51\x45\x0d\x00\x0f\x0b\x00\x0b", exports("$1", $1)), "run", [])); // assert_return(() => call($1, "extend32_s", [int64("0")]), int64("0"))
// extend64.wast:26
run(() => call(instance("\x00\x61\x73\x6d\x01\x00\x00\x00\x01\x89\x80\x80\x80\x00\x02\x60\x00\x00\x60\x01\x7e\x01\x7e\x02\x91\x80\x80\x80\x00\x01\x02\x24\x31\x0a\x65\x78\x74\x65\x6e\x64\x33\x32\x5f\x73\x00\x01\x03\x82\x80\x80\x80\x00\x01\x00\x07\x87\x80\x80\x80\x00\x01\x03\x72\x75\x6e\x00\x01\x0a\x9d\x80\x80\x80\x00\x01\x97\x80\x80\x80\x00\x00\x02\x40\x42\xff\xff\x01\x10\x00\x01\x42\xff\xff\x01\x01\x51\x45\x0d\x00\x0f\x0b\x00\x0b", exports("$1", $1)), "run", [])); // assert_return(() => call($1, "extend32_s", [int64("32767")]), int64("32767"))
// extend64.wast:27
run(() => call(instance("\x00\x61\x73\x6d\x01\x00\x00\x00\x01\x89\x80\x80\x80\x00\x02\x60\x00\x00\x60\x01\x7e\x01\x7e\x02\x91\x80\x80\x80\x00\x01\x02\x24\x31\x0a\x65\x78\x74\x65\x6e\x64\x33\x32\x5f\x73\x00\x01\x03\x82\x80\x80\x80\x00\x01\x00\x07\x87\x80\x80\x80\x00\x01\x03\x72\x75\x6e\x00\x01\x0a\x9d\x80\x80\x80\x00\x01\x97\x80\x80\x80\x00\x00\x02\x40\x42\x80\x80\x02\x10\x00\x01\x42\x80\x80\x02\x01\x51\x45\x0d\x00\x0f\x0b\x00\x0b", exports("$1", $1)), "run", [])); // assert_return(() => call($1, "extend32_s", [int64("32768")]), int64("32768"))
// extend64.wast:28
run(() => call(instance("\x00\x61\x73\x6d\x01\x00\x00\x00\x01\x89\x80\x80\x80\x00\x02\x60\x00\x00\x60\x01\x7e\x01\x7e\x02\x91\x80\x80\x80\x00\x01\x02\x24\x31\x0a\x65\x78\x74\x65\x6e\x64\x33\x32\x5f\x73\x00\x01\x03\x82\x80\x80\x80\x00\x01\x00\x07\x87\x80\x80\x80\x00\x01\x03\x72\x75\x6e\x00\x01\x0a\x9d\x80\x80\x80\x00\x01\x97\x80\x80\x80\x00\x00\x02\x40\x42\xff\xff\x03\x10\x00\x01\x42\xff\xff\x03\x01\x51\x45\x0d\x00\x0f\x0b\x00\x0b", exports("$1", $1)), "run", [])); // assert_return(() => call($1, "extend32_s", [int64("65535")]), int64("65535"))
// extend64.wast:29
run(() => call(instance("\x00\x61\x73\x6d\x01\x00\x00\x00\x01\x89\x80\x80\x80\x00\x02\x60\x00\x00\x60\x01\x7e\x01\x7e\x02\x91\x80\x80\x80\x00\x01\x02\x24\x31\x0a\x65\x78\x74\x65\x6e\x64\x33\x32\x5f\x73\x00\x01\x03\x82\x80\x80\x80\x00\x01\x00\x07\x87\x80\x80\x80\x00\x01\x03\x72\x75\x6e\x00\x01\x0a\xa1\x80\x80\x80\x00\x01\x9b\x80\x80\x80\x00\x00\x02\x40\x42\xff\xff\xff\xff\x07\x10\x00\x01\x42\xff\xff\xff\xff\x07\x01\x51\x45\x0d\x00\x0f\x0b\x00\x0b", exports("$1", $1)), "run", [])); // assert_return(() => call($1, "extend32_s", [int64("2147483647")]), int64("2147483647"))
// extend64.wast:30
run(() => call(instance("\x00\x61\x73\x6d\x01\x00\x00\x00\x01\x89\x80\x80\x80\x00\x02\x60\x00\x00\x60\x01\x7e\x01\x7e\x02\x91\x80\x80\x80\x00\x01\x02\x24\x31\x0a\x65\x78\x74\x65\x6e\x64\x33\x32\x5f\x73\x00\x01\x03\x82\x80\x80\x80\x00\x01\x00\x07\x87\x80\x80\x80\x00\x01\x03\x72\x75\x6e\x00\x01\x0a\xa1\x80\x80\x80\x00\x01\x9b\x80\x80\x80\x00\x00\x02\x40\x42\x80\x80\x80\x80\x08\x10\x00\x01\x42\x80\x80\x80\x80\x78\x01\x51\x45\x0d\x00\x0f\x0b\x00\x0b", exports("$1", $1)), "run", [])); // assert_return(() => call($1, "extend32_s", [int64("2147483648")]), int64("-2147483648"))
// extend64.wast:31
run(() => call(instance("\x00\x61\x73\x6d\x01\x00\x00\x00\x01\x89\x80\x80\x80\x00\x02\x60\x00\x00\x60\x01\x7e\x01\x7e\x02\x91\x80\x80\x80\x00\x01\x02\x24\x31\x0a\x65\x78\x74\x65\x6e\x64\x33\x32\x5f\x73\x00\x01\x03\x82\x80\x80\x80\x00\x01\x00\x07\x87\x80\x80\x80\x00\x01\x03\x72\x75\x6e\x00\x01\x0a\x9d\x80\x80\x80\x00\x01\x97\x80\x80\x80\x00\x00\x02\x40\x42\xff\xff\xff\xff\x0f\x10\x00\x01\x42\x7f\x01\x51\x45\x0d\x00\x0f\x0b\x00\x0b", exports("$1", $1)), "run", [])); // assert_return(() => call($1, "extend32_s", [int64("4294967295")]), int64("-1"))
// extend64.wast:32
run(() => call(instance("\x00\x61\x73\x6d\x01\x00\x00\x00\x01\x89\x80\x80\x80\x00\x02\x60\x00\x00\x60\x01\x7e\x01\x7e\x02\x91\x80\x80\x80\x00\x01\x02\x24\x31\x0a\x65\x78\x74\x65\x6e\x64\x33\x32\x5f\x73\x00\x01\x03\x82\x80\x80\x80\x00\x01\x00\x07\x87\x80\x80\x80\x00\x01\x03\x72\x75\x6e\x00\x01\x0a\xa1\x80\x80\x80\x00\x01\x9b\x80\x80\x80\x00\x00\x02\x40\x42\x80\x80\x80\x80\xf0\xac\xd1\x91\x01\x10\x00\x01\x42\x00\x01\x51\x45\x0d\x00\x0f\x0b\x00\x0b", exports("$1", $1)), "run", [])); // assert_return(() => call($1, "extend32_s", [int64("81985526906748928")]), int64("0"))
// extend64.wast:33
run(() => call(instance("\x00\x61\x73\x6d\x01\x00\x00\x00\x01\x89\x80\x80\x80\x00\x02\x60\x00\x00\x60\x01\x7e\x01\x7e\x02\x91\x80\x80\x80\x00\x01\x02\x24\x31\x0a\x65\x78\x74\x65\x6e\x64\x33\x32\x5f\x73\x00\x01\x03\x82\x80\x80\x80\x00\x01\x00\x07\x87\x80\x80\x80\x00\x01\x03\x72\x75\x6e\x00\x01\x0a\xa5\x80\x80\x80\x00\x01\x9f\x80\x80\x80\x00\x00\x02\x40\x42\x80\x80\x80\x80\x88\xd3\xae\xee\x7e\x10\x00\x01\x42\x80\x80\x80\x80\x78\x01\x51\x45\x0d\x00\x0f\x0b\x00\x0b", exports("$1", $1)), "run", [])); // assert_return(() => call($1, "extend32_s", [int64("-81985529054232576")]), int64("-2147483648"))
// extend64.wast:34
run(() => call(instance("\x00\x61\x73\x6d\x01\x00\x00\x00\x01\x89\x80\x80\x80\x00\x02\x60\x00\x00\x60\x01\x7e\x01\x7e\x02\x91\x80\x80\x80\x00\x01\x02\x24\x31\x0a\x65\x78\x74\x65\x6e\x64\x33\x32\x5f\x73\x00\x01\x03\x82\x80\x80\x80\x00\x01\x00\x07\x87\x80\x80\x80\x00\x01\x03\x72\x75\x6e\x00\x01\x0a\x99\x80\x80\x80\x00\x01\x93\x80\x80\x80\x00\x00\x02\x40\x42\x7f\x10\x00\x01\x42\x7f\x01\x51\x45\x0d\x00\x0f\x0b\x00\x0b", exports("$1", $1)), "run", [])); // assert_return(() => call($1, "extend32_s", [int64("-1")]), int64("-1"))

View File

@ -0,0 +1,23 @@
;; i32 sign extension operations
(module
(func (export "extend8_s") (param $x i32) (result i32) (i32.extend8_s (get_local $x)))
(func (export "extend16_s") (param $x i32) (result i32) (i32.extend16_s (get_local $x)))
)
(assert_return (invoke "extend8_s" (i32.const 0)) (i32.const 0))
(assert_return (invoke "extend8_s" (i32.const 0x7f)) (i32.const 127))
(assert_return (invoke "extend8_s" (i32.const 0x80)) (i32.const -128))
(assert_return (invoke "extend8_s" (i32.const 0xff)) (i32.const -1))
(assert_return (invoke "extend8_s" (i32.const 0x012345_00)) (i32.const 0))
(assert_return (invoke "extend8_s" (i32.const 0xfedcba_80)) (i32.const -0x80))
(assert_return (invoke "extend8_s" (i32.const -1)) (i32.const -1))
(assert_return (invoke "extend16_s" (i32.const 0)) (i32.const 0))
(assert_return (invoke "extend16_s" (i32.const 0x7fff)) (i32.const 32767))
(assert_return (invoke "extend16_s" (i32.const 0x8000)) (i32.const -32768))
(assert_return (invoke "extend16_s" (i32.const 0xffff)) (i32.const -1))
(assert_return (invoke "extend16_s" (i32.const 0x0123_0000)) (i32.const 0))
(assert_return (invoke "extend16_s" (i32.const 0xfedc_8000)) (i32.const -0x8000))
(assert_return (invoke "extend16_s" (i32.const -1)) (i32.const -1))

View File

@ -0,0 +1,34 @@
;; i64 sign extension operations
(module
(func (export "extend8_s") (param $x i64) (result i64) (i64.extend8_s (get_local $x)))
(func (export "extend16_s") (param $x i64) (result i64) (i64.extend16_s (get_local $x)))
(func (export "extend32_s") (param $x i64) (result i64) (i64.extend32_s (get_local $x)))
)
(assert_return (invoke "extend8_s" (i64.const 0)) (i64.const 0))
(assert_return (invoke "extend8_s" (i64.const 0x7f)) (i64.const 127))
(assert_return (invoke "extend8_s" (i64.const 0x80)) (i64.const -128))
(assert_return (invoke "extend8_s" (i64.const 0xff)) (i64.const -1))
(assert_return (invoke "extend8_s" (i64.const 0x01234567_89abcd_00)) (i64.const 0))
(assert_return (invoke "extend8_s" (i64.const 0xfedcba98_765432_80)) (i64.const -0x80))
(assert_return (invoke "extend8_s" (i64.const -1)) (i64.const -1))
(assert_return (invoke "extend16_s" (i64.const 0)) (i64.const 0))
(assert_return (invoke "extend16_s" (i64.const 0x7fff)) (i64.const 32767))
(assert_return (invoke "extend16_s" (i64.const 0x8000)) (i64.const -32768))
(assert_return (invoke "extend16_s" (i64.const 0xffff)) (i64.const -1))
(assert_return (invoke "extend16_s" (i64.const 0x12345678_9abc_0000)) (i64.const 0))
(assert_return (invoke "extend16_s" (i64.const 0xfedcba98_7654_8000)) (i64.const -0x8000))
(assert_return (invoke "extend16_s" (i64.const -1)) (i64.const -1))
(assert_return (invoke "extend32_s" (i64.const 0)) (i64.const 0))
(assert_return (invoke "extend32_s" (i64.const 0x7fff)) (i64.const 32767))
(assert_return (invoke "extend32_s" (i64.const 0x8000)) (i64.const 32768))
(assert_return (invoke "extend32_s" (i64.const 0xffff)) (i64.const 65535))
(assert_return (invoke "extend32_s" (i64.const 0x7fffffff)) (i64.const 0x7fffffff))
(assert_return (invoke "extend32_s" (i64.const 0x80000000)) (i64.const -0x80000000))
(assert_return (invoke "extend32_s" (i64.const 0xffffffff)) (i64.const -1))
(assert_return (invoke "extend32_s" (i64.const 0x01234567_00000000)) (i64.const 0))
(assert_return (invoke "extend32_s" (i64.const 0xfedcba98_80000000)) (i64.const -0x80000000))
(assert_return (invoke "extend32_s" (i64.const -1)) (i64.const -1))

View File

@ -13355,9 +13355,9 @@ CodeGenerator::visitFinishBoundFunctionInit(LFinishBoundFunctionInit* lir)
Label notBoundTarget, loadName;
masm.branchTest32(Assembler::Zero, temp1, Imm32(JSFunction::BOUND_FUN), &notBoundTarget);
{
// Target's name atom doesn't contain the bound function prefix, so we
// need to call into the VM.
masm.branchTest32(Assembler::Zero, temp1,
// Call into the VM if the target's name atom contains the bound
// function prefix.
masm.branchTest32(Assembler::NonZero, temp1,
Imm32(JSFunction::HAS_BOUND_FUNCTION_NAME_PREFIX), slowPath);
// We also take the slow path when target's length isn't an int32.

View File

@ -2413,24 +2413,18 @@ DoTypeMonitorFallback(JSContext* cx, BaselineFrame* frame, ICTypeMonitor_Fallbac
return true;
}
// Note: ideally we would merge this if-else statement with the one below,
// but that triggers an MSVC 2015 compiler bug. See bug 1363054.
StackTypeSet* types;
uint32_t argument;
if (stub->monitorsArgument(&argument))
types = TypeScript::ArgTypes(script, argument);
else if (stub->monitorsThis())
types = TypeScript::ThisTypes(script);
else
types = TypeScript::BytecodeTypes(script, pc);
if (stub->monitorsArgument(&argument)) {
MOZ_ASSERT(pc == script->code());
types = TypeScript::ArgTypes(script, argument);
TypeScript::SetArgument(cx, script, argument, value);
} else if (stub->monitorsThis()) {
MOZ_ASSERT(pc == script->code());
types = TypeScript::ThisTypes(script);
TypeScript::SetThis(cx, script, value);
} else {
types = TypeScript::BytecodeTypes(script, pc);
TypeScript::Monitor(cx, script, pc, types, value);
}

View File

@ -359,6 +359,7 @@ MacroAssembler::sub32FromStackPtrWithPatch(Register dest)
{
vixl::UseScratchRegisterScope temps(this);
const ARMRegister scratch = temps.AcquireX();
AutoForbidPools afp(this, /* max number of instructions in scope = */ 3);
CodeOffset offs = CodeOffset(currentOffset());
movz(scratch, 0, 0);
movk(scratch, 0, 16);

View File

@ -707,6 +707,7 @@ MacroAssembler::patchFarJump(CodeOffset farJump, uint32_t targetOffset)
CodeOffset
MacroAssembler::nopPatchableToCall(const wasm::CallSiteDesc& desc)
{
AutoForbidPools afp(this, /* max number of instructions in scope = */ 1);
CodeOffset offset(currentOffset());
Nop();
append(desc, CodeOffset(currentOffset()));
@ -1077,6 +1078,7 @@ MacroAssembler::comment(const char* msg)
CodeOffset
MacroAssembler::wasmTrapInstruction()
{
AutoForbidPools afp(this, /* max number of instructions in scope = */ 1);
CodeOffset offs(currentOffset());
Unreachable();
return offs;

View File

@ -156,6 +156,7 @@ if CONFIG['JS_BUILD_BINAST'] and CONFIG['JS_STANDALONE']:
DEFINES['EXPORT_JS_API'] = True
DEFINES['ENABLE_WASM_GLOBAL'] = True
LOCAL_INCLUDES += [
'!..',

View File

@ -3965,7 +3965,6 @@ JS::TransitiveCompileOptions::copyPODTransitiveOptions(const TransitiveCompileOp
canLazilyParse = rhs.canLazilyParse;
strictOption = rhs.strictOption;
extraWarningsOption = rhs.extraWarningsOption;
expressionClosuresOption = rhs.expressionClosuresOption;
werrorOption = rhs.werrorOption;
asmJSOption = rhs.asmJSOption;
throwOnAsmJSValidationFailureOption = rhs.throwOnAsmJSValidationFailureOption;
@ -4088,7 +4087,6 @@ JS::CompileOptions::CompileOptions(JSContext* cx)
{
strictOption = cx->options().strictMode();
extraWarningsOption = cx->compartment()->behaviors().extraWarnings(cx);
expressionClosuresOption = cx->options().expressionClosures();
isProbablySystemCode = cx->compartment()->isProbablySystemCode();
werrorOption = cx->options().werror();
if (!cx->options().asmJS())

View File

@ -990,7 +990,6 @@ class JS_PUBLIC_API(ContextOptions) {
#ifdef FUZZING
, fuzzing_(false)
#endif
, expressionClosures_(false)
, arrayProtoValues_(true)
{
}
@ -1147,12 +1146,6 @@ class JS_PUBLIC_API(ContextOptions) {
}
#endif
bool expressionClosures() const { return expressionClosures_; }
ContextOptions& setExpressionClosures(bool flag) {
expressionClosures_ = flag;
return *this;
}
bool arrayProtoValues() const { return arrayProtoValues_; }
ContextOptions& setArrayProtoValues(bool flag) {
arrayProtoValues_ = flag;
@ -1189,7 +1182,6 @@ class JS_PUBLIC_API(ContextOptions) {
#ifdef FUZZING
bool fuzzing_ : 1;
#endif
bool expressionClosures_ : 1;
bool arrayProtoValues_ : 1;
};
@ -3591,7 +3583,6 @@ class JS_FRIEND_API(TransitiveCompileOptions)
canLazilyParse(true),
strictOption(false),
extraWarningsOption(false),
expressionClosuresOption(false),
werrorOption(false),
asmJSOption(AsmJSOption::Disabled),
throwOnAsmJSValidationFailureOption(false),
@ -3627,7 +3618,6 @@ class JS_FRIEND_API(TransitiveCompileOptions)
bool canLazilyParse;
bool strictOption;
bool extraWarningsOption;
bool expressionClosuresOption;
bool werrorOption;
AsmJSOption asmJSOption;
bool throwOnAsmJSValidationFailureOption;

View File

@ -28,23 +28,6 @@
#define js_copysign copysign
#endif
/* Consistency wrapper for platform deviations in fmod() */
static inline double
js_fmod(double d, double d2)
{
#ifdef XP_WIN
/*
* Workaround MS fmod bug where 42 % (1/0) => NaN, not 42.
* Workaround MS fmod bug where -0 % -N => 0, not -0.
*/
if ((mozilla::IsFinite(d) && mozilla::IsInfinite(d2)) ||
(d == 0 && mozilla::IsFinite(d2))) {
return d;
}
#endif
return fmod(d, d2);
}
namespace js {
inline double
@ -52,13 +35,8 @@ NumberDiv(double a, double b)
{
AutoUnsafeCallWithABI unsafe;
if (b == 0) {
if (a == 0 || mozilla::IsNaN(a)
#ifdef XP_WIN
|| mozilla::IsNaN(b) /* XXX MSVC miscompiles such that (NaN == 0) */
#endif
)
if (a == 0 || mozilla::IsNaN(a))
return JS::GenericNaN();
if (mozilla::IsNegative(a) != mozilla::IsNegative(b))
return mozilla::NegativeInfinity<double>();
return mozilla::PositiveInfinity<double>();
@ -73,7 +51,7 @@ NumberMod(double a, double b)
AutoUnsafeCallWithABI unsafe;
if (b == 0)
return JS::GenericNaN();
return js_fmod(a, b);
return fmod(a, b);
}
} // namespace js

View File

@ -896,12 +896,6 @@ double
js::math_sin_uncached(double x)
{
AutoUnsafeCallWithABI unsafe;
#ifdef _WIN64
// Workaround MSVC bug where sin(-0) is +0 instead of -0 on x64 on
// CPUs without FMA3 (pre-Haswell). See bug 1076670.
if (IsNegativeZero(x))
return -0.0;
#endif
return sin(x);
}

View File

@ -18,6 +18,7 @@ UNIFIED_SOURCES += [
]
DEFINES['EXPORT_JS_API'] = True
DEFINES['ENABLE_WASM_GLOBAL'] = True
# Also set in ../moz.build
DEFINES['ENABLE_SHARED_ARRAY_BUFFER'] = True

View File

@ -1,83 +0,0 @@
// |reftest| skip-if(!xulRuntime.shell)
/* 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/. */
// ArrowFunctions with block bodies appearing at the end of the
// AssignmentExpression returned by SpiderMonkey-specific function expression
// closures, where subsequent token-examination must use the Operand modifier
// to avoid an assertion.
enableExpressionClosures();
eval(`
var ec1 = function() 0 ? 1 : a => {};
assertEq(typeof ec1, "function");
assertEq(typeof ec1(), "function");
assertEq(ec1()(), undefined);
function inFunction1()
{
var ec1f = function() 0 ? 1 : a => {};
assertEq(typeof ec1f, "function");
assertEq(typeof ec1f(), "function");
assertEq(ec1f()(), undefined);
}
inFunction1();
var ec2 = function() 0 ? 1 : a => {} // deliberately exercise ASI here
assertEq(typeof ec2, "function");
assertEq(typeof ec2(), "function");
assertEq(ec2()(), undefined);
function inFunction2()
{
var ec2f = function() 0 ? 1 : a => {} // deliberately exercise ASI here
assertEq(typeof ec2f, "function");
assertEq(typeof ec2f(), "function");
assertEq(ec2f()(), undefined);
}
inFunction2();
function ec3() 0 ? 1 : a => {} // exercise ASI here
assertEq(typeof ec3(), "function");
function inFunction3()
{
function ec3f() 0 ? 1 : a => {} // exercise ASI here
assertEq(typeof ec3f(), "function");
}
inFunction3();
function ec4() 0 ? 1 : a => {};
assertEq(typeof ec4(), "function");
function inFunction4()
{
function ec4f() 0 ? 1 : a => {};
assertEq(typeof ec4f(), "function");
}
var needle = "@";
var x = 42;
var g = { test() { assertEq(true, false, "shouldn't be called"); } };
function ec5() 0 ? 1 : a => {} // ASI
/x/g.test((needle = "x"));
assertEq(needle, "x");
function inFunction5()
{
var needle = "@";
var x = 42;
var g = { test() { assertEq(true, false, "shouldn't be called"); } };
function ec5f() 0 ? 1 : a => {} // ASI
/x/g.test((needle = "x"));
assertEq(needle, "x");
}
inFunction5();
`);
if (typeof reportCompare === "function")
reportCompare(true, true);

View File

@ -1,28 +0,0 @@
// |reftest| skip-if(!xulRuntime.shell)
/* -*- indent-tabs-mode: nil; js-indent-level: 4 -*- */
/*
* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/licenses/publicdomain/
* Contributor: Brendan Eich
*/
var summary = "Flat expression closure source coordinate fencepost test";
enableExpressionClosures();
eval(`
function f(a) {
if (a) {
let b = 42;
let c = function () a+b;
++b;
return c;
}
return null;
}
var expect = 44;
var actual = f(1)();
`);
reportCompare(expect, actual, summary);

View File

@ -1,28 +0,0 @@
// |reftest| skip-if(!xulRuntime.shell)
/* -*- indent-tabs-mode: nil; js-indent-level: 4 -*- */
/*
* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/licenses/publicdomain/
* Contributor: Brendan Eich
*/
var summary = "Partial flat expression closure upvar order test";
enableExpressionClosures();
eval(`
function f(a) {
if (a) {
let b = 42;
let c = function () b+a;
++b;
return c;
}
return null;
}
var expect = 44;
var actual = f(1)();
`);
reportCompare(expect, actual, summary);

View File

@ -1,13 +0,0 @@
// |reftest| skip-if(!xulRuntime.shell)
function test() {
// expression closures
enableExpressionClosures();
assertDecl("function inc(x) (x + 1)", funDecl(ident("inc"), [ident("x")], binExpr("+", ident("x"), lit(1))));
assertExpr("(function(x) (x+1))", funExpr(null, [ident("x")], binExpr("+", ident("x"), lit(1))));
}
runtest(test);

View File

@ -1,36 +0,0 @@
// |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
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//-----------------------------------------------------------------------------
var BUGNUMBER = 384758;
var summary = 'Statement can not follow expression closure with out intervening ;';
var actual = '';
var expect = '';
//-----------------------------------------------------------------------------
test();
//-----------------------------------------------------------------------------
function test()
{
printBugNumber(BUGNUMBER);
printStatus (summary);
enableExpressionClosures();
expect = 'SyntaxError: unexpected token: identifier';
try
{
eval('(function() { if(t) function x() foo() bar(); })');
}
catch(ex)
{
actual = ex + '';
}
reportCompare(expect, actual, summary);
}

View File

@ -312,11 +312,7 @@ js_dtobasestr(DtoaState* state, int base, double dinput)
return nullptr;
p = buffer;
if (dval(d) < 0.0
#if defined(XP_WIN)
&& !((word0(d) & Exp_mask) == Exp_mask && ((word0(d) & Frac_mask) || word1(d))) /* Visual C++ doesn't know how to compare against NaN */
#endif
) {
if (dval(d) < 0.0) {
*p++ = '-';
dval(d) = -dval(d);
}

View File

@ -60,6 +60,7 @@ using namespace js::gc;
using namespace js::frontend;
using mozilla::ArrayLength;
using mozilla::CheckedInt;
using mozilla::Maybe;
using mozilla::Some;
@ -537,7 +538,7 @@ fun_resolve(JSContext* cx, HandleObject obj, HandleId id, bool* resolvedp)
if (fun->hasResolvedName())
return true;
RootedAtom name(cx);
RootedString name(cx);
if (!JSFunction::getUnresolvedName(cx, fun, &name))
return false;
@ -1032,12 +1033,15 @@ js::FunctionToString(JSContext* cx, HandleFunction fun, bool isToSource)
if (fun->explicitName()) {
if (!out.append(' '))
return nullptr;
if (fun->isBoundFunction() && !fun->hasBoundFunctionNamePrefix()) {
if (!out.append(cx->names().boundWithSpace))
if (fun->isBoundFunction()) {
JSLinearString* boundName = JSFunction::getBoundFunctionName(cx, fun);
if (!boundName || !out.append(boundName))
return nullptr;
} else {
if (!out.append(fun->explicitName()))
return nullptr;
}
if (!out.append(fun->explicitName()))
return nullptr;
}
if (fun->isInterpreted() &&
@ -1321,41 +1325,90 @@ JSFunction::getUnresolvedLength(JSContext* cx, HandleFunction fun, MutableHandle
return true;
}
/* static */ bool
JSFunction::getUnresolvedName(JSContext* cx, HandleFunction fun, MutableHandleAtom v)
JSAtom*
JSFunction::infallibleGetUnresolvedName(JSContext* cx)
{
MOZ_ASSERT(!IsInternalFunctionObject(*fun));
MOZ_ASSERT(!fun->hasResolvedName());
MOZ_ASSERT(!IsInternalFunctionObject(*this));
MOZ_ASSERT(!hasResolvedName());
JSAtom* name = fun->explicitOrInferredName();
if (fun->isClassConstructor()) {
// Unnamed class expressions should not get a .name property at all.
if (name)
v.set(name);
if (JSAtom* name = explicitOrInferredName())
return name;
// Unnamed class expressions should not get a .name property at all.
if (isClassConstructor())
return nullptr;
return cx->names().empty;
}
/* static */ bool
JSFunction::getUnresolvedName(JSContext* cx, HandleFunction fun, MutableHandleString v)
{
if (fun->isBoundFunction()) {
JSLinearString* name = JSFunction::getBoundFunctionName(cx, fun);
if (!name)
return false;
v.set(name);
return true;
}
if (fun->isBoundFunction() && !fun->hasBoundFunctionNamePrefix()) {
// Bound functions are never unnamed.
MOZ_ASSERT(name);
v.set(fun->infallibleGetUnresolvedName(cx));
return true;
}
if (name->length() > 0) {
StringBuffer sb(cx);
if (!sb.append(cx->names().boundWithSpace) || !sb.append(name))
return false;
/* static */ JSLinearString*
JSFunction::getBoundFunctionName(JSContext* cx, HandleFunction fun)
{
MOZ_ASSERT(fun->isBoundFunction());
JSAtom* name = fun->explicitName();
name = sb.finishAtom();
if (!name)
return false;
} else {
name = cx->names().boundWithSpace;
}
// Bound functions are never unnamed.
MOZ_ASSERT(name);
fun->setPrefixedBoundFunctionName(name);
// If the bound function prefix is present, return the name as is.
if (fun->hasBoundFunctionNamePrefix())
return name;
// Otherwise return "bound " * (number of bound function targets) + name.
size_t boundTargets = 0;
for (JSFunction* boundFn = fun; boundFn->isBoundFunction(); ) {
boundTargets++;
JSObject* target = boundFn->getBoundFunctionTarget();
if (!target->is<JSFunction>())
break;
boundFn = &target->as<JSFunction>();
}
v.set(name != nullptr ? name : cx->names().empty);
return true;
// |function /*unnamed*/ (){...}.bind()| is a common case, handle it here.
if (name->empty() && boundTargets == 1)
return cx->names().boundWithSpace;
static constexpr char boundWithSpaceChars[] = "bound ";
static constexpr size_t boundWithSpaceCharsLength =
ArrayLength(boundWithSpaceChars) - 1; // No trailing '\0'.
MOZ_ASSERT(StringEqualsAscii(cx->names().boundWithSpace, boundWithSpaceChars));
StringBuffer sb(cx);
if (name->hasTwoByteChars() && !sb.ensureTwoByteChars())
return nullptr;
CheckedInt<size_t> len(boundTargets);
len *= boundWithSpaceCharsLength;
len += name->length();
if (!len.isValid()) {
ReportAllocationOverflow(cx);
return nullptr;
}
if (!sb.reserve(len.value()))
return nullptr;
while (boundTargets--)
sb.infallibleAppend(boundWithSpaceChars, boundWithSpaceCharsLength);
sb.infallibleAppendSubstring(name, 0, name->length());
return sb.finishString();
}
static const js::Value&
@ -1401,6 +1454,18 @@ JSFunction::getBoundFunctionArgumentCount() const
return GetBoundFunctionArguments(this)->length();
}
static JSAtom*
AppendBoundFunctionPrefix(JSContext* cx, JSString* str)
{
static constexpr char boundWithSpaceChars[] = "bound ";
MOZ_ASSERT(StringEqualsAscii(cx->names().boundWithSpace, boundWithSpaceChars));
StringBuffer sb(cx);
if (!sb.append(boundWithSpaceChars) || !sb.append(str))
return nullptr;
return sb.finishAtom();
}
/* static */ bool
JSFunction::finishBoundFunctionInit(JSContext* cx, HandleFunction bound, HandleObject targetObj,
int32_t argCount)
@ -1457,11 +1522,26 @@ JSFunction::finishBoundFunctionInit(JSContext* cx, HandleFunction bound, HandleO
// 19.2.3.2 Function.prototype.bind, step 8.
bound->setExtendedSlot(BOUND_FUN_LENGTH_SLOT, NumberValue(length));
MOZ_ASSERT(!bound->hasGuessedAtom());
// Try to avoid invoking the resolve hook.
RootedAtom name(cx);
JSAtom* name = nullptr;
if (targetObj->is<JSFunction>() && !targetObj->as<JSFunction>().hasResolvedName()) {
if (!JSFunction::getUnresolvedName(cx, targetObj.as<JSFunction>(), &name))
return false;
JSFunction* targetFn = &targetObj->as<JSFunction>();
// If the target is a bound function with a prefixed name, we can't
// lazily compute the full name in getBoundFunctionName(), therefore
// we need to append the bound function name prefix here.
if (targetFn->isBoundFunction() && targetFn->hasBoundFunctionNamePrefix()) {
name = AppendBoundFunctionPrefix(cx, targetFn->explicitName());
if (!name)
return false;
bound->setPrefixedBoundFunctionName(name);
} else {
name = targetFn->infallibleGetUnresolvedName(cx);
if (name)
bound->setAtom(name);
}
}
// 19.2.3.2 Function.prototype.bind, steps 9-11.
@ -1472,18 +1552,26 @@ JSFunction::finishBoundFunctionInit(JSContext* cx, HandleFunction bound, HandleO
return false;
// 19.2.3.2 Function.prototype.bind, step 10.
if (targetName.isString() && !targetName.toString()->empty()) {
if (!targetName.isString())
targetName.setString(cx->names().empty);
// If the target itself is a bound function (with a resolved name), we
// can't compute the full name in getBoundFunctionName() based only on
// the number of bound target functions, therefore we need to store
// the complete prefixed name here.
if (targetObj->is<JSFunction>() && targetObj->as<JSFunction>().isBoundFunction()) {
name = AppendBoundFunctionPrefix(cx, targetName.toString());
if (!name)
return false;
bound->setPrefixedBoundFunctionName(name);
} else {
name = AtomizeString(cx, targetName.toString());
if (!name)
return false;
} else {
name = cx->names().empty;
bound->setAtom(name);
}
}
MOZ_ASSERT(!bound->hasGuessedAtom());
bound->setAtom(name);
return true;
}

View File

@ -341,8 +341,12 @@ class JSFunction : public js::NativeObject
static bool getUnresolvedLength(JSContext* cx, js::HandleFunction fun,
js::MutableHandleValue v);
JSAtom* infallibleGetUnresolvedName(JSContext* cx);
static bool getUnresolvedName(JSContext* cx, js::HandleFunction fun,
js::MutableHandleAtom v);
js::MutableHandleString v);
static JSLinearString* getBoundFunctionName(JSContext* cx, js::HandleFunction fun);
JSAtom* explicitName() const {
return (hasInferredName() || hasGuessedAtom()) ? nullptr : atom_.get();

View File

@ -2154,13 +2154,14 @@ WasmGlobalObject::valueSetter(JSContext* cx, unsigned argc, Value* vp)
const JSPropertySpec WasmGlobalObject::properties[] =
{
JS_PSGS("value", WasmGlobalObject::valueGetter, WasmGlobalObject::valueSetter, 0),
JS_PSGS("value", WasmGlobalObject::valueGetter, WasmGlobalObject::valueSetter,
JSPROP_ENUMERATE),
JS_PS_END
};
const JSFunctionSpec WasmGlobalObject::methods[] =
{
JS_SYM_FN(toPrimitive, WasmGlobalObject::valueGetter, 1, JSPROP_READONLY),
JS_FN(js_valueOf_str, WasmGlobalObject::valueGetter, 0, 0),
JS_FS_END
};

View File

@ -5624,7 +5624,7 @@ nsFrame::ComputeSize(gfxContext* aRenderingContext,
// This bool only gets set (and used) if isFlexItem is true.
// It indicates (for flex items) whether we're using their flex-basis for the
// item's own ISize property vs. for its BSize property.
bool usingFlexBasisForISize;
bool usingFlexBasisForISize = false;
if (isFlexItem) {
// Flex items use their "flex-basis" property in place of their main-size
// property (e.g. "width") for sizing purposes, *unless* they have
@ -5870,7 +5870,7 @@ nsFrame::ComputeSizeWithIntrinsicDimensions(gfxContext* aRenderingConte
// This bool only gets set (and used) if isFlexItem is true.
// It indicates (for flex items) whether we're using their flex-basis for the
// item's own ISize property vs. for its BSize property.
bool usingFlexBasisForISize;
bool usingFlexBasisForISize = false;
Maybe<nsStyleCoord> imposedMainSizeStyleCoord;
// If this is a flex item, and we're measuring its cross size after flexing

View File

@ -186,6 +186,7 @@ TestFull(const char* aTestName, int aNum, const char* aMode, int aSeven)
// Analyze 1: freed, irrelevant.
// Analyze 2: freed, irrelevant.
char* f1 = (char*) malloc(64);
UseItOrLoseIt(f1, aSeven);
free(f1);
// Analyze 1: ignored.
@ -262,7 +263,9 @@ TestFull(const char* aTestName, int aNum, const char* aMode, int aSeven)
// Do some allocations that will only show up in cumulative mode.
for (int i = 0; i < 100; i++) {
free(malloc(128));
void* v = malloc(128);
UseItOrLoseIt(v, aSeven);
free(v);
}
if (aNum == 2) {

View File

@ -44,7 +44,7 @@ fundamental problem with a loaded module.
Please consider filing a bug against mach by going to the URL:
https://bugzilla.mozilla.org/enter_bug.cgi?product=Core&component=mach
https://bugzilla.mozilla.org/enter_bug.cgi?product=Firefox%20Build%20System&component=Mach%20Core
'''.lstrip()

View File

@ -98,6 +98,7 @@ def build_dict(config, env=os.environ):
d['updater'] = substs.get('MOZ_UPDATER') == '1'
d['artifact'] = substs.get('MOZ_ARTIFACT_BUILDS') == '1'
d['ccov'] = substs.get('MOZ_CODE_COVERAGE') == '1'
d['cc_type'] = substs.get('CC_TYPE')
def guess_platform():
if d['buildapp'] in ('browser', 'mulet'):

View File

@ -368,3 +368,12 @@ add_task(async function test_can_upload() {
BrowserTestUtils.removeTab(newTab);
Services.perms.remove(testHttpsUri, HC_PERMISSION);
});
add_task(async function test_hct_for_discopane() {
const discoHost = "https://discovery.addons.mozilla.org";
let discoHttpsUri = Services.io.newURI(discoHost);
let permission = Services.perms.testPermission(discoHttpsUri, HC_PERMISSION);
ok(permission == Services.perms.ALLOW_ACTION, "Disco Pane needs Hybrid Content Permission for Telemetry data upload");
});

View File

@ -5,4 +5,4 @@ skip-if = os != "win" || (os == "win" && os_version == "10.0") # Bug 1401250
[browser_checkcfgstatus.js]
# CFG is only supported on MSVC-compiled Windows 10+, only run it there
skip-if = ccov || os != "win" || os_version == "6.1" || os_version == "6.3"
skip-if = cc_type != "msvc" || os != "win" || os_version == "6.1" || os_version == "6.3"

View File

@ -332,10 +332,11 @@ VsizeMaxContiguousDistinguishedAmount(int64_t* aN)
#include <unistd.h>
static void
XMappingIter(int64_t& aVsize, int64_t& aResident)
XMappingIter(int64_t& aVsize, int64_t& aResident, int64_t& aShared)
{
aVsize = -1;
aResident = -1;
aShared = -1;
int mapfd = open("/proc/self/xmap", O_RDONLY);
struct stat st;
prxmap_t* prmapp = nullptr;
@ -359,9 +360,13 @@ XMappingIter(int64_t& aVsize, int64_t& aResident)
if (nmap >= n / sizeof(prxmap_t)) {
aVsize = 0;
aResident = 0;
aShared = 0;
for (int i = 0; i < n / sizeof(prxmap_t); i++) {
aVsize += prmapp[i].pr_size;
aResident += prmapp[i].pr_rss * prmapp[i].pr_pagesize;
if (prmapp[i].pr_mflags & MA_SHARED) {
aShared += prmapp[i].pr_rss * prmapp[i].pr_pagesize;
}
}
break;
}
@ -377,8 +382,8 @@ XMappingIter(int64_t& aVsize, int64_t& aResident)
static MOZ_MUST_USE nsresult
VsizeDistinguishedAmount(int64_t* aN)
{
int64_t vsize, resident;
XMappingIter(vsize, resident);
int64_t vsize, resident, shared;
XMappingIter(vsize, resident, shared);
if (vsize == -1) {
return NS_ERROR_FAILURE;
}
@ -389,8 +394,8 @@ VsizeDistinguishedAmount(int64_t* aN)
static MOZ_MUST_USE nsresult
ResidentDistinguishedAmount(int64_t* aN)
{
int64_t vsize, resident;
XMappingIter(vsize, resident);
int64_t vsize, resident, shared;
XMappingIter(vsize, resident, shared);
if (resident == -1) {
return NS_ERROR_FAILURE;
}
@ -404,6 +409,19 @@ ResidentFastDistinguishedAmount(int64_t* aN)
return ResidentDistinguishedAmount(aN);
}
#define HAVE_RESIDENT_UNIQUE_REPORTER 1
static MOZ_MUST_USE nsresult
ResidentUniqueDistinguishedAmount(int64_t* aN)
{
int64_t vsize, resident, shared;
XMappingIter(vsize, resident, shared);
if (resident == -1) {
return NS_ERROR_FAILURE;
}
*aN = resident - shared;
return NS_OK;
}
#elif defined(XP_MACOSX)
#include <mach/mach_init.h>

View File

@ -415,6 +415,11 @@ nsDirectoryService::GetFile(const char* aProp, bool* aPersistent,
RefPtr<nsAtom> inAtom = NS_Atomize(aProp);
// Check that nsGkAtoms::Home matches the value that sOS_HomeDirectory would
// have if it wasn't commented out to avoid static atom duplication.
MOZ_ASSERT(
NS_strcmp(nsGkAtoms::Home->GetUTF16String(), u"" NS_OS_HOME_DIR) == 0);
// check to see if it is one of our defaults
if (inAtom == nsDirectoryService::sCurrentProcess ||
@ -462,7 +467,7 @@ nsDirectoryService::GetFile(const char* aProp, bool* aPersistent,
rv = GetOSXFolderType(kClassicDomain, kInternetSearchSitesFolderType, getter_AddRefs(localFile));
} else if (inAtom == nsDirectoryService::sUserLibDirectory) {
rv = GetOSXFolderType(kUserDomain, kDomainLibraryFolderType, getter_AddRefs(localFile));
} else if (inAtom == nsDirectoryService::sOS_HomeDirectory) {
} else if (inAtom == nsGkAtoms::Home) {
rv = GetOSXFolderType(kUserDomain, kDomainTopLevelFolderType, getter_AddRefs(localFile));
} else if (inAtom == nsDirectoryService::sDefaultDownloadDirectory) {
// 10.5 and later, we can use kDownloadsFolderType which is defined in
@ -520,7 +525,7 @@ nsDirectoryService::GetFile(const char* aProp, bool* aPersistent,
rv = GetSpecialSystemDirectory(Win_WindowsDirectory, getter_AddRefs(localFile));
} else if (inAtom == nsDirectoryService::sWindowsProgramFiles) {
rv = GetSpecialSystemDirectory(Win_ProgramFiles, getter_AddRefs(localFile));
} else if (inAtom == nsDirectoryService::sOS_HomeDirectory) {
} else if (inAtom == nsGkAtoms::Home) {
rv = GetSpecialSystemDirectory(Win_HomeDirectory, getter_AddRefs(localFile));
} else if (inAtom == nsDirectoryService::sDesktop) {
rv = GetSpecialSystemDirectory(Win_Desktop, getter_AddRefs(localFile));
@ -598,7 +603,7 @@ nsDirectoryService::GetFile(const char* aProp, bool* aPersistent,
rv = GetSpecialSystemDirectory(Unix_LocalDirectory, getter_AddRefs(localFile));
} else if (inAtom == nsDirectoryService::sLibDirectory) {
rv = GetSpecialSystemDirectory(Unix_LibDirectory, getter_AddRefs(localFile));
} else if (inAtom == nsDirectoryService::sOS_HomeDirectory) {
} else if (inAtom == nsGkAtoms::Home) {
rv = GetSpecialSystemDirectory(Unix_HomeDirectory, getter_AddRefs(localFile));
} else if (inAtom == nsDirectoryService::sXDGDesktop ||
inAtom == nsDirectoryService::sOS_DesktopDirectory) {

View File

@ -11,7 +11,9 @@ DIR_ATOM(sOS_DriveDirectory, NS_OS_DRIVE_DIR)
DIR_ATOM(sOS_TemporaryDirectory, NS_OS_TEMP_DIR)
DIR_ATOM(sOS_CurrentProcessDirectory, NS_OS_CURRENT_PROCESS_DIR)
DIR_ATOM(sOS_CurrentWorkingDirectory, NS_OS_CURRENT_WORKING_DIR)
DIR_ATOM(sOS_HomeDirectory, NS_OS_HOME_DIR)
// This one is commented out because nsGkAtoms::Home also exists, and we don't
// allow duplicate static atoms.
//DIR_ATOM(sOS_HomeDirectory, NS_OS_HOME_DIR)
DIR_ATOM(sOS_DesktopDirectory, NS_OS_DESKTOP_DIR)
DIR_ATOM(sInitCurrentProcess_dummy, NS_XPCOM_INIT_CURRENT_PROCESS_DIR)
#if defined (MOZ_WIDGET_COCOA)

View File

@ -22,7 +22,11 @@
/* General OS specific locations */
// If this value ever changes, the special handling of the
// nsDirectoryService::sOS_HomeDirectory static atom -- i.e. the use of
// nsGkAtoms::Home in its place -- must be removed.
#define NS_OS_HOME_DIR "Home"
#define NS_OS_TEMP_DIR "TmpD"
#define NS_OS_CURRENT_WORKING_DIR "CurWorkD"
/* Files stored in this directory will appear on the user's desktop,