mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-24 21:58:06 +00:00
merge mozilla-central to autoland. r=merge a=merge
This commit is contained in:
commit
e9b3a258b8
1
.hgtags
1
.hgtags
@ -136,3 +136,4 @@ f9605772a0c9098ed1bcaa98089b2c944ed69e9b FIREFOX_BETA_55_BASE
|
||||
320642944e42a889db13c6c55b404e32319d4de6 FIREFOX_BETA_56_BASE
|
||||
8e818b5e9b6bef0fc1a5c527ecf30b0d56a02f14 FIREFOX_BETA_57_BASE
|
||||
f7e9777221a34f9f23c2e4933307eb38b621b679 FIREFOX_NIGHTLY_57_END
|
||||
40a14ca1cf04499f398e4cb8ba359b39eae4e216 FIREFOX_BETA_58_BASE
|
||||
|
@ -168,7 +168,7 @@ Compatibility::Init()
|
||||
|
||||
HMODULE jawsHandle = ::GetModuleHandleW(L"jhook");
|
||||
if (jawsHandle)
|
||||
sConsumers |= (IsModuleVersionLessThan(jawsHandle, 18, 4315)) ?
|
||||
sConsumers |= (IsModuleVersionLessThan(jawsHandle, 20, 0)) ?
|
||||
OLDJAWS : JAWS;
|
||||
|
||||
if (::GetModuleHandleW(L"gwm32inc"))
|
||||
|
@ -2917,9 +2917,11 @@ var JawsScreenReaderVersionCheck = {
|
||||
|
||||
_checkVersionAndPrompt() {
|
||||
// Make sure we only prompt for versions of JAWS we do not
|
||||
// support and never prompt if e10s is disabled.
|
||||
// support and never prompt if e10s is disabled or if we're on
|
||||
// nightly.
|
||||
if (!Services.appinfo.shouldBlockIncompatJaws ||
|
||||
!Services.appinfo.browserTabsRemoteAutostart) {
|
||||
!Services.appinfo.browserTabsRemoteAutostart ||
|
||||
AppConstants.NIGHTLY_BUILD) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,7 @@ Once Visual Studio 2015 Community has been installed, from a checkout
|
||||
of mozilla-central, run something like the following to produce a ZIP
|
||||
archive::
|
||||
|
||||
$ ./mach python build/windows_toolchain.py create-zip vs2015u3
|
||||
$ ./mach python build/windows_toolchain.py create-zip vs2017_15.4.2
|
||||
|
||||
The produced archive will be the argument to ``create-zip`` + ``.zip``.
|
||||
|
||||
|
@ -24,96 +24,111 @@ from mozpack.mozjar import (
|
||||
)
|
||||
import mozpack.path as mozpath
|
||||
|
||||
SDK_RELEASE = '10.0.15063.0'
|
||||
|
||||
# mozpack.match patterns for files under "Microsoft Visual Studio 14.0".
|
||||
VS_PATTERNS = [
|
||||
PATTERNS = [
|
||||
{
|
||||
'pattern': 'DIA SDK/bin/**',
|
||||
'ignore': (
|
||||
'DIA SDK/bin/arm/**',
|
||||
),
|
||||
'srcdir': '%(vs_path)s/DIA SDK',
|
||||
'dstdir': 'DIA SDK',
|
||||
'files': [
|
||||
{
|
||||
'pattern': 'bin/**',
|
||||
'ignore': (
|
||||
'bin/arm/**',
|
||||
),
|
||||
},
|
||||
{
|
||||
'pattern': 'idl/**',
|
||||
},
|
||||
{
|
||||
'pattern': 'include/**',
|
||||
},
|
||||
{
|
||||
'pattern': 'lib/**',
|
||||
'ignore': (
|
||||
'lib/arm/**',
|
||||
),
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
'pattern': 'DIA SDK/idl/**',
|
||||
'srcdir': '%(vs_path)s/VC/Tools/MSVC/14.11.25503',
|
||||
'dstdir': 'VC',
|
||||
'files': [
|
||||
# ATL is needed by Breakpad.
|
||||
{
|
||||
'pattern': 'atlmfc/include/**',
|
||||
},
|
||||
{
|
||||
'pattern': 'atlmfc/lib/x86/atls.*',
|
||||
},
|
||||
{
|
||||
'pattern': 'atlmfc/lib/x64/atls.*',
|
||||
},
|
||||
{
|
||||
'pattern': 'bin/Hostx64/**',
|
||||
},
|
||||
# 32-bit PGO-instrumented builds require 32-bit pgort140.dll.
|
||||
{
|
||||
'pattern': 'bin/Hostx86/x86/pgort140.dll',
|
||||
},
|
||||
{
|
||||
'pattern': 'include/**',
|
||||
},
|
||||
{
|
||||
'pattern': 'lib/**',
|
||||
'ignore': (
|
||||
'lib/onecore/**',
|
||||
'lib/x64/store/**',
|
||||
'lib/x86/store/**',
|
||||
),
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
'pattern': 'DIA SDK/include/**',
|
||||
'srcdir': '%(vs_path)s/VC/Redist/MSVC/14.11.25325',
|
||||
'dstdir': 'VC/redist',
|
||||
'files': [
|
||||
{
|
||||
'pattern': 'x64/Microsoft.VC141.CRT/**',
|
||||
},
|
||||
{
|
||||
'pattern': 'x86/Microsoft.VC141.CRT/**',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
'pattern': 'DIA SDK/lib/**',
|
||||
'ignore': (
|
||||
'DIA SDK/lib/arm/**',
|
||||
),
|
||||
},
|
||||
# ATL is needed by Breakpad.
|
||||
{
|
||||
'pattern': 'VC/atlmfc/include/**',
|
||||
},
|
||||
{
|
||||
'pattern': 'VC/atlmfc/lib/atls.*',
|
||||
},
|
||||
{
|
||||
'pattern': 'VC/atlmfc/lib/amd64/atls.*',
|
||||
},
|
||||
{
|
||||
'pattern': 'VC/bin/**',
|
||||
# We only care about compiling on amd64 for amd64 or x86 targets.
|
||||
'ignore': (
|
||||
'VC/bin/amd64_arm/**',
|
||||
'VC/bin/arm/**',
|
||||
'VC/bin/x86_arm/**',
|
||||
'VC/bin/x86_amd64/**',
|
||||
),
|
||||
},
|
||||
{
|
||||
'pattern': 'VC/include/**',
|
||||
},
|
||||
{
|
||||
'pattern': 'VC/lib/**',
|
||||
'ignore': (
|
||||
'VC/lib/arm/**',
|
||||
'VC/lib/onecore/**',
|
||||
'VC/lib/store/**',
|
||||
),
|
||||
},
|
||||
{
|
||||
'pattern': 'VC/redist/x64/Microsoft.VC140.CRT/**',
|
||||
},
|
||||
{
|
||||
'pattern': 'VC/redist/x86/Microsoft.VC140.CRT/**',
|
||||
},
|
||||
]
|
||||
|
||||
SDK_RELEASE = '10.0.14393.0'
|
||||
|
||||
# Files from the Windows 10 SDK to install.
|
||||
SDK_PATTERNS = [
|
||||
{
|
||||
'pattern': 'bin/x64/**',
|
||||
},
|
||||
{
|
||||
'pattern': 'Include/%s/**' % SDK_RELEASE,
|
||||
},
|
||||
{
|
||||
'pattern': 'Lib/%s/ucrt/x64/**' % SDK_RELEASE,
|
||||
},
|
||||
{
|
||||
'pattern': 'Lib/%s/ucrt/x86/**' % SDK_RELEASE,
|
||||
},
|
||||
{
|
||||
'pattern': 'Lib/%s/um/x64/**' % SDK_RELEASE,
|
||||
},
|
||||
{
|
||||
'pattern': 'Lib/%s/um/x86/**' % SDK_RELEASE,
|
||||
},
|
||||
{
|
||||
'pattern': 'Redist/D3D/**',
|
||||
},
|
||||
{
|
||||
'pattern': 'Redist/ucrt/DLLs/x64/**',
|
||||
},
|
||||
{
|
||||
'pattern': 'Redist/ucrt/DLLs/x86/**',
|
||||
'srcdir': '%(sdk_path)s',
|
||||
'dstdir': 'SDK',
|
||||
'files': [
|
||||
{
|
||||
'pattern': 'bin/%s/x64/**' % SDK_RELEASE,
|
||||
},
|
||||
{
|
||||
'pattern': 'Include/%s/**' % SDK_RELEASE,
|
||||
},
|
||||
{
|
||||
'pattern': 'Lib/%s/ucrt/x64/**' % SDK_RELEASE,
|
||||
},
|
||||
{
|
||||
'pattern': 'Lib/%s/ucrt/x86/**' % SDK_RELEASE,
|
||||
},
|
||||
{
|
||||
'pattern': 'Lib/%s/um/x64/**' % SDK_RELEASE,
|
||||
},
|
||||
{
|
||||
'pattern': 'Lib/%s/um/x86/**' % SDK_RELEASE,
|
||||
},
|
||||
{
|
||||
'pattern': 'Redist/D3D/**',
|
||||
},
|
||||
{
|
||||
'pattern': 'Redist/ucrt/DLLs/x64/**',
|
||||
},
|
||||
{
|
||||
'pattern': 'Redist/ucrt/DLLs/x86/**',
|
||||
},
|
||||
],
|
||||
},
|
||||
]
|
||||
|
||||
@ -128,9 +143,9 @@ def find_vs_paths():
|
||||
raise Exception('No "ProgramFiles(x86)" environment variable. '
|
||||
'Not running on 64-bit Windows?')
|
||||
|
||||
vs_path = os.path.join(pf, 'Microsoft Visual Studio 14.0')
|
||||
vs_path = os.path.join(pf, 'Microsoft Visual Studio', '2017', 'Community')
|
||||
if not os.path.exists(vs_path):
|
||||
raise Exception('%s does not exist; Visual Studio 2015 not installed?' %
|
||||
raise Exception('%s does not exist; Visual Studio 2017 not installed?' %
|
||||
vs_path)
|
||||
|
||||
sdk_path = os.path.join(pf, 'Windows Kits', '10')
|
||||
@ -138,6 +153,11 @@ def find_vs_paths():
|
||||
raise Exception('%s does not exist; Windows 10 SDK not installed?' %
|
||||
sdk_path)
|
||||
|
||||
sdk_fullver_path = os.path.join(sdk_path, 'Include', SDK_RELEASE)
|
||||
if not os.path.exists(sdk_fullver_path):
|
||||
raise Exception('%s does not exist; Wrong SDK version installed?' %
|
||||
sdk_fullver_path)
|
||||
|
||||
return vs_path, sdk_path
|
||||
|
||||
|
||||
@ -149,19 +169,16 @@ def resolve_files():
|
||||
"""
|
||||
vs_path, sdk_path = find_vs_paths()
|
||||
|
||||
for entry in VS_PATTERNS:
|
||||
finder = FileFinder(vs_path, ignore=entry.get('ignore', []))
|
||||
for p, f in finder.find(entry['pattern']):
|
||||
assert p.startswith(('VC/', 'DIA SDK/'))
|
||||
|
||||
yield p.encode('utf-8'), f
|
||||
|
||||
for entry in SDK_PATTERNS:
|
||||
finder = FileFinder(sdk_path, ignore=entry.get('ignore', []))
|
||||
for p, f in finder.find(entry['pattern']):
|
||||
relpath = 'SDK/%s' % p
|
||||
|
||||
yield relpath.encode('utf-8'), f
|
||||
for entry in PATTERNS:
|
||||
fullpath = entry['srcdir'] % {
|
||||
'vs_path': vs_path,
|
||||
'sdk_path': sdk_path,
|
||||
}
|
||||
for pattern in entry['files']:
|
||||
finder = FileFinder(fullpath, ignore=pattern.get('ignore', []))
|
||||
for p, f in finder.find(pattern['pattern']):
|
||||
dstpath = '%s/%s' % (entry['dstdir'], p)
|
||||
yield dstpath.encode('utf-8'), f
|
||||
|
||||
|
||||
def resolve_files_and_hash(manifest):
|
||||
@ -201,7 +218,7 @@ def write_zip(zip_path, prefix=None):
|
||||
if isinstance(prefix, unicode): # noqa Special case for Python 2
|
||||
prefix = prefix.encode('utf-8')
|
||||
|
||||
with JarWriter(file=zip_path, optimize=False, compress=5) as zip:
|
||||
with JarWriter(file=zip_path, optimize=False, compress_level=5) as zip:
|
||||
manifest = {}
|
||||
for p, data, mode in resolve_files_and_hash(manifest):
|
||||
print(p)
|
||||
|
@ -13,11 +13,11 @@ const {
|
||||
drawRect,
|
||||
drawRoundedRect,
|
||||
getBoundsFromPoints,
|
||||
getCanvasPosition,
|
||||
getCurrentMatrix,
|
||||
getPathDescriptionFromPoints,
|
||||
getPointsFromDiagonal,
|
||||
updateCanvasElement,
|
||||
updateCanvasPosition,
|
||||
} = require("./utils/canvas");
|
||||
const {
|
||||
CanvasFrameAnonymousContentHelper,
|
||||
@ -176,12 +176,10 @@ class CssGridHighlighter extends AutoRefreshHighlighter {
|
||||
y: 0
|
||||
};
|
||||
|
||||
// Calling `getCanvasPosition` anyway since the highlighter could be initialized
|
||||
// Calling `updateCanvasPosition` anyway since the highlighter could be initialized
|
||||
// on a page that has scrolled already.
|
||||
let { canvasX, canvasY } = getCanvasPosition(this._canvasPosition, this._scroll,
|
||||
this.win, this._winDimensions);
|
||||
this._canvasPosition.x = canvasX;
|
||||
this._canvasPosition.y = canvasY;
|
||||
updateCanvasPosition(this._canvasPosition, this._scroll, this.win,
|
||||
this._winDimensions);
|
||||
}
|
||||
|
||||
_buildMarkup() {
|
||||
@ -772,7 +770,7 @@ class CssGridHighlighter extends AutoRefreshHighlighter {
|
||||
* to give the illusion that it always covers the viewport.
|
||||
*/
|
||||
_scrollUpdate() {
|
||||
let { hasUpdated } = getCanvasPosition(this._canvasPosition, this._scroll, this.win,
|
||||
let hasUpdated = updateCanvasPosition(this._canvasPosition, this._scroll, this.win,
|
||||
this._winDimensions);
|
||||
|
||||
if (hasUpdated) {
|
||||
|
@ -7,9 +7,9 @@
|
||||
const { AutoRefreshHighlighter } = require("./auto-refresh");
|
||||
const {
|
||||
CANVAS_SIZE,
|
||||
getCanvasPosition,
|
||||
getCurrentMatrix,
|
||||
updateCanvasElement,
|
||||
updateCanvasPosition,
|
||||
} = require("./utils/canvas");
|
||||
const {
|
||||
CanvasFrameAnonymousContentHelper,
|
||||
@ -42,12 +42,10 @@ class FlexboxHighlighter extends AutoRefreshHighlighter {
|
||||
y: 0
|
||||
};
|
||||
|
||||
// Calling `getCanvasPosition` anyway since the highlighter could be initialized
|
||||
// Calling `updateCanvasPosition` anyway since the highlighter could be initialized
|
||||
// on a page that has scrolled already.
|
||||
let { canvasX, canvasY } = getCanvasPosition(this._canvasPosition, this._scroll,
|
||||
this.win, this._winDimensions);
|
||||
this._canvasPosition.x = canvasX;
|
||||
this._canvasPosition.y = canvasY;
|
||||
updateCanvasPosition(this._canvasPosition, this._scroll, this.win,
|
||||
this._winDimensions);
|
||||
}
|
||||
|
||||
_buildMarkup() {
|
||||
@ -126,7 +124,7 @@ class FlexboxHighlighter extends AutoRefreshHighlighter {
|
||||
* to give the illusion that it always covers the viewport.
|
||||
*/
|
||||
_scrollUpdate() {
|
||||
let { hasUpdated } = getCanvasPosition(this._canvasPosition, this._scroll, this.win,
|
||||
let hasUpdated = updateCanvasPosition(this._canvasPosition, this._scroll, this.win,
|
||||
this._winDimensions);
|
||||
|
||||
if (hasUpdated) {
|
||||
|
@ -228,79 +228,6 @@ function getBoundsFromPoints(points) {
|
||||
return bounds;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates and returns the <canvas>'s position in accordance with the page's scroll,
|
||||
* document's size, canvas size, and viewport's size. This is called when a page's scroll
|
||||
* is detected.
|
||||
*
|
||||
* @param {Object} canvasPosition
|
||||
* A pointer object {x, y} representing the <canvas> position to the top left
|
||||
* corner of the page.
|
||||
* @param {Object} scrollPosition
|
||||
* A pointer object {x, y} representing the window's pageXOffset and pageYOffset.
|
||||
* @param {Window} window
|
||||
* The window object.
|
||||
* @param {Object} windowDimensions
|
||||
* An object {width, height} representing the window's dimensions for the
|
||||
* `window` given.
|
||||
* @return {Object} An object with the following properties:
|
||||
* - {Boolean} hasUpdated
|
||||
* true if the <canvas> position was updated and false otherwise.
|
||||
* - {Number} canvasX
|
||||
* The canvas' x position.
|
||||
* - {Number} canvasY
|
||||
* The canvas' y position.
|
||||
*/
|
||||
function getCanvasPosition(canvasPosition, scrollPosition, window, windowDimensions) {
|
||||
let { x: canvasX, y: canvasY } = canvasPosition;
|
||||
let { x: scrollX, y: scrollY } = scrollPosition;
|
||||
let cssCanvasSize = CANVAS_SIZE / window.devicePixelRatio;
|
||||
let viewportSize = getViewportDimensions(window);
|
||||
let { height, width } = windowDimensions;
|
||||
let canvasWidth = cssCanvasSize;
|
||||
let canvasHeight = cssCanvasSize;
|
||||
let hasUpdated = false;
|
||||
|
||||
// Those values indicates the relative horizontal and vertical space the page can
|
||||
// scroll before we have to reposition the <canvas>; they're 1/4 of the delta between
|
||||
// the canvas' size and the viewport's size: that's because we want to consider both
|
||||
// sides (top/bottom, left/right; so 1/2 for each side) and also we don't want to
|
||||
// shown the edges of the canvas in case of fast scrolling (to avoid showing undraw
|
||||
// areas, therefore another 1/2 here).
|
||||
let bufferSizeX = (canvasWidth - viewportSize.width) >> 2;
|
||||
let bufferSizeY = (canvasHeight - viewportSize.height) >> 2;
|
||||
|
||||
// Defines the boundaries for the canvas.
|
||||
let leftBoundary = 0;
|
||||
let rightBoundary = width - canvasWidth;
|
||||
let topBoundary = 0;
|
||||
let bottomBoundary = height - canvasHeight;
|
||||
|
||||
// Defines the thresholds that triggers the canvas' position to be updated.
|
||||
let leftThreshold = scrollX - bufferSizeX;
|
||||
let rightThreshold = scrollX - canvasWidth + viewportSize.width + bufferSizeX;
|
||||
let topThreshold = scrollY - bufferSizeY;
|
||||
let bottomThreshold = scrollY - canvasHeight + viewportSize.height + bufferSizeY;
|
||||
|
||||
if (canvasX < rightBoundary && canvasX < rightThreshold) {
|
||||
canvasX = Math.min(leftThreshold, rightBoundary);
|
||||
hasUpdated = true;
|
||||
} else if (canvasX > leftBoundary && canvasX > leftThreshold) {
|
||||
canvasX = Math.max(rightThreshold, leftBoundary);
|
||||
hasUpdated = true;
|
||||
}
|
||||
|
||||
if (canvasY < bottomBoundary && canvasY < bottomThreshold) {
|
||||
canvasY = Math.min(topThreshold, bottomBoundary);
|
||||
hasUpdated = true;
|
||||
} else if (canvasY > topBoundary && canvasY > topThreshold) {
|
||||
canvasY = Math.max(bottomThreshold, topBoundary);
|
||||
hasUpdated = true;
|
||||
}
|
||||
|
||||
return { canvasX, canvasY, hasUpdated };
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current matrices for both canvas drawing and SVG taking into account the
|
||||
* following transformations, in this order:
|
||||
@ -427,14 +354,85 @@ function updateCanvasElement(canvas, canvasPosition, devicePixelRatio) {
|
||||
canvas.getCanvasContext("2d").clearRect(0, 0, CANVAS_SIZE, CANVAS_SIZE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates and returns the <canvas>'s position in accordance with the page's scroll,
|
||||
* document's size, canvas size, and viewport's size. This is called when a page's scroll
|
||||
* is detected.
|
||||
*
|
||||
* @param {Object} canvasPosition
|
||||
* A pointer object {x, y} representing the <canvas> position to the top left
|
||||
* corner of the page.
|
||||
* @param {Object} scrollPosition
|
||||
* A pointer object {x, y} representing the window's pageXOffset and pageYOffset.
|
||||
* @param {Window} window
|
||||
* The window object.
|
||||
* @param {Object} windowDimensions
|
||||
* An object {width, height} representing the window's dimensions for the
|
||||
* `window` given.
|
||||
* @return {Boolean} true if the <canvas> position was updated and false otherwise.
|
||||
*/
|
||||
function updateCanvasPosition(canvasPosition, scrollPosition, window, windowDimensions) {
|
||||
let { x: canvasX, y: canvasY } = canvasPosition;
|
||||
let { x: scrollX, y: scrollY } = scrollPosition;
|
||||
let cssCanvasSize = CANVAS_SIZE / window.devicePixelRatio;
|
||||
let viewportSize = getViewportDimensions(window);
|
||||
let { height, width } = windowDimensions;
|
||||
let canvasWidth = cssCanvasSize;
|
||||
let canvasHeight = cssCanvasSize;
|
||||
let hasUpdated = false;
|
||||
|
||||
// Those values indicates the relative horizontal and vertical space the page can
|
||||
// scroll before we have to reposition the <canvas>; they're 1/4 of the delta between
|
||||
// the canvas' size and the viewport's size: that's because we want to consider both
|
||||
// sides (top/bottom, left/right; so 1/2 for each side) and also we don't want to
|
||||
// shown the edges of the canvas in case of fast scrolling (to avoid showing undraw
|
||||
// areas, therefore another 1/2 here).
|
||||
let bufferSizeX = (canvasWidth - viewportSize.width) >> 2;
|
||||
let bufferSizeY = (canvasHeight - viewportSize.height) >> 2;
|
||||
|
||||
// Defines the boundaries for the canvas.
|
||||
let leftBoundary = 0;
|
||||
let rightBoundary = width - canvasWidth;
|
||||
let topBoundary = 0;
|
||||
let bottomBoundary = height - canvasHeight;
|
||||
|
||||
// Defines the thresholds that triggers the canvas' position to be updated.
|
||||
let leftThreshold = scrollX - bufferSizeX;
|
||||
let rightThreshold = scrollX - canvasWidth + viewportSize.width + bufferSizeX;
|
||||
let topThreshold = scrollY - bufferSizeY;
|
||||
let bottomThreshold = scrollY - canvasHeight + viewportSize.height + bufferSizeY;
|
||||
|
||||
if (canvasX < rightBoundary && canvasX < rightThreshold) {
|
||||
canvasX = Math.min(leftThreshold, rightBoundary);
|
||||
hasUpdated = true;
|
||||
} else if (canvasX > leftBoundary && canvasX > leftThreshold) {
|
||||
canvasX = Math.max(rightThreshold, leftBoundary);
|
||||
hasUpdated = true;
|
||||
}
|
||||
|
||||
if (canvasY < bottomBoundary && canvasY < bottomThreshold) {
|
||||
canvasY = Math.min(topThreshold, bottomBoundary);
|
||||
hasUpdated = true;
|
||||
} else if (canvasY > topBoundary && canvasY > topThreshold) {
|
||||
canvasY = Math.max(bottomThreshold, topBoundary);
|
||||
hasUpdated = true;
|
||||
}
|
||||
|
||||
// Update the canvas position with the calculated canvasX and canvasY positions.
|
||||
canvasPosition.x = canvasX;
|
||||
canvasPosition.y = canvasY;
|
||||
|
||||
return hasUpdated;
|
||||
}
|
||||
|
||||
exports.CANVAS_SIZE = CANVAS_SIZE;
|
||||
exports.drawBubbleRect = drawBubbleRect;
|
||||
exports.drawLine = drawLine;
|
||||
exports.drawRect = drawRect;
|
||||
exports.drawRoundedRect = drawRoundedRect;
|
||||
exports.getBoundsFromPoints = getBoundsFromPoints;
|
||||
exports.getCanvasPosition = getCanvasPosition;
|
||||
exports.getCurrentMatrix = getCurrentMatrix;
|
||||
exports.getPathDescriptionFromPoints = getPathDescriptionFromPoints;
|
||||
exports.getPointsFromDiagonal = getPointsFromDiagonal;
|
||||
exports.updateCanvasElement = updateCanvasElement;
|
||||
exports.updateCanvasPosition = updateCanvasPosition;
|
||||
|
@ -59,7 +59,6 @@ skip-if = toolkit == 'android' # needs plugin support
|
||||
[test_bug985859.html]
|
||||
[test_bug986930.html]
|
||||
[test_bug1092842.html]
|
||||
skip-if = os == "win" && debug # Bug 1408490
|
||||
[test_bug1165981.html]
|
||||
[test_bug1245545.html]
|
||||
[test_bug1307694.html]
|
||||
|
@ -9,14 +9,6 @@
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
U2FTransactionChild::U2FTransactionChild()
|
||||
{
|
||||
// Retain a reference so the task object isn't deleted without IPDL's
|
||||
// knowledge. The reference will be released by
|
||||
// mozilla::ipc::BackgroundChildImpl::DeallocPWebAuthnTransactionChild.
|
||||
NS_ADDREF_THIS();
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult
|
||||
U2FTransactionChild::RecvConfirmRegister(const uint64_t& aTransactionId,
|
||||
nsTArray<uint8_t>&& aRegBuffer)
|
||||
|
@ -7,7 +7,7 @@
|
||||
#ifndef mozilla_dom_U2FTransactionChild_h
|
||||
#define mozilla_dom_U2FTransactionChild_h
|
||||
|
||||
#include "mozilla/dom/PWebAuthnTransactionChild.h"
|
||||
#include "mozilla/dom/WebAuthnTransactionChildBase.h"
|
||||
|
||||
/*
|
||||
* Child process IPC implementation for U2F API. Receives results of U2F
|
||||
@ -18,12 +18,9 @@
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class U2FTransactionChild final : public PWebAuthnTransactionChild
|
||||
class U2FTransactionChild final : public WebAuthnTransactionChildBase
|
||||
{
|
||||
public:
|
||||
NS_INLINE_DECL_REFCOUNTING(U2FTransactionChild);
|
||||
U2FTransactionChild();
|
||||
|
||||
mozilla::ipc::IPCResult
|
||||
RecvConfirmRegister(const uint64_t& aTransactionId,
|
||||
nsTArray<uint8_t>&& aRegBuffer) override;
|
||||
@ -37,9 +34,6 @@ public:
|
||||
RecvAbort(const uint64_t& aTransactionId, const nsresult& aError) override;
|
||||
|
||||
void ActorDestroy(ActorDestroyReason why) override;
|
||||
|
||||
private:
|
||||
~U2FTransactionChild() = default;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -9,14 +9,6 @@
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
WebAuthnTransactionChild::WebAuthnTransactionChild()
|
||||
{
|
||||
// Retain a reference so the task object isn't deleted without IPDL's
|
||||
// knowledge. The reference will be released by
|
||||
// mozilla::ipc::BackgroundChildImpl::DeallocPWebAuthnTransactionChild.
|
||||
NS_ADDREF_THIS();
|
||||
}
|
||||
|
||||
mozilla::ipc::IPCResult
|
||||
WebAuthnTransactionChild::RecvConfirmRegister(const uint64_t& aTransactionId,
|
||||
nsTArray<uint8_t>&& aRegBuffer)
|
||||
|
@ -7,7 +7,7 @@
|
||||
#ifndef mozilla_dom_WebAuthnTransactionChild_h
|
||||
#define mozilla_dom_WebAuthnTransactionChild_h
|
||||
|
||||
#include "mozilla/dom/PWebAuthnTransactionChild.h"
|
||||
#include "mozilla/dom/WebAuthnTransactionChildBase.h"
|
||||
|
||||
/*
|
||||
* Child process IPC implementation for WebAuthn API. Receives results of
|
||||
@ -19,12 +19,9 @@
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class WebAuthnTransactionChild final : public PWebAuthnTransactionChild
|
||||
class WebAuthnTransactionChild final : public WebAuthnTransactionChildBase
|
||||
{
|
||||
public:
|
||||
NS_INLINE_DECL_REFCOUNTING(WebAuthnTransactionChild);
|
||||
WebAuthnTransactionChild();
|
||||
|
||||
mozilla::ipc::IPCResult
|
||||
RecvConfirmRegister(const uint64_t& aTransactionId,
|
||||
nsTArray<uint8_t>&& aRegBuffer) override;
|
||||
@ -38,9 +35,6 @@ public:
|
||||
RecvAbort(const uint64_t& aTransactionId, const nsresult& aError) override;
|
||||
|
||||
void ActorDestroy(ActorDestroyReason why) override;
|
||||
|
||||
private:
|
||||
~WebAuthnTransactionChild() = default;
|
||||
};
|
||||
|
||||
}
|
||||
|
21
dom/webauthn/WebAuthnTransactionChildBase.cpp
Normal file
21
dom/webauthn/WebAuthnTransactionChildBase.cpp
Normal file
@ -0,0 +1,21 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "mozilla/dom/WebAuthnTransactionChildBase.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
WebAuthnTransactionChildBase::WebAuthnTransactionChildBase()
|
||||
{
|
||||
// Retain a reference so the task object isn't deleted without IPDL's
|
||||
// knowledge. The reference will be released by
|
||||
// mozilla::ipc::BackgroundChildImpl::DeallocPWebAuthnTransactionChild.
|
||||
NS_ADDREF_THIS();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
36
dom/webauthn/WebAuthnTransactionChildBase.h
Normal file
36
dom/webauthn/WebAuthnTransactionChildBase.h
Normal file
@ -0,0 +1,36 @@
|
||||
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef mozilla_dom_WebAuthnTransactionChildBase_h
|
||||
#define mozilla_dom_WebAuthnTransactionChildBase_h
|
||||
|
||||
#include "mozilla/dom/PWebAuthnTransactionChild.h"
|
||||
|
||||
/*
|
||||
* A base class to be used by child process IPC implementations for WebAuthn
|
||||
* and U2F. This mostly handles refcounting so we can properly dereference
|
||||
* in mozilla::ipc::BackgroundChildImpl::DeallocPWebAuthnTransactionChild(),
|
||||
* a function that doesn't know which of the two implementations is passed.
|
||||
*/
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class WebAuthnTransactionChildBase : public PWebAuthnTransactionChild
|
||||
{
|
||||
public:
|
||||
NS_INLINE_DECL_REFCOUNTING(WebAuthnTransactionChildBase);
|
||||
WebAuthnTransactionChildBase();
|
||||
|
||||
protected:
|
||||
~WebAuthnTransactionChildBase() = default;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif //mozilla_dom_WebAuthnTransactionChildBase_h
|
@ -23,6 +23,7 @@ EXPORTS.mozilla.dom += [
|
||||
'WebAuthnCBORUtil.h',
|
||||
'WebAuthnManager.h',
|
||||
'WebAuthnTransactionChild.h',
|
||||
'WebAuthnTransactionChildBase.h',
|
||||
'WebAuthnTransactionParent.h',
|
||||
'WebAuthnUtil.h',
|
||||
]
|
||||
@ -40,6 +41,7 @@ UNIFIED_SOURCES += [
|
||||
'WebAuthnCBORUtil.cpp',
|
||||
'WebAuthnManager.cpp',
|
||||
'WebAuthnTransactionChild.cpp',
|
||||
'WebAuthnTransactionChildBase.cpp',
|
||||
'WebAuthnTransactionParent.cpp',
|
||||
'WebAuthnUtil.cpp',
|
||||
]
|
||||
|
@ -6,6 +6,10 @@ rust:
|
||||
- beta
|
||||
- nightly
|
||||
|
||||
matrix:
|
||||
allow_failures:
|
||||
- rust: nightly
|
||||
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
|
@ -195,7 +195,7 @@ impl DeviceInterfaceDetailData {
|
||||
return None;
|
||||
}
|
||||
|
||||
let mut data = unsafe { libc::malloc(size) as PSP_DEVICE_INTERFACE_DETAIL_DATA_W };
|
||||
let data = unsafe { libc::malloc(size) as PSP_DEVICE_INTERFACE_DETAIL_DATA_W };
|
||||
if data.is_null() {
|
||||
return None;
|
||||
}
|
||||
|
@ -42,7 +42,7 @@
|
||||
#include "mozilla/net/HttpBackgroundChannelChild.h"
|
||||
#include "mozilla/net/PUDPSocketChild.h"
|
||||
#include "mozilla/dom/network/UDPSocketChild.h"
|
||||
#include "mozilla/dom/WebAuthnTransactionChild.h"
|
||||
#include "mozilla/dom/WebAuthnTransactionChildBase.h"
|
||||
#include "nsID.h"
|
||||
#include "nsTraceRefcnt.h"
|
||||
|
||||
@ -86,7 +86,7 @@ using mozilla::dom::cache::PCacheStreamControlChild;
|
||||
using mozilla::dom::LocalStorage;
|
||||
using mozilla::dom::StorageDBChild;
|
||||
|
||||
using mozilla::dom::WebAuthnTransactionChild;
|
||||
using mozilla::dom::WebAuthnTransactionChildBase;
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// BackgroundChildImpl::ThreadLocal
|
||||
@ -607,8 +607,8 @@ bool
|
||||
BackgroundChildImpl::DeallocPWebAuthnTransactionChild(PWebAuthnTransactionChild* aActor)
|
||||
{
|
||||
MOZ_ASSERT(aActor);
|
||||
RefPtr<dom::WebAuthnTransactionChild> child =
|
||||
dont_AddRef(static_cast<dom::WebAuthnTransactionChild*>(aActor));
|
||||
RefPtr<dom::WebAuthnTransactionChildBase> child =
|
||||
dont_AddRef(static_cast<dom::WebAuthnTransactionChildBase*>(aActor));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -2,16 +2,16 @@
|
||||
* 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/. */
|
||||
|
||||
function StarGeneratorNext(val) {
|
||||
// The IsSuspendedStarGenerator call below is not necessary for
|
||||
// correctness. It's a performance optimization to check for the
|
||||
// common case with a single call. It's also inlined in Baseline.
|
||||
function GeneratorNext(val) {
|
||||
// The IsSuspendedGenerator call below is not necessary for correctness.
|
||||
// It's a performance optimization to check for the common case with a
|
||||
// single call. It's also inlined in Baseline.
|
||||
|
||||
if (!IsSuspendedStarGenerator(this)) {
|
||||
if (!IsObject(this) || !IsStarGeneratorObject(this))
|
||||
return callFunction(CallStarGeneratorMethodIfWrapped, this, val, "StarGeneratorNext");
|
||||
if (!IsSuspendedGenerator(this)) {
|
||||
if (!IsObject(this) || !IsGeneratorObject(this))
|
||||
return callFunction(CallGeneratorMethodIfWrapped, this, val, "GeneratorNext");
|
||||
|
||||
if (StarGeneratorObjectIsClosed(this))
|
||||
if (GeneratorObjectIsClosed(this))
|
||||
return { value: undefined, done: true };
|
||||
|
||||
if (GeneratorIsRunning(this))
|
||||
@ -21,18 +21,18 @@ function StarGeneratorNext(val) {
|
||||
try {
|
||||
return resumeGenerator(this, val, "next");
|
||||
} catch (e) {
|
||||
if (!StarGeneratorObjectIsClosed(this))
|
||||
if (!GeneratorObjectIsClosed(this))
|
||||
GeneratorSetClosed(this);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
function StarGeneratorThrow(val) {
|
||||
if (!IsSuspendedStarGenerator(this)) {
|
||||
if (!IsObject(this) || !IsStarGeneratorObject(this))
|
||||
return callFunction(CallStarGeneratorMethodIfWrapped, this, val, "StarGeneratorThrow");
|
||||
function GeneratorThrow(val) {
|
||||
if (!IsSuspendedGenerator(this)) {
|
||||
if (!IsObject(this) || !IsGeneratorObject(this))
|
||||
return callFunction(CallGeneratorMethodIfWrapped, this, val, "GeneratorThrow");
|
||||
|
||||
if (StarGeneratorObjectIsClosed(this))
|
||||
if (GeneratorObjectIsClosed(this))
|
||||
throw val;
|
||||
|
||||
if (GeneratorIsRunning(this))
|
||||
@ -42,18 +42,18 @@ function StarGeneratorThrow(val) {
|
||||
try {
|
||||
return resumeGenerator(this, val, "throw");
|
||||
} catch (e) {
|
||||
if (!StarGeneratorObjectIsClosed(this))
|
||||
if (!GeneratorObjectIsClosed(this))
|
||||
GeneratorSetClosed(this);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
function StarGeneratorReturn(val) {
|
||||
if (!IsSuspendedStarGenerator(this)) {
|
||||
if (!IsObject(this) || !IsStarGeneratorObject(this))
|
||||
return callFunction(CallStarGeneratorMethodIfWrapped, this, val, "StarGeneratorReturn");
|
||||
function GeneratorReturn(val) {
|
||||
if (!IsSuspendedGenerator(this)) {
|
||||
if (!IsObject(this) || !IsGeneratorObject(this))
|
||||
return callFunction(CallGeneratorMethodIfWrapped, this, val, "GeneratorReturn");
|
||||
|
||||
if (StarGeneratorObjectIsClosed(this))
|
||||
if (GeneratorObjectIsClosed(this))
|
||||
return { value: val, done: true };
|
||||
|
||||
if (GeneratorIsRunning(this))
|
||||
@ -62,9 +62,9 @@ function StarGeneratorReturn(val) {
|
||||
|
||||
try {
|
||||
var rval = { value: val, done: true };
|
||||
return resumeGenerator(this, rval, "close");
|
||||
return resumeGenerator(this, rval, "return");
|
||||
} catch (e) {
|
||||
if (!StarGeneratorObjectIsClosed(this))
|
||||
if (!GeneratorObjectIsClosed(this))
|
||||
GeneratorSetClosed(this);
|
||||
throw e;
|
||||
}
|
||||
@ -80,6 +80,6 @@ function InterpretGeneratorResume(gen, val, kind) {
|
||||
return resumeGenerator(gen, val, "next");
|
||||
if (kind === "throw")
|
||||
return resumeGenerator(gen, val, "throw");
|
||||
assert(kind === "close", "Invalid resume kind");
|
||||
return resumeGenerator(gen, val, "close");
|
||||
assert(kind === "return", "Invalid resume kind");
|
||||
return resumeGenerator(gen, val, "return");
|
||||
}
|
||||
|
@ -5,69 +5,3 @@
|
||||
function IteratorIdentity() {
|
||||
return this;
|
||||
}
|
||||
|
||||
var LegacyIteratorWrapperMap = new std_WeakMap();
|
||||
|
||||
function LegacyIteratorNext(arg) {
|
||||
var iter = callFunction(std_WeakMap_get, LegacyIteratorWrapperMap, this);
|
||||
try {
|
||||
return { value: callContentFunction(iter.next, iter, arg), done: false };
|
||||
} catch (e) {
|
||||
if (e instanceof std_StopIteration)
|
||||
return { value: undefined, done: true };
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
function LegacyIteratorThrow(exn) {
|
||||
var iter = callFunction(std_WeakMap_get, LegacyIteratorWrapperMap, this);
|
||||
try {
|
||||
return { value: callContentFunction(iter.throw, iter, exn), done: false };
|
||||
} catch (e) {
|
||||
if (e instanceof std_StopIteration)
|
||||
return { value: undefined, done: true };
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
function LegacyGeneratorIterator(iter) {
|
||||
callFunction(std_WeakMap_set, LegacyIteratorWrapperMap, this, iter);
|
||||
}
|
||||
|
||||
var LegacyIteratorsInitialized = std_Object_create(null);
|
||||
|
||||
function InitLegacyIterators() {
|
||||
var props = std_Object_create(null);
|
||||
|
||||
props.next = std_Object_create(null);
|
||||
props.next.value = LegacyIteratorNext;
|
||||
props.next.enumerable = false;
|
||||
props.next.configurable = true;
|
||||
props.next.writable = true;
|
||||
|
||||
props[std_iterator] = std_Object_create(null);
|
||||
props[std_iterator].value = IteratorIdentity;
|
||||
props[std_iterator].enumerable = false;
|
||||
props[std_iterator].configurable = true;
|
||||
props[std_iterator].writable = true;
|
||||
|
||||
props.throw = std_Object_create(null);
|
||||
props.throw.value = LegacyIteratorThrow;
|
||||
props.throw.enumerable = false;
|
||||
props.throw.configurable = true;
|
||||
props.throw.writable = true;
|
||||
|
||||
var LegacyGeneratorIteratorProto = std_Object_create(GetIteratorPrototype(), props);
|
||||
MakeConstructible(LegacyGeneratorIterator, LegacyGeneratorIteratorProto);
|
||||
|
||||
LegacyIteratorsInitialized.initialized = true;
|
||||
}
|
||||
|
||||
function LegacyGeneratorIteratorShim() {
|
||||
var iter = ToObject(this);
|
||||
|
||||
if (!LegacyIteratorsInitialized.initialized)
|
||||
InitLegacyIterators();
|
||||
|
||||
return new LegacyGeneratorIterator(iter);
|
||||
}
|
||||
|
@ -1071,11 +1071,10 @@ ModuleObject::instantiateFunctionDeclarations(JSContext* cx, HandleModuleObject
|
||||
return false;
|
||||
|
||||
if (fun->isAsync()) {
|
||||
if (fun->isStarGenerator()) {
|
||||
if (fun->isGenerator())
|
||||
obj = WrapAsyncGenerator(cx, obj.as<JSFunction>());
|
||||
} else {
|
||||
else
|
||||
obj = WrapAsyncFunction(cx, obj.as<JSFunction>());
|
||||
}
|
||||
}
|
||||
|
||||
if (!obj)
|
||||
|
@ -355,7 +355,7 @@ js::ObjectToSource(JSContext* cx, HandleObject obj)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (fun->isStarGenerator()) {
|
||||
if (fun->isGenerator()) {
|
||||
if (!buf.append('*'))
|
||||
return false;
|
||||
}
|
||||
|
@ -3427,7 +3427,7 @@ ASTSerializer::function(ParseNode* pn, ASTType type, MutableHandleValue dst)
|
||||
RootedFunction func(cx, pn->pn_funbox->function());
|
||||
|
||||
GeneratorStyle generatorStyle =
|
||||
pn->pn_funbox->isStarGenerator()
|
||||
pn->pn_funbox->isGenerator()
|
||||
? GeneratorStyle::ES6
|
||||
: GeneratorStyle::None;
|
||||
|
||||
|
@ -53,10 +53,6 @@
|
||||
//
|
||||
// Symbol is a bare constructor without properties or methods.
|
||||
var std_Symbol = Symbol;
|
||||
// WeakMap is a bare constructor without properties or methods.
|
||||
var std_WeakMap = WeakMap;
|
||||
// StopIteration is a bare constructor without properties or methods.
|
||||
var std_StopIteration = StopIteration;
|
||||
|
||||
|
||||
/********** List specification type **********/
|
||||
|
@ -74,8 +74,8 @@ WeakMap_get_impl(JSContext* cx, const CallArgs& args)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
js::WeakMap_get(JSContext* cx, unsigned argc, Value* vp)
|
||||
static bool
|
||||
WeakMap_get(JSContext* cx, unsigned argc, Value* vp)
|
||||
{
|
||||
CallArgs args = CallArgsFromVp(argc, vp);
|
||||
return CallNonGenericMethod<IsWeakMap, WeakMap_get_impl>(cx, args);
|
||||
@ -130,8 +130,8 @@ WeakMap_set_impl(JSContext* cx, const CallArgs& args)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
js::WeakMap_set(JSContext* cx, unsigned argc, Value* vp)
|
||||
static bool
|
||||
WeakMap_set(JSContext* cx, unsigned argc, Value* vp)
|
||||
{
|
||||
CallArgs args = CallArgsFromVp(argc, vp);
|
||||
return CallNonGenericMethod<IsWeakMap, WeakMap_set_impl>(cx, args);
|
||||
@ -295,8 +295,8 @@ static const JSFunctionSpec weak_map_methods[] = {
|
||||
JS_FS_END
|
||||
};
|
||||
|
||||
static JSObject*
|
||||
InitWeakMapClass(JSContext* cx, HandleObject obj, bool defineMembers)
|
||||
JSObject*
|
||||
js::InitWeakMapClass(JSContext* cx, HandleObject obj)
|
||||
{
|
||||
MOZ_ASSERT(obj->isNative());
|
||||
|
||||
@ -314,27 +314,12 @@ InitWeakMapClass(JSContext* cx, HandleObject obj, bool defineMembers)
|
||||
if (!LinkConstructorAndPrototype(cx, ctor, proto))
|
||||
return nullptr;
|
||||
|
||||
if (defineMembers) {
|
||||
if (!DefinePropertiesAndFunctions(cx, proto, nullptr, weak_map_methods))
|
||||
return nullptr;
|
||||
if (!DefineToStringTag(cx, proto, cx->names().WeakMap))
|
||||
return nullptr;
|
||||
}
|
||||
if (!DefinePropertiesAndFunctions(cx, proto, nullptr, weak_map_methods))
|
||||
return nullptr;
|
||||
if (!DefineToStringTag(cx, proto, cx->names().WeakMap))
|
||||
return nullptr;
|
||||
|
||||
if (!GlobalObject::initBuiltinConstructor(cx, global, JSProto_WeakMap, ctor, proto))
|
||||
return nullptr;
|
||||
return proto;
|
||||
}
|
||||
|
||||
JSObject*
|
||||
js::InitWeakMapClass(JSContext* cx, HandleObject obj)
|
||||
{
|
||||
return InitWeakMapClass(cx, obj, true);
|
||||
}
|
||||
|
||||
JSObject*
|
||||
js::InitBareWeakMapCtor(JSContext* cx, HandleObject obj)
|
||||
{
|
||||
return InitWeakMapClass(cx, obj, false);
|
||||
}
|
||||
|
||||
|
@ -32,17 +32,6 @@ class WeakMapObject : public WeakCollectionObject
|
||||
static const Class class_;
|
||||
};
|
||||
|
||||
// WeakMap methods exposed so they can be installed in the self-hosting global.
|
||||
|
||||
extern bool
|
||||
WeakMap_get(JSContext* cx, unsigned argc, Value* vp);
|
||||
|
||||
extern bool
|
||||
WeakMap_set(JSContext* cx, unsigned argc, Value* vp);
|
||||
|
||||
extern JSObject*
|
||||
InitBareWeakMapCtor(JSContext* cx, HandleObject obj);
|
||||
|
||||
extern JSObject*
|
||||
InitWeakMapClass(JSContext* cx, HandleObject obj);
|
||||
|
||||
|
@ -730,7 +730,8 @@ frontend::CompileStandaloneFunction(JSContext* cx, MutableHandleFunction fun,
|
||||
scope = &cx->global()->emptyGlobalScope();
|
||||
|
||||
BytecodeCompiler compiler(cx, cx->tempLifoAlloc(), options, srcBuf, scope);
|
||||
return compiler.compileStandaloneFunction(fun, NotGenerator, SyncFunction, parameterListEnd);
|
||||
return compiler.compileStandaloneFunction(fun, GeneratorKind::NotGenerator, SyncFunction,
|
||||
parameterListEnd);
|
||||
}
|
||||
|
||||
bool
|
||||
@ -742,7 +743,8 @@ frontend::CompileStandaloneGenerator(JSContext* cx, MutableHandleFunction fun,
|
||||
RootedScope emptyGlobalScope(cx, &cx->global()->emptyGlobalScope());
|
||||
|
||||
BytecodeCompiler compiler(cx, cx->tempLifoAlloc(), options, srcBuf, emptyGlobalScope);
|
||||
return compiler.compileStandaloneFunction(fun, StarGenerator, SyncFunction, parameterListEnd);
|
||||
return compiler.compileStandaloneFunction(fun, GeneratorKind::Generator, SyncFunction,
|
||||
parameterListEnd);
|
||||
}
|
||||
|
||||
bool
|
||||
@ -754,7 +756,8 @@ frontend::CompileStandaloneAsyncFunction(JSContext* cx, MutableHandleFunction fu
|
||||
RootedScope emptyGlobalScope(cx, &cx->global()->emptyGlobalScope());
|
||||
|
||||
BytecodeCompiler compiler(cx, cx->tempLifoAlloc(), options, srcBuf, emptyGlobalScope);
|
||||
return compiler.compileStandaloneFunction(fun, NotGenerator, AsyncFunction, parameterListEnd);
|
||||
return compiler.compileStandaloneFunction(fun, GeneratorKind::NotGenerator, AsyncFunction,
|
||||
parameterListEnd);
|
||||
}
|
||||
|
||||
bool
|
||||
@ -766,5 +769,6 @@ frontend::CompileStandaloneAsyncGenerator(JSContext* cx, MutableHandleFunction f
|
||||
RootedScope emptyGlobalScope(cx, &cx->global()->emptyGlobalScope());
|
||||
|
||||
BytecodeCompiler compiler(cx, cx->tempLifoAlloc(), options, srcBuf, emptyGlobalScope);
|
||||
return compiler.compileStandaloneFunction(fun, StarGenerator, AsyncFunction, parameterListEnd);
|
||||
return compiler.compileStandaloneFunction(fun, GeneratorKind::Generator, AsyncFunction,
|
||||
parameterListEnd);
|
||||
}
|
||||
|
@ -399,7 +399,7 @@ class BytecodeEmitter::EmitterScope : public Nestable<BytecodeEmitter::EmitterSc
|
||||
if (nextFrameSlot_ > bce->maxFixedSlots)
|
||||
bce->maxFixedSlots = nextFrameSlot_;
|
||||
MOZ_ASSERT_IF(bce->sc->isFunctionBox() &&
|
||||
(bce->sc->asFunctionBox()->isStarGenerator() ||
|
||||
(bce->sc->asFunctionBox()->isGenerator() ||
|
||||
bce->sc->asFunctionBox()->isAsync()),
|
||||
bce->maxFixedSlots == 0);
|
||||
}
|
||||
@ -4831,7 +4831,7 @@ BytecodeEmitter::isRunOnceLambda()
|
||||
|
||||
FunctionBox* funbox = sc->asFunctionBox();
|
||||
return !funbox->argumentsHasLocalBinding() &&
|
||||
!funbox->isStarGenerator() &&
|
||||
!funbox->isGenerator() &&
|
||||
!funbox->isAsync() &&
|
||||
!funbox->function()->explicitName();
|
||||
}
|
||||
@ -8239,7 +8239,7 @@ BytecodeEmitter::emitFunction(ParseNode* pn, bool needsProto)
|
||||
if (funbox->isAsync()) {
|
||||
MOZ_ASSERT(!needsProto);
|
||||
return emitAsyncWrapper(index, funbox->needsHomeObject(), fun->isArrow(),
|
||||
fun->isStarGenerator());
|
||||
fun->isGenerator());
|
||||
}
|
||||
|
||||
if (fun->isArrow()) {
|
||||
@ -8295,7 +8295,7 @@ BytecodeEmitter::emitFunction(ParseNode* pn, bool needsProto)
|
||||
switchToPrologue();
|
||||
if (funbox->isAsync()) {
|
||||
if (!emitAsyncWrapper(index, fun->isMethod(), fun->isArrow(),
|
||||
fun->isStarGenerator()))
|
||||
fun->isGenerator()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -8314,12 +8314,12 @@ BytecodeEmitter::emitFunction(ParseNode* pn, bool needsProto)
|
||||
// initialize the binding name of the function in the current scope.
|
||||
|
||||
bool isAsync = funbox->isAsync();
|
||||
bool isStarGenerator = funbox->isStarGenerator();
|
||||
auto emitLambda = [index, isAsync, isStarGenerator](BytecodeEmitter* bce,
|
||||
const NameLocation&, bool) {
|
||||
bool isGenerator = funbox->isGenerator();
|
||||
auto emitLambda = [index, isAsync, isGenerator](BytecodeEmitter* bce,
|
||||
const NameLocation&, bool) {
|
||||
if (isAsync) {
|
||||
return bce->emitAsyncWrapper(index, /* needsHomeObject = */ false,
|
||||
/* isArrow = */ false, isStarGenerator);
|
||||
/* isArrow = */ false, isGenerator);
|
||||
}
|
||||
return bce->emitIndexOp(JSOP_LAMBDA, index);
|
||||
};
|
||||
@ -8355,7 +8355,7 @@ BytecodeEmitter::emitAsyncWrapperLambda(unsigned index, bool isArrow) {
|
||||
|
||||
bool
|
||||
BytecodeEmitter::emitAsyncWrapper(unsigned index, bool needsHomeObject, bool isArrow,
|
||||
bool isStarGenerator)
|
||||
bool isGenerator)
|
||||
{
|
||||
// needsHomeObject can be true for propertyList for extended class.
|
||||
// In that case push both unwrapped and wrapped function, in order to
|
||||
@ -8387,7 +8387,7 @@ BytecodeEmitter::emitAsyncWrapper(unsigned index, bool needsHomeObject, bool isA
|
||||
if (!emit1(JSOP_DUP))
|
||||
return false;
|
||||
}
|
||||
if (isStarGenerator) {
|
||||
if (isGenerator) {
|
||||
if (!emit1(JSOP_TOASYNCGEN))
|
||||
return false;
|
||||
} else {
|
||||
@ -8641,7 +8641,7 @@ BytecodeEmitter::emitReturn(ParseNode* pn)
|
||||
return false;
|
||||
|
||||
bool isAsyncGenerator = sc->asFunctionBox()->isAsync() &&
|
||||
sc->asFunctionBox()->isStarGenerator();
|
||||
sc->asFunctionBox()->isGenerator();
|
||||
if (isAsyncGenerator) {
|
||||
if (!emitAwait())
|
||||
return false;
|
||||
@ -8805,7 +8805,7 @@ bool
|
||||
BytecodeEmitter::emitYieldStar(ParseNode* iter)
|
||||
{
|
||||
MOZ_ASSERT(sc->isFunctionBox());
|
||||
MOZ_ASSERT(sc->asFunctionBox()->isStarGenerator());
|
||||
MOZ_ASSERT(sc->asFunctionBox()->isGenerator());
|
||||
|
||||
bool isAsyncGenerator = sc->asFunctionBox()->isAsync();
|
||||
|
||||
@ -9362,7 +9362,7 @@ BytecodeEmitter::emitSelfHostedCallFunction(ParseNode* pn)
|
||||
bool
|
||||
BytecodeEmitter::emitSelfHostedResumeGenerator(ParseNode* pn)
|
||||
{
|
||||
// Syntax: resumeGenerator(gen, value, 'next'|'throw'|'close')
|
||||
// Syntax: resumeGenerator(gen, value, 'next'|'throw'|'return')
|
||||
if (pn->pn_count != 4) {
|
||||
reportError(pn, JSMSG_MORE_ARGS_NEEDED, "resumeGenerator", "1", "s");
|
||||
return false;
|
||||
|
@ -650,7 +650,7 @@ struct MOZ_STACK_CLASS BytecodeEmitter
|
||||
|
||||
MOZ_MUST_USE bool emitAsyncWrapperLambda(unsigned index, bool isArrow);
|
||||
MOZ_MUST_USE bool emitAsyncWrapper(unsigned index, bool needsHomeObject, bool isArrow,
|
||||
bool isStarGenerator);
|
||||
bool isGenerator);
|
||||
|
||||
MOZ_MUST_USE bool emitComputedPropertyName(ParseNode* computedPropName);
|
||||
|
||||
|
@ -1,3 +1,9 @@
|
||||
/* -*- 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/. */
|
||||
|
||||
#ifndef frontend_ParseContext_h
|
||||
#define frontend_ParseContext_h
|
||||
|
||||
@ -620,13 +626,15 @@ class ParseContext : public Nestable<ParseContext>
|
||||
return sc_->isFunctionBox() && sc_->asFunctionBox()->useAsmOrInsideUseAsm();
|
||||
}
|
||||
|
||||
// An ES6 generator is marked as a "star generator" before its body is parsed.
|
||||
// A generator is marked as a generator before its body is parsed.
|
||||
GeneratorKind generatorKind() const {
|
||||
return sc_->isFunctionBox() ? sc_->asFunctionBox()->generatorKind() : NotGenerator;
|
||||
return sc_->isFunctionBox()
|
||||
? sc_->asFunctionBox()->generatorKind()
|
||||
: GeneratorKind::NotGenerator;
|
||||
}
|
||||
|
||||
bool isStarGenerator() const {
|
||||
return generatorKind() == StarGenerator;
|
||||
bool isGenerator() const {
|
||||
return generatorKind() == GeneratorKind::Generator;
|
||||
}
|
||||
|
||||
bool isAsync() const {
|
||||
@ -634,7 +642,7 @@ class ParseContext : public Nestable<ParseContext>
|
||||
}
|
||||
|
||||
bool needsDotGeneratorName() const {
|
||||
return isStarGenerator() || isAsync();
|
||||
return isGenerator() || isAsync();
|
||||
}
|
||||
|
||||
FunctionAsyncKind asyncKind() const {
|
||||
|
@ -466,7 +466,7 @@ FunctionBox::FunctionBox(JSContext* cx, LifoAlloc& alloc, ObjectBox* traceListHe
|
||||
toStringStart(toStringStart),
|
||||
toStringEnd(0),
|
||||
length(0),
|
||||
generatorKindBits_(GeneratorKindAsBits(generatorKind)),
|
||||
generatorKind_(GeneratorKindAsBit(generatorKind)),
|
||||
asyncKindBits_(AsyncKindAsBits(asyncKind)),
|
||||
isGenexpLambda(false),
|
||||
hasDestructuringArgs(false),
|
||||
@ -2515,7 +2515,7 @@ Parser<SyntaxParseHandler, char16_t>::finishFunction(bool isStandaloneFunction /
|
||||
static YieldHandling
|
||||
GetYieldHandling(GeneratorKind generatorKind)
|
||||
{
|
||||
if (generatorKind == NotGenerator)
|
||||
if (generatorKind == GeneratorKind::NotGenerator)
|
||||
return YieldIsName;
|
||||
return YieldIsKeyword;
|
||||
}
|
||||
@ -2553,7 +2553,7 @@ Parser<FullParseHandler, char16_t>::standaloneFunction(HandleFunction fun,
|
||||
|
||||
if (!tokenStream.getToken(&tt))
|
||||
return null();
|
||||
if (generatorKind == StarGenerator) {
|
||||
if (generatorKind == GeneratorKind::Generator) {
|
||||
MOZ_ASSERT(tt == TOK_MUL);
|
||||
if (!tokenStream.getToken(&tt))
|
||||
return null();
|
||||
@ -2720,9 +2720,8 @@ Parser<ParseHandler, CharT>::functionBody(InHandling inHandling, YieldHandling y
|
||||
} else {
|
||||
MOZ_ASSERT(type == ExpressionBody);
|
||||
|
||||
// Async functions are implemented as star generators, and star
|
||||
// generators are assumed to be statement lists, to prepend initial
|
||||
// `yield`.
|
||||
// Async functions are implemented as generators, and generators are
|
||||
// assumed to be statement lists, to prepend initial `yield`.
|
||||
Node stmtList = null();
|
||||
if (pc->isAsync()) {
|
||||
stmtList = handler.newStatementList(pos());
|
||||
@ -2745,11 +2744,11 @@ Parser<ParseHandler, CharT>::functionBody(InHandling inHandling, YieldHandling y
|
||||
}
|
||||
|
||||
switch (pc->generatorKind()) {
|
||||
case NotGenerator:
|
||||
case GeneratorKind::NotGenerator:
|
||||
MOZ_ASSERT_IF(!pc->isAsync(), pc->lastYieldOffset == startYieldOffset);
|
||||
break;
|
||||
|
||||
case StarGenerator:
|
||||
case GeneratorKind::Generator:
|
||||
MOZ_ASSERT(kind != Arrow);
|
||||
MOZ_ASSERT(type == StatementListBody);
|
||||
break;
|
||||
@ -2795,7 +2794,7 @@ ParserBase::newFunction(HandleAtom atom, FunctionSyntaxKind kind,
|
||||
#endif
|
||||
switch (kind) {
|
||||
case Expression:
|
||||
flags = (generatorKind == NotGenerator && asyncKind == SyncFunction
|
||||
flags = (generatorKind == GeneratorKind::NotGenerator && asyncKind == SyncFunction
|
||||
? JSFunction::INTERPRETED_LAMBDA
|
||||
: JSFunction::INTERPRETED_LAMBDA_GENERATOR_OR_ASYNC);
|
||||
break;
|
||||
@ -2804,8 +2803,7 @@ ParserBase::newFunction(HandleAtom atom, FunctionSyntaxKind kind,
|
||||
allocKind = gc::AllocKind::FUNCTION_EXTENDED;
|
||||
break;
|
||||
case Method:
|
||||
MOZ_ASSERT(generatorKind == NotGenerator || generatorKind == StarGenerator);
|
||||
flags = (generatorKind == NotGenerator && asyncKind == SyncFunction
|
||||
flags = (generatorKind == GeneratorKind::NotGenerator && asyncKind == SyncFunction
|
||||
? JSFunction::INTERPRETED_METHOD
|
||||
: JSFunction::INTERPRETED_METHOD_GENERATOR_OR_ASYNC);
|
||||
allocKind = gc::AllocKind::FUNCTION_EXTENDED;
|
||||
@ -2833,7 +2831,7 @@ ParserBase::newFunction(HandleAtom atom, FunctionSyntaxKind kind,
|
||||
allocKind = gc::AllocKind::FUNCTION_EXTENDED;
|
||||
}
|
||||
#endif
|
||||
flags = (generatorKind == NotGenerator && asyncKind == SyncFunction
|
||||
flags = (generatorKind == GeneratorKind::NotGenerator && asyncKind == SyncFunction
|
||||
? JSFunction::INTERPRETED_NORMAL
|
||||
: JSFunction::INTERPRETED_GENERATOR_OR_ASYNC);
|
||||
}
|
||||
@ -3362,12 +3360,12 @@ Parser<ParseHandler, CharT>::functionDefinition(Node pn, uint32_t toStringStart,
|
||||
}
|
||||
|
||||
RootedObject proto(context);
|
||||
if (generatorKind == StarGenerator || asyncKind == AsyncFunction) {
|
||||
if (generatorKind == GeneratorKind::Generator || asyncKind == AsyncFunction) {
|
||||
// If we are off thread, the generator meta-objects have
|
||||
// already been created by js::StartOffThreadParseTask, so cx will not
|
||||
// be necessary.
|
||||
JSContext* cx = context->helperThread() ? nullptr : context;
|
||||
proto = GlobalObject::getOrCreateStarGeneratorFunctionPrototype(cx, context->global());
|
||||
proto = GlobalObject::getOrCreateGeneratorFunctionPrototype(cx, context->global());
|
||||
if (!proto)
|
||||
return null();
|
||||
}
|
||||
@ -3434,8 +3432,12 @@ Parser<FullParseHandler, char16_t>::trySyntaxParseInnerFunction(ParseNode* pn, H
|
||||
// parse to avoid the overhead of a lazy syntax-only parse. Although
|
||||
// the prediction may be incorrect, IIFEs are common enough that it
|
||||
// pays off for lots of code.
|
||||
if (pn->isLikelyIIFE() && generatorKind == NotGenerator && asyncKind == SyncFunction)
|
||||
if (pn->isLikelyIIFE() &&
|
||||
generatorKind == GeneratorKind::NotGenerator &&
|
||||
asyncKind == SyncFunction)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if (!syntaxParser_)
|
||||
break;
|
||||
@ -3712,7 +3714,7 @@ Parser<ParseHandler, CharT>::functionFormalParametersAndBody(InHandling inHandli
|
||||
uint32_t openedPos = 0;
|
||||
if (tt != TOK_LC) {
|
||||
if (kind != Arrow) {
|
||||
if (funbox->isStarGenerator() || funbox->isAsync() || kind == Method ||
|
||||
if (funbox->isGenerator() || funbox->isAsync() || kind == Method ||
|
||||
kind == GetterNoExpressionClosure || kind == SetterNoExpressionClosure ||
|
||||
IsConstructorKind(kind))
|
||||
{
|
||||
@ -3841,9 +3843,9 @@ Parser<ParseHandler, CharT>::functionStmt(uint32_t toStringStart, YieldHandling
|
||||
if (!tokenStream.getToken(&tt))
|
||||
return null();
|
||||
|
||||
GeneratorKind generatorKind = NotGenerator;
|
||||
GeneratorKind generatorKind = GeneratorKind::NotGenerator;
|
||||
if (tt == TOK_MUL) {
|
||||
generatorKind = StarGenerator;
|
||||
generatorKind = GeneratorKind::Generator;
|
||||
if (!tokenStream.getToken(&tt))
|
||||
return null();
|
||||
}
|
||||
@ -3868,9 +3870,11 @@ Parser<ParseHandler, CharT>::functionStmt(uint32_t toStringStart, YieldHandling
|
||||
MOZ_ASSERT(declaredInStmt->kind() != StatementKind::Label);
|
||||
MOZ_ASSERT(StatementKindIsBraced(declaredInStmt->kind()));
|
||||
|
||||
kind = !pc->sc()->strict() && generatorKind == NotGenerator && asyncKind == SyncFunction
|
||||
? DeclarationKind::SloppyLexicalFunction
|
||||
: DeclarationKind::LexicalFunction;
|
||||
kind = (!pc->sc()->strict() &&
|
||||
generatorKind == GeneratorKind::NotGenerator &&
|
||||
asyncKind == SyncFunction)
|
||||
? DeclarationKind::SloppyLexicalFunction
|
||||
: DeclarationKind::LexicalFunction;
|
||||
} else {
|
||||
kind = pc->atModuleLevel()
|
||||
? DeclarationKind::ModuleBodyLevelFunction
|
||||
@ -3906,13 +3910,13 @@ Parser<ParseHandler, CharT>::functionExpr(uint32_t toStringStart, InvokedPredict
|
||||
MOZ_ASSERT(tokenStream.isCurrentTokenType(TOK_FUNCTION));
|
||||
|
||||
AutoAwaitIsKeyword<Parser> awaitIsKeyword(this, GetAwaitHandling(asyncKind));
|
||||
GeneratorKind generatorKind = NotGenerator;
|
||||
GeneratorKind generatorKind = GeneratorKind::NotGenerator;
|
||||
TokenKind tt;
|
||||
if (!tokenStream.getToken(&tt))
|
||||
return null();
|
||||
|
||||
if (tt == TOK_MUL) {
|
||||
generatorKind = StarGenerator;
|
||||
generatorKind = GeneratorKind::Generator;
|
||||
if (!tokenStream.getToken(&tt))
|
||||
return null();
|
||||
}
|
||||
@ -6581,56 +6585,48 @@ Parser<ParseHandler, CharT>::yieldExpression(InHandling inHandling)
|
||||
MOZ_ASSERT(tokenStream.isCurrentTokenType(TOK_YIELD));
|
||||
uint32_t begin = pos().begin;
|
||||
|
||||
switch (pc->generatorKind()) {
|
||||
case StarGenerator:
|
||||
{
|
||||
MOZ_ASSERT(pc->isFunctionBox());
|
||||
MOZ_ASSERT(pc->isGenerator());
|
||||
MOZ_ASSERT(pc->isFunctionBox());
|
||||
|
||||
pc->lastYieldOffset = begin;
|
||||
pc->lastYieldOffset = begin;
|
||||
|
||||
Node exprNode;
|
||||
ParseNodeKind kind = PNK_YIELD;
|
||||
TokenKind tt = TOK_EOF;
|
||||
if (!tokenStream.peekTokenSameLine(&tt, TokenStream::Operand))
|
||||
return null();
|
||||
switch (tt) {
|
||||
// TOK_EOL is special; it implements the [no LineTerminator here]
|
||||
// quirk in the grammar.
|
||||
case TOK_EOL:
|
||||
// The rest of these make up the complete set of tokens that can
|
||||
// appear after any of the places where AssignmentExpression is used
|
||||
// throughout the grammar. Conveniently, none of them can also be the
|
||||
// start an expression.
|
||||
case TOK_EOF:
|
||||
case TOK_SEMI:
|
||||
case TOK_RC:
|
||||
case TOK_RB:
|
||||
case TOK_RP:
|
||||
case TOK_COLON:
|
||||
case TOK_COMMA:
|
||||
case TOK_IN:
|
||||
// No value.
|
||||
exprNode = null();
|
||||
tokenStream.addModifierException(TokenStream::NoneIsOperand);
|
||||
break;
|
||||
case TOK_MUL:
|
||||
kind = PNK_YIELD_STAR;
|
||||
tokenStream.consumeKnownToken(TOK_MUL, TokenStream::Operand);
|
||||
MOZ_FALLTHROUGH;
|
||||
default:
|
||||
exprNode = assignExpr(inHandling, YieldIsKeyword, TripledotProhibited);
|
||||
if (!exprNode)
|
||||
return null();
|
||||
}
|
||||
if (kind == PNK_YIELD_STAR)
|
||||
return handler.newYieldStarExpression(begin, exprNode);
|
||||
return handler.newYieldExpression(begin, exprNode);
|
||||
}
|
||||
case NotGenerator:
|
||||
Node exprNode;
|
||||
ParseNodeKind kind = PNK_YIELD;
|
||||
TokenKind tt = TOK_EOF;
|
||||
if (!tokenStream.peekTokenSameLine(&tt, TokenStream::Operand))
|
||||
return null();
|
||||
switch (tt) {
|
||||
// TOK_EOL is special; it implements the [no LineTerminator here]
|
||||
// quirk in the grammar.
|
||||
case TOK_EOL:
|
||||
// The rest of these make up the complete set of tokens that can
|
||||
// appear after any of the places where AssignmentExpression is used
|
||||
// throughout the grammar. Conveniently, none of them can also be the
|
||||
// start an expression.
|
||||
case TOK_EOF:
|
||||
case TOK_SEMI:
|
||||
case TOK_RC:
|
||||
case TOK_RB:
|
||||
case TOK_RP:
|
||||
case TOK_COLON:
|
||||
case TOK_COMMA:
|
||||
case TOK_IN:
|
||||
// No value.
|
||||
exprNode = null();
|
||||
tokenStream.addModifierException(TokenStream::NoneIsOperand);
|
||||
break;
|
||||
case TOK_MUL:
|
||||
kind = PNK_YIELD_STAR;
|
||||
tokenStream.consumeKnownToken(TOK_MUL, TokenStream::Operand);
|
||||
MOZ_FALLTHROUGH;
|
||||
default:
|
||||
exprNode = assignExpr(inHandling, YieldIsKeyword, TripledotProhibited);
|
||||
if (!exprNode)
|
||||
return null();
|
||||
}
|
||||
|
||||
MOZ_CRASH("yieldExpr");
|
||||
if (kind == PNK_YIELD_STAR)
|
||||
return handler.newYieldStarExpression(begin, exprNode);
|
||||
return handler.newYieldExpression(begin, exprNode);
|
||||
}
|
||||
|
||||
template <class ParseHandler, typename CharT>
|
||||
@ -8114,7 +8110,7 @@ Parser<ParseHandler, CharT>::assignExpr(InHandling inHandling, YieldHandling yie
|
||||
return null();
|
||||
|
||||
return functionDefinition(pn, toStringStart, inHandling, yieldHandling, nullptr,
|
||||
Arrow, NotGenerator, asyncKind);
|
||||
Arrow, GeneratorKind::NotGenerator, asyncKind);
|
||||
}
|
||||
|
||||
default:
|
||||
@ -8384,19 +8380,19 @@ Parser<ParseHandler, CharT>::generatorComprehensionLambda(unsigned begin)
|
||||
// be necessary.
|
||||
RootedObject proto(context);
|
||||
JSContext* cx = context->helperThread() ? nullptr : context;
|
||||
proto = GlobalObject::getOrCreateStarGeneratorFunctionPrototype(cx, context->global());
|
||||
proto = GlobalObject::getOrCreateGeneratorFunctionPrototype(cx, context->global());
|
||||
if (!proto)
|
||||
return null();
|
||||
|
||||
RootedFunction fun(context, newFunction(/* atom = */ nullptr, Expression,
|
||||
StarGenerator, SyncFunction, proto));
|
||||
GeneratorKind::Generator, SyncFunction, proto));
|
||||
if (!fun)
|
||||
return null();
|
||||
|
||||
// Create box for fun->object early to root it.
|
||||
Directives directives(/* strict = */ outerpc->sc()->strict());
|
||||
FunctionBox* genFunbox = newFunctionBox(genfn, fun, /* toStringStart = */ begin, directives,
|
||||
StarGenerator, SyncFunction);
|
||||
GeneratorKind::Generator, SyncFunction);
|
||||
if (!genFunbox)
|
||||
return null();
|
||||
genFunbox->isGenexpLambda = true;
|
||||
@ -8423,7 +8419,7 @@ Parser<ParseHandler, CharT>::generatorComprehensionLambda(unsigned begin)
|
||||
if (!body)
|
||||
return null();
|
||||
|
||||
Node comp = comprehension(StarGenerator);
|
||||
Node comp = comprehension(GeneratorKind::Generator);
|
||||
if (!comp)
|
||||
return null();
|
||||
|
||||
@ -8584,10 +8580,10 @@ Parser<ParseHandler, CharT>::comprehensionTail(GeneratorKind comprehensionKind)
|
||||
if (!bodyExpr)
|
||||
return null();
|
||||
|
||||
if (comprehensionKind == NotGenerator)
|
||||
if (comprehensionKind == GeneratorKind::NotGenerator)
|
||||
return handler.newArrayPush(begin, bodyExpr);
|
||||
|
||||
MOZ_ASSERT(comprehensionKind == StarGenerator);
|
||||
MOZ_ASSERT(comprehensionKind == GeneratorKind::Generator);
|
||||
Node yieldExpr = handler.newYieldExpression(begin, bodyExpr);
|
||||
if (!yieldExpr)
|
||||
return null();
|
||||
@ -8610,7 +8606,7 @@ Parser<ParseHandler, CharT>::comprehension(GeneratorKind comprehensionKind)
|
||||
if (!body)
|
||||
return null();
|
||||
|
||||
if (comprehensionKind != NotGenerator && pc->lastYieldOffset != startYieldOffset) {
|
||||
if (comprehensionKind == GeneratorKind::Generator && pc->lastYieldOffset != startYieldOffset) {
|
||||
errorAt(pc->lastYieldOffset, JSMSG_BAD_GENEXP_BODY, js_yield_str);
|
||||
return null();
|
||||
}
|
||||
@ -8622,7 +8618,7 @@ template <class ParseHandler, typename CharT>
|
||||
typename ParseHandler::Node
|
||||
Parser<ParseHandler, CharT>::arrayComprehension(uint32_t begin)
|
||||
{
|
||||
Node inner = comprehension(NotGenerator);
|
||||
Node inner = comprehension(GeneratorKind::NotGenerator);
|
||||
if (!inner)
|
||||
return null();
|
||||
|
||||
@ -9914,8 +9910,8 @@ Parser<ParseHandler, CharT>::methodDefinition(uint32_t toStringStart, PropertyTy
|
||||
|
||||
GeneratorKind generatorKind = (propType == PropertyType::GeneratorMethod ||
|
||||
propType == PropertyType::AsyncGeneratorMethod)
|
||||
? StarGenerator
|
||||
: NotGenerator;
|
||||
? GeneratorKind::Generator
|
||||
: GeneratorKind::NotGenerator;
|
||||
|
||||
FunctionAsyncKind asyncKind = (propType == PropertyType::AsyncMethod ||
|
||||
propType == PropertyType::AsyncGeneratorMethod)
|
||||
|
@ -172,8 +172,8 @@ class ParserBase : public StrictModeGetter
|
||||
TokenPos pos() const { return tokenStream.currentToken().pos; }
|
||||
|
||||
// Determine whether |yield| is a valid name in the current context.
|
||||
bool yieldExpressionsSupported() {
|
||||
return pc->isStarGenerator();
|
||||
bool yieldExpressionsSupported() const {
|
||||
return pc->isGenerator();
|
||||
}
|
||||
|
||||
virtual bool strictMode() { return pc->sc()->strict(); }
|
||||
|
@ -404,7 +404,7 @@ class FunctionBox : public ObjectBox, public SharedContext
|
||||
uint32_t toStringEnd;
|
||||
uint16_t length;
|
||||
|
||||
uint8_t generatorKindBits_; /* The GeneratorKind of this function. */
|
||||
uint8_t generatorKind_; /* The GeneratorKind of this function. */
|
||||
uint8_t asyncKindBits_; /* The FunctionAsyncKind of this function. */
|
||||
|
||||
bool isGenexpLambda:1; /* lambda from generator expression */
|
||||
@ -468,7 +468,7 @@ class FunctionBox : public ObjectBox, public SharedContext
|
||||
return hasExtensibleScope() ||
|
||||
needsHomeObject() ||
|
||||
isDerivedClassConstructor() ||
|
||||
isStarGenerator() ||
|
||||
isGenerator() ||
|
||||
isAsync();
|
||||
}
|
||||
|
||||
@ -487,18 +487,18 @@ class FunctionBox : public ObjectBox, public SharedContext
|
||||
return usesArguments && usesApply && usesThis && !usesReturn;
|
||||
}
|
||||
|
||||
GeneratorKind generatorKind() const { return GeneratorKindFromBits(generatorKindBits_); }
|
||||
bool isStarGenerator() const { return generatorKind() == StarGenerator; }
|
||||
GeneratorKind generatorKind() const { return GeneratorKindFromBit(generatorKind_); }
|
||||
bool isGenerator() const { return generatorKind() == GeneratorKind::Generator; }
|
||||
FunctionAsyncKind asyncKind() const { return AsyncKindFromBits(asyncKindBits_); }
|
||||
|
||||
bool needsFinalYield() const {
|
||||
return isStarGenerator() || isAsync();
|
||||
return isGenerator() || isAsync();
|
||||
}
|
||||
bool needsDotGeneratorName() const {
|
||||
return isStarGenerator() || isAsync();
|
||||
return isGenerator() || isAsync();
|
||||
}
|
||||
bool needsIteratorResult() const {
|
||||
return isStarGenerator();
|
||||
return isGenerator();
|
||||
}
|
||||
|
||||
bool isAsync() const { return asyncKind() == AsyncFunction; }
|
||||
@ -514,14 +514,6 @@ class FunctionBox : public ObjectBox, public SharedContext
|
||||
isExprBody_ = true;
|
||||
}
|
||||
|
||||
void setGeneratorKind(GeneratorKind kind) {
|
||||
// A generator kind can be set at initialization, or when "yield" is
|
||||
// first seen. In both cases the transition can only happen from
|
||||
// NotGenerator.
|
||||
MOZ_ASSERT(!isStarGenerator());
|
||||
generatorKindBits_ = GeneratorKindAsBits(kind);
|
||||
}
|
||||
|
||||
bool hasExtensibleScope() const { return funCxFlags.hasExtensibleScope; }
|
||||
bool hasThisBinding() const { return funCxFlags.hasThisBinding; }
|
||||
bool argumentsHasLocalBinding() const { return funCxFlags.argumentsHasLocalBinding; }
|
||||
@ -621,7 +613,7 @@ SharedContext::allBindingsClosedOver()
|
||||
{
|
||||
return bindingsAccessedDynamically() ||
|
||||
(isFunctionBox() &&
|
||||
(asFunctionBox()->isStarGenerator() ||
|
||||
(asFunctionBox()->isGenerator() ||
|
||||
asFunctionBox()->isAsync()));
|
||||
}
|
||||
|
||||
|
@ -22,92 +22,80 @@
|
||||
namespace js {
|
||||
namespace gc {
|
||||
|
||||
/* The GC allocation kinds. */
|
||||
// FIXME: uint8_t would make more sense for the underlying type, but causes
|
||||
// miscompilations in GCC (fixed in 4.8.5 and 4.9.3). See also bug 1143966.
|
||||
enum class AllocKind {
|
||||
FIRST,
|
||||
OBJECT_FIRST = FIRST,
|
||||
FUNCTION = FIRST,
|
||||
FUNCTION_EXTENDED,
|
||||
OBJECT0,
|
||||
OBJECT0_BACKGROUND,
|
||||
OBJECT2,
|
||||
OBJECT2_BACKGROUND,
|
||||
OBJECT4,
|
||||
OBJECT4_BACKGROUND,
|
||||
OBJECT8,
|
||||
OBJECT8_BACKGROUND,
|
||||
OBJECT12,
|
||||
OBJECT12_BACKGROUND,
|
||||
OBJECT16,
|
||||
OBJECT16_BACKGROUND,
|
||||
OBJECT_LIMIT,
|
||||
OBJECT_LAST = OBJECT_LIMIT - 1,
|
||||
SCRIPT,
|
||||
LAZY_SCRIPT,
|
||||
SHAPE,
|
||||
ACCESSOR_SHAPE,
|
||||
BASE_SHAPE,
|
||||
OBJECT_GROUP,
|
||||
FAT_INLINE_STRING,
|
||||
STRING,
|
||||
EXTERNAL_STRING,
|
||||
FAT_INLINE_ATOM,
|
||||
ATOM,
|
||||
SYMBOL,
|
||||
JITCODE,
|
||||
SCOPE,
|
||||
REGEXP_SHARED,
|
||||
LIMIT,
|
||||
LAST = LIMIT - 1
|
||||
};
|
||||
// The GC allocation kinds.
|
||||
//
|
||||
// These are defined by macros which enumerate the different allocation kinds
|
||||
// and supply the following information:
|
||||
//
|
||||
// - the corresponding AllocKind
|
||||
// - their JS::TraceKind
|
||||
// - their C++ base type
|
||||
// - a C++ type of the correct size
|
||||
// - whether they can be finalized on the background thread
|
||||
// - whether they can be allocated in the nursery
|
||||
|
||||
// Macro to enumerate the different allocation kinds supplying information about
|
||||
// the trace kind, C++ type and allocation size.
|
||||
#define FOR_EACH_OBJECT_ALLOCKIND(D) \
|
||||
/* AllocKind TraceKind TypeName SizedType */ \
|
||||
D(FUNCTION, Object, JSObject, JSFunction) \
|
||||
D(FUNCTION_EXTENDED, Object, JSObject, FunctionExtended) \
|
||||
D(OBJECT0, Object, JSObject, JSObject_Slots0) \
|
||||
D(OBJECT0_BACKGROUND, Object, JSObject, JSObject_Slots0) \
|
||||
D(OBJECT2, Object, JSObject, JSObject_Slots2) \
|
||||
D(OBJECT2_BACKGROUND, Object, JSObject, JSObject_Slots2) \
|
||||
D(OBJECT4, Object, JSObject, JSObject_Slots4) \
|
||||
D(OBJECT4_BACKGROUND, Object, JSObject, JSObject_Slots4) \
|
||||
D(OBJECT8, Object, JSObject, JSObject_Slots8) \
|
||||
D(OBJECT8_BACKGROUND, Object, JSObject, JSObject_Slots8) \
|
||||
D(OBJECT12, Object, JSObject, JSObject_Slots12) \
|
||||
D(OBJECT12_BACKGROUND, Object, JSObject, JSObject_Slots12) \
|
||||
D(OBJECT16, Object, JSObject, JSObject_Slots16) \
|
||||
D(OBJECT16_BACKGROUND, Object, JSObject, JSObject_Slots16)
|
||||
/* AllocKind TraceKind TypeName SizedType BGFinal Nursery */ \
|
||||
D(FUNCTION, Object, JSObject, JSFunction, true, true) \
|
||||
D(FUNCTION_EXTENDED, Object, JSObject, FunctionExtended, true, true) \
|
||||
D(OBJECT0, Object, JSObject, JSObject_Slots0, false, false) \
|
||||
D(OBJECT0_BACKGROUND, Object, JSObject, JSObject_Slots0, true, true) \
|
||||
D(OBJECT2, Object, JSObject, JSObject_Slots2, false, false) \
|
||||
D(OBJECT2_BACKGROUND, Object, JSObject, JSObject_Slots2, true, true) \
|
||||
D(OBJECT4, Object, JSObject, JSObject_Slots4, false, false) \
|
||||
D(OBJECT4_BACKGROUND, Object, JSObject, JSObject_Slots4, true, true) \
|
||||
D(OBJECT8, Object, JSObject, JSObject_Slots8, false, false) \
|
||||
D(OBJECT8_BACKGROUND, Object, JSObject, JSObject_Slots8, true, true) \
|
||||
D(OBJECT12, Object, JSObject, JSObject_Slots12, false, false) \
|
||||
D(OBJECT12_BACKGROUND, Object, JSObject, JSObject_Slots12, true, true) \
|
||||
D(OBJECT16, Object, JSObject, JSObject_Slots16, false, false) \
|
||||
D(OBJECT16_BACKGROUND, Object, JSObject, JSObject_Slots16, true, true)
|
||||
|
||||
#define FOR_EACH_NONOBJECT_ALLOCKIND(D) \
|
||||
/* AllocKind TraceKind TypeName SizedType */ \
|
||||
D(SCRIPT, Script, JSScript, JSScript) \
|
||||
D(LAZY_SCRIPT, LazyScript, js::LazyScript, js::LazyScript) \
|
||||
D(SHAPE, Shape, js::Shape, js::Shape) \
|
||||
D(ACCESSOR_SHAPE, Shape, js::AccessorShape, js::AccessorShape) \
|
||||
D(BASE_SHAPE, BaseShape, js::BaseShape, js::BaseShape) \
|
||||
D(OBJECT_GROUP, ObjectGroup, js::ObjectGroup, js::ObjectGroup) \
|
||||
D(FAT_INLINE_STRING, String, JSFatInlineString, JSFatInlineString) \
|
||||
D(STRING, String, JSString, JSString) \
|
||||
D(EXTERNAL_STRING, String, JSExternalString, JSExternalString) \
|
||||
D(FAT_INLINE_ATOM, String, js::FatInlineAtom, js::FatInlineAtom) \
|
||||
D(ATOM, String, js::NormalAtom, js::NormalAtom) \
|
||||
D(SYMBOL, Symbol, JS::Symbol, JS::Symbol) \
|
||||
D(JITCODE, JitCode, js::jit::JitCode, js::jit::JitCode) \
|
||||
D(SCOPE, Scope, js::Scope, js::Scope) \
|
||||
D(REGEXP_SHARED, RegExpShared, js::RegExpShared, js::RegExpShared)
|
||||
/* AllocKind TraceKind TypeName SizedType BGFinal Nursery */ \
|
||||
D(SCRIPT, Script, JSScript, JSScript, false, false) \
|
||||
D(LAZY_SCRIPT, LazyScript, js::LazyScript, js::LazyScript, true, false) \
|
||||
D(SHAPE, Shape, js::Shape, js::Shape, true, false) \
|
||||
D(ACCESSOR_SHAPE, Shape, js::AccessorShape, js::AccessorShape, true, false) \
|
||||
D(BASE_SHAPE, BaseShape, js::BaseShape, js::BaseShape, true, false) \
|
||||
D(OBJECT_GROUP, ObjectGroup, js::ObjectGroup, js::ObjectGroup, true, false) \
|
||||
D(FAT_INLINE_STRING, String, JSFatInlineString, JSFatInlineString, true, false) \
|
||||
D(STRING, String, JSString, JSString, true, false) \
|
||||
D(EXTERNAL_STRING, String, JSExternalString, JSExternalString, true, false) \
|
||||
D(FAT_INLINE_ATOM, String, js::FatInlineAtom, js::FatInlineAtom, true, false) \
|
||||
D(ATOM, String, js::NormalAtom, js::NormalAtom, true, false) \
|
||||
D(SYMBOL, Symbol, JS::Symbol, JS::Symbol, true, false) \
|
||||
D(JITCODE, JitCode, js::jit::JitCode, js::jit::JitCode, false, false) \
|
||||
D(SCOPE, Scope, js::Scope, js::Scope, true, false) \
|
||||
D(REGEXP_SHARED, RegExpShared, js::RegExpShared, js::RegExpShared, true, false)
|
||||
|
||||
#define FOR_EACH_ALLOCKIND(D) \
|
||||
FOR_EACH_OBJECT_ALLOCKIND(D) \
|
||||
FOR_EACH_NONOBJECT_ALLOCKIND(D)
|
||||
|
||||
static_assert(int(AllocKind::FIRST) == 0, "Various places depend on AllocKind starting at 0, "
|
||||
"please audit them carefully!");
|
||||
static_assert(int(AllocKind::OBJECT_FIRST) == 0, "Various places depend on AllocKind::OBJECT_FIRST "
|
||||
"being 0, please audit them carefully!");
|
||||
enum class AllocKind : uint8_t {
|
||||
#define DEFINE_ALLOC_KIND(allocKind, _1, _2, _3, _4, _5) allocKind,
|
||||
|
||||
FOR_EACH_OBJECT_ALLOCKIND(DEFINE_ALLOC_KIND)
|
||||
|
||||
OBJECT_LIMIT,
|
||||
OBJECT_LAST = OBJECT_LIMIT - 1,
|
||||
|
||||
FOR_EACH_NONOBJECT_ALLOCKIND(DEFINE_ALLOC_KIND)
|
||||
|
||||
LIMIT,
|
||||
LAST = LIMIT - 1,
|
||||
|
||||
FIRST = 0,
|
||||
OBJECT_FIRST = FUNCTION // Hardcoded to first object kind.
|
||||
|
||||
#undef DEFINE_ALLOC_KIND
|
||||
};
|
||||
|
||||
static_assert(int(AllocKind::FIRST) == 0,
|
||||
"Various places depend on AllocKind starting at 0");
|
||||
static_assert(int(AllocKind::OBJECT_FIRST) == 0,
|
||||
"OBJECT_FIRST must be defined as the first object kind");
|
||||
|
||||
inline bool
|
||||
IsAllocKind(AllocKind kind)
|
||||
@ -173,7 +161,7 @@ static inline JS::TraceKind
|
||||
MapAllocToTraceKind(AllocKind kind)
|
||||
{
|
||||
static const JS::TraceKind map[] = {
|
||||
#define EXPAND_ELEMENT(allocKind, traceKind, type, sizedType) \
|
||||
#define EXPAND_ELEMENT(allocKind, traceKind, type, sizedType, bgFinal, nursery) \
|
||||
JS::TraceKind::traceKind,
|
||||
FOR_EACH_ALLOCKIND(EXPAND_ELEMENT)
|
||||
#undef EXPAND_ELEMENT
|
||||
@ -195,37 +183,13 @@ static inline bool
|
||||
IsNurseryAllocable(AllocKind kind)
|
||||
{
|
||||
MOZ_ASSERT(IsValidAllocKind(kind));
|
||||
|
||||
static const bool map[] = {
|
||||
true, /* AllocKind::FUNCTION */
|
||||
true, /* AllocKind::FUNCTION_EXTENDED */
|
||||
false, /* AllocKind::OBJECT0 */
|
||||
true, /* AllocKind::OBJECT0_BACKGROUND */
|
||||
false, /* AllocKind::OBJECT2 */
|
||||
true, /* AllocKind::OBJECT2_BACKGROUND */
|
||||
false, /* AllocKind::OBJECT4 */
|
||||
true, /* AllocKind::OBJECT4_BACKGROUND */
|
||||
false, /* AllocKind::OBJECT8 */
|
||||
true, /* AllocKind::OBJECT8_BACKGROUND */
|
||||
false, /* AllocKind::OBJECT12 */
|
||||
true, /* AllocKind::OBJECT12_BACKGROUND */
|
||||
false, /* AllocKind::OBJECT16 */
|
||||
true, /* AllocKind::OBJECT16_BACKGROUND */
|
||||
false, /* AllocKind::SCRIPT */
|
||||
false, /* AllocKind::LAZY_SCRIPT */
|
||||
false, /* AllocKind::SHAPE */
|
||||
false, /* AllocKind::ACCESSOR_SHAPE */
|
||||
false, /* AllocKind::BASE_SHAPE */
|
||||
false, /* AllocKind::OBJECT_GROUP */
|
||||
false, /* AllocKind::FAT_INLINE_STRING */
|
||||
false, /* AllocKind::STRING */
|
||||
false, /* AllocKind::EXTERNAL_STRING */
|
||||
false, /* AllocKind::FAT_INLINE_ATOM */
|
||||
false, /* AllocKind::ATOM */
|
||||
false, /* AllocKind::SYMBOL */
|
||||
false, /* AllocKind::JITCODE */
|
||||
false, /* AllocKind::SCOPE */
|
||||
false, /* AllocKind::REGEXP_SHARED */
|
||||
#define DEFINE_NURSERY_ALLOCABLE(_1, _2, _3, _4, _5, nursery) nursery,
|
||||
FOR_EACH_ALLOCKIND(DEFINE_NURSERY_ALLOCABLE)
|
||||
#undef DEFINE_NURSERY_ALLOCABLE
|
||||
};
|
||||
|
||||
JS_STATIC_ASSERT(JS_ARRAY_LENGTH(map) == size_t(AllocKind::LIMIT));
|
||||
return map[size_t(kind)];
|
||||
}
|
||||
@ -234,37 +198,13 @@ static inline bool
|
||||
IsBackgroundFinalized(AllocKind kind)
|
||||
{
|
||||
MOZ_ASSERT(IsValidAllocKind(kind));
|
||||
|
||||
static const bool map[] = {
|
||||
true, /* AllocKind::FUNCTION */
|
||||
true, /* AllocKind::FUNCTION_EXTENDED */
|
||||
false, /* AllocKind::OBJECT0 */
|
||||
true, /* AllocKind::OBJECT0_BACKGROUND */
|
||||
false, /* AllocKind::OBJECT2 */
|
||||
true, /* AllocKind::OBJECT2_BACKGROUND */
|
||||
false, /* AllocKind::OBJECT4 */
|
||||
true, /* AllocKind::OBJECT4_BACKGROUND */
|
||||
false, /* AllocKind::OBJECT8 */
|
||||
true, /* AllocKind::OBJECT8_BACKGROUND */
|
||||
false, /* AllocKind::OBJECT12 */
|
||||
true, /* AllocKind::OBJECT12_BACKGROUND */
|
||||
false, /* AllocKind::OBJECT16 */
|
||||
true, /* AllocKind::OBJECT16_BACKGROUND */
|
||||
false, /* AllocKind::SCRIPT */
|
||||
true, /* AllocKind::LAZY_SCRIPT */
|
||||
true, /* AllocKind::SHAPE */
|
||||
true, /* AllocKind::ACCESSOR_SHAPE */
|
||||
true, /* AllocKind::BASE_SHAPE */
|
||||
true, /* AllocKind::OBJECT_GROUP */
|
||||
true, /* AllocKind::FAT_INLINE_STRING */
|
||||
true, /* AllocKind::STRING */
|
||||
true, /* AllocKind::EXTERNAL_STRING */
|
||||
true, /* AllocKind::FAT_INLINE_ATOM */
|
||||
true, /* AllocKind::ATOM */
|
||||
true, /* AllocKind::SYMBOL */
|
||||
false, /* AllocKind::JITCODE */
|
||||
true, /* AllocKind::SCOPE */
|
||||
true, /* AllocKind::REGEXP_SHARED */
|
||||
#define DEFINE_BACKGROUND_FINALIZED(_1, _2, _3, _4, bgFinal, _5) bgFinal,
|
||||
FOR_EACH_ALLOCKIND(DEFINE_BACKGROUND_FINALIZED)
|
||||
#undef DEFINE_BG_FINALIZE
|
||||
};
|
||||
|
||||
JS_STATIC_ASSERT(JS_ARRAY_LENGTH(map) == size_t(AllocKind::LIMIT));
|
||||
return map[size_t(kind)];
|
||||
}
|
||||
|
@ -147,7 +147,7 @@ js::Allocate(JSContext* cx)
|
||||
return GCRuntime::tryNewTenuredThing<T, allowGC>(cx, kind, thingSize);
|
||||
}
|
||||
|
||||
#define DECL_ALLOCATOR_INSTANCES(allocKind, traceKind, type, sizedType) \
|
||||
#define DECL_ALLOCATOR_INSTANCES(allocKind, traceKind, type, sizedType, bgFinal, nursery) \
|
||||
template type* js::Allocate<type, NoGC>(JSContext* cx);\
|
||||
template type* js::Allocate<type, CanGC>(JSContext* cx);
|
||||
FOR_EACH_NONOBJECT_ALLOCKIND(DECL_ALLOCATOR_INSTANCES)
|
||||
|
@ -42,7 +42,7 @@ TraceManuallyBarrieredGenericPointerEdge(JSTracer* trc, gc::Cell** thingp, const
|
||||
namespace gc {
|
||||
|
||||
class Arena;
|
||||
enum class AllocKind;
|
||||
enum class AllocKind : uint8_t;
|
||||
struct Chunk;
|
||||
class TenuredCell;
|
||||
|
||||
|
@ -65,7 +65,7 @@ struct Cell;
|
||||
class MinorCollectionTracer;
|
||||
class RelocationOverlay;
|
||||
struct TenureCountCache;
|
||||
enum class AllocKind;
|
||||
enum class AllocKind : uint8_t;
|
||||
class TenuredCell;
|
||||
} /* namespace gc */
|
||||
|
||||
|
@ -1789,18 +1789,6 @@ HandleLexicalCheckFailure(JSContext* cx, HandleScript outerScript, HandleScript
|
||||
Invalidate(cx, innerScript);
|
||||
}
|
||||
|
||||
static void
|
||||
HandleIterNextNonStringBailout(JSContext* cx, HandleScript outerScript, HandleScript innerScript)
|
||||
{
|
||||
JitSpew(JitSpew_IonBailouts, "Non-string iterator value %s:%zu, inlined into %s:%zu",
|
||||
innerScript->filename(), innerScript->lineno(),
|
||||
outerScript->filename(), outerScript->lineno());
|
||||
|
||||
// This should only happen when legacy generators are used.
|
||||
ForbidCompilation(cx, innerScript);
|
||||
InvalidateAfterBailout(cx, outerScript, "non-string iterator value");
|
||||
}
|
||||
|
||||
static bool
|
||||
CopyFromRematerializedFrame(JSContext* cx, JitActivation* act, uint8_t* fp, size_t inlineDepth,
|
||||
BaselineFrame* frame)
|
||||
@ -2041,10 +2029,6 @@ jit::FinishBailoutToBaseline(BaselineBailoutInfo* bailoutInfo)
|
||||
HandleBaselineInfoBailout(cx, outerScript, innerScript);
|
||||
break;
|
||||
|
||||
case Bailout_IterNextNonString:
|
||||
HandleIterNextNonStringBailout(cx, outerScript, innerScript);
|
||||
break;
|
||||
|
||||
case Bailout_ArgumentCheck:
|
||||
// Do nothing, bailout will resume before the argument monitor ICs.
|
||||
break;
|
||||
|
@ -4688,7 +4688,7 @@ static const VMFunction InterpretResumeInfo =
|
||||
typedef bool (*GeneratorThrowFn)(JSContext*, BaselineFrame*, Handle<GeneratorObject*>,
|
||||
HandleValue, uint32_t);
|
||||
static const VMFunction GeneratorThrowInfo =
|
||||
FunctionInfo<GeneratorThrowFn>(jit::GeneratorThrowOrClose, "GeneratorThrowOrClose", TailCall);
|
||||
FunctionInfo<GeneratorThrowFn>(jit::GeneratorThrowOrReturn, "GeneratorThrowOrReturn", TailCall);
|
||||
|
||||
bool
|
||||
BaselineCompiler::emit_JSOP_RESUME()
|
||||
@ -4871,7 +4871,7 @@ BaselineCompiler::emit_JSOP_RESUME()
|
||||
Address(genObj, GeneratorObject::offsetOfYieldAndAwaitIndexSlot()));
|
||||
masm.jump(scratch1);
|
||||
} else {
|
||||
MOZ_ASSERT(resumeKind == GeneratorObject::THROW || resumeKind == GeneratorObject::CLOSE);
|
||||
MOZ_ASSERT(resumeKind == GeneratorObject::THROW || resumeKind == GeneratorObject::RETURN);
|
||||
|
||||
// Update the frame's frameSize field.
|
||||
masm.computeEffectiveAddress(Address(BaselineFrameReg, BaselineFrame::FramePointerOffset),
|
||||
@ -4897,7 +4897,7 @@ BaselineCompiler::emit_JSOP_RESUME()
|
||||
|
||||
// Push the frame descriptor and a dummy return address (it doesn't
|
||||
// matter what we push here, frame iterators will use the frame pc
|
||||
// set in jit::GeneratorThrowOrClose).
|
||||
// set in jit::GeneratorThrowOrReturn).
|
||||
masm.push(scratch1);
|
||||
|
||||
// On ARM64, the callee will push the return address.
|
||||
@ -4916,8 +4916,8 @@ BaselineCompiler::emit_JSOP_RESUME()
|
||||
} else if (resumeKind == GeneratorObject::THROW) {
|
||||
pushArg(ImmGCPtr(cx->names().throw_));
|
||||
} else {
|
||||
MOZ_ASSERT(resumeKind == GeneratorObject::CLOSE);
|
||||
pushArg(ImmGCPtr(cx->names().close));
|
||||
MOZ_ASSERT(resumeKind == GeneratorObject::RETURN);
|
||||
pushArg(ImmGCPtr(cx->names().return_));
|
||||
}
|
||||
|
||||
masm.loadValue(frame.addressOfStackValue(frame.peek(-1)), retVal);
|
||||
|
@ -2325,13 +2325,13 @@ TryAttachCallStub(JSContext* cx, ICCall_Fallback* stub, HandleScript script, jsb
|
||||
return true;
|
||||
}
|
||||
|
||||
if (fun->native() == intrinsic_IsSuspendedStarGenerator) {
|
||||
if (fun->native() == intrinsic_IsSuspendedGenerator) {
|
||||
// This intrinsic only appears in self-hosted code.
|
||||
MOZ_ASSERT(op != JSOP_NEW);
|
||||
MOZ_ASSERT(argc == 1);
|
||||
JitSpew(JitSpew_BaselineIC, " Generating Call_IsSuspendedStarGenerator stub");
|
||||
JitSpew(JitSpew_BaselineIC, " Generating Call_IsSuspendedGenerator stub");
|
||||
|
||||
ICCall_IsSuspendedStarGenerator::Compiler compiler(cx);
|
||||
ICCall_IsSuspendedGenerator::Compiler compiler(cx);
|
||||
ICStub* newStub = compiler.getStub(compiler.getStubSpace(script));
|
||||
if (!newStub)
|
||||
return false;
|
||||
@ -3431,13 +3431,13 @@ ICCall_ConstStringSplit::Compiler::generateStubCode(MacroAssembler& masm)
|
||||
}
|
||||
|
||||
bool
|
||||
ICCall_IsSuspendedStarGenerator::Compiler::generateStubCode(MacroAssembler& masm)
|
||||
ICCall_IsSuspendedGenerator::Compiler::generateStubCode(MacroAssembler& masm)
|
||||
{
|
||||
MOZ_ASSERT(engine_ == Engine::Baseline);
|
||||
|
||||
// The IsSuspendedStarGenerator intrinsic is only called in self-hosted
|
||||
// code, so it's safe to assume we have a single argument and the callee
|
||||
// is our intrinsic.
|
||||
// The IsSuspendedGenerator intrinsic is only called in self-hosted code,
|
||||
// so it's safe to assume we have a single argument and the callee is our
|
||||
// intrinsic.
|
||||
|
||||
AllocatableGeneralRegisterSet regs(availableGeneralRegs(0));
|
||||
|
||||
@ -3452,9 +3452,9 @@ ICCall_IsSuspendedStarGenerator::Compiler::generateStubCode(MacroAssembler& masm
|
||||
masm.branchTestObject(Assembler::NotEqual, argVal, &returnFalse);
|
||||
masm.unboxObject(argVal, genObj);
|
||||
|
||||
// Check if it's a StarGeneratorObject.
|
||||
// Check if it's a GeneratorObject.
|
||||
Register scratch = regs.takeAny();
|
||||
masm.branchTestObjClass(Assembler::NotEqual, genObj, scratch, &StarGeneratorObject::class_,
|
||||
masm.branchTestObjClass(Assembler::NotEqual, genObj, scratch, &GeneratorObject::class_,
|
||||
&returnFalse);
|
||||
|
||||
// If the yield index slot holds an int32 value < YIELD_AND_AWAIT_INDEX_CLOSING,
|
||||
@ -3463,7 +3463,7 @@ ICCall_IsSuspendedStarGenerator::Compiler::generateStubCode(MacroAssembler& masm
|
||||
masm.branchTestInt32(Assembler::NotEqual, argVal, &returnFalse);
|
||||
masm.unboxInt32(argVal, scratch);
|
||||
masm.branch32(Assembler::AboveOrEqual, scratch,
|
||||
Imm32(StarGeneratorObject::YIELD_AND_AWAIT_INDEX_CLOSING),
|
||||
Imm32(GeneratorObject::YIELD_AND_AWAIT_INDEX_CLOSING),
|
||||
&returnFalse);
|
||||
|
||||
masm.moveValue(BooleanValue(true), R0);
|
||||
@ -4274,16 +4274,15 @@ ICIteratorMore_Native::Compiler::generateStubCode(MacroAssembler& masm)
|
||||
// IteratorClose_Fallback
|
||||
//
|
||||
|
||||
static bool
|
||||
static void
|
||||
DoIteratorCloseFallback(JSContext* cx, ICIteratorClose_Fallback* stub, HandleValue iterValue)
|
||||
{
|
||||
FallbackICSpew(cx, stub, "IteratorClose");
|
||||
|
||||
RootedObject iteratorObject(cx, &iterValue.toObject());
|
||||
return CloseIterator(cx, iteratorObject);
|
||||
CloseIterator(&iterValue.toObject());
|
||||
}
|
||||
|
||||
typedef bool (*DoIteratorCloseFallbackFn)(JSContext*, ICIteratorClose_Fallback*, HandleValue);
|
||||
typedef void (*DoIteratorCloseFallbackFn)(JSContext*, ICIteratorClose_Fallback*, HandleValue);
|
||||
static const VMFunction DoIteratorCloseFallbackInfo =
|
||||
FunctionInfo<DoIteratorCloseFallbackFn>(DoIteratorCloseFallback, "DoIteratorCloseFallback",
|
||||
TailCall);
|
||||
|
@ -1298,13 +1298,13 @@ class ICCall_ConstStringSplit : public ICMonitoredStub
|
||||
};
|
||||
};
|
||||
|
||||
class ICCall_IsSuspendedStarGenerator : public ICStub
|
||||
class ICCall_IsSuspendedGenerator : public ICStub
|
||||
{
|
||||
friend class ICStubSpace;
|
||||
|
||||
protected:
|
||||
explicit ICCall_IsSuspendedStarGenerator(JitCode* stubCode)
|
||||
: ICStub(ICStub::Call_IsSuspendedStarGenerator, stubCode)
|
||||
explicit ICCall_IsSuspendedGenerator(JitCode* stubCode)
|
||||
: ICStub(ICStub::Call_IsSuspendedGenerator, stubCode)
|
||||
{}
|
||||
|
||||
public:
|
||||
@ -1314,10 +1314,10 @@ class ICCall_IsSuspendedStarGenerator : public ICStub
|
||||
|
||||
public:
|
||||
explicit Compiler(JSContext* cx)
|
||||
: ICStubCompiler(cx, ICStub::Call_IsSuspendedStarGenerator, Engine::Baseline)
|
||||
: ICStubCompiler(cx, ICStub::Call_IsSuspendedGenerator, Engine::Baseline)
|
||||
{}
|
||||
ICStub* getStub(ICStubSpace* space) {
|
||||
return newStub<ICCall_IsSuspendedStarGenerator>(space, getStubCode());
|
||||
return newStub<ICCall_IsSuspendedGenerator>(space, getStubCode());
|
||||
}
|
||||
};
|
||||
};
|
||||
|
@ -48,7 +48,7 @@ namespace jit {
|
||||
_(Call_ScriptedApplyArguments) \
|
||||
_(Call_ScriptedFunCall) \
|
||||
_(Call_ConstStringSplit) \
|
||||
_(Call_IsSuspendedStarGenerator) \
|
||||
_(Call_IsSuspendedGenerator) \
|
||||
\
|
||||
_(GetElem_Fallback) \
|
||||
_(SetElem_Fallback) \
|
||||
|
@ -9291,9 +9291,9 @@ CodeGenerator::visitIsNoIterAndBranch(LIsNoIterAndBranch* lir)
|
||||
masm.jump(ifFalse);
|
||||
}
|
||||
|
||||
typedef bool (*CloseIteratorFn)(JSContext*, HandleObject);
|
||||
static const VMFunction CloseIteratorInfo =
|
||||
FunctionInfo<CloseIteratorFn>(CloseIterator, "CloseIterator");
|
||||
typedef void (*CloseIteratorFromIonFn)(JSContext*, JSObject*);
|
||||
static const VMFunction CloseIteratorFromIonInfo =
|
||||
FunctionInfo<CloseIteratorFromIonFn>(CloseIteratorFromIon, "CloseIteratorFromIon");
|
||||
|
||||
void
|
||||
CodeGenerator::visitIteratorEnd(LIteratorEnd* lir)
|
||||
@ -9303,7 +9303,7 @@ CodeGenerator::visitIteratorEnd(LIteratorEnd* lir)
|
||||
const Register temp2 = ToRegister(lir->temp2());
|
||||
const Register temp3 = ToRegister(lir->temp3());
|
||||
|
||||
OutOfLineCode* ool = oolCallVM(CloseIteratorInfo, lir, ArgList(obj), StoreNothing());
|
||||
OutOfLineCode* ool = oolCallVM(CloseIteratorFromIonInfo, lir, ArgList(obj), StoreNothing());
|
||||
|
||||
LoadNativeIterator(masm, obj, temp1, ool->entry());
|
||||
|
||||
|
@ -2275,7 +2275,7 @@ IonCompile(JSContext* cx, JSScript* script,
|
||||
static bool
|
||||
CheckFrame(JSContext* cx, BaselineFrame* frame)
|
||||
{
|
||||
MOZ_ASSERT(!frame->script()->isStarGenerator());
|
||||
MOZ_ASSERT(!frame->script()->isGenerator());
|
||||
MOZ_ASSERT(!frame->script()->isAsync());
|
||||
MOZ_ASSERT(!frame->isDebuggerEvalFrame());
|
||||
MOZ_ASSERT(!frame->isEvalFrame());
|
||||
@ -2307,7 +2307,7 @@ CheckScript(JSContext* cx, JSScript* script, bool osr)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (script->isStarGenerator()) {
|
||||
if (script->isGenerator()) {
|
||||
TrackAndSpewIonAbort(cx, script, "generator script");
|
||||
return false;
|
||||
}
|
||||
|
@ -4416,7 +4416,7 @@ jit::AnalyzeArgumentsUsage(JSContext* cx, JSScript* scriptArg)
|
||||
//
|
||||
// FIXME: Don't build arguments for ES6 generator expressions.
|
||||
if (scriptArg->isDebuggee() ||
|
||||
script->isStarGenerator() ||
|
||||
script->isGenerator() ||
|
||||
script->isAsync() ||
|
||||
script->bindingsAccessedDynamically())
|
||||
{
|
||||
|
@ -12629,11 +12629,8 @@ IonBuilder::jsop_iternext()
|
||||
MDefinition* def = current->pop();
|
||||
MOZ_ASSERT(def->type() == MIRType::Value);
|
||||
|
||||
// The value should be a string in most cases. Legacy generators can return
|
||||
// non-string values, so in that case bailout and give up Ion compilation
|
||||
// of the script.
|
||||
MInstruction* unbox = MUnbox::New(alloc(), def, MIRType::String, MUnbox::Fallible,
|
||||
Bailout_IterNextNonString);
|
||||
// The value must be a string.
|
||||
MInstruction* unbox = MUnbox::New(alloc(), def, MIRType::String, MUnbox::Infallible);
|
||||
current->add(unbox);
|
||||
current->push(unbox);
|
||||
|
||||
|
@ -132,10 +132,6 @@ enum BailoutKind
|
||||
// Like Bailout_Overflow, but causes immediate invalidation.
|
||||
Bailout_OverflowInvalidate,
|
||||
|
||||
// Like NonStringInput, but should cause immediate invalidation.
|
||||
// Used for jsop_iternext.
|
||||
Bailout_IterNextNonString,
|
||||
|
||||
// Used for integer division, multiplication and modulo.
|
||||
// If there's a remainder, bails to return a double.
|
||||
// Can also signal overflow or result of -0.
|
||||
@ -229,8 +225,6 @@ BailoutKindString(BailoutKind kind)
|
||||
// Bailouts caused by invalid assumptions.
|
||||
case Bailout_OverflowInvalidate:
|
||||
return "Bailout_OverflowInvalidate";
|
||||
case Bailout_IterNextNonString:
|
||||
return "Bailout_IterNextNonString";
|
||||
case Bailout_DoubleOutput:
|
||||
return "Bailout_DoubleOutput";
|
||||
|
||||
|
@ -139,7 +139,7 @@ CloseLiveIteratorIon(JSContext* cx, const InlineFrameIterator& frame, JSTryNote*
|
||||
|
||||
if (cx->isExceptionPending()) {
|
||||
if (tn->kind == JSTRY_FOR_IN)
|
||||
UnwindIteratorForException(cx, iterObject);
|
||||
CloseIterator(iterObject);
|
||||
else
|
||||
IteratorCloseForException(cx, iterObject);
|
||||
} else {
|
||||
@ -429,14 +429,8 @@ ProcessTryNotesBaseline(JSContext* cx, const JSJitFrameIter& frame, EnvironmentI
|
||||
uint8_t* stackPointer;
|
||||
BaselineFrameAndStackPointersFromTryNote(tn, frame, &framePointer, &stackPointer);
|
||||
Value iterValue(*reinterpret_cast<Value*>(stackPointer));
|
||||
RootedObject iterObject(cx, &iterValue.toObject());
|
||||
if (!UnwindIteratorForException(cx, iterObject)) {
|
||||
// See comment in the JSTRY_FOR_IN case in Interpreter.cpp's
|
||||
// ProcessTryNotes.
|
||||
SettleOnTryNote(cx, tn, frame, ei, rfe, pc);
|
||||
MOZ_ASSERT(**pc == JSOP_ENDITER);
|
||||
return false;
|
||||
}
|
||||
JSObject* iterObject = &iterValue.toObject();
|
||||
CloseIterator(iterObject);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -937,8 +937,8 @@ DebugAfterYield(JSContext* cx, BaselineFrame* frame)
|
||||
}
|
||||
|
||||
bool
|
||||
GeneratorThrowOrClose(JSContext* cx, BaselineFrame* frame, Handle<GeneratorObject*> genObj,
|
||||
HandleValue arg, uint32_t resumeKind)
|
||||
GeneratorThrowOrReturn(JSContext* cx, BaselineFrame* frame, Handle<GeneratorObject*> genObj,
|
||||
HandleValue arg, uint32_t resumeKind)
|
||||
{
|
||||
// Set the frame's pc to the current resume pc, so that frame iterators
|
||||
// work. This function always returns false, so we're guaranteed to enter
|
||||
@ -948,7 +948,7 @@ GeneratorThrowOrClose(JSContext* cx, BaselineFrame* frame, Handle<GeneratorObjec
|
||||
frame->setOverridePc(script->offsetToPC(offset));
|
||||
|
||||
MOZ_ALWAYS_TRUE(DebugAfterYield(cx, frame));
|
||||
MOZ_ALWAYS_FALSE(js::GeneratorThrowOrClose(cx, frame, genObj, arg, resumeKind));
|
||||
MOZ_ALWAYS_FALSE(js::GeneratorThrowOrReturn(cx, frame, genObj, arg, resumeKind));
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1835,6 +1835,12 @@ GetPrototypeOf(JSContext* cx, HandleObject target, MutableHandleValue rval)
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
CloseIteratorFromIon(JSContext* cx, JSObject* obj)
|
||||
{
|
||||
CloseIterator(obj);
|
||||
}
|
||||
|
||||
typedef bool (*SetObjectElementFn)(JSContext*, HandleObject, HandleValue,
|
||||
HandleValue, HandleValue, bool);
|
||||
const VMFunction SetObjectElementInfo =
|
||||
|
@ -731,8 +731,8 @@ InterpretResume(JSContext* cx, HandleObject obj, HandleValue val, HandleProperty
|
||||
MOZ_MUST_USE bool
|
||||
DebugAfterYield(JSContext* cx, BaselineFrame* frame);
|
||||
MOZ_MUST_USE bool
|
||||
GeneratorThrowOrClose(JSContext* cx, BaselineFrame* frame, Handle<GeneratorObject*> genObj,
|
||||
HandleValue arg, uint32_t resumeKind);
|
||||
GeneratorThrowOrReturn(JSContext* cx, BaselineFrame* frame, Handle<GeneratorObject*> genObj,
|
||||
HandleValue arg, uint32_t resumeKind);
|
||||
|
||||
MOZ_MUST_USE bool
|
||||
GlobalNameConflictsCheckFromIon(JSContext* cx, HandleScript script);
|
||||
@ -894,6 +894,9 @@ TypeOfObject(JSObject* obj, JSRuntime* rt);
|
||||
bool
|
||||
GetPrototypeOf(JSContext* cx, HandleObject target, MutableHandleValue rval);
|
||||
|
||||
void
|
||||
CloseIteratorFromIon(JSContext* cx, JSObject* obj);
|
||||
|
||||
extern const VMFunction SetObjectElementInfo;
|
||||
|
||||
} // namespace jit
|
||||
|
@ -1191,9 +1191,6 @@ class AutoAssertNoException
|
||||
}
|
||||
};
|
||||
|
||||
/* Exposed intrinsics for the JITs. */
|
||||
bool intrinsic_IsSuspendedStarGenerator(JSContext* cx, unsigned argc, Value* vp);
|
||||
|
||||
class MOZ_RAII AutoLockForExclusiveAccess
|
||||
{
|
||||
JSRuntime* runtime;
|
||||
|
@ -131,7 +131,7 @@ IsSloppyNormalFunction(JSFunction* fun)
|
||||
if (fun->isBuiltin() || fun->isBoundFunction())
|
||||
return false;
|
||||
|
||||
if (fun->isStarGenerator() || fun->isAsync())
|
||||
if (fun->isGenerator() || fun->isAsync())
|
||||
return false;
|
||||
|
||||
MOZ_ASSERT(fun->isInterpreted());
|
||||
@ -420,13 +420,13 @@ ResolveInterpretedFunctionPrototype(JSContext* cx, HandleFunction fun, HandleId
|
||||
// the function object itself, unless the function is an ES6 generator. In
|
||||
// that case, per the 15 July 2013 ES6 draft, section 15.19.3, its parent is
|
||||
// the GeneratorObjectPrototype singleton.
|
||||
bool isStarGenerator = fun->isStarGenerator();
|
||||
bool isGenerator = fun->isGenerator();
|
||||
Rooted<GlobalObject*> global(cx, &fun->global());
|
||||
RootedObject objProto(cx);
|
||||
if (isAsyncGenerator)
|
||||
objProto = GlobalObject::getOrCreateAsyncGeneratorPrototype(cx, global);
|
||||
else if (isStarGenerator)
|
||||
objProto = GlobalObject::getOrCreateStarGeneratorObjectPrototype(cx, global);
|
||||
else if (isGenerator)
|
||||
objProto = GlobalObject::getOrCreateGeneratorObjectPrototype(cx, global);
|
||||
else
|
||||
objProto = GlobalObject::getOrCreateObjectPrototype(cx, global);
|
||||
if (!objProto)
|
||||
@ -441,7 +441,7 @@ ResolveInterpretedFunctionPrototype(JSContext* cx, HandleFunction fun, HandleId
|
||||
// non-enumerable, and writable. However, per the 15 July 2013 ES6 draft,
|
||||
// section 15.19.3, the .prototype of a generator function does not link
|
||||
// back with a .constructor.
|
||||
if (!isStarGenerator && !isAsyncGenerator) {
|
||||
if (!isGenerator && !isAsyncGenerator) {
|
||||
RootedValue objVal(cx, ObjectValue(*fun));
|
||||
if (!DefineDataProperty(cx, proto, cx->names().constructor, objVal, 0))
|
||||
return false;
|
||||
@ -477,7 +477,7 @@ JSFunction::needsPrototypeProperty()
|
||||
if (isBuiltin())
|
||||
return IsWrappedAsyncGenerator(this);
|
||||
|
||||
return isConstructor() || isStarGenerator() || isAsync();
|
||||
return isConstructor() || isGenerator() || isAsync();
|
||||
}
|
||||
|
||||
static bool
|
||||
@ -572,7 +572,7 @@ js::XDRInterpretedFunction(XDRState<mode>* xdr, HandleScope enclosingScope,
|
||||
{
|
||||
enum FirstWordFlag {
|
||||
HasAtom = 0x1,
|
||||
HasStarGeneratorProto = 0x2,
|
||||
HasGeneratorProto = 0x2,
|
||||
IsLazy = 0x4,
|
||||
HasSingletonType = 0x8
|
||||
};
|
||||
@ -595,8 +595,8 @@ js::XDRInterpretedFunction(XDRState<mode>* xdr, HandleScope enclosingScope,
|
||||
if (fun->explicitName() || fun->hasCompileTimeName() || fun->hasGuessedAtom())
|
||||
firstword |= HasAtom;
|
||||
|
||||
if (fun->isStarGenerator() || fun->isAsync())
|
||||
firstword |= HasStarGeneratorProto;
|
||||
if (fun->isGenerator() || fun->isAsync())
|
||||
firstword |= HasGeneratorProto;
|
||||
|
||||
if (fun->isInterpretedLazy()) {
|
||||
// Encode a lazy script.
|
||||
@ -636,12 +636,12 @@ js::XDRInterpretedFunction(XDRState<mode>* xdr, HandleScope enclosingScope,
|
||||
|
||||
if (mode == XDR_DECODE) {
|
||||
RootedObject proto(cx);
|
||||
if (firstword & HasStarGeneratorProto) {
|
||||
if (firstword & HasGeneratorProto) {
|
||||
// If we are off thread, the generator meta-objects have
|
||||
// already been created by js::StartOffThreadParseTask, so
|
||||
// JSContext* will not be necessary.
|
||||
JSContext* context = cx->helperThread() ? nullptr : cx;
|
||||
proto = GlobalObject::getOrCreateStarGeneratorFunctionPrototype(context, cx->global());
|
||||
proto = GlobalObject::getOrCreateGeneratorFunctionPrototype(context, cx->global());
|
||||
if (!proto)
|
||||
return false;
|
||||
}
|
||||
@ -1084,7 +1084,7 @@ js::FunctionToString(JSContext* cx, HandleFunction fun, bool isToSource)
|
||||
if (!out.append("function"))
|
||||
return nullptr;
|
||||
|
||||
if (fun->isStarGenerator()) {
|
||||
if (fun->isGenerator()) {
|
||||
if (!out.append('*'))
|
||||
return nullptr;
|
||||
}
|
||||
@ -1750,7 +1750,7 @@ fun_isGenerator(JSContext* cx, unsigned argc, Value* vp)
|
||||
return true;
|
||||
}
|
||||
|
||||
args.rval().setBoolean(fun->isStarGenerator());
|
||||
args.rval().setBoolean(fun->isGenerator());
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1781,7 +1781,7 @@ CreateDynamicFunction(JSContext* cx, const CallArgs& args, GeneratorKind generat
|
||||
return false;
|
||||
}
|
||||
|
||||
bool isStarGenerator = generatorKind == StarGenerator;
|
||||
bool isGenerator = generatorKind == GeneratorKind::Generator;
|
||||
bool isAsync = asyncKind == AsyncFunction;
|
||||
|
||||
RootedScript maybeScript(cx);
|
||||
@ -1794,11 +1794,11 @@ CreateDynamicFunction(JSContext* cx, const CallArgs& args, GeneratorKind generat
|
||||
|
||||
const char* introductionType = "Function";
|
||||
if (isAsync) {
|
||||
if (isStarGenerator)
|
||||
if (isGenerator)
|
||||
introductionType = "AsyncGenerator";
|
||||
else
|
||||
introductionType = "AsyncFunction";
|
||||
} else if (generatorKind != NotGenerator) {
|
||||
} else if (isGenerator) {
|
||||
introductionType = "GeneratorFunction";
|
||||
}
|
||||
|
||||
@ -1820,7 +1820,7 @@ CreateDynamicFunction(JSContext* cx, const CallArgs& args, GeneratorKind generat
|
||||
}
|
||||
if (!sb.append("function"))
|
||||
return false;
|
||||
if (isStarGenerator) {
|
||||
if (isGenerator) {
|
||||
if (!sb.append('*'))
|
||||
return false;
|
||||
}
|
||||
@ -1893,15 +1893,15 @@ CreateDynamicFunction(JSContext* cx, const CallArgs& args, GeneratorKind generat
|
||||
// Use %Generator% for generators and the unwrapped function of async
|
||||
// functions and async generators.
|
||||
RootedObject defaultProto(cx);
|
||||
if (isStarGenerator || isAsync) {
|
||||
defaultProto = GlobalObject::getOrCreateStarGeneratorFunctionPrototype(cx, global);
|
||||
if (isGenerator || isAsync) {
|
||||
defaultProto = GlobalObject::getOrCreateGeneratorFunctionPrototype(cx, global);
|
||||
if (!defaultProto)
|
||||
return false;
|
||||
}
|
||||
|
||||
// Step 30-37 (reordered).
|
||||
RootedObject globalLexical(cx, &global->lexicalEnvironment());
|
||||
JSFunction::Flags flags = (isStarGenerator || isAsync)
|
||||
JSFunction::Flags flags = (isGenerator || isAsync)
|
||||
? JSFunction::INTERPRETED_LAMBDA_GENERATOR_OR_ASYNC
|
||||
: JSFunction::INTERPRETED_LAMBDA;
|
||||
AllocKind allocKind = isAsync ? AllocKind::FUNCTION_EXTENDED : AllocKind::FUNCTION;
|
||||
@ -1926,7 +1926,7 @@ CreateDynamicFunction(JSContext* cx, const CallArgs& args, GeneratorKind generat
|
||||
: SourceBufferHolder::NoOwnership;
|
||||
SourceBufferHolder srcBuf(chars.begin().get(), chars.length(), ownership);
|
||||
if (isAsync) {
|
||||
if (isStarGenerator) {
|
||||
if (isGenerator) {
|
||||
if (!CompileStandaloneAsyncGenerator(cx, &fun, options, srcBuf, parameterListEnd))
|
||||
return false;
|
||||
} else {
|
||||
@ -1934,7 +1934,7 @@ CreateDynamicFunction(JSContext* cx, const CallArgs& args, GeneratorKind generat
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (isStarGenerator) {
|
||||
if (isGenerator) {
|
||||
if (!CompileStandaloneGenerator(cx, &fun, options, srcBuf, parameterListEnd))
|
||||
return false;
|
||||
} else {
|
||||
@ -1951,7 +1951,7 @@ CreateDynamicFunction(JSContext* cx, const CallArgs& args, GeneratorKind generat
|
||||
if (isAsync) {
|
||||
// Create the async function wrapper.
|
||||
JSObject* wrapped;
|
||||
if (isStarGenerator) {
|
||||
if (isGenerator) {
|
||||
wrapped = proto
|
||||
? WrapAsyncGeneratorWithProto(cx, fun, proto)
|
||||
: WrapAsyncGenerator(cx, fun);
|
||||
@ -1981,28 +1981,28 @@ bool
|
||||
js::Function(JSContext* cx, unsigned argc, Value* vp)
|
||||
{
|
||||
CallArgs args = CallArgsFromVp(argc, vp);
|
||||
return CreateDynamicFunction(cx, args, NotGenerator, SyncFunction);
|
||||
return CreateDynamicFunction(cx, args, GeneratorKind::NotGenerator, SyncFunction);
|
||||
}
|
||||
|
||||
bool
|
||||
js::Generator(JSContext* cx, unsigned argc, Value* vp)
|
||||
{
|
||||
CallArgs args = CallArgsFromVp(argc, vp);
|
||||
return CreateDynamicFunction(cx, args, StarGenerator, SyncFunction);
|
||||
return CreateDynamicFunction(cx, args, GeneratorKind::Generator, SyncFunction);
|
||||
}
|
||||
|
||||
bool
|
||||
js::AsyncFunctionConstructor(JSContext* cx, unsigned argc, Value* vp)
|
||||
{
|
||||
CallArgs args = CallArgsFromVp(argc, vp);
|
||||
return CreateDynamicFunction(cx, args, NotGenerator, AsyncFunction);
|
||||
return CreateDynamicFunction(cx, args, GeneratorKind::NotGenerator, AsyncFunction);
|
||||
}
|
||||
|
||||
bool
|
||||
js::AsyncGeneratorConstructor(JSContext* cx, unsigned argc, Value* vp)
|
||||
{
|
||||
CallArgs args = CallArgsFromVp(argc, vp);
|
||||
return CreateDynamicFunction(cx, args, StarGenerator, AsyncFunction);
|
||||
return CreateDynamicFunction(cx, args, GeneratorKind::Generator, AsyncFunction);
|
||||
}
|
||||
|
||||
bool
|
||||
@ -2145,8 +2145,8 @@ NewFunctionClone(JSContext* cx, HandleFunction fun, NewObjectKind newKind,
|
||||
gc::AllocKind allocKind, HandleObject proto)
|
||||
{
|
||||
RootedObject cloneProto(cx, proto);
|
||||
if (!proto && (fun->isStarGenerator() || fun->isAsync())) {
|
||||
cloneProto = GlobalObject::getOrCreateStarGeneratorFunctionPrototype(cx, cx->global());
|
||||
if (!proto && (fun->isGenerator() || fun->isAsync())) {
|
||||
cloneProto = GlobalObject::getOrCreateGeneratorFunctionPrototype(cx, cx->global());
|
||||
if (!cloneProto)
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -149,7 +149,7 @@ class JSFunction : public js::NativeObject
|
||||
MOZ_ASSERT_IF(nonLazyScript()->funHasExtensibleScope() ||
|
||||
nonLazyScript()->needsHomeObject() ||
|
||||
nonLazyScript()->isDerivedClassConstructor() ||
|
||||
isStarGenerator() ||
|
||||
isGenerator() ||
|
||||
isAsync(),
|
||||
nonLazyScript()->bodyScope()->hasEnvironment());
|
||||
|
||||
@ -510,16 +510,16 @@ class JSFunction : public js::NativeObject
|
||||
|
||||
js::GeneratorKind generatorKind() const {
|
||||
if (!isInterpreted())
|
||||
return js::NotGenerator;
|
||||
return js::GeneratorKind::NotGenerator;
|
||||
if (hasScript())
|
||||
return nonLazyScript()->generatorKind();
|
||||
if (js::LazyScript* lazy = lazyScriptOrNull())
|
||||
return lazy->generatorKind();
|
||||
MOZ_ASSERT(isSelfHostedBuiltin());
|
||||
return js::NotGenerator;
|
||||
return js::GeneratorKind::NotGenerator;
|
||||
}
|
||||
|
||||
bool isStarGenerator() const { return generatorKind() == js::StarGenerator; }
|
||||
bool isGenerator() const { return generatorKind() == js::GeneratorKind::Generator; }
|
||||
|
||||
js::FunctionAsyncKind asyncKind() const {
|
||||
return isInterpretedLazy() ? lazyScript()->asyncKind() : nonLazyScript()->asyncKind();
|
||||
|
@ -359,7 +359,7 @@ const AllocKind gc::slotsToThingKind[] = {
|
||||
static_assert(JS_ARRAY_LENGTH(slotsToThingKind) == SLOTS_TO_THING_KIND_LIMIT,
|
||||
"We have defined a slot count for each kind.");
|
||||
|
||||
#define CHECK_THING_SIZE(allocKind, traceKind, type, sizedType) \
|
||||
#define CHECK_THING_SIZE(allocKind, traceKind, type, sizedType, bgFinal, nursery) \
|
||||
static_assert(sizeof(sizedType) >= SortedArenaList::MinThingSize, \
|
||||
#sizedType " is smaller than SortedArenaList::MinThingSize!"); \
|
||||
static_assert(sizeof(sizedType) >= sizeof(FreeSpan), \
|
||||
@ -372,7 +372,7 @@ FOR_EACH_ALLOCKIND(CHECK_THING_SIZE);
|
||||
#undef CHECK_THING_SIZE
|
||||
|
||||
const uint32_t Arena::ThingSizes[] = {
|
||||
#define EXPAND_THING_SIZE(allocKind, traceKind, type, sizedType) \
|
||||
#define EXPAND_THING_SIZE(allocKind, traceKind, type, sizedType, bgFinal, nursery) \
|
||||
sizeof(sizedType),
|
||||
FOR_EACH_ALLOCKIND(EXPAND_THING_SIZE)
|
||||
#undef EXPAND_THING_SIZE
|
||||
@ -386,7 +386,7 @@ FreeSpan ArenaLists::placeholder;
|
||||
#define OFFSET(type) uint32_t(ArenaHeaderSize + (ArenaSize - ArenaHeaderSize) % sizeof(type))
|
||||
|
||||
const uint32_t Arena::FirstThingOffsets[] = {
|
||||
#define EXPAND_FIRST_THING_OFFSET(allocKind, traceKind, type, sizedType) \
|
||||
#define EXPAND_FIRST_THING_OFFSET(allocKind, traceKind, type, sizedType, bgFinal, nursery) \
|
||||
OFFSET(sizedType),
|
||||
FOR_EACH_ALLOCKIND(EXPAND_FIRST_THING_OFFSET)
|
||||
#undef EXPAND_FIRST_THING_OFFSET
|
||||
@ -397,7 +397,7 @@ FOR_EACH_ALLOCKIND(EXPAND_FIRST_THING_OFFSET)
|
||||
#define COUNT(type) uint32_t((ArenaSize - ArenaHeaderSize) / sizeof(type))
|
||||
|
||||
const uint32_t Arena::ThingsPerArena[] = {
|
||||
#define EXPAND_THINGS_PER_ARENA(allocKind, traceKind, type, sizedType) \
|
||||
#define EXPAND_THINGS_PER_ARENA(allocKind, traceKind, type, sizedType, bgFinal, nursery) \
|
||||
COUNT(sizedType),
|
||||
FOR_EACH_ALLOCKIND(EXPAND_THINGS_PER_ARENA)
|
||||
#undef EXPAND_THINGS_PER_ARENA
|
||||
@ -641,7 +641,7 @@ FinalizeArenas(FreeOp* fop,
|
||||
ArenaLists::KeepArenasEnum keepArenas)
|
||||
{
|
||||
switch (thingKind) {
|
||||
#define EXPAND_CASE(allocKind, traceKind, type, sizedType) \
|
||||
#define EXPAND_CASE(allocKind, traceKind, type, sizedType, bgFinal, nursery) \
|
||||
case AllocKind::allocKind: \
|
||||
return FinalizeTypedArenas<type>(fop, src, dest, thingKind, budget, keepArenas);
|
||||
FOR_EACH_ALLOCKIND(EXPAND_CASE)
|
||||
@ -1127,7 +1127,7 @@ static const char*
|
||||
AllocKindName(AllocKind kind)
|
||||
{
|
||||
static const char* names[] = {
|
||||
#define EXPAND_THING_NAME(allocKind, _1, _2, _3) \
|
||||
#define EXPAND_THING_NAME(allocKind, _1, _2, _3, _4, _5) \
|
||||
#allocKind,
|
||||
FOR_EACH_ALLOCKIND(EXPAND_THING_NAME)
|
||||
#undef EXPAND_THING_NAME
|
||||
@ -2483,7 +2483,7 @@ UpdateArenaPointers(MovingTracer* trc, Arena* arena)
|
||||
AllocKind kind = arena->getAllocKind();
|
||||
|
||||
switch (kind) {
|
||||
#define EXPAND_CASE(allocKind, traceKind, type, sizedType) \
|
||||
#define EXPAND_CASE(allocKind, traceKind, type, sizedType, bgFinal, nursery) \
|
||||
case AllocKind::allocKind: \
|
||||
UpdateArenaPointersTyped<type>(trc, arena, JS::TraceKind::traceKind); \
|
||||
return;
|
||||
@ -3833,7 +3833,7 @@ static const char*
|
||||
AllocKindToAscii(AllocKind kind)
|
||||
{
|
||||
switch(kind) {
|
||||
#define MAKE_CASE(allocKind, traceKind, type, sizedType) \
|
||||
#define MAKE_CASE(allocKind, traceKind, type, sizedType, bgFinal, nursery) \
|
||||
case AllocKind:: allocKind: return #allocKind;
|
||||
FOR_EACH_ALLOCKIND(MAKE_CASE)
|
||||
#undef MAKE_CASE
|
||||
|
@ -55,7 +55,7 @@ struct Cell;
|
||||
* The AllocKind is available as MapTypeToFinalizeKind<SomeType>::kind.
|
||||
*/
|
||||
template <typename T> struct MapTypeToFinalizeKind {};
|
||||
#define EXPAND_MAPTYPETOFINALIZEKIND(allocKind, traceKind, type, sizedType) \
|
||||
#define EXPAND_MAPTYPETOFINALIZEKIND(allocKind, traceKind, type, sizedType, bgFinal, nursery) \
|
||||
template <> struct MapTypeToFinalizeKind<type> { \
|
||||
static const AllocKind kind = AllocKind::allocKind; \
|
||||
};
|
||||
|
@ -1263,8 +1263,8 @@ js::ValueToIterator(JSContext* cx, unsigned flags, HandleValue vp)
|
||||
return GetIterator(cx, obj, flags);
|
||||
}
|
||||
|
||||
bool
|
||||
js::CloseIterator(JSContext* cx, HandleObject obj)
|
||||
void
|
||||
js::CloseIterator(JSObject* obj)
|
||||
{
|
||||
if (obj->is<PropertyIteratorObject>()) {
|
||||
/* Remove enumerators from the active list, which is a stack. */
|
||||
@ -1283,22 +1283,6 @@ js::CloseIterator(JSContext* cx, HandleObject obj)
|
||||
ni->props_cursor = ni->props_array;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
js::UnwindIteratorForException(JSContext* cx, HandleObject obj)
|
||||
{
|
||||
RootedValue v(cx);
|
||||
bool getOk = cx->getPendingException(&v);
|
||||
cx->clearPendingException();
|
||||
if (!CloseIterator(cx, obj))
|
||||
return false;
|
||||
if (!getOk)
|
||||
return false;
|
||||
cx->setPendingException(v);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -182,11 +182,8 @@ NewEmptyPropertyIterator(JSContext* cx, unsigned flags);
|
||||
JSObject*
|
||||
ValueToIterator(JSContext* cx, unsigned flags, HandleValue vp);
|
||||
|
||||
bool
|
||||
CloseIterator(JSContext* cx, HandleObject iterObj);
|
||||
|
||||
bool
|
||||
UnwindIteratorForException(JSContext* cx, HandleObject obj);
|
||||
void
|
||||
CloseIterator(JSObject* obj);
|
||||
|
||||
bool
|
||||
IteratorCloseForException(JSContext* cx, HandleObject obj);
|
||||
|
@ -341,7 +341,7 @@ js::XDRScript(XDRState<mode>* xdr, HandleScope scriptEnclosingScope,
|
||||
FunctionHasThisBinding,
|
||||
FunctionHasExtraBodyVarScope,
|
||||
IsGeneratorExp,
|
||||
IsStarGenerator,
|
||||
IsGenerator,
|
||||
IsAsync,
|
||||
HasRest,
|
||||
IsExprBody,
|
||||
@ -456,8 +456,8 @@ js::XDRScript(XDRState<mode>* xdr, HandleScope scriptEnclosingScope,
|
||||
scriptBits |= (1 << OwnSource);
|
||||
if (script->isGeneratorExp())
|
||||
scriptBits |= (1 << IsGeneratorExp);
|
||||
if (script->isStarGenerator())
|
||||
scriptBits |= (1 << IsStarGenerator);
|
||||
if (script->isGenerator())
|
||||
scriptBits |= (1 << IsGenerator);
|
||||
if (script->asyncKind() == AsyncFunction)
|
||||
scriptBits |= (1 << IsAsync);
|
||||
if (script->hasRest())
|
||||
@ -629,8 +629,8 @@ js::XDRScript(XDRState<mode>* xdr, HandleScope scriptEnclosingScope,
|
||||
script->isDerivedClassConstructor_ = true;
|
||||
if (scriptBits & (1 << IsDefaultClassConstructor))
|
||||
script->isDefaultClassConstructor_ = true;
|
||||
if (scriptBits & (1 << IsStarGenerator))
|
||||
script->setGeneratorKind(StarGenerator);
|
||||
if (scriptBits & (1 << IsGenerator))
|
||||
script->setGeneratorKind(GeneratorKind::Generator);
|
||||
if (scriptBits & (1 << IsAsync))
|
||||
script->setAsyncKind(AsyncFunction);
|
||||
if (scriptBits & (1 << HasRest))
|
||||
@ -2980,7 +2980,7 @@ JSScript::initFromModuleContext(JSContext* cx, HandleScript script,
|
||||
script->funLength_ = 0;
|
||||
|
||||
script->isGeneratorExp_ = false;
|
||||
script->setGeneratorKind(NotGenerator);
|
||||
script->setGeneratorKind(GeneratorKind::NotGenerator);
|
||||
|
||||
// Since modules are only run once, mark the script so that initializers
|
||||
// created within it may be given more precise types.
|
||||
@ -3456,8 +3456,8 @@ CloneInnerInterpretedFunction(JSContext* cx, HandleScope enclosingScope, HandleF
|
||||
{
|
||||
/* NB: Keep this in sync with XDRInterpretedFunction. */
|
||||
RootedObject cloneProto(cx);
|
||||
if (srcFun->isStarGenerator() || srcFun->isAsync()) {
|
||||
cloneProto = GlobalObject::getOrCreateStarGeneratorFunctionPrototype(cx, cx->global());
|
||||
if (srcFun->isGenerator() || srcFun->isAsync()) {
|
||||
cloneProto = GlobalObject::getOrCreateGeneratorFunctionPrototype(cx, cx->global());
|
||||
if (!cloneProto)
|
||||
return nullptr;
|
||||
}
|
||||
@ -4196,7 +4196,7 @@ JSScript::argumentsOptimizationFailed(JSContext* cx, HandleScript script)
|
||||
if (script->needsArgsObj())
|
||||
return true;
|
||||
|
||||
MOZ_ASSERT(!script->isStarGenerator());
|
||||
MOZ_ASSERT(!script->isGenerator());
|
||||
MOZ_ASSERT(!script->isAsync());
|
||||
|
||||
script->needsArgsObj_ = true;
|
||||
@ -4385,7 +4385,7 @@ LazyScript::Create(JSContext* cx, HandleFunction fun,
|
||||
p.isExprBody = false;
|
||||
p.numClosedOverBindings = closedOverBindings.length();
|
||||
p.numInnerFunctions = innerFunctions.length();
|
||||
p.generatorKindBits = GeneratorKindAsBits(NotGenerator);
|
||||
p.generatorKind = GeneratorKindAsBit(GeneratorKind::NotGenerator);
|
||||
p.strict = false;
|
||||
p.bindingsAccessedDynamically = false;
|
||||
p.hasDebuggerStatement = false;
|
||||
|
@ -752,17 +752,19 @@ class ScriptSourceObject : public NativeObject
|
||||
static const uint32_t RESERVED_SLOTS = 4;
|
||||
};
|
||||
|
||||
enum GeneratorKind { NotGenerator, StarGenerator };
|
||||
enum class GeneratorKind : bool { NotGenerator, Generator };
|
||||
enum FunctionAsyncKind { SyncFunction, AsyncFunction };
|
||||
|
||||
static inline unsigned
|
||||
GeneratorKindAsBits(GeneratorKind generatorKind) {
|
||||
GeneratorKindAsBit(GeneratorKind generatorKind)
|
||||
{
|
||||
return static_cast<unsigned>(generatorKind);
|
||||
}
|
||||
|
||||
static inline GeneratorKind
|
||||
GeneratorKindFromBits(unsigned val) {
|
||||
MOZ_ASSERT(val <= StarGenerator);
|
||||
GeneratorKindFromBit(unsigned val)
|
||||
{
|
||||
MOZ_ASSERT(val <= unsigned(GeneratorKind::Generator));
|
||||
return static_cast<GeneratorKind>(val);
|
||||
}
|
||||
|
||||
@ -1033,7 +1035,7 @@ class JSScript : public js::gc::TenuredCell
|
||||
uint8_t hasArrayBits:ARRAY_KIND_BITS;
|
||||
|
||||
// The GeneratorKind of the script.
|
||||
uint8_t generatorKindBits_:2;
|
||||
uint8_t generatorKind_:1;
|
||||
|
||||
// 1-bit fields.
|
||||
|
||||
@ -1443,14 +1445,14 @@ class JSScript : public js::gc::TenuredCell
|
||||
}
|
||||
|
||||
js::GeneratorKind generatorKind() const {
|
||||
return js::GeneratorKindFromBits(generatorKindBits_);
|
||||
return js::GeneratorKindFromBit(generatorKind_);
|
||||
}
|
||||
bool isStarGenerator() const { return generatorKind() == js::StarGenerator; }
|
||||
bool isGenerator() const { return generatorKind() == js::GeneratorKind::Generator; }
|
||||
void setGeneratorKind(js::GeneratorKind kind) {
|
||||
// A script only gets its generator kind set as part of initialization,
|
||||
// so it can only transition from not being a generator.
|
||||
MOZ_ASSERT(!isStarGenerator());
|
||||
generatorKindBits_ = GeneratorKindAsBits(kind);
|
||||
MOZ_ASSERT(!isGenerator());
|
||||
generatorKind_ = GeneratorKindAsBit(kind);
|
||||
}
|
||||
|
||||
js::FunctionAsyncKind asyncKind() const {
|
||||
@ -1612,7 +1614,7 @@ class JSScript : public js::gc::TenuredCell
|
||||
|
||||
bool isRelazifiable() const {
|
||||
return (selfHosted() || lazyScript) && !hasInnerFunctions_ && !types_ &&
|
||||
!isStarGenerator() && !isAsync() &&
|
||||
!isGenerator() && !isAsync() &&
|
||||
!isDefaultClassConstructor() &&
|
||||
!hasBaselineScript() && !hasAnyIonScript() &&
|
||||
!doNotRelazify_;
|
||||
@ -1834,7 +1836,7 @@ class JSScript : public js::gc::TenuredCell
|
||||
bool hasTrynotes() const { return hasArray(TRYNOTES); }
|
||||
bool hasScopeNotes() const { return hasArray(SCOPENOTES); }
|
||||
bool hasYieldAndAwaitOffsets() const {
|
||||
return isStarGenerator() || isAsync();
|
||||
return isGenerator() || isAsync();
|
||||
}
|
||||
|
||||
#define OFF(fooOff, hasFoo, t) (fooOff() + (hasFoo() ? sizeof(t) : 0))
|
||||
@ -2129,7 +2131,7 @@ class LazyScript : public gc::TenuredCell
|
||||
|
||||
uint32_t numInnerFunctions : NumInnerFunctionsBits;
|
||||
|
||||
uint32_t generatorKindBits : 2;
|
||||
uint32_t generatorKind : 1;
|
||||
|
||||
// N.B. These are booleans but need to be uint32_t to pack correctly on MSVC.
|
||||
// If you add another boolean here, make sure to initialze it in
|
||||
@ -2253,15 +2255,15 @@ class LazyScript : public gc::TenuredCell
|
||||
return (GCPtrFunction*)&closedOverBindings()[numClosedOverBindings()];
|
||||
}
|
||||
|
||||
GeneratorKind generatorKind() const { return GeneratorKindFromBits(p_.generatorKindBits); }
|
||||
GeneratorKind generatorKind() const { return GeneratorKindFromBit(p_.generatorKind); }
|
||||
|
||||
bool isStarGenerator() const { return generatorKind() == StarGenerator; }
|
||||
bool isGenerator() const { return generatorKind() == GeneratorKind::Generator; }
|
||||
|
||||
void setGeneratorKind(GeneratorKind kind) {
|
||||
// A script only gets its generator kind set as part of initialization,
|
||||
// so it can only transition from NotGenerator.
|
||||
MOZ_ASSERT(!isStarGenerator());
|
||||
p_.generatorKindBits = GeneratorKindAsBits(kind);
|
||||
MOZ_ASSERT(!isGenerator());
|
||||
p_.generatorKind = GeneratorKindAsBit(kind);
|
||||
}
|
||||
|
||||
FunctionAsyncKind asyncKind() const {
|
||||
|
@ -10,26 +10,13 @@
|
||||
/*
|
||||
* JS Capability Macros.
|
||||
*/
|
||||
#define JS_HAS_STR_HTML_HELPERS 1 /* (no longer used) */
|
||||
#define JS_HAS_OBJ_PROTO_PROP 1 /* has o.__proto__ etc. */
|
||||
#define JS_HAS_TOSOURCE 1 /* has Object/Array toSource method */
|
||||
#define JS_HAS_CATCH_GUARD 1 /* has exception handling catch guard */
|
||||
#define JS_HAS_UNEVAL 1 /* has uneval() top-level function */
|
||||
#define JS_HAS_CONST 1 /* (no longer used) */
|
||||
#define JS_HAS_FUN_EXPR_STMT 1 /* (no longer used) */
|
||||
#define JS_HAS_FOR_EACH_IN 1 /* has for each (lhs in iterable) */
|
||||
#define JS_HAS_GENERATORS 1 /* (no longer used) */
|
||||
#define JS_HAS_BLOCK_SCOPE 1 /* (no longer used) */
|
||||
#define JS_HAS_DESTRUCTURING 2 /* (no longer used) */
|
||||
#define JS_HAS_GENERATOR_EXPRS 1 /* (no longer used) */
|
||||
#define JS_HAS_EXPR_CLOSURES 1 /* has function (formals) listexpr */
|
||||
|
||||
/* (no longer used) */
|
||||
#define JS_HAS_NEW_GLOBAL_OBJECT 1
|
||||
|
||||
/* (no longer used) */
|
||||
#define JS_HAS_DESTRUCTURING_SHORTHAND (JS_HAS_DESTRUCTURING == 2)
|
||||
|
||||
/*
|
||||
* Feature for Object.prototype.__{define,lookup}{G,S}etter__ legacy support;
|
||||
* support likely to be made opt-in at some future time.
|
||||
|
@ -266,17 +266,16 @@ CanReify(HandleObject obj)
|
||||
|
||||
struct AutoCloseIterator
|
||||
{
|
||||
AutoCloseIterator(JSContext* cx, PropertyIteratorObject* obj) : cx(cx), obj(cx, obj) {}
|
||||
AutoCloseIterator(JSContext* cx, PropertyIteratorObject* obj) : obj(cx, obj) {}
|
||||
|
||||
~AutoCloseIterator() {
|
||||
if (obj)
|
||||
MOZ_ALWAYS_TRUE(CloseIterator(cx, obj));
|
||||
CloseIterator(obj);
|
||||
}
|
||||
|
||||
void clear() { obj = nullptr; }
|
||||
|
||||
private:
|
||||
JSContext* cx;
|
||||
Rooted<PropertyIteratorObject*> obj;
|
||||
};
|
||||
|
||||
@ -314,7 +313,7 @@ Reify(JSContext* cx, JSCompartment* origin, HandleObject objp)
|
||||
}
|
||||
|
||||
close.clear();
|
||||
MOZ_ALWAYS_TRUE(CloseIterator(cx, iterObj));
|
||||
CloseIterator(iterObj);
|
||||
|
||||
obj = EnumeratedIdVectorToIterator(cx, obj, ni->flags, keys);
|
||||
}
|
||||
|
@ -184,8 +184,8 @@ AsyncFunctionResume(JSContext* cx, Handle<PromiseObject*> resultPromise, HandleV
|
||||
|
||||
// Execution context switching is handled in generator.
|
||||
HandlePropertyName funName = kind == ResumeKind::Normal
|
||||
? cx->names().StarGeneratorNext
|
||||
: cx->names().StarGeneratorThrow;
|
||||
? cx->names().GeneratorNext
|
||||
: cx->names().GeneratorThrow;
|
||||
FixedInvokeArgs<1> args(cx);
|
||||
args[0].set(valueOrReason);
|
||||
RootedValue value(cx);
|
||||
|
@ -465,10 +465,10 @@ js::AsyncGeneratorResume(JSContext* cx, Handle<AsyncGeneratorObject*> asyncGenOb
|
||||
|
||||
// 11.4.3.5 steps 12-14, 16-20.
|
||||
HandlePropertyName funName = completionKind == CompletionKind::Normal
|
||||
? cx->names().StarGeneratorNext
|
||||
? cx->names().GeneratorNext
|
||||
: completionKind == CompletionKind::Throw
|
||||
? cx->names().StarGeneratorThrow
|
||||
: cx->names().StarGeneratorReturn;
|
||||
? cx->names().GeneratorThrow
|
||||
: cx->names().GeneratorReturn;
|
||||
FixedInvokeArgs<1> args(cx);
|
||||
args[0].set(argument);
|
||||
RootedValue result(cx);
|
||||
|
@ -66,7 +66,6 @@
|
||||
macro(caseFirst, caseFirst, "caseFirst") \
|
||||
macro(catch, catch_, "catch") \
|
||||
macro(class, class_, "class") \
|
||||
macro(close, close, "close") \
|
||||
macro(Collator, Collator, "Collator") \
|
||||
macro(collections, collections, "collections") \
|
||||
macro(columnNumber, columnNumber, "columnNumber") \
|
||||
@ -155,6 +154,9 @@
|
||||
macro(gcCycleNumber, gcCycleNumber, "gcCycleNumber") \
|
||||
macro(Generator, Generator, "Generator") \
|
||||
macro(GeneratorFunction, GeneratorFunction, "GeneratorFunction") \
|
||||
macro(GeneratorNext, GeneratorNext, "GeneratorNext") \
|
||||
macro(GeneratorReturn, GeneratorReturn, "GeneratorReturn") \
|
||||
macro(GeneratorThrow, GeneratorThrow, "GeneratorThrow") \
|
||||
macro(get, get, "get") \
|
||||
macro(getInternals, getInternals, "getInternals") \
|
||||
macro(getOwnPropertyDescriptor, getOwnPropertyDescriptor, "getOwnPropertyDescriptor") \
|
||||
@ -374,9 +376,6 @@
|
||||
macro(stack, stack, "stack") \
|
||||
macro(star, star, "*") \
|
||||
macro(starDefaultStar, starDefaultStar, "*default*") \
|
||||
macro(StarGeneratorNext, StarGeneratorNext, "StarGeneratorNext") \
|
||||
macro(StarGeneratorReturn, StarGeneratorReturn, "StarGeneratorReturn") \
|
||||
macro(StarGeneratorThrow, StarGeneratorThrow, "StarGeneratorThrow") \
|
||||
macro(start, start, "start") \
|
||||
macro(startTimestamp, startTimestamp, "startTimestamp") \
|
||||
macro(state, state, "state") \
|
||||
|
@ -1592,8 +1592,8 @@ CheckResumptionValue(JSContext* cx, AbstractFramePtr frame, const Maybe<HandleVa
|
||||
// function violate the iterator protocol. The return value from
|
||||
// such a frame must have the form { done: <bool>, value: <anything> }.
|
||||
RootedFunction callee(cx, frame.callee());
|
||||
if (callee->isStarGenerator()) {
|
||||
if (!CheckStarGeneratorResumptionValue(cx, vp)) {
|
||||
if (callee->isGenerator()) {
|
||||
if (!CheckGeneratorResumptionValue(cx, vp)) {
|
||||
JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_DEBUG_BAD_YIELD);
|
||||
return false;
|
||||
}
|
||||
@ -5375,7 +5375,7 @@ static bool
|
||||
DebuggerScript_getIsGeneratorFunction(JSContext* cx, unsigned argc, Value* vp)
|
||||
{
|
||||
THIS_DEBUGSCRIPT_SCRIPT(cx, argc, vp, "(get isGeneratorFunction)", args, obj, script);
|
||||
args.rval().setBoolean(script->isStarGenerator());
|
||||
args.rval().setBoolean(script->isGenerator());
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -7648,7 +7648,7 @@ DebuggerFrame::getEnvironment(JSContext* cx, HandleDebuggerFrame frame,
|
||||
DebuggerFrame::getIsGenerator(HandleDebuggerFrame frame)
|
||||
{
|
||||
AbstractFramePtr referent = DebuggerFrame::getReferent(frame);
|
||||
return referent.hasScript() && referent.script()->isStarGenerator();
|
||||
return referent.hasScript() && referent.script()->isGenerator();
|
||||
}
|
||||
|
||||
/* static */ bool
|
||||
@ -9962,7 +9962,7 @@ DebuggerObject::isGeneratorFunction() const
|
||||
MOZ_ASSERT(isDebuggeeFunction());
|
||||
|
||||
JSFunction* fun = RemoveAsyncWrapper(&referent()->as<JSFunction>());
|
||||
return fun->isStarGenerator();
|
||||
return fun->isGenerator();
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -2598,7 +2598,7 @@ DebugEnvironments::addDebugEnvironment(JSContext* cx, const EnvironmentIter& ei,
|
||||
MOZ_ASSERT(cx->compartment() == debugEnv->compartment());
|
||||
// Generators should always have environments.
|
||||
MOZ_ASSERT_IF(ei.scope().is<FunctionScope>(),
|
||||
!ei.scope().as<FunctionScope>().canonicalFunction()->isStarGenerator() &&
|
||||
!ei.scope().as<FunctionScope>().canonicalFunction()->isGenerator() &&
|
||||
!ei.scope().as<FunctionScope>().canonicalFunction()->isAsync());
|
||||
|
||||
if (!CanUseDebugEnvironmentMaps(cx))
|
||||
@ -2745,7 +2745,7 @@ DebugEnvironments::onPopCall(JSContext* cx, AbstractFramePtr frame)
|
||||
if (!frame.environmentChain()->is<CallObject>())
|
||||
return;
|
||||
|
||||
if (frame.callee()->isStarGenerator() || frame.callee()->isAsync())
|
||||
if (frame.callee()->isGenerator() || frame.callee()->isAsync())
|
||||
return;
|
||||
|
||||
CallObject& callobj = frame.environmentChain()->as<CallObject>();
|
||||
@ -2879,7 +2879,7 @@ DebugEnvironments::updateLiveEnvironments(JSContext* cx)
|
||||
continue;
|
||||
|
||||
if (frame.isFunctionFrame()) {
|
||||
if (frame.callee()->isStarGenerator() || frame.callee()->isAsync())
|
||||
if (frame.callee()->isGenerator() || frame.callee()->isAsync())
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -3043,7 +3043,7 @@ GetDebugEnvironmentForMissing(JSContext* cx, const EnvironmentIter& ei)
|
||||
if (ei.scope().is<FunctionScope>()) {
|
||||
RootedFunction callee(cx, ei.scope().as<FunctionScope>().canonicalFunction());
|
||||
// Generators should always reify their scopes.
|
||||
MOZ_ASSERT(!callee->isStarGenerator() && !callee->isAsync());
|
||||
MOZ_ASSERT(!callee->isGenerator() && !callee->isAsync());
|
||||
|
||||
JS::ExposeObjectToActiveJS(callee);
|
||||
Rooted<CallObject*> callobj(cx, CallObject::createHollowForDebug(cx, callee));
|
||||
|
@ -20,7 +20,7 @@ using namespace js;
|
||||
JSObject*
|
||||
GeneratorObject::create(JSContext* cx, AbstractFramePtr frame)
|
||||
{
|
||||
MOZ_ASSERT(frame.script()->isStarGenerator() || frame.script()->isAsync());
|
||||
MOZ_ASSERT(frame.script()->isGenerator() || frame.script()->isAsync());
|
||||
MOZ_ASSERT(frame.script()->nfixed() == 0);
|
||||
|
||||
Rooted<GlobalObject*> global(cx, cx->global());
|
||||
@ -33,12 +33,12 @@ GeneratorObject::create(JSContext* cx, AbstractFramePtr frame)
|
||||
return nullptr;
|
||||
RootedObject proto(cx, pval.isObject() ? &pval.toObject() : nullptr);
|
||||
if (!proto) {
|
||||
proto = GlobalObject::getOrCreateStarGeneratorObjectPrototype(cx, global);
|
||||
proto = GlobalObject::getOrCreateGeneratorObjectPrototype(cx, global);
|
||||
if (!proto)
|
||||
return nullptr;
|
||||
}
|
||||
RootedNativeObject obj(cx,
|
||||
NewNativeObjectWithGivenProto(cx, &StarGeneratorObject::class_, proto));
|
||||
NewNativeObjectWithGivenProto(cx, &GeneratorObject::class_, proto));
|
||||
if (!obj)
|
||||
return nullptr;
|
||||
|
||||
@ -62,7 +62,7 @@ GeneratorObject::suspend(JSContext* cx, HandleObject obj, AbstractFramePtr frame
|
||||
Rooted<GeneratorObject*> genObj(cx, &obj->as<GeneratorObject>());
|
||||
MOZ_ASSERT(!genObj->hasExpressionStack() || genObj->isExpressionStackEmpty());
|
||||
MOZ_ASSERT_IF(*pc == JSOP_AWAIT, genObj->callee().isAsync());
|
||||
MOZ_ASSERT_IF(*pc == JSOP_YIELD, genObj->callee().isStarGenerator());
|
||||
MOZ_ASSERT_IF(*pc == JSOP_YIELD, genObj->callee().isGenerator());
|
||||
|
||||
ArrayObject* stack = nullptr;
|
||||
if (nvalues > 0) {
|
||||
@ -114,21 +114,17 @@ js::SetGeneratorClosed(JSContext* cx, AbstractFramePtr frame)
|
||||
}
|
||||
|
||||
bool
|
||||
js::GeneratorThrowOrClose(JSContext* cx, AbstractFramePtr frame, Handle<GeneratorObject*> genObj,
|
||||
HandleValue arg, uint32_t resumeKind)
|
||||
js::GeneratorThrowOrReturn(JSContext* cx, AbstractFramePtr frame, Handle<GeneratorObject*> genObj,
|
||||
HandleValue arg, uint32_t resumeKind)
|
||||
{
|
||||
if (resumeKind == GeneratorObject::THROW) {
|
||||
cx->setPendingException(arg);
|
||||
genObj->setRunning();
|
||||
} else {
|
||||
MOZ_ASSERT(resumeKind == GeneratorObject::CLOSE);
|
||||
MOZ_ASSERT(resumeKind == GeneratorObject::RETURN);
|
||||
|
||||
if (genObj->is<StarGeneratorObject>()) {
|
||||
MOZ_ASSERT(arg.isObject());
|
||||
frame.setReturnValue(arg);
|
||||
} else {
|
||||
MOZ_ASSERT(arg.isUndefined());
|
||||
}
|
||||
MOZ_ASSERT(arg.isObject());
|
||||
frame.setReturnValue(arg);
|
||||
|
||||
cx->setPendingException(MagicValue(JS_GENERATOR_CLOSING));
|
||||
genObj->setClosing();
|
||||
@ -179,23 +175,23 @@ GeneratorObject::resume(JSContext* cx, InterpreterActivation& activation,
|
||||
return true;
|
||||
|
||||
case THROW:
|
||||
case CLOSE:
|
||||
return GeneratorThrowOrClose(cx, activation.regs().fp(), genObj, arg, resumeKind);
|
||||
case RETURN:
|
||||
return GeneratorThrowOrReturn(cx, activation.regs().fp(), genObj, arg, resumeKind);
|
||||
|
||||
default:
|
||||
MOZ_CRASH("bad resumeKind");
|
||||
}
|
||||
}
|
||||
|
||||
const Class StarGeneratorObject::class_ = {
|
||||
const Class GeneratorObject::class_ = {
|
||||
"Generator",
|
||||
JSCLASS_HAS_RESERVED_SLOTS(GeneratorObject::RESERVED_SLOTS)
|
||||
};
|
||||
|
||||
static const JSFunctionSpec star_generator_methods[] = {
|
||||
JS_SELF_HOSTED_FN("next", "StarGeneratorNext", 1, 0),
|
||||
JS_SELF_HOSTED_FN("throw", "StarGeneratorThrow", 1, 0),
|
||||
JS_SELF_HOSTED_FN("return", "StarGeneratorReturn", 1, 0),
|
||||
static const JSFunctionSpec generator_methods[] = {
|
||||
JS_SELF_HOSTED_FN("next", "GeneratorNext", 1, 0),
|
||||
JS_SELF_HOSTED_FN("throw", "GeneratorThrow", 1, 0),
|
||||
JS_SELF_HOSTED_FN("return", "GeneratorReturn", 1, 0),
|
||||
JS_FS_END
|
||||
};
|
||||
|
||||
@ -209,9 +205,9 @@ js::NewSingletonObjectWithFunctionPrototype(JSContext* cx, Handle<GlobalObject*>
|
||||
}
|
||||
|
||||
/* static */ bool
|
||||
GlobalObject::initStarGenerators(JSContext* cx, Handle<GlobalObject*> global)
|
||||
GlobalObject::initGenerators(JSContext* cx, Handle<GlobalObject*> global)
|
||||
{
|
||||
if (global->getReservedSlot(STAR_GENERATOR_OBJECT_PROTO).isObject())
|
||||
if (global->getReservedSlot(GENERATOR_OBJECT_PROTO).isObject())
|
||||
return true;
|
||||
|
||||
RootedObject iteratorProto(cx, GlobalObject::getOrCreateIteratorPrototype(cx, global));
|
||||
@ -223,7 +219,7 @@ GlobalObject::initStarGenerators(JSContext* cx, Handle<GlobalObject*> global)
|
||||
iteratorProto));
|
||||
if (!genObjectProto)
|
||||
return false;
|
||||
if (!DefinePropertiesAndFunctions(cx, genObjectProto, nullptr, star_generator_methods) ||
|
||||
if (!DefinePropertiesAndFunctions(cx, genObjectProto, nullptr, generator_methods) ||
|
||||
!DefineToStringTag(cx, genObjectProto, cx->names().Generator))
|
||||
{
|
||||
return false;
|
||||
@ -256,14 +252,14 @@ GlobalObject::initStarGenerators(JSContext* cx, Handle<GlobalObject*> global)
|
||||
return false;
|
||||
}
|
||||
|
||||
global->setReservedSlot(STAR_GENERATOR_OBJECT_PROTO, ObjectValue(*genObjectProto));
|
||||
global->setReservedSlot(STAR_GENERATOR_FUNCTION, ObjectValue(*genFunction));
|
||||
global->setReservedSlot(STAR_GENERATOR_FUNCTION_PROTO, ObjectValue(*genFunctionProto));
|
||||
global->setReservedSlot(GENERATOR_OBJECT_PROTO, ObjectValue(*genObjectProto));
|
||||
global->setReservedSlot(GENERATOR_FUNCTION, ObjectValue(*genFunction));
|
||||
global->setReservedSlot(GENERATOR_FUNCTION_PROTO, ObjectValue(*genFunctionProto));
|
||||
return true;
|
||||
}
|
||||
|
||||
MOZ_MUST_USE bool
|
||||
js::CheckStarGeneratorResumptionValue(JSContext* cx, HandleValue v)
|
||||
js::CheckGeneratorResumptionValue(JSContext* cx, HandleValue v)
|
||||
{
|
||||
// yield/return value should be an Object.
|
||||
if (!v.isObject())
|
||||
|
@ -34,7 +34,9 @@ class GeneratorObject : public NativeObject
|
||||
RESERVED_SLOTS
|
||||
};
|
||||
|
||||
enum ResumeKind { NEXT, THROW, CLOSE };
|
||||
enum ResumeKind { NEXT, THROW, RETURN };
|
||||
|
||||
static const Class class_;
|
||||
|
||||
private:
|
||||
static bool suspend(JSContext* cx, HandleObject obj, AbstractFramePtr frame, jsbytecode* pc,
|
||||
@ -44,7 +46,7 @@ class GeneratorObject : public NativeObject
|
||||
static inline ResumeKind getResumeKind(jsbytecode* pc) {
|
||||
MOZ_ASSERT(*pc == JSOP_RESUME);
|
||||
unsigned arg = GET_UINT16(pc);
|
||||
MOZ_ASSERT(arg <= CLOSE);
|
||||
MOZ_ASSERT(arg <= RETURN);
|
||||
return static_cast<ResumeKind>(arg);
|
||||
}
|
||||
|
||||
@ -53,8 +55,8 @@ class GeneratorObject : public NativeObject
|
||||
return NEXT;
|
||||
if (atom == cx->names().throw_)
|
||||
return THROW;
|
||||
MOZ_ASSERT(atom == cx->names().close);
|
||||
return CLOSE;
|
||||
MOZ_ASSERT(atom == cx->names().return_);
|
||||
return RETURN;
|
||||
}
|
||||
|
||||
static JSObject* create(JSContext* cx, AbstractFramePtr frame);
|
||||
@ -143,7 +145,7 @@ class GeneratorObject : public NativeObject
|
||||
return getFixedSlot(YIELD_AND_AWAIT_INDEX_SLOT).toInt32() == YIELD_AND_AWAIT_INDEX_CLOSING;
|
||||
}
|
||||
bool isSuspended() const {
|
||||
// Note: also update Baseline's IsSuspendedStarGenerator code if this
|
||||
// Note: also update Baseline's IsSuspendedGenerator code if this
|
||||
// changes.
|
||||
MOZ_ASSERT(!isClosed());
|
||||
static_assert(YIELD_AND_AWAIT_INDEX_CLOSING < YIELD_AND_AWAIT_INDEX_RUNNING,
|
||||
@ -185,10 +187,10 @@ class GeneratorObject : public NativeObject
|
||||
bool isAfterYield();
|
||||
bool isAfterAwait();
|
||||
|
||||
private:
|
||||
private:
|
||||
bool isAfterYieldOrAwait(JSOp op);
|
||||
|
||||
public:
|
||||
public:
|
||||
static size_t offsetOfCalleeSlot() {
|
||||
return getFixedSlotOffset(CALLEE_SLOT);
|
||||
}
|
||||
@ -209,26 +211,13 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
class StarGeneratorObject : public GeneratorObject
|
||||
{
|
||||
public:
|
||||
static const Class class_;
|
||||
};
|
||||
|
||||
bool GeneratorThrowOrClose(JSContext* cx, AbstractFramePtr frame, Handle<GeneratorObject*> obj,
|
||||
HandleValue val, uint32_t resumeKind);
|
||||
bool GeneratorThrowOrReturn(JSContext* cx, AbstractFramePtr frame, Handle<GeneratorObject*> obj,
|
||||
HandleValue val, uint32_t resumeKind);
|
||||
void SetGeneratorClosed(JSContext* cx, AbstractFramePtr frame);
|
||||
|
||||
MOZ_MUST_USE bool
|
||||
CheckStarGeneratorResumptionValue(JSContext* cx, HandleValue v);
|
||||
CheckGeneratorResumptionValue(JSContext* cx, HandleValue v);
|
||||
|
||||
} // namespace js
|
||||
|
||||
template<>
|
||||
inline bool
|
||||
JSObject::is<js::GeneratorObject>() const
|
||||
{
|
||||
return is<js::StarGeneratorObject>();
|
||||
}
|
||||
|
||||
#endif /* vm_GeneratorObject_h */
|
||||
|
@ -521,8 +521,6 @@ GlobalObject::initSelfHostingBuiltins(JSContext* cx, Handle<GlobalObject*> globa
|
||||
InitBareBuiltinCtor(cx, global, JSProto_Uint8Array) &&
|
||||
InitBareBuiltinCtor(cx, global, JSProto_Int32Array) &&
|
||||
InitBareSymbolCtor(cx, global) &&
|
||||
InitBareWeakMapCtor(cx, global) &&
|
||||
InitStopIterationClass(cx, global) &&
|
||||
DefineFunctions(cx, global, builtins, AsIntrinsic);
|
||||
}
|
||||
|
||||
|
@ -77,9 +77,9 @@ class GlobalObject : public NativeObject
|
||||
ITERATOR_PROTO,
|
||||
ARRAY_ITERATOR_PROTO,
|
||||
STRING_ITERATOR_PROTO,
|
||||
STAR_GENERATOR_OBJECT_PROTO,
|
||||
STAR_GENERATOR_FUNCTION_PROTO,
|
||||
STAR_GENERATOR_FUNCTION,
|
||||
GENERATOR_OBJECT_PROTO,
|
||||
GENERATOR_FUNCTION_PROTO,
|
||||
GENERATOR_FUNCTION,
|
||||
ASYNC_FUNCTION_PROTO,
|
||||
ASYNC_FUNCTION,
|
||||
ASYNC_ITERATOR_PROTO,
|
||||
@ -577,21 +577,21 @@ class GlobalObject : public NativeObject
|
||||
}
|
||||
|
||||
static NativeObject*
|
||||
getOrCreateStarGeneratorObjectPrototype(JSContext* cx, Handle<GlobalObject*> global)
|
||||
getOrCreateGeneratorObjectPrototype(JSContext* cx, Handle<GlobalObject*> global)
|
||||
{
|
||||
return MaybeNativeObject(getOrCreateObject(cx, global, STAR_GENERATOR_OBJECT_PROTO,
|
||||
initStarGenerators));
|
||||
return MaybeNativeObject(getOrCreateObject(cx, global, GENERATOR_OBJECT_PROTO,
|
||||
initGenerators));
|
||||
}
|
||||
|
||||
static NativeObject*
|
||||
getOrCreateStarGeneratorFunctionPrototype(JSContext* cx, Handle<GlobalObject*> global) {
|
||||
return MaybeNativeObject(getOrCreateObject(cx, global, STAR_GENERATOR_FUNCTION_PROTO,
|
||||
initStarGenerators));
|
||||
getOrCreateGeneratorFunctionPrototype(JSContext* cx, Handle<GlobalObject*> global) {
|
||||
return MaybeNativeObject(getOrCreateObject(cx, global, GENERATOR_FUNCTION_PROTO,
|
||||
initGenerators));
|
||||
}
|
||||
|
||||
static JSObject*
|
||||
getOrCreateStarGeneratorFunction(JSContext* cx, Handle<GlobalObject*> global) {
|
||||
return getOrCreateObject(cx, global, STAR_GENERATOR_FUNCTION, initStarGenerators);
|
||||
getOrCreateGeneratorFunction(JSContext* cx, Handle<GlobalObject*> global) {
|
||||
return getOrCreateObject(cx, global, GENERATOR_FUNCTION, initGenerators);
|
||||
}
|
||||
|
||||
static NativeObject*
|
||||
@ -764,7 +764,7 @@ class GlobalObject : public NativeObject
|
||||
static bool initStringIteratorProto(JSContext* cx, Handle<GlobalObject*> global);
|
||||
|
||||
// Implemented in vm/GeneratorObject.cpp.
|
||||
static bool initStarGenerators(JSContext* cx, Handle<GlobalObject*> global);
|
||||
static bool initGenerators(JSContext* cx, Handle<GlobalObject*> global);
|
||||
|
||||
static bool initAsyncFunction(JSContext* cx, Handle<GlobalObject*> global);
|
||||
|
||||
@ -842,10 +842,10 @@ class GlobalObject : public NativeObject
|
||||
return &value.toObject().as<JSFunction>();
|
||||
}
|
||||
|
||||
// Returns either this global's star-generator function prototype, or null
|
||||
// if that object was never created. Dodgy; for use only in also-dodgy
|
||||
// Returns either this global's generator function prototype, or null if
|
||||
// that object was never created. Dodgy; for use only in also-dodgy
|
||||
// GlobalHelperThreadState::mergeParseTaskCompartment().
|
||||
JSObject* getStarGeneratorFunctionPrototype();
|
||||
JSObject* getGeneratorFunctionPrototype();
|
||||
};
|
||||
|
||||
/*
|
||||
|
@ -700,7 +700,7 @@ EnsureParserCreatedClasses(JSContext* cx, ParseTaskKind kind)
|
||||
if (!EnsureConstructor(cx, global, JSProto_RegExp))
|
||||
return false; // needed by regular expression literals
|
||||
|
||||
if (!GlobalObject::initStarGenerators(cx, global))
|
||||
if (!GlobalObject::initGenerators(cx, global))
|
||||
return false; // needed by function*() {} and generator comprehensions
|
||||
|
||||
if (kind == ParseTaskKind::Module && !GlobalObject::ensureModulePrototypesCreated(cx, global))
|
||||
@ -1720,9 +1720,9 @@ GlobalHelperThreadState::cancelParseTask(JSRuntime* rt, ParseTaskKind kind, void
|
||||
}
|
||||
|
||||
JSObject*
|
||||
GlobalObject::getStarGeneratorFunctionPrototype()
|
||||
GlobalObject::getGeneratorFunctionPrototype()
|
||||
{
|
||||
const Value& v = getReservedSlot(STAR_GENERATOR_FUNCTION_PROTO);
|
||||
const Value& v = getReservedSlot(GENERATOR_FUNCTION_PROTO);
|
||||
return v.isObject() ? &v.toObject() : nullptr;
|
||||
}
|
||||
|
||||
@ -1745,7 +1745,7 @@ GlobalHelperThreadState::mergeParseTaskCompartment(JSContext* cx, ParseTask* par
|
||||
// different function object, so the IdentifyStandardPrototype trick
|
||||
// below won't work. Just special-case it.
|
||||
GlobalObject* parseGlobal = &parseTask->parseGlobal->as<GlobalObject>();
|
||||
JSObject* parseTaskStarGenFunctionProto = parseGlobal->getStarGeneratorFunctionPrototype();
|
||||
JSObject* parseTaskGenFunctionProto = parseGlobal->getGeneratorFunctionPrototype();
|
||||
|
||||
// Module objects don't have standard prototypes either.
|
||||
JSObject* moduleProto = parseGlobal->maybeGetModulePrototype();
|
||||
@ -1770,8 +1770,8 @@ GlobalHelperThreadState::mergeParseTaskCompartment(JSContext* cx, ParseTask* par
|
||||
MOZ_ASSERT(key == JSProto_Object || key == JSProto_Array ||
|
||||
key == JSProto_Function || key == JSProto_RegExp);
|
||||
newProto = GetBuiltinPrototypePure(global, key);
|
||||
} else if (protoObj == parseTaskStarGenFunctionProto) {
|
||||
newProto = global->getStarGeneratorFunctionPrototype();
|
||||
} else if (protoObj == parseTaskGenFunctionProto) {
|
||||
newProto = global->getGeneratorFunctionPrototype();
|
||||
} else if (protoObj == moduleProto) {
|
||||
newProto = global->getModulePrototype();
|
||||
} else if (protoObj == importEntryProto) {
|
||||
|
@ -1270,16 +1270,8 @@ ProcessTryNotes(JSContext* cx, EnvironmentIter& ei, InterpreterRegs& regs)
|
||||
DebugOnly<jsbytecode*> pc = regs.fp()->script()->main() + tn->start + tn->length;
|
||||
MOZ_ASSERT(JSOp(*pc) == JSOP_ENDITER);
|
||||
Value* sp = regs.spForStackDepth(tn->stackDepth);
|
||||
RootedObject obj(cx, &sp[-1].toObject());
|
||||
if (!UnwindIteratorForException(cx, obj)) {
|
||||
// We should only settle on the note only if
|
||||
// UnwindIteratorForException itself threw, as
|
||||
// onExceptionUnwind should be called anew with the new
|
||||
// location of the throw (the iterator). Indeed, we must
|
||||
// settle to avoid infinitely handling the same exception.
|
||||
SettleOnTryNote(cx, tn, ei, regs);
|
||||
return ErrorReturnContinuation;
|
||||
}
|
||||
JSObject* obj = &sp[-1].toObject();
|
||||
CloseIterator(obj);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -1985,7 +1977,6 @@ CASE(EnableInterruptsPseudoOpcode)
|
||||
CASE(JSOP_NOP)
|
||||
CASE(JSOP_NOP_DESTRUCTURING)
|
||||
CASE(JSOP_TRY_DESTRUCTURING_ITERCLOSE)
|
||||
CASE(JSOP_ITERNEXT)
|
||||
CASE(JSOP_UNUSED126)
|
||||
CASE(JSOP_UNUSED223)
|
||||
CASE(JSOP_CONDSWITCH)
|
||||
@ -2280,11 +2271,8 @@ CASE(JSOP_ENDITER)
|
||||
{
|
||||
MOZ_ASSERT(REGS.stackDepth() >= 1);
|
||||
COUNT_COVERAGE();
|
||||
ReservedRooted<JSObject*> obj(&rootObject0, ®S.sp[-1].toObject());
|
||||
bool ok = CloseIterator(cx, obj);
|
||||
CloseIterator(®S.sp[-1].toObject());
|
||||
REGS.sp--;
|
||||
if (!ok)
|
||||
goto error;
|
||||
}
|
||||
END_CASE(JSOP_ENDITER)
|
||||
|
||||
@ -2295,6 +2283,13 @@ CASE(JSOP_ISGENCLOSING)
|
||||
}
|
||||
END_CASE(JSOP_ISGENCLOSING)
|
||||
|
||||
CASE(JSOP_ITERNEXT)
|
||||
{
|
||||
// Ion relies on this.
|
||||
MOZ_ASSERT(REGS.sp[-1].isString());
|
||||
}
|
||||
END_CASE(JSOP_ITERNEXT)
|
||||
|
||||
CASE(JSOP_DUP)
|
||||
{
|
||||
MOZ_ASSERT(REGS.stackDepth() >= 1);
|
||||
|
@ -187,7 +187,7 @@ ObjectGroup::useSingletonForNewObject(JSContext* cx, JSScript* script, jsbytecod
|
||||
* Sub2 lets us continue to distinguish the two subclasses and any extra
|
||||
* properties added to those prototype objects.
|
||||
*/
|
||||
if (script->isStarGenerator() || script->isAsync())
|
||||
if (script->isGenerator() || script->isAsync())
|
||||
return false;
|
||||
if (JSOp(*pc) != JSOP_NEW)
|
||||
return false;
|
||||
|
@ -41,7 +41,7 @@ probes::EnterScript(JSContext* cx, JSScript* script, JSFunction* maybeFun,
|
||||
if (rt->geckoProfiler().enabled()) {
|
||||
if (!cx->geckoProfiler().enter(cx, script, maybeFun))
|
||||
return false;
|
||||
MOZ_ASSERT_IF(!fp->script()->isStarGenerator() &&
|
||||
MOZ_ASSERT_IF(!fp->script()->isGenerator() &&
|
||||
!fp->script()->isAsync(),
|
||||
!fp->hasPushedGeckoProfilerFrame());
|
||||
fp->setPushedGeckoProfilerFrame();
|
||||
|
@ -727,20 +727,6 @@ intrinsic_IsPackedArray(JSContext* cx, unsigned argc, Value* vp)
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
intrinsic_GetIteratorPrototype(JSContext* cx, unsigned argc, Value* vp)
|
||||
{
|
||||
CallArgs args = CallArgsFromVp(argc, vp);
|
||||
MOZ_ASSERT(args.length() == 0);
|
||||
|
||||
JSObject* obj = GlobalObject::getOrCreateIteratorPrototype(cx, cx->global());
|
||||
if (!obj)
|
||||
return false;
|
||||
|
||||
args.rval().setObject(*obj);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
js::intrinsic_NewArrayIterator(JSContext* cx, unsigned argc, Value* vp)
|
||||
{
|
||||
@ -848,41 +834,33 @@ intrinsic_SetCanonicalName(JSContext* cx, unsigned argc, Value* vp)
|
||||
}
|
||||
|
||||
static bool
|
||||
intrinsic_StarGeneratorObjectIsClosed(JSContext* cx, unsigned argc, Value* vp)
|
||||
intrinsic_GeneratorObjectIsClosed(JSContext* cx, unsigned argc, Value* vp)
|
||||
{
|
||||
CallArgs args = CallArgsFromVp(argc, vp);
|
||||
MOZ_ASSERT(args.length() == 1);
|
||||
MOZ_ASSERT(args[0].isObject());
|
||||
|
||||
StarGeneratorObject* genObj = &args[0].toObject().as<StarGeneratorObject>();
|
||||
GeneratorObject* genObj = &args[0].toObject().as<GeneratorObject>();
|
||||
args.rval().setBoolean(genObj->isClosed());
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
js::intrinsic_IsSuspendedStarGenerator(JSContext* cx, unsigned argc, Value* vp)
|
||||
js::intrinsic_IsSuspendedGenerator(JSContext* cx, unsigned argc, Value* vp)
|
||||
{
|
||||
CallArgs args = CallArgsFromVp(argc, vp);
|
||||
MOZ_ASSERT(args.length() == 1);
|
||||
|
||||
if (!args[0].isObject() || !args[0].toObject().is<StarGeneratorObject>()) {
|
||||
if (!args[0].isObject() || !args[0].toObject().is<GeneratorObject>()) {
|
||||
args.rval().setBoolean(false);
|
||||
return true;
|
||||
}
|
||||
|
||||
StarGeneratorObject& genObj = args[0].toObject().as<StarGeneratorObject>();
|
||||
GeneratorObject& genObj = args[0].toObject().as<GeneratorObject>();
|
||||
args.rval().setBoolean(!genObj.isClosed() && genObj.isSuspended());
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
intrinsic_ThrowStopIteration(JSContext* cx, unsigned argc, Value* vp)
|
||||
{
|
||||
MOZ_ASSERT(CallArgsFromVp(argc, vp).length() == 0);
|
||||
|
||||
return ThrowStopIteration(cx);
|
||||
}
|
||||
|
||||
static bool
|
||||
intrinsic_GeneratorIsRunning(JSContext* cx, unsigned argc, Value* vp)
|
||||
{
|
||||
@ -2288,9 +2266,6 @@ static const JSFunctionSpec intrinsic_functions[] = {
|
||||
|
||||
JS_FN("std_TypedArray_buffer", js::TypedArray_bufferGetter, 1,0),
|
||||
|
||||
JS_FN("std_WeakMap_get", WeakMap_get, 1,0),
|
||||
JS_FN("std_WeakMap_set", WeakMap_set, 2,0),
|
||||
|
||||
JS_FN("std_SIMD_Int8x16_extractLane", simd_int8x16_extractLane, 2,0),
|
||||
JS_FN("std_SIMD_Int16x8_extractLane", simd_int16x8_extractLane, 2,0),
|
||||
JS_INLINABLE_FN("std_SIMD_Int32x4_extractLane", simd_int32x4_extractLane, 2,0, SimdInt32x4_extractLane),
|
||||
@ -2362,8 +2337,6 @@ static const JSFunctionSpec intrinsic_functions[] = {
|
||||
JS_INLINABLE_FN("IsPackedArray", intrinsic_IsPackedArray, 1,0,
|
||||
IntrinsicIsPackedArray),
|
||||
|
||||
JS_FN("GetIteratorPrototype", intrinsic_GetIteratorPrototype, 0,0),
|
||||
|
||||
JS_INLINABLE_FN("NewArrayIterator", intrinsic_NewArrayIterator, 0,0,
|
||||
IntrinsicNewArrayIterator),
|
||||
|
||||
@ -2403,12 +2376,10 @@ static const JSFunctionSpec intrinsic_functions[] = {
|
||||
JS_FN("CallStringIteratorMethodIfWrapped",
|
||||
CallNonGenericSelfhostedMethod<Is<StringIteratorObject>>, 2,0),
|
||||
|
||||
JS_FN("IsStarGeneratorObject",
|
||||
intrinsic_IsInstanceOfBuiltin<StarGeneratorObject>, 1,0),
|
||||
JS_FN("StarGeneratorObjectIsClosed", intrinsic_StarGeneratorObjectIsClosed, 1,0),
|
||||
JS_FN("IsSuspendedStarGenerator",intrinsic_IsSuspendedStarGenerator,1,0),
|
||||
|
||||
JS_FN("ThrowStopIteration", intrinsic_ThrowStopIteration, 0,0),
|
||||
JS_FN("IsGeneratorObject",
|
||||
intrinsic_IsInstanceOfBuiltin<GeneratorObject>, 1,0),
|
||||
JS_FN("GeneratorObjectIsClosed", intrinsic_GeneratorObjectIsClosed, 1,0),
|
||||
JS_FN("IsSuspendedGenerator", intrinsic_IsSuspendedGenerator, 1,0),
|
||||
|
||||
JS_FN("GeneratorIsRunning", intrinsic_GeneratorIsRunning, 1,0),
|
||||
JS_FN("GeneratorSetClosed", intrinsic_GeneratorSetClosed, 1,0),
|
||||
@ -2478,8 +2449,8 @@ static const JSFunctionSpec intrinsic_functions[] = {
|
||||
JS_FN("CallTypedArrayMethodIfWrapped",
|
||||
CallNonGenericSelfhostedMethod<Is<TypedArrayObject>>, 2, 0),
|
||||
|
||||
JS_FN("CallStarGeneratorMethodIfWrapped",
|
||||
CallNonGenericSelfhostedMethod<Is<StarGeneratorObject>>, 2, 0),
|
||||
JS_FN("CallGeneratorMethodIfWrapped",
|
||||
CallNonGenericSelfhostedMethod<Is<GeneratorObject>>, 2, 0),
|
||||
|
||||
JS_INLINABLE_FN("IsMapObject", intrinsic_IsInstanceOfBuiltin<MapObject>, 1, 0,
|
||||
IntrinsicIsMapObject),
|
||||
@ -3155,7 +3126,7 @@ JSRuntime::cloneSelfHostedFunctionScript(JSContext* cx, HandlePropertyName name,
|
||||
return false;
|
||||
// JSFunction::generatorKind can't handle lazy self-hosted functions, so we make sure there
|
||||
// aren't any.
|
||||
MOZ_ASSERT(!sourceFun->isStarGenerator() && !sourceFun->isAsync());
|
||||
MOZ_ASSERT(!sourceFun->isGenerator() && !sourceFun->isAsync());
|
||||
MOZ_ASSERT(targetFun->isExtended());
|
||||
MOZ_ASSERT(targetFun->isInterpretedLazy());
|
||||
MOZ_ASSERT(targetFun->isSelfHostedBuiltin());
|
||||
|
@ -53,6 +53,9 @@ intrinsic_NewArrayIterator(JSContext* cx, unsigned argc, JS::Value* vp);
|
||||
bool
|
||||
intrinsic_NewStringIterator(JSContext* cx, unsigned argc, JS::Value* vp);
|
||||
|
||||
bool
|
||||
intrinsic_IsSuspendedGenerator(JSContext* cx, unsigned argc, JS::Value* vp);
|
||||
|
||||
} /* namespace js */
|
||||
|
||||
#endif /* vm_SelfHosting_h_ */
|
||||
|
@ -322,7 +322,7 @@ InterpreterStack::resumeGeneratorCallFrame(JSContext* cx, InterpreterRegs& regs,
|
||||
HandleFunction callee, HandleValue newTarget,
|
||||
HandleObject envChain)
|
||||
{
|
||||
MOZ_ASSERT(callee->isStarGenerator() || callee->isAsync());
|
||||
MOZ_ASSERT(callee->isGenerator() || callee->isAsync());
|
||||
RootedScript script(cx, JSFunction::getOrCreateScript(cx, callee));
|
||||
InterpreterFrame* prev = regs.fp();
|
||||
jsbytecode* prevpc = regs.pc;
|
||||
|
@ -264,7 +264,7 @@ InterpreterFrame::epilogue(JSContext* cx, jsbytecode* pc)
|
||||
UnwindAllEnvironmentsInFrame(cx, ei);
|
||||
|
||||
if (isFunctionFrame()) {
|
||||
if (!callee().isStarGenerator() &&
|
||||
if (!callee().isGenerator() &&
|
||||
!callee().isAsync() &&
|
||||
isConstructing() &&
|
||||
thisArgument().isObject() &&
|
||||
|
@ -714,7 +714,7 @@ class InterpreterFrame
|
||||
}
|
||||
|
||||
void resumeGeneratorFrame(JSObject* envChain) {
|
||||
MOZ_ASSERT(script()->isStarGenerator() || script()->isAsync());
|
||||
MOZ_ASSERT(script()->isGenerator() || script()->isAsync());
|
||||
MOZ_ASSERT(isFunctionFrame());
|
||||
flags_ |= HAS_INITIAL_ENV;
|
||||
envChain_ = envChain;
|
||||
|
@ -7152,7 +7152,7 @@ ParseFunction(ModuleValidator& m, ParseNode** fnOut, unsigned* line)
|
||||
ParseContext* outerpc = m.parser().pc;
|
||||
Directives directives(outerpc);
|
||||
FunctionBox* funbox = m.parser().newFunctionBox(fn, fun, toStringStart, directives,
|
||||
NotGenerator, SyncFunction);
|
||||
GeneratorKind::NotGenerator, SyncFunction);
|
||||
if (!funbox)
|
||||
return false;
|
||||
funbox->initWithEnclosingParseContext(outerpc, frontend::Statement);
|
||||
@ -8680,7 +8680,7 @@ EstablishPreconditions(JSContext* cx, AsmJSParser& parser)
|
||||
break;
|
||||
}
|
||||
|
||||
if (parser.pc->isStarGenerator())
|
||||
if (parser.pc->isGenerator())
|
||||
return Warn(parser, JSMSG_USE_ASM_TYPE_FAIL, "Disabled by generator context");
|
||||
|
||||
if (parser.pc->isAsync())
|
||||
|
@ -13,29 +13,16 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=862380
|
||||
/** Test for Bug 862380 **/
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
function go() {
|
||||
checkNotEnumerable($('ifr').contentWindow, true);
|
||||
checkNotEnumerable($('ifr').contentWindow.location, false);
|
||||
checkNotEnumerable($('ifr').contentWindow);
|
||||
checkNotEnumerable($('ifr').contentWindow.location);
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
function checkNotEnumerable(obj, isWindow) {
|
||||
function checkNotEnumerable(obj) {
|
||||
try {
|
||||
const expectedWindow = ["0", "window", "location", "top", "close",
|
||||
"focus", "blur", "postMessage", "self", "closed",
|
||||
"frames", "length", "opener", "parent"];
|
||||
const expectedLocation = ["replace", "href"];
|
||||
const expected = isWindow ? expectedWindow : expectedLocation;
|
||||
is(Object.keys(obj).length, expected.length,
|
||||
"Object.keys gives right array length");
|
||||
var actual = [];
|
||||
is(Object.keys(obj).length, 0, "Object.keys gives empty array");
|
||||
for (var i in obj)
|
||||
actual.push(i);
|
||||
is(actual.length, expected.length,
|
||||
"Enumeration sees the right number of props");
|
||||
actual.sort();
|
||||
expected.sort();
|
||||
for (var i = 0; i < actual.length; ++i)
|
||||
is(actual[i], expected[i], "Arrays should be the same " + i);
|
||||
ok(false, "Enumerated something: " + i);
|
||||
} catch (e) {
|
||||
ok(false, "threw: " + e);
|
||||
}
|
||||
|
@ -223,8 +223,9 @@ CrossOriginXrayWrapper::getPropertyDescriptor(JSContext* cx,
|
||||
// All properties on cross-origin DOM objects are |own|.
|
||||
desc.object().set(wrapper);
|
||||
|
||||
// All properties on cross-origin DOM objects are "configurable". Any
|
||||
// value attributes are read-only.
|
||||
// All properties on cross-origin DOM objects are non-enumerable and
|
||||
// "configurable". Any value attributes are read-only.
|
||||
desc.attributesRef() &= ~JSPROP_ENUMERATE;
|
||||
desc.attributesRef() &= ~JSPROP_PERMANENT;
|
||||
if (!desc.getter() && !desc.setter())
|
||||
desc.attributesRef() |= JSPROP_READONLY;
|
||||
|
@ -209,7 +209,7 @@ pref("dom.compartment_per_addon", true);
|
||||
// execution to record the bytecode of the JavaScript function used, and save it
|
||||
// in the existing cache entry. On the following loads of the same script, the
|
||||
// bytecode would be loaded from the cache instead of being generated once more.
|
||||
pref("dom.script_loader.bytecode_cache.enabled", false);
|
||||
pref("dom.script_loader.bytecode_cache.enabled", true);
|
||||
|
||||
// Ignore the heuristics of the bytecode cache, and always record on the first
|
||||
// visit. (used for testing purposes).
|
||||
|
@ -3,6 +3,7 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "MozURL.h"
|
||||
#include "rust-url-capi/src/rust-url-capi.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace net {
|
||||
@ -107,6 +108,13 @@ MozURL::GetOrigin(nsACString& aOrigin)
|
||||
|
||||
// MozURL::Mutator
|
||||
|
||||
MozURL::Mutator::Mutator(MozURL* url)
|
||||
: mURL(rusturl_clone(url->mURL.get()))
|
||||
, mFinalized(false)
|
||||
, mStatus(NS_OK)
|
||||
{
|
||||
}
|
||||
|
||||
// This macro ensures that the mutator is still valid, meaning it hasn't been
|
||||
// finalized, and none of the setters have returned an error code.
|
||||
#define ENSURE_VALID() \
|
||||
@ -206,5 +214,11 @@ MozURL::Mutator::SetPort(int32_t aPort)
|
||||
return *this;
|
||||
}
|
||||
|
||||
void
|
||||
MozURL::FreeRustURL::operator()(rusturl* aPtr)
|
||||
{
|
||||
rusturl_free(aPtr);
|
||||
}
|
||||
|
||||
} // namespace net
|
||||
} // namespace mozilla
|
||||
|
@ -5,9 +5,12 @@
|
||||
#ifndef mozURL_h__
|
||||
#define mozURL_h__
|
||||
|
||||
#include "rust-url-capi/src/rust-url-capi.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
|
||||
extern "C" {
|
||||
struct rusturl;
|
||||
}
|
||||
|
||||
namespace mozilla {
|
||||
namespace net {
|
||||
|
||||
@ -62,7 +65,7 @@ private:
|
||||
virtual ~MozURL() {}
|
||||
struct FreeRustURL
|
||||
{
|
||||
void operator()(rusturl* aPtr) { rusturl_free(aPtr); }
|
||||
void operator()(rusturl* aPtr);
|
||||
};
|
||||
mozilla::UniquePtr<rusturl, FreeRustURL> mURL;
|
||||
|
||||
@ -111,12 +114,7 @@ public:
|
||||
// if (NS_SUCCEEDED(rv)) { /* use url2 */ }
|
||||
nsresult GetStatus() { return mStatus; }
|
||||
private:
|
||||
explicit Mutator(MozURL* url)
|
||||
: mURL(rusturl_clone(url->mURL.get()))
|
||||
, mFinalized(false)
|
||||
, mStatus(NS_OK)
|
||||
{
|
||||
}
|
||||
explicit Mutator(MozURL* url);
|
||||
mozilla::UniquePtr<rusturl, FreeRustURL> mURL;
|
||||
bool mFinalized;
|
||||
nsresult mStatus;
|
||||
|
234
netwerk/test/gtest/TestBufferedInputStream.cpp
Normal file
234
netwerk/test/gtest/TestBufferedInputStream.cpp
Normal file
@ -0,0 +1,234 @@
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#include "nsBufferedStreams.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsStreamUtils.h"
|
||||
#include "nsString.h"
|
||||
#include "nsStringStream.h"
|
||||
#include "nsThreadUtils.h"
|
||||
#include "Helpers.h"
|
||||
|
||||
class AsyncStringStream final : public nsIAsyncInputStream
|
||||
{
|
||||
nsCOMPtr<nsIInputStream> mStream;
|
||||
|
||||
public:
|
||||
NS_DECL_THREADSAFE_ISUPPORTS
|
||||
|
||||
explicit AsyncStringStream(const nsACString& aBuffer)
|
||||
{
|
||||
NS_NewCStringInputStream(getter_AddRefs(mStream), aBuffer);
|
||||
}
|
||||
|
||||
NS_IMETHOD
|
||||
Available(uint64_t* aLength) override
|
||||
{
|
||||
return mStream->Available(aLength);
|
||||
}
|
||||
|
||||
NS_IMETHOD
|
||||
Read(char* aBuffer, uint32_t aCount, uint32_t* aReadCount) override
|
||||
{
|
||||
return mStream->Read(aBuffer, aCount, aReadCount);
|
||||
}
|
||||
|
||||
NS_IMETHOD
|
||||
ReadSegments(nsWriteSegmentFun aWriter, void* aClosure,
|
||||
uint32_t aCount, uint32_t *aResult) override
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHOD
|
||||
Close() override
|
||||
{
|
||||
nsresult rv = mStream->Close();
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
MaybeExecCallback(mCallback, mCallbackEventTarget);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHOD
|
||||
IsNonBlocking(bool* aNonBlocking) override
|
||||
{
|
||||
return mStream->IsNonBlocking(aNonBlocking);
|
||||
}
|
||||
|
||||
NS_IMETHOD
|
||||
CloseWithStatus(nsresult aStatus) override
|
||||
{
|
||||
return Close();
|
||||
}
|
||||
|
||||
NS_IMETHOD
|
||||
AsyncWait(nsIInputStreamCallback* aCallback,
|
||||
uint32_t aFlags, uint32_t aRequestedCount,
|
||||
nsIEventTarget* aEventTarget) override
|
||||
{
|
||||
if (aFlags & nsIAsyncInputStream::WAIT_CLOSURE_ONLY) {
|
||||
mCallback = aCallback;
|
||||
mCallbackEventTarget = aEventTarget;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
MaybeExecCallback(aCallback, aEventTarget);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
MaybeExecCallback(nsIInputStreamCallback* aCallback,
|
||||
nsIEventTarget* aEventTarget)
|
||||
{
|
||||
if (!aCallback) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIInputStreamCallback> callback = aCallback;
|
||||
nsCOMPtr<nsIAsyncInputStream> self = this;
|
||||
|
||||
nsCOMPtr<nsIRunnable> r = NS_NewRunnableFunction(
|
||||
"AsyncWait", [callback, self]() { callback->OnInputStreamReady(self); });
|
||||
|
||||
if (aEventTarget) {
|
||||
aEventTarget->Dispatch(r.forget());
|
||||
} else {
|
||||
r->Run();
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
~AsyncStringStream() = default;
|
||||
|
||||
nsCOMPtr<nsIInputStreamCallback> mCallback;
|
||||
nsCOMPtr<nsIEventTarget> mCallbackEventTarget;
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS(AsyncStringStream, nsIAsyncInputStream, nsIInputStream)
|
||||
|
||||
// Helper function for creating a AsyncStringStream
|
||||
already_AddRefed<nsBufferedInputStream>
|
||||
CreateStream(uint32_t aSize, nsCString& aBuffer)
|
||||
{
|
||||
aBuffer.SetLength(aSize);
|
||||
for (uint32_t i = 0; i < aSize; ++i) {
|
||||
aBuffer.BeginWriting()[i] = i % 10;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIInputStream> stream = new AsyncStringStream(aBuffer);
|
||||
|
||||
RefPtr<nsBufferedInputStream> bis = new nsBufferedInputStream();
|
||||
bis->Init(stream, aSize);
|
||||
return bis.forget();
|
||||
}
|
||||
|
||||
// Simple reading.
|
||||
TEST(TestBufferedInputStream, SimpleRead) {
|
||||
const size_t kBufSize = 10;
|
||||
|
||||
nsCString buf;
|
||||
RefPtr<nsBufferedInputStream> bis = CreateStream(kBufSize, buf);
|
||||
|
||||
uint64_t length;
|
||||
ASSERT_EQ(NS_OK, bis->Available(&length));
|
||||
ASSERT_EQ((uint64_t)kBufSize, length);
|
||||
|
||||
char buf2[kBufSize];
|
||||
uint32_t count;
|
||||
ASSERT_EQ(NS_OK, bis->Read(buf2, sizeof(buf2), &count));
|
||||
ASSERT_EQ(count, buf.Length());
|
||||
ASSERT_TRUE(nsCString(buf.get(), kBufSize).Equals(nsCString(buf2, count)));
|
||||
}
|
||||
|
||||
// Simple segment reading.
|
||||
TEST(TestBufferedInputStream, SimpleReadSegments) {
|
||||
const size_t kBufSize = 10;
|
||||
|
||||
nsCString buf;
|
||||
RefPtr<nsBufferedInputStream> bis = CreateStream(kBufSize, buf);
|
||||
|
||||
char buf2[kBufSize];
|
||||
uint32_t count;
|
||||
ASSERT_EQ(NS_OK, bis->ReadSegments(NS_CopySegmentToBuffer, buf2, sizeof(buf2), &count));
|
||||
ASSERT_EQ(count, buf.Length());
|
||||
ASSERT_TRUE(nsCString(buf.get(), kBufSize).Equals(nsCString(buf2, count)));
|
||||
}
|
||||
|
||||
// AsyncWait - sync
|
||||
TEST(TestBufferedInputStream, AsyncWait_sync) {
|
||||
const size_t kBufSize = 10;
|
||||
|
||||
nsCString buf;
|
||||
RefPtr<nsBufferedInputStream> bis = CreateStream(kBufSize, buf);
|
||||
|
||||
RefPtr<testing::InputStreamCallback> cb =
|
||||
new testing::InputStreamCallback();
|
||||
|
||||
ASSERT_EQ(NS_OK, bis->AsyncWait(cb, 0, 0, nullptr));
|
||||
|
||||
// Immediatelly called
|
||||
ASSERT_TRUE(cb->Called());
|
||||
}
|
||||
|
||||
// AsyncWait - async
|
||||
TEST(TestBufferedInputStream, AsyncWait_async) {
|
||||
const size_t kBufSize = 10;
|
||||
|
||||
nsCString buf;
|
||||
RefPtr<nsBufferedInputStream> bis = CreateStream(kBufSize, buf);
|
||||
|
||||
RefPtr<testing::InputStreamCallback> cb =
|
||||
new testing::InputStreamCallback();
|
||||
nsCOMPtr<nsIThread> thread = do_GetCurrentThread();
|
||||
|
||||
ASSERT_EQ(NS_OK, bis->AsyncWait(cb, 0, 0, thread));
|
||||
|
||||
ASSERT_FALSE(cb->Called());
|
||||
|
||||
// Eventually it is called.
|
||||
MOZ_ALWAYS_TRUE(mozilla::SpinEventLoopUntil([&]() { return cb->Called(); }));
|
||||
ASSERT_TRUE(cb->Called());
|
||||
}
|
||||
|
||||
// AsyncWait - sync - closureOnly
|
||||
TEST(TestBufferedInputStream, AsyncWait_sync_closureOnly) {
|
||||
const size_t kBufSize = 10;
|
||||
|
||||
nsCString buf;
|
||||
RefPtr<nsBufferedInputStream> bis = CreateStream(kBufSize, buf);
|
||||
|
||||
RefPtr<testing::InputStreamCallback> cb =
|
||||
new testing::InputStreamCallback();
|
||||
|
||||
ASSERT_EQ(NS_OK, bis->AsyncWait(cb, nsIAsyncInputStream::WAIT_CLOSURE_ONLY,
|
||||
0, nullptr));
|
||||
ASSERT_FALSE(cb->Called());
|
||||
|
||||
bis->CloseWithStatus(NS_ERROR_FAILURE);
|
||||
|
||||
// Immediatelly called
|
||||
ASSERT_TRUE(cb->Called());
|
||||
}
|
||||
|
||||
// AsyncWait - async
|
||||
TEST(TestBufferedInputStream, AsyncWait_async_closureOnly) {
|
||||
const size_t kBufSize = 10;
|
||||
|
||||
nsCString buf;
|
||||
RefPtr<nsBufferedInputStream> bis = CreateStream(kBufSize, buf);
|
||||
|
||||
RefPtr<testing::InputStreamCallback> cb =
|
||||
new testing::InputStreamCallback();
|
||||
nsCOMPtr<nsIThread> thread = do_GetCurrentThread();
|
||||
|
||||
ASSERT_EQ(NS_OK, bis->AsyncWait(cb, nsIAsyncInputStream::WAIT_CLOSURE_ONLY,
|
||||
0, thread));
|
||||
|
||||
ASSERT_FALSE(cb->Called());
|
||||
bis->CloseWithStatus(NS_ERROR_FAILURE);
|
||||
ASSERT_FALSE(cb->Called());
|
||||
|
||||
// Eventually it is called.
|
||||
MOZ_ALWAYS_TRUE(mozilla::SpinEventLoopUntil([&]() { return cb->Called(); }));
|
||||
ASSERT_TRUE(cb->Called());
|
||||
}
|
@ -5,6 +5,7 @@
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
UNIFIED_SOURCES += [
|
||||
'TestBufferedInputStream.cpp',
|
||||
'TestHeaders.cpp',
|
||||
'TestHttpAuthUtils.cpp',
|
||||
'TestMozURL.cpp',
|
||||
@ -17,6 +18,11 @@ TEST_DIRS += [
|
||||
'parse-ftp',
|
||||
]
|
||||
|
||||
LOCAL_INCLUDES += [
|
||||
'/netwerk/base',
|
||||
'/xpcom/tests/gtest',
|
||||
]
|
||||
|
||||
include('/ipc/chromium/chromium-config.mozbuild')
|
||||
|
||||
FINAL_LIBRARY = 'xul-gtest'
|
||||
|
Binary file not shown.
Binary file not shown.
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 57 KiB |
@ -4,7 +4,7 @@
|
||||
== bug569229-1.xml bug569229-1-ref.xml
|
||||
== bug577418-1.html bug577418-1-ref.html
|
||||
== bug582788-1.html bug582788-1-ref.html
|
||||
skip-if(OSX&&!isDebugBuild) fuzzy-if(skiaContent,2,5) == bug582940-1.html bug582940-1-ref.html
|
||||
skip-if(OSX) fuzzy-if(skiaContent,2,5) == bug582940-1.html bug582940-1-ref.html
|
||||
== bug592656-1.html bug592656-1-ref.html
|
||||
fuzzy-if(skiaContent,1,5) == bug599320-1.html bug599320-1-ref.html
|
||||
fuzzy-if(skiaContent,2,5) == bug608373-1.html bug608373-1-ref.html
|
||||
|
@ -1158,4 +1158,4 @@ static const TransportSecurityPreload kPublicKeyPinningPreloadList[] = {
|
||||
|
||||
static const int32_t kUnknownId = -1;
|
||||
|
||||
static const PRTime kPreloadPKPinsExpirationTime = INT64_C(1518053725194000);
|
||||
static const PRTime kPreloadPKPinsExpirationTime = INT64_C(1518114522653000);
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -718,6 +718,9 @@ __PK11_SetCertificateNickname
|
||||
NSS_SecureMemcmpZero
|
||||
PORT_ZAllocAlignedOffset_Util
|
||||
CERT_FindCertByNicknameOrEmailAddrCX
|
||||
SECKEY_GetPrivateKeyType
|
||||
SEC_DerSignDataWithAlgorithmID
|
||||
SEC_CreateSignatureAlgorithmParameters
|
||||
# These symbols are not used by Firefox itself, but are used by Java's security
|
||||
# libraries, which in turn are used by Java applets/plugins/etc. Provide them
|
||||
# to make Java code happy.
|
||||
|
@ -1 +1 @@
|
||||
f3766809817b
|
||||
NSS_3_34_BETA1
|
||||
|
@ -0,0 +1,11 @@
|
||||
Functions changes summary: 0 Removed, 0 Changed, 4 Added functions
|
||||
Variables changes summary: 0 Removed, 0 Changed, 0 Added variable
|
||||
|
||||
4 Added functions:
|
||||
|
||||
'function SECItem* SEC_CreateSignatureAlgorithmParameters(SECItem*, SECOidTag, SECOidTag, const SECItem*, const SECKEYPrivateKey*)' {SEC_CreateSignatureAlgorithmParameters@@NSS_3.34}
|
||||
'function SECStatus SEC_DerSignDataWithAlgorithmID(SECItem*, const unsigned char*, int, SECKEYPrivateKey*, SECAlgorithmID*)' {SEC_DerSignDataWithAlgorithmID@@NSS_3.34}
|
||||
'function SECStatus SEC_SignDataWithAlgorithmID(SECItem*, const unsigned char*, int, SECKEYPrivateKey*, SECAlgorithmID*)' {SEC_SignDataWithAlgorithmID@@NSS_3.34}
|
||||
'function void SGN_NewContextWithAlgorithmID(SECAlgorithmID*, SECKEYPrivateKey*)' {SGN_NewContextWithAlgorithmID@@NSS_3.34}
|
||||
|
||||
|
@ -0,0 +1,15 @@
|
||||
Functions changes summary: 0 Removed, 1 Changed, 0 Added function
|
||||
Variables changes summary: 0 Removed, 0 Changed, 0 Added variable
|
||||
|
||||
1 function with some indirect sub-type change:
|
||||
|
||||
[C]'function SECStatus SSL_GetChannelInfo(SSLChannelInfo*, PRUintn)' at sslinfo.c:26:1 has some indirect sub-type changes:
|
||||
parameter 1 of type 'SSLChannelInfo*' has sub-type changes:
|
||||
in pointed to type 'typedef SSLChannelInfo' at sslt.h:288:1:
|
||||
underlying type 'struct SSLChannelInfoStr' at sslt.h:229:1 changed:
|
||||
type size changed from 896 to 960 bits
|
||||
2 data member insertions:
|
||||
'SSLNamedGroup SSLChannelInfoStr::originalKeaGroup', at offset 864 (in bits) at sslt.h:281:1
|
||||
'PRBool SSLChannelInfoStr::resumed', at offset 896 (in bits) at sslt.h:284:1
|
||||
|
||||
|
@ -256,26 +256,41 @@ check_abi()
|
||||
fi
|
||||
popd
|
||||
|
||||
ABI_PROBLEM_FOUND=0
|
||||
ABI_REPORT=${OUTPUTDIR}/abi-diff.txt
|
||||
rm -f ${ABI_REPORT}
|
||||
PREVDIST=${HGDIR}/baseline/dist
|
||||
NEWDIST=${HGDIR}/dist
|
||||
ALL_SOs="libfreebl3.so libfreeblpriv3.so libnspr4.so libnss3.so libnssckbi.so libnssdbm3.so libnsssysinit.so libnssutil3.so libplc4.so libplds4.so libsmime3.so libsoftokn3.so libssl3.so"
|
||||
for SO in ${ALL_SOs}; do
|
||||
if [ ! -f nss/automation/abi-check/expected-report-$SO.txt ]; then
|
||||
touch nss/automation/abi-check/expected-report-$SO.txt
|
||||
if [ ! -f ${HGDIR}/nss/automation/abi-check/expected-report-$SO.txt ]; then
|
||||
touch ${HGDIR}/nss/automation/abi-check/expected-report-$SO.txt
|
||||
fi
|
||||
abidiff --hd1 $PREVDIST/public/ --hd2 $NEWDIST/public \
|
||||
$PREVDIST/*/lib/$SO $NEWDIST/*/lib/$SO \
|
||||
> nss/automation/abi-check/new-report-$SO.txt
|
||||
diff -u nss/automation/abi-check/expected-report-$SO.txt \
|
||||
nss/automation/abi-check/new-report-$SO.txt >> ${ABI_REPORT}
|
||||
> ${HGDIR}/nss/automation/abi-check/new-report-$SO.txt
|
||||
if [ $? -ne 0 ]; then
|
||||
ABI_PROBLEM_FOUND=1
|
||||
fi
|
||||
if [ ! -f ${HGDIR}/nss/automation/abi-check/expected-report-$SO.txt ]; then
|
||||
ABI_PROBLEM_FOUND=1
|
||||
fi
|
||||
|
||||
diff -wB -u ${HGDIR}/nss/automation/abi-check/expected-report-$SO.txt \
|
||||
${HGDIR}/nss/automation/abi-check/new-report-$SO.txt >> ${ABI_REPORT}
|
||||
if [ ! -f ${ABI_REPORT} ]; then
|
||||
ABI_PROBLEM_FOUND=1
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -s ${ABI_REPORT} ]; then
|
||||
print_log "FAILED: there are new unexpected ABI changes"
|
||||
cat ${ABI_REPORT}
|
||||
return 1
|
||||
elif [ $ABI_PROBLEM_FOUND -ne 0 ]; then
|
||||
print_log "FAILED: failure executing the ABI checks"
|
||||
cat ${ABI_REPORT}
|
||||
return 1
|
||||
fi
|
||||
|
||||
return 0
|
||||
|
@ -194,6 +194,8 @@ CertReq(SECKEYPrivateKey *privk, SECKEYPublicKey *pubk, KeyType keyType,
|
||||
PLArenaPool *arena;
|
||||
void *extHandle;
|
||||
SECItem signedReq = { siBuffer, NULL, 0 };
|
||||
SECAlgorithmID signAlg;
|
||||
SECItem *params = NULL;
|
||||
|
||||
arena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE);
|
||||
if (!arena) {
|
||||
@ -211,11 +213,25 @@ CertReq(SECKEYPrivateKey *privk, SECKEYPublicKey *pubk, KeyType keyType,
|
||||
|
||||
/* Change cert type to RSA-PSS, if desired. */
|
||||
if (pssCertificate) {
|
||||
params = SEC_CreateSignatureAlgorithmParameters(arena,
|
||||
NULL,
|
||||
SEC_OID_PKCS1_RSA_PSS_SIGNATURE,
|
||||
hashAlgTag,
|
||||
NULL,
|
||||
privk);
|
||||
if (!params) {
|
||||
PORT_FreeArena(arena, PR_FALSE);
|
||||
SECKEY_DestroySubjectPublicKeyInfo(spki);
|
||||
SECU_PrintError(progName, "unable to create RSA-PSS parameters");
|
||||
return SECFailure;
|
||||
}
|
||||
|
||||
spki->algorithm.parameters.data = NULL;
|
||||
rv = SECOID_SetAlgorithmID(arena, &spki->algorithm,
|
||||
SEC_OID_PKCS1_RSA_PSS_SIGNATURE, 0);
|
||||
SEC_OID_PKCS1_RSA_PSS_SIGNATURE, params);
|
||||
if (rv != SECSuccess) {
|
||||
PORT_FreeArena(arena, PR_FALSE);
|
||||
SECKEY_DestroySubjectPublicKeyInfo(spki);
|
||||
SECU_PrintError(progName, "unable to set algorithm ID");
|
||||
return SECFailure;
|
||||
}
|
||||
@ -256,16 +272,34 @@ CertReq(SECKEYPrivateKey *privk, SECKEYPublicKey *pubk, KeyType keyType,
|
||||
return SECFailure;
|
||||
}
|
||||
|
||||
/* Sign the request */
|
||||
signAlgTag = SEC_GetSignatureAlgorithmOidTag(keyType, hashAlgTag);
|
||||
if (signAlgTag == SEC_OID_UNKNOWN) {
|
||||
PORT_FreeArena(arena, PR_FALSE);
|
||||
SECU_PrintError(progName, "unknown Key or Hash type");
|
||||
return SECFailure;
|
||||
PORT_Memset(&signAlg, 0, sizeof(signAlg));
|
||||
if (pssCertificate) {
|
||||
rv = SECOID_SetAlgorithmID(arena, &signAlg,
|
||||
SEC_OID_PKCS1_RSA_PSS_SIGNATURE, params);
|
||||
if (rv != SECSuccess) {
|
||||
PORT_FreeArena(arena, PR_FALSE);
|
||||
SECU_PrintError(progName, "unable to set algorithm ID");
|
||||
return SECFailure;
|
||||
}
|
||||
} else {
|
||||
signAlgTag = SEC_GetSignatureAlgorithmOidTag(keyType, hashAlgTag);
|
||||
if (signAlgTag == SEC_OID_UNKNOWN) {
|
||||
PORT_FreeArena(arena, PR_FALSE);
|
||||
SECU_PrintError(progName, "unknown Key or Hash type");
|
||||
return SECFailure;
|
||||
}
|
||||
rv = SECOID_SetAlgorithmID(arena, &signAlg, signAlgTag, 0);
|
||||
if (rv != SECSuccess) {
|
||||
PORT_FreeArena(arena, PR_FALSE);
|
||||
SECU_PrintError(progName, "unable to set algorithm ID");
|
||||
return SECFailure;
|
||||
}
|
||||
}
|
||||
|
||||
rv = SEC_DerSignData(arena, &signedReq, encoding->data, encoding->len,
|
||||
privk, signAlgTag);
|
||||
/* Sign the request */
|
||||
rv = SEC_DerSignDataWithAlgorithmID(arena, &signedReq,
|
||||
encoding->data, encoding->len,
|
||||
privk, &signAlg);
|
||||
if (rv) {
|
||||
PORT_FreeArena(arena, PR_FALSE);
|
||||
SECU_PrintError(progName, "signing of data failed");
|
||||
@ -1183,6 +1217,8 @@ luC(enum usage_level ul, const char *command)
|
||||
" -o output-cert");
|
||||
FPS "%-20s Self sign\n",
|
||||
" -x");
|
||||
FPS "%-20s Sign the certificate with RSA-PSS (the issuer key must be rsa)\n",
|
||||
" --pss-sign");
|
||||
FPS "%-20s Cert serial number\n",
|
||||
" -m serial-number");
|
||||
FPS "%-20s Time Warp\n",
|
||||
@ -1516,6 +1552,8 @@ luR(enum usage_level ul, const char *command)
|
||||
" -h token-name");
|
||||
FPS "%-20s Key size in bits, RSA keys only (min %d, max %d, default %d)\n",
|
||||
" -g key-size", MIN_KEY_BITS, MAX_KEY_BITS, DEFAULT_KEY_BITS);
|
||||
FPS "%-20s Create a certificate request restricted to RSA-PSS (rsa only)\n",
|
||||
" --pss");
|
||||
FPS "%-20s Name of file containing PQG parameters (dsa only)\n",
|
||||
" -q pqgfile");
|
||||
FPS "%-20s Elliptic curve name (ec only)\n",
|
||||
@ -1693,6 +1731,8 @@ luS(enum usage_level ul, const char *command)
|
||||
" -h token-name");
|
||||
FPS "%-20s Key size in bits, RSA keys only (min %d, max %d, default %d)\n",
|
||||
" -g key-size", MIN_KEY_BITS, MAX_KEY_BITS, DEFAULT_KEY_BITS);
|
||||
FPS "%-20s Create a certificate restricted to RSA-PSS (rsa only)\n",
|
||||
" --pss");
|
||||
FPS "%-20s Name of file containing PQG parameters (dsa only)\n",
|
||||
" -q pqgfile");
|
||||
FPS "%-20s Elliptic curve name (ec only)\n",
|
||||
@ -1701,6 +1741,8 @@ luS(enum usage_level ul, const char *command)
|
||||
"");
|
||||
FPS "%-20s Self sign\n",
|
||||
" -x");
|
||||
FPS "%-20s Sign the certificate with RSA-PSS (the issuer key must be rsa)\n",
|
||||
" --pss-sign");
|
||||
FPS "%-20s Cert serial number\n",
|
||||
" -m serial-number");
|
||||
FPS "%-20s Time Warp\n",
|
||||
@ -1864,47 +1906,120 @@ MakeV1Cert(CERTCertDBHandle *handle,
|
||||
return (cert);
|
||||
}
|
||||
|
||||
static SECStatus
|
||||
SetSignatureAlgorithm(PLArenaPool *arena,
|
||||
SECAlgorithmID *signAlg,
|
||||
SECAlgorithmID *spkiAlg,
|
||||
SECOidTag hashAlgTag,
|
||||
SECKEYPrivateKey *privKey,
|
||||
PRBool pssSign)
|
||||
{
|
||||
SECStatus rv;
|
||||
|
||||
if (pssSign ||
|
||||
SECOID_GetAlgorithmTag(spkiAlg) == SEC_OID_PKCS1_RSA_PSS_SIGNATURE) {
|
||||
SECItem *srcParams;
|
||||
SECItem *params;
|
||||
|
||||
if (SECOID_GetAlgorithmTag(spkiAlg) == SEC_OID_PKCS1_RSA_PSS_SIGNATURE) {
|
||||
srcParams = &spkiAlg->parameters;
|
||||
} else {
|
||||
/* If the issuer's public key is RSA, the parameter field
|
||||
* of the SPKI should be NULL, which can't be used as a
|
||||
* basis of RSA-PSS parameters. */
|
||||
srcParams = NULL;
|
||||
}
|
||||
params = SEC_CreateSignatureAlgorithmParameters(arena,
|
||||
NULL,
|
||||
SEC_OID_PKCS1_RSA_PSS_SIGNATURE,
|
||||
hashAlgTag,
|
||||
srcParams,
|
||||
privKey);
|
||||
if (!params) {
|
||||
SECU_PrintError(progName, "Could not create RSA-PSS parameters");
|
||||
return SECFailure;
|
||||
}
|
||||
rv = SECOID_SetAlgorithmID(arena, signAlg,
|
||||
SEC_OID_PKCS1_RSA_PSS_SIGNATURE,
|
||||
params);
|
||||
if (rv != SECSuccess) {
|
||||
SECU_PrintError(progName, "Could not set signature algorithm id.");
|
||||
return rv;
|
||||
}
|
||||
} else {
|
||||
KeyType keyType = SECKEY_GetPrivateKeyType(privKey);
|
||||
SECOidTag algID;
|
||||
|
||||
algID = SEC_GetSignatureAlgorithmOidTag(keyType, hashAlgTag);
|
||||
if (algID == SEC_OID_UNKNOWN) {
|
||||
SECU_PrintError(progName, "Unknown key or hash type for issuer.");
|
||||
return SECFailure;
|
||||
}
|
||||
rv = SECOID_SetAlgorithmID(arena, signAlg, algID, 0);
|
||||
if (rv != SECSuccess) {
|
||||
SECU_PrintError(progName, "Could not set signature algorithm id.");
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
return SECSuccess;
|
||||
}
|
||||
|
||||
static SECStatus
|
||||
SignCert(CERTCertDBHandle *handle, CERTCertificate *cert, PRBool selfsign,
|
||||
SECOidTag hashAlgTag,
|
||||
SECKEYPrivateKey *privKey, char *issuerNickName,
|
||||
int certVersion, void *pwarg)
|
||||
int certVersion, PRBool pssSign, void *pwarg)
|
||||
{
|
||||
SECItem der;
|
||||
SECKEYPrivateKey *caPrivateKey = NULL;
|
||||
SECStatus rv;
|
||||
PLArenaPool *arena;
|
||||
SECOidTag algID;
|
||||
CERTCertificate *issuer;
|
||||
void *dummy;
|
||||
|
||||
if (!selfsign) {
|
||||
CERTCertificate *issuer = PK11_FindCertFromNickname(issuerNickName, pwarg);
|
||||
if ((CERTCertificate *)NULL == issuer) {
|
||||
SECU_PrintError(progName, "unable to find issuer with nickname %s",
|
||||
issuerNickName);
|
||||
return SECFailure;
|
||||
}
|
||||
|
||||
privKey = caPrivateKey = PK11_FindKeyByAnyCert(issuer, pwarg);
|
||||
CERT_DestroyCertificate(issuer);
|
||||
if (caPrivateKey == NULL) {
|
||||
SECU_PrintError(progName, "unable to retrieve key %s", issuerNickName);
|
||||
return SECFailure;
|
||||
}
|
||||
}
|
||||
|
||||
arena = cert->arena;
|
||||
|
||||
algID = SEC_GetSignatureAlgorithmOidTag(privKey->keyType, hashAlgTag);
|
||||
if (algID == SEC_OID_UNKNOWN) {
|
||||
fprintf(stderr, "Unknown key or hash type for issuer.");
|
||||
if (selfsign) {
|
||||
issuer = cert;
|
||||
} else {
|
||||
issuer = PK11_FindCertFromNickname(issuerNickName, pwarg);
|
||||
if ((CERTCertificate *)NULL == issuer) {
|
||||
SECU_PrintError(progName, "unable to find issuer with nickname %s",
|
||||
issuerNickName);
|
||||
rv = SECFailure;
|
||||
goto done;
|
||||
}
|
||||
privKey = caPrivateKey = PK11_FindKeyByAnyCert(issuer, pwarg);
|
||||
if (caPrivateKey == NULL) {
|
||||
SECU_PrintError(progName, "unable to retrieve key %s", issuerNickName);
|
||||
rv = SECFailure;
|
||||
CERT_DestroyCertificate(issuer);
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
||||
if (pssSign &&
|
||||
(SECKEY_GetPrivateKeyType(privKey) != rsaKey &&
|
||||
SECKEY_GetPrivateKeyType(privKey) != rsaPssKey)) {
|
||||
SECU_PrintError(progName, "unable to create RSA-PSS signature with key %s",
|
||||
issuerNickName);
|
||||
rv = SECFailure;
|
||||
if (!selfsign) {
|
||||
CERT_DestroyCertificate(issuer);
|
||||
}
|
||||
goto done;
|
||||
}
|
||||
|
||||
rv = SECOID_SetAlgorithmID(arena, &cert->signature, algID, 0);
|
||||
rv = SetSignatureAlgorithm(arena,
|
||||
&cert->signature,
|
||||
&issuer->subjectPublicKeyInfo.algorithm,
|
||||
hashAlgTag,
|
||||
privKey,
|
||||
pssSign);
|
||||
if (!selfsign) {
|
||||
CERT_DestroyCertificate(issuer);
|
||||
}
|
||||
if (rv != SECSuccess) {
|
||||
fprintf(stderr, "Could not set signature algorithm id.");
|
||||
goto done;
|
||||
}
|
||||
|
||||
@ -1923,7 +2038,8 @@ SignCert(CERTCertDBHandle *handle, CERTCertificate *cert, PRBool selfsign,
|
||||
break;
|
||||
default:
|
||||
PORT_SetError(SEC_ERROR_INVALID_ARGS);
|
||||
return SECFailure;
|
||||
rv = SECFailure;
|
||||
goto done;
|
||||
}
|
||||
|
||||
der.len = 0;
|
||||
@ -1936,7 +2052,8 @@ SignCert(CERTCertDBHandle *handle, CERTCertificate *cert, PRBool selfsign,
|
||||
goto done;
|
||||
}
|
||||
|
||||
rv = SEC_DerSignData(arena, &cert->derCert, der.data, der.len, privKey, algID);
|
||||
rv = SEC_DerSignDataWithAlgorithmID(arena, &cert->derCert, der.data, der.len,
|
||||
privKey, &cert->signature);
|
||||
if (rv != SECSuccess) {
|
||||
fprintf(stderr, "Could not sign encoded certificate data.\n");
|
||||
/* result allocated out of the arena, it will be freed
|
||||
@ -1969,6 +2086,7 @@ CreateCert(
|
||||
certutilExtnList extnList,
|
||||
const char *extGeneric,
|
||||
int certVersion,
|
||||
PRBool pssSign,
|
||||
SECItem *certDER)
|
||||
{
|
||||
void *extHandle = NULL;
|
||||
@ -2029,7 +2147,7 @@ CreateCert(
|
||||
|
||||
rv = SignCert(handle, subjectCert, selfsign, hashAlgTag,
|
||||
*selfsignprivkey, issuerNickName,
|
||||
certVersion, pwarg);
|
||||
certVersion, pssSign, pwarg);
|
||||
if (rv != SECSuccess)
|
||||
break;
|
||||
|
||||
@ -2352,6 +2470,7 @@ enum certutilOpts {
|
||||
opt_GenericExtensions,
|
||||
opt_NewNickname,
|
||||
opt_Pss,
|
||||
opt_PssSign,
|
||||
opt_Help
|
||||
};
|
||||
|
||||
@ -2472,6 +2591,8 @@ static const secuCommandFlag options_init[] =
|
||||
"new-n" },
|
||||
{ /* opt_Pss */ 0, PR_FALSE, 0, PR_FALSE,
|
||||
"pss" },
|
||||
{ /* opt_PssSign */ 0, PR_FALSE, 0, PR_FALSE,
|
||||
"pss-sign" },
|
||||
};
|
||||
#define NUM_OPTIONS ((sizeof options_init) / (sizeof options_init[0]))
|
||||
|
||||
@ -3363,6 +3484,25 @@ certutil_main(int argc, char **argv, PRBool initialize)
|
||||
}
|
||||
}
|
||||
|
||||
/* --pss-sign is to sign a certificate with RSA-PSS, even if the
|
||||
* issuer's key is an RSA key. If the key is an RSA-PSS key, the
|
||||
* generated signature is always RSA-PSS. */
|
||||
if (certutil.options[opt_PssSign].activated) {
|
||||
if (!certutil.commands[cmd_CreateNewCert].activated &&
|
||||
!certutil.commands[cmd_CreateAndAddCert].activated) {
|
||||
PR_fprintf(PR_STDERR,
|
||||
"%s -%c: --pss-sign only works with -C or -S.\n",
|
||||
progName, commandToRun);
|
||||
return 255;
|
||||
}
|
||||
if (keytype != rsaKey) {
|
||||
PR_fprintf(PR_STDERR,
|
||||
"%s -%c: --pss-sign only works with RSA keys.\n",
|
||||
progName, commandToRun);
|
||||
return 255;
|
||||
}
|
||||
}
|
||||
|
||||
/* If we need a list of extensions convert the flags into list format */
|
||||
if (certutil.commands[cmd_CertReq].activated ||
|
||||
certutil.commands[cmd_CreateAndAddCert].activated ||
|
||||
@ -3500,6 +3640,7 @@ certutil_main(int argc, char **argv, PRBool initialize)
|
||||
(certutil.options[opt_GenericExtensions].activated ? certutil.options[opt_GenericExtensions].arg
|
||||
: NULL),
|
||||
certVersion,
|
||||
certutil.options[opt_PssSign].activated,
|
||||
&certDER);
|
||||
if (rv)
|
||||
goto shutdown;
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user