Merge inbound to mozilla-central. a=merge

This commit is contained in:
Bogdan Tara 2018-05-18 01:04:08 +03:00
Родитель 3a6da08524 a4df82c15c
Коммит 3287e1104c
144 изменённых файлов: 1047 добавлений и 1010 удалений

Просмотреть файл

@ -20,7 +20,6 @@
#include "nsCaret.h"
#include "nsContentUtils.h"
#include "nsFocusManager.h"
#include "nsIDOMRange.h"
#include "nsIEditingSession.h"
#include "nsContainerFrame.h"
#include "nsFrameSelection.h"
@ -31,6 +30,7 @@
#include "nsIServiceManager.h"
#include "nsITextControlElement.h"
#include "nsIMathMLFrame.h"
#include "nsRange.h"
#include "nsTextFragment.h"
#include "mozilla/BinarySearch.h"
#include "mozilla/dom/Element.h"

Просмотреть файл

@ -18,7 +18,6 @@
#include "TreeWalker.h"
#include "mozilla/dom/HTMLTableElement.h"
#include "nsIDOMRange.h"
#include "nsIHTMLCollection.h"
#include "nsIDocument.h"
#include "nsIMutableArray.h"

Просмотреть файл

@ -1,9 +1,9 @@
This is the debugger.html project output.
See https://github.com/devtools-html/debugger.html
Version 53
Version 54
Comparison: https://github.com/devtools-html/debugger.html/compare/release-52...release-53
Comparison: https://github.com/devtools-html/debugger.html/compare/release-53...release-54
Packages:
- babel-plugin-transform-es2015-modules-commonjs @6.26.2

Просмотреть файл

