Merge inbound to mozilla-central. a=merge

This commit is contained in:
Csoregi Natalia 2018-05-10 19:42:51 +03:00
Родитель 282a3f5586 26b590e899
Коммит 3f17a23476
345 изменённых файлов: 37831 добавлений и 30663 удалений

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

@ -113,14 +113,7 @@ AutoCompleteSearch.prototype =
stopSearch() {},
// nsISupports implementation
QueryInterface(iid) {
if (iid.equals(nsISupports) ||
iid.equals(nsIFactory) ||
iid.equals(nsIAutoCompleteSearch))
return this;
throw Cr.NS_ERROR_NO_INTERFACE;
},
QueryInterface: ChromeUtils.generateQI(["nsIFactory", "nsIAutoCompleteSearch"]),
// nsIFactory implementation
createInstance(outer, iid) {
@ -188,13 +181,7 @@ AutoCompleteResult.prototype =
removeValueAt(aRowIndex, aRemoveFromDb) {},
// nsISupports implementation
QueryInterface(iid) {
if (iid.equals(nsISupports) ||
iid.equals(nsIAutoCompleteResult))
return this;
throw Cr.NS_ERROR_NO_INTERFACE;
},
QueryInterface: ChromeUtils.generateQI(["nsIAutoCompleteResult"]),
// Data
values: null,

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

@ -0,0 +1,161 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
#include "LaunchUnelevated.h"
#include "mozilla/CmdLineAndEnvUtils.h"
#include "mozilla/mscom/COMApartmentRegion.h"
#include "mozilla/RefPtr.h"
#include "nsWindowsHelpers.h"
// For _bstr_t and _variant_t
#include <comdef.h>
#include <comutil.h>
#include <windows.h>
#include <exdisp.h>
#include <objbase.h>
#include <servprov.h>
#include <shlobj.h>
#include <shobjidl.h>
namespace mozilla {
// If we're running at an elevated integrity level, re-run ourselves at the
// user's normal integrity level. We do this by locating the active explorer
// shell, and then asking it to do a ShellExecute on our behalf. We do it this
// way to ensure that the child process runs as the original user in the active
// session; an elevated process could be running with different credentials than
// those of the session.
// See https://blogs.msdn.microsoft.com/oldnewthing/20131118-00/?p=2643
bool
LaunchUnelevated(int aArgc, wchar_t* aArgv[])
{
// We require a single-threaded apartment to talk to Explorer.
mscom::STARegion sta;
if (!sta.IsValid()) {
return false;
}
// NB: Explorer is a local server, not an inproc server
RefPtr<IShellWindows> shellWindows;
HRESULT hr = ::CoCreateInstance(CLSID_ShellWindows, nullptr,
CLSCTX_LOCAL_SERVER, IID_IShellWindows,
getter_AddRefs(shellWindows));
if (FAILED(hr)) {
return false;
}
// 1. Find the shell view for the desktop.
_variant_t loc(CSIDL_DESKTOP);
_variant_t empty;
long hwnd;
RefPtr<IDispatch> dispDesktop;
hr = shellWindows->FindWindowSW(&loc, &empty, SWC_DESKTOP, &hwnd,
SWFO_NEEDDISPATCH, getter_AddRefs(dispDesktop));
if (FAILED(hr)) {
return false;
}
RefPtr<IServiceProvider> servProv;
hr = dispDesktop->QueryInterface(IID_IServiceProvider, getter_AddRefs(servProv));
if (FAILED(hr)) {
return false;
}
RefPtr<IShellBrowser> browser;
hr = servProv->QueryService(SID_STopLevelBrowser, IID_IShellBrowser,
getter_AddRefs(browser));
if (FAILED(hr)) {
return false;
}
RefPtr<IShellView> activeShellView;
hr = browser->QueryActiveShellView(getter_AddRefs(activeShellView));
if (FAILED(hr)) {
return false;
}
// 2. Get the automation object for the desktop.
RefPtr<IDispatch> dispView;
hr = activeShellView->GetItemObject(SVGIO_BACKGROUND, IID_IDispatch,
getter_AddRefs(dispView));
if (FAILED(hr)) {
return false;
}
RefPtr<IShellFolderViewDual> folderView;
hr = dispView->QueryInterface(IID_IShellFolderViewDual,
getter_AddRefs(folderView));
if (FAILED(hr)) {
return false;
}
// 3. Get the interface to IShellDispatch2
RefPtr<IDispatch> dispShell;
hr = folderView->get_Application(getter_AddRefs(dispShell));
if (FAILED(hr)) {
return false;
}
RefPtr<IShellDispatch2> shellDisp;
hr = dispShell->QueryInterface(IID_IShellDispatch2, getter_AddRefs(shellDisp));
if (FAILED(hr)) {
return false;
}
// 4. Now call IShellDispatch2::ShellExecute to ask Explorer to re-launch us.
// Omit argv[0] because ShellExecute doesn't need it in params
UniquePtr<wchar_t[]> cmdLine(MakeCommandLine(aArgc - 1, aArgv + 1));
if (!cmdLine) {
return false;
}
_bstr_t exe(aArgv[0]);
_variant_t args(cmdLine.get());
_variant_t operation(L"open");
_variant_t directory;
_variant_t showCmd(SW_SHOWNORMAL);
hr = shellDisp->ShellExecute(exe, args, operation, directory, showCmd);
return SUCCEEDED(hr);
}
mozilla::Maybe<bool>
IsElevated()
{
HANDLE rawToken;
if (!::OpenProcessToken(::GetCurrentProcess(), TOKEN_QUERY, &rawToken)) {
return mozilla::Nothing();
}
nsAutoHandle token(rawToken);
DWORD reqdLen;
if (!::GetTokenInformation(token.get(), TokenIntegrityLevel, nullptr, 0,
&reqdLen) &&
::GetLastError() != ERROR_INSUFFICIENT_BUFFER) {
return mozilla::Nothing();
}
auto buf = mozilla::MakeUnique<char[]>(reqdLen);
if (!::GetTokenInformation(token.get(), TokenIntegrityLevel, buf.get(),
reqdLen, &reqdLen)) {
return mozilla::Nothing();
}
auto tokenLabel = reinterpret_cast<PTOKEN_MANDATORY_LABEL>(buf.get());
DWORD subAuthCount = *::GetSidSubAuthorityCount(tokenLabel->Label.Sid);
DWORD integrityLevel = *::GetSidSubAuthority(tokenLabel->Label.Sid,
subAuthCount - 1);
return mozilla::Some(integrityLevel > SECURITY_MANDATORY_MEDIUM_RID);
}
} // namespace mozilla

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

@ -0,0 +1,20 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
#ifndef mozilla_LaunchUnelevated_h
#define mozilla_LaunchUnelevated_h
#include "mozilla/Maybe.h"
namespace mozilla {
mozilla::Maybe<bool> IsElevated();
bool LaunchUnelevated(int aArgc, wchar_t* aArgv[]);
} // namespace mozilla
#endif // mozilla_LaunchUnelevated_h

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

@ -10,13 +10,18 @@
#include "mozilla/Attributes.h"
#include "mozilla/CmdLineAndEnvUtils.h"
#include "mozilla/DebugOnly.h"
#include "mozilla/DynamicallyLinkedFunctionPtr.h"
#include "mozilla/Maybe.h"
#include "mozilla/SafeMode.h"
#include "mozilla/UniquePtr.h"
#include "mozilla/WindowsVersion.h"
#include "nsWindowsHelpers.h"
#include <windows.h>
#include <processthreadsapi.h>
#include "LaunchUnelevated.h"
#include "ProcThreadAttributes.h"
/**
@ -32,6 +37,16 @@ PostCreationSetup(HANDLE aChildProcess, HANDLE aChildMainThread,
return true;
}
#if !defined(PROCESS_CREATION_MITIGATION_POLICY_IMAGE_LOAD_PREFER_SYSTEM32_ALWAYS_ON)
# define PROCESS_CREATION_MITIGATION_POLICY_IMAGE_LOAD_PREFER_SYSTEM32_ALWAYS_ON (0x00000001ui64 << 60)
#endif // !defined(PROCESS_CREATION_MITIGATION_POLICY_IMAGE_LOAD_PREFER_SYSTEM32_ALWAYS_ON)
#if (_WIN32_WINNT < 0x0602)
BOOL WINAPI
SetProcessMitigationPolicy(PROCESS_MITIGATION_POLICY aMitigationPolicy,
PVOID aBuffer, SIZE_T aBufferLen);
#endif // (_WIN32_WINNT >= 0x0602)
/**
* Any mitigation policies that should be set on the browser process should go
* here.
@ -39,6 +54,9 @@ PostCreationSetup(HANDLE aChildProcess, HANDLE aChildMainThread,
static void
SetMitigationPolicies(mozilla::ProcThreadAttributes& aAttrs, const bool aIsSafeMode)
{
if (mozilla::IsWin10November2015UpdateOrLater()) {
aAttrs.AddMitigationPolicy(PROCESS_CREATION_MITIGATION_POLICY_IMAGE_LOAD_PREFER_SYSTEM32_ALWAYS_ON);
}
}
static void
@ -77,6 +95,30 @@ RunAsLauncherProcess(int& argc, wchar_t** argv)
int
LauncherMain(int argc, wchar_t* argv[])
{
if (IsWin10November2015UpdateOrLater()) {
const DynamicallyLinkedFunctionPtr<decltype(&SetProcessMitigationPolicy)>
pSetProcessMitigationPolicy(L"kernel32.dll", "SetProcessMitigationPolicy");
if (pSetProcessMitigationPolicy) {
// Make sure that the launcher process itself has image load policies set
PROCESS_MITIGATION_IMAGE_LOAD_POLICY imgLoadPol = {};
imgLoadPol.PreferSystem32Images = 1;
DebugOnly<BOOL> setOk = pSetProcessMitigationPolicy(ProcessImageLoadPolicy,
&imgLoadPol,
sizeof(imgLoadPol));
MOZ_ASSERT(setOk);
}
}
Maybe<bool> isElevated = IsElevated();
if (!isElevated) {
return 1;
}
if (isElevated.value()) {
return !LaunchUnelevated(argc, argv);
}
UniquePtr<wchar_t[]> cmdLine(MakeCommandLine(argc, argv));
if (!cmdLine) {
return 1;

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

@ -1,5 +1,5 @@
<?xml version='1.0' encoding='UTF-8'?>
<blocklist lastupdate="1524147337556" xmlns="http://www.mozilla.org/2006/addons-blocklist">
<blocklist lastupdate="1525377135149" xmlns="http://www.mozilla.org/2006/addons-blocklist">
<emItems>
<emItem blockID="i334" id="{0F827075-B026-42F3-885D-98981EE7B1AE}">
<prefs/>
@ -2251,6 +2251,14 @@
<prefs/>
<versionRange minVersion="0" maxVersion="*" severity="3"/>
</emItem>
<emItem blockID="3ab9f100-e253-4080-b3e5-652f842ddb7a" id="/((@extcorp\.[a-z]+)|(@brcorporation\.com)|(@brmodcorp\.com)|(@teset\.com)|(@modext\.tech)|(@ext?mod\.net)|(@browcorporation\.org)|(@omegacorporation\.org)|(@browmodule\.com)|(@corpext\.net)|({6b50ddac-f5e0-4d9e-945b-e4165bfea5d6})|({fab6484f-b8a7-4ba9-a041-0f948518b80c})|({b797035a-7f29-4ff5-bd19-77f1b5e464b1})|({0f612416-5c5a-4ec8-b482-eb546af9cac4}))$/">
<prefs/>
<versionRange minVersion="0" maxVersion="*" severity="3"/>
</emItem>
<emItem blockID="3a123214-b4b6-410c-a061-bbaf0d168d31" id="/^(({41c14ab8-9958-44bf-b74e-af54c1f169a6})|({78054cb2-e3e8-4070-a8ad-3fd69c8e4707})|({0089b179-8f3d-44d9-bb18-582843b0757a})|({f44ddcb4-4cc0-4866-92fa-eefda60c6720})|({1893d673-7953-4870-8069-baac49ce3335})|({fb28cac0-c2aa-4e0c-a614-cf3641196237})|({d7dee150-da14-45ba-afca-02c7a79ad805})|(RandomNameTest@RandomNameTest\.com )|(corpsearchengine@mail\.ru)|(support@work\.org))$/">
<prefs/>
<versionRange minVersion="0" maxVersion="*" severity="3"/>
</emItem>
</emItems>
<pluginItems>
<pluginItem blockID="p332">

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

@ -64,6 +64,15 @@ if CONFIG['OS_ARCH'] == 'WINNT':
DEFINES['MOZ_PHOENIX'] = True
SOURCES += [
'LauncherProcessWin.cpp',
'LaunchUnelevated.cpp',
]
DELAYLOAD_DLLS += [
'oleaut32.dll',
'ole32.dll',
]
OS_LIBS += [
'oleaut32',
'ole32',
]
if CONFIG['MOZ_SANDBOX'] and CONFIG['OS_ARCH'] == 'WINNT':

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

@ -51,16 +51,7 @@ function test() {
req.cancel(Cr.NS_ERROR_FAILURE);
},
QueryInterface: function QueryInterface(aIID) {
if (aIID.equals(Ci.nsIWebProgressListener) ||
aIID.equals(Ci.nsIWebProgressListener2) ||
aIID.equals(Ci.nsISupportsWeakReference) ||
aIID.equals(Ci.nsISupports)) {
return this;
}
throw Cr.NS_ERROR_NO_INTERFACE;
}
QueryInterface: ChromeUtils.generateQI(["nsIWebProgressListener", "nsIWebProgressListener2", "nsISupportsWeakReference"])
};
let webProgress = docShell.QueryInterface(Ci.nsIInterfaceRequestor)

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

@ -58,13 +58,7 @@ function test() {
}
var gWebProgressListener = {
QueryInterface(aIID) {
if (aIID.equals(Ci.nsIWebProgressListener) ||
aIID.equals(Ci.nsISupportsWeakReference) ||
aIID.equals(Ci.nsISupports))
return this;
throw Cr.NS_NOINTERFACE;
},
QueryInterface: ChromeUtils.generateQI(["nsIWebProgressListener", "nsISupportsWeakReference"]),
// ---------------------------------------------------------------------------
// NOTIFY_LOCATION mode should work fine without these methods.

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

@ -89,12 +89,7 @@ function OpenCacheEntry(key, where, flags, lci) {
CacheListener.prototype = {
_appCache: null,
QueryInterface(iid) {
if (iid.equals(Ci.nsICacheEntryOpenCallback) ||
iid.equals(Ci.nsISupports))
return this;
throw Cr.NS_ERROR_NO_INTERFACE;
},
QueryInterface: ChromeUtils.generateQI(["nsICacheEntryOpenCallback"]),
onCacheEntryCheck(entry, appCache) {
return Ci.nsICacheEntryOpenCallback.ENTRY_WANTED;

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

@ -13,6 +13,10 @@ add_task(async function() {
let placementsAfterDrag = getAreaWidgetIds(CustomizableUI.AREA_NAVBAR);
placementsAfterDrag.splice(placementsAfterDrag.indexOf("forward-button"), 1);
placementsAfterDrag.splice(placementsAfterDrag.indexOf("urlbar-container"), 0, "forward-button");
// Force layout flush to ensure the drag completes as expected
urlbarContainer.clientWidth;
simulateItemDrag(forwardButton, urlbarContainer, "start");
assertAreaPlacements(CustomizableUI.AREA_NAVBAR, placementsAfterDrag);
ok(!CustomizableUI.inDefaultState, "Should no longer be in default state.");

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

@ -47,12 +47,7 @@ function cacheDataForContext(loadContextInfo) {
onCacheEntryVisitCompleted() {
resolve(cacheEntries);
},
QueryInterface(iid) {
if (iid.equals(Ci.nsICacheStorageVisitor))
return this;
throw Cr.NS_ERROR_NO_INTERFACE;
}
QueryInterface: ChromeUtils.generateQI(["nsICacheStorageVisitor"])
};
// Visiting the disk cache also visits memory storage so we do not
// need to use Services.cache2.memoryCacheStorage() here.

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

@ -25,12 +25,7 @@ function cacheDataForContext(loadContextInfo) {
onCacheEntryVisitCompleted() {
resolve(cachedURIs);
},
QueryInterface(iid) {
if (iid.equals(Ci.nsICacheStorageVisitor))
return this;
throw Cr.NS_ERROR_NO_INTERFACE;
}
QueryInterface: ChromeUtils.generateQI(["nsICacheStorageVisitor"])
};
// Visiting the disk cache also visits memory storage so we do not
// need to use Services.cache2.memoryCacheStorage() here.

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

@ -61,7 +61,7 @@ PlacesTreeView.prototype = {
return this.__xulStore;
},
QueryInterface: XPCOMUtils.generateQI(PTV_interfaces),
QueryInterface: ChromeUtils.generateQI(PTV_interfaces),
// Bug 761494:
// ----------

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

@ -8,6 +8,8 @@ Services.scriptloader.loadSubScript("resource://testing-common/sinon-2.3.2.js",
ChromeUtils.import("resource:///modules/PlacesUIUtils.jsm");
/* eslint-disable mozilla/use-chromeutils-generateqi */
add_task(async function test_no_result_node() {
let functionSpy = sinon.stub().returns(Promise.resolve());

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

@ -1,5 +1,7 @@
"use strict";
/* eslint-disable mozilla/use-chromeutils-generateqi */
var gTestTab;
var gContentAPI;
var gContentWindow;

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

@ -79,12 +79,7 @@ TestHangReport.prototype = {
return this._hangType;
},
QueryInterface(aIID) {
if (aIID.equals(Ci.nsIHangReport) ||
aIID.equals(Ci.nsISupports))
return this;
throw Cr.NS_NOINTERFACE;
},
QueryInterface: ChromeUtils.generateQI(["nsIHangReport"]),
userCanceled() {
this._resolver(TEST_ACTION_CANCELLED);

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

@ -224,7 +224,6 @@ def old_configure_options(*options):
'--enable-universalchardet',
'--enable-unsigned-overflow-sanitizer',
'--enable-updater',
'--enable-valgrind',
'--enable-verify-mar',
'--enable-xul',
'--enable-zipwriter',
@ -260,7 +259,6 @@ def old_configure_options(*options):
'--with-nspr-prefix',
'--with-nss-exec-prefix',
'--with-nss-prefix',
'--with-pthreads',
'--with-qemu-exe',
'--with-sixgill',
'--with-soft-float',

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

@ -495,7 +495,7 @@ def check_compiler(compiler, language, target):
if info.language == 'C++':
if info.type == 'clang' and info.language_version != cxx14_version:
append_flag('-std=gnu++14')
# MSVC 2015 headers include C++14 features, but don't guard them
# MSVC headers include C++14 features, but don't guard them
# with appropriate checks.
elif info.type == 'clang-cl' and info.language_version != cxx14_version:
append_flag('-std=c++14')
@ -561,21 +561,6 @@ def get_vc_paths(topsrcdir):
'json'
] + args).decode(encoding, 'replace'))
# Can't pass -requires with -legacy, so query each separately.
# Legacy versions first (VS2015)
for install in vswhere(['-legacy', '-version', '[14.0,15.0)']):
version = Version(install['installationVersion'])
# Skip anything older than VS2015.
if version < '14':
continue
path = install['installationPath']
yield (Version(install['installationVersion']), {
'x64': [os.path.join(path, r'VC\bin\amd64')],
# The x64->x86 cross toolchain requires DLLs from the native x64 toolchain.
'x86': [os.path.join(path, r'VC\bin\amd64_x86'), os.path.join(path, r'VC\bin\amd64')],
})
# Then VS2017 and newer.
for install in vswhere(['-requires', 'Microsoft.VisualStudio.Component.VC.Tools.x86.x64']):
path = install['installationPath']
tools_version = open(os.path.join(
@ -590,15 +575,14 @@ def get_vc_paths(topsrcdir):
js_option('--with-visual-studio-version', nargs=1,
choices=('2015', '2017'),
choices=('2017',),
help='Select a specific Visual Studio version to use')
@depends('--with-visual-studio-version')
def vs_major_version(value):
if value:
return {'2015': 14,
'2017': 15}[value[0]]
return {'2017': 15}[value[0]]
@depends(host, target, vs_major_version, check_build_environment, '--with-visual-studio-version')
@ -917,7 +901,18 @@ def compiler(language, host_or_target, c_compiler=None, other_compiler=None,
raise FatalCheckError(
'This version (%s) of the MSVC compiler is not '
'supported.\n'
'You must install Visual C++ 2017 Update 6 or newer in '
'You must install Visual C++ 2017 Update 6 in '
'order to build.\n'
'See https://developer.mozilla.org/en/'
'Windows_Build_Prerequisites' % info.version)
# MSVC version 15.7 and the previews for 15.8, at least,
# can't build Firefox.
if info.version >= '19.14.0':
raise FatalCheckError(
'This version (%s) of the MSVC compiler is not '
'supported due to compiler bugs.\n'
'You must install Visual C++ 2017 Update 6 in '
'order to build.\n'
'See https://developer.mozilla.org/en/'
'Windows_Build_Prerequisites' % info.version)
@ -1044,8 +1039,6 @@ def msvs_version(info):
if info.type in ('clang-cl', 'msvc'):
if info.version >= '19.10':
return '2017'
elif info.version >= '19.00':
return '2015'
return ''

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

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

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

@ -2343,6 +2343,23 @@ button.jump-definition {
border-top-color: var(--theme-body-background);
top: -1px;
}
.bracket-arrow.left::before {
border-left-color: transparent;
border-right-color: var(--theme-splitter-color);
top: 0px;
}
.theme-dark .bracket-arrow.left::before {
border-right-color: var(--theme-body-color);
}
.bracket-arrow.left::after {
border-left-color: transparent;
border-right-color: var(--theme-body-background);
top: 0px;
left: 1px;
}
/* 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/>. */
@ -2357,7 +2374,7 @@ button.jump-definition {
padding-top: 5px;
}
.popover .preview-popup {
.popover:not(.orientation-right) .preview-popup {
margin-left: -55px;
}
@ -3069,6 +3086,10 @@ html[dir="rtl"] .breakpoints-list .breakpoint .breakpoint-line {
visibility: visible;
}
.CodeMirror.cm-s-mozilla-breakpoint {
cursor: default;
}
.CodeMirror.cm-s-mozilla-breakpoint .CodeMirror-lines {
padding: 0;
}
@ -3091,7 +3112,6 @@ html[dir="rtl"] .breakpoints-list .breakpoint .breakpoint-line {
.CodeMirror.cm-s-mozilla-breakpoint .CodeMirror-code,
.CodeMirror.cm-s-mozilla-breakpoint .CodeMirror-scroll {
cursor: default;
pointer-events: none;
}
@ -3804,6 +3824,7 @@ img.skipPausing {
.secondary-panes .accordion {
flex: 1 0 auto;
margin-bottom: 0;
}
.secondary-panes-wrapper .accordion li:last-child ._content {

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

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

@ -1021,6 +1021,7 @@ function _parse(code, opts) {
const sourceOptions = {
generated: {
sourceType: "unambiguous",
tokens: true,
plugins: ["objectRestSpread"]
},
@ -2521,8 +2522,18 @@ Object.defineProperty(exports, "__esModule", {
});
exports.getFramework = getFramework;
var _types = __webpack_require__(2268);
var t = _interopRequireWildcard(_types);
var _getSymbols = __webpack_require__(1457);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
/* 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 getFramework(sourceId) {
const sourceSymbols = (0, _getSymbols.getSymbols)(sourceId);
@ -2539,10 +2550,6 @@ function getFramework(sourceId) {
// React
/* 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 isReactComponent(sourceSymbols) {
const { imports, classes, callExpressions } = sourceSymbols;
return importsReact(imports) || requiresReact(callExpressions) || extendsReactComponent(classes);
@ -2557,14 +2564,7 @@ function requiresReact(callExpressions) {
}
function extendsReactComponent(classes) {
let result = false;
classes.some(classObj => {
if (classObj.parent && (classObj.parent.name === "Component" || classObj.parent.name === "PureComponent" || classObj.parent.property.name === "Component")) {
result = true;
}
});
return result;
return classes.some(classObj => t.isIdentifier(classObj.parent, { name: "Component" }) || t.isIdentifier(classObj.parent, { name: "PureComponent" }) || t.isMemberExpression(classObj.parent, { computed: false }) && t.isIdentifier(classObj.parent, { name: "Component" }));
}
// Angular
@ -22866,7 +22866,7 @@ function fromBabelLocation(location, sourceId) {
};
}
function parseDeclarator(declaratorId, targetScope, type, declaration, state) {
function parseDeclarator(declaratorId, targetScope, type, locationType, declaration, state) {
if (isNode(declaratorId, "Identifier")) {
let existing = targetScope.bindings[declaratorId.name];
if (!existing) {
@ -22878,7 +22878,7 @@ function parseDeclarator(declaratorId, targetScope, type, declaration, state) {
}
state.declarationBindingIds.add(declaratorId);
existing.refs.push({
type: "decl",
type: locationType,
start: fromBabelLocation(declaratorId.loc.start, state.sourceId),
end: fromBabelLocation(declaratorId.loc.end, state.sourceId),
declaration: {
@ -22888,16 +22888,16 @@ function parseDeclarator(declaratorId, targetScope, type, declaration, state) {
});
} else if (isNode(declaratorId, "ObjectPattern")) {
declaratorId.properties.forEach(prop => {
parseDeclarator(prop.value, targetScope, type, declaration, state);
parseDeclarator(prop.value, targetScope, type, locationType, declaration, state);
});
} else if (isNode(declaratorId, "ArrayPattern")) {
declaratorId.elements.forEach(item => {
parseDeclarator(item, targetScope, type, declaration, state);
parseDeclarator(item, targetScope, type, locationType, declaration, state);
});
} else if (isNode(declaratorId, "AssignmentPattern")) {
parseDeclarator(declaratorId.left, targetScope, type, declaration, state);
parseDeclarator(declaratorId.left, targetScope, type, locationType, declaration, state);
} else if (isNode(declaratorId, "RestElement")) {
parseDeclarator(declaratorId.argument, targetScope, type, declaration, state);
parseDeclarator(declaratorId.argument, targetScope, type, locationType, declaration, state);
}
}
@ -22958,7 +22958,7 @@ const scopeCollectionVisitor = {
scope.bindings[node.id.name] = {
type: "const",
refs: [{
type: "decl",
type: "fn-expr",
start: fromBabelLocation(node.id.loc.start, state.sourceId),
end: fromBabelLocation(node.id.loc.end, state.sourceId),
declaration: {
@ -22977,7 +22977,7 @@ const scopeCollectionVisitor = {
scope.bindings[node.id.name] = {
type: fnScope === scope ? "var" : "let",
refs: [{
type: "decl",
type: "fn-decl",
start: fromBabelLocation(node.id.loc.start, state.sourceId),
end: fromBabelLocation(node.id.loc.end, state.sourceId),
declaration: {
@ -22995,7 +22995,7 @@ const scopeCollectionVisitor = {
end: fromBabelLocation(node.loc.end, state.sourceId)
});
node.params.forEach(param => parseDeclarator(param, scope, "var", node, state));
node.params.forEach(param => parseDeclarator(param, scope, "var", "fn-param", node, state));
if (!t.isArrowFunctionExpression(node)) {
scope.bindings.this = {
@ -23034,7 +23034,7 @@ const scopeCollectionVisitor = {
state.scope.bindings[node.id.name] = {
type: "let",
refs: [{
type: "decl",
type: "class-decl",
start: fromBabelLocation(node.id.loc.start, state.sourceId),
end: fromBabelLocation(node.id.loc.end, state.sourceId),
declaration
@ -23051,7 +23051,7 @@ const scopeCollectionVisitor = {
scope.bindings[node.id.name] = {
type: "const",
refs: [{
type: "decl",
type: "class-inner",
start: fromBabelLocation(node.id.loc.start, state.sourceId),
end: fromBabelLocation(node.id.loc.end, state.sourceId),
declaration
@ -23074,7 +23074,7 @@ const scopeCollectionVisitor = {
start: fromBabelLocation(node.loc.start, state.sourceId),
end: fromBabelLocation(node.loc.end, state.sourceId)
});
parseDeclarator(node.param, scope, "var", node, state);
parseDeclarator(node.param, scope, "var", "catch", node, state);
} else if (t.isBlockStatement(node) && hasLexicalDeclaration(node, parentNode)) {
// Debugger will create new lexical environment for the block.
pushTempScope(state, "block", "Block", {
@ -23087,7 +23087,7 @@ const scopeCollectionVisitor = {
// Finds right lexical environment
const hoistAt = !isLetOrConst(node) ? getVarScope(state.scope) : state.scope;
node.declarations.forEach(declarator => {
parseDeclarator(declarator.id, hoistAt, node.kind, node, state);
parseDeclarator(declarator.id, hoistAt, node.kind, node.kind, node, state);
});
} else if (t.isImportDeclaration(node) && (!node.importKind || node.importKind === "value")) {
node.specifiers.forEach(spec => {
@ -23099,7 +23099,7 @@ const scopeCollectionVisitor = {
// just normal const bindings.
type: "const",
refs: [{
type: "decl",
type: "import-ns-decl",
start: fromBabelLocation(spec.local.loc.start, state.sourceId),
end: fromBabelLocation(spec.local.loc.end, state.sourceId),
declaration: {
@ -23114,7 +23114,7 @@ const scopeCollectionVisitor = {
state.scope.bindings[spec.local.name] = {
type: "import",
refs: [{
type: "decl",
type: "import-decl",
start: fromBabelLocation(spec.local.loc.start, state.sourceId),
end: fromBabelLocation(spec.local.loc.end, state.sourceId),
importName: t.isImportDefaultSpecifier(spec) ? "default" : spec.imported.name,
@ -23131,7 +23131,7 @@ const scopeCollectionVisitor = {
state.scope.bindings[node.id.name] = {
type: "const",
refs: [{
type: "decl",
type: "ts-enum-decl",
start: fromBabelLocation(node.id.loc.start, state.sourceId),
end: fromBabelLocation(node.id.loc.end, state.sourceId),
declaration: {
@ -24999,9 +24999,7 @@ const {
isOriginalId
} = __webpack_require__(3652);
const {
workerUtils: { WorkerDispatcher }
} = __webpack_require__(3651);
const { workerUtils: { WorkerDispatcher } } = __webpack_require__(3651);
const dispatcher = new WorkerDispatcher();

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

@ -677,8 +677,8 @@ exports.findSourceMatches = findSourceMatches;
// Maybe reuse file search's functions?
function findSourceMatches(source, queryText) {
const text = source.text;
if (source.loadedState !== "loaded" || !text || queryText == "") {
const { id, loadedState, text } = source;
if (loadedState != "loaded" || !text || queryText == "") {
return [];
}
@ -686,12 +686,12 @@ function findSourceMatches(source, queryText) {
let result = undefined;
const query = new RegExp(queryText, "g");
let matches = lines.map((_text, line) => {
const matches = lines.map((_text, line) => {
const indices = [];
while (result = query.exec(_text)) {
indices.push({
sourceId: source.id,
sourceId: id,
line: line + 1,
column: result.index,
match: result[0],
@ -702,8 +702,7 @@ function findSourceMatches(source, queryText) {
return indices;
}).filter(_matches => _matches.length > 0);
matches = [].concat(...matches);
return matches;
return [].concat(...matches);
}
/***/ }),

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

@ -4,10 +4,13 @@ subsuite = devtools
skip-if = (os == 'linux' && debug && bits == 32)
support-files =
head.js
helpers.js
!/devtools/client/commandline/test/helpers.js
!/devtools/client/shared/test/shared-head.js
!/devtools/client/shared/test/telemetry-test-helpers.js
examples/babel/polyfill-bundle.js
examples/babel/fixtures/ts-classes/output.js
examples/babel/fixtures/ts-classes/output.js.map
examples/babel/fixtures/eval-source-maps/output.js
examples/babel/fixtures/eval-source-maps/output.js.map
examples/babel/fixtures/for-of/output.js

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

@ -128,8 +128,8 @@ function testImportedBindings(dbg) {
{
line: 25,
column: 16,
expression: "_mod4.original;",
result: '"an-original"',
expression: "_mod3.aNamed;",
result: '"a-named"',
},
{
line: 26,
@ -161,8 +161,8 @@ function testImportedBindings(dbg) {
{
line: 34,
column: 20,
expression: "_mod9.original;",
result: '"an-original2"',
expression: "_mod8.aNamed2;",
result: '"a-named2"',
},
{
line: 35,

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

@ -7,7 +7,7 @@ requestLongerTimeout(6);
// Tests loading sourcemapped sources for Babel's compile output.
async function breakpointScopes(dbg, fixture, { line, column }, scopes) {
const filename = `fixtures/${fixture}/input.js`;
const filename = `fixtures/${fixture}/input.`;
const fnName = fixture.replace(/-([a-z])/g, (s, c) => c.toUpperCase());
await invokeWithBreakpoint(dbg, fnName, filename, { line, column }, async () => {
@ -22,6 +22,21 @@ add_task(async function() {
const dbg = await initDebugger("doc-babel.html");
await breakpointScopes(dbg, "ts-classes", { line: 52, column: 4 }, [
"Module",
"AnotherThing()",
["anyWindow", "Window"],
"AppComponent()",
"decoratorFactory()",
"def()",
"ExportedOther()",
"ExpressionClass:Foo()",
"fn()",
["ns", '{\u2026}'],
"SubDecl()",
"SubVar:SubExpr()"
]);
await breakpointScopes(dbg, "eval-source-maps", { line: 14, column: 4 }, [
"Block",
["three", "5"],
@ -129,6 +144,9 @@ add_task(async function() {
["aNamespace", "{\u2026}"],
["aNamespace2", "{\u2026}"],
["aNamespace3", "{\u2026}"],
["anotherNamed", '"a-named"'],
["anotherNamed2", '"a-named2"'],
["anotherNamed3", '"a-named3"'],
["example", "(optimized away)"],
["optimizedOut", "(optimized away)"],
"root()"
@ -282,6 +300,9 @@ add_task(async function() {
["aNamespace", "{\u2026}"],
["aNamespace2", "{\u2026}"],
["aNamespace3", "{\u2026}"],
["anotherNamed", "Getter"],
["anotherNamed2", "Getter"],
["anotherNamed3", "Getter"],
["example", "(optimized away)"],
["optimizedOut", "(optimized away)"],
"root()"
@ -301,6 +322,9 @@ add_task(async function() {
["aNamespace", "{\u2026}"],
["aNamespace2", "{\u2026}"],
["aNamespace3", "{\u2026}"],
["anotherNamed", '"a-named"'],
["anotherNamed2", '"a-named2"'],
["anotherNamed3", '"a-named3"'],
["example", "(optimized away)"],
["optimizedOut", "(optimized away)"],
"root()"

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

@ -1,15 +1,15 @@
import aDefault from "./src/mod1";
import { aNamed } from "./src/mod2";
import { aNamed, aNamed as anotherNamed } from "./src/mod2";
import { original as anAliased } from "./src/mod3";
import * as aNamespace from "./src/mod4";
import aDefault2 from "./src/mod5";
import { aNamed2 } from "./src/mod6";
import { aNamed2, aNamed2 as anotherNamed2 } from "./src/mod6";
import { original as anAliased2 } from "./src/mod7";
import * as aNamespace2 from "./src/mod8";
import aDefault3 from "./src/mod9";
import { aNamed3 } from "./src/mod10";
import { aNamed3, aNamed3 as anotherNamed3 } from "./src/mod10";
import { original as anAliased3 } from "./src/mod11";
import * as aNamespace3 from "./src/mod12";
@ -22,7 +22,7 @@ export default function root() {
console.log(aDefault);
console.log(anAliased);
console.log(aNamed);
console.log(anAliased);
console.log(anotherNamed);
console.log(aNamespace);
try {
@ -31,13 +31,13 @@ export default function root() {
console.log(aDefault2());
console.log(anAliased2());
console.log(aNamed2());
console.log(anAliased2());
console.log(anotherNamed2());
console.log(aNamespace2());
console.log(new aDefault3());
console.log(new anAliased3());
console.log(new aNamed3());
console.log(new anAliased3());
console.log(new anotherNamed3());
console.log(new aNamespace3());
} catch (e) {}
}

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

@ -129,7 +129,7 @@ function root() {
console.log(_mod2.default);
console.log(_mod4.original);
console.log(_mod3.aNamed);
console.log(_mod4.original);
console.log(_mod3.aNamed);
console.log(aNamespace);
try {
@ -138,13 +138,13 @@ function root() {
console.log((0, _mod7.default)());
console.log((0, _mod9.original)());
console.log((0, _mod8.aNamed2)());
console.log((0, _mod9.original)());
console.log((0, _mod8.aNamed2)());
console.log(aNamespace2());
console.log(new _mod12.default());
console.log(new _mod14.original());
console.log(new _mod13.aNamed3());
console.log(new _mod14.original());
console.log(new _mod13.aNamed3());
console.log(new aNamespace3());
} catch (e) {}
}

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

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

@ -0,0 +1,54 @@
// This file essentially reproduces an example Angular component to map testing,
// among other typescript edge cases.
import def, { decoratorFactory } from './src/mod.ts';
import * as ns from './src/mod.ts';
@decoratorFactory({
selector: 'app-root',
})
export class AppComponent {
title = 'app';
}
const fn = arg => {
console.log("here");
};
fn("arg");
// Un-decorated exported classes present a mapping challege because
// the class name is mapped to an unhelpful export assignment.
export class ExportedOther {
title = 'app';
}
class AnotherThing {
prop = 4;
}
const ExpressionClass = class Foo {
prop = 4;
};
class SubDecl extends AnotherThing {
prop = 4;
}
let SubVar = class SubExpr extends AnotherThing {
prop = 4;
};
ns;
const anyWindow = (<any>window);
anyWindow.Promise.resolve().then(() => {
anyWindow.tsClasses = function() {
// This file is specifically for testing the mappings of classes and things
// above, which means we don't want to include _other_ references to then.
// To avoid having them be optimized out, we include a no-op eval.
eval("");
console.log("pause here");
};
});

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

@ -0,0 +1,181 @@
var tsClasses =
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, {
/******/ configurable: false,
/******/ enumerable: true,
/******/ get: getter
/******/ });
/******/ }
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 1);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
function decoratorFactory(opts) {
return function decorator(target) {
return target;
};
}
exports.decoratorFactory = decoratorFactory;
function def() { }
exports["default"] = def;
/***/ }),
/* 1 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
// This file essentially reproduces an example Angular component to map testing,
// among other typescript edge cases.
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
exports.__esModule = true;
var mod_ts_1 = __webpack_require__(0);
var ns = __webpack_require__(0);
var AppComponent = /** @class */ (function () {
function AppComponent() {
this.title = 'app';
}
AppComponent = __decorate([
mod_ts_1.decoratorFactory({
selector: 'app-root'
})
], AppComponent);
return AppComponent;
}());
exports.AppComponent = AppComponent;
var fn = function (arg) {
console.log("here");
};
fn("arg");
// Un-decorated exported classes present a mapping challege because
// the class name is mapped to an unhelpful export assignment.
var ExportedOther = /** @class */ (function () {
function ExportedOther() {
this.title = 'app';
}
return ExportedOther;
}());
exports.ExportedOther = ExportedOther;
var AnotherThing = /** @class */ (function () {
function AnotherThing() {
this.prop = 4;
}
return AnotherThing;
}());
var ExpressionClass = /** @class */ (function () {
function Foo() {
this.prop = 4;
}
return Foo;
}());
var SubDecl = /** @class */ (function (_super) {
__extends(SubDecl, _super);
function SubDecl() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.prop = 4;
return _this;
}
return SubDecl;
}(AnotherThing));
var SubVar = /** @class */ (function (_super) {
__extends(SubExpr, _super);
function SubExpr() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.prop = 4;
return _this;
}
return SubExpr;
}(AnotherThing));
ns;
var anyWindow = window;
anyWindow.Promise.resolve().then(function () {
anyWindow.tsClasses = function () {
// This file is specifically for testing the mappings of classes and things
// above, which means we don't want to include _other_ references to then.
// To avoid having them be optimized out, we include a no-op eval.
eval("");
console.log("pause here");
};
});
/***/ })
/******/ ]);
//# sourceMappingURL=output.js.map

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

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

@ -0,0 +1,8 @@
export function decoratorFactory(opts: { selector: string }) {
return function decorator(target) {
return <any>target;
};
}
export default function def() {}

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

@ -1,15 +1,15 @@
import aDefault from "./src/mod1";
import { aNamed } from "./src/mod2";
import { aNamed, aNamed as anotherNamed } from "./src/mod2";
import { original as anAliased } from "./src/mod3";
import * as aNamespace from "./src/mod4";
import aDefault2 from "./src/mod5";
import { aNamed2 } from "./src/mod6";
import { aNamed2, aNamed2 as anotherNamed2 } from "./src/mod6";
import { original as anAliased2 } from "./src/mod7";
import * as aNamespace2 from "./src/mod8";
import aDefault3 from "./src/mod9";
import { aNamed3 } from "./src/mod10";
import { aNamed3, aNamed3 as anotherNamed3 } from "./src/mod10";
import { original as anAliased3 } from "./src/mod11";
import * as aNamespace3 from "./src/mod12";
@ -22,7 +22,7 @@ export default function root() {
console.log(aDefault);
console.log(anAliased);
console.log(aNamed);
console.log(anAliased);
console.log(anotherNamed);
console.log(aNamespace);
try {
@ -31,13 +31,13 @@ export default function root() {
console.log(aDefault2());
console.log(anAliased2());
console.log(aNamed2());
console.log(anAliased2());
console.log(anotherNamed2());
console.log(aNamespace2());
console.log(new aDefault3());
console.log(new anAliased3());
console.log(new aNamed3());
console.log(new anAliased3());
console.log(new anotherNamed3());
console.log(new aNamespace3());
} catch (e) {}
}

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

@ -109,7 +109,7 @@ function root() {
console.log(__WEBPACK_IMPORTED_MODULE_0__src_mod1__["a" /* default */]);
console.log(__WEBPACK_IMPORTED_MODULE_2__src_mod3__["a" /* original */]);
console.log(__WEBPACK_IMPORTED_MODULE_1__src_mod2__["a" /* aNamed */]);
console.log(__WEBPACK_IMPORTED_MODULE_2__src_mod3__["a" /* original */]);
console.log(__WEBPACK_IMPORTED_MODULE_1__src_mod2__["a" /* aNamed */]);
console.log(__WEBPACK_IMPORTED_MODULE_3__src_mod4__);
try {
@ -118,13 +118,13 @@ function root() {
console.log(Object(__WEBPACK_IMPORTED_MODULE_4__src_mod5__["a" /* default */])());
console.log(Object(__WEBPACK_IMPORTED_MODULE_6__src_mod7__["a" /* original */])());
console.log(Object(__WEBPACK_IMPORTED_MODULE_5__src_mod6__["a" /* aNamed2 */])());
console.log(Object(__WEBPACK_IMPORTED_MODULE_6__src_mod7__["a" /* original */])());
console.log(Object(__WEBPACK_IMPORTED_MODULE_5__src_mod6__["a" /* aNamed2 */])());
console.log(__WEBPACK_IMPORTED_MODULE_7__src_mod8__());
console.log(new __WEBPACK_IMPORTED_MODULE_8__src_mod9__["a" /* default */]());
console.log(new __WEBPACK_IMPORTED_MODULE_10__src_mod11__["a" /* original */]());
console.log(new __WEBPACK_IMPORTED_MODULE_9__src_mod10__["a" /* aNamed3 */]());
console.log(new __WEBPACK_IMPORTED_MODULE_10__src_mod11__["a" /* original */]());
console.log(new __WEBPACK_IMPORTED_MODULE_9__src_mod10__["a" /* aNamed3 */]());
console.log(new __WEBPACK_IMPORTED_MODULE_11__src_mod12__());
} catch (e) {}
}

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

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

@ -1,15 +1,15 @@
import aDefault from "./src/mod1";
import { aNamed } from "./src/mod2";
import { aNamed, aNamed as anotherNamed } from "./src/mod2";
import { original as anAliased } from "./src/mod3";
import * as aNamespace from "./src/mod4";
import aDefault2 from "./src/mod5";
import { aNamed2 } from "./src/mod6";
import { aNamed2, aNamed2 as anotherNamed2 } from "./src/mod6";
import { original as anAliased2 } from "./src/mod7";
import * as aNamespace2 from "./src/mod8";
import aDefault3 from "./src/mod9";
import { aNamed3 } from "./src/mod10";
import { aNamed3, aNamed3 as anotherNamed3 } from "./src/mod10";
import { original as anAliased3 } from "./src/mod11";
import * as aNamespace3 from "./src/mod12";
@ -22,7 +22,7 @@ export default function root() {
console.log(aDefault);
console.log(anAliased);
console.log(aNamed);
console.log(anAliased);
console.log(anotherNamed);
console.log(aNamespace);
try {
@ -31,13 +31,13 @@ export default function root() {
console.log(aDefault2());
console.log(anAliased2());
console.log(aNamed2());
console.log(anAliased2());
console.log(anotherNamed2());
console.log(aNamespace2());
console.log(new aDefault3());
console.log(new anAliased3());
console.log(new aNamed3());
console.log(new anAliased3());
console.log(new anotherNamed3());
console.log(new aNamespace3());
} catch (e) {}
}

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

@ -109,7 +109,7 @@ function root() {
console.log(__WEBPACK_IMPORTED_MODULE_0__src_mod1__["a" /* default */]);
console.log(__WEBPACK_IMPORTED_MODULE_2__src_mod3__["a" /* original */]);
console.log(__WEBPACK_IMPORTED_MODULE_1__src_mod2__["a" /* aNamed */]);
console.log(__WEBPACK_IMPORTED_MODULE_2__src_mod3__["a" /* original */]);
console.log(__WEBPACK_IMPORTED_MODULE_1__src_mod2__["a" /* aNamed */]);
console.log(__WEBPACK_IMPORTED_MODULE_3__src_mod4__);
try {
@ -118,13 +118,13 @@ function root() {
console.log(Object(__WEBPACK_IMPORTED_MODULE_4__src_mod5__["a" /* default */])());
console.log(Object(__WEBPACK_IMPORTED_MODULE_6__src_mod7__["a" /* original */])());
console.log(Object(__WEBPACK_IMPORTED_MODULE_5__src_mod6__["a" /* aNamed2 */])());
console.log(Object(__WEBPACK_IMPORTED_MODULE_6__src_mod7__["a" /* original */])());
console.log(Object(__WEBPACK_IMPORTED_MODULE_5__src_mod6__["a" /* aNamed2 */])());
console.log(__WEBPACK_IMPORTED_MODULE_7__src_mod8__());
console.log(new __WEBPACK_IMPORTED_MODULE_8__src_mod9__["a" /* default */]());
console.log(new __WEBPACK_IMPORTED_MODULE_10__src_mod11__["a" /* original */]());
console.log(new __WEBPACK_IMPORTED_MODULE_9__src_mod10__["a" /* aNamed3 */]());
console.log(new __WEBPACK_IMPORTED_MODULE_10__src_mod11__["a" /* original */]());
console.log(new __WEBPACK_IMPORTED_MODULE_9__src_mod10__["a" /* aNamed3 */]());
console.log(new __WEBPACK_IMPORTED_MODULE_11__src_mod12__());
} catch (e) {}
}

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

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

@ -15,6 +15,8 @@
"babel-plugin-add-module-exports": "^0.2.1",
"babel-plugin-transform-flow-strip-types": "^6.22.0",
"babel-preset-env": "^1.6.1",
"ts-loader": "3.5",
"typescript": "^2.8.3",
"webpack": "^3.7.1"
},
"dependencies": {

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

@ -0,0 +1,10 @@
{
"compilerOptions": {
"sourceMap": true,
"experimentalDecorators": true
},
"include": [
"fixtures/*/input.ts",
"fixtures/*/src/*.ts"
]
}

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

@ -9,10 +9,13 @@ const tests = fs.readdirSync(fixtures).map(name => {
const dirname = path.relative(__dirname, path.join(fixtures, name));
const inputTS = path.join(dirname, "input.ts");
const inputJS = path.join(dirname, "input.js");
return {
name: _.camelCase(name),
dirname,
input: `./${path.join(dirname, "input.js")}`,
input: `./${fs.existsSync(inputTS) ? inputTS : inputJS}`,
output: path.join(dirname, "output.js")
};
}).filter(Boolean);
@ -68,9 +71,9 @@ module.exports = [
},
devtool,
module: {
loaders: babelEnabled
? [
{
loaders: [
babelEnabled
? {
test: /\.js$/,
exclude: /node_modules/,
loader: "babel-loader",
@ -85,8 +88,14 @@ module.exports = [
])
}
}
]
: []
: null,
{
test: /\.tsx?$/,
exclude: /node_modules/,
loader: "ts-loader",
options: {}
}
].filter(Boolean)
}
};
})

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

@ -57,6 +57,8 @@
<button onclick="thisArgumentsBindings()">Run thisArgumentsBindings</button>
<script src="babel/fixtures/try-catches/output.js"></script>
<button onclick="tryCatches()">Run tryCatches</button>
<script src="babel/fixtures/ts-classes/output.js"></script>
<button onclick="tsClasses()">Run tsClasses</button>
<script src="babel/fixtures/webpack-modules/output.js"></script>
<button onclick="webpackModules()">Run webpackModules</button>
<script src="babel/fixtures/webpack-modules-es6/output.js"></script>

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@ -44,6 +44,7 @@ support-files =
sjs_code_bundle_reload_map.sjs
test_browser_toolbox_debugger.js
!/devtools/client/debugger/new/test/mochitest/head.js
!/devtools/client/debugger/new/test/mochitest/helpers.js
!/devtools/client/shared/test/frame-script-utils.js
!/devtools/client/shared/test/shared-head.js
!/devtools/client/shared/test/shared-redux-head.js

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

@ -18,6 +18,7 @@ requestLongerTimeout(4);
const { fetch } = require("devtools/shared/DevToolsUtils");
const debuggerHeadURL = CHROME_URL_ROOT + "../../debugger/new/test/mochitest/head.js";
const helpersURL = CHROME_URL_ROOT + "../../debugger/new/test/mochitest/helpers.js";
const testScriptURL = CHROME_URL_ROOT + "test_browser_toolbox_debugger.js";
add_task(async function runTest() {
@ -121,11 +122,16 @@ add_task(async function runTest() {
// Stringify testHead's function and remove `(function {` prefix and `})` suffix
// to ensure inner symbols gets exposed to next pieces of code
// Then inject new debugger head file
let { content } = await fetch(debuggerHeadURL);
let debuggerHead = content;
let { content: debuggerHead } = await fetch(debuggerHeadURL);
// We remove its import of shared-head, which isn't available in browser toolbox process
// And isn't needed thanks to testHead's symbols
debuggerHead = debuggerHead.replace(/Services.scriptloader.loadSubScript[^\)]*\);/, "");
debuggerHead = debuggerHead.replace(/Services.scriptloader.loadSubScript[^\)]*\);/g, "");
// Also include the debugger helpers which are separated from debugger's head to be
// reused in other modules.
let { content: debuggerHelpers } = await fetch(helpersURL);
debuggerHead = debuggerHead + debuggerHelpers;
// Finally, fetch the debugger test script that is going to be execute in the browser
// toolbox process

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

@ -7,7 +7,7 @@
"use strict";
const {Ci, Cu, CC} = require("chrome");
const { XPCOMUtils } = require("resource://gre/modules/XPCOMUtils.jsm");
const ChromeUtils = require("ChromeUtils");
const Services = require("Services");
loader.lazyRequireGetter(this, "NetworkHelper",
@ -38,7 +38,7 @@ loader.lazyGetter(this, "jsonViewStrings", () => {
function Converter() {}
Converter.prototype = {
QueryInterface: XPCOMUtils.generateQI([
QueryInterface: ChromeUtils.generateQI([
Ci.nsIStreamConverter,
Ci.nsIStreamListener,
Ci.nsIRequestObserver

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

@ -53,7 +53,7 @@ const CONTENT_SNIFFER_CATEGORY = "net-content-sniffers";
function JsonViewSniffer() {}
JsonViewSniffer.prototype = {
QueryInterface: XPCOMUtils.generateQI([Ci.nsIContentSniffer]),
QueryInterface: ChromeUtils.generateQI([Ci.nsIContentSniffer]),
get wrappedJSObject() {
return this;

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

@ -5,7 +5,7 @@
"use strict";
const { Ci, Cu, Cr } = require("chrome");
const { XPCOMUtils } = require("resource://gre/modules/XPCOMUtils.jsm");
const ChromeUtils = require("ChromeUtils");
const Services = require("Services");
const { NetUtil } = require("resource://gre/modules/NetUtil.jsm");
const { Utils } = require("resource://gre/modules/sessionstore/Utils.jsm");
@ -33,7 +33,7 @@ function BrowserElementWebNavigation(browser) {
BrowserElementWebNavigation.prototype = {
QueryInterface: XPCOMUtils.generateQI([
QueryInterface: ChromeUtils.generateQI([
Ci.nsIWebNavigation
]),

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

@ -1612,9 +1612,7 @@ const { nodeIsError, nodeIsPrimitive } = node;
const selection = __webpack_require__(3698);
const { MODE } = __webpack_require__(3645);
const {
REPS: { Rep, Grip }
} = __webpack_require__(3647);
const { REPS: { Rep, Grip } } = __webpack_require__(3647);
function shouldRenderRootsInReps(roots) {
@ -3078,9 +3076,7 @@ function nodeNeedsNumericalBuckets(item) {
}
function makeNodesForPromiseProperties(item) {
const {
promiseState: { reason, value, state }
} = getValue(item);
const { promiseState: { reason, value, state } } = getValue(item);
const properties = [];

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

@ -430,9 +430,7 @@ const {
isOriginalId
} = __webpack_require__(3652);
const {
workerUtils: { WorkerDispatcher }
} = __webpack_require__(3651);
const { workerUtils: { WorkerDispatcher } } = __webpack_require__(3651);
const dispatcher = new WorkerDispatcher();

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

@ -1985,9 +1985,7 @@ const {
const { clearSourceMaps } = __webpack_require__(3704);
const {
workerUtils: { workerHandler }
} = __webpack_require__(3651);
const { workerUtils: { workerHandler } } = __webpack_require__(3651);
// The interface is implemented in source-map to be
// easier to unit test.

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

@ -65,7 +65,7 @@ registerCleanupFunction(function() {
* Watch console messages for failed propType definitions in React components.
*/
const ConsoleObserver = {
QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver]),
QueryInterface: ChromeUtils.generateQI([Ci.nsIObserver]),
observe: function(subject) {
let message = subject.wrappedJSObject.arguments[0];

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

@ -8,7 +8,7 @@ const { Ci } = require("chrome");
const InspectorUtils = require("InspectorUtils");
const Services = require("Services");
const { XPCOMUtils } = require("resource://gre/modules/XPCOMUtils.jsm");
const ChromeUtils = require("ChromeUtils");
const protocol = require("devtools/shared/protocol");
const { cssUsageSpec } = require("devtools/shared/specs/csscoverage");
@ -102,8 +102,8 @@ var CSSUsageActor = protocol.ActorClassWithSpec(cssUsageSpec, {
this._tooManyUnused = false;
this._progressListener = {
QueryInterface: XPCOMUtils.generateQI([ Ci.nsIWebProgressListener,
Ci.nsISupportsWeakReference ]),
QueryInterface: ChromeUtils.generateQI([ Ci.nsIWebProgressListener,
Ci.nsISupportsWeakReference ]),
onStateChange: (progress, request, flags, status) => {
let isStop = flags & Ci.nsIWebProgressListener.STATE_STOP;

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

@ -6,7 +6,7 @@
const { Ci, Cu } = require("chrome");
const { XPCOMUtils } = require("resource://gre/modules/XPCOMUtils.jsm");
const ChromeUtils = require("ChromeUtils");
const EventEmitter = require("devtools/shared/event-emitter");
const protocol = require("devtools/shared/protocol");
const Services = require("Services");
@ -579,7 +579,7 @@ HighlighterEnvironment.prototype = {
// navigated.
let self = this;
this.listener = {
QueryInterface: XPCOMUtils.generateQI([
QueryInterface: ChromeUtils.generateQI([
Ci.nsIWebProgressListener,
Ci.nsISupportsWeakReference
]),

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

@ -25,7 +25,7 @@
*/
const {Ci} = require("chrome");
const {XPCOMUtils} = require("resource://gre/modules/XPCOMUtils.jsm");
const ChromeUtils = require("ChromeUtils");
const protocol = require("devtools/shared/protocol");
const EventEmitter = require("devtools/shared/event-emitter");
const {reflowSpec} = require("devtools/shared/specs/reflow");
@ -460,7 +460,7 @@ class ReflowObserver extends Observable {
}
}
ReflowObserver.prototype.QueryInterface = XPCOMUtils
ReflowObserver.prototype.QueryInterface = ChromeUtils
.generateQI([Ci.nsIReflowObserver, Ci.nsISupportsWeakReference]);
/**

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

@ -14,7 +14,7 @@
var { Ci, Cu, Cr, Cc } = require("chrome");
var Services = require("Services");
var { XPCOMUtils } = require("resource://gre/modules/XPCOMUtils.jsm");
const ChromeUtils = require("ChromeUtils");
var {
ActorPool, createExtraActors, appendExtraActors
} = require("devtools/server/actors/common");
@ -1505,7 +1505,7 @@ function DebuggerProgressListener(tabActor) {
}
DebuggerProgressListener.prototype = {
QueryInterface: XPCOMUtils.generateQI([
QueryInterface: ChromeUtils.generateQI([
Ci.nsIWebProgressListener,
Ci.nsISupportsWeakReference,
]),

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

@ -5,7 +5,6 @@
"use strict";
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm", {});
const { XPCOMUtils } = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm", {});
ChromeUtils.defineModuleGetter(this, "E10SUtils",
"resource://gre/modules/E10SUtils.jsm");
@ -37,8 +36,8 @@ function ContentProcessForward() {
Services.cpmm.addMessageListener("DevTools:StopForwardingContentProcessMessage", this);
}
ContentProcessForward.prototype = {
QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver,
Ci.nsISupportsWeakReference]),
QueryInterface: ChromeUtils.generateQI([Ci.nsIObserver,
Ci.nsISupportsWeakReference]),
receiveMessage(message) {
if (message.name == "DevTools:StopForwardingContentProcessMessage") {

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

@ -7,7 +7,7 @@
const {Cc, Ci, components} = require("chrome");
const {isWindowIncluded} = require("devtools/shared/layout/utils");
const Services = require("Services");
const {XPCOMUtils} = require("resource://gre/modules/XPCOMUtils.jsm");
const ChromeUtils = require("ChromeUtils");
const {CONSOLE_WORKER_IDS, WebConsoleUtils} = require("devtools/server/actors/webconsole/utils");
loader.lazyRequireGetter(this, "EventEmitter", "devtools/shared/event-emitter");
@ -38,7 +38,7 @@ exports.ConsoleServiceListener = ConsoleServiceListener;
ConsoleServiceListener.prototype =
{
QueryInterface: XPCOMUtils.generateQI([Ci.nsIConsoleListener]),
QueryInterface: ChromeUtils.generateQI([Ci.nsIConsoleListener]),
/**
* The content window for which we listen to page errors.
@ -203,7 +203,7 @@ exports.ConsoleAPIListener = ConsoleAPIListener;
ConsoleAPIListener.prototype =
{
QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver]),
QueryInterface: ChromeUtils.generateQI([Ci.nsIObserver]),
/**
* The content window for which we listen to window.console API calls.
@ -390,8 +390,8 @@ exports.ConsoleReflowListener = ConsoleReflowListener;
ConsoleReflowListener.prototype =
{
QueryInterface: XPCOMUtils.generateQI([Ci.nsIReflowObserver,
Ci.nsISupportsWeakReference]),
QueryInterface: ChromeUtils.generateQI([Ci.nsIReflowObserver,
Ci.nsISupportsWeakReference]),
docshell: null,
listener: null,

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

@ -10,18 +10,15 @@ const {Cc, Ci, Cu, Cr} = require("chrome");
const {DebuggerServer} = require("devtools/server/main");
const Services = require("Services");
const ChromeUtils = require("ChromeUtils");
loader.lazyGetter(this, "NodeActor", () => require("devtools/server/actors/inspector/node").NodeActor, true);
const {
XPCOMUtils,
} = require("resource://gre/modules/XPCOMUtils.jsm");
const {
webExtensionInspectedWindowSpec,
} = require("devtools/shared/specs/webextension-inspected-window");
const {WebExtensionPolicy} = Cu.getGlobalForObject(XPCOMUtils);
const {WebExtensionPolicy} = Cu.getGlobalForObject(require("resource://gre/modules/XPCOMUtils.jsm"));
// A weak set of the documents for which a warning message has been
// already logged (so that we don't keep emitting the same warning if an
@ -112,8 +109,8 @@ function CustomizedReload(params) {
}
CustomizedReload.prototype = {
QueryInterface: XPCOMUtils.generateQI([Ci.nsIWebProgressListener,
Ci.nsISupportsWeakReference]),
QueryInterface: ChromeUtils.generateQI([Ci.nsIWebProgressListener,
Ci.nsISupportsWeakReference]),
get window() {
return this.docShell.DOMWindow;
},

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

@ -5,6 +5,7 @@
"use strict";
const { Ci } = require("chrome");
const ChromeUtils = require("ChromeUtils");
const { DebuggerServer } = require("devtools/server/main");
const Services = require("Services");
const { XPCOMUtils } = require("resource://gre/modules/XPCOMUtils.jsm");
@ -380,7 +381,7 @@ protocol.ActorClassWithSpec(serviceWorkerRegistrationSpec, {
unregisterFailed: function() {
console.error("Failed to unregister the service worker for " + scope);
},
QueryInterface: XPCOMUtils.generateQI(
QueryInterface: ChromeUtils.generateQI(
[Ci.nsIServiceWorkerUnregisterCallback])
};
swm.propagateUnregister(principal, unregisterCallback, scope);

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

@ -5,6 +5,8 @@
// Test the LayoutChangesObserver
/* eslint-disable mozilla/use-chromeutils-generateqi */
var {
getLayoutChangesObserver,
releaseLayoutChangesObserver,

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

@ -7,6 +7,7 @@
"use strict";
const {Cc, Ci, Cm, Cu, Cr, components} = require("chrome");
const ChromeUtils = require("ChromeUtils");
const Services = require("Services");
const { XPCOMUtils } = require("resource://gre/modules/XPCOMUtils.jsm");
@ -117,7 +118,7 @@ function ChannelEventSink() {
}
ChannelEventSink.prototype = {
QueryInterface: XPCOMUtils.generateQI([Ci.nsIChannelEventSink]),
QueryInterface: ChromeUtils.generateQI([Ci.nsIChannelEventSink]),
registerCollector(collector) {
this.collectors.add(collector);
@ -285,8 +286,8 @@ function NetworkResponseListener(owner, httpActivity) {
NetworkResponseListener.prototype = {
QueryInterface:
XPCOMUtils.generateQI([Ci.nsIStreamListener, Ci.nsIInputStreamCallback,
Ci.nsIRequestObserver, Ci.nsIInterfaceRequestor]),
ChromeUtils.generateQI([Ci.nsIStreamListener, Ci.nsIInputStreamCallback,
Ci.nsIRequestObserver, Ci.nsIInterfaceRequestor]),
// nsIInterfaceRequestor implementation
@ -2099,8 +2100,8 @@ ConsoleProgressListener.prototype = {
_webProgress: null,
QueryInterface: XPCOMUtils.generateQI([Ci.nsIWebProgressListener,
Ci.nsISupportsWeakReference]),
QueryInterface: ChromeUtils.generateQI([Ci.nsIWebProgressListener,
Ci.nsISupportsWeakReference]),
/**
* Initialize the ConsoleProgressListener.

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

@ -6,7 +6,6 @@
// Test that NetworkHelper.parseSecurityInfo returns correctly formatted object.
const { require } = ChromeUtils.import("resource://devtools/shared/Loader.jsm", {});
ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
Object.defineProperty(this, "NetworkHelper", {
get: function() {
@ -34,8 +33,8 @@ const MockCertificate = {
};
const MockSecurityInfo = {
QueryInterface: XPCOMUtils.generateQI([Ci.nsITransportSecurityInfo,
Ci.nsISSLStatusProvider]),
QueryInterface: ChromeUtils.generateQI([Ci.nsITransportSecurityInfo,
Ci.nsISSLStatusProvider]),
securityState: wpl.STATE_IS_SECURE,
errorCode: 0,
SSLStatus: {

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

@ -7,7 +7,6 @@
// different cases.
const { require } = ChromeUtils.import("resource://devtools/shared/Loader.jsm", {});
ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
Object.defineProperty(this, "NetworkHelper", {
get: function() {
@ -20,8 +19,8 @@ Object.defineProperty(this, "NetworkHelper", {
const wpl = Ci.nsIWebProgressListener;
const MockSecurityInfo = {
QueryInterface: XPCOMUtils.generateQI([Ci.nsITransportSecurityInfo,
Ci.nsISSLStatusProvider]),
QueryInterface: ChromeUtils.generateQI([Ci.nsITransportSecurityInfo,
Ci.nsISSLStatusProvider]),
securityState: wpl.STATE_IS_BROKEN,
errorCode: 0,
SSLStatus: {

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

@ -6,7 +6,6 @@
// Test that NetworkHelper.parseSecurityInfo correctly detects static hpkp pins
const { require } = ChromeUtils.import("resource://devtools/shared/Loader.jsm", {});
ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
const Services = require("Services");
Object.defineProperty(this, "NetworkHelper", {
@ -21,8 +20,8 @@ Object.defineProperty(this, "NetworkHelper", {
const wpl = Ci.nsIWebProgressListener;
const MockSecurityInfo = {
QueryInterface: XPCOMUtils.generateQI([Ci.nsITransportSecurityInfo,
Ci.nsISSLStatusProvider]),
QueryInterface: ChromeUtils.generateQI([Ci.nsITransportSecurityInfo,
Ci.nsISSLStatusProvider]),
securityState: wpl.STATE_IS_SECURE,
errorCode: 0,
SSLStatus: {

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

@ -3,6 +3,8 @@
"use strict";
/* eslint-disable mozilla/use-chromeutils-generateqi */
const { require } = ChromeUtils.import("resource://devtools/shared/Loader.jsm", {});
const defer = require("devtools/shared/defer");
const { NetworkThrottleManager } =

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

@ -17,7 +17,7 @@ loader.lazyServiceGetter(this, "gActivityDistributor",
"@mozilla.org/network/http-activity-distributor;1",
"nsIHttpActivityDistributor");
const {XPCOMUtils} = require("resource://gre/modules/XPCOMUtils.jsm");
const ChromeUtils = require("ChromeUtils");
const {setTimeout} = require("resource://gre/modules/Timer.jsm");
/**
@ -42,7 +42,7 @@ function NetworkThrottleListener(queue) {
NetworkThrottleListener.prototype = {
QueryInterface:
XPCOMUtils.generateQI([Ci.nsIStreamListener, Ci.nsIInterfaceRequestor]),
ChromeUtils.generateQI([Ci.nsIStreamListener, Ci.nsIInterfaceRequestor]),
/**
* Set the original listener for this object. The original listener

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

@ -890,7 +890,7 @@ DevToolsStartup.prototype = {
/* eslint-disable max-len */
classID: Components.ID("{9e9a9283-0ce9-4e4a-8f1c-ba129a032c32}"),
QueryInterface: XPCOMUtils.generateQI([Ci.nsICommandLineHandler]),
QueryInterface: ChromeUtils.generateQI([Ci.nsICommandLineHandler]),
};
/**

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

@ -1024,9 +1024,9 @@ StructuredCloneHolder::CustomReadHandler(JSContext* aCx,
return ReadFormData(aCx, aReader, aIndex, this);
}
if (aTag == SCTAG_DOM_IMAGEBITMAP) {
MOZ_ASSERT(mStructuredCloneScope == StructuredCloneScope::SameProcessSameThread ||
mStructuredCloneScope == StructuredCloneScope::SameProcessDifferentThread);
if (aTag == SCTAG_DOM_IMAGEBITMAP &&
(mStructuredCloneScope == StructuredCloneScope::SameProcessSameThread ||
mStructuredCloneScope == StructuredCloneScope::SameProcessDifferentThread)) {
// Get the current global object.
// This can be null.
@ -1040,7 +1040,9 @@ StructuredCloneHolder::CustomReadHandler(JSContext* aCx,
return StructuredCloneBlob::ReadStructuredClone(aCx, aReader, this);
}
if (aTag == SCTAG_DOM_WASM) {
if (aTag == SCTAG_DOM_WASM &&
(mStructuredCloneScope == StructuredCloneScope::SameProcessSameThread ||
mStructuredCloneScope == StructuredCloneScope::SameProcessDifferentThread)) {
return ReadWasmModule(aCx, aIndex, this);
}
@ -1175,9 +1177,9 @@ StructuredCloneHolder::CustomReadTransferHandler(JSContext* aCx,
return true;
}
if (aTag == SCTAG_DOM_CANVAS) {
MOZ_ASSERT(mStructuredCloneScope == StructuredCloneScope::SameProcessSameThread ||
mStructuredCloneScope == StructuredCloneScope::SameProcessDifferentThread);
if (aTag == SCTAG_DOM_CANVAS &&
(mStructuredCloneScope == StructuredCloneScope::SameProcessSameThread ||
mStructuredCloneScope == StructuredCloneScope::SameProcessDifferentThread)) {
MOZ_ASSERT(aContent);
OffscreenCanvasCloneData* data =
static_cast<OffscreenCanvasCloneData*>(aContent);
@ -1195,9 +1197,9 @@ StructuredCloneHolder::CustomReadTransferHandler(JSContext* aCx,
return true;
}
if (aTag == SCTAG_DOM_IMAGEBITMAP) {
MOZ_ASSERT(mStructuredCloneScope == StructuredCloneScope::SameProcessSameThread ||
mStructuredCloneScope == StructuredCloneScope::SameProcessDifferentThread);
if (aTag == SCTAG_DOM_IMAGEBITMAP &&
(mStructuredCloneScope == StructuredCloneScope::SameProcessSameThread ||
mStructuredCloneScope == StructuredCloneScope::SameProcessDifferentThread)) {
MOZ_ASSERT(aContent);
ImageBitmapCloneData* data =
static_cast<ImageBitmapCloneData*>(aContent);
@ -1320,9 +1322,9 @@ StructuredCloneHolder::CustomFreeTransferHandler(uint32_t aTag,
return;
}
if (aTag == SCTAG_DOM_CANVAS) {
MOZ_ASSERT(mStructuredCloneScope == StructuredCloneScope::SameProcessSameThread ||
mStructuredCloneScope == StructuredCloneScope::SameProcessDifferentThread);
if (aTag == SCTAG_DOM_CANVAS &&
(mStructuredCloneScope == StructuredCloneScope::SameProcessSameThread ||
mStructuredCloneScope == StructuredCloneScope::SameProcessDifferentThread)) {
MOZ_ASSERT(aContent);
OffscreenCanvasCloneData* data =
static_cast<OffscreenCanvasCloneData*>(aContent);
@ -1330,9 +1332,9 @@ StructuredCloneHolder::CustomFreeTransferHandler(uint32_t aTag,
return;
}
if (aTag == SCTAG_DOM_IMAGEBITMAP) {
MOZ_ASSERT(mStructuredCloneScope == StructuredCloneScope::SameProcessSameThread ||
mStructuredCloneScope == StructuredCloneScope::SameProcessDifferentThread);
if (aTag == SCTAG_DOM_IMAGEBITMAP &&
(mStructuredCloneScope == StructuredCloneScope::SameProcessSameThread ||
mStructuredCloneScope == StructuredCloneScope::SameProcessDifferentThread)) {
MOZ_ASSERT(aContent);
ImageBitmapCloneData* data =
static_cast<ImageBitmapCloneData*>(aContent);

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

@ -2963,7 +2963,8 @@ nsFrameLoader::EnsureMessageManager()
return NS_ERROR_FAILURE;
}
mChildMessageManager =
new nsInProcessTabChildGlobal(mDocShell, mOwnerContent, mMessageManager);
nsInProcessTabChildGlobal::Create(mDocShell, mOwnerContent, mMessageManager);
NS_ENSURE_TRUE(mChildMessageManager, NS_ERROR_UNEXPECTED);
}
return NS_OK;
}

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

@ -90,8 +90,8 @@ nsInProcessTabChildGlobal::DoSendAsyncMessage(JSContext* aCx,
nsInProcessTabChildGlobal::nsInProcessTabChildGlobal(nsIDocShell* aShell,
nsIContent* aOwner,
nsFrameMessageManager* aChrome)
: ContentFrameMessageManager(aChrome),
mDocShell(aShell), mInitialized(false), mLoadingScript(false),
: ContentFrameMessageManager(new nsFrameMessageManager(this)),
mDocShell(aShell), mLoadingScript(false),
mPreventEventsEscaping(false),
mOwner(aOwner), mChromeMessageManager(aChrome)
{
@ -123,17 +123,22 @@ nsInProcessTabChildGlobal::MarkForCC()
MessageManagerGlobal::MarkForCC();
}
nsresult
bool
nsInProcessTabChildGlobal::Init()
{
#ifdef DEBUG
nsresult rv =
#endif
InitTabChildGlobal();
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv),
"Couldn't initialize nsInProcessTabChildGlobal");
mMessageManager = new nsFrameMessageManager(this);
return NS_OK;
// If you change this, please change GetCompartmentName() in XPCJSContext.cpp
// accordingly.
nsAutoCString id;
id.AssignLiteral("inProcessTabChildGlobal");
nsIURI* uri = mOwner->OwnerDoc()->GetDocumentURI();
if (uri) {
nsAutoCString u;
nsresult rv = uri->GetSpec(u);
NS_ENSURE_SUCCESS(rv, false);
id.AppendLiteral("?ownedBy=");
id.Append(u);
}
return InitChildGlobalInternal(id);
}
NS_IMPL_CYCLE_COLLECTION_CLASS(nsInProcessTabChildGlobal)
@ -295,25 +300,6 @@ nsInProcessTabChildGlobal::GetEventTargetParent(EventChainPreVisitor& aVisitor)
}
}
nsresult
nsInProcessTabChildGlobal::InitTabChildGlobal()
{
// If you change this, please change GetCompartmentName() in XPCJSContext.cpp
// accordingly.
nsAutoCString id;
id.AssignLiteral("inProcessTabChildGlobal");
nsIURI* uri = mOwner->OwnerDoc()->GetDocumentURI();
if (uri) {
nsAutoCString u;
nsresult rv = uri->GetSpec(u);
NS_ENSURE_SUCCESS(rv, rv);
id.AppendLiteral("?ownedBy=");
id.Append(u);
}
NS_ENSURE_STATE(InitChildGlobalInternal(id));
return NS_OK;
}
class nsAsyncScriptLoad : public Runnable
{
public:
@ -344,10 +330,6 @@ nsInProcessTabChildGlobal::LoadFrameScript(const nsAString& aURL, bool aRunInGlo
nsContentUtils::AddScriptRunner(new nsAsyncScriptLoad(this, aURL, aRunInGlobalScope));
return;
}
if (!mInitialized) {
mInitialized = true;
Init();
}
bool tmp = mLoadingScript;
mLoadingScript = true;
JS::Rooted<JSObject*> global(mozilla::dom::RootingCx(), GetWrapper());

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

@ -9,6 +9,7 @@
#include "mozilla/Attributes.h"
#include "mozilla/DOMEventTargetHelper.h"
#include "mozilla/RefPtr.h"
#include "mozilla/dom/ContentFrameMessageManager.h"
#include "nsCOMPtr.h"
#include "nsFrameMessageManager.h"
@ -27,19 +28,35 @@ namespace mozilla {
class EventChainPreVisitor;
} // namespace mozilla
class nsInProcessTabChildGlobal : public mozilla::dom::ContentFrameMessageManager,
public nsMessageManagerScriptExecutor,
public nsIInProcessContentFrameMessageManager,
public nsIGlobalObject,
public nsIScriptObjectPrincipal,
public nsSupportsWeakReference,
public mozilla::dom::ipc::MessageManagerCallback
class nsInProcessTabChildGlobal final : public mozilla::dom::ContentFrameMessageManager,
public nsMessageManagerScriptExecutor,
public nsIInProcessContentFrameMessageManager,
public nsIGlobalObject,
public nsIScriptObjectPrincipal,
public nsSupportsWeakReference,
public mozilla::dom::ipc::MessageManagerCallback
{
typedef mozilla::dom::ipc::StructuredCloneData StructuredCloneData;
public:
private:
nsInProcessTabChildGlobal(nsIDocShell* aShell, nsIContent* aOwner,
nsFrameMessageManager* aChrome);
bool Init();
public:
static already_AddRefed<nsInProcessTabChildGlobal> Create(nsIDocShell* aShell,
nsIContent* aOwner,
nsFrameMessageManager* aChrome)
{
RefPtr<nsInProcessTabChildGlobal> global =
new nsInProcessTabChildGlobal(aShell, aOwner, aChrome);
NS_ENSURE_TRUE(global->Init(), nullptr);
return global.forget();
}
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(nsInProcessTabChildGlobal,
mozilla::DOMEventTargetHelper)
@ -123,10 +140,7 @@ public:
protected:
virtual ~nsInProcessTabChildGlobal();
nsresult Init();
nsresult InitTabChildGlobal();
nsCOMPtr<nsIDocShell> mDocShell;
bool mInitialized;
bool mLoadingScript;
// Is this the message manager for an in-process <iframe mozbrowser>? This

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

@ -85,6 +85,42 @@ nsStyleLinkElement::~nsStyleLinkElement()
nsStyleLinkElement::SetStyleSheet(nullptr);
}
void
nsStyleLinkElement::GetTitleAndMediaForElement(const Element& aSelf,
nsString& aTitle,
nsString& aMedia)
{
// Only honor title as stylesheet name for elements in the document (that is,
// ignore for Shadow DOM), per [1] and [2]. See [3].
//
// [1]: https://html.spec.whatwg.org/#attr-link-title
// [2]: https://html.spec.whatwg.org/#attr-style-title
// [3]: https://github.com/w3c/webcomponents/issues/535
if (aSelf.IsInUncomposedDoc()) {
aSelf.GetAttr(kNameSpaceID_None, nsGkAtoms::title, aTitle);
aTitle.CompressWhitespace();
}
aSelf.GetAttr(kNameSpaceID_None, nsGkAtoms::media, aMedia);
// The HTML5 spec is formulated in terms of the CSSOM spec, which specifies
// that media queries should be ASCII lowercased during serialization.
//
// FIXME(emilio): How does it matter? This is going to be parsed anyway, CSS
// should take care of serializing it properly.
nsContentUtils::ASCIIToLower(aMedia);
}
bool
nsStyleLinkElement::IsCSSMimeTypeAttribute(const Element& aSelf)
{
nsAutoString type;
nsAutoString mimeType;
nsAutoString notUsed;
aSelf.GetAttr(kNameSpaceID_None, nsGkAtoms::type, type);
nsContentUtils::SplitMimeType(type, mimeType, notUsed);
return mimeType.IsEmpty() || mimeType.LowerCaseEqualsLiteral("text/css");
}
void
nsStyleLinkElement::Unlink()
{

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

@ -93,6 +93,18 @@ protected:
mozilla::dom::ShadowRoot* aOldShadowRoot,
ForceUpdate = ForceUpdate::No);
// Gets a suitable title and media for SheetInfo out of an element, which
// needs to be `this`.
//
// NOTE(emilio): Needs nsString instead of nsAString because of
// CompressWhitespace.
static void GetTitleAndMediaForElement(const mozilla::dom::Element&,
nsString& aTitle,
nsString& aMedia);
// Returns whether the type attribute specifies the text/css mime type.
static bool IsCSSMimeTypeAttribute(const mozilla::dom::Element&);
virtual mozilla::Maybe<SheetInfo> GetStyleSheetInfo() = 0;
// CC methods

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

@ -13,28 +13,28 @@ namespace dom {
/*
* Utility function form libyuv source files.
*/
static __inline int32 clamp0(int32 v) {
static __inline int32_t clamp0(int32_t v) {
return ((-(v) >> 31) & (v));
}
static __inline int32 clamp255(int32 v) {
static __inline int32_t clamp255(int32_t v) {
return (((255 - (v)) >> 31) | (v)) & 255;
}
static __inline uint32 Clamp(int32 val) {
static __inline uint32_t Clamp(int32_t val) {
int v = clamp0(val);
return (uint32)(clamp255(v));
return (uint32_t)(clamp255(v));
}
#define YG 74 /* (int8)(1.164 * 64 + 0.5) */
#define YG 74 /* (int8_t)(1.164 * 64 + 0.5) */
#define UB 127 /* min(63,(int8)(2.018 * 64)) */
#define UG -25 /* (int8)(-0.391 * 64 - 0.5) */
#define UB 127 /* min(63,(int8_t)(2.018 * 64)) */
#define UG -25 /* (int8_t)(-0.391 * 64 - 0.5) */
#define UR 0
#define VB 0
#define VG -52 /* (int8)(-0.813 * 64 - 0.5) */
#define VR 102 /* (int8)(1.596 * 64 + 0.5) */
#define VG -52 /* (int8_t)(-0.813 * 64 - 0.5) */
#define VR 102 /* (int8_t)(1.596 * 64 + 0.5) */
// Bias
#define BB UB * 128 + VB * 128
@ -42,28 +42,28 @@ static __inline uint32 Clamp(int32 val) {
#define BR UR * 128 + VR * 128
static __inline void
YuvPixel(uint8 y, uint8 u, uint8 v, uint8* b, uint8* g, uint8* r)
YuvPixel(uint8_t y, uint8_t u, uint8_t v, uint8_t* b, uint8_t* g, uint8_t* r)
{
int32 y1 = ((int32)(y) - 16) * YG;
*b = Clamp((int32)((u * UB + v * VB) - (BB) + y1) >> 6);
*g = Clamp((int32)((u * UG + v * VG) - (BG) + y1) >> 6);
*r = Clamp((int32)((u * UR + v * VR) - (BR) + y1) >> 6);
int32_t y1 = ((int32_t)(y) - 16) * YG;
*b = Clamp((int32_t)((u * UB + v * VB) - (BB) + y1) >> 6);
*g = Clamp((int32_t)((u * UG + v * VG) - (BG) + y1) >> 6);
*r = Clamp((int32_t)((u * UR + v * VR) - (BR) + y1) >> 6);
}
static __inline int
RGBToY(uint8 r, uint8 g, uint8 b)
RGBToY(uint8_t r, uint8_t g, uint8_t b)
{
return (66 * r + 129 * g + 25 * b + 0x1080) >> 8;
}
static __inline int
RGBToU(uint8 r, uint8 g, uint8 b)
RGBToU(uint8_t r, uint8_t g, uint8_t b)
{
return (112 * b - 74 * g - 38 * r + 0x8080) >> 8;
}
static __inline int
RGBToV(uint8 r, uint8 g, uint8 b)
RGBToV(uint8_t r, uint8_t g, uint8_t b)
{
return (112 * r - 94 * g - 18 * b + 0x8080) >> 8;
}

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

@ -151,6 +151,7 @@ function test_changeDataWhileWorking() {
function test_setup() {
SpecialPowers.pushPrefEnv({"set": [["dom.input.dirpicker", true],
["dom.filesystem.pathcheck.disabled", true],
["dom.webkitBlink.dirPicker.enabled", true]]}, next);
}

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

@ -430,9 +430,13 @@ HTMLLinkElement::GetStyleSheetInfo()
return Nothing();
}
if (!IsCSSMimeTypeAttribute(*this)) {
return Nothing();
}
nsAutoString title;
GetAttr(kNameSpaceID_None, nsGkAtoms::title, title);
title.CompressWhitespace();
nsAutoString media;
GetTitleAndMediaForElement(*this, title, media);
bool alternate = linkTypes & nsStyleLinkElement::eALTERNATE;
if (alternate && title.IsEmpty()) {
@ -440,30 +444,12 @@ HTMLLinkElement::GetStyleSheetInfo()
return Nothing();
}
nsAutoString type;
nsAutoString mimeType;
nsAutoString notUsed;
GetAttr(kNameSpaceID_None, nsGkAtoms::type, type);
nsContentUtils::SplitMimeType(type, mimeType, notUsed);
if (!mimeType.IsEmpty() && !mimeType.LowerCaseEqualsLiteral("text/css")) {
return Nothing();
}
nsAutoString href;
GetAttr(kNameSpaceID_None, nsGkAtoms::href, href);
if (href.IsEmpty()) {
return Nothing();
}
nsAutoString media;
GetAttr(kNameSpaceID_None, nsGkAtoms::media, media);
// The HTML5 spec is formulated in terms of the CSSOM spec, which specifies
// that media queries should be ASCII lowercased during serialization.
//
// FIXME(emilio): How does it matter? This is going to be parsed anyway, CSS
// should take care of serializing it properly.
nsContentUtils::ASCIIToLower(media);
nsCOMPtr<nsIURI> uri = Link::GetURI();
nsCOMPtr<nsIPrincipal> prin = mTriggeringPrincipal;
return Some(SheetInfo {

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

@ -197,27 +197,14 @@ HTMLStyleElement::SetTextContentInternal(const nsAString& aTextContent,
Maybe<nsStyleLinkElement::SheetInfo>
HTMLStyleElement::GetStyleSheetInfo()
{
nsAutoString title;
GetAttr(kNameSpaceID_None, nsGkAtoms::title, title);
title.CompressWhitespace();
nsAutoString media;
GetAttr(kNameSpaceID_None, nsGkAtoms::media, media);
// The HTML5 spec is formulated in terms of the CSSOM spec, which specifies
// that media queries should be ASCII lowercased during serialization.
//
// FIXME(emilio): Doesn't matter I'd think, style should take care of that.
nsContentUtils::ASCIIToLower(media);
nsAutoString type;
nsAutoString mimeType;
nsAutoString notUsed;
GetAttr(kNameSpaceID_None, nsGkAtoms::type, type);
nsContentUtils::SplitMimeType(type, mimeType, notUsed);
if (!mimeType.IsEmpty() && !mimeType.LowerCaseEqualsLiteral("text/css")) {
if (!IsCSSMimeTypeAttribute(*this)) {
return Nothing();
}
nsAutoString title;
nsAutoString media;
GetTitleAndMediaForElement(*this, title, media);
nsCOMPtr<nsIPrincipal> prin = mTriggeringPrincipal;
return Some(SheetInfo {
*OwnerDoc(),

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

@ -5249,6 +5249,14 @@ ContentParent::RecvGetFilesRequest(const nsID& aUUID,
{
MOZ_ASSERT(!mGetFilesPendingRequests.GetWeak(aUUID));
if (!mozilla::Preferences::GetBool("dom.filesystem.pathcheck.disabled", false)) {
RefPtr<FileSystemSecurity> fss = FileSystemSecurity::Get();
if (NS_WARN_IF(!fss ||
!fss->ContentProcessHasAccessTo(ChildID(), aDirectoryPath))) {
return IPC_FAIL_NO_REASON(this);
}
}
ErrorResult rv;
RefPtr<GetFilesHelper> helper =
GetFilesHelperParent::Create(aUUID, aDirectoryPath, aRecursiveFlag, this,

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

@ -219,29 +219,24 @@ SVGStyleElement::SetTitle(const nsAString& aTitle, ErrorResult& rv)
Maybe<nsStyleLinkElement::SheetInfo>
SVGStyleElement::GetStyleSheetInfo()
{
nsAutoString title;
GetAttr(kNameSpaceID_None, nsGkAtoms::title, title);
title.CompressWhitespace();
nsAutoString media;
GetAttr(kNameSpaceID_None, nsGkAtoms::media, media);
// The SVG spec is formulated in terms of the CSS2 spec,
// which specifies that media queries are case insensitive.
nsContentUtils::ASCIIToLower(media);
// FIXME(emilio): Why doesn't this do the same as HTMLStyleElement?
nsAutoString type;
GetAttr(kNameSpaceID_None, nsGkAtoms::type, type);
if (!type.IsEmpty() && !type.LowerCaseEqualsLiteral("text/css")) {
if (!IsCSSMimeTypeAttribute(*this)) {
return Nothing();
}
nsAutoString title;
nsAutoString media;
GetTitleAndMediaForElement(*this, title, media);
return Some(SheetInfo {
*OwnerDoc(),
this,
nullptr,
// FIXME(bug 1459822): Why doesn't this need a principal, but
// HTMLStyleElement does?
nullptr,
net::ReferrerPolicy::RP_Unset,
// FIXME(bug 1459822): Why does this need a crossorigin attribute, but
// HTMLStyleElement doesn't?
AttrValueToCORSMode(GetParsedAttr(nsGkAtoms::crossorigin)),
title,
media,

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

@ -86,7 +86,7 @@ public:
// Count GL extensions
DECL_GFX_ENV("MOZ_GL_DUMP_EXTS", GlDumpExtensions);
// Very noisy GLContext and GLContextProviderELG
// Very noisy GLContext and GLContextProviderEGL
DECL_GFX_ENV("MOZ_GL_SPEW", GlSpew);
// Do extra work before and after each GLX call in GLContextProviderGLX

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

@ -12,6 +12,7 @@
#include "mozilla/Attributes.h"
#include "mozilla/Casting.h"
#include "mozilla/HashFunctions.h"
#include "mozilla/MemoryChecking.h"
#include "mozilla/MemoryReporting.h"
#include "mozilla/Move.h"
#include "mozilla/Opaque.h"
@ -811,17 +812,22 @@ class HashTableEntry
void operator=(const HashTableEntry&) = delete;
~HashTableEntry() = delete;
void destroyStoredT() {
mem.addr()->~T();
MOZ_MAKE_MEM_UNDEFINED(mem.addr(), sizeof(*mem.addr()));
}
public:
// NB: HashTableEntry is treated as a POD: no constructor or destructor calls.
void destroyIfLive() {
if (isLive())
mem.addr()->~T();
destroyStoredT();
}
void destroy() {
MOZ_ASSERT(isLive());
mem.addr()->~T();
destroyStoredT();
}
void swap(HashTableEntry* other) {
@ -837,20 +843,68 @@ class HashTableEntry
mozilla::Swap(keyHash, other->keyHash);
}
T& get() { MOZ_ASSERT(isLive()); return *mem.addr(); }
NonConstT& getMutable() { MOZ_ASSERT(isLive()); return *mem.addr(); }
T& get() {
MOZ_ASSERT(isLive());
return *mem.addr();
}
bool isFree() const { return keyHash == sFreeKey; }
void clearLive() { MOZ_ASSERT(isLive()); keyHash = sFreeKey; mem.addr()->~T(); }
void clear() { if (isLive()) mem.addr()->~T(); keyHash = sFreeKey; }
bool isRemoved() const { return keyHash == sRemovedKey; }
void removeLive() { MOZ_ASSERT(isLive()); keyHash = sRemovedKey; mem.addr()->~T(); }
bool isLive() const { return isLiveHash(keyHash); }
void setCollision() { MOZ_ASSERT(isLive()); keyHash |= sCollisionBit; }
void unsetCollision() { keyHash &= ~sCollisionBit; }
bool hasCollision() const { return keyHash & sCollisionBit; }
bool matchHash(HashNumber hn) { return (keyHash & ~sCollisionBit) == hn; }
HashNumber getKeyHash() const { return keyHash & ~sCollisionBit; }
NonConstT& getMutable() {
MOZ_ASSERT(isLive());
return *mem.addr();
}
bool isFree() const {
return keyHash == sFreeKey;
}
void clearLive() {
MOZ_ASSERT(isLive());
keyHash = sFreeKey;
destroyStoredT();
}
void clear() {
if (isLive())
destroyStoredT();
MOZ_MAKE_MEM_UNDEFINED(this, sizeof(*this));
keyHash = sFreeKey;
}
bool isRemoved() const {
return keyHash == sRemovedKey;
}
void removeLive() {
MOZ_ASSERT(isLive());
keyHash = sRemovedKey;
destroyStoredT();
}
bool isLive() const {
return isLiveHash(keyHash);
}
void setCollision() {
MOZ_ASSERT(isLive());
keyHash |= sCollisionBit;
}
void unsetCollision() {
keyHash &= ~sCollisionBit;
}
bool hasCollision() const {
return keyHash & sCollisionBit;
}
bool matchHash(HashNumber hn) {
return (keyHash & ~sCollisionBit) == hn;
}
HashNumber getKeyHash() const {
return keyHash & ~sCollisionBit;
}
template <typename... Args>
void setLive(HashNumber hn, Args&&... args)
@ -1670,14 +1724,10 @@ class HashTable : private AllocPolicy
public:
void clear()
{
if (mozilla::IsPod<Entry>::value) {
memset(table, 0, sizeof(*table) * capacity());
} else {
uint32_t tableCapacity = capacity();
Entry* end = table + tableCapacity;
for (Entry* e = table; e < end; ++e)
e->clear();
}
Entry* end = table + capacity();
for (Entry* e = table; e < end; ++e)
e->clear();
removedCount = 0;
entryCount = 0;
#ifdef JS_DEBUG

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

@ -28,6 +28,7 @@
#include "irregexp/RegExpEngine.h"
#include "irregexp/RegExpParser.h"
#endif
#include "gc/Heap.h"
#include "jit/BaselineJIT.h"
#include "jit/InlinableNatives.h"
#include "js/Debug.h"
@ -52,6 +53,7 @@
#include "vm/ProxyObject.h"
#include "vm/SavedStacks.h"
#include "vm/Stack.h"
#include "vm/StringType.h"
#include "vm/TraceLogging.h"
#include "wasm/AsmJS.h"
#include "wasm/WasmBinaryToText.h"
@ -66,6 +68,7 @@
#include "vm/JSContext-inl.h"
#include "vm/JSObject-inl.h"
#include "vm/NativeObject-inl.h"
#include "vm/StringType-inl.h"
using namespace js;
@ -1504,6 +1507,48 @@ NewMaybeExternalString(JSContext* cx, unsigned argc, Value* vp)
return true;
}
// Warning! This will let you create ropes that I'm not sure would be possible
// otherwise, specifically:
//
// - a rope with a zero-length child
// - a rope that would fit into an inline string
//
static bool
NewRope(JSContext* cx, unsigned argc, Value* vp)
{
CallArgs args = CallArgsFromVp(argc, vp);
if (!args.get(0).isString() || !args.get(1).isString()) {
JS_ReportErrorASCII(cx, "newRope requires two string arguments.");
return false;
}
gc::InitialHeap heap = js::gc::DefaultHeap;
if (args.get(2).isObject()) {
RootedObject options(cx, &args[2].toObject());
RootedValue v(cx);
if (!JS_GetProperty(cx, options, "nursery", &v))
return false;
if (!v.isUndefined() && !ToBoolean(v))
heap = js::gc::TenuredHeap;
}
JSString* left = args[0].toString();
JSString* right = args[1].toString();
size_t length = JS_GetStringLength(left) + JS_GetStringLength(right);
if (length > JSString::MAX_LENGTH) {
JS_ReportErrorASCII(cx, "rope length exceeds maximum string length");
return false;
}
Rooted<JSRope*> str(cx, JSRope::new_<NoGC>(cx, left, right, length, heap));
if (!str)
return false;
args.rval().setString(str);
return true;
}
static bool
EnsureFlatString(JSContext* cx, unsigned argc, Value* vp)
{
@ -5321,6 +5366,12 @@ static const JSFunctionSpecWithHelp TestingFunctions[] = {
" This function simulates interrupts similar to how oomTest simulates OOM conditions."),
#endif
JS_FN_HELP("newRope", NewRope, 3, 0,
"newRope(left, right[, options])",
" Creates a rope with the given left/right strings.\n"
" Available options:\n"
" nursery: bool - force the string to be created in/out of the nursery, if possible.\n"),
JS_FN_HELP("settlePromiseNow", SettlePromiseNow, 1, 0,
"settlePromiseNow(promise)",
" 'Settle' a 'promise' immediately. This just marks the promise as resolved\n"

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

@ -1621,7 +1621,6 @@ OutlineTypedObject::obj_trace(JSTracer* trc, JSObject* object)
// inline with it. Note that an array buffer pointing to data in an inline
// typed object will never be used as an owner for another outline typed
// object. In such cases, the owner will be the inline typed object itself.
MakeAccessibleAfterMovingGC(owner);
MOZ_ASSERT_IF(owner->is<ArrayBufferObject>(),
!owner->as<ArrayBufferObject>().forInlineTypedObject());
if (owner != oldOwner &&

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

@ -622,7 +622,7 @@ frontend::CompileGlobalScript(JSContext* cx, LifoAlloc& alloc, ScopeKind scopeKi
JSScript*
frontend::CompileGlobalBinASTScript(JSContext* cx, LifoAlloc& alloc, const ReadOnlyCompileOptions& options,
const uint8_t* src, size_t len)
const uint8_t* src, size_t len, ScriptSourceObject** sourceObjectOut)
{
AutoAssertReportedException assertException(cx);
@ -630,7 +630,7 @@ frontend::CompileGlobalBinASTScript(JSContext* cx, LifoAlloc& alloc, const ReadO
if (!usedNames.init())
return nullptr;
RootedObject sourceObj(cx, CreateScriptSourceObject(cx, options));
RootedScriptSourceObject sourceObj(cx, CreateScriptSourceObject(cx, options));
if (!sourceObj)
return nullptr;
@ -661,6 +661,9 @@ frontend::CompileGlobalBinASTScript(JSContext* cx, LifoAlloc& alloc, const ReadO
if (!NameFunctions(cx, pn))
return nullptr;
if (sourceObjectOut)
*sourceObjectOut = sourceObj;
assertException.reset();
return script;
}

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

@ -41,7 +41,8 @@ CompileGlobalScript(JSContext* cx, LifoAlloc& alloc, ScopeKind scopeKind,
JSScript*
CompileGlobalBinASTScript(JSContext *cx, LifoAlloc& alloc,
const ReadOnlyCompileOptions& options,
const uint8_t* src, size_t len);
const uint8_t* src, size_t len,
ScriptSourceObject** sourceObjectOut = nullptr);
#endif // JS_BUILD_BINAST

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

@ -7,6 +7,8 @@
#ifndef frontend_TokenKind_h
#define frontend_TokenKind_h
#include <stdint.h>
/*
* List of token kinds and their ranges.
*
@ -235,7 +237,8 @@ namespace frontend {
// Values of this type are used to index into arrays such as isExprEnding[],
// so the first value must be zero.
enum class TokenKind {
enum class TokenKind : uint8_t
{
#define EMIT_ENUM(name, desc) name,
#define EMIT_ENUM_RANGE(name, value) name = value,
FOR_EACH_TOKEN_KIND_WITH_RANGE(EMIT_ENUM, EMIT_ENUM_RANGE)

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@ -164,6 +164,7 @@
#include "mozilla/Assertions.h"
#include "mozilla/Attributes.h"
#include "mozilla/DebugOnly.h"
#include "mozilla/MemoryChecking.h"
#include "mozilla/PodOperations.h"
#include "mozilla/TypeTraits.h"
#include "mozilla/Unused.h"
@ -550,7 +551,11 @@ class TokenStreamAnyChars
template<typename CharT> friend class TokenStreamPosition;
// Accessors.
const Token& currentToken() const { return tokens[cursor]; }
unsigned cursor() const { return cursor_; }
unsigned nextCursor() const { return (cursor_ + 1) & ntokensMask; }
unsigned aheadCursor(unsigned steps) const { return (cursor_ + steps) & ntokensMask; }
const Token& currentToken() const { return tokens[cursor()]; }
bool isCurrentTokenType(TokenKind type) const {
return currentToken().type == type;
}
@ -661,7 +666,7 @@ class TokenStreamAnyChars
default:
MOZ_CRASH("unexpected modifier exception");
}
tokens[(cursor + 1) & ntokensMask].modifierException = modifierException;
tokens[nextCursor()].modifierException = modifierException;
#endif
}
@ -687,8 +692,8 @@ class TokenStreamAnyChars
return sourceMapURL_.get();
}
// This class maps a userbuf offset (which is 0-indexed) to a line number
// (which is 1-indexed) and a column index (which is 0-indexed).
// This class maps a sourceUnits offset (which is 0-indexed) to a line
// number (which is 1-indexed) and a column index (which is 0-indexed).
class SourceCoords
{
// For a given buffer holding source code, |lineStartOffsets_| has one
@ -794,16 +799,33 @@ class TokenStreamAnyChars
public:
const Token& nextToken() const {
MOZ_ASSERT(hasLookahead());
return tokens[(cursor + 1) & ntokensMask];
return tokens[nextCursor()];
}
bool hasLookahead() const { return lookahead > 0; }
void advanceCursor() {
cursor_ = (cursor_ + 1) & ntokensMask;
}
void retractCursor() {
cursor_ = (cursor_ - 1) & ntokensMask;
}
Token* allocateToken() {
advanceCursor();
Token* tp = &tokens[cursor()];
MOZ_MAKE_MEM_UNDEFINED(tp, sizeof(*tp));
return tp;
}
// Push the last scanned token back into the stream.
void ungetToken() {
MOZ_ASSERT(lookahead < maxLookahead);
lookahead++;
cursor = (cursor - 1) & ntokensMask;
retractCursor();
}
public:
@ -835,7 +857,9 @@ class TokenStreamAnyChars
const ReadOnlyCompileOptions& options_;
Token tokens[ntokens]; // circular token buffer
unsigned cursor; // index of last parsed token
private:
unsigned cursor_; // index of last parsed token
protected:
unsigned lookahead; // count of lookahead tokens
unsigned lineno; // current line number
TokenStreamFlags flags; // flags -- see above
@ -850,6 +874,134 @@ class TokenStreamAnyChars
StrictModeGetter* strictModeGetter; // used to test for strict mode
};
// This is the low-level interface to the JS source code buffer. It just gets
// raw Unicode code units -- 16-bit char16_t units of source text that are not
// (always) full code points, and 8-bit units of UTF-8 source text soon.
// TokenStreams functions are layered on top and do some extra stuff like
// converting all EOL sequences to '\n', tracking the line number, and setting
// |flags.isEOF|. (The "raw" in "raw Unicode code units" refers to the lack of
// EOL sequence normalization.)
//
// buf[0..length-1] often represents a substring of some larger source,
// where we have only the substring in memory. The |startOffset| argument
// indicates the offset within this larger string at which our string
// begins, the offset of |buf[0]|.
template<typename CharT>
class SourceUnits
{
public:
SourceUnits(const CharT* buf, size_t length, size_t startOffset)
: base_(buf),
startOffset_(startOffset),
limit_(buf + length),
ptr(buf)
{ }
bool hasRawChars() const {
return ptr < limit_;
}
bool atStart() const {
return offset() == 0;
}
size_t startOffset() const {
return startOffset_;
}
size_t offset() const {
return startOffset_ + mozilla::PointerRangeSize(base_, ptr);
}
const CharT* codeUnitPtrAt(size_t offset) const {
MOZ_ASSERT(startOffset_ <= offset);
MOZ_ASSERT(offset - startOffset_ <= mozilla::PointerRangeSize(base_, limit_));
return base_ + (offset - startOffset_);
}
const CharT* limit() const {
return limit_;
}
CharT getCodeUnit() {
return *ptr++; // this will nullptr-crash if poisoned
}
CharT peekCodeUnit() const {
return *ptr; // this will nullptr-crash if poisoned
}
bool matchCodeUnit(CharT c) {
if (*ptr == c) { // this will nullptr-crash if poisoned
ptr++;
return true;
}
return false;
}
/**
* Unget the '\n' (CR) that precedes a '\n' (LF), when ungetting a line
* terminator that's a full "\r\n" sequence. If the prior code unit isn't
* '\r', do nothing.
*/
void ungetOptionalCRBeforeLF() {
MOZ_ASSERT(ptr, "shouldn't unget a '\\r' from poisoned SourceUnits");
MOZ_ASSERT(*ptr == CharT('\n'),
"function should only be called when a '\\n' was just "
"ungotten, and any '\\r' preceding it must also be "
"ungotten");
if (*(ptr - 1) == CharT('\r'))
ptr--;
}
void ungetCodeUnit() {
MOZ_ASSERT(ptr); // make sure it hasn't been poisoned
ptr--;
}
const CharT* addressOfNextCodeUnit(bool allowPoisoned = false) const {
MOZ_ASSERT_IF(!allowPoisoned, ptr); // make sure it hasn't been poisoned
return ptr;
}
// Use this with caution!
void setAddressOfNextCodeUnit(const CharT* a, bool allowPoisoned = false) {
MOZ_ASSERT_IF(!allowPoisoned, a);
ptr = a;
}
// Poison the SourceUnits so they can't be accessed again.
void poisonInDebug() {
#ifdef DEBUG
ptr = nullptr;
#endif
}
static bool isRawEOLChar(int32_t c) {
return c == '\n' ||
c == '\r' ||
c == unicode::LINE_SEPARATOR ||
c == unicode::PARA_SEPARATOR;
}
// Returns the offset of the next EOL, but stops once 'max' characters
// have been scanned (*including* the char at startOffset_).
size_t findEOLMax(size_t start, size_t max);
private:
/** Base of buffer. */
const CharT* base_;
/** Offset of base_[0]. */
uint32_t startOffset_;
/** Limit for quick bounds check. */
const CharT* limit_;
/** Next char to get. */
const CharT* ptr;
};
template<typename CharT>
class TokenStreamCharsBase
{
@ -869,130 +1021,13 @@ class TokenStreamCharsBase
MOZ_MUST_USE bool copyTokenbufTo(JSContext* cx,
UniquePtr<char16_t[], JS::FreePolicy>* destination);
// This is the low-level interface to the JS source code buffer. It just
// gets raw chars, basically. TokenStreams functions are layered on top
// and do some extra stuff like converting all EOL sequences to '\n',
// tracking the line number, and setting |flags.isEOF|. (The "raw" in "raw
// chars" refers to the lack of EOL sequence normalization.)
//
// buf[0..length-1] often represents a substring of some larger source,
// where we have only the substring in memory. The |startOffset| argument
// indicates the offset within this larger string at which our string
// begins, the offset of |buf[0]|.
class TokenBuf
{
public:
TokenBuf(const CharT* buf, size_t length, size_t startOffset)
: base_(buf),
startOffset_(startOffset),
limit_(buf + length),
ptr(buf)
{ }
bool hasRawChars() const {
return ptr < limit_;
}
bool atStart() const {
return offset() == 0;
}
size_t startOffset() const {
return startOffset_;
}
size_t offset() const {
return startOffset_ + mozilla::PointerRangeSize(base_, ptr);
}
const CharT* rawCharPtrAt(size_t offset) const {
MOZ_ASSERT(startOffset_ <= offset);
MOZ_ASSERT(offset - startOffset_ <= mozilla::PointerRangeSize(base_, limit_));
return base_ + (offset - startOffset_);
}
const CharT* limit() const {
return limit_;
}
CharT getRawChar() {
return *ptr++; // this will nullptr-crash if poisoned
}
CharT peekRawChar() const {
return *ptr; // this will nullptr-crash if poisoned
}
bool matchRawChar(CharT c) {
if (*ptr == c) { // this will nullptr-crash if poisoned
ptr++;
return true;
}
return false;
}
bool matchRawCharBackwards(CharT c) {
MOZ_ASSERT(ptr); // make sure it hasn't been poisoned
if (*(ptr - 1) == c) {
ptr--;
return true;
}
return false;
}
void ungetRawChar() {
MOZ_ASSERT(ptr); // make sure it hasn't been poisoned
ptr--;
}
const CharT* addressOfNextRawChar(bool allowPoisoned = false) const {
MOZ_ASSERT_IF(!allowPoisoned, ptr); // make sure it hasn't been poisoned
return ptr;
}
// Use this with caution!
void setAddressOfNextRawChar(const CharT* a, bool allowPoisoned = false) {
MOZ_ASSERT_IF(!allowPoisoned, a);
ptr = a;
}
#ifdef DEBUG
// Poison the TokenBuf so it cannot be accessed again.
void poison() {
ptr = nullptr;
}
#endif
static bool isRawEOLChar(int32_t c) {
return c == '\n' ||
c == '\r' ||
c == unicode::LINE_SEPARATOR ||
c == unicode::PARA_SEPARATOR;
}
// Returns the offset of the next EOL, but stops once 'max' characters
// have been scanned (*including* the char at startOffset_).
size_t findEOLMax(size_t start, size_t max);
private:
/** Base of buffer. */
const CharT* base_;
/** Offset of base_[0]. */
uint32_t startOffset_;
/** Limit for quick bounds check. */
const CharT* limit_;
/** Next char to get. */
const CharT* ptr;
};
using SourceUnits = frontend::SourceUnits<CharT>;
MOZ_MUST_USE bool appendCodePointToTokenbuf(uint32_t codePoint);
protected:
/** User input buffer. */
TokenBuf userbuf;
/** Code units in the source code being tokenized. */
SourceUnits sourceUnits;
/** Current token string buffer. */
CharBuffer tokenbuf;
@ -1005,16 +1040,60 @@ TokenStreamCharsBase<char16_t>::atomizeChars(JSContext* cx, const char16_t* char
return AtomizeChars(cx, chars, length);
}
/** A small class encapsulating computation of the start-offset of a Token. */
class TokenStart
{
uint32_t startOffset_;
public:
/**
* Compute a starting offset that is the current offset of |sourceUnits|,
* offset by |adjust|. (For example, |adjust| of -1 indicates the code
* unit one backwards from |sourceUnits|'s current offset.)
*/
template<class SourceUnits>
TokenStart(const SourceUnits& sourceUnits, ptrdiff_t adjust)
: startOffset_(sourceUnits.offset() + adjust)
{}
TokenStart(const TokenStart&) = default;
uint32_t offset() const { return startOffset_; }
};
template<typename CharT, class AnyCharsAccess>
class GeneralTokenStreamChars
: public TokenStreamCharsBase<CharT>
{
using CharsSharedBase = TokenStreamCharsBase<CharT>;
protected:
using typename CharsSharedBase::TokenBuf;
Token* newTokenInternal(TokenKind kind, TokenStart start, TokenKind* out);
using CharsSharedBase::userbuf;
/**
* Allocates a new Token from the given offset to the current offset,
* ascribes it the given kind, and sets |*out| to that kind.
*/
Token* newToken(TokenKind kind, TokenStart start, TokenStreamShared::Modifier modifier,
TokenKind* out)
{
Token* token = newTokenInternal(kind, start, out);
#ifdef DEBUG
// Save the modifier used to get this token, so that if an ungetToken()
// occurs and then the token is re-gotten (or peeked, etc.), we can
// assert both gets used compatible modifiers.
token->modifier = modifier;
token->modifierException = TokenStreamShared::NoException;
#endif
return token;
}
protected:
using typename CharsSharedBase::SourceUnits;
using CharsSharedBase::sourceUnits;
using CharsSharedBase::ungetCharIgnoreEOL;
public:
using CharsSharedBase::CharsSharedBase;
@ -1036,9 +1115,55 @@ class GeneralTokenStreamChars
return static_cast<TokenStreamSpecific*>(this);
}
void newSimpleToken(TokenKind kind, TokenStart start, TokenStreamShared::Modifier modifier,
TokenKind* out)
{
newToken(kind, start, modifier, out);
}
void newNumberToken(double dval, DecimalPoint decimalPoint, TokenStart start,
TokenStreamShared::Modifier modifier, TokenKind* out)
{
Token* token = newToken(TokenKind::Number, start, modifier, out);
token->setNumber(dval, decimalPoint);
}
void newAtomToken(TokenKind kind, JSAtom* atom, TokenStart start,
TokenStreamShared::Modifier modifier, TokenKind* out)
{
MOZ_ASSERT(kind == TokenKind::String ||
kind == TokenKind::TemplateHead ||
kind == TokenKind::NoSubsTemplate);
Token* token = newToken(kind, start, modifier, out);
token->setAtom(atom);
}
void newNameToken(PropertyName* name, TokenStart start, TokenStreamShared::Modifier modifier,
TokenKind* out)
{
Token* token = newToken(TokenKind::Name, start, modifier, out);
token->setName(name);
}
void newRegExpToken(RegExpFlag reflags, TokenStart start,
TokenStreamShared::Modifier modifier, TokenKind* out)
{
Token* token = newToken(TokenKind::RegExp, start, modifier, out);
token->setRegExpFlags(reflags);
}
MOZ_COLD bool badToken();
int32_t getCharIgnoreEOL();
void ungetChar(int32_t c);
/**
* Consume characters til EOL/EOF following the start of a single-line
* comment, without consuming the EOL/EOF.
*/
void consumeRestOfSingleLineComment();
};
template<typename CharT, class AnyCharsAccess> class TokenStreamChars;
@ -1061,8 +1186,8 @@ class TokenStreamChars<char16_t, AnyCharsAccess>
protected:
using GeneralCharsBase::anyCharsAccess;
using GeneralCharsBase::getCharIgnoreEOL;
using GeneralCharsBase::sourceUnits;
using CharsSharedBase::ungetCharIgnoreEOL;
using GeneralCharsBase::userbuf;
using GeneralCharsBase::GeneralCharsBase;
@ -1101,8 +1226,8 @@ class TokenStreamChars<char16_t, AnyCharsAccess>
// linearly scans it into |Token|s.
//
// Internally the class uses a four element circular buffer |tokens| of
// |Token|s. As an index for |tokens|, the member |cursor| points to the
// current token. Calls to getToken() increase |cursor| by one and return the
// |Token|s. As an index for |tokens|, the member |cursor_| points to the
// current token. Calls to getToken() increase |cursor_| by one and return the
// new current token. If a TokenStream was just created, the current token is
// uninitialized. It's therefore important that one of the first four member
// functions listed below is called first. The circular buffer lets us go back
@ -1165,19 +1290,26 @@ class MOZ_STACK_CLASS TokenStreamSpecific
private:
using typename CharsSharedBase::CharBuffer;
using typename CharsSharedBase::TokenBuf;
using typename CharsSharedBase::SourceUnits;
private:
using CharsSharedBase::appendCodePointToTokenbuf;
using CharsSharedBase::atomizeChars;
using GeneralCharsBase::badToken;
using GeneralCharsBase::consumeRestOfSingleLineComment;
using CharsSharedBase::copyTokenbufTo;
using GeneralCharsBase::getCharIgnoreEOL;
using CharsBase::matchMultiUnitCodePoint;
using GeneralCharsBase::newAtomToken;
using GeneralCharsBase::newNameToken;
using GeneralCharsBase::newNumberToken;
using GeneralCharsBase::newRegExpToken;
using GeneralCharsBase::newSimpleToken;
using CharsSharedBase::sourceUnits;
using CharsSharedBase::tokenbuf;
using GeneralCharsBase::ungetChar;
using CharsSharedBase::ungetCharIgnoreEOL;
using CharsBase::ungetCodePointIgnoreEOL;
using CharsSharedBase::userbuf;
template<typename CharU> friend class TokenStreamPosition;
@ -1269,14 +1401,14 @@ class MOZ_STACK_CLASS TokenStreamSpecific
MOZ_ASSERT(anyChars.currentToken().type == TokenKind::TemplateHead ||
anyChars.currentToken().type == TokenKind::NoSubsTemplate);
const CharT* cur = userbuf.rawCharPtrAt(anyChars.currentToken().pos.begin + 1);
const CharT* cur = sourceUnits.codeUnitPtrAt(anyChars.currentToken().pos.begin + 1);
const CharT* end;
if (anyChars.currentToken().type == TokenKind::TemplateHead) {
// Of the form |`...${| or |}...${|
end = userbuf.rawCharPtrAt(anyChars.currentToken().pos.end - 2);
end = sourceUnits.codeUnitPtrAt(anyChars.currentToken().pos.end - 2);
} else {
// NO_SUBS_TEMPLATE is of the form |`...`| or |}...`|
end = userbuf.rawCharPtrAt(anyChars.currentToken().pos.end - 1);
end = sourceUnits.codeUnitPtrAt(anyChars.currentToken().pos.end - 1);
}
CharBuffer charbuf(anyChars.cx);
@ -1321,6 +1453,47 @@ class MOZ_STACK_CLASS TokenStreamSpecific
MOZ_MUST_USE bool putIdentInTokenbuf(const CharT* identStart);
/**
* Tokenize a decimal number that begins at |numStart| into the provided
* token.
*
* |c| must be one of these values:
*
* 1. The first decimal digit in the integral part of a decimal number
* not starting with '0' or '.', e.g. '1' for "17", '3' for "3.14", or
* '8' for "8.675309e6".
*
* In this case, the next |getCharIgnoreEOL()| must return the code unit
* after |c| in the overall number.
*
* 2. The '.' in a "."/"0."-prefixed decimal number or the 'e'/'E' in a
* "0e"/"0E"-prefixed decimal number, e.g. ".17", "0.42", or "0.1e3".
*
* In this case, the next |getCharIgnoreEOL()| must return the code unit
* *after* the first decimal digit *after* the '.'. So the next code
* unit would be '7' in ".17", '2' in "0.42", 'e' in "0.4e+8", or '/' in
* "0.5/2" (three separate tokens).
*
* 3. The code unit after the '0' where "0" is the entire number token.
*
* In this case, the next |getCharIgnoreEOL()| returns the code unit
* after |c|.
*
* 4. (Non-strict mode code only) The first '8' or '9' in a "noctal"
* number that begins with a '0' but contains a non-octal digit in its
* integer part so is interpreted as decimal, e.g. '9' in "09.28" or
* '8' in "0386" or '9' in "09+7" (three separate tokens").
*
* In this case, the next |getCharIgnoreEOL()| returns the code unit
* after |c|: '.', '6', or '+' in the examples above.
*
* This interface is super-hairy and horribly stateful. Unfortunately, its
* hair merely reflects the intricacy of ECMAScript numeric literal syntax.
* And incredibly, it *improves* on the goto-based horror that predated it.
*/
MOZ_MUST_USE bool decimalNumber(int c, TokenStart start, const CharT* numStart,
Modifier modifier, TokenKind* out);
public:
// Advance to the next token. If the token stream encountered an error,
// return false. Otherwise return true and store the token kind in |*ttp|.
@ -1330,7 +1503,7 @@ class MOZ_STACK_CLASS TokenStreamSpecific
if (anyChars.lookahead != 0) {
MOZ_ASSERT(!anyChars.flags.hadError);
anyChars.lookahead--;
anyChars.cursor = (anyChars.cursor + 1) & ntokensMask;
anyChars.advanceCursor();
TokenKind tt = anyChars.currentToken().type;
MOZ_ASSERT(tt != TokenKind::Eol);
verifyConsistentModifier(modifier, anyChars.currentToken());
@ -1472,20 +1645,21 @@ class MOZ_STACK_CLASS TokenStreamSpecific
void seek(const Position& pos);
MOZ_MUST_USE bool seek(const Position& pos, const TokenStreamAnyChars& other);
const CharT* rawCharPtrAt(size_t offset) const {
return userbuf.rawCharPtrAt(offset);
const CharT* codeUnitPtrAt(size_t offset) const {
return sourceUnits.codeUnitPtrAt(offset);
}
const CharT* rawLimit() const {
return userbuf.limit();
return sourceUnits.limit();
}
MOZ_MUST_USE bool identifierName(Token* token, const CharT* identStart,
IdentifierEscapes escaping);
MOZ_MUST_USE bool identifierName(TokenStart start, const CharT* identStart,
IdentifierEscapes escaping, Modifier modifier,
TokenKind* out);
MOZ_MUST_USE bool getTokenInternal(TokenKind* ttp, Modifier modifier);
MOZ_MUST_USE bool getTokenInternal(TokenKind* const ttp, const Modifier modifier);
MOZ_MUST_USE bool getStringOrTemplateToken(char untilChar, Token** tp);
MOZ_MUST_USE bool getStringOrTemplateToken(char untilChar, Modifier modifier, TokenKind* out);
// Try to get the next character, normalizing '\r', '\r\n', and '\n' into
// '\n'. Also updates internal line-counter state. Return true on success
@ -1493,7 +1667,6 @@ class MOZ_STACK_CLASS TokenStreamSpecific
// on failure.
MOZ_MUST_USE bool getChar(int32_t* cp);
Token* newToken(ptrdiff_t adjust);
uint32_t peekUnicodeEscape(uint32_t* codePoint);
uint32_t peekExtendedUnicodeEscape(uint32_t* codePoint);
uint32_t matchUnicodeEscapeIdStart(uint32_t* codePoint);
@ -1510,8 +1683,8 @@ class MOZ_STACK_CLASS TokenStreamSpecific
// |expect| cannot be an EOL char.
bool matchChar(int32_t expect) {
MOZ_ASSERT(!TokenBuf::isRawEOLChar(expect));
return MOZ_LIKELY(userbuf.hasRawChars()) && userbuf.matchRawChar(expect);
MOZ_ASSERT(!SourceUnits::isRawEOLChar(expect));
return MOZ_LIKELY(sourceUnits.hasRawChars()) && sourceUnits.matchCodeUnit(expect);
}
void consumeKnownChar(int32_t expect) {
@ -1520,6 +1693,14 @@ class MOZ_STACK_CLASS TokenStreamSpecific
MOZ_ASSERT(c == expect);
}
void consumeKnownCharIgnoreEOL(int32_t expect) {
#ifdef DEBUG
auto c =
#endif
getCharIgnoreEOL();
MOZ_ASSERT(c == expect);
}
MOZ_MUST_USE bool peekChar(int32_t* c) {
if (!getChar(c))
return false;
@ -1529,15 +1710,15 @@ class MOZ_STACK_CLASS TokenStreamSpecific
void skipChars(uint32_t n) {
while (n-- > 0) {
MOZ_ASSERT(userbuf.hasRawChars());
MOZ_ASSERT(sourceUnits.hasRawChars());
mozilla::DebugOnly<int32_t> c = getCharIgnoreEOL();
MOZ_ASSERT(!TokenBuf::isRawEOLChar(c));
MOZ_ASSERT(!SourceUnits::isRawEOLChar(c));
}
}
void skipCharsIgnoreEOL(uint8_t n) {
while (n-- > 0) {
MOZ_ASSERT(userbuf.hasRawChars());
MOZ_ASSERT(sourceUnits.hasRawChars());
getCharIgnoreEOL();
}
}
@ -1559,17 +1740,15 @@ TokenStreamPosition<CharT>::TokenStreamPosition(AutoKeepAtoms& keepAtoms,
{
TokenStreamAnyChars& anyChars = tokenStream.anyCharsAccess();
buf = tokenStream.userbuf.addressOfNextRawChar(/* allowPoisoned = */ true);
buf = tokenStream.sourceUnits.addressOfNextCodeUnit(/* allowPoisoned = */ true);
flags = anyChars.flags;
lineno = anyChars.lineno;
linebase = anyChars.linebase;
prevLinebase = anyChars.prevLinebase;
lookahead = anyChars.lookahead;
currentToken = anyChars.currentToken();
for (unsigned i = 0; i < anyChars.lookahead; i++) {
lookaheadTokens[i] =
anyChars.tokens[(anyChars.cursor + 1 + i) & TokenStreamShared::ntokensMask];
}
for (unsigned i = 0; i < anyChars.lookahead; i++)
lookaheadTokens[i] = anyChars.tokens[anyChars.aheadCursor(1 + i)];
}
class TokenStreamAnyCharsAccess

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

@ -643,7 +643,7 @@ GCRuntime::pickChunk(AutoLockGCBgAlloc& lock)
}
BackgroundAllocTask::BackgroundAllocTask(JSRuntime* rt, ChunkPool& pool)
: GCParallelTask(rt),
: GCParallelTaskHelper(rt),
chunkPool_(pool),
enabled_(CanUseExtraThreads() && GetCPUCount() >= 2)
{

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

@ -2696,7 +2696,7 @@ ArenasToUpdate::getArenasToUpdate(AutoLockHelperThreadState& lock, unsigned maxL
return { begin, last->next };
}
struct UpdatePointersTask : public GCParallelTask
struct UpdatePointersTask : public GCParallelTaskHelper<UpdatePointersTask>
{
// Maximum number of arenas to update in one block.
#ifdef DEBUG
@ -2706,19 +2706,18 @@ struct UpdatePointersTask : public GCParallelTask
#endif
UpdatePointersTask(JSRuntime* rt, ArenasToUpdate* source, AutoLockHelperThreadState& lock)
: GCParallelTask(rt), source_(source)
: GCParallelTaskHelper(rt), source_(source)
{
arenas_.begin = nullptr;
arenas_.end = nullptr;
}
~UpdatePointersTask() override { join(); }
void run();
private:
ArenasToUpdate* source_;
ArenaListSegment arenas_;
virtual void run() override;
bool getArenasToUpdate();
void updateArenas();
};
@ -2818,7 +2817,7 @@ GCRuntime::updateCellPointers(Zone* zone, AllocKinds kinds, size_t bgTaskCount)
for (size_t i = 0; i < bgTaskCount && !bgArenas.done(); i++) {
bgTasks[i].emplace(rt, &bgArenas, lock);
startTask(*bgTasks[i], gcstats::PhaseKind::COMPACT_UPDATE_CELLS, lock);
tasksStarted = i;
tasksStarted++;
}
}
@ -2829,6 +2828,8 @@ GCRuntime::updateCellPointers(Zone* zone, AllocKinds kinds, size_t bgTaskCount)
for (size_t i = 0; i < tasksStarted; i++)
joinTask(*bgTasks[i], gcstats::PhaseKind::COMPACT_UPDATE_CELLS, lock);
for (size_t i = tasksStarted; i < MaxCellUpdateBackgroundTasks; i++)
MOZ_ASSERT(bgTasks[i].isNothing());
}
}
@ -3976,17 +3977,13 @@ ArenaLists::checkEmptyArenaList(AllocKind kind)
class MOZ_RAII js::gc::AutoRunParallelTask : public GCParallelTask
{
using Func = void (*)(JSRuntime*);
Func func_;
gcstats::PhaseKind phase_;
AutoLockHelperThreadState& lock_;
public:
AutoRunParallelTask(JSRuntime* rt, Func func, gcstats::PhaseKind phase,
AutoRunParallelTask(JSRuntime* rt, TaskFunc func, gcstats::PhaseKind phase,
AutoLockHelperThreadState& lock)
: GCParallelTask(rt),
func_(func),
: GCParallelTask(rt, func),
phase_(phase),
lock_(lock)
{
@ -3996,10 +3993,6 @@ class MOZ_RAII js::gc::AutoRunParallelTask : public GCParallelTask
~AutoRunParallelTask() {
runtime()->gc.joinTask(*this, phase_, lock_);
}
void run() override {
func_(runtime());
}
};
void
@ -4310,8 +4303,9 @@ PurgeShapeTablesForShrinkingGC(JSRuntime* rt)
}
static void
UnmarkCollectedZones(JSRuntime* rt)
UnmarkCollectedZones(GCParallelTask* task)
{
JSRuntime* rt = task->runtime();
for (GCZonesIter zone(rt); !zone.done(); zone.next()) {
/* Unmark everything in the zones being collected. */
zone->arenas.unmarkAll();
@ -4324,9 +4318,9 @@ UnmarkCollectedZones(JSRuntime* rt)
}
static void
BufferGrayRoots(JSRuntime* rt)
BufferGrayRoots(GCParallelTask* task)
{
rt->gc.bufferGrayRoots();
task->runtime()->gc.bufferGrayRoots();
}
bool
@ -5368,7 +5362,7 @@ GCRuntime::endMarkingSweepGroup(FreeOp* fop, SliceBudget& budget)
}
// Causes the given WeakCache to be swept when run.
class ImmediateSweepWeakCacheTask : public GCParallelTask
class ImmediateSweepWeakCacheTask : public GCParallelTaskHelper<ImmediateSweepWeakCacheTask>
{
JS::detail::WeakCacheBase& cache;
@ -5376,21 +5370,23 @@ class ImmediateSweepWeakCacheTask : public GCParallelTask
public:
ImmediateSweepWeakCacheTask(JSRuntime* rt, JS::detail::WeakCacheBase& wc)
: GCParallelTask(rt), cache(wc)
: GCParallelTaskHelper(rt), cache(wc)
{}
ImmediateSweepWeakCacheTask(ImmediateSweepWeakCacheTask&& other)
: GCParallelTask(Move(other)), cache(other.cache)
: GCParallelTaskHelper(Move(other)), cache(other.cache)
{}
void run() override {
void run() {
cache.sweep();
}
};
static void
UpdateAtomsBitmap(JSRuntime* runtime)
UpdateAtomsBitmap(GCParallelTask* task)
{
JSRuntime* runtime = task->runtime();
DenseBitmap marked;
if (runtime->gc.atomMarking.computeBitmapFromChunkMarkBits(runtime, marked)) {
for (GCZonesIter zone(runtime); !zone.done(); zone.next())
@ -5411,22 +5407,25 @@ UpdateAtomsBitmap(JSRuntime* runtime)
}
static void
SweepCCWrappers(JSRuntime* runtime)
SweepCCWrappers(GCParallelTask* task)
{
JSRuntime* runtime = task->runtime();
for (SweepGroupCompartmentsIter c(runtime); !c.done(); c.next())
c->sweepCrossCompartmentWrappers();
}
static void
SweepObjectGroups(JSRuntime* runtime)
SweepObjectGroups(GCParallelTask* task)
{
JSRuntime* runtime = task->runtime();
for (SweepGroupCompartmentsIter c(runtime); !c.done(); c.next())
c->objectGroups.sweep();
}
static void
SweepMisc(JSRuntime* runtime)
SweepMisc(GCParallelTask* task)
{
JSRuntime* runtime = task->runtime();
for (SweepGroupCompartmentsIter c(runtime); !c.done(); c.next()) {
c->sweepGlobalObject();
c->sweepTemplateObjects();
@ -5438,17 +5437,19 @@ SweepMisc(JSRuntime* runtime)
}
static void
SweepCompressionTasks(JSRuntime* runtime)
SweepCompressionTasks(GCParallelTask* task)
{
JSRuntime* runtime = task->runtime();
AutoLockHelperThreadState lock;
// Attach finished compression tasks.
auto& finished = HelperThreadState().compressionFinishedList(lock);
for (size_t i = 0; i < finished.length(); i++) {
if (finished[i]->runtimeMatches(runtime)) {
UniquePtr<SourceCompressionTask> task(Move(finished[i]));
UniquePtr<SourceCompressionTask> compressionTask(Move(finished[i]));
HelperThreadState().remove(finished, &i);
task->complete();
compressionTask->complete();
}
}
@ -5461,8 +5462,9 @@ SweepCompressionTasks(JSRuntime* runtime)
}
static void
SweepWeakMaps(JSRuntime* runtime)
SweepWeakMaps(GCParallelTask* task)
{
JSRuntime* runtime = task->runtime();
for (SweepGroupZonesIter zone(runtime); !zone.done(); zone.next()) {
/* Clear all weakrefs that point to unmarked things. */
for (auto edge : zone->gcWeakRefs()) {
@ -5482,14 +5484,15 @@ SweepWeakMaps(JSRuntime* runtime)
}
static void
SweepUniqueIds(JSRuntime* runtime)
SweepUniqueIds(GCParallelTask* task)
{
for (SweepGroupZonesIter zone(runtime); !zone.done(); zone.next())
for (SweepGroupZonesIter zone(task->runtime()); !zone.done(); zone.next())
zone->sweepUniqueIds();
}
void
GCRuntime::startTask(GCParallelTask& task, gcstats::PhaseKind phase, AutoLockHelperThreadState& locked)
GCRuntime::startTask(GCParallelTask& task, gcstats::PhaseKind phase,
AutoLockHelperThreadState& locked)
{
if (!task.startWithLockHeld(locked)) {
AutoUnlockHelperThreadState unlock(locked);
@ -5499,7 +5502,8 @@ GCRuntime::startTask(GCParallelTask& task, gcstats::PhaseKind phase, AutoLockHel
}
void
GCRuntime::joinTask(GCParallelTask& task, gcstats::PhaseKind phase, AutoLockHelperThreadState& locked)
GCRuntime::joinTask(GCParallelTask& task, gcstats::PhaseKind phase,
AutoLockHelperThreadState& locked)
{
{
gcstats::AutoPhase ap(stats(), gcstats::PhaseKind::JOIN_PARALLEL_TASKS);
@ -6089,7 +6093,7 @@ class js::gc::WeakCacheSweepIterator
}
};
class IncrementalSweepWeakCacheTask : public GCParallelTask
class IncrementalSweepWeakCacheTask : public GCParallelTaskHelper<IncrementalSweepWeakCacheTask>
{
WeakCacheSweepIterator& work_;
SliceBudget& budget_;
@ -6099,7 +6103,7 @@ class IncrementalSweepWeakCacheTask : public GCParallelTask
public:
IncrementalSweepWeakCacheTask(JSRuntime* rt, WeakCacheSweepIterator& work, SliceBudget& budget,
AutoLockHelperThreadState& lock)
: GCParallelTask(rt), work_(work), budget_(budget), lock_(lock),
: GCParallelTaskHelper(rt), work_(work), budget_(budget), lock_(lock),
cache_(work.next(lock))
{
MOZ_ASSERT(cache_);
@ -6110,8 +6114,7 @@ class IncrementalSweepWeakCacheTask : public GCParallelTask
runtime()->gc.joinTask(*this, gcstats::PhaseKind::SWEEP_WEAK_CACHES, lock_);
}
private:
void run() override {
void run() {
do {
MOZ_ASSERT(cache_->needsIncrementalBarrier());
size_t steps = cache_->sweep();

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

@ -7,17 +7,27 @@
#ifndef gc_GCParallelTask_h
#define gc_GCParallelTask_h
#include "mozilla/Move.h"
#include "js/TypeDecls.h"
#include "threading/ProtectedData.h"
namespace js {
// A generic task used to dispatch work to the helper thread system.
// Users should derive from GCParallelTask add what data they need and
// override |run|.
// Users supply a function pointer to call.
//
// Note that we don't use virtual functions here because destructors can write
// the vtable pointer on entry, which can causes races if synchronization
// happens there.
class GCParallelTask
{
public:
using TaskFunc = void (*)(GCParallelTask*);
private:
JSRuntime* const runtime_;
TaskFunc func_;
// The state of the parallel computation.
enum class State {
@ -36,17 +46,17 @@ class GCParallelTask
// A flag to signal a request for early completion of the off-thread task.
mozilla::Atomic<bool, mozilla::MemoryOrdering::ReleaseAcquire> cancel_;
virtual void run() = 0;
public:
explicit GCParallelTask(JSRuntime* runtime)
explicit GCParallelTask(JSRuntime* runtime, TaskFunc func)
: runtime_(runtime),
func_(func),
state_(State::NotStarted),
duration_(nullptr),
cancel_(false)
{}
GCParallelTask(GCParallelTask&& other)
: runtime_(other.runtime_),
func_(other.func_),
state_(other.state_),
duration_(nullptr),
cancel_(false)
@ -54,7 +64,7 @@ class GCParallelTask
// Derived classes must override this to ensure that join() gets called
// before members get destructed.
virtual ~GCParallelTask();
~GCParallelTask();
JSRuntime* runtime() { return runtime_; }
@ -113,11 +123,33 @@ class GCParallelTask
state_ = State::NotStarted;
}
void runTask() {
func_(this);
}
// This should be friended to HelperThread, but cannot be because it
// would introduce several circular dependencies.
public:
void runFromHelperThread(AutoLockHelperThreadState& locked);
};
// CRTP template to handle cast to derived type when calling run().
template <typename Derived>
class GCParallelTaskHelper : public GCParallelTask
{
public:
explicit GCParallelTaskHelper(JSRuntime* runtime)
: GCParallelTask(runtime, &runTaskTyped)
{}
GCParallelTaskHelper(GCParallelTaskHelper&& other)
: GCParallelTask(mozilla::Move(other))
{}
private:
static void runTaskTyped(GCParallelTask* task) {
static_cast<Derived*>(task)->run();
}
};
} /* namespace js */
#endif /* gc_GCParallelTask_h */

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

@ -106,7 +106,7 @@ class ChunkPool
// Performs extra allocation off thread so that when memory is required on the
// main thread it will already be available and waiting.
class BackgroundAllocTask : public GCParallelTask
class BackgroundAllocTask : public GCParallelTaskHelper<BackgroundAllocTask>
{
// Guarded by the GC lock.
GCLockData<ChunkPool&> chunkPool_;
@ -117,21 +117,19 @@ class BackgroundAllocTask : public GCParallelTask
BackgroundAllocTask(JSRuntime* rt, ChunkPool& pool);
bool enabled() const { return enabled_; }
protected:
void run() override;
void run();
};
// Search the provided Chunks for free arenas and decommit them.
class BackgroundDecommitTask : public GCParallelTask
class BackgroundDecommitTask : public GCParallelTaskHelper<BackgroundDecommitTask>
{
public:
using ChunkVector = mozilla::Vector<Chunk*>;
explicit BackgroundDecommitTask(JSRuntime *rt) : GCParallelTask(rt) {}
explicit BackgroundDecommitTask(JSRuntime *rt) : GCParallelTaskHelper(rt) {}
void setChunksToScan(ChunkVector &chunks);
protected:
void run() override;
void run();
private:
MainThreadOrGCTaskData<ChunkVector> toDecommit;
@ -492,8 +490,10 @@ class GCRuntime
/*
* Concurrent sweep infrastructure.
*/
void startTask(GCParallelTask& task, gcstats::PhaseKind phase, AutoLockHelperThreadState& locked);
void joinTask(GCParallelTask& task, gcstats::PhaseKind phase, AutoLockHelperThreadState& locked);
void startTask(GCParallelTask& task, gcstats::PhaseKind phase,
AutoLockHelperThreadState& locked);
void joinTask(GCParallelTask& task, gcstats::PhaseKind phase,
AutoLockHelperThreadState& locked);
void mergeCompartments(JSCompartment* source, JSCompartment* target);

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

@ -82,7 +82,6 @@ MaybeForwarded(T t)
{
if (IsForwarded(t))
t = Forwarded(t);
MakeAccessibleAfterMovingGC(t);
return t;
}

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

@ -995,14 +995,28 @@ js::GCMarker::traverseEdge(S source, const T& thing)
namespace {
template <typename T> struct ParticipatesInCC {};
template <typename T> struct TypeParticipatesInCC {};
#define EXPAND_PARTICIPATES_IN_CC(_, type, addToCCKind) \
template <> struct ParticipatesInCC<type> { static const bool value = addToCCKind; };
template <> struct TypeParticipatesInCC<type> { static const bool value = addToCCKind; };
JS_FOR_EACH_TRACEKIND(EXPAND_PARTICIPATES_IN_CC)
#undef EXPAND_PARTICIPATES_IN_CC
struct ParticipatesInCCFunctor
{
template <typename T>
bool operator()() {
return TypeParticipatesInCC<T>::value;
}
};
} // namespace
static bool
TraceKindParticipatesInCC(JS::TraceKind kind)
{
return DispatchTraceKindTyped(ParticipatesInCCFunctor(), kind);
}
template <typename T>
bool
js::GCMarker::mark(T* thing)
@ -1011,7 +1025,7 @@ js::GCMarker::mark(T* thing)
TenuredCell* cell = TenuredCell::fromPointer(thing);
MOZ_ASSERT(!IsInsideNursery(cell));
if (!ParticipatesInCC<T>::value)
if (!TypeParticipatesInCC<T>::value)
return cell->markIfUnmarked(MarkColor::Black);
return cell->markIfUnmarked(markColor());
@ -2063,7 +2077,6 @@ inline JSRope*
MarkStack::TaggedPtr::asTempRope() const
{
MOZ_ASSERT(tag() == TempRopeTag);
MOZ_ASSERT(ptr()->isTenured());
MOZ_ASSERT(ptr()->is<JSString>());
return static_cast<JSRope*>(ptr());
}
@ -2568,12 +2581,18 @@ GCMarker::markDelayedChildren(Arena* arena)
MOZ_ASSERT(arena->markOverflow);
arena->markOverflow = 0;
JS::TraceKind kind = MapAllocToTraceKind(arena->getAllocKind());
// Whether we need to mark children of gray or black cells in the arena
// depends on which kind of marking we were doing when the arena as pushed
// onto the list. We never change mark color without draining the mark
// stack though so this is the same as the current color.
bool markGrayCells = markColor() == MarkColor::Gray && TraceKindParticipatesInCC(kind);
for (ArenaCellIterUnderGC i(arena); !i.done(); i.next()) {
TenuredCell* t = i.getCell();
if (t->isMarkedAny()) {
t->markIfUnmarked();
js::TraceChildren(this, t, MapAllocToTraceKind(arena->getAllocKind()));
}
if ((markGrayCells && t->isMarkedGray()) || (!markGrayCells && t->isMarkedBlack()))
js::TraceChildren(this, t, kind);
}
}

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

@ -175,12 +175,6 @@ inline Value Forwarded(const JS::Value& value);
template <typename T>
inline T MaybeForwarded(T t);
inline void
MakeAccessibleAfterMovingGC(void* anyp) {}
inline void
MakeAccessibleAfterMovingGC(JSObject* obj); // Defined in jsobjinlines.h.
#ifdef JSGC_HASH_TABLE_CHECKS
template <typename T>

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

@ -43,19 +43,21 @@ using mozilla::TimeStamp;
constexpr uintptr_t CanaryMagicValue = 0xDEADB15D;
struct js::Nursery::FreeMallocedBuffersTask : public GCParallelTask
struct js::Nursery::FreeMallocedBuffersTask : public GCParallelTaskHelper<FreeMallocedBuffersTask>
{
explicit FreeMallocedBuffersTask(FreeOp* fop) : GCParallelTask(fop->runtime()), fop_(fop) {}
explicit FreeMallocedBuffersTask(FreeOp* fop)
: GCParallelTaskHelper(fop->runtime()),
fop_(fop) {}
bool init() { return buffers_.init(); }
void transferBuffersToFree(MallocedBuffersSet& buffersToFree,
const AutoLockHelperThreadState& lock);
~FreeMallocedBuffersTask() override { join(); }
~FreeMallocedBuffersTask() { join(); }
void run();
private:
FreeOp* fop_;
MallocedBuffersSet buffers_;
virtual void run() override;
};
#ifdef JS_GC_ZEAL

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

@ -25,9 +25,6 @@
#include "vm/JSONPrinter.h"
namespace js {
class GCParallelTask;
namespace gcstats {
// Phase data is generated by a script. If you need to add phases, edit

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