mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 11:55:49 +00:00
Merge inbound to mozilla-central. a=merge
This commit is contained in:
commit
8374f362e7
@ -30,7 +30,7 @@ addMessageListener(TEST_MSG, msg => {
|
||||
|
||||
content.dispatchEvent(
|
||||
new content.CustomEvent(CLIENT_EVENT_TYPE, {
|
||||
detail: msg.data,
|
||||
detail: Cu.cloneInto(msg.data, content),
|
||||
})
|
||||
);
|
||||
|
||||
|
@ -4,12 +4,13 @@
|
||||
|
||||
@import "chrome://global/skin/in-content/common.css";
|
||||
@import "resource://devtools/client/aboutdebugging-new/src/components/App.css";
|
||||
@import "resource://devtools/client/aboutdebugging-new/src/components/ConnectPage.css";
|
||||
@import "resource://devtools/client/aboutdebugging-new/src/components/DebugTargetItem.css";
|
||||
@import "resource://devtools/client/aboutdebugging-new/src/components/DebugTargetList.css";
|
||||
@import "resource://devtools/client/aboutdebugging-new/src/components/ConnectPage.css";
|
||||
@import "resource://devtools/client/aboutdebugging-new/src/components/RuntimeInfo.css";
|
||||
@import "resource://devtools/client/aboutdebugging-new/src/components/Sidebar.css";
|
||||
@import "resource://devtools/client/aboutdebugging-new/src/components/SidebarItem.css";
|
||||
@import "resource://devtools/client/aboutdebugging-new/src/components/debugtarget/ExtensionDetail.css";
|
||||
|
||||
:root {
|
||||
/* Import css variables from common.css */
|
||||
@ -22,6 +23,11 @@ html, body {
|
||||
color: var(--text-color);
|
||||
}
|
||||
|
||||
dd {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
ul {
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
|
@ -4,6 +4,8 @@
|
||||
|
||||
"use strict";
|
||||
|
||||
const { BrowserToolboxProcess } =
|
||||
require("resource://devtools/client/framework/ToolboxProcess.jsm");
|
||||
const { DebuggerClient } = require("devtools/shared/client/debugger-client");
|
||||
const { DebuggerServer } = require("devtools/server/main");
|
||||
|
||||
@ -15,11 +17,16 @@ const {
|
||||
DISCONNECT_RUNTIME_FAILURE,
|
||||
DISCONNECT_RUNTIME_START,
|
||||
DISCONNECT_RUNTIME_SUCCESS,
|
||||
REQUEST_EXTENSIONS_FAILURE,
|
||||
REQUEST_EXTENSIONS_START,
|
||||
REQUEST_EXTENSIONS_SUCCESS,
|
||||
REQUEST_TABS_FAILURE,
|
||||
REQUEST_TABS_START,
|
||||
REQUEST_TABS_SUCCESS,
|
||||
} = require("../constants");
|
||||
|
||||
let browserToolboxProcess = null;
|
||||
|
||||
function connectRuntime() {
|
||||
return async (dispatch, getState) => {
|
||||
dispatch({ type: CONNECT_RUNTIME_START });
|
||||
@ -32,6 +39,7 @@ function connectRuntime() {
|
||||
await client.connect();
|
||||
|
||||
dispatch({ type: CONNECT_RUNTIME_SUCCESS, client });
|
||||
dispatch(requestExtensions());
|
||||
dispatch(requestTabs());
|
||||
} catch (e) {
|
||||
dispatch({ type: CONNECT_RUNTIME_FAILURE, error: e.message });
|
||||
@ -59,6 +67,18 @@ function disconnectRuntime() {
|
||||
function inspectDebugTarget(type, id) {
|
||||
if (type === DEBUG_TARGETS.TAB) {
|
||||
window.open(`about:devtools-toolbox?type=tab&id=${ id }`);
|
||||
} else if (type === DEBUG_TARGETS.EXTENSION) {
|
||||
// Close previous addon debugging toolbox.
|
||||
if (browserToolboxProcess) {
|
||||
browserToolboxProcess.close();
|
||||
}
|
||||
|
||||
browserToolboxProcess = BrowserToolboxProcess.init({
|
||||
addonID: id,
|
||||
onClose: () => {
|
||||
browserToolboxProcess = null;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
console.error(`Failed to inspect the debug target of type: ${ type } id: ${ id }`);
|
||||
}
|
||||
@ -83,9 +103,33 @@ function requestTabs() {
|
||||
};
|
||||
}
|
||||
|
||||
function requestExtensions() {
|
||||
return async (dispatch, getState) => {
|
||||
dispatch({ type: REQUEST_EXTENSIONS_START });
|
||||
|
||||
const client = getState().runtime.client;
|
||||
|
||||
try {
|
||||
const { addons } = await client.listAddons();
|
||||
const extensions = addons.filter(a => a.debuggable);
|
||||
const installedExtensions = extensions.filter(e => !e.temporarilyInstalled);
|
||||
const temporaryExtensions = extensions.filter(e => e.temporarilyInstalled);
|
||||
|
||||
dispatch({
|
||||
type: REQUEST_EXTENSIONS_SUCCESS,
|
||||
installedExtensions,
|
||||
temporaryExtensions,
|
||||
});
|
||||
} catch (e) {
|
||||
dispatch({ type: REQUEST_EXTENSIONS_FAILURE, error: e.message });
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
connectRuntime,
|
||||
disconnectRuntime,
|
||||
inspectDebugTarget,
|
||||
requestTabs,
|
||||
requestExtensions,
|
||||
};
|
||||
|
@ -4,11 +4,15 @@
|
||||
|
||||
"use strict";
|
||||
|
||||
const { PureComponent } = require("devtools/client/shared/vendor/react");
|
||||
const { createFactory, PureComponent } = require("devtools/client/shared/vendor/react");
|
||||
const dom = require("devtools/client/shared/vendor/react-dom-factories");
|
||||
const PropTypes = require("devtools/client/shared/vendor/react-prop-types");
|
||||
|
||||
const ExtensionDetail = createFactory(require("./debugtarget/ExtensionDetail"));
|
||||
const TabDetail = createFactory(require("./debugtarget/TabDetail"));
|
||||
|
||||
const Actions = require("../actions/index");
|
||||
const { DEBUG_TARGETS } = require("../constants");
|
||||
|
||||
/**
|
||||
* This component displays debug target.
|
||||
@ -17,27 +21,39 @@ class DebugTargetItem extends PureComponent {
|
||||
static get propTypes() {
|
||||
return {
|
||||
dispatch: PropTypes.func.isRequired,
|
||||
icon: PropTypes.string.isRequired,
|
||||
id: PropTypes.string.isRequired,
|
||||
name: PropTypes.string.isRequired,
|
||||
type: PropTypes.string.isRequired,
|
||||
url: PropTypes.string.isRequired,
|
||||
target: PropTypes.object.isRequired,
|
||||
};
|
||||
}
|
||||
|
||||
inspect() {
|
||||
const { dispatch, type, id } = this.props;
|
||||
dispatch(Actions.inspectDebugTarget(type, id));
|
||||
const { dispatch, target } = this.props;
|
||||
dispatch(Actions.inspectDebugTarget(target.type, target.id));
|
||||
}
|
||||
|
||||
renderDetail() {
|
||||
const { target } = this.props;
|
||||
|
||||
switch (target.type) {
|
||||
case DEBUG_TARGETS.EXTENSION:
|
||||
return ExtensionDetail({ target });
|
||||
case DEBUG_TARGETS.TAB:
|
||||
return TabDetail({ target });
|
||||
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
renderIcon() {
|
||||
return dom.img({
|
||||
className: "debug-target-item__icon",
|
||||
src: this.props.icon,
|
||||
src: this.props.target.icon,
|
||||
});
|
||||
}
|
||||
|
||||
renderInfo() {
|
||||
const { target } = this.props;
|
||||
|
||||
return dom.div(
|
||||
{
|
||||
className: "debug-target-item__info",
|
||||
@ -45,16 +61,11 @@ class DebugTargetItem extends PureComponent {
|
||||
dom.div(
|
||||
{
|
||||
className: "debug-target-item__info__name ellipsis-text",
|
||||
title: this.props.name,
|
||||
title: target.name,
|
||||
},
|
||||
this.props.name
|
||||
),
|
||||
dom.div(
|
||||
{
|
||||
className: "debug-target-item__info__url ellipsis-text",
|
||||
},
|
||||
this.props.url
|
||||
target.name
|
||||
),
|
||||
this.renderDetail(),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,7 @@ class DebugTargetList extends PureComponent {
|
||||
static get propTypes() {
|
||||
return {
|
||||
dispatch: PropTypes.func.isRequired,
|
||||
targets: PropTypes.arrayOf(PropTypes.Object).isRequired,
|
||||
targets: PropTypes.arrayOf(PropTypes.object).isRequired,
|
||||
};
|
||||
}
|
||||
|
||||
@ -28,16 +28,7 @@ class DebugTargetList extends PureComponent {
|
||||
{
|
||||
className: "debug-target-list",
|
||||
},
|
||||
targets.map(target =>
|
||||
DebugTargetItem({
|
||||
dispatch,
|
||||
icon: target.icon,
|
||||
id: target.id,
|
||||
name: target.name,
|
||||
type: target.type,
|
||||
url: target.url,
|
||||
})
|
||||
),
|
||||
targets.map(target => DebugTargetItem({ dispatch, target })),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -18,12 +18,14 @@ class RuntimePage extends PureComponent {
|
||||
static get propTypes() {
|
||||
return {
|
||||
dispatch: PropTypes.func.isRequired,
|
||||
installedExtensions: PropTypes.arrayOf(PropTypes.object).isRequired,
|
||||
tabs: PropTypes.arrayOf(PropTypes.object).isRequired,
|
||||
temporaryExtensions: PropTypes.arrayOf(PropTypes.object).isRequired,
|
||||
};
|
||||
}
|
||||
|
||||
render() {
|
||||
const { dispatch, tabs } = this.props;
|
||||
const { dispatch, installedExtensions, tabs, temporaryExtensions } = this.props;
|
||||
|
||||
return dom.article(
|
||||
{
|
||||
@ -34,6 +36,16 @@ class RuntimePage extends PureComponent {
|
||||
name: Services.appinfo.name,
|
||||
version: Services.appinfo.version,
|
||||
}),
|
||||
DebugTargetPane({
|
||||
dispatch,
|
||||
name: "Temporary Extensions",
|
||||
targets: temporaryExtensions,
|
||||
}),
|
||||
DebugTargetPane({
|
||||
dispatch,
|
||||
name: "Extensions",
|
||||
targets: installedExtensions,
|
||||
}),
|
||||
DebugTargetPane({
|
||||
dispatch,
|
||||
name: "Tabs",
|
||||
@ -45,7 +57,9 @@ class RuntimePage extends PureComponent {
|
||||
|
||||
const mapStateToProps = state => {
|
||||
return {
|
||||
installedExtensions: state.runtime.installedExtensions,
|
||||
tabs: state.runtime.tabs,
|
||||
temporaryExtensions: state.runtime.temporaryExtensions,
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -0,0 +1,25 @@
|
||||
/* 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/. */
|
||||
|
||||
/*
|
||||
* The current layout of extension detail is
|
||||
*
|
||||
* +----------------+--------------------+
|
||||
* | detail name dt | detail value dd |
|
||||
* | (120px) | (auto) |
|
||||
* +----------------+--------------------+
|
||||
* | detail name dt | detail value dd |
|
||||
* +----------------+--------------------+
|
||||
* | detail name dt | detail value dd |
|
||||
* +----------------+--------------------+
|
||||
*/
|
||||
.extension-detail {
|
||||
display: grid;
|
||||
grid-template-columns: 120px auto;
|
||||
margin-block-start: 4px;
|
||||
}
|
||||
|
||||
.extension-detail__manifest {
|
||||
margin-inline-start: 1ch;
|
||||
}
|
@ -0,0 +1,68 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
"use strict";
|
||||
|
||||
const { PureComponent } = require("devtools/client/shared/vendor/react");
|
||||
const dom = require("devtools/client/shared/vendor/react-dom-factories");
|
||||
const PropTypes = require("devtools/client/shared/vendor/react-prop-types");
|
||||
|
||||
/**
|
||||
* This component displays detail information for extension.
|
||||
*/
|
||||
class ExtensionDetail extends PureComponent {
|
||||
static get propTypes() {
|
||||
return {
|
||||
target: PropTypes.object.isRequired,
|
||||
};
|
||||
}
|
||||
|
||||
renderField(name, value, title) {
|
||||
return [
|
||||
dom.dt({}, name),
|
||||
dom.dd(
|
||||
{
|
||||
className: "ellipsis-text",
|
||||
title: title || value,
|
||||
},
|
||||
value,
|
||||
),
|
||||
];
|
||||
}
|
||||
|
||||
renderUUID() {
|
||||
const { target } = this.props;
|
||||
const { manifestURL, uuid } = target;
|
||||
|
||||
const value = [
|
||||
uuid,
|
||||
dom.a(
|
||||
{
|
||||
className: "extension-detail__manifest",
|
||||
href: manifestURL,
|
||||
target: "_blank",
|
||||
},
|
||||
"Manifest URL",
|
||||
)
|
||||
];
|
||||
|
||||
return this.renderField("Internal UUID", value, uuid);
|
||||
}
|
||||
|
||||
render() {
|
||||
const { target } = this.props;
|
||||
const { id, location, uuid } = target;
|
||||
|
||||
return dom.dl(
|
||||
{
|
||||
className: "extension-detail",
|
||||
},
|
||||
location ? this.renderField("Location", location) : null,
|
||||
this.renderField("Extension ID", id),
|
||||
uuid ? this.renderUUID() : null,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = ExtensionDetail;
|
@ -0,0 +1,26 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
"use strict";
|
||||
|
||||
const { PureComponent } = require("devtools/client/shared/vendor/react");
|
||||
const dom = require("devtools/client/shared/vendor/react-dom-factories");
|
||||
const PropTypes = require("devtools/client/shared/vendor/react-prop-types");
|
||||
|
||||
/**
|
||||
* This component displays detail information for tab.
|
||||
*/
|
||||
class TabDetail extends PureComponent {
|
||||
static get propTypes() {
|
||||
return {
|
||||
target: PropTypes.object.isRequired,
|
||||
};
|
||||
}
|
||||
|
||||
render() {
|
||||
return dom.div({ className: "ellipsis-text" }, this.props.target.url);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = TabDetail;
|
@ -0,0 +1,9 @@
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
DevToolsModules(
|
||||
'ExtensionDetail.css',
|
||||
'ExtensionDetail.js',
|
||||
'TabDetail.js',
|
||||
)
|
@ -2,6 +2,10 @@
|
||||
# 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/.
|
||||
|
||||
DIRS += [
|
||||
'debugtarget',
|
||||
]
|
||||
|
||||
DevToolsModules(
|
||||
'App.css',
|
||||
'App.js',
|
||||
|
@ -11,6 +11,9 @@ const actionTypes = {
|
||||
DISCONNECT_RUNTIME_FAILURE: "DISCONNECT_RUNTIME_FAILURE",
|
||||
DISCONNECT_RUNTIME_START: "DISCONNECT_RUNTIME_START",
|
||||
DISCONNECT_RUNTIME_SUCCESS: "DISCONNECT_RUNTIME_SUCCESS",
|
||||
REQUEST_EXTENSIONS_FAILURE: "REQUEST_EXTENSIONS_FAILURE",
|
||||
REQUEST_EXTENSIONS_START: "REQUEST_EXTENSIONS_START",
|
||||
REQUEST_EXTENSIONS_SUCCESS: "REQUEST_EXTENSIONS_SUCCESS",
|
||||
REQUEST_TABS_FAILURE: "REQUEST_TABS_FAILURE",
|
||||
REQUEST_TABS_START: "REQUEST_TABS_START",
|
||||
REQUEST_TABS_SUCCESS: "REQUEST_TABS_SUCCESS",
|
||||
@ -18,6 +21,7 @@ const actionTypes = {
|
||||
};
|
||||
|
||||
const DEBUG_TARGETS = {
|
||||
EXTENSION: "EXTENSION",
|
||||
TAB: "TAB",
|
||||
};
|
||||
|
||||
|
@ -4,6 +4,8 @@
|
||||
|
||||
"use strict";
|
||||
|
||||
const { AddonManager } = require("resource://gre/modules/AddonManager.jsm");
|
||||
|
||||
const {
|
||||
CONNECT_RUNTIME_SUCCESS,
|
||||
DISCONNECT_RUNTIME_START,
|
||||
@ -11,18 +13,50 @@ const {
|
||||
const Actions = require("../actions/index");
|
||||
|
||||
function debugTargetListenerMiddleware(state) {
|
||||
const onExtensionsUpdated = () => {
|
||||
state.dispatch(Actions.requestExtensions());
|
||||
};
|
||||
|
||||
const onTabsUpdated = () => {
|
||||
state.dispatch(Actions.requestTabs());
|
||||
};
|
||||
|
||||
const extensionsListener = {
|
||||
onDisabled() {
|
||||
onExtensionsUpdated();
|
||||
},
|
||||
|
||||
onEnabled() {
|
||||
onExtensionsUpdated();
|
||||
},
|
||||
|
||||
onInstalled() {
|
||||
onExtensionsUpdated();
|
||||
},
|
||||
|
||||
onOperationCancelled() {
|
||||
onExtensionsUpdated();
|
||||
},
|
||||
|
||||
onUninstalled() {
|
||||
onExtensionsUpdated();
|
||||
},
|
||||
|
||||
onUninstalling() {
|
||||
onExtensionsUpdated();
|
||||
},
|
||||
};
|
||||
|
||||
return next => action => {
|
||||
switch (action.type) {
|
||||
case CONNECT_RUNTIME_SUCCESS: {
|
||||
action.client.addListener("tabListChanged", onTabsUpdated);
|
||||
AddonManager.addAddonListener(extensionsListener);
|
||||
break;
|
||||
}
|
||||
case DISCONNECT_RUNTIME_START: {
|
||||
state.getState().runtime.client.removeListener("tabListChanged", onTabsUpdated);
|
||||
AddonManager.removeAddonListener(extensionsListener);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -8,13 +8,16 @@ const {
|
||||
CONNECT_RUNTIME_SUCCESS,
|
||||
DEBUG_TARGETS,
|
||||
DISCONNECT_RUNTIME_SUCCESS,
|
||||
REQUEST_EXTENSIONS_SUCCESS,
|
||||
REQUEST_TABS_SUCCESS,
|
||||
} = require("../constants");
|
||||
|
||||
function RuntimeState() {
|
||||
return {
|
||||
client: null,
|
||||
installedExtensions: [],
|
||||
tabs: [],
|
||||
temporaryExtensions: [],
|
||||
};
|
||||
}
|
||||
|
||||
@ -27,6 +30,13 @@ function runtimeReducer(state = RuntimeState(), action) {
|
||||
case DISCONNECT_RUNTIME_SUCCESS: {
|
||||
return RuntimeState();
|
||||
}
|
||||
case REQUEST_EXTENSIONS_SUCCESS: {
|
||||
const { installedExtensions, temporaryExtensions } = action;
|
||||
return Object.assign({}, state, {
|
||||
installedExtensions: toExtensionComponentData(installedExtensions),
|
||||
temporaryExtensions: toExtensionComponentData(temporaryExtensions),
|
||||
});
|
||||
}
|
||||
case REQUEST_TABS_SUCCESS: {
|
||||
const { tabs } = action;
|
||||
return Object.assign({}, state, { tabs: toTabComponentData(tabs) });
|
||||
@ -37,6 +47,37 @@ function runtimeReducer(state = RuntimeState(), action) {
|
||||
}
|
||||
}
|
||||
|
||||
function getExtensionFilePath(extension) {
|
||||
// Only show file system paths, and only for temporarily installed add-ons.
|
||||
if (!extension.temporarilyInstalled ||
|
||||
!extension.url ||
|
||||
!extension.url.startsWith("file://")) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Strip a leading slash from Windows drive letter URIs.
|
||||
// file:///home/foo ~> /home/foo
|
||||
// file:///C:/foo ~> C:/foo
|
||||
const windowsRegex = /^file:\/\/\/([a-zA-Z]:\/.*)/;
|
||||
|
||||
if (windowsRegex.test(extension.url)) {
|
||||
return windowsRegex.exec(extension.url)[1];
|
||||
}
|
||||
|
||||
return extension.url.slice("file://".length);
|
||||
}
|
||||
|
||||
function toExtensionComponentData(extensions) {
|
||||
return extensions.map(extension => {
|
||||
const type = DEBUG_TARGETS.EXTENSION;
|
||||
const { iconURL, id, manifestURL, name } = extension;
|
||||
const icon = iconURL || "chrome://mozapps/skin/extensions/extensionGeneric.svg";
|
||||
const location = getExtensionFilePath(extension);
|
||||
const uuid = manifestURL ? /moz-extension:\/\/([^/]*)/.exec(manifestURL)[1] : null;
|
||||
return { type, id, icon, location, manifestURL, name, uuid };
|
||||
});
|
||||
}
|
||||
|
||||
function toTabComponentData(tabs) {
|
||||
return tabs.map(tab => {
|
||||
const type = DEBUG_TARGETS.TAB;
|
||||
|
@ -406,9 +406,6 @@ readSizeOfNextMessage(ZeroCopyInputStream& stream, uint32_t* sizep)
|
||||
bool
|
||||
HeapSnapshot::init(JSContext* cx, const uint8_t* buffer, uint32_t size)
|
||||
{
|
||||
if (!nodes.init() || !frames.init())
|
||||
return false;
|
||||
|
||||
ArrayInputStream stream(buffer, size);
|
||||
GzipInputStream gzipStream(&stream);
|
||||
uint32_t sizeOfMessage = 0;
|
||||
@ -439,8 +436,6 @@ HeapSnapshot::init(JSContext* cx, const uint8_t* buffer, uint32_t size)
|
||||
|
||||
// The set of all node ids we've found edges pointing to.
|
||||
NodeIdSet edgeReferents(cx);
|
||||
if (NS_WARN_IF(!edgeReferents.init()))
|
||||
return false;
|
||||
|
||||
if (NS_WARN_IF(!saveNode(root, edgeReferents)))
|
||||
return false;
|
||||
@ -478,10 +473,6 @@ HeapSnapshot::TakeCensus(JSContext* cx, JS::HandleObject options,
|
||||
JS::MutableHandleValue rval, ErrorResult& rv)
|
||||
{
|
||||
JS::ubi::Census census(cx);
|
||||
if (NS_WARN_IF(!census.init())) {
|
||||
rv.Throw(NS_ERROR_OUT_OF_MEMORY);
|
||||
return;
|
||||
}
|
||||
|
||||
JS::ubi::CountTypePtr rootType;
|
||||
if (NS_WARN_IF(!JS::ubi::ParseCensusOptions(cx, census, options, rootType))) {
|
||||
@ -501,10 +492,6 @@ HeapSnapshot::TakeCensus(JSContext* cx, JS::HandleObject options,
|
||||
JS::AutoCheckCannotGC nogc;
|
||||
|
||||
JS::ubi::CensusTraversal traversal(cx, handler, nogc);
|
||||
if (NS_WARN_IF(!traversal.init())) {
|
||||
rv.Throw(NS_ERROR_OUT_OF_MEMORY);
|
||||
return;
|
||||
}
|
||||
|
||||
if (NS_WARN_IF(!traversal.addStart(getRoot()))) {
|
||||
rv.Throw(NS_ERROR_OUT_OF_MEMORY);
|
||||
@ -610,10 +597,6 @@ HeapSnapshot::ComputeShortestPaths(JSContext*cx, uint64_t start,
|
||||
// snapshot.
|
||||
|
||||
JS::ubi::NodeSet targetsSet;
|
||||
if (NS_WARN_IF(!targetsSet.init())) {
|
||||
rv.Throw(NS_ERROR_OUT_OF_MEMORY);
|
||||
return;
|
||||
}
|
||||
|
||||
for (const auto& target : targets) {
|
||||
Maybe<JS::ubi::Node> targetNode = getNodeById(target);
|
||||
@ -722,9 +705,6 @@ HeapSnapshot::ComputeShortestPaths(JSContext*cx, uint64_t start,
|
||||
static bool
|
||||
PopulateCompartmentsWithGlobals(CompartmentSet& compartments, AutoObjectVector& globals)
|
||||
{
|
||||
if (!compartments.init())
|
||||
return false;
|
||||
|
||||
unsigned length = globals.length();
|
||||
for (unsigned i = 0; i < length; i++) {
|
||||
if (!compartments.put(GetObjectCompartment(globals[i])))
|
||||
@ -768,7 +748,7 @@ EstablishBoundaries(JSContext* cx,
|
||||
CompartmentSet& compartments)
|
||||
{
|
||||
MOZ_ASSERT(!roots.initialized());
|
||||
MOZ_ASSERT(!compartments.initialized());
|
||||
MOZ_ASSERT(compartments.empty());
|
||||
|
||||
bool foundBoundaryProperty = false;
|
||||
|
||||
@ -851,8 +831,6 @@ EstablishBoundaries(JSContext* cx,
|
||||
}
|
||||
|
||||
MOZ_ASSERT(roots.initialized());
|
||||
MOZ_ASSERT_IF(boundaries.mDebugger.WasPassed(), compartments.initialized());
|
||||
MOZ_ASSERT_IF(boundaries.mGlobals.WasPassed(), compartments.initialized());
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1257,12 +1235,6 @@ public:
|
||||
, compartments(compartments)
|
||||
{ }
|
||||
|
||||
bool init() {
|
||||
return framesAlreadySerialized.init() &&
|
||||
twoByteStringsAlreadySerialized.init() &&
|
||||
oneByteStringsAlreadySerialized.init();
|
||||
}
|
||||
|
||||
~StreamWriter() override { }
|
||||
|
||||
bool writeMetadata(uint64_t timestamp) final {
|
||||
@ -1440,8 +1412,6 @@ WriteHeapGraph(JSContext* cx,
|
||||
|
||||
HeapSnapshotHandler handler(writer, compartments);
|
||||
HeapSnapshotHandler::Traversal traversal(cx, handler, noGC);
|
||||
if (!traversal.init())
|
||||
return false;
|
||||
traversal.wantNames = wantNames;
|
||||
|
||||
bool ok = traversal.addStartVisited(node) &&
|
||||
@ -1621,11 +1591,7 @@ ChromeUtils::SaveHeapSnapshotShared(GlobalObject& global,
|
||||
return;
|
||||
|
||||
StreamWriter writer(cx, gzipStream, wantNames,
|
||||
compartments.initialized() ? &compartments : nullptr);
|
||||
if (NS_WARN_IF(!writer.init())) {
|
||||
rv.Throw(NS_ERROR_OUT_OF_MEMORY);
|
||||
return;
|
||||
}
|
||||
!compartments.empty() ? &compartments : nullptr);
|
||||
|
||||
MOZ_ASSERT(maybeNoGC.isSome());
|
||||
ubi::Node roots(&rootList);
|
||||
@ -1638,7 +1604,7 @@ ChromeUtils::SaveHeapSnapshotShared(GlobalObject& global,
|
||||
roots,
|
||||
writer,
|
||||
wantNames,
|
||||
compartments.initialized() ? &compartments : nullptr,
|
||||
!compartments.empty() ? &compartments : nullptr,
|
||||
maybeNoGC.ref(),
|
||||
nodeCount,
|
||||
edgeCount))
|
||||
|
@ -137,7 +137,6 @@ public:
|
||||
|
||||
// Get the root node of this heap snapshot's graph.
|
||||
JS::ubi::Node getRoot() {
|
||||
MOZ_ASSERT(nodes.initialized());
|
||||
auto p = nodes.lookup(rootId);
|
||||
MOZ_ASSERT(p);
|
||||
const DeserializedNode& node = *p;
|
||||
|
@ -27,7 +27,6 @@ DEF_TEST(DoesCrossCompartmentBoundaries, {
|
||||
|
||||
// Our set of target compartments is both the old and new compartments.
|
||||
JS::CompartmentSet targetCompartments;
|
||||
ASSERT_TRUE(targetCompartments.init());
|
||||
ASSERT_TRUE(targetCompartments.put(compartment));
|
||||
ASSERT_TRUE(targetCompartments.put(newCompartment));
|
||||
|
||||
|
@ -28,7 +28,6 @@ DEF_TEST(DoesntCrossCompartmentBoundaries, {
|
||||
// Our set of target compartments is only the pre-existing compartment and
|
||||
// does not include the new compartment.
|
||||
JS::CompartmentSet targetCompartments;
|
||||
ASSERT_TRUE(targetCompartments.init());
|
||||
ASSERT_TRUE(targetCompartments.put(compartment));
|
||||
|
||||
FakeNode nodeA;
|
||||
|
@ -285,7 +285,6 @@ CustomElementRegistry::CustomElementRegistry(nsPIDOMWindowInner* aWindow)
|
||||
, mIsCustomDefinitionRunning(false)
|
||||
{
|
||||
MOZ_ASSERT(aWindow);
|
||||
MOZ_ALWAYS_TRUE(mConstructors.init());
|
||||
|
||||
mozilla::HoldJSObjects(this);
|
||||
}
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include "js/TracingAPI.h"
|
||||
#include "js/Wrapper.h"
|
||||
#include "mozilla/HashFunctions.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
#include "mozilla/dom/ScriptSettings.h"
|
||||
|
||||
#define NPRUNTIME_JSCLASS_NAME "NPObject JS wrapper class"
|
||||
@ -85,7 +86,7 @@ typedef JS::GCHashMap<nsJSObjWrapperKey,
|
||||
nsJSObjWrapper*,
|
||||
JSObjWrapperHasher,
|
||||
js::SystemAllocPolicy> JSObjWrapperTable;
|
||||
static JSObjWrapperTable sJSObjWrappers;
|
||||
static UniquePtr<JSObjWrapperTable> sJSObjWrappers;
|
||||
|
||||
// Whether it's safe to iterate sJSObjWrappers. Set to true when sJSObjWrappers
|
||||
// has been initialized and is not currently being enumerated.
|
||||
@ -294,8 +295,8 @@ OnWrapperDestroyed();
|
||||
static void
|
||||
TraceJSObjWrappers(JSTracer *trc, void *data)
|
||||
{
|
||||
if (sJSObjWrappers.initialized()) {
|
||||
sJSObjWrappers.trace(trc);
|
||||
if (sJSObjWrappers) {
|
||||
sJSObjWrappers->trace(trc);
|
||||
}
|
||||
}
|
||||
|
||||
@ -361,17 +362,13 @@ static bool
|
||||
CreateJSObjWrapperTable()
|
||||
{
|
||||
MOZ_ASSERT(!sJSObjWrappersAccessible);
|
||||
MOZ_ASSERT(!sJSObjWrappers.initialized());
|
||||
MOZ_ASSERT(!sJSObjWrappers);
|
||||
|
||||
if (!RegisterGCCallbacks()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!sJSObjWrappers.init(16)) {
|
||||
NS_ERROR("Error initializing PLDHashTable sJSObjWrappers!");
|
||||
return false;
|
||||
}
|
||||
|
||||
sJSObjWrappers = MakeUnique<JSObjWrapperTable>();
|
||||
sJSObjWrappersAccessible = true;
|
||||
return true;
|
||||
}
|
||||
@ -380,12 +377,11 @@ static void
|
||||
DestroyJSObjWrapperTable()
|
||||
{
|
||||
MOZ_ASSERT(sJSObjWrappersAccessible);
|
||||
MOZ_ASSERT(sJSObjWrappers.initialized());
|
||||
MOZ_ASSERT(sJSObjWrappers.count() == 0);
|
||||
MOZ_ASSERT(sJSObjWrappers);
|
||||
MOZ_ASSERT(sJSObjWrappers->count() == 0);
|
||||
|
||||
// No more wrappers, and our hash was initialized. Finish the
|
||||
// hash to prevent leaking it.
|
||||
sJSObjWrappers.finish();
|
||||
// No more wrappers. Delete the table.
|
||||
sJSObjWrappers = nullptr;
|
||||
sJSObjWrappersAccessible = false;
|
||||
}
|
||||
|
||||
@ -694,9 +690,9 @@ nsJSObjWrapper::NP_Invalidate(NPObject *npobj)
|
||||
if (sJSObjWrappersAccessible) {
|
||||
// Remove the wrapper from the hash
|
||||
nsJSObjWrapperKey key(jsnpobj->mJSObj, jsnpobj->mNpp);
|
||||
JSObjWrapperTable::Ptr ptr = sJSObjWrappers.lookup(key);
|
||||
JSObjWrapperTable::Ptr ptr = sJSObjWrappers->lookup(key);
|
||||
MOZ_ASSERT(ptr.found());
|
||||
sJSObjWrappers.remove(ptr);
|
||||
sJSObjWrappers->remove(ptr);
|
||||
}
|
||||
|
||||
// Forget our reference to the JSObject.
|
||||
@ -1132,14 +1128,14 @@ nsJSObjWrapper::GetNewOrUsed(NPP npp, JS::Handle<JSObject*> obj,
|
||||
return _retainobject(npobj);
|
||||
}
|
||||
|
||||
if (!sJSObjWrappers.initialized()) {
|
||||
if (!sJSObjWrappers) {
|
||||
// No hash yet (or any more), initialize it.
|
||||
if (!CreateJSObjWrapperTable())
|
||||
return nullptr;
|
||||
}
|
||||
MOZ_ASSERT(sJSObjWrappersAccessible);
|
||||
|
||||
JSObjWrapperTable::Ptr p = sJSObjWrappers.lookupForAdd(nsJSObjWrapperKey(obj, npp));
|
||||
JSObjWrapperTable::Ptr p = sJSObjWrappers->lookupForAdd(nsJSObjWrapperKey(obj, npp));
|
||||
if (p) {
|
||||
MOZ_ASSERT(p->value());
|
||||
// Found a live nsJSObjWrapper, return it.
|
||||
@ -1162,7 +1158,7 @@ nsJSObjWrapper::GetNewOrUsed(NPP npp, JS::Handle<JSObject*> obj,
|
||||
|
||||
// Insert the new wrapper into the hashtable, rooting the JSObject. Its
|
||||
// lifetime is now tied to that of the NPObject.
|
||||
if (!sJSObjWrappers.putNew(nsJSObjWrapperKey(obj, npp), wrapper)) {
|
||||
if (!sJSObjWrappers->putNew(nsJSObjWrapperKey(obj, npp), wrapper)) {
|
||||
// Out of memory, free the wrapper we created.
|
||||
_releaseobject(wrapper);
|
||||
return nullptr;
|
||||
@ -2032,7 +2028,7 @@ nsJSNPRuntime::OnPluginDestroy(NPP npp)
|
||||
// Prevent modification of sJSObjWrappers table if we go reentrant.
|
||||
sJSObjWrappersAccessible = false;
|
||||
|
||||
for (auto iter = sJSObjWrappers.modIter(); !iter.done(); iter.next()) {
|
||||
for (auto iter = sJSObjWrappers->modIter(); !iter.done(); iter.next()) {
|
||||
nsJSObjWrapper* npobj = iter.get().value();
|
||||
MOZ_ASSERT(npobj->_class == &nsJSObjWrapper::sJSObjWrapperNPClass);
|
||||
if (npobj->mNpp == npp) {
|
||||
@ -2105,7 +2101,7 @@ nsJSNPRuntime::OnPluginDestroyPending(NPP npp)
|
||||
if (sJSObjWrappersAccessible) {
|
||||
// Prevent modification of sJSObjWrappers table if we go reentrant.
|
||||
sJSObjWrappersAccessible = false;
|
||||
for (auto iter = sJSObjWrappers.iter(); !iter.done(); iter.next()) {
|
||||
for (auto iter = sJSObjWrappers->iter(); !iter.done(); iter.next()) {
|
||||
nsJSObjWrapper* npobj = iter.get().value();
|
||||
MOZ_ASSERT(npobj->_class == &nsJSObjWrapper::sJSObjWrapperNPClass);
|
||||
if (npobj->mNpp == npp) {
|
||||
|
@ -42,11 +42,6 @@ JavaScriptChild::~JavaScriptChild()
|
||||
bool
|
||||
JavaScriptChild::init()
|
||||
{
|
||||
if (!WrapperOwner::init())
|
||||
return false;
|
||||
if (!WrapperAnswer::init())
|
||||
return false;
|
||||
|
||||
JSContext* cx = dom::danger::GetJSContext();
|
||||
JS_AddWeakPointerZonesCallback(cx, UpdateChildWeakPointersBeforeSweepingZoneGroup, this);
|
||||
JS_AddExtraGCRootsTracer(cx, TraceChild, this);
|
||||
|
@ -31,21 +31,17 @@ TraceParent(JSTracer* trc, void* data)
|
||||
static_cast<JavaScriptParent*>(data)->trace(trc);
|
||||
}
|
||||
|
||||
JavaScriptParent::JavaScriptParent()
|
||||
: savedNextCPOWNumber_(1)
|
||||
{
|
||||
JS_AddExtraGCRootsTracer(danger::GetJSContext(), TraceParent, this);
|
||||
}
|
||||
|
||||
JavaScriptParent::~JavaScriptParent()
|
||||
{
|
||||
JS_RemoveExtraGCRootsTracer(danger::GetJSContext(), TraceParent, this);
|
||||
}
|
||||
|
||||
bool
|
||||
JavaScriptParent::init()
|
||||
{
|
||||
if (!WrapperOwner::init())
|
||||
return false;
|
||||
|
||||
JS_AddExtraGCRootsTracer(danger::GetJSContext(), TraceParent, this);
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
ForbidUnsafeBrowserCPOWs()
|
||||
{
|
||||
@ -151,12 +147,7 @@ JavaScriptParent::afterProcessTask()
|
||||
PJavaScriptParent*
|
||||
mozilla::jsipc::NewJavaScriptParent()
|
||||
{
|
||||
JavaScriptParent* parent = new JavaScriptParent();
|
||||
if (!parent->init()) {
|
||||
delete parent;
|
||||
return nullptr;
|
||||
}
|
||||
return parent;
|
||||
return new JavaScriptParent();
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -17,10 +17,9 @@ namespace jsipc {
|
||||
class JavaScriptParent : public JavaScriptBase<PJavaScriptParent>
|
||||
{
|
||||
public:
|
||||
JavaScriptParent() : savedNextCPOWNumber_(1) {}
|
||||
JavaScriptParent();
|
||||
virtual ~JavaScriptParent();
|
||||
|
||||
bool init();
|
||||
void trace(JSTracer* trc);
|
||||
|
||||
void drop(JSObject* obj);
|
||||
|
@ -20,18 +20,10 @@ using namespace mozilla;
|
||||
using namespace mozilla::jsipc;
|
||||
|
||||
IdToObjectMap::IdToObjectMap()
|
||||
: table_(SystemAllocPolicy())
|
||||
: table_(SystemAllocPolicy(), 32)
|
||||
{
|
||||
}
|
||||
|
||||
bool
|
||||
IdToObjectMap::init()
|
||||
{
|
||||
if (table_.initialized())
|
||||
return true;
|
||||
return table_.init(32);
|
||||
}
|
||||
|
||||
void
|
||||
IdToObjectMap::trace(JSTracer* trc, uint64_t minimumId)
|
||||
{
|
||||
@ -105,10 +97,9 @@ IdToObjectMap::has(const ObjectId& id, const JSObject* obj) const
|
||||
}
|
||||
#endif
|
||||
|
||||
bool
|
||||
ObjectToIdMap::init()
|
||||
ObjectToIdMap::ObjectToIdMap()
|
||||
: table_(SystemAllocPolicy(), 32)
|
||||
{
|
||||
return table_.initialized() || table_.init(32);
|
||||
}
|
||||
|
||||
void
|
||||
@ -179,21 +170,6 @@ JavaScriptShared::~JavaScriptShared()
|
||||
MOZ_RELEASE_ASSERT(cpows_.empty());
|
||||
}
|
||||
|
||||
bool
|
||||
JavaScriptShared::init()
|
||||
{
|
||||
if (!objects_.init())
|
||||
return false;
|
||||
if (!cpows_.init())
|
||||
return false;
|
||||
if (!unwaivedObjectIds_.init())
|
||||
return false;
|
||||
if (!waivedObjectIds_.init())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
JavaScriptShared::decref()
|
||||
{
|
||||
|
@ -98,7 +98,6 @@ class IdToObjectMap
|
||||
public:
|
||||
IdToObjectMap();
|
||||
|
||||
bool init();
|
||||
void trace(JSTracer* trc, uint64_t minimumId = 0);
|
||||
void sweep();
|
||||
|
||||
@ -125,7 +124,8 @@ class ObjectToIdMap
|
||||
using Table = JS::GCHashMap<JS::Heap<JSObject*>, ObjectId, Hasher, js::SystemAllocPolicy>;
|
||||
|
||||
public:
|
||||
bool init();
|
||||
ObjectToIdMap();
|
||||
|
||||
void trace(JSTracer* trc);
|
||||
void sweep();
|
||||
|
||||
@ -146,8 +146,6 @@ class JavaScriptShared : public CPOWManager
|
||||
JavaScriptShared();
|
||||
virtual ~JavaScriptShared();
|
||||
|
||||
bool init();
|
||||
|
||||
void decref();
|
||||
void incref();
|
||||
|
||||
|
@ -906,15 +906,6 @@ WrapperOwner::updatePointer(JSObject* obj, const JSObject* old)
|
||||
cpows_.add(objId, obj);
|
||||
}
|
||||
|
||||
bool
|
||||
WrapperOwner::init()
|
||||
{
|
||||
if (!JavaScriptShared::init())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
WrapperOwner::getPropertyKeys(JSContext* cx, HandleObject proxy, uint32_t flags, AutoIdVector& props)
|
||||
{
|
||||
|
@ -24,7 +24,6 @@ class WrapperOwner : public virtual JavaScriptShared
|
||||
ActorDestroyReason;
|
||||
|
||||
WrapperOwner();
|
||||
bool init();
|
||||
|
||||
// Standard internal methods.
|
||||
// (The traps should be in the same order like js/Proxy.h)
|
||||
|
@ -60,11 +60,11 @@ class GCHashMap : public js::HashMap<Key, Value, HashPolicy, AllocPolicy>
|
||||
|
||||
public:
|
||||
explicit GCHashMap(AllocPolicy a = AllocPolicy()) : Base(a) {}
|
||||
explicit GCHashMap(size_t length) : Base(length) {}
|
||||
GCHashMap(AllocPolicy a, size_t length) : Base(a, length) {}
|
||||
|
||||
static void trace(GCHashMap* map, JSTracer* trc) { map->trace(trc); }
|
||||
void trace(JSTracer* trc) {
|
||||
if (!this->initialized())
|
||||
return;
|
||||
for (typename Base::Enum e(*this); !e.empty(); e.popFront()) {
|
||||
GCPolicy<Value>::trace(trc, &e.front().value(), "hashmap value");
|
||||
GCPolicy<Key>::trace(trc, &e.front().mutableKey(), "hashmap key");
|
||||
@ -72,13 +72,10 @@ class GCHashMap : public js::HashMap<Key, Value, HashPolicy, AllocPolicy>
|
||||
}
|
||||
|
||||
bool needsSweep() const {
|
||||
return this->initialized() && !this->empty();
|
||||
return !this->empty();
|
||||
}
|
||||
|
||||
void sweep() {
|
||||
if (!this->initialized())
|
||||
return;
|
||||
|
||||
for (typename Base::Enum e(*this); !e.empty(); e.popFront()) {
|
||||
if (MapSweepPolicy::needsSweep(&e.front().mutableKey(), &e.front().value()))
|
||||
e.removeFront();
|
||||
@ -117,12 +114,11 @@ class GCRekeyableHashMap : public JS::GCHashMap<Key, Value, HashPolicy, AllocPol
|
||||
using Base = JS::GCHashMap<Key, Value, HashPolicy, AllocPolicy>;
|
||||
|
||||
public:
|
||||
explicit GCRekeyableHashMap(AllocPolicy a = AllocPolicy()) : Base(a) {}
|
||||
explicit GCRekeyableHashMap(AllocPolicy a = AllocPolicy()) : Base(a) {}
|
||||
explicit GCRekeyableHashMap(size_t length) : Base(length) {}
|
||||
GCRekeyableHashMap(AllocPolicy a, size_t length) : Base(a, length) {}
|
||||
|
||||
void sweep() {
|
||||
if (!this->initialized())
|
||||
return;
|
||||
|
||||
for (typename Base::Enum e(*this); !e.empty(); e.popFront()) {
|
||||
Key key(e.front().key());
|
||||
if (MapSweepPolicy::needsSweep(&key, &e.front().value()))
|
||||
@ -153,9 +149,7 @@ class WrappedPtrOperations<JS::GCHashMap<Args...>, Wrapper>
|
||||
using Ptr = typename Map::Ptr;
|
||||
using Range = typename Map::Range;
|
||||
|
||||
bool initialized() const { return map().initialized(); }
|
||||
Ptr lookup(const Lookup& l) const { return map().lookup(l); }
|
||||
AddPtr lookupForAdd(const Lookup& l) const { return map().lookupForAdd(l); }
|
||||
Range all() const { return map().all(); }
|
||||
bool empty() const { return map().empty(); }
|
||||
uint32_t count() const { return map().count(); }
|
||||
@ -184,10 +178,10 @@ class MutableWrappedPtrOperations<JS::GCHashMap<Args...>, Wrapper>
|
||||
using Ptr = typename Map::Ptr;
|
||||
using Range = typename Map::Range;
|
||||
|
||||
bool init(uint32_t len = 16) { return map().init(len); }
|
||||
void clear() { map().clear(); }
|
||||
void finish() { map().finish(); }
|
||||
void clearAndCompact() { map().clearAndCompact(); }
|
||||
void remove(Ptr p) { map().remove(p); }
|
||||
AddPtr lookupForAdd(const Lookup& l) { return map().lookupForAdd(l); }
|
||||
|
||||
template<typename KeyInput, typename ValueInput>
|
||||
bool add(AddPtr& p, KeyInput&& k, ValueInput&& v) {
|
||||
@ -243,22 +237,20 @@ class GCHashSet : public js::HashSet<T, HashPolicy, AllocPolicy>
|
||||
|
||||
public:
|
||||
explicit GCHashSet(AllocPolicy a = AllocPolicy()) : Base(a) {}
|
||||
explicit GCHashSet(size_t length) : Base(length) {}
|
||||
GCHashSet(AllocPolicy a, size_t length) : Base(a, length) {}
|
||||
|
||||
static void trace(GCHashSet* set, JSTracer* trc) { set->trace(trc); }
|
||||
void trace(JSTracer* trc) {
|
||||
if (!this->initialized())
|
||||
return;
|
||||
for (typename Base::Enum e(*this); !e.empty(); e.popFront())
|
||||
GCPolicy<T>::trace(trc, &e.mutableFront(), "hashset element");
|
||||
}
|
||||
|
||||
bool needsSweep() const {
|
||||
return this->initialized() && !this->empty();
|
||||
return !this->empty();
|
||||
}
|
||||
|
||||
void sweep() {
|
||||
if (!this->initialized())
|
||||
return;
|
||||
for (typename Base::Enum e(*this); !e.empty(); e.popFront()) {
|
||||
if (GCPolicy<T>::needsSweep(&e.mutableFront()))
|
||||
e.removeFront();
|
||||
@ -296,9 +288,7 @@ class WrappedPtrOperations<JS::GCHashSet<Args...>, Wrapper>
|
||||
using Ptr = typename Set::Ptr;
|
||||
using Range = typename Set::Range;
|
||||
|
||||
bool initialized() const { return set().initialized(); }
|
||||
Ptr lookup(const Lookup& l) const { return set().lookup(l); }
|
||||
AddPtr lookupForAdd(const Lookup& l) const { return set().lookupForAdd(l); }
|
||||
Range all() const { return set().all(); }
|
||||
bool empty() const { return set().empty(); }
|
||||
uint32_t count() const { return set().count(); }
|
||||
@ -328,11 +318,12 @@ class MutableWrappedPtrOperations<JS::GCHashSet<Args...>, Wrapper>
|
||||
using Ptr = typename Set::Ptr;
|
||||
using Range = typename Set::Range;
|
||||
|
||||
bool init(uint32_t len = 16) { return set().init(len); }
|
||||
void clear() { set().clear(); }
|
||||
void finish() { set().finish(); }
|
||||
void clearAndCompact() { set().clearAndCompact(); }
|
||||
MOZ_MUST_USE bool reserve(uint32_t len) { return set().reserve(len); }
|
||||
void remove(Ptr p) { set().remove(p); }
|
||||
void remove(const Lookup& l) { set().remove(l); }
|
||||
AddPtr lookupForAdd(const Lookup& l) { return set().lookupForAdd(l); }
|
||||
|
||||
template<typename TInput>
|
||||
bool add(AddPtr& p, TInput&& t) {
|
||||
@ -395,9 +386,6 @@ class WeakCache<GCHashMap<Key, Value, HashPolicy, AllocPolicy, MapSweepPolicy>>
|
||||
}
|
||||
|
||||
size_t sweep() override {
|
||||
if (!this->initialized())
|
||||
return 0;
|
||||
|
||||
size_t steps = map.count();
|
||||
map.sweep();
|
||||
return steps;
|
||||
@ -467,10 +455,6 @@ class WeakCache<GCHashMap<Key, Value, HashPolicy, AllocPolicy, MapSweepPolicy>>
|
||||
}
|
||||
};
|
||||
|
||||
bool initialized() const {
|
||||
return map.initialized();
|
||||
}
|
||||
|
||||
Ptr lookup(const Lookup& l) const {
|
||||
Ptr ptr = map.lookup(l);
|
||||
if (needsBarrier && ptr && entryNeedsSweep(*ptr)) {
|
||||
@ -480,7 +464,7 @@ class WeakCache<GCHashMap<Key, Value, HashPolicy, AllocPolicy, MapSweepPolicy>>
|
||||
return ptr;
|
||||
}
|
||||
|
||||
AddPtr lookupForAdd(const Lookup& l) const {
|
||||
AddPtr lookupForAdd(const Lookup& l) {
|
||||
AddPtr ptr = map.lookupForAdd(l);
|
||||
if (needsBarrier && ptr && entryNeedsSweep(*ptr)) {
|
||||
const_cast<Map&>(map).remove(ptr);
|
||||
@ -524,11 +508,6 @@ class WeakCache<GCHashMap<Key, Value, HashPolicy, AllocPolicy, MapSweepPolicy>>
|
||||
return mallocSizeOf(this) + map.shallowSizeOfExcludingThis(mallocSizeOf);
|
||||
}
|
||||
|
||||
bool init(uint32_t len = 16) {
|
||||
MOZ_ASSERT(!needsBarrier);
|
||||
return map.init(len);
|
||||
}
|
||||
|
||||
void clear() {
|
||||
// This operation is not currently allowed while barriers are in place
|
||||
// since it doesn't make sense to clear a cache while it is being swept.
|
||||
@ -536,11 +515,11 @@ class WeakCache<GCHashMap<Key, Value, HashPolicy, AllocPolicy, MapSweepPolicy>>
|
||||
map.clear();
|
||||
}
|
||||
|
||||
void finish() {
|
||||
void clearAndCompact() {
|
||||
// This operation is not currently allowed while barriers are in place
|
||||
// since it doesn't make sense to destroy a cache while it is being swept.
|
||||
// since it doesn't make sense to clear a cache while it is being swept.
|
||||
MOZ_ASSERT(!needsBarrier);
|
||||
map.finish();
|
||||
map.clearAndCompact();
|
||||
}
|
||||
|
||||
void remove(Ptr p) {
|
||||
@ -602,9 +581,6 @@ class WeakCache<GCHashSet<T, HashPolicy, AllocPolicy>>
|
||||
{}
|
||||
|
||||
size_t sweep() override {
|
||||
if (!this->initialized())
|
||||
return 0;
|
||||
|
||||
size_t steps = set.count();
|
||||
set.sweep();
|
||||
return steps;
|
||||
@ -674,10 +650,6 @@ class WeakCache<GCHashSet<T, HashPolicy, AllocPolicy>>
|
||||
}
|
||||
};
|
||||
|
||||
bool initialized() const {
|
||||
return set.initialized();
|
||||
}
|
||||
|
||||
Ptr lookup(const Lookup& l) const {
|
||||
Ptr ptr = set.lookup(l);
|
||||
if (needsBarrier && ptr && entryNeedsSweep(*ptr)) {
|
||||
@ -687,7 +659,7 @@ class WeakCache<GCHashSet<T, HashPolicy, AllocPolicy>>
|
||||
return ptr;
|
||||
}
|
||||
|
||||
AddPtr lookupForAdd(const Lookup& l) const {
|
||||
AddPtr lookupForAdd(const Lookup& l) {
|
||||
AddPtr ptr = set.lookupForAdd(l);
|
||||
if (needsBarrier && ptr && entryNeedsSweep(*ptr)) {
|
||||
const_cast<Set&>(set).remove(ptr);
|
||||
@ -731,11 +703,6 @@ class WeakCache<GCHashSet<T, HashPolicy, AllocPolicy>>
|
||||
return mallocSizeOf(this) + set.shallowSizeOfExcludingThis(mallocSizeOf);
|
||||
}
|
||||
|
||||
bool init(uint32_t len = 16) {
|
||||
MOZ_ASSERT(!needsBarrier);
|
||||
return set.init(len);
|
||||
}
|
||||
|
||||
void clear() {
|
||||
// This operation is not currently allowed while barriers are in place
|
||||
// since it doesn't make sense to clear a cache while it is being swept.
|
||||
@ -743,11 +710,11 @@ class WeakCache<GCHashSet<T, HashPolicy, AllocPolicy>>
|
||||
set.clear();
|
||||
}
|
||||
|
||||
void finish() {
|
||||
void clearAndCompact() {
|
||||
// This operation is not currently allowed while barriers are in place
|
||||
// since it doesn't make sense to destroy a cache while it is being swept.
|
||||
// since it doesn't make sense to clear a cache while it is being swept.
|
||||
MOZ_ASSERT(!needsBarrier);
|
||||
set.finish();
|
||||
set.clearAndCompact();
|
||||
}
|
||||
|
||||
void remove(Ptr p) {
|
||||
|
@ -569,7 +569,7 @@ struct RuntimeSizes
|
||||
notableScriptSources()
|
||||
{
|
||||
allScriptSources = js_new<ScriptSourcesHashMap>();
|
||||
if (!allScriptSources || !allScriptSources->init())
|
||||
if (!allScriptSources)
|
||||
MOZ_CRASH("oom");
|
||||
}
|
||||
|
||||
|
@ -88,9 +88,6 @@ struct BreadthFirst {
|
||||
traversalBegun(false), stopRequested(false), abandonRequested(false)
|
||||
{ }
|
||||
|
||||
// Initialize this traversal object. Return false on OOM.
|
||||
bool init() { return visited.init(); }
|
||||
|
||||
// Add |node| as a starting point for the traversal. You may add
|
||||
// as many starting points as you like. Return false on OOM.
|
||||
bool addStart(Node node) { return pending.append(node); }
|
||||
|
@ -206,8 +206,6 @@ struct Census {
|
||||
JS::ZoneSet targetZones;
|
||||
|
||||
explicit Census(JSContext* cx) : cx(cx) { }
|
||||
|
||||
MOZ_MUST_USE JS_PUBLIC_API(bool) init();
|
||||
};
|
||||
|
||||
// A BreadthFirst handler type that conducts a census, using a CountBase to
|
||||
|
@ -338,7 +338,6 @@ class JS_PUBLIC_API(DominatorTree)
|
||||
if (!p) {
|
||||
mozilla::UniquePtr<NodeSet, DeletePolicy<NodeSet>> set(js_new<NodeSet>());
|
||||
if (!set ||
|
||||
!set->init() ||
|
||||
!predecessorSets.add(p, edge.referent, std::move(set)))
|
||||
{
|
||||
return false;
|
||||
@ -349,8 +348,7 @@ class JS_PUBLIC_API(DominatorTree)
|
||||
};
|
||||
|
||||
PostOrder traversal(cx, noGC);
|
||||
return traversal.init() &&
|
||||
traversal.addStart(root) &&
|
||||
return traversal.addStart(root) &&
|
||||
traversal.traverse(onNode, onEdge);
|
||||
}
|
||||
|
||||
@ -358,10 +356,10 @@ class JS_PUBLIC_API(DominatorTree)
|
||||
// `postOrder`.
|
||||
static MOZ_MUST_USE bool mapNodesToTheirIndices(JS::ubi::Vector<Node>& postOrder,
|
||||
NodeToIndexMap& map) {
|
||||
MOZ_ASSERT(!map.initialized());
|
||||
MOZ_ASSERT(map.empty());
|
||||
MOZ_ASSERT(postOrder.length() < UINT32_MAX);
|
||||
uint32_t length = postOrder.length();
|
||||
if (!map.init(length))
|
||||
if (!map.reserve(length))
|
||||
return false;
|
||||
for (uint32_t i = 0; i < length; i++)
|
||||
map.putNewInfallible(postOrder[i], i);
|
||||
@ -403,7 +401,7 @@ class JS_PUBLIC_API(DominatorTree)
|
||||
predecessorVectors[i].infallibleAppend(ptr->value());
|
||||
}
|
||||
}
|
||||
predecessorSets.finish();
|
||||
predecessorSets.clearAndCompact();
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -515,7 +513,7 @@ class JS_PUBLIC_API(DominatorTree)
|
||||
Create(JSContext* cx, AutoCheckCannotGC& noGC, const Node& root) {
|
||||
JS::ubi::Vector<Node> postOrder;
|
||||
PredecessorSets predecessorSets;
|
||||
if (!predecessorSets.init() || !doTraversal(cx, noGC, root, postOrder, predecessorSets))
|
||||
if (!doTraversal(cx, noGC, root, postOrder, predecessorSets))
|
||||
return mozilla::Nothing();
|
||||
|
||||
MOZ_ASSERT(postOrder.length() < UINT32_MAX);
|
||||
@ -528,7 +526,7 @@ class JS_PUBLIC_API(DominatorTree)
|
||||
// implementation, but we have to pay a little bit of upfront cost to
|
||||
// convert our data structures to play along first.
|
||||
|
||||
NodeToIndexMap nodeToPostOrderIndex;
|
||||
NodeToIndexMap nodeToPostOrderIndex(postOrder.length());
|
||||
if (!mapNodesToTheirIndices(postOrder, nodeToPostOrderIndex))
|
||||
return mozilla::Nothing();
|
||||
|
||||
|
@ -123,9 +123,6 @@ struct PostOrder {
|
||||
#endif
|
||||
{ }
|
||||
|
||||
// Initialize this traversal object. Return false on OOM.
|
||||
MOZ_MUST_USE bool init() { return seen.init(); }
|
||||
|
||||
// Add `node` as a starting point for the traversal. You may add
|
||||
// as many starting points as you like. Returns false on OOM.
|
||||
MOZ_MUST_USE bool addStart(const Node& node) {
|
||||
|
@ -188,18 +188,11 @@ struct JS_PUBLIC_API(ShortestPaths)
|
||||
: maxNumPaths_(maxNumPaths)
|
||||
, root_(root)
|
||||
, targets_(std::move(targets))
|
||||
, paths_()
|
||||
, paths_(targets_.count())
|
||||
, backEdges_()
|
||||
{
|
||||
MOZ_ASSERT(maxNumPaths_ > 0);
|
||||
MOZ_ASSERT(root_);
|
||||
MOZ_ASSERT(targets_.initialized());
|
||||
}
|
||||
|
||||
bool initialized() const {
|
||||
return targets_.initialized() &&
|
||||
paths_.initialized() &&
|
||||
backEdges_.initialized();
|
||||
}
|
||||
|
||||
public:
|
||||
@ -249,15 +242,12 @@ struct JS_PUBLIC_API(ShortestPaths)
|
||||
MOZ_ASSERT(targets.count() > 0);
|
||||
MOZ_ASSERT(maxNumPaths > 0);
|
||||
|
||||
size_t count = targets.count();
|
||||
ShortestPaths paths(maxNumPaths, root, std::move(targets));
|
||||
if (!paths.paths_.init(count))
|
||||
return mozilla::Nothing();
|
||||
|
||||
Handler handler(paths);
|
||||
Traversal traversal(cx, handler, noGC);
|
||||
traversal.wantNames = true;
|
||||
if (!traversal.init() || !traversal.addStart(root) || !traversal.traverse())
|
||||
if (!traversal.addStart(root) || !traversal.traverse())
|
||||
return mozilla::Nothing();
|
||||
|
||||
// Take ownership of the back edges we created while traversing the
|
||||
@ -265,7 +255,6 @@ struct JS_PUBLIC_API(ShortestPaths)
|
||||
// use-after-free.
|
||||
paths.backEdges_ = std::move(traversal.visited);
|
||||
|
||||
MOZ_ASSERT(paths.initialized());
|
||||
return mozilla::Some(std::move(paths));
|
||||
}
|
||||
|
||||
@ -275,7 +264,6 @@ struct JS_PUBLIC_API(ShortestPaths)
|
||||
* instance.
|
||||
*/
|
||||
NodeSet::Iterator targetIter() const {
|
||||
MOZ_ASSERT(initialized());
|
||||
return targets_.iter();
|
||||
}
|
||||
|
||||
@ -291,7 +279,6 @@ struct JS_PUBLIC_API(ShortestPaths)
|
||||
*/
|
||||
template <class Func>
|
||||
MOZ_MUST_USE bool forEachPath(const Node& target, Func func) {
|
||||
MOZ_ASSERT(initialized());
|
||||
MOZ_ASSERT(targets_.has(target));
|
||||
|
||||
auto ptr = paths_.lookup(target);
|
||||
|
@ -661,9 +661,7 @@ js::Stringify(JSContext* cx, MutableHandleValue vp, JSObject* replacer_, const V
|
||||
// is passed in. If we end up having to add elements past this
|
||||
// size, the set will naturally resize to accommodate them.
|
||||
const uint32_t MaxInitialSize = 32;
|
||||
Rooted<GCHashSet<jsid>> idSet(cx, GCHashSet<jsid>(cx));
|
||||
if (!idSet.init(Min(len, MaxInitialSize)))
|
||||
return false;
|
||||
Rooted<GCHashSet<jsid>> idSet(cx, GCHashSet<jsid>(cx, Min(len, MaxInitialSize)));
|
||||
|
||||
/* Step 4b(iii)(4). */
|
||||
uint32_t k = 0;
|
||||
|
@ -349,11 +349,6 @@ IndirectBindingMap::put(JSContext* cx, HandleId name,
|
||||
if (!map_) {
|
||||
MOZ_ASSERT(!cx->zone()->createdForHelperThread());
|
||||
map_.emplace(cx->zone());
|
||||
if (!map_->init()) {
|
||||
map_.reset();
|
||||
ReportOutOfMemory(cx);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
RootedShape shape(cx, environment->lookup(cx, localName));
|
||||
@ -1231,14 +1226,6 @@ ModuleBuilder::ModuleBuilder(JSContext* cx, HandleModuleObject module,
|
||||
starExportEntries_(cx, ExportEntryVector(cx))
|
||||
{}
|
||||
|
||||
bool
|
||||
ModuleBuilder::init()
|
||||
{
|
||||
return requestedModuleSpecifiers_.init() &&
|
||||
importEntries_.init() &&
|
||||
exportNames_.init();
|
||||
}
|
||||
|
||||
bool
|
||||
ModuleBuilder::buildTables()
|
||||
{
|
||||
|
@ -352,7 +352,6 @@ class MOZ_STACK_CLASS ModuleBuilder
|
||||
public:
|
||||
explicit ModuleBuilder(JSContext* cx, HandleModuleObject module,
|
||||
const frontend::TokenStreamAnyChars& tokenStream);
|
||||
bool init();
|
||||
|
||||
bool processImport(frontend::ParseNode* pn);
|
||||
bool processExport(frontend::ParseNode* pn);
|
||||
|
@ -4579,9 +4579,6 @@ OffThreadPromiseRuntimeState::OffThreadPromiseRuntimeState()
|
||||
numCanceled_(0),
|
||||
internalDispatchQueueClosed_(false)
|
||||
{
|
||||
AutoEnterOOMUnsafeRegion noOOM;
|
||||
if (!live_.init())
|
||||
noOOM.crash("OffThreadPromiseRuntimeState");
|
||||
}
|
||||
|
||||
OffThreadPromiseRuntimeState::~OffThreadPromiseRuntimeState()
|
||||
|
@ -3469,8 +3469,6 @@ reflect_parse(JSContext* cx, uint32_t argc, Value* vp)
|
||||
options.allowHTMLComments = target == ParseGoal::Script;
|
||||
mozilla::Range<const char16_t> chars = linearChars.twoByteRange();
|
||||
UsedNameTracker usedNames(cx);
|
||||
if (!usedNames.init())
|
||||
return false;
|
||||
|
||||
RootedScriptSourceObject sourceObject(cx, frontend::CreateScriptSourceObject(cx, options,
|
||||
mozilla::Nothing()));
|
||||
@ -3500,8 +3498,6 @@ reflect_parse(JSContext* cx, uint32_t argc, Value* vp)
|
||||
return false;
|
||||
|
||||
ModuleBuilder builder(cx, module, parser.anyChars);
|
||||
if (!builder.init())
|
||||
return false;
|
||||
|
||||
ModuleSharedContext modulesc(cx, module, &cx->global()->emptyGlobalScope(), builder);
|
||||
pn = parser.moduleBody(&modulesc);
|
||||
|
@ -1254,8 +1254,7 @@ ClearSavedFrames(JSContext* cx, unsigned argc, Value* vp)
|
||||
CallArgs args = CallArgsFromVp(argc, vp);
|
||||
|
||||
js::SavedStacks& savedStacks = cx->realm()->savedStacks();
|
||||
if (savedStacks.initialized())
|
||||
savedStacks.clear();
|
||||
savedStacks.clear();
|
||||
|
||||
for (ActivationIterator iter(cx); !iter.done(); ++iter)
|
||||
iter->clearLiveSavedFrameCache();
|
||||
@ -3593,7 +3592,7 @@ FindPath(JSContext* cx, unsigned argc, Value* vp)
|
||||
|
||||
heaptools::FindPathHandler handler(cx, start, target, &nodes, edges);
|
||||
heaptools::FindPathHandler::Traversal traversal(cx, handler, autoCannotGC);
|
||||
if (!traversal.init() || !traversal.addStart(start)) {
|
||||
if (!traversal.addStart(start)) {
|
||||
ReportOutOfMemory(cx);
|
||||
return false;
|
||||
}
|
||||
@ -3719,10 +3718,6 @@ ShortestPaths(JSContext* cx, unsigned argc, Value* vp)
|
||||
JS::AutoCheckCannotGC noGC(cx);
|
||||
|
||||
JS::ubi::NodeSet targets;
|
||||
if (!targets.init()) {
|
||||
ReportOutOfMemory(cx);
|
||||
return false;
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < length; i++) {
|
||||
RootedValue val(cx, objs->getDenseElement(i));
|
||||
|
@ -2163,11 +2163,6 @@ InlineTransparentTypedObject::getOrCreateBuffer(JSContext* cx)
|
||||
if (!table)
|
||||
return nullptr;
|
||||
|
||||
if (!table->init()) {
|
||||
ReportOutOfMemory(cx);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
realm.lazyArrayBuffers = std::move(table);
|
||||
}
|
||||
|
||||
|
@ -41,10 +41,6 @@ WeakCollectionPutEntryInternal(JSContext* cx, Handle<WeakCollectionObject*> obj,
|
||||
auto newMap = cx->make_unique<ObjectValueMap>(cx, obj.get());
|
||||
if (!newMap)
|
||||
return false;
|
||||
if (!newMap->init()) {
|
||||
JS_ReportOutOfMemory(cx);
|
||||
return false;
|
||||
}
|
||||
map = newMap.release();
|
||||
obj->setPrivate(map);
|
||||
}
|
||||
|
@ -111,12 +111,7 @@ js::intl::SharedIntlData::ensureTimeZones(JSContext* cx)
|
||||
|
||||
// If ensureTimeZones() was called previously, but didn't complete due to
|
||||
// OOM, clear all sets/maps and start from scratch.
|
||||
if (availableTimeZones.initialized())
|
||||
availableTimeZones.finish();
|
||||
if (!availableTimeZones.init()) {
|
||||
ReportOutOfMemory(cx);
|
||||
return false;
|
||||
}
|
||||
availableTimeZones.clearAndCompact();
|
||||
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
UEnumeration* values = ucal_openTimeZones(&status);
|
||||
@ -158,12 +153,7 @@ js::intl::SharedIntlData::ensureTimeZones(JSContext* cx)
|
||||
}
|
||||
}
|
||||
|
||||
if (ianaZonesTreatedAsLinksByICU.initialized())
|
||||
ianaZonesTreatedAsLinksByICU.finish();
|
||||
if (!ianaZonesTreatedAsLinksByICU.init()) {
|
||||
ReportOutOfMemory(cx);
|
||||
return false;
|
||||
}
|
||||
ianaZonesTreatedAsLinksByICU.clearAndCompact();
|
||||
|
||||
for (const char* rawTimeZone : timezone::ianaZonesTreatedAsLinksByICU) {
|
||||
MOZ_ASSERT(rawTimeZone != nullptr);
|
||||
@ -181,12 +171,7 @@ js::intl::SharedIntlData::ensureTimeZones(JSContext* cx)
|
||||
}
|
||||
}
|
||||
|
||||
if (ianaLinksCanonicalizedDifferentlyByICU.initialized())
|
||||
ianaLinksCanonicalizedDifferentlyByICU.finish();
|
||||
if (!ianaLinksCanonicalizedDifferentlyByICU.init()) {
|
||||
ReportOutOfMemory(cx);
|
||||
return false;
|
||||
}
|
||||
ianaLinksCanonicalizedDifferentlyByICU.clearAndCompact();
|
||||
|
||||
RootedAtom linkName(cx);
|
||||
RootedAtom& target = timeZone;
|
||||
@ -308,12 +293,7 @@ js::intl::SharedIntlData::ensureUpperCaseFirstLocales(JSContext* cx)
|
||||
|
||||
// If ensureUpperCaseFirstLocales() was called previously, but didn't
|
||||
// complete due to OOM, clear all data and start from scratch.
|
||||
if (upperCaseFirstLocales.initialized())
|
||||
upperCaseFirstLocales.finish();
|
||||
if (!upperCaseFirstLocales.init()) {
|
||||
ReportOutOfMemory(cx);
|
||||
return false;
|
||||
}
|
||||
upperCaseFirstLocales.clearAndCompact();
|
||||
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
UEnumeration* available = ucol_openAvailableLocales(&status);
|
||||
@ -393,10 +373,10 @@ js::intl::SharedIntlData::isUpperCaseFirst(JSContext* cx, HandleString locale, b
|
||||
void
|
||||
js::intl::SharedIntlData::destroyInstance()
|
||||
{
|
||||
availableTimeZones.finish();
|
||||
ianaZonesTreatedAsLinksByICU.finish();
|
||||
ianaLinksCanonicalizedDifferentlyByICU.finish();
|
||||
upperCaseFirstLocales.finish();
|
||||
availableTimeZones.clearAndCompact();
|
||||
ianaZonesTreatedAsLinksByICU.clearAndCompact();
|
||||
ianaLinksCanonicalizedDifferentlyByICU.clearAndCompact();
|
||||
upperCaseFirstLocales.clearAndCompact();
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -6104,11 +6104,7 @@ StructType::DefineInternal(JSContext* cx, JSObject* typeObj_, JSObject* fieldsOb
|
||||
return false;
|
||||
|
||||
// Create a FieldInfoHash to stash on the type object.
|
||||
Rooted<FieldInfoHash> fields(cx);
|
||||
if (!fields.init(len)) {
|
||||
JS_ReportOutOfMemory(cx);
|
||||
return false;
|
||||
}
|
||||
Rooted<FieldInfoHash> fields(cx, len);
|
||||
|
||||
// Process the field types.
|
||||
size_t structSize, structAlign;
|
||||
@ -6215,7 +6211,6 @@ StructType::DefineInternal(JSContext* cx, JSObject* typeObj_, JSObject* fieldsOb
|
||||
JS_ReportOutOfMemory(cx);
|
||||
return false;
|
||||
}
|
||||
MOZ_ASSERT(heapHash->initialized());
|
||||
JS_SetReservedSlot(typeObj, SLOT_FIELDINFO, PrivateValue(heapHash));
|
||||
|
||||
JS_SetReservedSlot(typeObj, SLOT_SIZE, sizeVal);
|
||||
|
@ -12,10 +12,8 @@ using namespace js;
|
||||
|
||||
SparseBitmap::~SparseBitmap()
|
||||
{
|
||||
if (data.initialized()) {
|
||||
for (Data::Range r(data.all()); !r.empty(); r.popFront())
|
||||
js_delete(r.front().value());
|
||||
}
|
||||
for (Data::Range r(data.all()); !r.empty(); r.popFront())
|
||||
js_delete(r.front().value());
|
||||
}
|
||||
|
||||
size_t
|
||||
@ -28,10 +26,9 @@ SparseBitmap::sizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf)
|
||||
}
|
||||
|
||||
SparseBitmap::BitBlock&
|
||||
SparseBitmap::createBlock(Data::AddPtr p, size_t blockId)
|
||||
SparseBitmap::createBlock(Data::AddPtr p, size_t blockId, AutoEnterOOMUnsafeRegion& oomUnsafe)
|
||||
{
|
||||
MOZ_ASSERT(!p);
|
||||
AutoEnterOOMUnsafeRegion oomUnsafe;
|
||||
MOZ_ASSERT(!p && p.isValid());
|
||||
BitBlock* block = js_new<BitBlock>();
|
||||
if (!block || !data.add(p, blockId, block))
|
||||
oomUnsafe.crash("Bitmap OOM");
|
||||
|
@ -88,7 +88,7 @@ class SparseBitmap
|
||||
return std::min<size_t>((size_t)WordsInBlock, std::max<long>(count, 0));
|
||||
}
|
||||
|
||||
BitBlock& createBlock(Data::AddPtr p, size_t blockId);
|
||||
BitBlock& createBlock(Data::AddPtr p, size_t blockId, AutoEnterOOMUnsafeRegion& oomUnsafe);
|
||||
|
||||
MOZ_ALWAYS_INLINE BitBlock* getBlock(size_t blockId) const {
|
||||
Data::Ptr p = data.lookup(blockId);
|
||||
@ -96,14 +96,16 @@ class SparseBitmap
|
||||
}
|
||||
|
||||
MOZ_ALWAYS_INLINE BitBlock& getOrCreateBlock(size_t blockId) {
|
||||
// The lookupForAdd() needs protection against injected OOMs, as does
|
||||
// the add() within createBlock().
|
||||
AutoEnterOOMUnsafeRegion oomUnsafe;
|
||||
Data::AddPtr p = data.lookupForAdd(blockId);
|
||||
if (p)
|
||||
return *p->value();
|
||||
return createBlock(p, blockId);
|
||||
return createBlock(p, blockId, oomUnsafe);
|
||||
}
|
||||
|
||||
public:
|
||||
bool init() { return data.init(); }
|
||||
~SparseBitmap();
|
||||
|
||||
size_t sizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf);
|
||||
|
@ -71,13 +71,7 @@ class InlineTable : private AllocPolicy
|
||||
MOZ_MUST_USE bool switchToTable() {
|
||||
MOZ_ASSERT(inlNext_ == InlineEntries);
|
||||
|
||||
if (table_.initialized()) {
|
||||
table_.clear();
|
||||
} else {
|
||||
if (!table_.init(count()))
|
||||
return false;
|
||||
MOZ_ASSERT(table_.initialized());
|
||||
}
|
||||
table_.clear();
|
||||
|
||||
InlineEntry* end = inlineEnd();
|
||||
for (InlineEntry* it = inlineStart(); it != end; ++it) {
|
||||
@ -330,7 +324,7 @@ class InlineTable : private AllocPolicy
|
||||
--inlCount_;
|
||||
return;
|
||||
}
|
||||
MOZ_ASSERT(table_.initialized() && usingTable());
|
||||
MOZ_ASSERT(usingTable());
|
||||
table_.remove(p.tablePtr_);
|
||||
}
|
||||
|
||||
|
@ -64,6 +64,8 @@ struct BinaryASTSupport {
|
||||
}
|
||||
};
|
||||
|
||||
BinaryASTSupport();
|
||||
|
||||
JS::Result<const BinVariant*> binVariant(JSContext*, const CharSlice);
|
||||
JS::Result<const BinField*> binField(JSContext*, const CharSlice);
|
||||
JS::Result<const BinKind*> binKind(JSContext*, const CharSlice);
|
||||
|
@ -73,15 +73,17 @@ const char* describeBinVariant(const BinVariant& variant)
|
||||
|
||||
} // namespace frontend
|
||||
|
||||
BinaryASTSupport::BinaryASTSupport()
|
||||
: binKindMap_(frontend::BINKIND_LIMIT)
|
||||
, binFieldMap_(frontend::BINFIELD_LIMIT)
|
||||
, binVariantMap_(frontend::BINVARIANT_LIMIT)
|
||||
{
|
||||
}
|
||||
|
||||
JS::Result<const js::frontend::BinKind*>
|
||||
BinaryASTSupport::binKind(JSContext* cx, const CharSlice key)
|
||||
{
|
||||
if (!binKindMap_.initialized()) {
|
||||
// Initialize lazily.
|
||||
if (!binKindMap_.init(frontend::BINKIND_LIMIT))
|
||||
return ReportOutOfMemoryResult(cx);
|
||||
|
||||
if (binKindMap_.empty()) {
|
||||
for (size_t i = 0; i < frontend::BINKIND_LIMIT; ++i) {
|
||||
const BinKind variant = static_cast<BinKind>(i);
|
||||
const CharSlice& key = getBinKind(variant);
|
||||
@ -100,12 +102,9 @@ BinaryASTSupport::binKind(JSContext* cx, const CharSlice key)
|
||||
}
|
||||
|
||||
JS::Result<const js::frontend::BinVariant*>
|
||||
BinaryASTSupport::binVariant(JSContext* cx, const CharSlice key) {
|
||||
if (!binVariantMap_.initialized()) {
|
||||
// Initialize lazily.
|
||||
if (!binVariantMap_.init(frontend::BINVARIANT_LIMIT))
|
||||
return ReportOutOfMemoryResult(cx);
|
||||
|
||||
BinaryASTSupport::binVariant(JSContext* cx, const CharSlice key)
|
||||
{
|
||||
if (binVariantMap_.empty()) {
|
||||
for (size_t i = 0; i < frontend::BINVARIANT_LIMIT; ++i) {
|
||||
const BinVariant variant = static_cast<BinVariant>(i);
|
||||
const CharSlice& key = getBinVariant(variant);
|
||||
|
@ -125,8 +125,6 @@ BinTokenReaderMultipart::readHeader()
|
||||
return raiseOOM();
|
||||
if (!slicesTable_.reserve(stringsNumberOfEntries))
|
||||
return raiseOOM();
|
||||
if (!variantsTable_.init())
|
||||
return raiseOOM();
|
||||
|
||||
RootedAtom atom(cx_);
|
||||
for (uint32_t i = 0; i < stringsNumberOfEntries; ++i) {
|
||||
|
@ -223,8 +223,6 @@ bool
|
||||
BytecodeCompiler::createParser(ParseGoal goal)
|
||||
{
|
||||
usedNames.emplace(cx);
|
||||
if (!usedNames->init())
|
||||
return false;
|
||||
|
||||
if (canLazilyParse()) {
|
||||
syntaxParser.emplace(cx, alloc, options, sourceBuffer.get(), sourceBuffer.length(),
|
||||
@ -410,8 +408,6 @@ BytecodeCompiler::compileModule()
|
||||
module->init(script);
|
||||
|
||||
ModuleBuilder builder(cx, module, parser->anyChars);
|
||||
if (!builder.init())
|
||||
return nullptr;
|
||||
|
||||
ModuleSharedContext modulesc(cx, module, enclosingScope, builder);
|
||||
ParseNode* pn = parser->moduleBody(&modulesc);
|
||||
@ -629,8 +625,6 @@ frontend::CompileGlobalBinASTScript(JSContext* cx, LifoAlloc& alloc, const ReadO
|
||||
AutoAssertReportedException assertException(cx);
|
||||
|
||||
frontend::UsedNameTracker usedNames(cx);
|
||||
if (!usedNames.init())
|
||||
return nullptr;
|
||||
|
||||
RootedScriptSourceObject sourceObj(cx, CreateScriptSourceObject(cx, options));
|
||||
|
||||
@ -819,8 +813,6 @@ frontend::CompileLazyFunction(JSContext* cx, Handle<LazyScript*> lazy, const cha
|
||||
}
|
||||
|
||||
UsedNameTracker usedNames(cx);
|
||||
if (!usedNames.init())
|
||||
return false;
|
||||
|
||||
RootedScriptSourceObject sourceObject(cx, &lazy->sourceObject());
|
||||
Parser<FullParseHandler, char16_t> parser(cx, cx->tempLifoAlloc(), options, chars, length,
|
||||
|
@ -121,10 +121,6 @@ class UsedNameTracker
|
||||
scopeCounter_(0)
|
||||
{ }
|
||||
|
||||
MOZ_MUST_USE bool init() {
|
||||
return map_.init();
|
||||
}
|
||||
|
||||
uint32_t nextScriptId() {
|
||||
MOZ_ASSERT(scriptCounter_ != UINT32_MAX,
|
||||
"ParseContext::Scope::init should have prevented wraparound");
|
||||
|
@ -51,10 +51,6 @@ testBinASTReaderFuzz(const uint8_t* buf, size_t size) {
|
||||
}
|
||||
|
||||
js::frontend::UsedNameTracker binUsedNames(gCx);
|
||||
if (!binUsedNames.init()) {
|
||||
ReportOutOfMemory(gCx);
|
||||
return 0;
|
||||
}
|
||||
|
||||
js::frontend::BinASTParser<js::frontend::BinTokenReaderTester> reader(gCx, gCx->tempLifoAlloc(), binUsedNames, options);
|
||||
|
||||
|
@ -963,6 +963,7 @@ GCRuntime::GCRuntime(JSRuntime* rt) :
|
||||
stats_(rt),
|
||||
marker(rt),
|
||||
usage(nullptr),
|
||||
rootsHash(256),
|
||||
nextCellUniqueId_(LargestTaggedNullCellPointer + 1), // Ensure disjoint from null tagged pointers.
|
||||
numArenasFreeCommitted(0),
|
||||
verifyPreData(nullptr),
|
||||
@ -1287,9 +1288,6 @@ GCRuntime::init(uint32_t maxbytes, uint32_t maxNurseryBytes)
|
||||
{
|
||||
MOZ_ASSERT(SystemPageSize());
|
||||
|
||||
if (!rootsHash.ref().init(256))
|
||||
return false;
|
||||
|
||||
{
|
||||
AutoLockGCBgAlloc lock(rt);
|
||||
|
||||
@ -4699,9 +4697,6 @@ js::gc::MarkingValidator::nonIncrementalMark(AutoGCSession& session)
|
||||
* Currently this does not validate gray marking.
|
||||
*/
|
||||
|
||||
if (!map.init())
|
||||
return;
|
||||
|
||||
JSRuntime* runtime = gc->rt;
|
||||
GCMarker* gcmarker = &gc->marker;
|
||||
|
||||
@ -4732,8 +4727,6 @@ js::gc::MarkingValidator::nonIncrementalMark(AutoGCSession& session)
|
||||
*/
|
||||
|
||||
WeakMapSet markedWeakMaps;
|
||||
if (!markedWeakMaps.init())
|
||||
return;
|
||||
|
||||
/*
|
||||
* For saving, smush all of the keys into one big table and split them back
|
||||
@ -8077,7 +8070,7 @@ js::NewRealm(JSContext* cx, JSPrincipals* principals, const JS::RealmOptions& op
|
||||
|
||||
if (!comp) {
|
||||
compHolder = cx->make_unique<JS::Compartment>(zone);
|
||||
if (!compHolder || !compHolder->init(cx))
|
||||
if (!compHolder)
|
||||
return nullptr;
|
||||
|
||||
comp = compHolder.get();
|
||||
@ -8254,9 +8247,6 @@ GCRuntime::mergeRealms(Realm* source, Realm* target)
|
||||
|
||||
if (!target->scriptNameMap)
|
||||
oomUnsafe.crash("Failed to create a script name map.");
|
||||
|
||||
if (!target->scriptNameMap->init())
|
||||
oomUnsafe.crash("Failed to initialize a script name map.");
|
||||
}
|
||||
|
||||
for (ScriptNameMap::Range r = source->scriptNameMap->all(); !r.empty(); r.popFront()) {
|
||||
|
@ -24,7 +24,7 @@ struct DependentAddPtr
|
||||
typedef typename T::Entry Entry;
|
||||
|
||||
template <class Lookup>
|
||||
DependentAddPtr(const JSContext* cx, const T& table, const Lookup& lookup)
|
||||
DependentAddPtr(const JSContext* cx, T& table, const Lookup& lookup)
|
||||
: addPtr(table.lookupForAdd(lookup))
|
||||
, originalGcNumber(cx->zone()->gcNumber())
|
||||
{}
|
||||
@ -56,7 +56,7 @@ struct DependentAddPtr
|
||||
const Entry* operator->() const { return &*addPtr; }
|
||||
|
||||
private:
|
||||
AddPtr addPtr ;
|
||||
AddPtr addPtr;
|
||||
const uint64_t originalGcNumber;
|
||||
|
||||
template <class KeyInput>
|
||||
|
@ -2711,7 +2711,6 @@ js::gc::StoreBuffer::MonoTypeBuffer<T>::trace(StoreBuffer* owner, TenuringTracer
|
||||
{
|
||||
mozilla::ReentrancyGuard g(*owner);
|
||||
MOZ_ASSERT(owner->isEnabled());
|
||||
MOZ_ASSERT(stores_.initialized());
|
||||
if (last_)
|
||||
last_.trace(mover);
|
||||
for (typename StoreSet::Range r = stores_.all(); !r.empty(); r.popFront())
|
||||
|
@ -49,7 +49,6 @@ struct js::Nursery::FreeMallocedBuffersTask : public GCParallelTaskHelper<FreeMa
|
||||
explicit FreeMallocedBuffersTask(FreeOp* fop)
|
||||
: GCParallelTaskHelper(fop->runtime()),
|
||||
fop_(fop) {}
|
||||
bool init() { return buffers_.init(); }
|
||||
void transferBuffersToFree(MallocedBuffersSet& buffersToFree,
|
||||
const AutoLockHelperThreadState& lock);
|
||||
~FreeMallocedBuffersTask() { join(); }
|
||||
@ -149,11 +148,8 @@ js::Nursery::Nursery(JSRuntime* rt)
|
||||
bool
|
||||
js::Nursery::init(uint32_t maxNurseryBytes, AutoLockGCBgAlloc& lock)
|
||||
{
|
||||
if (!mallocedBuffers.init())
|
||||
return false;
|
||||
|
||||
freeMallocedBuffersTask = js_new<FreeMallocedBuffersTask>(runtime()->defaultFreeOp());
|
||||
if (!freeMallocedBuffersTask || !freeMallocedBuffersTask->init())
|
||||
if (!freeMallocedBuffersTask)
|
||||
return false;
|
||||
|
||||
// The nursery is permanently disabled when recording or replaying. Nursery
|
||||
@ -500,8 +496,6 @@ Nursery::setIndirectForwardingPointer(void* oldData, void* newData)
|
||||
MOZ_ASSERT(!isInside(newData) || (uintptr_t(newData) & ChunkMask) == 0);
|
||||
|
||||
AutoEnterOOMUnsafeRegion oomUnsafe;
|
||||
if (!forwardedBuffers.initialized() && !forwardedBuffers.init())
|
||||
oomUnsafe.crash("Nursery::setForwardingPointer");
|
||||
#ifdef DEBUG
|
||||
if (ForwardedBufferMap::Ptr p = forwardedBuffers.lookup(oldData))
|
||||
MOZ_ASSERT(p->value() == newData);
|
||||
@ -530,11 +524,9 @@ js::Nursery::forwardBufferPointer(HeapSlot** pSlotsElems)
|
||||
// The new location for this buffer is either stored inline with it or in
|
||||
// the forwardedBuffers table.
|
||||
do {
|
||||
if (forwardedBuffers.initialized()) {
|
||||
if (ForwardedBufferMap::Ptr p = forwardedBuffers.lookup(old)) {
|
||||
*pSlotsElems = reinterpret_cast<HeapSlot*>(p->value());
|
||||
break;
|
||||
}
|
||||
if (ForwardedBufferMap::Ptr p = forwardedBuffers.lookup(old)) {
|
||||
*pSlotsElems = reinterpret_cast<HeapSlot*>(p->value());
|
||||
break;
|
||||
}
|
||||
|
||||
*pSlotsElems = *reinterpret_cast<HeapSlot**>(old);
|
||||
@ -929,7 +921,7 @@ js::Nursery::doCollection(JS::gcreason::Reason reason, TenureCountCache& tenureC
|
||||
// Update any slot or element pointers whose destination has been tenured.
|
||||
startProfile(ProfileKey::UpdateJitActivations);
|
||||
js::jit::UpdateJitActivationsForMinorGC(rt);
|
||||
forwardedBuffers.finish();
|
||||
forwardedBuffers.clearAndCompact();
|
||||
endProfile(ProfileKey::UpdateJitActivations);
|
||||
|
||||
startProfile(ProfileKey::ObjectsTenuredCallback);
|
||||
|
@ -288,8 +288,6 @@ class Nursery
|
||||
return allocatedChunkCount() * gc::ChunkSize;
|
||||
}
|
||||
size_t sizeOfMallocedBuffers(mozilla::MallocSizeOf mallocSizeOf) const {
|
||||
if (!mallocedBuffers.initialized())
|
||||
return 0;
|
||||
size_t total = 0;
|
||||
for (MallocedBuffersSet::Range r = mallocedBuffers.all(); !r.empty(); r.popFront())
|
||||
total += mallocSizeOf(r.front());
|
||||
|
@ -90,8 +90,8 @@ class NurseryAwareHashMap
|
||||
using Entry = typename MapType::Entry;
|
||||
|
||||
explicit NurseryAwareHashMap(AllocPolicy a = AllocPolicy()) : map(a) {}
|
||||
|
||||
MOZ_MUST_USE bool init(uint32_t len = 16) { return map.init(len); }
|
||||
explicit NurseryAwareHashMap(size_t length) : map(length) {}
|
||||
NurseryAwareHashMap(AllocPolicy a, size_t length) : map(a, length) {}
|
||||
|
||||
bool empty() const { return map.empty(); }
|
||||
Ptr lookup(const Lookup& l) const { return map.lookup(l); }
|
||||
|
@ -432,8 +432,7 @@ js::gc::GCRuntime::finishRoots()
|
||||
|
||||
rt->finishAtoms();
|
||||
|
||||
if (rootsHash.ref().initialized())
|
||||
rootsHash.ref().clear();
|
||||
rootsHash.ref().clear();
|
||||
|
||||
rt->finishPersistentRoots();
|
||||
|
||||
|
@ -50,10 +50,7 @@ StoreBuffer::enable()
|
||||
|
||||
checkEmpty();
|
||||
|
||||
if (!bufferVal.init() ||
|
||||
!bufferCell.init() ||
|
||||
!bufferSlot.init() ||
|
||||
!bufferWholeCell.init() ||
|
||||
if (!bufferWholeCell.init() ||
|
||||
!bufferGeneric.init())
|
||||
{
|
||||
return false;
|
||||
|
@ -83,24 +83,14 @@ class StoreBuffer
|
||||
const static size_t MaxEntries = 48 * 1024 / sizeof(T);
|
||||
|
||||
explicit MonoTypeBuffer() : last_(T()) {}
|
||||
~MonoTypeBuffer() { stores_.finish(); }
|
||||
|
||||
MOZ_MUST_USE bool init() {
|
||||
if (!stores_.initialized() && !stores_.init())
|
||||
return false;
|
||||
clear();
|
||||
return true;
|
||||
}
|
||||
|
||||
void clear() {
|
||||
last_ = T();
|
||||
if (stores_.initialized())
|
||||
stores_.clear();
|
||||
stores_.clear();
|
||||
}
|
||||
|
||||
/* Add one item to the buffer. */
|
||||
void put(StoreBuffer* owner, const T& t) {
|
||||
MOZ_ASSERT(stores_.initialized());
|
||||
sinkStore(owner);
|
||||
last_ = t;
|
||||
}
|
||||
@ -117,7 +107,6 @@ class StoreBuffer
|
||||
|
||||
/* Move any buffered stores to the canonical store set. */
|
||||
void sinkStore(StoreBuffer* owner) {
|
||||
MOZ_ASSERT(stores_.initialized());
|
||||
if (last_) {
|
||||
AutoEnterOOMUnsafeRegion oomUnsafe;
|
||||
if (!stores_.put(last_))
|
||||
@ -142,7 +131,7 @@ class StoreBuffer
|
||||
}
|
||||
|
||||
bool isEmpty() const {
|
||||
return last_ == T() && (!stores_.initialized() || stores_.empty());
|
||||
return last_ == T() && stores_.empty();
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -212,9 +212,6 @@ gc::GCRuntime::startVerifyPreBarriers()
|
||||
trc->edgeptr = (char*)trc->root;
|
||||
trc->term = trc->edgeptr + size;
|
||||
|
||||
if (!trc->nodemap.init())
|
||||
goto oom;
|
||||
|
||||
/* Create the root node. */
|
||||
trc->curnode = MakeNode(trc, nullptr, JS::TraceKind(0));
|
||||
|
||||
@ -458,7 +455,6 @@ class HeapCheckTracerBase : public JS::CallbackTracer
|
||||
{
|
||||
public:
|
||||
explicit HeapCheckTracerBase(JSRuntime* rt, WeakMapTraceKind weakTraceKind);
|
||||
bool init();
|
||||
bool traceHeap(AutoTraceSession& session);
|
||||
virtual void checkCell(Cell* cell) = 0;
|
||||
|
||||
@ -505,12 +501,6 @@ HeapCheckTracerBase::HeapCheckTracerBase(JSRuntime* rt, WeakMapTraceKind weakTra
|
||||
#endif
|
||||
}
|
||||
|
||||
bool
|
||||
HeapCheckTracerBase::init()
|
||||
{
|
||||
return visited.init();
|
||||
}
|
||||
|
||||
void
|
||||
HeapCheckTracerBase::onChild(const JS::GCCellPtr& thing)
|
||||
{
|
||||
@ -674,8 +664,7 @@ js::gc::CheckHeapAfterGC(JSRuntime* rt)
|
||||
gcType = CheckHeapTracer::GCType::NonMoving;
|
||||
|
||||
CheckHeapTracer tracer(rt, gcType);
|
||||
if (tracer.init())
|
||||
tracer.check(session);
|
||||
tracer.check(session);
|
||||
}
|
||||
|
||||
#endif /* JSGC_HASH_TABLE_CHECKS */
|
||||
@ -743,8 +732,6 @@ js::CheckGrayMarkingState(JSRuntime* rt)
|
||||
gcstats::AutoPhase ap(rt->gc.stats(), gcstats::PhaseKind::TRACE_HEAP);
|
||||
AutoTraceSession session(rt);
|
||||
CheckGrayMarkingTracer tracer(rt);
|
||||
if (!tracer.init())
|
||||
return true; // Ignore failure
|
||||
|
||||
return tracer.check(session);
|
||||
}
|
||||
|
@ -28,17 +28,9 @@ static T* extractUnbarriered(T* v)
|
||||
template <class K, class V, class HP>
|
||||
WeakMap<K, V, HP>::WeakMap(JSContext* cx, JSObject* memOf)
|
||||
: Base(cx->zone()), WeakMapBase(memOf, cx->zone())
|
||||
{}
|
||||
|
||||
template <class K, class V, class HP>
|
||||
bool
|
||||
WeakMap<K, V, HP>::init(uint32_t len)
|
||||
{
|
||||
if (!Base::init(len))
|
||||
return false;
|
||||
zone()->gcWeakMapList().insertFront(this);
|
||||
marked = JS::IsIncrementalGCInProgress(TlsContext.get());
|
||||
return true;
|
||||
}
|
||||
|
||||
// Trace a WeakMap entry based on 'markedCell' getting marked, where 'origKey'
|
||||
@ -80,9 +72,6 @@ WeakMap<K, V, HP>::trace(JSTracer* trc)
|
||||
|
||||
TraceNullableEdge(trc, &memberOf, "WeakMap owner");
|
||||
|
||||
if (!Base::initialized())
|
||||
return;
|
||||
|
||||
if (trc->isMarkingTracer()) {
|
||||
MOZ_ASSERT(trc->weakMapAction() == ExpandWeakMaps);
|
||||
marked = true;
|
||||
|
@ -81,8 +81,7 @@ WeakMapBase::sweepZone(JS::Zone* zone)
|
||||
if (m->marked) {
|
||||
m->sweep();
|
||||
} else {
|
||||
/* Destroy the hash map now to catch any use after this point. */
|
||||
m->finish();
|
||||
m->clearAndCompact();
|
||||
m->removeFrom(zone->gcWeakMapList());
|
||||
}
|
||||
m = next;
|
||||
@ -157,16 +156,9 @@ ObjectWeakMap::ObjectWeakMap(JSContext* cx)
|
||||
: map(cx, nullptr)
|
||||
{}
|
||||
|
||||
bool
|
||||
ObjectWeakMap::init()
|
||||
{
|
||||
return map.init();
|
||||
}
|
||||
|
||||
JSObject*
|
||||
ObjectWeakMap::lookup(const JSObject* obj)
|
||||
{
|
||||
MOZ_ASSERT(map.initialized());
|
||||
if (ObjectValueMap::Ptr p = map.lookup(const_cast<JSObject*>(obj)))
|
||||
return &p->value().toObject();
|
||||
return nullptr;
|
||||
@ -176,7 +168,6 @@ bool
|
||||
ObjectWeakMap::add(JSContext* cx, JSObject* obj, JSObject* target)
|
||||
{
|
||||
MOZ_ASSERT(obj && target);
|
||||
MOZ_ASSERT(map.initialized());
|
||||
|
||||
MOZ_ASSERT(!map.has(obj));
|
||||
if (!map.put(obj, ObjectValue(*target))) {
|
||||
@ -190,7 +181,6 @@ ObjectWeakMap::add(JSContext* cx, JSObject* obj, JSObject* target)
|
||||
void
|
||||
ObjectWeakMap::clear()
|
||||
{
|
||||
MOZ_ASSERT(map.initialized());
|
||||
map.clear();
|
||||
}
|
||||
|
||||
@ -203,7 +193,6 @@ ObjectWeakMap::trace(JSTracer* trc)
|
||||
size_t
|
||||
ObjectWeakMap::sizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf)
|
||||
{
|
||||
MOZ_ASSERT(map.initialized());
|
||||
return map.shallowSizeOfExcludingThis(mallocSizeOf);
|
||||
}
|
||||
|
||||
@ -211,7 +200,6 @@ ObjectWeakMap::sizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf)
|
||||
void
|
||||
ObjectWeakMap::checkAfterMovingGC()
|
||||
{
|
||||
MOZ_ASSERT(map.initialized());
|
||||
for (ObjectValueMap::Range r = map.all(); !r.empty(); r.popFront()) {
|
||||
CheckGCThingAfterMovingGC(r.front().key().get());
|
||||
CheckGCThingAfterMovingGC(&r.front().value().toObject());
|
||||
|
@ -92,7 +92,7 @@ class WeakMapBase : public mozilla::LinkedListElement<WeakMapBase>
|
||||
virtual bool findZoneEdges() = 0;
|
||||
virtual void sweep() = 0;
|
||||
virtual void traceMappings(WeakMapTracer* tracer) = 0;
|
||||
virtual void finish() = 0;
|
||||
virtual void clearAndCompact() = 0;
|
||||
|
||||
// Any weakmap key types that want to participate in the non-iterative
|
||||
// ephemeron marking must override this method.
|
||||
@ -127,8 +127,6 @@ class WeakMap : public HashMap<Key, Value, HashPolicy, ZoneAllocPolicy>,
|
||||
|
||||
explicit WeakMap(JSContext* cx, JSObject* memOf = nullptr);
|
||||
|
||||
bool init(uint32_t len = 16);
|
||||
|
||||
// Overwritten to add a read barrier to prevent an incorrectly gray value
|
||||
// from escaping the weak map. See the UnmarkGrayTracer::onChild comment in
|
||||
// gc/Marking.cpp.
|
||||
@ -139,7 +137,7 @@ class WeakMap : public HashMap<Key, Value, HashPolicy, ZoneAllocPolicy>,
|
||||
return p;
|
||||
}
|
||||
|
||||
AddPtr lookupForAdd(const Lookup& l) const {
|
||||
AddPtr lookupForAdd(const Lookup& l) {
|
||||
AddPtr p = Base::lookupForAdd(l);
|
||||
if (p)
|
||||
exposeGCThingToActiveJS(p->value());
|
||||
@ -178,8 +176,9 @@ class WeakMap : public HashMap<Key, Value, HashPolicy, ZoneAllocPolicy>,
|
||||
|
||||
void sweep() override;
|
||||
|
||||
void finish() override {
|
||||
Base::finish();
|
||||
void clearAndCompact() override {
|
||||
Base::clear();
|
||||
Base::compact();
|
||||
}
|
||||
|
||||
/* memberOf can be nullptr, which means that the map is not part of a JSObject. */
|
||||
@ -212,7 +211,6 @@ class ObjectWeakMap
|
||||
|
||||
public:
|
||||
explicit ObjectWeakMap(JSContext* cx);
|
||||
bool init();
|
||||
|
||||
JS::Zone* zone() const { return map.zone(); }
|
||||
|
||||
|
@ -66,7 +66,7 @@ JS::WeakMapPtr<K, V>::init(JSContext* cx)
|
||||
MOZ_ASSERT(!initialized());
|
||||
typename WeakMapDetails::Utils<K, V>::PtrType map =
|
||||
cx->new_<typename WeakMapDetails::Utils<K,V>::Type>(cx);
|
||||
if (!map || !map->init())
|
||||
if (!map)
|
||||
return false;
|
||||
ptr = map;
|
||||
return true;
|
||||
|
@ -105,13 +105,7 @@ bool
|
||||
Zone::init(bool isSystemArg)
|
||||
{
|
||||
isSystem = isSystemArg;
|
||||
return uniqueIds().init() &&
|
||||
gcSweepGroupEdges().init() &&
|
||||
gcWeakKeys().init() &&
|
||||
typeDescrObjects().init() &&
|
||||
markedAtoms().init() &&
|
||||
atomCache().init() &&
|
||||
regExps.init();
|
||||
return gcWeakKeys().init();
|
||||
}
|
||||
|
||||
void
|
||||
@ -288,7 +282,7 @@ Zone::createJitZone(JSContext* cx)
|
||||
return nullptr;
|
||||
|
||||
UniquePtr<jit::JitZone> jitZone(cx->new_<js::jit::JitZone>());
|
||||
if (!jitZone || !jitZone->init(cx))
|
||||
if (!jitZone)
|
||||
return nullptr;
|
||||
|
||||
jitZone_ = jitZone.release();
|
||||
@ -364,10 +358,8 @@ Zone::clearTables()
|
||||
{
|
||||
MOZ_ASSERT(regExps.empty());
|
||||
|
||||
if (baseShapes().initialized())
|
||||
baseShapes().clear();
|
||||
if (initialShapes().initialized())
|
||||
initialShapes().clear();
|
||||
baseShapes().clear();
|
||||
initialShapes().clear();
|
||||
}
|
||||
|
||||
void
|
||||
@ -453,7 +445,7 @@ Zone::purgeAtomCache()
|
||||
MOZ_ASSERT(!hasKeptAtoms());
|
||||
MOZ_ASSERT(!purgeAtomsDeferred);
|
||||
|
||||
atomCache().clearAndShrink();
|
||||
atomCache().clearAndCompact();
|
||||
|
||||
// Also purge the dtoa caches so that subsequent lookups populate atom
|
||||
// cache too.
|
||||
|
@ -10217,9 +10217,6 @@ CodeGenerator::generate()
|
||||
if (!addNativeToBytecodeEntry(startSite))
|
||||
return false;
|
||||
|
||||
if (!snapshots_.init())
|
||||
return false;
|
||||
|
||||
if (!safepoints_.init(gen->alloc()))
|
||||
return false;
|
||||
|
||||
|
@ -99,8 +99,7 @@ ExecutableAllocator::~ExecutableAllocator()
|
||||
m_smallPools[i]->release(/* willDestroy = */true);
|
||||
|
||||
// If this asserts we have a pool leak.
|
||||
MOZ_ASSERT_IF((m_pools.initialized() &&
|
||||
TlsContext.get()->runtime()->gc.shutdownCollectedEverything()),
|
||||
MOZ_ASSERT_IF(TlsContext.get()->runtime()->gc.shutdownCollectedEverything(),
|
||||
m_pools.empty());
|
||||
}
|
||||
|
||||
@ -180,9 +179,6 @@ ExecutableAllocator::createPool(size_t n)
|
||||
if (allocSize == OVERSIZE_ALLOCATION)
|
||||
return nullptr;
|
||||
|
||||
if (!m_pools.initialized() && !m_pools.init())
|
||||
return nullptr;
|
||||
|
||||
ExecutablePool::Allocation a = systemAlloc(allocSize);
|
||||
if (!a.pages)
|
||||
return nullptr;
|
||||
@ -235,8 +231,6 @@ ExecutableAllocator::releasePoolPages(ExecutablePool* pool)
|
||||
MOZ_ASSERT(pool->m_allocation.pages);
|
||||
systemRelease(pool->m_allocation);
|
||||
|
||||
MOZ_ASSERT(m_pools.initialized());
|
||||
|
||||
// Pool may not be present in m_pools if we hit OOM during creation.
|
||||
if (auto ptr = m_pools.lookup(pool))
|
||||
m_pools.remove(ptr);
|
||||
@ -263,15 +257,13 @@ ExecutableAllocator::purge()
|
||||
void
|
||||
ExecutableAllocator::addSizeOfCode(JS::CodeSizes* sizes) const
|
||||
{
|
||||
if (m_pools.initialized()) {
|
||||
for (ExecPoolHashSet::Range r = m_pools.all(); !r.empty(); r.popFront()) {
|
||||
ExecutablePool* pool = r.front();
|
||||
sizes->ion += pool->m_codeBytes[CodeKind::Ion];
|
||||
sizes->baseline += pool->m_codeBytes[CodeKind::Baseline];
|
||||
sizes->regexp += pool->m_codeBytes[CodeKind::RegExp];
|
||||
sizes->other += pool->m_codeBytes[CodeKind::Other];
|
||||
sizes->unused += pool->m_allocation.size - pool->usedCodeBytes();
|
||||
}
|
||||
for (ExecPoolHashSet::Range r = m_pools.all(); !r.empty(); r.popFront()) {
|
||||
ExecutablePool* pool = r.front();
|
||||
sizes->ion += pool->m_codeBytes[CodeKind::Ion];
|
||||
sizes->baseline += pool->m_codeBytes[CodeKind::Baseline];
|
||||
sizes->regexp += pool->m_codeBytes[CodeKind::RegExp];
|
||||
sizes->other += pool->m_codeBytes[CodeKind::Other];
|
||||
sizes->unused += pool->m_allocation.size - pool->usedCodeBytes();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -221,7 +221,7 @@ JitRuntime::initialize(JSContext* cx)
|
||||
JitContext jctx(cx, nullptr);
|
||||
|
||||
functionWrappers_ = cx->new_<VMWrapperMap>(cx);
|
||||
if (!functionWrappers_ || !functionWrappers_->init())
|
||||
if (!functionWrappers_)
|
||||
return false;
|
||||
|
||||
StackMacroAssembler masm;
|
||||
@ -410,11 +410,6 @@ JitRealm::initialize(JSContext* cx)
|
||||
if (!stubCodes_)
|
||||
return false;
|
||||
|
||||
if (!stubCodes_->init()) {
|
||||
ReportOutOfMemory(cx);
|
||||
return false;
|
||||
}
|
||||
|
||||
stringsCanBeInNursery = cx->nursery().canAllocateStrings();
|
||||
|
||||
return true;
|
||||
@ -443,17 +438,6 @@ JitRealm::performStubReadBarriers(uint32_t stubsToBarrier) const
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
JitZone::init(JSContext* cx)
|
||||
{
|
||||
if (!baselineCacheIRStubCodes_.init()) {
|
||||
ReportOutOfMemory(cx);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
jit::FreeIonBuilder(IonBuilder* builder)
|
||||
{
|
||||
@ -686,7 +670,6 @@ TrampolinePtr
|
||||
JitRuntime::getVMWrapper(const VMFunction& f) const
|
||||
{
|
||||
MOZ_ASSERT(functionWrappers_);
|
||||
MOZ_ASSERT(functionWrappers_->initialized());
|
||||
MOZ_ASSERT(trampolineCode_);
|
||||
|
||||
JitRuntime::VMWrapperMap::Ptr p = functionWrappers_->readonlyThreadsafeLookup(&f);
|
||||
@ -1483,8 +1466,6 @@ OptimizeMIR(MIRGenerator* mir)
|
||||
}
|
||||
|
||||
ValueNumberer gvn(mir, graph);
|
||||
if (!gvn.init())
|
||||
return false;
|
||||
|
||||
// Alias analysis is required for LICM and GVN so that we don't move
|
||||
// loads across stores.
|
||||
|
@ -3581,9 +3581,6 @@ jit::EliminateRedundantChecks(MIRGraph& graph)
|
||||
{
|
||||
BoundsCheckMap checks(graph.alloc());
|
||||
|
||||
if (!checks.init())
|
||||
return false;
|
||||
|
||||
// Stack for pre-order CFG traversal.
|
||||
Vector<MBasicBlock*, 1, JitAllocPolicy> worklist(graph.alloc());
|
||||
|
||||
|
@ -398,7 +398,6 @@ class JitZone
|
||||
BaselineCacheIRStubCodeMap baselineCacheIRStubCodes_;
|
||||
|
||||
public:
|
||||
MOZ_MUST_USE bool init(JSContext* cx);
|
||||
void sweep();
|
||||
|
||||
void addSizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf,
|
||||
@ -433,22 +432,18 @@ class JitZone
|
||||
}
|
||||
|
||||
CacheIRStubInfo* getIonCacheIRStubInfo(const CacheIRStubKey::Lookup& key) {
|
||||
if (!ionCacheIRStubInfoSet_.initialized())
|
||||
return nullptr;
|
||||
IonCacheIRStubInfoSet::Ptr p = ionCacheIRStubInfoSet_.lookup(key);
|
||||
return p ? p->stubInfo.get() : nullptr;
|
||||
}
|
||||
MOZ_MUST_USE bool putIonCacheIRStubInfo(const CacheIRStubKey::Lookup& lookup,
|
||||
CacheIRStubKey& key)
|
||||
{
|
||||
if (!ionCacheIRStubInfoSet_.initialized() && !ionCacheIRStubInfoSet_.init())
|
||||
return false;
|
||||
IonCacheIRStubInfoSet::AddPtr p = ionCacheIRStubInfoSet_.lookupForAdd(lookup);
|
||||
MOZ_ASSERT(!p);
|
||||
return ionCacheIRStubInfoSet_.add(p, std::move(key));
|
||||
}
|
||||
void purgeIonCacheIRStubInfo() {
|
||||
ionCacheIRStubInfoSet_.finish();
|
||||
ionCacheIRStubInfoSet_.clearAndCompact();
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -37,8 +37,6 @@ LIRGraph::LIRGraph(MIRGraph* mir)
|
||||
bool
|
||||
LIRGraph::addConstantToPool(const Value& v, uint32_t* index)
|
||||
{
|
||||
MOZ_ASSERT(constantPoolMap_.initialized());
|
||||
|
||||
ConstantPoolMap::AddPtr p = constantPoolMap_.lookupForAdd(v);
|
||||
if (p) {
|
||||
*index = p->value();
|
||||
|
@ -1898,7 +1898,7 @@ class LIRGraph
|
||||
explicit LIRGraph(MIRGraph* mir);
|
||||
|
||||
MOZ_MUST_USE bool init() {
|
||||
return constantPoolMap_.init() && blocks_.init(mir_.alloc(), mir_.numBlocks());
|
||||
return blocks_.init(mir_.alloc(), mir_.numBlocks());
|
||||
}
|
||||
MIRGraph& mir() const {
|
||||
return mir_;
|
||||
|
@ -250,9 +250,6 @@ LoopUnroller::go(LoopIterationBound* bound)
|
||||
graph.insertBlockAfter(unrolledBackedge, newPreheader);
|
||||
graph.renumberBlocksAfter(oldPreheader);
|
||||
|
||||
if (!unrolledDefinitions.init())
|
||||
return false;
|
||||
|
||||
// Add phis to the unrolled loop header which correspond to the phis in the
|
||||
// original loop header.
|
||||
MOZ_ASSERT(header->getPredecessor(0) == oldPreheader);
|
||||
|
@ -373,7 +373,6 @@ class jit::UniqueTrackedTypes
|
||||
list_(cx)
|
||||
{ }
|
||||
|
||||
bool init() { return map_.init(); }
|
||||
bool getIndexOf(TypeSet::Type ty, uint8_t* indexp);
|
||||
|
||||
uint32_t count() const { MOZ_ASSERT(map_.count() == list_.length()); return list_.length(); }
|
||||
@ -965,8 +964,6 @@ jit::WriteIonTrackedOptimizationsTable(JSContext* cx, CompactBufferWriter& write
|
||||
|
||||
// Write out type info payloads.
|
||||
UniqueTrackedTypes uniqueTypes(cx);
|
||||
if (!uniqueTypes.init())
|
||||
return false;
|
||||
|
||||
for (const UniqueTrackedOptimizations::SortEntry* p = vec.begin(); p != vec.end(); p++) {
|
||||
const TempOptimizationTypeInfoVector* v = p->types;
|
||||
|
@ -182,7 +182,6 @@ class UniqueTrackedOptimizations
|
||||
sorted_(cx)
|
||||
{ }
|
||||
|
||||
MOZ_MUST_USE bool init() { return map_.init(); }
|
||||
MOZ_MUST_USE bool add(const TrackedOptimizations* optimizations);
|
||||
|
||||
MOZ_MUST_USE bool sortByFrequency(JSContext* cx);
|
||||
|
@ -75,7 +75,7 @@ AllocationIntegrityState::record()
|
||||
}
|
||||
}
|
||||
|
||||
return seen.init();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -547,14 +547,12 @@ SnapshotReader::readAllocation()
|
||||
return RValueAllocation::read(allocReader_);
|
||||
}
|
||||
|
||||
bool
|
||||
SnapshotWriter::init()
|
||||
{
|
||||
// Based on the measurements made in Bug 962555 comment 20, this should be
|
||||
// enough to prevent the reallocation of the hash table for at least half of
|
||||
// the compilations.
|
||||
return allocMap_.init(32);
|
||||
}
|
||||
SnapshotWriter::SnapshotWriter()
|
||||
// Based on the measurements made in Bug 962555 comment 20, this length
|
||||
// should be enough to prevent the reallocation of the hash table for at
|
||||
// least half of the compilations.
|
||||
: allocMap_(32)
|
||||
{}
|
||||
|
||||
RecoverReader::RecoverReader(SnapshotReader& snapshot, const uint8_t* recovers, uint32_t size)
|
||||
: reader_(nullptr, nullptr),
|
||||
@ -647,8 +645,6 @@ SnapshotWriter::trackSnapshot(uint32_t pcOpcode, uint32_t mirOpcode, uint32_t mi
|
||||
bool
|
||||
SnapshotWriter::add(const RValueAllocation& alloc)
|
||||
{
|
||||
MOZ_ASSERT(allocMap_.initialized());
|
||||
|
||||
uint32_t offset;
|
||||
RValueAllocMap::AddPtr p = allocMap_.lookupForAdd(alloc);
|
||||
if (!p) {
|
||||
|
@ -400,7 +400,7 @@ class SnapshotWriter
|
||||
SnapshotOffset lastStart_;
|
||||
|
||||
public:
|
||||
MOZ_MUST_USE bool init();
|
||||
SnapshotWriter();
|
||||
|
||||
SnapshotOffset startSnapshot(RecoverOffset recoverOffset, BailoutKind kind);
|
||||
#ifdef TRACK_SNAPSHOTS
|
||||
|
@ -78,13 +78,6 @@ ValueNumberer::VisibleValues::VisibleValues(TempAllocator& alloc)
|
||||
: set_(alloc)
|
||||
{}
|
||||
|
||||
// Initialize the set.
|
||||
bool
|
||||
ValueNumberer::VisibleValues::init()
|
||||
{
|
||||
return set_.init();
|
||||
}
|
||||
|
||||
// Look up the first entry for |def|.
|
||||
ValueNumberer::VisibleValues::Ptr
|
||||
ValueNumberer::VisibleValues::findLeader(const MDefinition* def) const
|
||||
@ -1208,6 +1201,12 @@ bool ValueNumberer::cleanupOSRFixups()
|
||||
|
||||
ValueNumberer::ValueNumberer(MIRGenerator* mir, MIRGraph& graph)
|
||||
: mir_(mir), graph_(graph),
|
||||
// Initialize the value set. It's tempting to pass in a length that is a
|
||||
// function of graph_.getNumInstructionIds(). But if we start out with a
|
||||
// large capacity, it will be far larger than the actual element count for
|
||||
// most of the pass, so when we remove elements, it would often think it
|
||||
// needs to compact itself. Empirically, just letting the HashTable grow as
|
||||
// needed on its own seems to work pretty well.
|
||||
values_(graph.alloc()),
|
||||
deadDefs_(graph.alloc()),
|
||||
remainingBlocks_(graph.alloc()),
|
||||
@ -1220,18 +1219,6 @@ ValueNumberer::ValueNumberer(MIRGenerator* mir, MIRGraph& graph)
|
||||
hasOSRFixups_(false)
|
||||
{}
|
||||
|
||||
bool
|
||||
ValueNumberer::init()
|
||||
{
|
||||
// Initialize the value set. It's tempting to pass in a size here of some
|
||||
// function of graph_.getNumInstructionIds(), however if we start out with a
|
||||
// large capacity, it will be far larger than the actual element count for
|
||||
// most of the pass, so when we remove elements, it would often think it
|
||||
// needs to compact itself. Empirically, just letting the HashTable grow as
|
||||
// needed on its own seems to work pretty well.
|
||||
return values_.init();
|
||||
}
|
||||
|
||||
bool
|
||||
ValueNumberer::run(UpdateAliasAnalysisFlag updateAliasAnalysis)
|
||||
{
|
||||
|
@ -41,7 +41,6 @@ class ValueNumberer
|
||||
|
||||
public:
|
||||
explicit VisibleValues(TempAllocator& alloc);
|
||||
MOZ_MUST_USE bool init();
|
||||
|
||||
typedef ValueSet::Ptr Ptr;
|
||||
typedef ValueSet::AddPtr AddPtr;
|
||||
@ -108,7 +107,6 @@ class ValueNumberer
|
||||
|
||||
public:
|
||||
ValueNumberer(MIRGenerator* mir, MIRGraph& graph);
|
||||
MOZ_MUST_USE bool init();
|
||||
|
||||
enum UpdateAliasAnalysisFlag {
|
||||
DontUpdateAliasAnalysis,
|
||||
|
@ -31,8 +31,6 @@ jit::EliminateBoundsChecks(MIRGenerator* mir, MIRGraph& graph)
|
||||
{
|
||||
// Map for dominating block where a given definition was checked
|
||||
LastSeenMap lastSeen;
|
||||
if (!lastSeen.init())
|
||||
return false;
|
||||
|
||||
for (ReversePostorderIterator bIter(graph.rpoBegin()); bIter != graph.rpoEnd(); bIter++) {
|
||||
MBasicBlock* block = *bIter;
|
||||
|
@ -1282,7 +1282,10 @@ Simulator::~Simulator()
|
||||
SimulatorProcess::SimulatorProcess()
|
||||
: cacheLock_(mutexid::SimulatorCacheLock)
|
||||
, redirection_(nullptr)
|
||||
{}
|
||||
{
|
||||
if (getenv("ARM_SIM_ICACHE_CHECKS"))
|
||||
ICacheCheckingDisableCount = 0;
|
||||
}
|
||||
|
||||
SimulatorProcess::~SimulatorProcess()
|
||||
{
|
||||
@ -1294,15 +1297,6 @@ SimulatorProcess::~SimulatorProcess()
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
SimulatorProcess::init()
|
||||
{
|
||||
if (getenv("ARM_SIM_ICACHE_CHECKS"))
|
||||
ICacheCheckingDisableCount = 0;
|
||||
|
||||
return icache_.init();
|
||||
}
|
||||
|
||||
/* static */ void*
|
||||
Simulator::RedirectNativeFunction(void* nativeFunction, ABIFunctionType type)
|
||||
{
|
||||
|
@ -487,7 +487,7 @@ class SimulatorProcess
|
||||
|
||||
static bool initialize() {
|
||||
singleton_ = js_new<SimulatorProcess>();
|
||||
return singleton_ && singleton_->init();
|
||||
return singleton_;
|
||||
}
|
||||
static void destroy() {
|
||||
js_delete(singleton_);
|
||||
@ -498,8 +498,6 @@ class SimulatorProcess
|
||||
~SimulatorProcess();
|
||||
|
||||
private:
|
||||
bool init();
|
||||
|
||||
static SimulatorProcess* singleton_;
|
||||
|
||||
// This lock creates a critical section around 'redirection_' and
|
||||
|
@ -716,7 +716,6 @@ bool
|
||||
JitRuntime::generateVMWrapper(JSContext* cx, MacroAssembler& masm, const VMFunction& f)
|
||||
{
|
||||
MOZ_ASSERT(functionWrappers_);
|
||||
MOZ_ASSERT(functionWrappers_->initialized());
|
||||
|
||||
uint32_t wrapperOffset = startTrampolineCode(masm);
|
||||
|
||||
|
@ -524,7 +524,6 @@ bool
|
||||
JitRuntime::generateVMWrapper(JSContext* cx, MacroAssembler& masm, const VMFunction& f)
|
||||
{
|
||||
MOZ_ASSERT(functionWrappers_);
|
||||
MOZ_ASSERT(functionWrappers_->initialized());
|
||||
|
||||
uint32_t wrapperOffset = startTrampolineCode(masm);
|
||||
|
||||
|
@ -880,8 +880,6 @@ CodeGeneratorShared::generateCompactTrackedOptimizationsMap(JSContext* cx, JitCo
|
||||
return true;
|
||||
|
||||
UniqueTrackedOptimizations unique(cx);
|
||||
if (!unique.init())
|
||||
return false;
|
||||
|
||||
// Iterate through all entries to deduplicate their optimization attempts.
|
||||
for (size_t i = 0; i < trackedOptimizations_.length(); i++) {
|
||||
|
@ -604,7 +604,6 @@ bool
|
||||
JitRuntime::generateVMWrapper(JSContext* cx, MacroAssembler& masm, const VMFunction& f)
|
||||
{
|
||||
MOZ_ASSERT(functionWrappers_);
|
||||
MOZ_ASSERT(functionWrappers_->initialized());
|
||||
|
||||
uint32_t wrapperOffset = startTrampolineCode(masm);
|
||||
|
||||
|
@ -139,11 +139,6 @@ MacroAssemblerX86Shared::getConstant(const typename T::Pod& value, Map& map,
|
||||
Vector<T, 0, SystemAllocPolicy>& vec)
|
||||
{
|
||||
typedef typename Map::AddPtr AddPtr;
|
||||
if (!map.initialized()) {
|
||||
enoughMemory_ &= map.init();
|
||||
if (!enoughMemory_)
|
||||
return nullptr;
|
||||
}
|
||||
size_t index;
|
||||
if (AddPtr p = map.lookupForAdd(value)) {
|
||||
index = p->value();
|
||||
|
@ -624,7 +624,6 @@ bool
|
||||
JitRuntime::generateVMWrapper(JSContext* cx, MacroAssembler& masm, const VMFunction& f)
|
||||
{
|
||||
MOZ_ASSERT(functionWrappers_);
|
||||
MOZ_ASSERT(functionWrappers_->initialized());
|
||||
|
||||
uint32_t wrapperOffset = startTrampolineCode(masm);
|
||||
|
||||
|
@ -166,8 +166,6 @@ runTestFromPath(JSContext* cx, const char* path)
|
||||
txtOptions.setFileAndLine(txtPath.begin(), 0);
|
||||
|
||||
UsedNameTracker txtUsedNames(cx);
|
||||
if (!txtUsedNames.init())
|
||||
MOZ_CRASH("Couldn't initialize used names");
|
||||
|
||||
RootedScriptSourceObject sourceObject(cx, frontend::CreateScriptSourceObject(
|
||||
cx, txtOptions, mozilla::Nothing()));
|
||||
@ -206,8 +204,6 @@ runTestFromPath(JSContext* cx, const char* path)
|
||||
binOptions.setFileAndLine(binPath.begin(), 0);
|
||||
|
||||
js::frontend::UsedNameTracker binUsedNames(cx);
|
||||
if (!binUsedNames.init())
|
||||
MOZ_CRASH("Couldn't initialized binUsedNames");
|
||||
|
||||
js::frontend::BinASTParser<Tok> binParser(cx, allocScope.alloc(), binUsedNames, binOptions);
|
||||
|
||||
|
@ -145,9 +145,7 @@ using MyHashMap = js::GCHashMap<js::Shape*, JSObject*>;
|
||||
|
||||
BEGIN_TEST(testGCRootedHashMap)
|
||||
{
|
||||
JS::Rooted<MyHashMap> map(cx, MyHashMap(cx));
|
||||
CHECK(map.init(15));
|
||||
CHECK(map.initialized());
|
||||
JS::Rooted<MyHashMap> map(cx, MyHashMap(cx, 15));
|
||||
|
||||
for (size_t i = 0; i < 10; ++i) {
|
||||
RootedObject obj(cx, JS_NewObject(cx, nullptr));
|
||||
@ -205,9 +203,7 @@ CheckMyHashMap(JSContext* cx, Handle<MyHashMap> map)
|
||||
|
||||
BEGIN_TEST(testGCHandleHashMap)
|
||||
{
|
||||
JS::Rooted<MyHashMap> map(cx, MyHashMap(cx));
|
||||
CHECK(map.init(15));
|
||||
CHECK(map.initialized());
|
||||
JS::Rooted<MyHashMap> map(cx, MyHashMap(cx, 15));
|
||||
|
||||
CHECK(FillMyHashMap(cx, &map));
|
||||
|
||||
|
@ -344,7 +344,6 @@ TestUnassociatedWeakMaps()
|
||||
// Make a weakmap that's not associated with a JSObject.
|
||||
auto weakMap = cx->make_unique<GCManagedObjectWeakMap>(cx);
|
||||
CHECK(weakMap);
|
||||
CHECK(weakMap->init());
|
||||
|
||||
// Make sure this gets traced during GC.
|
||||
Rooted<GCManagedObjectWeakMap*> rootMap(cx, weakMap.get());
|
||||
|
@ -122,7 +122,6 @@ BEGIN_TEST(testTracingIncomingCCWs)
|
||||
// Ensure that |TraceIncomingCCWs| finds the object wrapped by the CCW.
|
||||
|
||||
JS::CompartmentSet compartments;
|
||||
CHECK(compartments.init());
|
||||
CHECK(compartments.put(global2->compartment()));
|
||||
|
||||
void* thing = wrappee.get();
|
||||
|
@ -32,7 +32,6 @@ BEGIN_TEST(testWeakCacheSet)
|
||||
SystemAllocPolicy>;
|
||||
using Cache = JS::WeakCache<ObjectSet>;
|
||||
Cache cache(JS::GetObjectZone(tenured1));
|
||||
CHECK(cache.init());
|
||||
|
||||
cache.put(tenured1);
|
||||
cache.put(tenured2);
|
||||
@ -73,7 +72,6 @@ BEGIN_TEST(testWeakCacheMap)
|
||||
js::MovableCellHasher<JS::Heap<JSObject*>>>;
|
||||
using Cache = JS::WeakCache<ObjectMap>;
|
||||
Cache cache(JS::GetObjectZone(tenured1), cx);
|
||||
CHECK(cache.init());
|
||||
|
||||
cache.put(tenured1, 1);
|
||||
cache.put(tenured2, 2);
|
||||
@ -284,8 +282,6 @@ TestSet()
|
||||
TempAllocPolicy>;
|
||||
using Cache = JS::WeakCache<ObjectSet>;
|
||||
Cache cache(JS::GetObjectZone(global), cx);
|
||||
CHECK(cache.init());
|
||||
CHECK(cache.initialized());
|
||||
|
||||
// Sweep empty cache.
|
||||
|
||||
@ -405,7 +401,6 @@ TestSet()
|
||||
CHECK(cache.has(obj4));
|
||||
|
||||
cache.clear();
|
||||
cache.finish();
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -418,8 +413,6 @@ TestMap()
|
||||
TempAllocPolicy>;
|
||||
using Cache = JS::WeakCache<ObjectMap>;
|
||||
Cache cache(JS::GetObjectZone(global), cx);
|
||||
CHECK(cache.init());
|
||||
CHECK(cache.initialized());
|
||||
|
||||
// Sweep empty cache.
|
||||
|
||||
@ -541,7 +534,6 @@ TestMap()
|
||||
CHECK(cache.has(obj4));
|
||||
|
||||
cache.clear();
|
||||
cache.finish();
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -556,7 +548,6 @@ TestReplaceDyingInSet()
|
||||
MovableCellHasher<NumberAndObjectEntry>,
|
||||
TempAllocPolicy>>;
|
||||
Cache cache(JS::GetObjectZone(global), cx);
|
||||
CHECK(cache.init());
|
||||
|
||||
RootedObject value1(cx, JS_NewPlainObject(cx));
|
||||
RootedObject value2(cx, JS_NewPlainObject(cx));
|
||||
@ -620,7 +611,6 @@ TestReplaceDyingInMap()
|
||||
DefaultHasher<uint32_t>,
|
||||
TempAllocPolicy>>;
|
||||
Cache cache(JS::GetObjectZone(global), cx);
|
||||
CHECK(cache.init());
|
||||
|
||||
RootedObject value1(cx, JS_NewPlainObject(cx));
|
||||
RootedObject value2(cx, JS_NewPlainObject(cx));
|
||||
@ -687,7 +677,6 @@ TestUniqueIDLookups()
|
||||
MovableCellHasher<ObjectEntry>,
|
||||
TempAllocPolicy>>;
|
||||
Cache cache(JS::GetObjectZone(global), cx);
|
||||
CHECK(cache.init());
|
||||
|
||||
Rooted<GCVector<JSObject*, 0, SystemAllocPolicy>> liveObjects(cx);
|
||||
|
||||
|
@ -143,8 +143,6 @@ template <class NewKeyFunction>
|
||||
static bool
|
||||
SlowRekey(IntMap* m) {
|
||||
IntMap tmp;
|
||||
if (!tmp.init())
|
||||
return false;
|
||||
|
||||
for (auto iter = m->iter(); !iter.done(); iter.next()) {
|
||||
if (NewKeyFunction::shouldBeRemoved(iter.get().key()))
|
||||
@ -169,8 +167,6 @@ template <class NewKeyFunction>
|
||||
static bool
|
||||
SlowRekey(IntSet* s) {
|
||||
IntSet tmp;
|
||||
if (!tmp.init())
|
||||
return false;
|
||||
|
||||
for (auto iter = s->iter(); !iter.done(); iter.next()) {
|
||||
if (NewKeyFunction::shouldBeRemoved(iter.get()))
|
||||
@ -194,8 +190,6 @@ SlowRekey(IntSet* s) {
|
||||
BEGIN_TEST(testHashRekeyManual)
|
||||
{
|
||||
IntMap am, bm;
|
||||
CHECK(am.init());
|
||||
CHECK(bm.init());
|
||||
for (size_t i = 0; i < TestIterations; ++i) {
|
||||
#ifdef FUZZ
|
||||
fprintf(stderr, "map1: %lu\n", i);
|
||||
@ -216,8 +210,6 @@ BEGIN_TEST(testHashRekeyManual)
|
||||
}
|
||||
|
||||
IntSet as, bs;
|
||||
CHECK(as.init());
|
||||
CHECK(bs.init());
|
||||
for (size_t i = 0; i < TestIterations; ++i) {
|
||||
#ifdef FUZZ
|
||||
fprintf(stderr, "set1: %lu\n", i);
|
||||
@ -244,8 +236,6 @@ END_TEST(testHashRekeyManual)
|
||||
BEGIN_TEST(testHashRekeyManualRemoval)
|
||||
{
|
||||
IntMap am, bm;
|
||||
CHECK(am.init());
|
||||
CHECK(bm.init());
|
||||
for (size_t i = 0; i < TestIterations; ++i) {
|
||||
#ifdef FUZZ
|
||||
fprintf(stderr, "map2: %lu\n", i);
|
||||
@ -270,8 +260,6 @@ BEGIN_TEST(testHashRekeyManualRemoval)
|
||||
}
|
||||
|
||||
IntSet as, bs;
|
||||
CHECK(as.init());
|
||||
CHECK(bs.init());
|
||||
for (size_t i = 0; i < TestIterations; ++i) {
|
||||
#ifdef FUZZ
|
||||
fprintf(stderr, "set1: %lu\n", i);
|
||||
@ -338,7 +326,6 @@ BEGIN_TEST(testHashSetOfMoveOnlyType)
|
||||
typedef js::HashSet<MoveOnlyType, MoveOnlyType::HashPolicy, js::SystemAllocPolicy> Set;
|
||||
|
||||
Set set;
|
||||
CHECK(set.init());
|
||||
|
||||
MoveOnlyType a(1);
|
||||
|
||||
@ -357,9 +344,6 @@ GrowUntilResize()
|
||||
{
|
||||
IntMap m;
|
||||
|
||||
if (!m.init())
|
||||
return false;
|
||||
|
||||
// Add entries until we've resized the table four times.
|
||||
size_t lastCapacity = m.capacity();
|
||||
size_t resizes = 0;
|
||||
@ -367,7 +351,7 @@ GrowUntilResize()
|
||||
while (resizes < 4) {
|
||||
auto p = m.lookupForAdd(key);
|
||||
if (!p && !m.add(p, key, 0))
|
||||
return false; // OOM'd while adding
|
||||
return false; // OOM'd in lookupForAdd() or add()
|
||||
|
||||
size_t capacity = m.capacity();
|
||||
if (capacity != lastCapacity) {
|
||||
@ -398,7 +382,6 @@ END_TEST(testHashMapGrowOOM)
|
||||
BEGIN_TEST(testHashTableMovableModIterator)
|
||||
{
|
||||
IntSet set;
|
||||
CHECK(set.init());
|
||||
|
||||
// Exercise returning a hash table ModIterator object from a function.
|
||||
|
||||
@ -435,3 +418,84 @@ IntSet::ModIterator setModIter(IntSet& set)
|
||||
}
|
||||
|
||||
END_TEST(testHashTableMovableModIterator)
|
||||
|
||||
BEGIN_TEST(testHashLazyStorage)
|
||||
{
|
||||
// The following code depends on the current capacity computation, which
|
||||
// could change in the future.
|
||||
uint32_t defaultCap = 32;
|
||||
uint32_t minCap = 4;
|
||||
|
||||
IntSet set;
|
||||
CHECK(set.capacity() == 0);
|
||||
|
||||
CHECK(set.put(1));
|
||||
CHECK(set.capacity() == defaultCap);
|
||||
|
||||
set.compact(); // effectively a no-op
|
||||
CHECK(set.capacity() == minCap);
|
||||
|
||||
set.clear();
|
||||
CHECK(set.capacity() == minCap);
|
||||
|
||||
set.compact();
|
||||
CHECK(set.capacity() == 0);
|
||||
|
||||
CHECK(set.putNew(1));
|
||||
CHECK(set.capacity() == minCap);
|
||||
|
||||
set.clear();
|
||||
set.compact();
|
||||
CHECK(set.capacity() == 0);
|
||||
|
||||
// lookupForAdd() instantiates, even if not followed by add().
|
||||
set.lookupForAdd(1);
|
||||
CHECK(set.capacity() == minCap);
|
||||
|
||||
set.clear();
|
||||
set.compact();
|
||||
CHECK(set.capacity() == 0);
|
||||
|
||||
CHECK(set.reserve(0)); // a no-op
|
||||
CHECK(set.capacity() == 0);
|
||||
|
||||
CHECK(set.reserve(1));
|
||||
CHECK(set.capacity() == minCap);
|
||||
|
||||
CHECK(set.reserve(0)); // a no-op
|
||||
CHECK(set.capacity() == minCap);
|
||||
|
||||
CHECK(set.reserve(2)); // effectively a no-op
|
||||
CHECK(set.capacity() == minCap);
|
||||
|
||||
// No need to clear here because we didn't add anything.
|
||||
set.compact();
|
||||
CHECK(set.capacity() == 0);
|
||||
|
||||
CHECK(set.reserve(128));
|
||||
CHECK(set.capacity() == 256);
|
||||
CHECK(set.reserve(3)); // effectively a no-op
|
||||
CHECK(set.capacity() == 256);
|
||||
for (int i = 0; i < 8; i++) {
|
||||
CHECK(set.putNew(i));
|
||||
}
|
||||
CHECK(set.count() == 8);
|
||||
CHECK(set.capacity() == 256);
|
||||
set.compact();
|
||||
CHECK(set.capacity() == 16);
|
||||
set.compact(); // effectively a no-op
|
||||
CHECK(set.capacity() == 16);
|
||||
for (int i = 8; i < 16; i++) {
|
||||
CHECK(set.putNew(i));
|
||||
}
|
||||
CHECK(set.count() == 16);
|
||||
CHECK(set.capacity() == 32);
|
||||
set.clear();
|
||||
CHECK(set.capacity() == 32);
|
||||
set.compact();
|
||||
CHECK(set.capacity() == 0);
|
||||
|
||||
return true;
|
||||
}
|
||||
END_TEST(testHashLazyStorage)
|
||||
|
||||
|
@ -86,8 +86,6 @@ struct MinimalFunc : MinimalAlloc
|
||||
if (!BuildPhiReverseMapping(graph))
|
||||
return false;
|
||||
ValueNumberer gvn(&mir, graph);
|
||||
if (!gvn.init())
|
||||
return false;
|
||||
if (!gvn.run(ValueNumberer::DontUpdateAliasAnalysis))
|
||||
return false;
|
||||
return true;
|
||||
|
@ -368,7 +368,6 @@ BEGIN_TEST(test_ubiPostOrder)
|
||||
FakeNode g('g');
|
||||
|
||||
js::HashSet<ExpectedEdge> expectedEdges(cx);
|
||||
CHECK(expectedEdges.init());
|
||||
|
||||
auto declareEdge = [&](FakeNode& from, FakeNode& to) {
|
||||
return from.addEdgeTo(to) && expectedEdges.putNew(ExpectedEdge(from, to));
|
||||
@ -395,7 +394,6 @@ BEGIN_TEST(test_ubiPostOrder)
|
||||
|
||||
JS::AutoCheckCannotGC nogc(cx);
|
||||
JS::ubi::PostOrder traversal(cx, nogc);
|
||||
CHECK(traversal.init());
|
||||
CHECK(traversal.addStart(&r));
|
||||
|
||||
auto onNode = [&](const JS::ubi::Node& node) {
|
||||
@ -590,7 +588,6 @@ BEGIN_TEST(test_JS_ubi_DominatorTree)
|
||||
fprintf(stderr, "Checking %c's dominated set:\n", node.name);
|
||||
|
||||
js::HashSet<char> expectedDominatedSet(cx);
|
||||
CHECK(expectedDominatedSet.init());
|
||||
for (auto& rel : domination) {
|
||||
if (&rel.dominator == &node) {
|
||||
fprintf(stderr, " Expecting %c\n", rel.dominated.name);
|
||||
@ -714,7 +711,6 @@ BEGIN_TEST(test_JS_ubi_ShortestPaths_no_path)
|
||||
JS::AutoCheckCannotGC noGC(cx);
|
||||
|
||||
JS::ubi::NodeSet targets;
|
||||
CHECK(targets.init());
|
||||
CHECK(targets.put(&b));
|
||||
|
||||
maybeShortestPaths = JS::ubi::ShortestPaths::Create(cx, noGC, 10, &a,
|
||||
@ -756,7 +752,6 @@ BEGIN_TEST(test_JS_ubi_ShortestPaths_one_path)
|
||||
JS::AutoCheckCannotGC noGC(cx);
|
||||
|
||||
JS::ubi::NodeSet targets;
|
||||
CHECK(targets.init());
|
||||
CHECK(targets.put(&b));
|
||||
|
||||
maybeShortestPaths = JS::ubi::ShortestPaths::Create(cx, noGC, 10, &a,
|
||||
@ -823,7 +818,6 @@ BEGIN_TEST(test_JS_ubi_ShortestPaths_multiple_paths)
|
||||
JS::AutoCheckCannotGC noGC(cx);
|
||||
|
||||
JS::ubi::NodeSet targets;
|
||||
CHECK(targets.init());
|
||||
CHECK(targets.put(&f));
|
||||
|
||||
maybeShortestPaths = JS::ubi::ShortestPaths::Create(cx, noGC, 10, &a,
|
||||
@ -915,7 +909,6 @@ BEGIN_TEST(test_JS_ubi_ShortestPaths_more_paths_than_max)
|
||||
JS::AutoCheckCannotGC noGC(cx);
|
||||
|
||||
JS::ubi::NodeSet targets;
|
||||
CHECK(targets.init());
|
||||
CHECK(targets.put(&f));
|
||||
|
||||
maybeShortestPaths = JS::ubi::ShortestPaths::Create(cx, noGC, 1, &a,
|
||||
@ -965,7 +958,6 @@ BEGIN_TEST(test_JS_ubi_ShortestPaths_multiple_edges_to_target)
|
||||
JS::AutoCheckCannotGC noGC(cx);
|
||||
|
||||
JS::ubi::NodeSet targets;
|
||||
CHECK(targets.init());
|
||||
CHECK(targets.put(&b));
|
||||
|
||||
maybeShortestPaths = JS::ubi::ShortestPaths::Create(cx, noGC, 10, &a,
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user