@ -1796,7 +1796,7 @@ html .toggle-button.end.vertical svg {
justify-content: center;
}
.source-footer > button.action:hover {
.source-footer > .commands > button.action:hover {
background: var(--theme-toolbar-background-hover);
}
@ -2920,7 +2920,8 @@ debug-expression-error {
.breakpoints-list .breakpoint-heading,
.breakpoints-list .breakpoint,
.breakpoints-exceptions {
.breakpoints-exceptions,
.breakpoints-exceptions-caught {
padding: 0.25em 1em;
}
@ -2930,8 +2931,7 @@ debug-expression-error {
}
.breakpoints-list .breakpoint {
padding-top: 0.25em;
padding-bottom: 0.25em;
height: var(--breakpoint-expression-height);
}
.breakpoints-exceptions-caught {
@ -2996,7 +2996,7 @@ html .breakpoints-list .breakpoint.paused {
.breakpoints-list .breakpoint.disabled .breakpoint-label {
color: var(--theme-comment);
transition: color 0.5s linear;
transition: color 0.15s linear;
}
.breakpoints-list .breakpoint:hover {
@ -3096,8 +3096,11 @@ html[dir="rtl"] .breakpoints-list .breakpoint .breakpoint-line {
min-width: initial !important;
}
.breakpoints-list .breakpoint .CodeMirror.cm-s-mozilla-breakpoint {
transition: opacity 0.15s linear;
}
.breakpoints-list .breakpoint.disabled .CodeMirror.cm-s-mozilla-breakpoint {
transition: opacity 0.5s linear;
opacity: 0.5;
}
@ -3190,6 +3193,7 @@ html[dir="rtl"] .breakpoints-list .breakpoint .breakpoint-line {
background-color: var(--theme-body-background);
display: block;
position: relative;
height: var(--breakpoint-expression-height);
}
.expression-container > .tree {
@ -3800,9 +3804,10 @@ img.skipPausing {
flex-direction: column;
flex: 1;
white-space: nowrap;
--breakpoint-expression-right-clear-space: 36px;
-moz-user-select: none;
user-select: none;
--breakpoint-expression-right-clear-space: 36px;
--breakpoint-expression-height: 2.4em;
}
/*

Просмотреть файл

@ -10,19 +10,16 @@ var _selectors = require("../../selectors/index");
var _preview = require("../../utils/preview");
var _ast = require("../../utils/ast");
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
async function getReactProps(evaluate) {
/* 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/>. */
async function getReactProps(evaluate, displayName) {
const componentNames = await evaluate(`
if(this.hasOwnProperty('_reactInternalFiber')) {
let componentNames = [];
let componentNode = this._reactInternalFiber;
while(componentNode) {
componentNames.push(componentNode.type.name);
let componentNames = [];
let componentNode = this._reactInternalFiber;
while(componentNode) {
componentNames.push(componentNode.type.name);
componentNode = componentNode._debugOwner
}
componentNames;
@ -32,13 +29,18 @@ async function getReactProps(evaluate) {
}
`);
const items = componentNames.result.preview && componentNames.result.preview.items;
let extra = {
displayName
};
if (items) {
return {
displayName: items[0],
extra = {
displayName,
componentStack: items
};
}
return extra;
}
async function getImmutableProps(expression, evaluate) {
@ -52,23 +54,10 @@ async function getImmutableProps(expression, evaluate) {
async function getExtraProps(getState, expression, result, evaluate) {
const props = {};
const component = (0, _selectors.inComponent)(getState());
if ((0, _preview.isReactComponent)(result)) {
const selectedFrame = (0, _selectors.getSelectedFrame)(getState());
const source = (0, _selectors.getSource)(getState(), selectedFrame.location.sourceId);
const symbols = (0, _selectors.getSymbols)(getState(), source);
if (symbols && symbols.classes) {
const originalClass = (0, _ast.findClosestClass)(symbols, selectedFrame.location);
if (originalClass) {
props.react = {
displayName: originalClass.name
};
}
}
props.react = _objectSpread({}, (await getReactProps(evaluate)), props.react);
if (component) {
props.react = await getReactProps(evaluate, component);
}
if ((0, _preview.isImmutable)(result)) {

Просмотреть файл

@ -182,6 +182,7 @@ class SearchBar extends _react.Component {
this.traverseResults(e, e.shiftKey);
e.preventDefault();
return this.doSearch(e.target.value);
};
this.renderSearchModifiers = () => {

Просмотреть файл

@ -472,7 +472,7 @@ function mapStateToProps(state) {
const selectedSource = (0, _selectors.getSelectedSource)(state);
return {
enabled: (0, _selectors.getQuickOpenEnabled)(state),
sources: (0, _quickOpen.formatSources)((0, _selectors.getRelativeSources)(state), (0, _selectors.getTabs)(state).toArray()),
sources: (0, _quickOpen.formatSources)((0, _selectors.getRelativeSources)(state).toArray(), (0, _selectors.getTabs)(state).toArray()),
selectedSource,
symbols: (0, _quickOpen.formatSymbols)((0, _selectors.getSymbols)(state, selectedSource)),
symbolsLoading: (0, _selectors.isSymbolsLoading)(state, selectedSource),

Просмотреть файл

@ -3,7 +3,7 @@
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getSelectedSourceText = exports.getSelectedSource = exports.getSelectedLocation = exports.getSourcesForTabs = exports.getSourceTabs = exports.getTabs = exports.getSources = exports.SourceRecordClass = undefined;
exports.getSelectedSourceText = exports.getSelectedSource = exports.getSelectedLocation = exports.getSourcesForTabs = exports.getSourceTabs = exports.getTabs = exports.getSources = exports.RelativeSourceRecordClass = exports.SourceRecordClass = undefined;
exports.initialSourcesState = initialSourcesState;
exports.removeSourceFromTabList = removeSourceFromTabList;
exports.removeSourcesFromTabList = removeSourcesFromTabList;
@ -51,7 +51,7 @@ function initialSourcesState() {
})();
}
const SourceRecordClass = exports.SourceRecordClass = new I.Record({
const sourceRecordProperties = {
id: undefined,
url: undefined,
sourceMapURL: undefined,
@ -62,7 +62,11 @@ const SourceRecordClass = exports.SourceRecordClass = new I.Record({
contentType: "",
error: undefined,
loadedState: "unloaded"
});
};
const SourceRecordClass = exports.SourceRecordClass = new I.Record(sourceRecordProperties);
const RelativeSourceRecordClass = exports.RelativeSourceRecordClass = new I.Record(_objectSpread({}, sourceRecordProperties, {
relativeUrl: undefined
}));
function update(state = initialSourcesState(), action) {
let location = null;

Просмотреть файл

@ -3,16 +3,19 @@
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getRelativeSources = getRelativeSources;
exports.getRelativeSources = undefined;
var _selectors = require("../selectors/index");
var _sources = require("../reducers/sources");
var _source = require("../utils/source");
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
var _reselect = require("devtools/client/debugger/new/dist/vendors").vendored["reselect"];
/* 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/>. */
function getRelativeUrl(url, root) {
if (!root) {
return (0, _source.getSourcePath)(url);
@ -23,19 +26,13 @@ function getRelativeUrl(url, root) {
}
function formatSource(source, root) {
return _objectSpread({}, source, {
relativeUrl: getRelativeUrl(source.url, root)
});
return new _sources.RelativeSourceRecordClass(source).set("relativeUrl", getRelativeUrl(source.url, root));
}
/*
* Gets the sources that are below a project root
*/
function getRelativeSources(state) {
const sources = (0, _selectors.getSources)(state);
const root = (0, _selectors.getProjectDirectoryRoot)(state);
return sources.valueSeq().toJS().filter(({
url
}) => url && url.includes(root)).map(source => formatSource(source, root));
}
const getRelativeSources = exports.getRelativeSources = (0, _reselect.createSelector)(_selectors.getSources, _selectors.getProjectDirectoryRoot, (sources, root) => {
return sources.valueSeq().filter(source => source.url && source.url.includes(root)).map(source => formatSource(source, root));
});

Просмотреть файл

@ -0,0 +1,44 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.inComponent = inComponent;
var _ = require("./index");
var _ast = require("../utils/ast");
var _ast2 = require("../reducers/ast");
/* 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/>. */
function inComponent(state) {
const selectedFrame = (0, _.getSelectedFrame)(state);
const source = (0, _.getSource)(state, selectedFrame.location.sourceId);
const symbols = (0, _.getSymbols)(state, source);
if (!symbols) {
return;
}
const closestClass = (0, _ast.findClosestClass)(symbols, selectedFrame.location);
if (!closestClass) {
return null;
}
const sourceMetaData = (0, _ast2.getSourceMetaData)(state, source.id);
if (!sourceMetaData || !sourceMetaData.framework) {
return;
}
const inReactFile = sourceMetaData.framework == "React";
const isComponent = closestClass.parent && ["Component", "PureComponent"].includes(closestClass.parent.name);
if (inReactFile && isComponent) {
return closestClass.name;
}
}

Просмотреть файл

@ -208,6 +208,15 @@ Object.defineProperty(exports, "getVisibleBreakpoints", {
}
});
var _inComponent = require("./inComponent");
Object.defineProperty(exports, "inComponent", {
enumerable: true,
get: function () {
return _inComponent.inComponent;
}
});
var _isSelectedFrameVisible = require("./isSelectedFrameVisible");
Object.defineProperty(exports, "isSelectedFrameVisible", {

Просмотреть файл

@ -11,6 +11,7 @@ DevToolsModules(
'breakpointAtLocation.js',
'getCallStackFrames.js',
'getRelativeSources.js',
'inComponent.js',
'index.js',
'isSelectedFrameVisible.js',
'visibleBreakpoints.js',

Просмотреть файл

@ -110,5 +110,5 @@ function findClosestClass(symbols, location) {
return null;
}
return findClosestofSymbol(symbols.functions, location);
return findClosestofSymbol(symbols.classes, location);
}

Просмотреть файл

@ -123,7 +123,7 @@ function formatShortcutResults() {
}
function formatSources(sources, tabs) {
return sources.filter(source => !(0, _source.isPretty)(source)).map(source => formatSourcesForList(source, tabs)).filter(({
value
}) => value != "");
return sources.filter(source => !(0, _source.isPretty)(source)).filter(({
relativeUrl
}) => !!relativeUrl).map(source => formatSourcesForList(source, tabs));
}

Просмотреть файл

@ -673,7 +673,7 @@ const reps = [RegExp, StyleSheet, Event, DateTime, CommentNode, ElementNode, Tex
/**
* Generic rep that is used for rendering native JS types or an object.
* The right template used for rendering is picked automatically according
* to the current value type. The value must be passed is as 'object'
* to the current value type. The value must be passed in as the 'object'
* property.
*/
const Rep = function (props) {
@ -2587,6 +2587,10 @@ module.exports = {
"use strict";
const { getValue, nodeHasFullText } = __webpack_require__(3667); /* 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/>. */
async function enumIndexedProperties(objectClient, start, end) {
try {
const { iterator } = await objectClient.enumProperties({
@ -2598,9 +2602,7 @@ async function enumIndexedProperties(objectClient, start, end) {
console.error("Error in enumIndexedProperties", e);
return {};
}
} /* 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/>. */
}
async function enumNonIndexedProperties(objectClient, start, end) {
try {
@ -2645,8 +2647,14 @@ async function getPrototype(objectClient) {
return objectClient.getPrototype();
}
async function getFullText(longStringClient, object) {
const { initial, length } = object;
async function getFullText(longStringClient, item) {
const { initial, fullText, length } = getValue(item);
// Return fullText property if it exists so that it can be added to the
// loadedProperties map.
if (nodeHasFullText(item)) {
return Promise.resolve({ fullText });
}
return new Promise((resolve, reject) => {
longStringClient.substring(initial.length, length, response => {
@ -2753,7 +2761,7 @@ function loadItemProperties(item, createObjectClient, createLongStringClient, lo
}
if (shouldLoadItemFullText(item, loadedProperties)) {
promises.push(getFullText(createLongStringClient(value), value));
promises.push(getFullText(createLongStringClient(value), item));
}
return Promise.all(promises).then(mergeResponses);

Просмотреть файл

@ -392,7 +392,7 @@ void printRange(nsRange *aDomRange)
{
if (!aDomRange)
{
printf("NULL nsIDOMRange\n");
printf("NULL Range\n");
}
nsINode* startNode = aDomRange->GetStartContainer();
nsINode* endNode = aDomRange->GetEndContainer();
@ -1926,7 +1926,7 @@ Selection::SetAncestorLimiter(nsIContent* aLimiter)
}
RangeData*
Selection::FindRangeData(nsIDOMRange* aRange)
Selection::FindRangeData(nsRange* aRange)
{
NS_ENSURE_TRUE(aRange, nullptr);
for (uint32_t i = 0; i < mRanges.Length(); i++) {

Просмотреть файл

@ -595,7 +595,7 @@ private:
nsINode* aEndNode, int32_t aEndOffset,
bool aAllowAdjacent,
int32_t* aStartIndex, int32_t* aEndIndex);
RangeData* FindRangeData(nsIDOMRange* aRange);
RangeData* FindRangeData(nsRange* aRange);
void UserSelectRangesToAdd(nsRange* aItem, nsTArray<RefPtr<nsRange> >& rangesToAdd);

Просмотреть файл

@ -17,7 +17,6 @@
#include "nsISelectionController.h"
#include "nsIDOMNode.h"
#include "nsPIDOMWindow.h"
#include "nsIDOMRange.h"
#include "nsIFormControl.h"
#include "nsITransferable.h"
#include "nsComponentManagerUtils.h"

Просмотреть файл

@ -93,7 +93,7 @@ public:
virtual nsresult Init(nsINode* aRoot) override;
virtual nsresult Init(nsIDOMRange* aRange) override;
virtual nsresult Init(nsRange* aRange) override;
virtual nsresult Init(nsINode* aStartContainer, uint32_t aStartOffset,
nsINode* aEndContainer, uint32_t aEndOffset) override;
@ -259,20 +259,19 @@ nsContentIterator::Init(nsINode* aRoot)
}
nsresult
nsContentIterator::Init(nsIDOMRange* aDOMRange)
nsContentIterator::Init(nsRange* aRange)
{
mIsDone = false;
if (NS_WARN_IF(!aDOMRange)) {
if (NS_WARN_IF(!aRange)) {
return NS_ERROR_INVALID_ARG;
}
nsRange* range = static_cast<nsRange*>(aDOMRange);
if (NS_WARN_IF(!range->IsPositioned())) {
if (NS_WARN_IF(!aRange->IsPositioned())) {
return NS_ERROR_INVALID_ARG;
}
return InitInternal(range->StartRef().AsRaw(), range->EndRef().AsRaw());
return InitInternal(aRange->StartRef().AsRaw(), aRange->EndRef().AsRaw());
}
nsresult
@ -852,7 +851,7 @@ public:
virtual nsresult Init(nsINode* aRoot) override;
virtual nsresult Init(nsIDOMRange* aRange) override;
virtual nsresult Init(nsRange* aRange) override;
virtual nsresult Init(nsINode* aStartContainer, uint32_t aStartOffset,
nsINode* aEndContainer, uint32_t aEndOffset) override;
@ -942,18 +941,17 @@ nsContentSubtreeIterator::Init(nsINode* aRoot)
nsresult
nsContentSubtreeIterator::Init(nsIDOMRange* aRange)
nsContentSubtreeIterator::Init(nsRange* aRange)
{
MOZ_ASSERT(aRange);
mIsDone = false;
nsRange* range = static_cast<nsRange*>(aRange);
if (NS_WARN_IF(!range->IsPositioned())) {
if (NS_WARN_IF(!aRange->IsPositioned())) {
return NS_ERROR_INVALID_ARG;
}
mRange = range;
mRange = aRange;
return InitWithRange();
}

Просмотреть файл

@ -15,7 +15,6 @@
#include "nsWidgetsCID.h"
#include "nsXPCOM.h"
#include "nsISupportsPrimitives.h"
#include "nsIDOMRange.h"
#include "nsRange.h"
#include "imgIContainer.h"
#include "imgIRequest.h"

Просмотреть файл

@ -287,9 +287,9 @@ nsDocumentEncoder::SetSelection(Selection* aSelection)
}
NS_IMETHODIMP
nsDocumentEncoder::SetRange(nsIDOMRange* aRange)
nsDocumentEncoder::SetRange(nsRange* aRange)
{
mRange = static_cast<nsRange*>(aRange);
mRange = aRange;
return NS_OK;
}

Просмотреть файл

@ -18,7 +18,6 @@
#include "nsIContentParent.h"
#include "nsPIDOMWindow.h"
#include "nsIDOMChromeWindow.h"
#include "nsIDOMRange.h"
#include "nsIHTMLDocument.h"
#include "nsIDocShell.h"
#include "nsIDocShellTreeOwner.h"

Просмотреть файл

@ -12,7 +12,7 @@
#include "mozilla/RangeBoundary.h"
class nsINode;
class nsIDOMRange;
class nsRange;
#define NS_ICONTENTITERATOR_IID \
{ 0x2550078e, 0xae87, 0x4914, \
@ -30,7 +30,7 @@ public:
/* Initializes an iterator for the subtree defined by the range aRange
Subclasses should make sure they implement both of these!
*/
virtual nsresult Init(nsIDOMRange* aRange) = 0;
virtual nsresult Init(nsRange* aRange) = 0;
/* Initializes an iterator for the subtree between
aStartContainer/aStartOffset and aEndContainer/aEndOffset

Просмотреть файл

@ -5,12 +5,12 @@
#include "nsISupports.idl"
interface nsIDOMRange;
interface nsIDOMNode;
interface nsIOutputStream;
webidl Selection;
webidl Document;
webidl Range;
%{ C++
class nsINode;
@ -257,7 +257,7 @@ interface nsIDocumentEncoder : nsISupports
* document or selection is encoded.
* @param aRange The range to encode.
*/
void setRange(in nsIDOMRange aRange);
void setRange(in Range aRange);
/**
* If the node is set to a non-null value, then the

Просмотреть файл

@ -101,7 +101,7 @@ nsJSUtils::CompileFunction(AutoJSAPI& jsapi,
JSObject** aFunctionObject)
{
JSContext* cx = jsapi.cx();
MOZ_ASSERT(js::GetEnterCompartmentDepth(cx) > 0);
MOZ_ASSERT(js::GetEnterRealmDepth(cx) > 0);
MOZ_ASSERT_IF(aScopeChain.length() != 0,
js::IsObjectInContextCompartment(aScopeChain[0], cx));

Просмотреть файл

@ -5,7 +5,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/*
* Implementation of the DOM nsIDOMRange object.
* Implementation of the DOM Range object.
*/
#include "nscore.h"
@ -326,31 +326,6 @@ nsRange::CreateRange(nsINode* aStartContainer, uint32_t aStartOffset,
return NS_OK;
}
/* static */
nsresult
nsRange::CreateRange(nsIDOMNode* aStartContainer, uint32_t aStartOffset,
nsIDOMNode* aEndParent, uint32_t aEndOffset,
nsRange** aRange)
{
nsCOMPtr<nsINode> startContainer = do_QueryInterface(aStartContainer);
nsCOMPtr<nsINode> endContainer = do_QueryInterface(aEndParent);
return CreateRange(startContainer, aStartOffset,
endContainer, aEndOffset, aRange);
}
/* static */
nsresult
nsRange::CreateRange(nsIDOMNode* aStartContainer, uint32_t aStartOffset,
nsIDOMNode* aEndParent, uint32_t aEndOffset,
nsIDOMRange** aRange)
{
RefPtr<nsRange> range;
nsresult rv = nsRange::CreateRange(aStartContainer, aStartOffset, aEndParent,
aEndOffset, getter_AddRefs(range));
range.forget(aRange);
return rv;
}
/* static */
nsresult
nsRange::CreateRange(const RawRangeBoundary& aStart,
@ -377,9 +352,8 @@ NS_IMPL_MAIN_THREAD_ONLY_CYCLE_COLLECTING_RELEASE_WITH_LAST_RELEASE(
// QueryInterface implementation for nsRange
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsRange)
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
NS_INTERFACE_MAP_ENTRY(nsIDOMRange)
NS_INTERFACE_MAP_ENTRY(nsIMutationObserver)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMRange)
NS_INTERFACE_MAP_ENTRY(nsISupports)
NS_INTERFACE_MAP_END
NS_IMPL_CYCLE_COLLECTION_CLASS(nsRange)
@ -3156,8 +3130,7 @@ nsRange::GetClientRects(bool aClampToEdge, bool aFlushLayout)
return nullptr;
}
RefPtr<DOMRectList> rectList =
new DOMRectList(static_cast<nsIDOMRange*>(this));
RefPtr<DOMRectList> rectList = new DOMRectList(this);
nsLayoutUtils::RectListBuilder builder(rectList);
@ -3175,7 +3148,7 @@ nsRange::GetClientRectsAndTexts(
return;
}
aResult.mRectList = new DOMRectList(static_cast<nsIDOMRange*>(this));
aResult.mRectList = new DOMRectList(this);
nsLayoutUtils::RectListBuilder builder(aResult.mRectList);

Просмотреть файл

@ -5,13 +5,12 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/*
* Implementation of the DOM nsIDOMRange object.
* Implementation of the DOM Range object.
*/
#ifndef nsRange_h___
#define nsRange_h___
#include "nsIDOMRange.h"
#include "nsCOMPtr.h"
#include "nsINode.h"
#include "nsIDocument.h"
@ -38,8 +37,7 @@ class Selection;
} // namespace dom
} // namespace mozilla
class nsRange final : public nsIDOMRange,
public nsStubMutationObserver,
class nsRange final : public nsStubMutationObserver,
public nsWrapperCache,
// For linking together selection-associated ranges.
public mozilla::LinkedListElement<nsRange>
@ -56,16 +54,6 @@ class nsRange final : public nsIDOMRange,
public:
explicit nsRange(nsINode* aNode);
static nsresult CreateRange(nsIDOMNode* aStartContainer,
uint32_t aStartOffset,
nsIDOMNode* aEndContainer,
uint32_t aEndOffset,
nsRange** aRange);
static nsresult CreateRange(nsIDOMNode* aStartContainer,
uint32_t aStartOffset,
nsIDOMNode* aEndContainer,
uint32_t aEndOffset,
nsIDOMRange** aRange);
static nsresult CreateRange(nsINode* aStartContainer,
uint32_t aStartOffset,
nsINode* aEndContainer,
@ -76,16 +64,13 @@ public:
nsRange** aRange);
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(nsRange, nsIDOMRange)
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(nsRange)
nsrefcnt GetRefCount() const
{
return mRefCnt;
}
// nsIDOMRange interface
NS_DECL_NSIDOMRANGE
nsINode* GetRoot() const
{
return mRoot;
@ -586,10 +571,4 @@ protected:
bool mCalledByJS : 1;
};
inline nsISupports*
ToSupports(nsRange* aRange)
{
return static_cast<nsIDOMRange*>(aRange);
}
#endif /* nsRange_h___ */

Просмотреть файл

@ -28,7 +28,7 @@ catch (e) {
}
<!-- The ok() function tests the first arg -->
ok(passed, "nsIDOMRange.setStartBefore");
ok(passed, "Range.setStartBefore");
</script>
</pre>

Просмотреть файл

@ -22,7 +22,6 @@
#include "nsAtom.h"
#include "nsIContent.h"
#include "nsIDocument.h"
#include "nsIDOMRange.h"
#include "nsIFrame.h"
#include "nsINode.h"
#include "nsIPresShell.h"
@ -30,6 +29,7 @@
#include "nsISupports.h"
#include "nsIWidget.h"
#include "nsPresContext.h"
#include "nsRange.h"
#include "nsRefreshDriver.h"
#include "nsWeakReference.h"
#include "WritingModes.h"

Просмотреть файл

@ -37,6 +37,3 @@ interface nsIDOMEventListener;
// HTML
interface nsIDOMHTMLHeadElement;
// Range
interface nsIDOMRange;

Просмотреть файл

@ -1,21 +0,0 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "domstubs.idl"
/**
* The nsIDOMNodeList interface provides the abstraction of an ordered
* collection of nodes, without defining or constraining how this collection
* is implemented.
* The items in the list are accessible via an integral index, starting from 0.
*
* For more information on this interface please see
* http://www.w3.org/TR/DOM-Level-2-Core/
*/
[shim(NodeList), uuid(450cf0ba-de90-4f86-85bf-e10cc8b8713f)]
interface nsIDOMNodeList : nsISupports
{
};

Просмотреть файл

@ -1,15 +0,0 @@
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# 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/.
with Files("**"):
BUG_COMPONENT = ("Core", "DOM")
XPIDL_SOURCES += [
'nsIDOMRange.idl',
]
XPIDL_MODULE = 'dom_range'

Просмотреть файл

@ -1,18 +0,0 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "domstubs.idl"
/**
* The nsIDOMRange interface is an interface to a DOM range object.
*
* For more information on this interface please see
* http://www.w3.org/TR/DOM-Level-2-Traversal-Range/
*/
[shim(Range), uuid(1f94055c-42e7-4a30-96a1-6a804f1c2d1e)]
interface nsIDOMRange : nsISupports
{
};

Просмотреть файл

@ -2467,6 +2467,11 @@ ContentParent::InitInternal(ProcessPriority aInitialPriority)
nsTArray<BlobURLRegistrationData> registrations;
if (nsHostObjectProtocolHandler::GetAllBlobURLEntries(registrations,
this)) {
for (const BlobURLRegistrationData& registration : registrations) {
nsresult rv = TransmitPermissionsForPrincipal(registration.principal());
Unused << NS_WARN_IF(NS_FAILED(rv));
}
Unused << SendInitBlobURLs(registrations);
}
}
@ -5145,8 +5150,13 @@ ContentParent::BroadcastBlobURLRegistration(const nsACString& aURI,
for (auto* cp : AllProcesses(eLive)) {
if (cp != aIgnoreThisCP) {
nsresult rv = cp->TransmitPermissionsForPrincipal(principal);
if (NS_WARN_IF(NS_FAILED(rv))) {
break;
}
IPCBlob ipcBlob;
nsresult rv = IPCBlobUtils::Serialize(aBlobImpl, cp, ipcBlob);
rv = IPCBlobUtils::Serialize(aBlobImpl, cp, ipcBlob);
if (NS_WARN_IF(NS_FAILED(rv))) {
break;
}

Просмотреть файл

@ -19,7 +19,6 @@ interfaces = [
'html',
'events',
'sidebar',
'range',
'xul',
'security',
'storage',

Просмотреть файл

@ -431,7 +431,6 @@ WebAuthnManager::MakeCredential(const PublicKeyCredentialCreationOptions& aOptio
mTransaction = Some(WebAuthnTransaction(promise,
rpIdHash,
clientDataJSON,
requestDirectAttestation,
signal));
mChild->SendRequestRegister(mTransaction.ref().mId, info);
@ -639,7 +638,6 @@ WebAuthnManager::GetAssertion(const PublicKeyCredentialRequestOptions& aOptions,
mTransaction = Some(WebAuthnTransaction(promise,
rpIdHash,
clientDataJSON,
false /* aDirectAttestation */,
signal));
mChild->SendRequestSign(mTransaction.ref().mId, info);

Просмотреть файл

@ -50,12 +50,10 @@ public:
WebAuthnTransaction(const RefPtr<Promise>& aPromise,
const nsTArray<uint8_t>& aRpIdHash,
const nsCString& aClientData,
bool aDirectAttestation,
AbortSignal* aSignal)
: mPromise(aPromise)
, mRpIdHash(aRpIdHash)
, mClientData(aClientData)
, mDirectAttestation(aDirectAttestation)
, mSignal(aSignal)
, mId(NextId())
{
@ -71,10 +69,6 @@ public:
// Client data used to assemble reply objects.
nsCString mClientData;
// The RP might request direct attestation.
// Only used by the MakeCredential operation.
bool mDirectAttestation;
// An optional AbortSignal instance.
RefPtr<AbortSignal> mSignal;

Просмотреть файл

@ -1167,8 +1167,8 @@ public:
delete static_cast<xpc::ZoneStatsExtras*>(zoneStatsVector[i].extra);
}
for (size_t i = 0; i != compartmentStatsVector.length(); i++) {
delete static_cast<xpc::CompartmentStatsExtras*>(compartmentStatsVector[i].extra);
for (size_t i = 0; i != realmStatsVector.length(); i++) {
delete static_cast<xpc::RealmStatsExtras*>(realmStatsVector[i].extra);
}
}
@ -1196,24 +1196,24 @@ public:
}
virtual void
initExtraCompartmentStats(JSCompartment* aCompartment,
JS::CompartmentStats* aCompartmentStats)
override
initExtraRealmStats(JSCompartment* aCompartment,
JS::RealmStats* aRealmStats)
override
{
MOZ_ASSERT(!aCompartmentStats->extra);
MOZ_ASSERT(!aRealmStats->extra);
// ReportJSRuntimeExplicitTreeStats expects that
// aCompartmentStats->extra is a xpc::CompartmentStatsExtras pointer.
xpc::CompartmentStatsExtras* extras = new xpc::CompartmentStatsExtras;
// aRealmStats->extra is a xpc::RealmStatsExtras pointer.
xpc::RealmStatsExtras* extras = new xpc::RealmStatsExtras;
// This is the |jsPathPrefix|. Each worker has exactly two compartments:
// This is the |jsPathPrefix|. Each worker has exactly two realms:
// one for atoms, and one for everything else.
extras->jsPathPrefix.Assign(mRtPath);
extras->jsPathPrefix += nsPrintfCString("zone(0x%p)/",
(void *)js::GetCompartmentZone(aCompartment));
extras->jsPathPrefix += js::IsAtomsCompartment(aCompartment)
? NS_LITERAL_CSTRING("compartment(web-worker-atoms)/")
: NS_LITERAL_CSTRING("compartment(web-worker)/");
? NS_LITERAL_CSTRING("realm(web-worker-atoms)/")
: NS_LITERAL_CSTRING("realm(web-worker)/");
// This should never be used when reporting with workers (hence the "?!").
extras->domPathPrefix.AssignLiteral("explicit/workers/?!/");
@ -1223,7 +1223,7 @@ public:
extras->location = nullptr;
aCompartmentStats->extra = extras;
aRealmStats->extra = extras;
}
};

Просмотреть файл

@ -40,7 +40,6 @@ class nsITransferable;
class nsIClipboard;
class nsILinkHandler;
class nsTableWrapperFrame;
class nsIDOMRange;
class nsRange;
namespace mozilla {

Просмотреть файл

@ -1388,7 +1388,7 @@ HTMLEditor::SelectBlockOfCells(Element* aStartCell,
RefPtr<Element> cell;
int32_t currentRowIndex, currentColIndex;
nsCOMPtr<nsIDOMRange> range;
RefPtr<nsRange> range;
rv = GetFirstSelectedCell(getter_AddRefs(range), getter_AddRefs(cell));
NS_ENSURE_SUCCESS(rv, rv);
if (rv == NS_SUCCESS_EDITOR_ELEMENT_NOT_FOUND) {
@ -1401,7 +1401,7 @@ HTMLEditor::SelectBlockOfCells(Element* aStartCell,
if (currentRowIndex < maxRow || currentRowIndex > maxRow ||
currentColIndex < maxColumn || currentColIndex > maxColumn) {
selection->RemoveRange(*static_cast<nsRange*>(range.get()), IgnoreErrors());
selection->RemoveRange(*range, IgnoreErrors());
// Since we've removed the range, decrement pointer to next range
mSelectedCellIndex--;
}
@ -2894,7 +2894,7 @@ HTMLEditor::GetCellFromRange(nsRange* aRange,
}
NS_IMETHODIMP
HTMLEditor::GetFirstSelectedCell(nsIDOMRange** aRange,
HTMLEditor::GetFirstSelectedCell(nsRange** aRange,
Element** aCell)
{
NS_ENSURE_TRUE(aCell, NS_ERROR_NULL_POINTER);
@ -2923,8 +2923,7 @@ HTMLEditor::GetFirstSelectedCell(nsIDOMRange** aRange,
}
if (aRange) {
*aRange = range.get();
NS_ADDREF(*aRange);
range.forget(aRange);
}
// Setup for next cell
@ -2934,7 +2933,7 @@ HTMLEditor::GetFirstSelectedCell(nsIDOMRange** aRange,
}
NS_IMETHODIMP
HTMLEditor::GetNextSelectedCell(nsIDOMRange** aRange,
HTMLEditor::GetNextSelectedCell(nsRange** aRange,
Element** aCell)
{
NS_ENSURE_TRUE(aCell, NS_ERROR_NULL_POINTER);
@ -2974,8 +2973,7 @@ HTMLEditor::GetNextSelectedCell(nsIDOMRange** aRange,
NS_ENSURE_TRUE(*aCell, NS_SUCCESS_EDITOR_ELEMENT_NOT_FOUND);
if (aRange) {
*aRange = range.get();
NS_ADDREF(*aRange);
range.forget(aRange);
}
// Setup for next cell

Просмотреть файл

@ -7,10 +7,10 @@
#include "nsISupports.idl"
interface nsIDOMNode;
interface nsIDOMRange;
webidl Element;
webidl Node;
webidl Range;
[scriptable, builtinclass, uuid(4805e684-49b9-11d3-9ce4-ed60bd6cb5bc)]
interface nsITableEditor : nsISupports
@ -282,7 +282,7 @@ interface nsITableEditor : nsISupports
* (in C++: returns NS_EDITOR_ELEMENT_NOT_FOUND if an element is not found
* passes NS_SUCCEEDED macro)
*/
Element getFirstSelectedCell(out nsIDOMRange aRange);
Element getFirstSelectedCell(out Range aRange);
/** Get first selected element in the table
* This is the upper-left-most selected cell in table,
@ -313,5 +313,5 @@ interface nsITableEditor : nsISupports
* (in C++: returns NS_EDITOR_ELEMENT_NOT_FOUND if an element is not found
* passes NS_SUCCEEDED macro)
*/
Element getNextSelectedCell(out nsIDOMRange aRange);
Element getNextSelectedCell(out Range aRange);
};

Просмотреть файл

@ -76,18 +76,17 @@ nsFilteredContentIterator::Init(nsINode* aRoot)
//------------------------------------------------------------
nsresult
nsFilteredContentIterator::Init(nsIDOMRange* aRange)
nsFilteredContentIterator::Init(nsRange* aRange)
{
if (NS_WARN_IF(!aRange)) {
return NS_ERROR_INVALID_ARG;
}
nsRange* range = static_cast<nsRange*>(aRange);
if (NS_WARN_IF(!range->IsPositioned())) {
if (NS_WARN_IF(!aRange->IsPositioned())) {
return NS_ERROR_INVALID_ARG;
}
mRange = range->CloneRange();
mRange = aRange->CloneRange();
return InitWithRange();
}

Просмотреть файл

@ -14,7 +14,6 @@
class nsAtom;
class nsIDOMNode;
class nsIDOMRange;
class nsINode;
class nsITextServicesFilter;
class nsRange;
@ -31,7 +30,7 @@ public:
/* nsIContentIterator */
virtual nsresult Init(nsINode* aRoot) override;
virtual nsresult Init(nsIDOMRange* aRange) override;
virtual nsresult Init(nsRange* aRange) override;
virtual nsresult Init(nsINode* aStartContainer, uint32_t aStartOffset,
nsINode* aEndContainer, uint32_t aEndOffset) override;
virtual nsresult Init(const mozilla::RawRangeBoundary& aStart,

Просмотреть файл

@ -9,6 +9,8 @@
interface nsIEditor;
interface nsIEditorSpellCheck;
webidl Range;
[scriptable, uuid(b7b7a77c-40c4-4196-b0b7-b0338243b3fe)]
interface nsIInlineSpellChecker : nsISupports
{
@ -19,9 +21,9 @@ interface nsIInlineSpellChecker : nsISupports
attribute boolean enableRealTimeSpell;
void spellCheckRange(in nsIDOMRange aSelection);
void spellCheckRange(in Range aSelection);
nsIDOMRange getMisspelledWord(in nsIDOMNode aNode, in long aOffset);
Range getMisspelledWord(in nsIDOMNode aNode, in long aOffset);
void replaceWord(in nsIDOMNode aNode, in long aOffset, in AString aNewword);
void addWordToDictionary(in AString aWord);
void removeWordFromDictionary(in AString aWord);

Просмотреть файл

@ -899,7 +899,7 @@ mozInlineSpellChecker::SpellCheckAfterEditorChange(
// Supply a nullptr range and this will check the entire editor.
nsresult
mozInlineSpellChecker::SpellCheckRange(nsIDOMRange* aRange)
mozInlineSpellChecker::SpellCheckRange(nsRange* aRange)
{
if (!mSpellCheck) {
NS_WARNING_ASSERTION(
@ -909,8 +909,7 @@ mozInlineSpellChecker::SpellCheckRange(nsIDOMRange* aRange)
}
auto status = MakeUnique<mozInlineSpellStatus>(this);
nsRange* range = static_cast<nsRange*>(aRange);
nsresult rv = status->InitForRange(range);
nsresult rv = status->InitForRange(aRange);
NS_ENSURE_SUCCESS(rv, rv);
return ScheduleSpellCheck(Move(status));
}
@ -919,7 +918,7 @@ mozInlineSpellChecker::SpellCheckRange(nsIDOMRange* aRange)
NS_IMETHODIMP
mozInlineSpellChecker::GetMisspelledWord(nsIDOMNode *aNode, int32_t aOffset,
nsIDOMRange **newword)
nsRange** newword)
{
if (NS_WARN_IF(!aNode)) {
return NS_ERROR_INVALID_ARG;
@ -941,7 +940,7 @@ mozInlineSpellChecker::ReplaceWord(nsIDOMNode *aNode, int32_t aOffset,
return NS_ERROR_FAILURE;
}
nsCOMPtr<nsIDOMRange> range;
RefPtr<nsRange> range;
nsresult res = GetMisspelledWord(aNode, aOffset, getter_AddRefs(range));
NS_ENSURE_SUCCESS(res, res);
@ -950,7 +949,7 @@ mozInlineSpellChecker::ReplaceWord(nsIDOMNode *aNode, int32_t aOffset,
// This range was retrieved from the spellchecker selection. As
// ranges cannot be shared between selections, we must clone it
// before adding it to the editor's selection.
RefPtr<nsRange> editorRange = static_cast<nsRange*>(range.get())->CloneRange();
RefPtr<nsRange> editorRange = range->CloneRange();
AutoPlaceholderBatch phb(mTextEditor, nullptr);
@ -1619,7 +1618,7 @@ nsresult
mozInlineSpellChecker::IsPointInSelection(Selection& aSelection,
nsIDOMNode *aNode,
int32_t aOffset,
nsIDOMRange **aRange)
nsRange** aRange)
{
*aRange = nullptr;

Просмотреть файл

@ -228,7 +228,7 @@ public:
nsresult IsPointInSelection(mozilla::dom::Selection& aSelection,
nsIDOMNode *aNode,
int32_t aOffset,
nsIDOMRange **aRange);
nsRange** aRange);
nsresult CleanupRangesInSelection(mozilla::dom::Selection *aSelection);

Просмотреть файл

@ -347,8 +347,9 @@ public:
return Oblique(angle);
}
// Not recognized as an oblique angle; maybe it's from a startup-cache
// created by an older version. Just treat it as 'normal'.
return Normal();
// created by an older version. The style field there used a simple 0/1
// for normal/italic respectively.
return aString[0] == '0' ? Normal() : Italic();
}
}

Просмотреть файл

@ -87,12 +87,12 @@ public:
const nsRect& aRect) { return false; }
/**
* Get the computed CSS border for the widget, in pixels.
* Get the border for the widget, in device pixels.
*/
NS_IMETHOD GetWidgetBorder(nsDeviceContext* aContext,
nsIFrame* aFrame,
uint8_t aWidgetType,
nsIntMargin* aResult)=0;
mozilla::LayoutDeviceIntMargin* aResult) = 0;
/**
* This method can return false to indicate that the CSS padding
@ -106,7 +106,7 @@ public:
virtual bool GetWidgetPadding(nsDeviceContext* aContext,
nsIFrame* aFrame,
uint8_t aWidgetType,
nsIntMargin* aResult) = 0;
mozilla::LayoutDeviceIntMargin* aResult) = 0;
/**
* On entry, *aResult is positioned at 0,0 and sized to the new size

Просмотреть файл

@ -1006,7 +1006,7 @@ gfxFT2FontList::AppendFacesFromCachedFaceList(
int32_t colon = minStyle.FindChar(':');
if (colon > 0) {
maxStyle.Assign(minStyle.BeginReading() + colon + 1);
minStyle.Truncate(colon - 1);
minStyle.Truncate(colon);
}
beginning = end + 1;
@ -1060,7 +1060,11 @@ AppendToFaceList(nsCString& aFaceList,
aFaceList.Append(',');
aFaceList.AppendInt(aFontEntry->mFTFontIndex);
aFaceList.Append(',');
aFaceList.Append(aFontEntry->IsItalic() ? '1' : '0');
// Note that ToString() appends to the destination string without
// replacing existing contents (see FontPropertyTypes.h)
aFontEntry->SlantStyle().Min().ToString(aFaceList);
aFaceList.Append(':');
aFontEntry->SlantStyle().Max().ToString(aFaceList);
aFaceList.Append(',');
aFaceList.AppendFloat(aFontEntry->Weight().Min().ToFloat());
aFaceList.Append(':');

Просмотреть файл

@ -799,7 +799,7 @@ struct ZoneStats
#undef FOR_EACH_SIZE
};
struct CompartmentStats
struct RealmStats
{
// We assume that |objectsPrivate| is on the malloc heap, but it's not
// actually guaranteed. But for Servo, at least, it's a moot point because
@ -816,8 +816,8 @@ struct CompartmentStats
macro(Other, MallocHeap, typeInferenceAllocationSiteTables) \
macro(Other, MallocHeap, typeInferenceArrayTypeTables) \
macro(Other, MallocHeap, typeInferenceObjectTypeTables) \
macro(Other, MallocHeap, compartmentObject) \
macro(Other, MallocHeap, compartmentTables) \
macro(Other, MallocHeap, realmObject) \
macro(Other, MallocHeap, realmTables) \
macro(Other, MallocHeap, innerViewsTable) \
macro(Other, MallocHeap, lazyArrayBuffersTable) \
macro(Other, MallocHeap, objectMetadataTable) \
@ -825,11 +825,11 @@ struct CompartmentStats
macro(Other, MallocHeap, savedStacksSet) \
macro(Other, MallocHeap, varNamesSet) \
macro(Other, MallocHeap, nonSyntacticLexicalScopesTable) \
macro(Other, MallocHeap, jitCompartment) \
macro(Other, MallocHeap, jitRealm) \
macro(Other, MallocHeap, privateData) \
macro(Other, MallocHeap, scriptCountsMap)
CompartmentStats()
RealmStats()
: FOR_EACH_SIZE(ZERO_SIZE)
classInfo(),
extra(),
@ -838,7 +838,7 @@ struct CompartmentStats
isTotals(true)
{}
CompartmentStats(CompartmentStats&& other)
RealmStats(RealmStats&& other)
: FOR_EACH_SIZE(COPY_OTHER_SIZE)
classInfo(mozilla::Move(other.classInfo)),
extra(other.extra),
@ -850,9 +850,9 @@ struct CompartmentStats
MOZ_ASSERT(!other.isTotals);
}
CompartmentStats(const CompartmentStats&) = delete; // disallow copying
RealmStats(const RealmStats&) = delete; // disallow copying
~CompartmentStats() {
~RealmStats() {
// |allClasses| is usually deleted and set to nullptr before this
// destructor runs. But there are failure cases due to OOMs that may
// prevent that, so it doesn't hurt to try again here.
@ -861,7 +861,7 @@ struct CompartmentStats
bool initClasses();
void addSizes(const CompartmentStats& other) {
void addSizes(const RealmStats& other) {
MOZ_ASSERT(isTotals);
FOR_EACH_SIZE(ADD_OTHER_SIZE)
classInfo.add(other.classInfo);
@ -906,7 +906,7 @@ struct CompartmentStats
#undef FOR_EACH_SIZE
};
typedef js::Vector<CompartmentStats, 0, js::SystemAllocPolicy> CompartmentStatsVector;
typedef js::Vector<RealmStats, 0, js::SystemAllocPolicy> RealmStatsVector;
typedef js::Vector<ZoneStats, 0, js::SystemAllocPolicy> ZoneStatsVector;
struct RuntimeStats
@ -927,9 +927,9 @@ struct RuntimeStats
explicit RuntimeStats(mozilla::MallocSizeOf mallocSizeOf)
: FOR_EACH_SIZE(ZERO_SIZE)
runtime(),
cTotals(),
realmTotals(),
zTotals(),
compartmentStatsVector(),
realmStatsVector(),
zoneStatsVector(),
currZoneStats(nullptr),
mallocSizeOf_(mallocSizeOf)
@ -964,17 +964,17 @@ struct RuntimeStats
RuntimeSizes runtime;
CompartmentStats cTotals; // The sum of this runtime's compartments' measurements.
RealmStats realmTotals; // The sum of this runtime's realms' measurements.
ZoneStats zTotals; // The sum of this runtime's zones' measurements.
CompartmentStatsVector compartmentStatsVector;
RealmStatsVector realmStatsVector;
ZoneStatsVector zoneStatsVector;
ZoneStats* currZoneStats;
mozilla::MallocSizeOf mallocSizeOf_;
virtual void initExtraCompartmentStats(JSCompartment* c, CompartmentStats* cstats) = 0;
virtual void initExtraRealmStats(JSCompartment* c, RealmStats* rstats) = 0;
virtual void initExtraZoneStats(JS::Zone* zone, ZoneStats* zstats) = 0;
#undef FOR_EACH_SIZE
@ -1004,10 +1004,10 @@ extern JS_PUBLIC_API(bool)
CollectRuntimeStats(JSContext* cx, RuntimeStats* rtStats, ObjectPrivateVisitor* opv, bool anonymize);
extern JS_PUBLIC_API(size_t)
SystemCompartmentCount(JSContext* cx);
SystemRealmCount(JSContext* cx);
extern JS_PUBLIC_API(size_t)
UserCompartmentCount(JSContext* cx);
UserRealmCount(JSContext* cx);
extern JS_PUBLIC_API(size_t)
PeakSizeOfTemporary(const JSContext* cx);

Просмотреть файл

@ -22,6 +22,7 @@
#include "js/GCPolicyAPI.h"
#include "js/HeapAPI.h"
#include "js/ProfilingStack.h"
#include "js/Realm.h"
#include "js/TypeDecls.h"
#include "js/UniquePtr.h"
#include "js/Utility.h"
@ -827,8 +828,8 @@ class RootingContext
// JSContext pointers. They are unrelated to rooting and are in place so
// that inlined API functions can directly access the data.
/* The current compartment. */
JSCompartment* compartment_;
/* The current realm. */
JS::Realm* realm_;
/* The current zone. */
JS::Zone* zone_;
@ -1018,7 +1019,7 @@ namespace js {
inline JSCompartment*
GetContextCompartment(const JSContext* cx)
{
return JS::RootingContext::get(cx)->compartment_;
return GetCompartmentForRealm(JS::RootingContext::get(cx)->realm_);
}
inline JS::Zone*

Просмотреть файл

@ -611,7 +611,7 @@ impl GCMethods for JS::Value {
impl Drop for JSAutoRealm {
fn drop(&mut self) {
unsafe { JS::LeaveRealm(self.cx_, self.oldCompartment_); }
unsafe { JS::LeaveRealm(self.cx_, self.oldRealm_); }
}
}

Просмотреть файл

@ -151,6 +151,7 @@ using JS::HandleValueArray;
using JS::ObjectOpResult;
using JS::PropertyResult;
using JS::Realm;
using JS::Zone;
using JS::Symbol;

Просмотреть файл

@ -3294,7 +3294,7 @@ static bool
SharedMemoryEnabled(JSContext* cx, unsigned argc, Value* vp)
{
CallArgs args = CallArgsFromVp(argc, vp);
args.rval().setBoolean(cx->compartment()->creationOptions().getSharedMemoryAndAtomicsEnabled());
args.rval().setBoolean(cx->realm()->creationOptions().getSharedMemoryAndAtomicsEnabled());
return true;
}
@ -4125,7 +4125,7 @@ SetLazyParsingDisabled(JSContext* cx, unsigned argc, Value* vp)
CallArgs args = CallArgsFromVp(argc, vp);
bool disable = !args.hasDefined(0) || ToBoolean(args[0]);
cx->compartment()->behaviors().setDisableLazyParsing(disable);
cx->realm()->behaviors().setDisableLazyParsing(disable);
args.rval().setUndefined();
return true;
@ -4137,7 +4137,7 @@ SetDiscardSource(JSContext* cx, unsigned argc, Value* vp)
CallArgs args = CallArgsFromVp(argc, vp);
bool discard = !args.hasDefined(0) || ToBoolean(args[0]);
cx->compartment()->behaviors().setDiscardSource(discard);
cx->realm()->behaviors().setDiscardSource(discard);
args.rval().setUndefined();
return true;

Просмотреть файл

@ -193,7 +193,7 @@ BytecodeCompiler::createScriptSource(const Maybe<uint32_t>& parameterListEnd)
scriptSource = sourceObject->source();
if (!cx->compartment()->behaviors().discardSource()) {
if (!cx->realm()->behaviors().discardSource()) {
if (options.sourceIsLazy) {
scriptSource->setSourceRetrievable();
} else if (!scriptSource->setSourceCopy(cx, sourceBuffer)) {
@ -208,8 +208,8 @@ bool
BytecodeCompiler::canLazilyParse()
{
return options.canLazilyParse &&
!cx->compartment()->behaviors().disableLazyParsing() &&
!cx->compartment()->behaviors().discardSource() &&
!cx->realm()->behaviors().disableLazyParsing() &&
!cx->realm()->behaviors().discardSource() &&
!options.sourceIsLazy &&
!cx->lcovEnabled();
}

Просмотреть файл

@ -90,7 +90,7 @@ static void
jsfuzz_uninit(JSContext* cx, JSCompartment* oldCompartment)
{
if (oldCompartment) {
JS::LeaveRealm(cx, oldCompartment);
JS::LeaveRealm(cx, JS::GetRealmForCompartment(oldCompartment));
oldCompartment = nullptr;
}
if (cx) {

Просмотреть файл

@ -1334,7 +1334,7 @@ GCRuntime::finish()
AutoSetThreadIsSweeping threadIsSweeping;
for (ZonesIter zone(rt, WithAtoms); !zone.done(); zone.next()) {
for (CompartmentsInZoneIter comp(zone); !comp.done(); comp.next())
js_delete(comp.get());
js_delete(JS::GetRealmForCompartment(comp.get()));
zone->compartments().clear();
js_delete(zone.get());
}
@ -3803,11 +3803,11 @@ JS::Zone::sweepUniqueIds()
}
void
JSCompartment::destroy(FreeOp* fop)
Realm::destroy(FreeOp* fop)
{
JSRuntime* rt = fop->runtime();
if (auto callback = rt->destroyRealmCallback)
callback(fop, JS::GetRealmForCompartment(this));
callback(fop, this);
if (auto callback = rt->destroyCompartmentCallback)
callback(fop, this);
if (principals())
@ -3853,7 +3853,7 @@ Zone::sweepCompartments(FreeOp* fop, bool keepAtleastOne, bool destroyingRuntime
*/
bool dontDelete = read == end && !foundOne && keepAtleastOne;
if ((!comp->marked && !dontDelete) || destroyingRuntime) {
comp->destroy(fop);
JS::GetRealmForCompartment(comp)->destroy(fop);
} else {
*write++ = comp;
foundOne = true;
@ -4047,7 +4047,7 @@ GCRuntime::shouldPreserveJITCode(JSCompartment* comp, int64_t currentTime,
if (alwaysPreserveCode)
return true;
if (comp->preserveJitCode())
if (JS::GetRealmForCompartment(comp)->preserveJitCode())
return true;
if (comp->lastAnimationTime + PRMJ_USEC_PER_SEC >= currentTime)
return true;
@ -7949,7 +7949,7 @@ js::NewCompartment(JSContext* cx, JSPrincipals* principals,
}
}
ScopedJSDeletePtr<JSCompartment> compartment(cx->new_<JSCompartment>(zone, options));
ScopedJSDeletePtr<Realm> compartment(cx->new_<Realm>(zone, options));
if (!compartment || !compartment->init(cx))
return nullptr;
@ -7994,10 +7994,11 @@ gc::MergeCompartments(JSCompartment* source, JSCompartment* target)
void
GCRuntime::mergeCompartments(JSCompartment* source, JSCompartment* target)
{
// The source compartment must be specifically flagged as mergable. This
// also implies that the compartment is not visible to the debugger.
MOZ_ASSERT(source->creationOptions_.mergeable());
MOZ_ASSERT(source->creationOptions_.invisibleToDebugger());
// The source realm must be specifically flagged as mergable. This
// also implies that the realm is not visible to the debugger.
mozilla::DebugOnly<Realm*> sourceRealm = JS::GetRealmForCompartment(source);
MOZ_ASSERT(sourceRealm->creationOptions().mergeable());
MOZ_ASSERT(sourceRealm->creationOptions().invisibleToDebugger());
MOZ_ASSERT(!source->hasBeenEntered());
MOZ_ASSERT(source->zone()->compartments().length() == 1);
@ -8031,7 +8032,7 @@ GCRuntime::mergeCompartments(JSCompartment* source, JSCompartment* target)
for (auto script = source->zone()->cellIter<JSScript>(); !script.done(); script.next()) {
MOZ_ASSERT(script->compartment() == source);
script->compartment_ = target;
script->realm_ = JS::GetRealmForCompartment(target);
script->setTypesGeneration(target->zone()->types.generation);
}
@ -8056,7 +8057,7 @@ GCRuntime::mergeCompartments(JSCompartment* source, JSCompartment* target)
}
group->setGeneration(target->zone()->types.generation);
group->compartment_ = target;
group->realm_ = JS::GetRealmForCompartment(target);
// Remove any unboxed layouts from the list in the off thread
// compartment. These do not need to be reinserted in the target

Просмотреть файл

@ -397,7 +397,7 @@ Zone::deleteEmptyCompartment(JSCompartment* comp)
for (auto& i : compartments()) {
if (i == comp) {
compartments().erase(&i);
comp->destroy(runtimeFromMainThread()->defaultFreeOp());
JS::GetRealmForCompartment(comp)->destroy(runtimeFromMainThread()->defaultFreeOp());
return;
}
}

Просмотреть файл

@ -1660,8 +1660,7 @@ static const VMFunction DeepCloneObjectLiteralInfo =
bool
BaselineCompiler::emit_JSOP_OBJECT()
{
JSCompartment* comp = cx->compartment();
if (comp->creationOptions().cloneSingletons()) {
if (cx->realm()->creationOptions().cloneSingletons()) {
RootedObject obj(cx, script->getObject(GET_UINT32_INDEX(pc)));
if (!obj)
return false;
@ -1680,7 +1679,7 @@ BaselineCompiler::emit_JSOP_OBJECT()
return true;
}
comp->behaviors().setSingletonsAsValues();
cx->realm()->behaviors().setSingletonsAsValues();
frame.push(ObjectValue(*script->getObject(pc)));
return true;
}

Просмотреть файл

@ -136,7 +136,7 @@ EnterBaseline(JSContext* cx, EnterJitData& data)
data.result.setInt32(data.numActualArgs);
{
AssertCompartmentUnchanged pcc(cx);
AssertRealmUnchanged aru(cx);
ActivationEntryMonitor entryMonitor(cx, data.calleeToken);
JitActivation activation(cx);

Просмотреть файл

@ -473,7 +473,7 @@ IsCacheableNoProperty(JSContext* cx, JSObject* obj, JSObject* holder, Shape* sha
// If we're doing a name lookup, we have to throw a ReferenceError. If
// extra warnings are enabled, we may have to report a warning.
// Note that Ion does not generate idempotent caches for JSOP_GETBOUNDNAME.
if ((pc && *pc == JSOP_GETBOUNDNAME) || cx->compartment()->behaviors().extraWarnings(cx))
if ((pc && *pc == JSOP_GETBOUNDNAME) || cx->realm()->behaviors().extraWarnings(cx))
return false;
return CheckHasNoSuchProperty(cx, obj, id);

Просмотреть файл

@ -2537,8 +2537,8 @@ CodeGenerator::visitRegExpPrototypeOptimizable(LRegExpPrototypeOptimizable* ins)
addOutOfLineCode(ool, ins->mir());
masm.loadJSContext(temp);
masm.loadPtr(Address(temp, JSContext::offsetOfCompartment()), temp);
size_t offset = JSCompartment::offsetOfRegExps() +
masm.loadPtr(Address(temp, JSContext::offsetOfRealm()), temp);
size_t offset = Realm::offsetOfRegExps() +
RegExpCompartment::offsetOfOptimizableRegExpPrototypeShape();
masm.loadPtr(Address(temp, offset), temp);
@ -2597,8 +2597,8 @@ CodeGenerator::visitRegExpInstanceOptimizable(LRegExpInstanceOptimizable* ins)
addOutOfLineCode(ool, ins->mir());
masm.loadJSContext(temp);
masm.loadPtr(Address(temp, JSContext::offsetOfCompartment()), temp);
size_t offset = JSCompartment::offsetOfRegExps() +
masm.loadPtr(Address(temp, JSContext::offsetOfRealm()), temp);
size_t offset = Realm::offsetOfRegExps() +
RegExpCompartment::offsetOfOptimizableRegExpInstanceShape();
masm.loadPtr(Address(temp, offset), temp);

Просмотреть файл

@ -291,7 +291,7 @@ CompileCompartment::hasAllocationMetadataBuilder()
void
CompileCompartment::setSingletonsAsValues()
{
compartment()->behaviors().setSingletonsAsValues();
JS::GetRealmForCompartment(compartment())->behaviors().setSingletonsAsValues();
}
JitCompileOptions::JitCompileOptions()
@ -303,7 +303,7 @@ JitCompileOptions::JitCompileOptions()
JitCompileOptions::JitCompileOptions(JSContext* cx)
{
cloneSingletons_ = cx->compartment()->creationOptions().cloneSingletons();
cloneSingletons_ = cx->realm()->creationOptions().cloneSingletons();
profilerSlowAssertionsEnabled_ = cx->runtime()->geckoProfiler().enabled() &&
cx->runtime()->geckoProfiler().slowAssertionsEnabled();
offThreadCompilationAvailable_ = OffThreadCompilationAvailable(cx);

Просмотреть файл

@ -88,7 +88,7 @@ EnterJit(JSContext* cx, RunState& state, uint8_t* code)
RootedValue result(cx, Int32Value(numActualArgs));
{
AssertCompartmentUnchanged pcc(cx);
AssertRealmUnchanged aru(cx);
ActivationEntryMonitor entryMonitor(cx, calleeToken);
JitActivation activation(cx);
EnterJitCode enter = cx->runtime()->jitRuntime()->enterJit();

Просмотреть файл

@ -3275,7 +3275,7 @@ MacroAssembler::branchTestObjCompartment(Condition cond, Register obj, const Add
{
MOZ_ASSERT(obj != scratch);
loadPtr(Address(obj, JSObject::offsetOfGroup()), scratch);
loadPtr(Address(scratch, ObjectGroup::offsetOfCompartment()), scratch);
loadPtr(Address(scratch, ObjectGroup::offsetOfRealm()), scratch);
branchPtr(cond, compartment, scratch, label);
}
@ -3286,7 +3286,7 @@ MacroAssembler::branchTestObjCompartment(Condition cond, Register obj,
{
MOZ_ASSERT(obj != scratch);
loadPtr(Address(obj, JSObject::offsetOfGroup()), scratch);
loadPtr(Address(scratch, ObjectGroup::offsetOfCompartment()), scratch);
loadPtr(Address(scratch, ObjectGroup::offsetOfRealm()), scratch);
branchPtr(cond, scratch, ImmPtr(compartment), label);
}

Просмотреть файл

@ -115,7 +115,7 @@ template<JSObject* CreateWithBuffer(JSContext*, JS::HandleObject, uint32_t, int3
bool
TestArrayFromBuffer(JSContext* cx)
{
if (Shared && !cx->compartment()->creationOptions().getSharedMemoryAndAtomicsEnabled())
if (Shared && !cx->realm()->creationOptions().getSharedMemoryAndAtomicsEnabled())
return true;
size_t elts = 8;

Просмотреть файл

@ -33,7 +33,7 @@ bool JSAPITest::init()
void JSAPITest::uninit()
{
if (oldCompartment) {
JS::LeaveRealm(cx, oldCompartment);
JS::LeaveRealm(cx, JS::GetRealmForCompartment(oldCompartment));
oldCompartment = nullptr;
}
if (global) {

Просмотреть файл

@ -680,61 +680,61 @@ JS::EnterRealm(JSContext* cx, JSObject* target)
AssertHeapIsIdle();
CHECK_REQUEST(cx);
JSCompartment* oldCompartment = cx->compartment();
cx->enterCompartmentOf(target);
return oldCompartment;
Realm* oldRealm = cx->realm();
cx->enterRealmOf(target);
return JS::GetRealmForCompartment(oldRealm);
}
JS_PUBLIC_API(void)
JS::LeaveRealm(JSContext* cx, JSCompartment* oldRealm)
JS::LeaveRealm(JSContext* cx, JS::Realm* oldRealm)
{
AssertHeapIsIdle();
CHECK_REQUEST(cx);
cx->leaveCompartment(oldRealm);
cx->leaveRealm(oldRealm);
}
JSAutoRealm::JSAutoRealm(JSContext* cx, JSObject* target
MOZ_GUARD_OBJECT_NOTIFIER_PARAM_IN_IMPL)
: cx_(cx),
oldCompartment_(cx->compartment())
oldRealm_(cx->realm())
{
AssertHeapIsIdleOrIterating();
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
cx_->enterCompartmentOf(target);
cx_->enterRealmOf(target);
}
JSAutoRealm::JSAutoRealm(JSContext* cx, JSScript* target
MOZ_GUARD_OBJECT_NOTIFIER_PARAM_IN_IMPL)
: cx_(cx),
oldCompartment_(cx->compartment())
oldRealm_(cx->realm())
{
AssertHeapIsIdleOrIterating();
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
cx_->enterCompartmentOf(target);
cx_->enterRealmOf(target);
}
JSAutoRealm::~JSAutoRealm()
{
cx_->leaveCompartment(oldCompartment_);
cx_->leaveRealm(oldRealm_);
}
JSAutoNullableRealm::JSAutoNullableRealm(JSContext* cx,
JSObject* targetOrNull
MOZ_GUARD_OBJECT_NOTIFIER_PARAM_IN_IMPL)
: cx_(cx),
oldCompartment_(cx->compartment())
oldRealm_(cx->realm())
{
AssertHeapIsIdleOrIterating();
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
if (targetOrNull)
cx_->enterCompartmentOf(targetOrNull);
cx_->enterRealmOf(targetOrNull);
else
cx_->enterNullCompartment();
cx_->enterNullRealm();
}
JSAutoNullableRealm::~JSAutoNullableRealm()
{
cx_->leaveCompartment(oldCompartment_);
cx_->leaveRealm(oldRealm_);
}
JS_PUBLIC_API(void)
@ -1869,19 +1869,19 @@ JS::RealmCreationOptions::setNewZone()
const JS::RealmCreationOptions&
JS::RealmCreationOptionsRef(JSCompartment* compartment)
{
return compartment->creationOptions();
return JS::GetRealmForCompartment(compartment)->creationOptions();
}
const JS::RealmCreationOptions&
JS::RealmCreationOptionsRef(JSObject* obj)
{
return obj->compartment()->creationOptions();
return obj->realm()->creationOptions();
}
const JS::RealmCreationOptions&
JS::RealmCreationOptionsRef(JSContext* cx)
{
return cx->compartment()->creationOptions();
return cx->realm()->creationOptions();
}
bool
@ -1906,19 +1906,19 @@ JS::RealmCreationOptions::setSharedMemoryAndAtomicsEnabled(bool flag)
JS::RealmBehaviors&
JS::RealmBehaviorsRef(JSCompartment* compartment)
{
return compartment->behaviors();
return JS::GetRealmForCompartment(compartment)->behaviors();
}
JS::RealmBehaviors&
JS::RealmBehaviorsRef(JSObject* obj)
{
return obj->compartment()->behaviors();
return obj->realm()->behaviors();
}
JS::RealmBehaviors&
JS::RealmBehaviorsRef(JSContext* cx)
{
return cx->compartment()->behaviors();
return cx->realm()->behaviors();
}
JS_PUBLIC_API(JSObject*)
@ -1955,7 +1955,7 @@ JS_GlobalObjectTraceHook(JSTracer* trc, JSObject* global)
// we know the global is live.
global->compartment()->traceGlobal(trc);
if (JSTraceOp trace = global->compartment()->creationOptions().getTrace())
if (JSTraceOp trace = global->realm()->creationOptions().getTrace())
trace(trc, global);
}
@ -4064,7 +4064,7 @@ JS::CompileOptions::CompileOptions(JSContext* cx)
introductionScriptRoot(cx)
{
strictOption = cx->options().strictMode();
extraWarningsOption = cx->compartment()->behaviors().extraWarnings(cx);
extraWarningsOption = cx->realm()->behaviors().extraWarnings(cx);
isProbablySystemCode = cx->compartment()->isProbablySystemCode();
werrorOption = cx->options().werror();
if (!cx->options().asmJS())

Просмотреть файл

@ -1064,7 +1064,7 @@ JS_RefreshCrossCompartmentWrappers(JSContext* cx, JS::Handle<JSObject*> obj);
class MOZ_RAII JS_PUBLIC_API(JSAutoRealm)
{
JSContext* cx_;
JSCompartment* oldCompartment_;
JS::Realm* oldRealm_;
public:
JSAutoRealm(JSContext* cx, JSObject* target MOZ_GUARD_OBJECT_NOTIFIER_PARAM);
JSAutoRealm(JSContext* cx, JSScript* target MOZ_GUARD_OBJECT_NOTIFIER_PARAM);
@ -1076,7 +1076,7 @@ class MOZ_RAII JS_PUBLIC_API(JSAutoRealm)
class MOZ_RAII JS_PUBLIC_API(JSAutoNullableRealm)
{
JSContext* cx_;
JSCompartment* oldCompartment_;
JS::Realm* oldRealm_;
public:
explicit JSAutoNullableRealm(JSContext* cx, JSObject* targetOrNull
MOZ_GUARD_OBJECT_NOTIFIER_PARAM);
@ -1096,7 +1096,7 @@ extern JS_PUBLIC_API(JSCompartment*)
EnterRealm(JSContext* cx, JSObject* target);
extern JS_PUBLIC_API(void)
LeaveRealm(JSContext* cx, JSCompartment* oldRealm);
LeaveRealm(JSContext* cx, JS::Realm* oldRealm);
} // namespace JS

Просмотреть файл

@ -39,7 +39,7 @@ using mozilla::Move;
using mozilla::PodArrayZero;
JS::RootingContext::RootingContext()
: autoGCRooters_(nullptr), compartment_(nullptr), zone_(nullptr)
: autoGCRooters_(nullptr), realm_(nullptr), zone_(nullptr)
{
for (auto& stackRootPtr : stackRoots_)
stackRootPtr = nullptr;
@ -149,7 +149,7 @@ JS_NewObjectWithoutMetadata(JSContext* cx, const JSClass* clasp, JS::Handle<JSOb
JS_FRIEND_API(bool)
JS_GetIsSecureContext(JSCompartment* compartment)
{
return compartment->creationOptions().secureContext();
return JS::GetRealmForCompartment(compartment)->creationOptions().secureContext();
}
JS_FRIEND_API(JSPrincipals*)
@ -1312,9 +1312,9 @@ js::GetTestingFunctions(JSContext* cx)
#ifdef DEBUG
JS_FRIEND_API(unsigned)
js::GetEnterCompartmentDepth(JSContext* cx)
js::GetEnterRealmDepth(JSContext* cx)
{
return cx->getEnterCompartmentDepth();
return cx->getEnterRealmDepth();
}
#endif

Просмотреть файл

@ -1202,7 +1202,7 @@ GetErrorTypeName(JSContext* cx, int16_t exnType);
#ifdef JS_DEBUG
extern JS_FRIEND_API(unsigned)
GetEnterCompartmentDepth(JSContext* cx);
GetEnterRealmDepth(JSContext* cx);
#endif
extern JS_FRIEND_API(RegExpShared*)

Просмотреть файл

@ -5732,7 +5732,7 @@ GetSharedArrayBuffer(JSContext* cx, unsigned argc, Value* vp)
// Shared memory is enabled globally in the shell: there can't be a worker
// that does not enable it if the main thread has it.
MOZ_ASSERT(cx->compartment()->creationOptions().getSharedMemoryAndAtomicsEnabled());
MOZ_ASSERT(cx->realm()->creationOptions().getSharedMemoryAndAtomicsEnabled());
newObj = SharedArrayBufferObject::New(cx, buf, mbx->length);
if (!newObj) {

Просмотреть файл

@ -91,17 +91,25 @@ js::ToClampedIndex(JSContext* cx, HandleValue v, uint32_t length, uint32_t* out)
// bug 1068684, bug 1073934 for details. The limiting case seems to be
// Windows Vista Home 64-bit, where the per-process address space is limited
// to 8TB. Thus we track the number of live objects, and set a limit of
// 1000 live objects per process; we run synchronous GC if necessary; and
// we throw an OOM error if the per-process limit is exceeded.
// 1000 live objects per process and we throw an OOM error if the per-process
// limit is exceeded.
//
// Since the MaximumLiveMappedBuffers limit is not generally accounted for by
// any existing GC-trigger heuristics, we need an extra heuristic for triggering
// GCs when the caller is allocating memories rapidly without other garbage.
// Thus, once the live buffer count crosses a certain threshold, we start
// triggering GCs every N allocations.
// triggering GCs every N allocations. As we get close to the limit, perform
// expensive non-incremental full GCs as a last-ditch effort to avoid
// unnecessary failure. The *Sans use a ton of vmem for bookkeeping leaving a
// lot less for the program so use a lower limit.
#if defined(MOZ_TSAN) || defined(MOZ_ASAN)
static const int32_t MaximumLiveMappedBuffers = 500;
#else
static const int32_t MaximumLiveMappedBuffers = 1000;
static const int32_t StartTriggeringAtLiveBufferCount = 200;
#endif
static const int32_t StartTriggeringAtLiveBufferCount = 100;
static const int32_t StartSyncFullGCAtLiveBufferCount = MaximumLiveMappedBuffers - 100;
static const int32_t AllocatedBuffersPerTrigger = 100;
static Atomic<int32_t, mozilla::ReleaseAcquire> liveBufferCount(0);
@ -838,8 +846,12 @@ CreateBuffer(JSContext* cx, uint32_t initialSize, const Maybe<uint32_t>& maxSize
maybeSharedObject.set(object);
// See StartTriggeringAtLiveBufferCount comment above.
if (liveBufferCount > StartTriggeringAtLiveBufferCount) {
// See MaximumLiveMappedBuffers comment above.
if (liveBufferCount > StartSyncFullGCAtLiveBufferCount) {
JS::PrepareForFullGC(cx);
JS::GCForReason(cx, GC_NORMAL, JS::gcreason::TOO_MUCH_WASM_MEMORY);
allocatedSinceLastTrigger = 0;
} else if (liveBufferCount > StartTriggeringAtLiveBufferCount) {
allocatedSinceLastTrigger++;
if (allocatedSinceLastTrigger > AllocatedBuffersPerTrigger) {
Unused << cx->runtime()->gc.triggerGC(JS::gcreason::TOO_MUCH_WASM_MEMORY);
@ -884,7 +896,7 @@ js::CreateWasmBuffer(JSContext* cx, const wasm::Limits& memory,
#endif
if (memory.shared == wasm::Shareable::True) {
if (!cx->compartment()->creationOptions().getSharedMemoryAndAtomicsEnabled()) {
if (!cx->realm()->creationOptions().getSharedMemoryAndAtomicsEnabled()) {
JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_WASM_NO_SHMEM_LINK);
return false;
}

Просмотреть файл

@ -2174,7 +2174,7 @@ void
Debugger::slowPathOnNewGlobalObject(JSContext* cx, Handle<GlobalObject*> global)
{
MOZ_ASSERT(!cx->runtime()->onNewGlobalObjectWatchers().isEmpty());
if (global->compartment()->creationOptions().invisibleToDebugger())
if (global->realm()->creationOptions().invisibleToDebugger())
return;
/*
@ -3742,8 +3742,11 @@ Debugger::addAllGlobalsAsDebuggees(JSContext* cx, unsigned argc, Value* vp)
THIS_DEBUGGER(cx, argc, vp, "addAllGlobalsAsDebuggees", args, dbg);
for (ZonesIter zone(cx->runtime(), SkipAtoms); !zone.done(); zone.next()) {
for (CompartmentsInZoneIter c(zone); !c.done(); c.next()) {
if (c == dbg->object->compartment() || c->creationOptions().invisibleToDebugger())
if (c == dbg->object->compartment() ||
JS::GetRealmForCompartment(c)->creationOptions().invisibleToDebugger())
{
continue;
}
c->scheduledForDestruction = false;
GlobalObject* global = c->maybeGlobal();
if (global) {
@ -3963,15 +3966,15 @@ Debugger::addDebuggeeGlobal(JSContext* cx, Handle<GlobalObject*> global)
// invisible global in order to pass it to addDebuggee. But this is possible
// with certain testing aides we expose in the shell, so just make addDebuggee
// throw in that case.
JSCompartment* debuggeeCompartment = global->compartment();
if (debuggeeCompartment->creationOptions().invisibleToDebugger()) {
Realm* debuggeeRealm = global->realm();
if (debuggeeRealm->creationOptions().invisibleToDebugger()) {
JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_DEBUG_CANT_DEBUG_GLOBAL);
return false;
}
/*
* Check for cycles. If global's compartment is reachable from this
* Debugger object's compartment by following debuggee-to-debugger links,
* Check for cycles. If global's realm is reachable from this
* Debugger object's realm by following debuggee-to-debugger links,
* then adding global would create a cycle. (Typically nobody is debugging
* the debugger, in which case we zip through this code without looping.)
*/
@ -3980,7 +3983,7 @@ Debugger::addDebuggeeGlobal(JSContext* cx, Handle<GlobalObject*> global)
return false;
for (size_t i = 0; i < visited.length(); i++) {
JSCompartment* c = visited[i];
if (c == debuggeeCompartment) {
if (c == debuggeeRealm) {
JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_DEBUG_LOOP);
return false;
}
@ -4072,12 +4075,12 @@ Debugger::addDebuggeeGlobal(JSContext* cx, Handle<GlobalObject*> global)
});
// (6)
AutoRestoreCompartmentDebugMode debugModeGuard(debuggeeCompartment);
debuggeeCompartment->setIsDebuggee();
debuggeeCompartment->updateDebuggerObservesAsmJS();
debuggeeCompartment->updateDebuggerObservesBinarySource();
debuggeeCompartment->updateDebuggerObservesCoverage();
if (observesAllExecution() && !ensureExecutionObservabilityOfCompartment(cx, debuggeeCompartment))
AutoRestoreCompartmentDebugMode debugModeGuard(debuggeeRealm);
debuggeeRealm->setIsDebuggee();
debuggeeRealm->updateDebuggerObservesAsmJS();
debuggeeRealm->updateDebuggerObservesBinarySource();
debuggeeRealm->updateDebuggerObservesCoverage();
if (observesAllExecution() && !ensureExecutionObservabilityOfCompartment(cx, debuggeeRealm))
return false;
globalDebuggersGuard.release();
@ -4959,7 +4962,7 @@ Debugger::findAllGlobals(JSContext* cx, unsigned argc, Value* vp)
JS::AutoCheckCannotGC nogc;
for (CompartmentsIter c(cx->runtime(), SkipAtoms); !c.done(); c.next()) {
if (c->creationOptions().invisibleToDebugger())
if (JS::GetRealmForCompartment(c)->creationOptions().invisibleToDebugger())
continue;
c->scheduledForDestruction = false;
@ -5009,11 +5012,10 @@ Debugger::makeGlobalObjectReference(JSContext* cx, unsigned argc, Value* vp)
if (!global)
return false;
// If we create a D.O referring to a global in an invisible compartment,
// If we create a D.O referring to a global in an invisible realm,
// then from it we can reach function objects, scripts, environments, etc.,
// none of which we're ever supposed to see.
JSCompartment* globalCompartment = global->compartment();
if (globalCompartment->creationOptions().invisibleToDebugger()) {
if (global->realm()->creationOptions().invisibleToDebugger()) {
JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr,
JSMSG_DEBUG_INVISIBLE_COMPARTMENT);
return false;
@ -10645,9 +10647,8 @@ DebuggerObject::unwrap(JSContext* cx, HandleDebuggerObject object,
// Don't allow unwrapping to create a D.O whose referent is in an
// invisible-to-Debugger global. (If our referent is a *wrapper* to such,
// and the wrapper is in a visible compartment, that's fine.)
JSCompartment* unwrappedCompartment = unwrapped->compartment();
if (unwrappedCompartment->creationOptions().invisibleToDebugger()) {
// and the wrapper is in a visible realm, that's fine.)
if (unwrapped->realm()->creationOptions().invisibleToDebugger()) {
JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_DEBUG_INVISIBLE_COMPARTMENT);
return false;
}

Просмотреть файл

@ -160,9 +160,9 @@ class DebuggerWeakMap : private WeakMap<HeapPtr<UnbarrieredKey>, HeapPtr<JSObjec
template<typename KeyInput, typename ValueInput>
bool relookupOrAdd(AddPtr& p, const KeyInput& k, const ValueInput& v) {
MOZ_ASSERT(v->compartment() == this->compartment);
MOZ_ASSERT(!k->compartment()->creationOptions().mergeable());
MOZ_ASSERT(!k->realm()->creationOptions().mergeable());
MOZ_ASSERT_IF(!InvisibleKeysOk,
!k->compartment()->creationOptions().invisibleToDebugger());
!k->realm()->creationOptions().invisibleToDebugger());
MOZ_ASSERT(!Base::has(k));
if (!incZoneCount(k->zone()))
return false;
@ -1798,7 +1798,7 @@ Debugger::onNewScript(JSContext* cx, HandleScript script)
{
// We early return in slowPathOnNewScript for self-hosted scripts, so we can
// ignore those in our assertion here.
MOZ_ASSERT_IF(!script->compartment()->creationOptions().invisibleToDebugger() &&
MOZ_ASSERT_IF(!script->realm()->creationOptions().invisibleToDebugger() &&
!script->selfHosted(),
script->compartment()->firedOnNewGlobalObject);

Просмотреть файл

@ -112,7 +112,7 @@ GlobalObject::skipDeselectedConstructor(JSContext* cx, JSProtoKey key)
// Return true if the given constructor has been disabled at run-time.
case JSProto_Atomics:
case JSProto_SharedArrayBuffer:
return !cx->compartment()->creationOptions().getSharedMemoryAndAtomicsEnabled();
return !cx->realm()->creationOptions().getSharedMemoryAndAtomicsEnabled();
default:
return false;
}

Просмотреть файл

@ -733,10 +733,10 @@ class MOZ_RAII AutoSetCreatedForHelperThread
static JSObject*
CreateGlobalForOffThreadParse(JSContext* cx, const gc::AutoSuppressGC& nogc)
{
JSCompartment* currentCompartment = cx->compartment();
JS::Realm* currentRealm = cx->realm();
JS::RealmOptions realmOptions(currentCompartment->creationOptions(),
currentCompartment->behaviors());
JS::RealmOptions realmOptions(currentRealm->creationOptions(),
currentRealm->behaviors());
auto& creationOptions = realmOptions.creationOptions();
@ -754,7 +754,7 @@ CreateGlobalForOffThreadParse(JSContext* cx, const gc::AutoSuppressGC& nogc)
Rooted<GlobalObject*> global(cx, &obj->as<GlobalObject>());
JS_SetCompartmentPrincipals(global->compartment(), currentCompartment->principals());
JS_SetCompartmentPrincipals(global->compartment(), currentRealm->principals());
return global;
}

Просмотреть файл

@ -3290,13 +3290,13 @@ END_CASE(JSOP_SYMBOL)
CASE(JSOP_OBJECT)
{
ReservedRooted<JSObject*> ref(&rootObject0, script->getObject(REGS.pc));
if (cx->compartment()->creationOptions().cloneSingletons()) {
if (cx->realm()->creationOptions().cloneSingletons()) {
JSObject* obj = DeepCloneObjectLiteral(cx, ref, TenuredObject);
if (!obj)
goto error;
PUSH_OBJECT(*obj);
} else {
cx->compartment()->behaviors().setSingletonsAsValues();
cx->realm()->behaviors().setSingletonsAsValues();
PUSH_OBJECT(*ref);
}
}

Просмотреть файл

@ -46,47 +46,47 @@ JSCompartment::globalIsAboutToBeFinalized()
template <typename T>
js::AutoRealm::AutoRealm(JSContext* cx, const T& target)
: cx_(cx),
origin_(cx->compartment()),
origin_(cx->realm()),
maybeLock_(nullptr)
{
cx_->enterCompartmentOf(target);
cx_->enterRealmOf(target);
}
// Protected constructor that bypasses assertions in enterCompartmentOf. Used
// only for entering the atoms compartment.
js::AutoRealm::AutoRealm(JSContext* cx, JSCompartment* target,
js::AutoRealm::AutoRealm(JSContext* cx, JS::Realm* target,
js::AutoLockForExclusiveAccess& lock)
: cx_(cx),
origin_(cx->compartment()),
origin_(cx->realm()),
maybeLock_(&lock)
{
MOZ_ASSERT(target->isAtomsCompartment());
cx_->enterAtomsCompartment(target, lock);
cx_->enterAtomsRealm(target, lock);
}
// Protected constructor that bypasses assertions in enterCompartmentOf. Should
// not be used to enter the atoms compartment.
js::AutoRealm::AutoRealm(JSContext* cx, JSCompartment* target)
js::AutoRealm::AutoRealm(JSContext* cx, JS::Realm* target)
: cx_(cx),
origin_(cx->compartment()),
origin_(cx->realm()),
maybeLock_(nullptr)
{
MOZ_ASSERT(!target->isAtomsCompartment());
cx_->enterNonAtomsCompartment(target);
cx_->enterNonAtomsRealm(target);
}
js::AutoRealm::~AutoRealm()
{
cx_->leaveCompartment(origin_, maybeLock_);
cx_->leaveRealm(origin_, maybeLock_);
}
js::AutoAtomsRealm::AutoAtomsRealm(JSContext* cx,
js::AutoLockForExclusiveAccess& lock)
: AutoRealm(cx, cx->atomsCompartment(lock), lock)
: AutoRealm(cx, JS::GetRealmForCompartment(cx->atomsCompartment(lock)), lock)
{}
js::AutoRealmUnchecked::AutoRealmUnchecked(JSContext* cx, JSCompartment* target)
: AutoRealm(cx, target)
: AutoRealm(cx, JS::GetRealmForCompartment(target))
{}
inline bool

Просмотреть файл

@ -41,10 +41,8 @@ using namespace js::jit;
using mozilla::PodArrayZero;
JSCompartment::JSCompartment(Zone* zone, const JS::RealmOptions& options = JS::RealmOptions())
: creationOptions_(options.creationOptions()),
behaviors_(options.behaviors()),
zone_(zone),
JSCompartment::JSCompartment(Zone* zone)
: zone_(zone),
runtime_(zone->runtimeFromAnyThread()),
principals_(nullptr),
isSystem_(false),
@ -82,7 +80,7 @@ JSCompartment::JSCompartment(Zone* zone, const JS::RealmOptions& options = JS::R
debugScriptMap(nullptr),
debugEnvs(nullptr),
enumerators(nullptr),
compartmentStats_(nullptr),
realmStats_(nullptr),
scheduledForDestruction(false),
maybeAlive(true),
jitCompartment_(nullptr),
@ -92,6 +90,13 @@ JSCompartment::JSCompartment(Zone* zone, const JS::RealmOptions& options = JS::R
lcovOutput()
{
runtime_->numCompartments++;
}
JS::Realm::Realm(JS::Zone* zone, const JS::RealmOptions& options)
: JSCompartment(zone),
creationOptions_(options.creationOptions()),
behaviors_(options.behaviors())
{
MOZ_ASSERT_IF(creationOptions_.mergeable(),
creationOptions_.invisibleToDebugger());
}

Просмотреть файл

@ -550,9 +550,6 @@ class WeakMapBase;
struct JSCompartment
{
const JS::RealmCreationOptions creationOptions_;
JS::RealmBehaviors behaviors_;
private:
JS::Zone* zone_;
JSRuntime* runtime_;
@ -649,10 +646,6 @@ struct JSCompartment
JS::Zone* zone() { return zone_; }
const JS::Zone* zone() const { return zone_; }
const JS::RealmCreationOptions& creationOptions() const { return creationOptions_; }
JS::RealmBehaviors& behaviors() { return behaviors_; }
const JS::RealmBehaviors& behaviors() const { return behaviors_; }
JSRuntime* runtimeFromMainThread() const {
MOZ_ASSERT(js::CurrentThreadCanAccessRuntime(runtime_));
return runtime_;
@ -851,12 +844,12 @@ struct JSCompartment
bool isAccessValid() const { return validAccessPtr ? *validAccessPtr : true; }
void setValidAccessPtr(bool* accessp) { validAccessPtr = accessp; }
public:
JSCompartment(JS::Zone* zone, const JS::RealmOptions& options);
protected:
explicit JSCompartment(JS::Zone* zone);
~JSCompartment();
public:
MOZ_MUST_USE bool init(JSContext* maybecx);
void destroy(js::FreeOp* fop);
MOZ_MUST_USE inline bool wrap(JSContext* cx, JS::MutableHandleValue vp);
@ -926,9 +919,6 @@ struct JSCompartment
void traceOutgoingCrossCompartmentWrappers(JSTracer* trc);
static void traceIncomingCrossCompartmentEdgesForZoneGC(JSTracer* trc);
/* Whether to preserve JIT code on non-shrinking GCs. */
bool preserveJitCode() { return creationOptions_.preserveJitCode(); }
void sweepAfterMinorGC(JSTracer* trc);
void sweepMapAndSetObjectsAfterMinorGC();
@ -1134,25 +1124,24 @@ struct JSCompartment
private:
/* Used by memory reporters and invalid otherwise. */
JS::CompartmentStats* compartmentStats_;
JS::RealmStats* realmStats_;
public:
// This should only be called when it is non-null, i.e. during memory
// reporting.
JS::CompartmentStats& compartmentStats() {
JS::RealmStats& realmStats() {
// We use MOZ_RELEASE_ASSERT here because in bug 1132502 there was some
// (inconclusive) evidence that compartmentStats_ can be nullptr
// unexpectedly.
MOZ_RELEASE_ASSERT(compartmentStats_);
return *compartmentStats_;
// (inconclusive) evidence that realmStats_ can be nullptr unexpectedly.
MOZ_RELEASE_ASSERT(realmStats_);
return *realmStats_;
}
void nullCompartmentStats() {
MOZ_ASSERT(compartmentStats_);
compartmentStats_ = nullptr;
void nullRealmStats() {
MOZ_ASSERT(realmStats_);
realmStats_ = nullptr;
}
void setCompartmentStats(JS::CompartmentStats* newStats) {
MOZ_ASSERT(!compartmentStats_ && newStats);
compartmentStats_ = newStats;
void setRealmStats(JS::RealmStats* newStats) {
MOZ_ASSERT(!realmStats_ && newStats);
realmStats_ = newStats;
}
MOZ_ALWAYS_INLINE bool objectMaybeInIteration(JSObject* obj);
@ -1209,6 +1198,24 @@ struct JSCompartment
js::Vector<js::SetObject*, 0, js::SystemAllocPolicy> setsWithNurseryMemory;
};
class JS::Realm : public JSCompartment
{
const JS::RealmCreationOptions creationOptions_;
JS::RealmBehaviors behaviors_;
public:
Realm(JS::Zone* zone, const JS::RealmOptions& options);
void destroy(js::FreeOp* fop);
const JS::RealmCreationOptions& creationOptions() const { return creationOptions_; }
JS::RealmBehaviors& behaviors() { return behaviors_; }
const JS::RealmBehaviors& behaviors() const { return behaviors_; }
/* Whether to preserve JIT code on non-shrinking GCs. */
bool preserveJitCode() { return creationOptions_.preserveJitCode(); }
};
namespace js {
// We only set the maybeAlive flag for objects and scripts. It's assumed that,
@ -1226,41 +1233,42 @@ inline js::Handle<js::GlobalObject*>
JSContext::global() const
{
/*
* It's safe to use |unsafeGet()| here because any compartment that is
* It's safe to use |unsafeGet()| here because any realm that is
* on-stack will be marked automatically, so there's no need for a read
* barrier on it. Once the compartment is popped, the handle is no longer
* barrier on it. Once the realm is popped, the handle is no longer
* safe to use.
*/
MOZ_ASSERT(compartment_, "Caller needs to enter a compartment first");
return js::Handle<js::GlobalObject*>::fromMarkedLocation(compartment_->global_.unsafeGet());
MOZ_ASSERT(realm_, "Caller needs to enter a realm first");
JSCompartment* comp = GetCompartmentForRealm(realm_);
return js::Handle<js::GlobalObject*>::fromMarkedLocation(comp->global_.unsafeGet());
}
namespace js {
class MOZ_RAII AssertCompartmentUnchanged
class MOZ_RAII AssertRealmUnchanged
{
public:
explicit AssertCompartmentUnchanged(JSContext* cx
MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
: cx(cx), oldCompartment(cx->compartment())
explicit AssertRealmUnchanged(JSContext* cx
MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
: cx(cx), oldRealm(cx->realm())
{
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
}
~AssertCompartmentUnchanged() {
MOZ_ASSERT(cx->compartment() == oldCompartment);
~AssertRealmUnchanged() {
MOZ_ASSERT(cx->realm() == oldRealm);
}
protected:
JSContext * const cx;
JSCompartment * const oldCompartment;
JSContext* const cx;
JS::Realm* const oldRealm;
MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
};
class AutoRealm
{
JSContext* const cx_;
JSCompartment* const origin_;
JS::Realm* const origin_;
const AutoLockForExclusiveAccess* maybeLock_;
public:
@ -1269,13 +1277,13 @@ class AutoRealm
inline ~AutoRealm();
JSContext* context() const { return cx_; }
JSCompartment* origin() const { return origin_; }
JS::Realm* origin() const { return origin_; }
protected:
inline AutoRealm(JSContext* cx, JSCompartment* target);
inline AutoRealm(JSContext* cx, JS::Realm* target);
// Used only for entering the atoms compartment.
inline AutoRealm(JSContext* cx, JSCompartment* target,
inline AutoRealm(JSContext* cx, JS::Realm* target,
AutoLockForExclusiveAccess& lock);
private:
@ -1402,7 +1410,7 @@ class MOZ_RAII AutoSuppressAllocationMetadataBuilder {
public:
explicit AutoSuppressAllocationMetadataBuilder(JSContext* cx)
: AutoSuppressAllocationMetadataBuilder(cx->compartment()->zone())
: AutoSuppressAllocationMetadataBuilder(cx->realm()->zone())
{ }
explicit AutoSuppressAllocationMetadataBuilder(JS::Zone* zone)

Просмотреть файл

@ -464,83 +464,81 @@ JSContext::runningWithTrustedPrincipals()
}
inline void
JSContext::enterNonAtomsCompartment(JSCompartment* c)
JSContext::enterNonAtomsRealm(JS::Realm* realm)
{
enterCompartmentDepth_++;
enterRealmDepth_++;
MOZ_ASSERT(!c->zone()->isAtomsZone());
MOZ_ASSERT(!realm->zone()->isAtomsZone());
c->enter();
setCompartment(c, nullptr);
realm->enter();
setRealm(realm, nullptr);
}
inline void
JSContext::enterAtomsCompartment(JSCompartment* c,
const js::AutoLockForExclusiveAccess& lock)
JSContext::enterAtomsRealm(JS::Realm* realm,
const js::AutoLockForExclusiveAccess& lock)
{
enterCompartmentDepth_++;
enterRealmDepth_++;
MOZ_ASSERT(c->zone()->isAtomsZone());
MOZ_ASSERT(realm->zone()->isAtomsZone());
c->enter();
setCompartment(c, &lock);
realm->enter();
setRealm(realm, &lock);
}
template <typename T>
inline void
JSContext::enterCompartmentOf(const T& target)
JSContext::enterRealmOf(const T& target)
{
MOZ_ASSERT(JS::CellIsNotGray(target));
enterNonAtomsCompartment(target->compartment());
enterNonAtomsRealm(JS::GetRealmForCompartment(target->compartment()));
}
inline void
JSContext::enterNullCompartment()
JSContext::enterNullRealm()
{
enterCompartmentDepth_++;
setCompartment(nullptr);
enterRealmDepth_++;
setRealm(nullptr);
}
inline void
JSContext::leaveCompartment(
JSCompartment* oldCompartment,
const js::AutoLockForExclusiveAccess* maybeLock /* = nullptr */)
JSContext::leaveRealm(JS::Realm* oldRealm,
const js::AutoLockForExclusiveAccess* maybeLock /* = nullptr */)
{
MOZ_ASSERT(hasEnteredCompartment());
enterCompartmentDepth_--;
MOZ_ASSERT(hasEnteredRealm());
enterRealmDepth_--;
// Only call leave() after we've setCompartment()-ed away from the current
// compartment.
JSCompartment* startingCompartment = compartment_;
setCompartment(oldCompartment, maybeLock);
if (startingCompartment)
startingCompartment->leave();
// Only call leave() after we've setRealm()-ed away from the current realm.
JS::Realm* startingRealm = realm_;
setRealm(oldRealm, maybeLock);
if (startingRealm)
startingRealm->leave();
}
inline void
JSContext::setCompartment(JSCompartment* comp,
const js::AutoLockForExclusiveAccess* maybeLock /* = nullptr */)
JSContext::setRealm(JS::Realm* realm,
const js::AutoLockForExclusiveAccess* maybeLock /* = nullptr */)
{
// Only one thread can be in the atoms compartment at a time.
MOZ_ASSERT_IF(runtime_->isAtomsCompartment(comp), maybeLock != nullptr);
MOZ_ASSERT_IF(runtime_->isAtomsCompartment(comp) || runtime_->isAtomsCompartment(compartment_),
// Only one thread can be in the atoms realm at a time.
MOZ_ASSERT_IF(runtime_->isAtomsCompartment(realm), maybeLock != nullptr);
MOZ_ASSERT_IF(runtime_->isAtomsCompartment(realm) || runtime_->isAtomsCompartment(realm_),
runtime_->currentThreadHasExclusiveAccess());
// Make sure that the atoms compartment has its own zone.
MOZ_ASSERT_IF(comp && !runtime_->isAtomsCompartment(comp),
!comp->zone()->isAtomsZone());
// Make sure that the atoms realm has its own zone.
MOZ_ASSERT_IF(realm && !runtime_->isAtomsCompartment(realm),
!realm->zone()->isAtomsZone());
// Both the current and the new compartment should be properly marked as
// Both the current and the new realm should be properly marked as
// entered at this point.
MOZ_ASSERT_IF(compartment_, compartment_->hasBeenEntered());
MOZ_ASSERT_IF(comp, comp->hasBeenEntered());
MOZ_ASSERT_IF(realm_, realm_->hasBeenEntered());
MOZ_ASSERT_IF(realm, realm->hasBeenEntered());
// This thread must have exclusive access to the zone.
MOZ_ASSERT_IF(comp && !comp->zone()->isAtomsZone(),
CurrentThreadCanAccessZone(comp->zone()));
MOZ_ASSERT_IF(realm && !realm->zone()->isAtomsZone(),
CurrentThreadCanAccessZone(realm->zone()));
compartment_ = comp;
zone_ = comp ? comp->zone() : nullptr;
realm_ = realm;
zone_ = realm ? realm->zone() : nullptr;
arenas_ = zone_ ? &zone_->arenas : nullptr;
}

Просмотреть файл

@ -370,7 +370,7 @@ checkReportFlags(JSContext* cx, unsigned* flags)
{
if (JSREPORT_IS_STRICT(*flags)) {
/* Warning/error only when JSOPTION_STRICT is set. */
if (!cx->compartment()->behaviors().extraWarnings(cx))
if (!cx->realm()->behaviors().extraWarnings(cx))
return true;
}
@ -1219,7 +1219,7 @@ JSContext::JSContext(JSRuntime* runtime, const JS::ContextOptions& options)
helperThread_(nullptr),
options_(options),
arenas_(nullptr),
enterCompartmentDepth_(0),
enterRealmDepth_(0),
jitActivation(nullptr),
activation_(nullptr),
profilingActivation_(nullptr),
@ -1482,8 +1482,8 @@ JSContext::trace(JSTracer* trc)
cycleDetectorVector().trace(trc);
geckoProfiler().trace(trc);
if (trc->isMarkingTracer() && compartment_)
compartment_->mark();
if (trc->isMarkingTracer() && realm_)
realm_->mark();
}
void*

Просмотреть файл

@ -144,7 +144,7 @@ struct JSContext : public JS::RootingContext,
template <typename T>
inline bool isInsideCurrentCompartment(T thing) const {
return thing->compartment() == compartment_;
return thing->compartment() == GetCompartmentForRealm(realm_);
}
void* onOutOfMemory(js::AllocFunction allocFunc, size_t nbytes, void* reallocPtr = nullptr) {
@ -188,50 +188,50 @@ struct JSContext : public JS::RootingContext,
bool lcovEnabled() const { return runtime_->lcovOutput().isEnabled(); }
/*
* "Entering" a compartment changes cx->compartment (which changes
* cx->global). Note that this does not push any InterpreterFrame which means
* that it is possible for cx->fp()->compartment() != cx->compartment.
* This is not a problem since, in general, most places in the VM cannot
* know that they were called from script (e.g., they may have been called
* through the JSAPI via JS_CallFunction) and thus cannot expect fp.
* "Entering" a realm changes cx->realm (which changes cx->global). Note
* that this does not push an Activation so it's possible for the caller's
* realm to be != cx->realm(). This is not a problem since, in general, most
* places in the VM cannot know that they were called from script (e.g.,
* they may have been called through the JSAPI via JS_CallFunction) and thus
* cannot expect there is a scripted caller.
*
* Compartments should be entered/left in a LIFO fasion. The depth of this
* enter/leave stack is maintained by enterCompartmentDepth_ and queried by
* hasEnteredCompartment.
* Realms should be entered/left in a LIFO fasion. The depth of this
* enter/leave stack is maintained by enterRealmDepth_ and queried by
* hasEnteredRealm.
*
* To enter a compartment, code should prefer using AutoRealm over
* manually calling cx->enterCompartment/leaveCompartment.
* manually calling cx->enterRealm/leaveRealm.
*/
protected:
js::ThreadData<unsigned> enterCompartmentDepth_;
js::ThreadData<unsigned> enterRealmDepth_;
inline void setCompartment(JSCompartment* comp,
const js::AutoLockForExclusiveAccess* maybeLock = nullptr);
inline void setRealm(JS::Realm* realm,
const js::AutoLockForExclusiveAccess* maybeLock = nullptr);
public:
bool hasEnteredCompartment() const {
return enterCompartmentDepth_ > 0;
bool hasEnteredRealm() const {
return enterRealmDepth_ > 0;
}
#ifdef DEBUG
unsigned getEnterCompartmentDepth() const {
return enterCompartmentDepth_;
unsigned getEnterRealmDepth() const {
return enterRealmDepth_;
}
#endif
private:
// We distinguish between entering the atoms compartment and all other
// compartments. Entering the atoms compartment requires a lock.
inline void enterNonAtomsCompartment(JSCompartment* c);
inline void enterAtomsCompartment(JSCompartment* c,
const js::AutoLockForExclusiveAccess& lock);
// We distinguish between entering the atoms realm and all other realms.
// Entering the atoms realm requires a lock.
inline void enterNonAtomsRealm(JS::Realm* realm);
inline void enterAtomsRealm(JS::Realm* realm,
const js::AutoLockForExclusiveAccess& lock);
friend class js::AutoRealm;
public:
template <typename T>
inline void enterCompartmentOf(const T& target);
inline void enterNullCompartment();
inline void leaveCompartment(JSCompartment* oldCompartment,
const js::AutoLockForExclusiveAccess* maybeLock = nullptr);
inline void enterRealmOf(const T& target);
inline void enterNullRealm();
inline void leaveRealm(JS::Realm* oldRealm,
const js::AutoLockForExclusiveAccess* maybeLock = nullptr);
void setHelperThread(js::HelperThread* helperThread);
js::HelperThread* helperThread() const { return helperThread_; }
@ -242,11 +242,14 @@ struct JSContext : public JS::RootingContext,
// Threads may freely access any data in their compartment and zone.
JSCompartment* compartment() const {
return compartment_;
return JS::GetCompartmentForRealm(realm_);
}
JS::Realm* realm() const {
return realm_;
}
JS::Zone* zone() const {
MOZ_ASSERT_IF(!compartment(), !zone_);
MOZ_ASSERT_IF(compartment(), js::GetCompartmentZone(compartment()) == zone_);
MOZ_ASSERT_IF(!realm(), !zone_);
MOZ_ASSERT_IF(realm(), js::GetCompartmentZone(GetCompartmentForRealm(realm())) == zone_);
return zoneRaw();
}
@ -307,8 +310,8 @@ struct JSContext : public JS::RootingContext,
JSRuntime* runtime() { return runtime_; }
const JSRuntime* runtime() const { return runtime_; }
static size_t offsetOfCompartment() {
return offsetof(JSContext, compartment_);
static size_t offsetOfRealm() {
return offsetof(JSContext, realm_);
}
friend class JS::AutoSaveExceptionState;

Просмотреть файл

@ -1057,7 +1057,7 @@ js::FunctionToString(JSContext* cx, HandleFunction fun, bool isToSource)
MOZ_ASSERT_IF(fun->infallibleIsDefaultClassConstructor(cx),
!cx->runtime()->sourceHook.ref() ||
!script->scriptSource()->sourceRetrievable() ||
fun->compartment()->behaviors().discardSource());
fun->realm()->behaviors().discardSource());
if (!out.append("() {\n [sourceless code]\n}"))
return nullptr;

Просмотреть файл

@ -1326,7 +1326,7 @@ js::DeepCloneObjectLiteral(JSContext* cx, HandleObject obj, NewObjectKind newKin
{
/* NB: Keep this in sync with XDRObjectLiteral. */
MOZ_ASSERT_IF(obj->isSingleton(),
cx->compartment()->behaviors().getSingletonsAsTemplates());
cx->realm()->behaviors().getSingletonsAsTemplates());
MOZ_ASSERT(obj->is<PlainObject>() || obj->is<UnboxedPlainObject>() ||
obj->is<ArrayObject>());
MOZ_ASSERT(newKind != SingletonObject);

Просмотреть файл

@ -162,6 +162,7 @@ class JSObject : public js::gc::Cell
JSCompartment* compartment() const { return group_->compartment(); }
JSCompartment* maybeCompartment() const { return compartment(); }
JS::Realm* realm() const { return group_->realm(); }
inline js::Shape* maybeShape() const;
inline js::Shape* ensureShape(JSContext* cx);

Просмотреть файл

@ -204,7 +204,7 @@ JSScript::ensureHasAnalyzedArgsUsage(JSContext* cx)
inline bool
JSScript::isDebuggee() const
{
return compartment_->debuggerObservesAllExecution() || hasDebugScript_;
return realm_->debuggerObservesAllExecution() || hasDebugScript_;
}
#endif /* vm_JSScript_inl_h */

Просмотреть файл

@ -374,9 +374,9 @@ js::XDRScript(XDRState<mode>* xdr, HandleScope scriptEnclosingScope,
// JSOP_OBJECT that then got modified. So throw if we're not
// cloning in JSOP_OBJECT or if we ever didn't clone in it in the
// past.
JSCompartment* comp = cx->compartment();
if (!comp->creationOptions().cloneSingletons() ||
!comp->behaviors().getSingletonsAsTemplates())
Realm* realm = cx->realm();
if (!realm->creationOptions().cloneSingletons() ||
!realm->behaviors().getSingletonsAsTemplates())
{
return xdr->fail(JS::TranscodeResult_Failure_RunOnceNotSupported);
}
@ -2626,12 +2626,6 @@ ScriptDataSize(uint32_t nscopes, uint32_t nconsts, uint32_t nobjects,
return size;
}
void
JSScript::initCompartment(JSContext* cx)
{
compartment_ = cx->compartment();
}
/* static */ JSScript*
JSScript::Create(JSContext* cx, const ReadOnlyCompileOptions& options,
HandleObject sourceObject, uint32_t bufStart, uint32_t bufEnd,
@ -2651,7 +2645,7 @@ JSScript::Create(JSContext* cx, const ReadOnlyCompileOptions& options,
PodZero(script.get());
script->initCompartment(cx);
script->realm_ = cx->realm();
#ifndef JS_CODEGEN_NONE
uint8_t* stubEntry = cx->runtime()->jitRuntime()->interpreterStub().value;

Просмотреть файл

@ -923,7 +923,7 @@ class JSScript : public js::gc::TenuredCell
uint8_t* data; /* pointer to variable-length data array (see
comment above Create() for details) */
JSCompartment* compartment_;
JS::Realm* realm_;
private:
/* Persistent type information retained across GCs. */
@ -1174,8 +1174,6 @@ class JSScript : public js::gc::TenuredCell
uint32_t sourceStart, uint32_t sourceEnd,
uint32_t toStringStart, uint32_t toStringEnd);
void initCompartment(JSContext* cx);
// Three ways ways to initialize a JSScript. Callers of partiallyInit()
// are responsible for notifying the debugger after successfully creating
// any kind (function or other) of new JSScript. However, callers of
@ -1206,8 +1204,9 @@ class JSScript : public js::gc::TenuredCell
public:
inline JSPrincipals* principals();
JSCompartment* compartment() const { return compartment_; }
JSCompartment* compartment() const { return JS::GetCompartmentForRealm(realm_); }
JSCompartment* maybeCompartment() const { return compartment(); }
JS::Realm* realm() const { return realm_; }
js::SharedScriptData* scriptData() {
return scriptData_;

Просмотреть файл

@ -35,7 +35,7 @@ using namespace js;
using JS::RuntimeStats;
using JS::ObjectPrivateVisitor;
using JS::ZoneStats;
using JS::CompartmentStats;
using JS::RealmStats;
namespace js {
@ -307,7 +307,7 @@ DecommittedArenasChunkCallback(JSRuntime* rt, void* data, gc::Chunk* chunk)
static void
StatsZoneCallback(JSRuntime* rt, void* data, Zone* zone)
{
// Append a new CompartmentStats to the vector.
// Append a new RealmStats to the vector.
RuntimeStats* rtStats = static_cast<StatsClosure*>(data)->rtStats;
// CollectRuntimeStats reserves enough space.
@ -330,37 +330,37 @@ StatsZoneCallback(JSRuntime* rt, void* data, Zone* zone)
}
static void
StatsCompartmentCallback(JSContext* cx, void* data, JSCompartment* compartment)
StatsRealmCallback(JSContext* cx, void* data, JSCompartment* compartment)
{
// Append a new CompartmentStats to the vector.
// Append a new RealmStats to the vector.
RuntimeStats* rtStats = static_cast<StatsClosure*>(data)->rtStats;
// CollectRuntimeStats reserves enough space.
MOZ_ALWAYS_TRUE(rtStats->compartmentStatsVector.growBy(1));
CompartmentStats& cStats = rtStats->compartmentStatsVector.back();
if (!cStats.initClasses())
MOZ_ALWAYS_TRUE(rtStats->realmStatsVector.growBy(1));
RealmStats& realmStats = rtStats->realmStatsVector.back();
if (!realmStats.initClasses())
MOZ_CRASH("oom");
rtStats->initExtraCompartmentStats(compartment, &cStats);
rtStats->initExtraRealmStats(compartment, &realmStats);
compartment->setCompartmentStats(&cStats);
compartment->setRealmStats(&realmStats);
// Measure the compartment object itself, and things hanging off it.
compartment->addSizeOfIncludingThis(rtStats->mallocSizeOf_,
&cStats.typeInferenceAllocationSiteTables,
&cStats.typeInferenceArrayTypeTables,
&cStats.typeInferenceObjectTypeTables,
&cStats.compartmentObject,
&cStats.compartmentTables,
&cStats.innerViewsTable,
&cStats.lazyArrayBuffersTable,
&cStats.objectMetadataTable,
&cStats.crossCompartmentWrappersTable,
&cStats.savedStacksSet,
&cStats.varNamesSet,
&cStats.nonSyntacticLexicalScopesTable,
&cStats.jitCompartment,
&cStats.privateData,
&cStats.scriptCountsMap);
&realmStats.typeInferenceAllocationSiteTables,
&realmStats.typeInferenceArrayTypeTables,
&realmStats.typeInferenceObjectTypeTables,
&realmStats.realmObject,
&realmStats.realmTables,
&realmStats.innerViewsTable,
&realmStats.lazyArrayBuffersTable,
&realmStats.objectMetadataTable,
&realmStats.crossCompartmentWrappersTable,
&realmStats.savedStacksSet,
&realmStats.varNamesSet,
&realmStats.nonSyntacticLexicalScopesTable,
&realmStats.jitRealm,
&realmStats.privateData,
&realmStats.scriptCountsMap);
}
static void
@ -391,15 +391,15 @@ enum Granularity {
};
static void
AddClassInfo(Granularity granularity, CompartmentStats& cStats, const char* className,
AddClassInfo(Granularity granularity, RealmStats& realmStats, const char* className,
JS::ClassInfo& info)
{
if (granularity == FineGrained) {
if (!className)
className = "<no class name>";
CompartmentStats::ClassesHashMap::AddPtr p = cStats.allClasses->lookupForAdd(className);
RealmStats::ClassesHashMap::AddPtr p = realmStats.allClasses->lookupForAdd(className);
if (!p) {
bool ok = cStats.allClasses->add(p, className, info);
bool ok = realmStats.allClasses->add(p, className, info);
// Ignore failure -- we just won't record the
// object/shape/base-shape as notable.
(void)ok;
@ -459,7 +459,7 @@ StatsCellCallback(JSRuntime* rt, void* data, void* thing, JS::TraceKind traceKin
switch (traceKind) {
case JS::TraceKind::Object: {
JSObject* obj = static_cast<JSObject*>(thing);
CompartmentStats& cStats = obj->compartment()->compartmentStats();
RealmStats& realmStats = obj->compartment()->realmStats();
JS::ClassInfo info; // This zeroes all the sizes.
info.objectsGCHeap += thingSize;
@ -490,29 +490,29 @@ StatsCellCallback(JSRuntime* rt, void* data, void* thing, JS::TraceKind traceKin
&info.objectsMallocHeapMisc);
}
cStats.classInfo.add(info);
realmStats.classInfo.add(info);
const Class* clasp = obj->getClass();
const char* className = clasp->name;
AddClassInfo(granularity, cStats, className, info);
AddClassInfo(granularity, realmStats, className, info);
if (ObjectPrivateVisitor* opv = closure->opv) {
nsISupports* iface;
if (opv->getISupports_(obj, &iface) && iface)
cStats.objectsPrivate += opv->sizeOfIncludingThis(iface);
realmStats.objectsPrivate += opv->sizeOfIncludingThis(iface);
}
break;
}
case JS::TraceKind::Script: {
JSScript* script = static_cast<JSScript*>(thing);
CompartmentStats& cStats = script->compartment()->compartmentStats();
cStats.scriptsGCHeap += thingSize;
cStats.scriptsMallocHeapData += script->sizeOfData(rtStats->mallocSizeOf_);
cStats.typeInferenceTypeScripts += script->sizeOfTypeScript(rtStats->mallocSizeOf_);
jit::AddSizeOfBaselineData(script, rtStats->mallocSizeOf_, &cStats.baselineData,
&cStats.baselineStubsFallback);
cStats.ionData += jit::SizeOfIonData(script, rtStats->mallocSizeOf_);
RealmStats& realmStats = script->compartment()->realmStats();
realmStats.scriptsGCHeap += thingSize;
realmStats.scriptsMallocHeapData += script->sizeOfData(rtStats->mallocSizeOf_);
realmStats.typeInferenceTypeScripts += script->sizeOfTypeScript(rtStats->mallocSizeOf_);
jit::AddSizeOfBaselineData(script, rtStats->mallocSizeOf_, &realmStats.baselineData,
&realmStats.baselineStubsFallback);
realmStats.ionData += jit::SizeOfIonData(script, rtStats->mallocSizeOf_);
CollectScriptSourceStats<granularity>(closure, script->scriptSource());
break;
}
@ -633,7 +633,7 @@ ZoneStats::initStrings()
}
bool
CompartmentStats::initClasses()
RealmStats::initClasses()
{
isTotals = false;
allClasses = js_new<ClassesHashMap>();
@ -678,14 +678,14 @@ FindNotableStrings(ZoneStats& zStats)
}
static bool
FindNotableClasses(CompartmentStats& cStats)
FindNotableClasses(RealmStats& realmStats)
{
using namespace JS;
// We should only run FindNotableClasses once per ZoneStats object.
MOZ_ASSERT(cStats.notableClasses.empty());
MOZ_ASSERT(realmStats.notableClasses.empty());
for (CompartmentStats::ClassesHashMap::Range r = cStats.allClasses->all();
for (RealmStats::ClassesHashMap::Range r = realmStats.allClasses->all();
!r.empty();
r.popFront())
{
@ -697,19 +697,19 @@ FindNotableClasses(CompartmentStats& cStats)
if (!info.isNotable())
continue;
if (!cStats.notableClasses.growBy(1))
if (!realmStats.notableClasses.growBy(1))
return false;
cStats.notableClasses.back() = NotableClassInfo(className, info);
realmStats.notableClasses.back() = NotableClassInfo(className, info);
// We're moving this class from a non-notable to a notable bucket, so
// subtract it out of the non-notable tallies.
cStats.classInfo.subtract(info);
realmStats.classInfo.subtract(info);
}
// Delete |allClasses| now, rather than waiting for zStats's destruction,
// to reduce peak memory consumption during reporting.
js_delete(cStats.allClasses);
cStats.allClasses = nullptr;
js_delete(realmStats.allClasses);
realmStats.allClasses = nullptr;
return true;
}
@ -752,7 +752,7 @@ CollectRuntimeStatsHelper(JSContext* cx, RuntimeStats* rtStats, ObjectPrivateVis
bool anonymize, IterateCellCallback statsCellCallback)
{
JSRuntime* rt = cx->runtime();
if (!rtStats->compartmentStatsVector.reserve(rt->numCompartments))
if (!rtStats->realmStatsVector.reserve(rt->numCompartments))
return false;
size_t totalZones = rt->gc.zones().length() + 1; // + 1 for the atoms zone.
@ -773,10 +773,10 @@ CollectRuntimeStatsHelper(JSContext* cx, RuntimeStats* rtStats, ObjectPrivateVis
if (!closure.init())
return false;
IterateHeapUnbarriered(cx, &closure,
StatsZoneCallback,
StatsCompartmentCallback,
StatsArenaCallback,
statsCellCallback);
StatsZoneCallback,
StatsRealmCallback,
StatsArenaCallback,
statsCellCallback);
// Take the "explicit/js/runtime/" measurements.
rt->addSizeOfIncludingThis(rtStats->mallocSizeOf_, &rtStats->runtime);
@ -799,23 +799,23 @@ CollectRuntimeStatsHelper(JSContext* cx, RuntimeStats* rtStats, ObjectPrivateVis
MOZ_ASSERT(!zTotals.allStrings);
JS::CompartmentStatsVector& cs = rtStats->compartmentStatsVector;
CompartmentStats& cTotals = rtStats->cTotals;
JS::RealmStatsVector& realmStats = rtStats->realmStatsVector;
RealmStats& realmTotals = rtStats->realmTotals;
// As with the zones, we sum all compartments first, and then get the
// As with the zones, we sum all realms first, and then get the
// notable classes within each zone.
for (size_t i = 0; i < cs.length(); i++)
cTotals.addSizes(cs[i]);
for (size_t i = 0; i < realmStats.length(); i++)
realmTotals.addSizes(realmStats[i]);
for (size_t i = 0; i < cs.length(); i++) {
if (!FindNotableClasses(cs[i]))
for (size_t i = 0; i < realmStats.length(); i++) {
if (!FindNotableClasses(realmStats[i]))
return false;
}
MOZ_ASSERT(!cTotals.allClasses);
MOZ_ASSERT(!realmTotals.allClasses);
rtStats->gcHeapGCThings = rtStats->zTotals.sizeOfLiveGCThings() +
rtStats->cTotals.sizeOfLiveGCThings();
rtStats->realmTotals.sizeOfLiveGCThings();
#ifdef DEBUG
// Check that the in-arena measurements look ok.
@ -826,7 +826,7 @@ CollectRuntimeStatsHelper(JSContext* cx, RuntimeStats* rtStats, ObjectPrivateVis
#endif
for (CompartmentsIter comp(rt, WithAtoms); !comp.done(); comp.next())
comp->nullCompartmentStats();
comp->nullRealmStats();
size_t numDirtyChunks =
(rtStats->gcHeapChunkTotal - rtStats->gcHeapUnusedChunks) / gc::ChunkSize;
@ -872,7 +872,7 @@ JS::CollectRuntimeStats(JSContext* cx, RuntimeStats *rtStats, ObjectPrivateVisit
}
JS_PUBLIC_API(size_t)
JS::SystemCompartmentCount(JSContext* cx)
JS::SystemRealmCount(JSContext* cx)
{
size_t n = 0;
for (CompartmentsIter comp(cx->runtime(), WithAtoms); !comp.done(); comp.next()) {
@ -883,7 +883,7 @@ JS::SystemCompartmentCount(JSContext* cx)
}
JS_PUBLIC_API(size_t)
JS::UserCompartmentCount(JSContext* cx)
JS::UserRealmCount(JSContext* cx)
{
size_t n = 0;
for (CompartmentsIter comp(cx->runtime(), WithAtoms); !comp.done(); comp.next()) {
@ -912,8 +912,8 @@ class SimpleJSRuntimeStats : public JS::RuntimeStats
override
{}
virtual void initExtraCompartmentStats(
JSCompartment* c, JS::CompartmentStats* cStats) override
virtual void initExtraRealmStats(
JSCompartment* c, JS::RealmStats* realmStats) override
{}
};
@ -925,7 +925,7 @@ AddSizeOfTab(JSContext* cx, HandleObject obj, MallocSizeOf mallocSizeOf, ObjectP
JS::Zone* zone = GetObjectZone(obj);
if (!rtStats.compartmentStatsVector.reserve(zone->compartments().length()))
if (!rtStats.realmStatsVector.reserve(zone->compartments().length()))
return false;
if (!rtStats.zoneStatsVector.reserve(1))
@ -938,21 +938,21 @@ AddSizeOfTab(JSContext* cx, HandleObject obj, MallocSizeOf mallocSizeOf, ObjectP
return false;
IterateHeapUnbarrieredForZone(cx, zone, &closure,
StatsZoneCallback,
StatsCompartmentCallback,
StatsRealmCallback,
StatsArenaCallback,
StatsCellCallback<CoarseGrained>);
MOZ_ASSERT(rtStats.zoneStatsVector.length() == 1);
rtStats.zTotals.addSizes(rtStats.zoneStatsVector[0]);
for (size_t i = 0; i < rtStats.compartmentStatsVector.length(); i++)
rtStats.cTotals.addSizes(rtStats.compartmentStatsVector[i]);
for (size_t i = 0; i < rtStats.realmStatsVector.length(); i++)
rtStats.realmTotals.addSizes(rtStats.realmStatsVector[i]);
for (CompartmentsInZoneIter comp(zone); !comp.done(); comp.next())
comp->nullCompartmentStats();
comp->nullRealmStats();
rtStats.zTotals.addToTabSizes(sizes);
rtStats.cTotals.addToTabSizes(sizes);
rtStats.realmTotals.addToTabSizes(sizes);
return true;
}
@ -977,7 +977,7 @@ AddServoSizeOf(JSContext* cx, MallocSizeOf mallocSizeOf, ObjectPrivateVisitor* o
rtStats.addToServoSizes(sizes);
rtStats.zTotals.addToServoSizes(sizes);
rtStats.cTotals.addToServoSizes(sizes);
rtStats.realmTotals.addToServoSizes(sizes);
#ifdef DEBUG
size_t gcHeapTotal = sizes->gcHeapUsed +

Просмотреть файл

@ -2261,7 +2261,7 @@ GetNonexistentProperty(JSContext* cx, HandleId id, IsNameLookup nameLookup, Muta
//
// Don't warn if extra warnings not enabled or for random getprop
// operations.
if (MOZ_LIKELY(!cx->compartment()->behaviors().extraWarnings(cx)))
if (MOZ_LIKELY(!cx->realm()->behaviors().extraWarnings(cx)))
return true;
jsbytecode* pc;
@ -2456,7 +2456,7 @@ MaybeReportUndeclaredVarAssignment(JSContext* cx, HandleString propname)
// check is needed.
if (IsStrictSetPC(pc))
flags = JSREPORT_ERROR;
else if (cx->compartment()->behaviors().extraWarnings(cx))
else if (cx->realm()->behaviors().extraWarnings(cx))
flags = JSREPORT_WARNING | JSREPORT_STRICT;
else
return true;

Просмотреть файл

@ -34,7 +34,7 @@ using mozilla::PodZero;
// ObjectGroup
/////////////////////////////////////////////////////////////////////
ObjectGroup::ObjectGroup(const Class* clasp, TaggedProto proto, JSCompartment* comp,
ObjectGroup::ObjectGroup(const Class* clasp, TaggedProto proto, JS::Realm* realm,
ObjectGroupFlags initialFlags)
{
PodZero(this);
@ -45,7 +45,7 @@ ObjectGroup::ObjectGroup(const Class* clasp, TaggedProto proto, JSCompartment* c
this->clasp_ = clasp;
this->proto_ = proto;
this->compartment_ = comp;
this->realm_ = realm;
this->flags_ = initialFlags;
setGeneration(zone()->types.generation);
@ -1673,7 +1673,7 @@ ObjectGroupCompartment::makeGroup(JSContext* cx, const Class* clasp,
ObjectGroup* group = Allocate<ObjectGroup>(cx);
if (!group)
return nullptr;
new(group) ObjectGroup(clasp, proto, cx->compartment(), initialFlags);
new(group) ObjectGroup(clasp, proto, cx->realm(), initialFlags);
return group;
}

Просмотреть файл

@ -96,8 +96,8 @@ class ObjectGroup : public gc::TenuredCell
/* Prototype shared by objects in this group. */
GCPtr<TaggedProto> proto_;
/* Compartment shared by objects in this group. */
JSCompartment* compartment_;
/* Realm shared by objects in this group. */
JS::Realm* realm_;
public:
const Class* clasp() const {
@ -152,8 +152,9 @@ class ObjectGroup : public gc::TenuredCell
return res;
}
JSCompartment* compartment() const { return compartment_; }
JSCompartment* compartment() const { return JS::GetCompartmentForRealm(realm_); }
JSCompartment* maybeCompartment() const { return compartment(); }
JS::Realm* realm() const { return realm_; }
private:
/* Flags for this group. */
@ -377,7 +378,7 @@ class ObjectGroup : public gc::TenuredCell
Property** propertySet;
public:
inline ObjectGroup(const Class* clasp, TaggedProto proto, JSCompartment* comp,
inline ObjectGroup(const Class* clasp, TaggedProto proto, JS::Realm* realm,
ObjectGroupFlags initialFlags);
inline bool hasAnyFlags(const AutoSweepObjectGroup& sweep, ObjectGroupFlags flags);
@ -475,8 +476,8 @@ class ObjectGroup : public gc::TenuredCell
return offsetof(ObjectGroup, proto_);
}
static inline uint32_t offsetOfCompartment() {
return offsetof(ObjectGroup, compartment_);
static inline uint32_t offsetOfRealm() {
return offsetof(ObjectGroup, realm_);
}
static inline uint32_t offsetOfAddendum() {

Просмотреть файл

@ -222,7 +222,7 @@ JSRuntime::init(JSContext* cx, uint32_t maxbytes, uint32_t maxNurseryBytes)
return false;
JS::RealmOptions options;
ScopedJSDeletePtr<JSCompartment> atomsCompartment(js_new<JSCompartment>(atomsZone.get(), options));
ScopedJSDeletePtr<Realm> atomsCompartment(js_new<Realm>(atomsZone.get(), options));
if (!atomsCompartment || !atomsCompartment->init(nullptr))
return false;

Просмотреть файл

@ -262,7 +262,7 @@ SharedArrayBufferObject*
SharedArrayBufferObject::New(JSContext* cx, SharedArrayRawBuffer* buffer, uint32_t length,
HandleObject proto)
{
MOZ_ASSERT(cx->compartment()->creationOptions().getSharedMemoryAndAtomicsEnabled());
MOZ_ASSERT(cx->realm()->creationOptions().getSharedMemoryAndAtomicsEnabled());
AutoSetNewObjectMetadata metadata(cx);
Rooted<SharedArrayBufferObject*> obj(cx,
@ -358,7 +358,7 @@ SharedArrayBufferObject*
SharedArrayBufferObject::createFromNewRawBuffer(JSContext* cx, SharedArrayRawBuffer* buffer,
uint32_t initialSize)
{
MOZ_ASSERT(cx->compartment()->creationOptions().getSharedMemoryAndAtomicsEnabled());
MOZ_ASSERT(cx->realm()->creationOptions().getSharedMemoryAndAtomicsEnabled());
AutoSetNewObjectMetadata metadata(cx);
SharedArrayBufferObject* obj = NewObjectWithClassProto<SharedArrayBufferObject>(cx, nullptr);
@ -484,7 +484,7 @@ js::GetSharedArrayBufferLengthAndData(JSObject* obj, uint32_t* length, bool* isS
JS_FRIEND_API(JSObject*)
JS_NewSharedArrayBuffer(JSContext* cx, uint32_t nbytes)
{
MOZ_ASSERT(cx->compartment()->creationOptions().getSharedMemoryAndAtomicsEnabled());
MOZ_ASSERT(cx->realm()->creationOptions().getSharedMemoryAndAtomicsEnabled());
MOZ_ASSERT(nbytes <= INT32_MAX);
return SharedArrayBufferObject::New(cx, nbytes, /* proto = */ nullptr);

Просмотреть файл

@ -2056,7 +2056,7 @@ JSStructuredCloneReader::readSharedArrayBuffer(MutableHandleValue vp)
// transmission point, but that's tricky, and it will be a very rare problem
// in any case. Just fail at the receiving end if we can't handle it.
if (!context()->compartment()->creationOptions().getSharedMemoryAndAtomicsEnabled()) {
if (!context()->realm()->creationOptions().getSharedMemoryAndAtomicsEnabled()) {
JS_ReportErrorNumberASCII(context(), GetErrorMessage, nullptr, JSMSG_SC_SAB_DISABLED);
return false;
}

Просмотреть файл

@ -1795,7 +1795,7 @@ class MOZ_STACK_CLASS ModuleValidator
atomicsPresent_(false),
simdPresent_(false),
env_(CompileMode::Once, Tier::Ion, DebugEnabled::False, HasGcTypes::False,
cx->compartment()->creationOptions().getSharedMemoryAndAtomicsEnabled()
cx->realm()->creationOptions().getSharedMemoryAndAtomicsEnabled()
? Shareable::True
: Shareable::False,
ModuleKind::AsmJS),

Просмотреть файл

@ -103,7 +103,7 @@ class AstDecodeContext
d(d),
generateNames(generateNames),
env_(CompileMode::Once, Tier::Ion, DebugEnabled::False, HasGcTypes::False,
cx->compartment()->creationOptions().getSharedMemoryAndAtomicsEnabled()
cx->realm()->creationOptions().getSharedMemoryAndAtomicsEnabled()
? Shareable::True
: Shareable::False),
module_(module),

Просмотреть файл

@ -95,7 +95,7 @@ CompileArgs::initFromContext(JSContext* cx, ScriptedCaller&& scriptedCaller)
baselineEnabled = cx->options().wasmBaseline() || gcEnabled;
ionEnabled = cx->options().wasmIon() && !gcEnabled;
sharedMemoryEnabled = cx->compartment()->creationOptions().getSharedMemoryAndAtomicsEnabled();
sharedMemoryEnabled = cx->realm()->creationOptions().getSharedMemoryAndAtomicsEnabled();
gcTypesEnabled = gcEnabled ? HasGcTypes::True : HasGcTypes::False;
testTiering = (cx->options().testWasmAwaitTier2() || JitOptions.wasmDelayTier2) && !gcEnabled;

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше