From 1e50e307ffc722efc22ab8651b2cd2b6abf0cd04 Mon Sep 17 00:00:00 2001 From: Alexandre Poirot Date: Wed, 2 Mar 2016 02:32:05 -0800 Subject: [PATCH 001/160] Bug 1248609 - Fix debugger when reloading via the addon. r=jryans --- devtools/client/debugger/debugger-controller.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/devtools/client/debugger/debugger-controller.js b/devtools/client/debugger/debugger-controller.js index 388b9e63286..32c7c6bc62c 100644 --- a/devtools/client/debugger/debugger-controller.js +++ b/devtools/client/debugger/debugger-controller.js @@ -108,7 +108,7 @@ Cu.import("resource://devtools/client/shared/widgets/ViewHelpers.jsm"); var L10N = new ViewHelpers.L10N(DBG_STRINGS_URI); Cu.import("resource://devtools/client/shared/browser-loader.js"); -const require = BrowserLoader("resource://devtools/client/debugger/", this).require; +const require = BrowserLoader("resource://devtools/client/debugger/", window).require; XPCOMUtils.defineConstant(this, "require", require); const { gDevTools } = require("devtools/client/framework/devtools"); From 7aa8fbd068d15f318a5d473aea77984bc663d14a Mon Sep 17 00:00:00 2001 From: Alexandre Poirot Date: Wed, 2 Mar 2016 02:32:05 -0800 Subject: [PATCH 002/160] Bug 1248435 - Add telemetry probes for reload addon installation and reload action. r=jryans data-review=bsmedberg --- devtools/bootstrap.js | 13 ++++++++- devtools/client/shared/telemetry.js | 10 ++++++- toolkit/components/telemetry/Histograms.json | 28 ++++++++++++++++++++ 3 files changed, 49 insertions(+), 2 deletions(-) diff --git a/devtools/bootstrap.js b/devtools/bootstrap.js index 7f5e5bbc516..5f0e5616080 100644 --- a/devtools/bootstrap.js +++ b/devtools/bootstrap.js @@ -8,6 +8,13 @@ const Cu = Components.utils; const Ci = Components.interfaces; const {Services} = Cu.import("resource://gre/modules/Services.jsm", {}); +function actionOccurred(id) { + let {require} = Cu.import("resource://devtools/shared/Loader.jsm", {}); + let Telemetry = require("devtools/client/shared/telemetry");; + let telemetry = new Telemetry(); + telemetry.actionOccurred(id); +} + // Helper to listen to a key on all windows function MultiWindowKeyListener({ keyCode, ctrlKey, altKey, callback }) { let keyListener = function (event) { @@ -150,6 +157,8 @@ function reload(event) { gDevTools.showToolbox(target); }, 1000); } + + actionOccurred("reloadAddonReload"); } let listener; @@ -165,5 +174,7 @@ function shutdown() { listener.stop(); listener = null; } -function install() {} +function install() { + actionOccurred("reloadAddonInstalled"); +} function uninstall() {} diff --git a/devtools/client/shared/telemetry.js b/devtools/client/shared/telemetry.js index 462798003ca..2532b00f04a 100644 --- a/devtools/client/shared/telemetry.js +++ b/devtools/client/shared/telemetry.js @@ -233,7 +233,15 @@ Telemetry.prototype = { histogram: "DEVTOOLS_CUSTOM_OPENED_COUNT", userHistogram: "DEVTOOLS_CUSTOM_OPENED_PER_USER_FLAG", timerHistogram: "DEVTOOLS_CUSTOM_TIME_ACTIVE_SECONDS" - } + }, + reloadAddonInstalled: { + histogram: "DEVTOOLS_RELOAD_ADDON_INSTALLED_COUNT", + userHistogram: "DEVTOOLS_RELOAD_ADDON_INSTALLED_PER_USER_FLAG", + }, + reloadAddonReload: { + histogram: "DEVTOOLS_RELOAD_ADDON_RELOAD_COUNT", + userHistogram: "DEVTOOLS_RELOAD_ADDON_RELOAD_PER_USER_FLAG", + }, }, /** diff --git a/toolkit/components/telemetry/Histograms.json b/toolkit/components/telemetry/Histograms.json index b9b371ed85d..3d0f27fdcab 100644 --- a/toolkit/components/telemetry/Histograms.json +++ b/toolkit/components/telemetry/Histograms.json @@ -7021,6 +7021,20 @@ "description": "Number of times a custom developer tool has been opened.", "releaseChannelCollection": "opt-out" }, + "DEVTOOLS_RELOAD_ADDON_INSTALLED_COUNT": { + "alert_emails": ["dev-developer-tools@lists.mozilla.org"], + "expires_in_version": "55", + "kind": "count", + "description": "Number of times the reload addon has been installed.", + "bug_numbers": [1248435] + }, + "DEVTOOLS_RELOAD_ADDON_RELOAD_COUNT": { + "alert_emails": ["dev-developer-tools@lists.mozilla.org"], + "expires_in_version": "55", + "kind": "count", + "description": "Number of times the tools have been reloaded by the reload addon.", + "bug_numbers": [1248435] + }, "DEVTOOLS_TOOLBOX_OPENED_PER_USER_FLAG": { "expires_in_version": "never", "kind": "flag", @@ -7204,6 +7218,20 @@ "kind": "flag", "description": "Number of users that have opened a custom developer tool via the toolbox button." }, + "DEVTOOLS_RELOAD_ADDON_INSTALLED_PER_USER_FLAG": { + "alert_emails": ["dev-developer-tools@lists.mozilla.org"], + "expires_in_version": "55", + "kind": "flag", + "description": "Records once per browser version if the reload add-on is installed.", + "bug_numbers": [1248435] + }, + "DEVTOOLS_RELOAD_ADDON_RELOAD_PER_USER_FLAG": { + "alert_emails": ["dev-developer-tools@lists.mozilla.org"], + "expires_in_version": "55", + "kind": "flag", + "description": "Records once per browser version if the tools have been reloaded via the reload add-on.", + "bug_numbers": [1248435] + }, "DEVTOOLS_TOOLBOX_TIME_ACTIVE_SECONDS": { "expires_in_version": "never", "kind": "exponential", From ae5b1a6639316e6df602151d0e3ef6e85a89fdd4 Mon Sep 17 00:00:00 2001 From: Alexandre Poirot Date: Wed, 2 Mar 2016 02:32:05 -0800 Subject: [PATCH 003/160] Bug 1252245 - Disable gcli on the browser toolbox. r=jwalker --- devtools/client/framework/toolbox.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/devtools/client/framework/toolbox.js b/devtools/client/framework/toolbox.js index b0b20c5c97f..8f266fc51c3 100644 --- a/devtools/client/framework/toolbox.js +++ b/devtools/client/framework/toolbox.js @@ -912,6 +912,10 @@ Toolbox.prototype = { if (!this.target.hasActor("gcli")) { return promise.resolve(); } + // Disable gcli in browser toolbox until there is usages of it + if (this.target.chrome) { + return promise.resolve(); + } const options = { environment: CommandUtils.createEnvironment(this, '_target') From 039c88723eb009ec168fdb6f3c4536684bb70253 Mon Sep 17 00:00:00 2001 From: Andrew Swan Date: Mon, 29 Feb 2016 10:57:12 -0800 Subject: [PATCH 004/160] bug 1245603 - Implement browser.downloads.search() r=kmag MozReview-Commit-ID: 9XqkfZyeS8X --- .../components/extensions/ext-downloads.js | 315 ++++++++++++++- .../extensions/schemas/downloads.json | 14 +- .../test/mochitest/file_download.html | 12 + .../extensions/test/mochitest/mochitest.ini | 3 + .../mochitest/test_ext_downloads_search.html | 366 ++++++++++++++++++ 5 files changed, 701 insertions(+), 9 deletions(-) create mode 100644 toolkit/components/extensions/test/mochitest/file_download.html create mode 100644 toolkit/components/extensions/test/mochitest/test_ext_downloads_search.html diff --git a/toolkit/components/extensions/ext-downloads.js b/toolkit/components/extensions/ext-downloads.js index 949084fc2af..985be8131b6 100644 --- a/toolkit/components/extensions/ext-downloads.js +++ b/toolkit/components/extensions/ext-downloads.js @@ -20,7 +20,262 @@ const { ignoreEvent, } = ExtensionUtils; -let currentId = 0; +const DOWNLOAD_ITEM_FIELDS = ["id", "url", "referrer", "filename", "incognito", + "danger", "mime", "startTime", "endTime", + "estimatedEndTime", "state", "canResume", + "error", "bytesReceived", "totalBytes", + "fileSize", "exists", + "byExtensionId", "byExtensionName"]; + +class DownloadItem { + constructor(id, download, extension) { + this.id = id; + this.download = download; + this.extension = extension; + } + + get url() { return this.download.source.url; } + get referrer() { return this.download.source.referrer; } + get filename() { return this.download.target.path; } + get incognito() { return this.download.source.isPrivate; } + get danger() { return "safe"; } // TODO + get mime() { return this.download.contentType; } + get startTime() { return this.download.startTime; } + get endTime() { return null; } // TODO + get estimatedEndTime() { return null; } // TODO + get state() { + if (this.download.succeeded) { + return "complete"; + } + if (this.download.stopped) { + return "interrupted"; + } + return "in_progress"; + } + get canResume() { + return this.download.stopped && this.download.hasPartialData; + } + get error() { + if (!this.download.stopped || this.download.succeeded) { + return null; + } + // TODO store this instead of calculating it + + if (this.download.error) { + if (this.download.error.becauseSourceFailed) { + return "NETWORK_FAILED"; // TODO + } + if (this.download.error.becauseTargetFailed) { + return "FILE_FAILED"; // TODO + } + return "CRASH"; + } + return "USER_CANCELED"; + } + get bytesReceived() { + return this.download.currentBytes; + } + get totalBytes() { + return this.download.hasProgress ? this.download.totalBytes : -1; + } + get fileSize() { + // todo: this is supposed to be post-compression + return this.download.succeeded ? this.download.target.size : -1; + } + get exists() { return this.download.target.exists; } + get byExtensionId() { return this.extension.id; } + get byExtensionName() { return this.extension.name; } + + /** + * Create a cloneable version of this object by pulling all the + * fields into simple properties (instead of getters). + * + * @returns {object} A DownloadItem with flat properties, + * suitable for cloning. + */ + serialize() { + let obj = {}; + for (let field of DOWNLOAD_ITEM_FIELDS) { + obj[field] = this[field]; + } + if (obj.startTime) { + obj.startTime = obj.startTime.toISOString(); + } + return obj; + } +} + + +// DownloadMap maps back and forth betwen the numeric identifiers used in +// the downloads WebExtension API and a Download object from the Downloads jsm. +// todo: make id and extension info persistent (bug 1247794) +const DownloadMap = { + currentId: 0, + loadPromise: null, + + // Maps numeric id -> DownloadItem + byId: new Map(), + + // Maps Download object -> DownloadItem + byDownload: new WeakMap(), + + lazyInit() { + return Downloads.getList(Downloads.ALL).then(list => { + return list.getAll().then(downloads => { + downloads.forEach(download => { + this.newFromDownload(download, null); + }); + let self = this; + return list.addView({ + onDownloadAdded(download) { + self.newFromDownload(download, null); + }, + + onDownloadRemoved(download) { + const item = self.byDownload.get(download); + if (item != null) { + self.byDownload.delete(download); + self.byId.delete(item.id); + } + }, + }); + }); + }); + }, + + getAll() { + if (this.loadPromise == null) { + this.loadPromise = this.lazyInit(); + } + return this.loadPromise.then(() => this.byId.values()); + }, + + fromId(id) { + const download = this.byId.get(id); + if (!download) { + throw new Error(`Invalid download id ${id}`); + } + return download; + }, + + newFromDownload(download, extension) { + if (this.byDownload.has(download)) { + return this.byDownload.get(download); + } + + const id = ++this.currentId; + let item = new DownloadItem(id, download, extension); + this.byId.set(id, item); + this.byDownload.set(download, item); + return item; + }, +}; + +// Create a callable function that filters a DownloadItem based on a +// query object of the type passed to search() or erase(). +function downloadQuery(query) { + let queryTerms = []; + let queryNegativeTerms = []; + if (query.query != null) { + for (let term of query.query) { + if (term[0] == "-") { + queryNegativeTerms.push(term.slice(1).toLowerCase()); + } else { + queryTerms.push(term.toLowerCase()); + } + } + } + + function normalizeTime(arg, before) { + if (arg == null) { + return before ? Number.MAX_VALUE : 0; + } + return parseInt(arg, 10); + } + + const startedBefore = normalizeTime(query.startedBefore, true); + const startedAfter = normalizeTime(query.startedAfter, false); + // const endedBefore = normalizeTime(query.endedBefore, true); + // const endedAfter = normalizeTime(query.endedAfter, false); + + const totalBytesGreater = query.totalBytesGreater || 0; + const totalBytesLess = (query.totalBytesLess != null) + ? query.totalBytesLess : Number.MAX_VALUE; + + // Handle options for which we can have a regular expression and/or + // an explicit value to match. + function makeMatch(regex, value, field) { + if (value == null && regex == null) { + return input => true; + } + + let re; + try { + re = new RegExp(regex || "", "i"); + } catch (err) { + throw new Error(`Invalid ${field}Regex: ${err.message}`); + } + if (value == null) { + return input => re.test(input); + } + + value = value.toLowerCase(); + if (re.test(value)) { + return input => (value == input); + } else { + return input => false; + } + } + + const matchFilename = makeMatch(query.filenameRegex, query.filename, "filename"); + const matchUrl = makeMatch(query.urlRegex, query.url, "url"); + + return function(item) { + const url = item.url.toLowerCase(); + const filename = item.filename.toLowerCase(); + + if (!queryTerms.every(term => url.includes(term) || filename.includes(term))) { + return false; + } + + if (queryNegativeTerms.some(term => url.includes(term) || filename.includes(term))) { + return false; + } + + if (!matchFilename(filename) || !matchUrl(url)) { + return false; + } + + if (!item.startTime) { + if (query.startedBefore != null || query.startedAfter != null) { + return false; + } + } else if (item.startTime > startedBefore || item.startTime < startedAfter) { + return false; + } + + // todo endedBefore, endedAfter + + if (item.totalBytes == -1) { + if (query.totalBytesGreater != null || query.totalBytesLess != null) { + return false; + } + } else if (item.totalBytes <= totalBytesGreater || item.totalBytes >= totalBytesLess) { + return false; + } + + // todo: include danger, paused, error + const SIMPLE_ITEMS = ["id", "mime", "startTime", "endTime", "state", + "bytesReceived", "totalBytes", "fileSize", "exists"]; + for (let field of SIMPLE_ITEMS) { + if (query[field] != null && item[field] != query[field]) { + return false; + } + } + + return true; + }; +} extensions.registerSchemaAPI("downloads", "downloads", (extension, context) => { return { @@ -94,12 +349,64 @@ extensions.registerSchemaAPI("downloads", "downloads", (extension, context) => { download.tryToKeepPartialData = true; download.start(); - // Without other chrome.downloads methods, we can't actually - // do anything with the id so just return a dummy value for now. - return currentId++; + const item = DownloadMap.newFromDownload(download, extension); + return item.id; }); }, + search(query) { + let matchFn; + try { + matchFn = downloadQuery(query); + } catch (err) { + return Promise.reject({message: err.message}); + } + + let compareFn; + if (query.orderBy != null) { + const fields = query.orderBy.map(field => field[0] == "-" + ? {reverse: true, name: field.slice(1)} + : {reverse: false, name: field}); + + for (let field of fields) { + if (!DOWNLOAD_ITEM_FIELDS.includes(field.name)) { + return Promise.reject({message: `Invalid orderBy field ${field.name}`}); + } + } + + compareFn = (dl1, dl2) => { + for (let field of fields) { + const val1 = dl1[field.name]; + const val2 = dl2[field.name]; + + if (val1 < val2) { + return field.reverse ? 1 : -1; + } else if (val1 > val2) { + return field.reverse ? -1 : 1; + } + } + return 0; + }; + } + + return DownloadMap.getAll().then(downloads => { + if (compareFn) { + downloads = Array.from(downloads); + downloads.sort(compareFn); + } + let results = []; + for (let download of downloads) { + if (query.limit && results.length >= query.limit) { + break; + } + if (matchFn(download)) { + results.push(download.serialize()); + } + } + return results; + }); + }, + // When we do open(), check for additional downloads.open permission. // i.e.: // open(downloadId) { diff --git a/toolkit/components/extensions/schemas/downloads.json b/toolkit/components/extensions/schemas/downloads.json index b13e314cfd2..f4a82f846cf 100644 --- a/toolkit/components/extensions/schemas/downloads.json +++ b/toolkit/components/extensions/schemas/downloads.json @@ -295,7 +295,7 @@ { "name": "search", "type": "function", - "unsupported": true, + "async": "callback", "description": "Find DownloadItems. Set query to the empty object to get all DownloadItems. To get a specific DownloadItem, set only the id field.", "parameters": [ { @@ -311,22 +311,26 @@ "startedBefore": { "description": "Limits results to downloads that started before the given ms since the epoch.", "optional": true, - "type": "string" + "type": "string", + "pattern": "^[1-9]\\d*$" }, "startedAfter": { "description": "Limits results to downloads that started after the given ms since the epoch.", "optional": true, - "type": "string" + "type": "string", + "pattern": "^[1-9]\\d*$" }, "endedBefore": { "description": "Limits results to downloads that ended before the given ms since the epoch.", "optional": true, - "type": "string" + "type": "string", + "pattern": "^[1-9]\\d*$" }, "endedAfter": { "description": "Limits results to downloads that ended after the given ms since the epoch.", "optional": true, - "type": "string" + "type": "string", + "pattern": "^[1-9]\\d*$" }, "totalBytesGreater": { "description": "Limits results to downloads whose totalBytes is greater than the given integer.", diff --git a/toolkit/components/extensions/test/mochitest/file_download.html b/toolkit/components/extensions/test/mochitest/file_download.html new file mode 100644 index 00000000000..d970c63259d --- /dev/null +++ b/toolkit/components/extensions/test/mochitest/file_download.html @@ -0,0 +1,12 @@ + + + + + + + + +
Download HTML File
+ + + diff --git a/toolkit/components/extensions/test/mochitest/mochitest.ini b/toolkit/components/extensions/test/mochitest/mochitest.ini index b0f2beebb4e..f9a1d2f8605 100644 --- a/toolkit/components/extensions/test/mochitest/mochitest.ini +++ b/toolkit/components/extensions/test/mochitest/mochitest.ini @@ -22,6 +22,8 @@ support-files = file_privilege_escalation.html file_ext_test_api_injection.js file_permission_xhr.html + file_download.html + file_download.txt [test_ext_simple.html] [test_ext_schema.html] @@ -32,6 +34,7 @@ skip-if = buildapp == 'b2g' # runat != document_idle is not supported. [test_ext_contentscript_create_iframe.html] [test_ext_contentscript_api_injection.html] [test_ext_downloads.html] +[test_ext_downloads_search.html] [test_ext_i18n_css.html] [test_ext_generate.html] [test_ext_idle.html] diff --git a/toolkit/components/extensions/test/mochitest/test_ext_downloads_search.html b/toolkit/components/extensions/test/mochitest/test_ext_downloads_search.html new file mode 100644 index 00000000000..5d92bfff53b --- /dev/null +++ b/toolkit/components/extensions/test/mochitest/test_ext_downloads_search.html @@ -0,0 +1,366 @@ + + + + WebExtension test + + + + + + + + + + + + From 6bdbd6c4e0098b934b3670d25dfaa7e1e9a52bcb Mon Sep 17 00:00:00 2001 From: Luca Greco Date: Thu, 18 Feb 2016 01:56:09 +0100 Subject: [PATCH 005/160] Bug 1249144 - [webext] Test explicitly the frameId/parentFrameId associated to the toplevel frame. r=billm MozReview-Commit-ID: 9E7LmdyHcnG --- .../test/browser/browser_ext_webNavigation_getFrames.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/browser/components/extensions/test/browser/browser_ext_webNavigation_getFrames.js b/browser/components/extensions/test/browser/browser_ext_webNavigation_getFrames.js index 039a8865074..9bf366bd55d 100644 --- a/browser/components/extensions/test/browser/browser_ext_webNavigation_getFrames.js +++ b/browser/components/extensions/test/browser/browser_ext_webNavigation_getFrames.js @@ -138,6 +138,9 @@ add_task(function* testWebNavigationFrames() { is(getAllFramesDetails.length, collectedDetails.length, "number of frames found should equal the number onCompleted events collected"); + is(getAllFramesDetails[0].frameId, 0, "the root frame has the expected frameId"); + is(getAllFramesDetails[0].parentFrameId, -1, "the root frame has the expected parentFrameId"); + // ordered by frameId let sortByFrameId = (el1, el2) => { let val1 = el1 ? el1.frameId : -1; From a84e8c05f80f77011cbcc0afd96b4f521ab0429a Mon Sep 17 00:00:00 2001 From: Eddy Bruel Date: Wed, 2 Mar 2016 12:38:25 +0100 Subject: [PATCH 006/160] Bug 1119490 - Test for source maps in workers;r=jryans --- .../client/debugger/debugger-controller.js | 18 ++-- .../debugger/test/mochitest/browser.ini | 6 ++ .../browser_dbg_worker-source-map.js | 85 +++++++++++++++++++ .../mochitest/code_worker-source-map.coffee | 22 +++++ .../test/mochitest/code_worker-source-map.js | 35 ++++++++ .../mochitest/code_worker-source-map.js.map | 10 +++ .../test/mochitest/doc_worker-source-map.html | 18 ++++ .../client/debugger/views/workers-view.js | 14 +-- 8 files changed, 195 insertions(+), 13 deletions(-) create mode 100644 devtools/client/debugger/test/mochitest/browser_dbg_worker-source-map.js create mode 100644 devtools/client/debugger/test/mochitest/code_worker-source-map.coffee create mode 100644 devtools/client/debugger/test/mochitest/code_worker-source-map.js create mode 100644 devtools/client/debugger/test/mochitest/code_worker-source-map.js.map create mode 100644 devtools/client/debugger/test/mochitest/doc_worker-source-map.html diff --git a/devtools/client/debugger/debugger-controller.js b/devtools/client/debugger/debugger-controller.js index 32c7c6bc62c..12f753b34de 100644 --- a/devtools/client/debugger/debugger-controller.js +++ b/devtools/client/debugger/debugger-controller.js @@ -82,7 +82,10 @@ const EVENTS = { OPTIONS_POPUP_HIDDEN: "Debugger:OptionsPopupHidden", // When the widgets layout has been changed. - LAYOUT_CHANGED: "Debugger:LayoutChanged" + LAYOUT_CHANGED: "Debugger:LayoutChanged", + + // When a worker has been selected. + WORKER_SELECTED: "Debugger::WorkerSelected" }; // Descriptions for what a stack frame represents after the debugger pauses. @@ -491,8 +494,8 @@ Workers.prototype = { for (let workerActor in this._workerForms) { if (!(workerActor in workerForms)) { + DebuggerView.Workers.removeWorker(this._workerForms[workerActor]); delete this._workerForms[workerActor]; - DebuggerView.Workers.removeWorker(workerActor); } } @@ -500,7 +503,7 @@ Workers.prototype = { if (!(workerActor in this._workerForms)) { let workerForm = workerForms[workerActor]; this._workerForms[workerActor] = workerForm; - DebuggerView.Workers.addWorker(workerActor, workerForm.url); + DebuggerView.Workers.addWorker(workerForm); } } }); @@ -510,10 +513,11 @@ Workers.prototype = { this._updateWorkerList(); }, - _onWorkerSelect: function (workerActor) { - DebuggerController.client.attachWorker(workerActor, (response, workerClient) => { - gDevTools.showToolbox(TargetFactory.forWorker(workerClient), - "jsdebugger", Toolbox.HostType.WINDOW); + _onWorkerSelect: function (workerForm) { + DebuggerController.client.attachWorker(workerForm.actor, (response, workerClient) => { + let toolbox = gDevTools.showToolbox(TargetFactory.forWorker(workerClient), + "jsdebugger", Toolbox.HostType.WINDOW); + window.emit(EVENTS.WORKER_SELECTED, toolbox); }); } }; diff --git a/devtools/client/debugger/test/mochitest/browser.ini b/devtools/client/debugger/test/mochitest/browser.ini index 5b13be24926..b3a1fae2127 100644 --- a/devtools/client/debugger/test/mochitest/browser.ini +++ b/devtools/client/debugger/test/mochitest/browser.ini @@ -45,6 +45,9 @@ support-files = code_ugly-7.js code_ugly-8 code_ugly-8^headers^ + code_worker-source-map.coffee + code_worker-source-map.js + code_worker-source-map.js.map code_WorkerActor.attach-worker1.js code_WorkerActor.attach-worker2.js code_WorkerActor.attachThread-worker.js @@ -112,6 +115,7 @@ support-files = doc_watch-expressions.html doc_watch-expression-button.html doc_with-frame.html + doc_worker-source-map.html doc_WorkerActor.attach-tab1.html doc_WorkerActor.attach-tab2.html doc_WorkerActor.attachThread-tab.html @@ -592,6 +596,8 @@ skip-if = e10s && debug skip-if = e10s && debug [browser_dbg_worker-console.js] skip-if = e10s && debug +[browser_dbg_worker-source-map.js] +skip-if = e10s && debug [browser_dbg_worker-window.js] skip-if = e10s && debug [browser_dbg_WorkerActor.attach.js] diff --git a/devtools/client/debugger/test/mochitest/browser_dbg_worker-source-map.js b/devtools/client/debugger/test/mochitest/browser_dbg_worker-source-map.js new file mode 100644 index 00000000000..bbedaff097f --- /dev/null +++ b/devtools/client/debugger/test/mochitest/browser_dbg_worker-source-map.js @@ -0,0 +1,85 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* vim: set ft=javascript ts=2 et sw=2 tw=80: */ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ */ + +const TAB_URL = EXAMPLE_URL + "doc_worker-source-map.html"; +const WORKER_URL = "code_worker-source-map.js"; +const COFFEE_URL = EXAMPLE_URL + "code_worker-source-map.coffee"; + +function selectWorker(aPanel, aURL) { + let panelWin = aPanel.panelWin; + let promise = waitForDebuggerEvents(aPanel, panelWin.EVENTS.WORKER_SELECTED); + let Workers = panelWin.DebuggerView.Workers; + let item = Workers.getItemForAttachment((workerForm) => { + return workerForm.url === aURL; + }); + Workers.selectedItem = item; + return promise; +} + +function test() { + return Task.spawn(function* () { + yield pushPrefs(["devtools.debugger.workers", true]); + + let [tab,, panel] = yield initDebugger(TAB_URL); + let toolbox = yield selectWorker(panel, WORKER_URL); + let workerPanel = toolbox.getCurrentPanel(); + yield waitForSourceShown(workerPanel, ".coffee"); + let panelWin = workerPanel.panelWin; + let Sources = panelWin.DebuggerView.Sources; + let editor = panelWin.DebuggerView.editor; + let threadClient = panelWin.gThreadClient; + + isnot(Sources.selectedItem.attachment.source.url.indexOf(".coffee"), -1, + "The debugger should show the source mapped coffee source file."); + is(Sources.selectedValue.indexOf(".js"), -1, + "The debugger should not show the generated js source file."); + is(editor.getText().indexOf("isnt"), 211, + "The debugger's editor should have the coffee source source displayed."); + is(editor.getText().indexOf("function"), -1, + "The debugger's editor should not have the JS source displayed."); + + yield threadClient.interrupt(); + let sourceForm = getSourceForm(Sources, COFFEE_URL); + let source = threadClient.source(sourceForm); + let response = yield source.setBreakpoint({ line: 5 }); + + ok(!response.error, + "Should be able to set a breakpoint in a coffee source file."); + ok(!response.actualLocation, + "Should be able to set a breakpoint on line 5."); + + let promise = new Promise((resolve) => { + threadClient.addOneTimeListener("paused", (event, packet) => { + is(packet.type, "paused", + "We should now be paused again."); + is(packet.why.type, "breakpoint", + "and the reason we should be paused is because we hit a breakpoint."); + + // Check that we stopped at the right place, by making sure that the + // environment is in the state that we expect. + is(packet.frame.environment.bindings.variables.start.value, 0, + "'start' is 0."); + is(packet.frame.environment.bindings.variables.stop.value.type, "undefined", + "'stop' hasn't been assigned to yet."); + is(packet.frame.environment.bindings.variables.pivot.value.type, "undefined", + "'pivot' hasn't been assigned to yet."); + + waitForCaretUpdated(workerPanel, 5).then(resolve); + }); + }); + + // This will cause the breakpoint to be hit, and put us back in the + // paused state. + yield threadClient.resume(); + callInTab(tab, "binary_search", [0, 2, 3, 5, 7, 10], 5); + yield promise; + + yield threadClient.resume(); + yield toolbox.destroy(); + yield closeDebuggerAndFinish(panel); + + yield popPrefs(); + }); +} diff --git a/devtools/client/debugger/test/mochitest/code_worker-source-map.coffee b/devtools/client/debugger/test/mochitest/code_worker-source-map.coffee new file mode 100644 index 00000000000..446e3aefe94 --- /dev/null +++ b/devtools/client/debugger/test/mochitest/code_worker-source-map.coffee @@ -0,0 +1,22 @@ +# Uses a binary search algorithm to locate a value in the specified array. +binary_search = (items, value) -> + + start = 0 + stop = items.length - 1 + pivot = Math.floor (start + stop) / 2 + + while items[pivot] isnt value and start < stop + + # Adjust the search area. + stop = pivot - 1 if value < items[pivot] + start = pivot + 1 if value > items[pivot] + + # Recalculate the pivot. + pivot = Math.floor (stop + start) / 2 + + # Make sure we've found the correct value. + if items[pivot] is value then pivot else -1 + +self.onmessage = (event) -> + data = event.data + binary_search(data.items, data.value) diff --git a/devtools/client/debugger/test/mochitest/code_worker-source-map.js b/devtools/client/debugger/test/mochitest/code_worker-source-map.js new file mode 100644 index 00000000000..9a9f541a956 --- /dev/null +++ b/devtools/client/debugger/test/mochitest/code_worker-source-map.js @@ -0,0 +1,35 @@ +// Generated by CoffeeScript 1.10.0 +(function() { + var binary_search; + + binary_search = function(items, value) { + var pivot, start, stop; + start = 0; + stop = items.length - 1; + pivot = Math.floor((start + stop) / 2); + while (items[pivot] !== value && start < stop) { + if (value < items[pivot]) { + stop = pivot - 1; + } + if (value > items[pivot]) { + start = pivot + 1; + } + pivot = Math.floor((stop + start) / 2); + } + if (items[pivot] === value) { + return pivot; + } else { + return -1; + } + }; + + self.onmessage = function(event) { + console.log("EUTA"); + var data; + data = event.data; + return binary_search(data.items, data.value); + }; + +}).call(this); + +//# sourceMappingURL=code_worker-source-map.js.map diff --git a/devtools/client/debugger/test/mochitest/code_worker-source-map.js.map b/devtools/client/debugger/test/mochitest/code_worker-source-map.js.map new file mode 100644 index 00000000000..97c801a5841 --- /dev/null +++ b/devtools/client/debugger/test/mochitest/code_worker-source-map.js.map @@ -0,0 +1,10 @@ +{ + "version": 3, + "file": "code_worker-source-map.js", + "sourceRoot": "", + "sources": [ + "code_worker-source-map.coffee" + ], + "names": [], + "mappings": ";AACA;AAAA,MAAA;;EAAA,aAAA,GAAgB,SAAC,KAAD,EAAQ,KAAR;AAEd,QAAA;IAAA,KAAA,GAAQ;IACR,IAAA,GAAQ,KAAK,CAAC,MAAN,GAAe;IACvB,KAAA,GAAQ,IAAI,CAAC,KAAL,CAAW,CAAC,KAAA,GAAQ,IAAT,CAAA,GAAiB,CAA5B;AAER,WAAM,KAAM,CAAA,KAAA,CAAN,KAAkB,KAAlB,IAA4B,KAAA,GAAQ,IAA1C;MAGE,IAAqB,KAAA,GAAQ,KAAM,CAAA,KAAA,CAAnC;QAAA,IAAA,GAAQ,KAAA,GAAQ,EAAhB;;MACA,IAAqB,KAAA,GAAQ,KAAM,CAAA,KAAA,CAAnC;QAAA,KAAA,GAAQ,KAAA,GAAQ,EAAhB;;MAGA,KAAA,GAAQ,IAAI,CAAC,KAAL,CAAW,CAAC,IAAA,GAAO,KAAR,CAAA,GAAiB,CAA5B;IAPV;IAUA,IAAG,KAAM,CAAA,KAAA,CAAN,KAAgB,KAAnB;aAA8B,MAA9B;KAAA,MAAA;aAAyC,CAAC,EAA1C;;EAhBc;;EAkBhB,IAAI,CAAC,SAAL,GAAiB,SAAC,KAAD;AACf,QAAA;IAAA,IAAA,GAAO,KAAK,CAAC;WACb,aAAA,CAAc,IAAI,CAAC,KAAnB,EAA0B,IAAI,CAAC,KAA/B;EAFe;AAlBjB" +} diff --git a/devtools/client/debugger/test/mochitest/doc_worker-source-map.html b/devtools/client/debugger/test/mochitest/doc_worker-source-map.html new file mode 100644 index 00000000000..20a14e35193 --- /dev/null +++ b/devtools/client/debugger/test/mochitest/doc_worker-source-map.html @@ -0,0 +1,18 @@ + + + + + + + + + diff --git a/devtools/client/debugger/views/workers-view.js b/devtools/client/debugger/views/workers-view.js index 4869f369bca..1dc86770a46 100644 --- a/devtools/client/debugger/views/workers-view.js +++ b/devtools/client/debugger/views/workers-view.js @@ -28,22 +28,24 @@ WorkersView.prototype = Heritage.extend(WidgetMethods, { this.widget.addEventListener("select", this._onWorkerSelect, false); }, - addWorker: function (actor, name) { + addWorker: function (workerForm) { let element = document.createElement("label"); element.className = "plain dbg-worker-item"; - element.setAttribute("value", name); + element.setAttribute("value", workerForm.url); element.setAttribute("flex", "1"); - this.push([element, actor], {}); + this.push([element, workerForm.actor], { + attachment: workerForm + }); }, - removeWorker: function (actor) { - this.remove(this.getItemByValue(actor)); + removeWorker: function (workerForm) { + this.remove(this.getItemByValue(workerForm.actor)); }, _onWorkerSelect: function () { if (this.selectedItem !== null) { - DebuggerController.Workers._onWorkerSelect(this.selectedItem.value); + DebuggerController.Workers._onWorkerSelect(this.selectedItem.attachment); this.selectedItem = null; } } From 61492c8c219657db55e8e60e2d38d9e157fee345 Mon Sep 17 00:00:00 2001 From: Marco Bonardo Date: Fri, 26 Feb 2016 18:55:36 +0100 Subject: [PATCH 007/160] Bug 1250958 - fix browser_markPageAsFollowedLink.js for e10s (and fix framed link coloring to make it pass). r=jaws MozReview-Commit-ID: 9k58B16nPL8 --- .../places/tests/browser/browser.ini | 1 - .../browser/browser_markPageAsFollowedLink.js | 125 ++++++++---------- browser/modules/ContentClick.jsm | 18 +-- 3 files changed, 62 insertions(+), 82 deletions(-) diff --git a/browser/components/places/tests/browser/browser.ini b/browser/components/places/tests/browser/browser.ini index 28614b5b02a..6d638d64ec2 100644 --- a/browser/components/places/tests/browser/browser.ini +++ b/browser/components/places/tests/browser/browser.ini @@ -46,7 +46,6 @@ skip-if = e10s # Bug ?????? - test fails - "Number of dragged items should be th [browser_library_search.js] [browser_library_views_liveupdate.js] [browser_markPageAsFollowedLink.js] -skip-if = e10s # Bug 933103 - mochitest's EventUtils.synthesizeMouse functions not e10s friendly (test does EventUtils.sendMouseEvent...) [browser_sidebarpanels_click.js] skip-if = true # temporarily disabled for breaking the treeview - bug 658744 [browser_sort_in_library.js] diff --git a/browser/components/places/tests/browser/browser_markPageAsFollowedLink.js b/browser/components/places/tests/browser/browser_markPageAsFollowedLink.js index e2a04f6017a..e3557338a33 100644 --- a/browser/components/places/tests/browser/browser_markPageAsFollowedLink.js +++ b/browser/components/places/tests/browser/browser_markPageAsFollowedLink.js @@ -1,7 +1,3 @@ -/* Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ - */ - /** * Tests that visits across frames are correctly represented in the database. */ @@ -11,76 +7,61 @@ const PAGE_URL = BASE_URL + "/framedPage.html"; const LEFT_URL = BASE_URL + "/frameLeft.html"; const RIGHT_URL = BASE_URL + "/frameRight.html"; -var gTabLoaded = false; -var gLeftFrameVisited = false; +add_task(function* test() { + // We must wait for both frames to be loaded and the visits to be registered. + let deferredLeftFrameVisit = PromiseUtils.defer(); + let deferredRightFrameVisit = PromiseUtils.defer(); -var observer = { - observe: function(aSubject, aTopic, aData) - { - let url = aSubject.QueryInterface(Ci.nsIURI).spec; - if (url == LEFT_URL ) { - is(getTransitionForUrl(url), null, - "Embed visits should not get a database entry."); - gLeftFrameVisited = true; - maybeClickLink(); - } - else if (url == RIGHT_URL ) { - is(getTransitionForUrl(url), PlacesUtils.history.TRANSITION_FRAMED_LINK, - "User activated visits should get a FRAMED_LINK transition."); - finish(); - } - }, - QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver]) -}; -Services.obs.addObserver(observer, "uri-visit-saved", false); + Services.obs.addObserver(function observe(subject) { + Task.spawn(function* () { + let url = subject.QueryInterface(Ci.nsIURI).spec; + if (url == LEFT_URL ) { + is((yield getTransitionForUrl(url)), null, + "Embed visits should not get a database entry."); + deferredLeftFrameVisit.resolve(); + } + else if (url == RIGHT_URL ) { + is((yield getTransitionForUrl(url)), + PlacesUtils.history.TRANSITION_FRAMED_LINK, + "User activated visits should get a FRAMED_LINK transition."); + Services.obs.removeObserver(observe, "uri-visit-saved"); + deferredRightFrameVisit.resolve(); + } + }); + }, "uri-visit-saved", false); -function test() -{ - waitForExplicitFinish(); - gBrowser.selectedTab = gBrowser.addTab(PAGE_URL); - let frameCount = 0; - gBrowser.selectedBrowser.addEventListener("DOMContentLoaded", - function (event) - { - // Wait for all the frames. - if (frameCount++ < 2) - return; - gBrowser.selectedBrowser.removeEventListener("DOMContentLoaded", arguments.callee, false) - gTabLoaded = true; - maybeClickLink(); - }, false - ); -} + // Open a tab and wait for all the subframes to load. + let tab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, PAGE_URL); -function maybeClickLink() { - if (gTabLoaded && gLeftFrameVisited) { - // Click on the link in the left frame to cause a page load in the - // right frame. - EventUtils.sendMouseEvent({type: "click"}, "clickme", content.frames[0]); + // Wait for the left frame visit to be registered. + info("Waiting left frame visit"); + yield deferredLeftFrameVisit.promise; + + // Click on the link in the left frame to cause a page load in the + // right frame. + info("Clicking link"); + yield ContentTask.spawn(tab.linkedBrowser, {}, function* () { + content.frames[0].document.getElementById("clickme").click(); + }); + + // Wait for the right frame visit to be registered. + info("Waiting right frame visit"); + yield deferredRightFrameVisit.promise; + + yield BrowserTestUtils.removeTab(tab); +}); + +function* getTransitionForUrl(url) { + // Ensure all the transactions completed. + yield PlacesTestUtils.promiseAsyncUpdates(); + let db = yield PlacesUtils.promiseDBConnection(); + let rows = yield db.execute(` + SELECT visit_type + FROM moz_historyvisits + WHERE place_id = (SELECT id FROM moz_places WHERE url = :url)`, + { url }); + if (rows.length) { + return rows[0].getResultByName("visit_type"); } + return null; } - -function getTransitionForUrl(aUrl) -{ - let dbConn = PlacesUtils.history - .QueryInterface(Ci.nsPIPlacesDatabase).DBConnection; - let stmt = dbConn.createStatement( - "SELECT visit_type FROM moz_historyvisits WHERE place_id = " + - "(SELECT id FROM moz_places WHERE url = :page_url)"); - stmt.params.page_url = aUrl; - try { - if (!stmt.executeStep()) { - return null; - } - return stmt.row.visit_type; - } - finally { - stmt.finalize(); - } -} - -registerCleanupFunction(function () -{ - gBrowser.removeTab(gBrowser.selectedTab); - Services.obs.removeObserver(observer, "uri-visit-saved"); -}) diff --git a/browser/modules/ContentClick.jsm b/browser/modules/ContentClick.jsm index 9f717f1146e..9053d4d3d44 100644 --- a/browser/modules/ContentClick.jsm +++ b/browser/modules/ContentClick.jsm @@ -61,6 +61,15 @@ var ContentClick = { // Note: We don't need the sidebar code here. + // Mark the page as a user followed link. This is done so that history can + // distinguish automatic embed visits from user activated ones. For example + // pages loaded in frames are embed visits and lost with the session, while + // visits across frames should be preserved. + try { + if (!PrivateBrowsingUtils.isWindowPrivate(window)) + PlacesUIUtils.markPageAsFollowedLink(json.href); + } catch (ex) { /* Skip invalid URIs. */ } + // This part is based on handleLinkClick. var where = window.whereToOpenLink(json); if (where == "current") @@ -73,14 +82,5 @@ var ContentClick = { referrerPolicy: json.referrerPolicy, noReferrer: json.noReferrer }; window.openLinkIn(json.href, where, params); - - // Mark the page as a user followed link. This is done so that history can - // distinguish automatic embed visits from user activated ones. For example - // pages loaded in frames are embed visits and lost with the session, while - // visits across frames should be preserved. - try { - if (!PrivateBrowsingUtils.isWindowPrivate(window)) - PlacesUIUtils.markPageAsFollowedLink(json.href); - } catch (ex) { /* Skip invalid URIs. */ } } }; From 855e9453c2bde34fe4d9a43389f5e687e171fb40 Mon Sep 17 00:00:00 2001 From: Tristan Date: Wed, 2 Mar 2016 08:19:11 -0500 Subject: [PATCH 008/160] Bug 1244197 - Fixed conditional logic for two performance optimizations, r=capella --- mobile/android/chrome/content/ActionBarHandler.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/mobile/android/chrome/content/ActionBarHandler.js b/mobile/android/chrome/content/ActionBarHandler.js index 2081071c3a2..97c15828590 100644 --- a/mobile/android/chrome/content/ActionBarHandler.js +++ b/mobile/android/chrome/content/ActionBarHandler.js @@ -63,8 +63,9 @@ var ActionBarHandler = { // Else, update an open ActionBar. if (this._selectionID) { - if ([this._targetElement, this._contentWindow] === - [Services.focus.focusedElement, Services.focus.focusedWindow]) { + let [element, win] = this._getSelectionTargets(); + if (this._targetElement === element && + this._contentWindow === win) { // We have the same focused window/element as before. Trigger "TextSelection:ActionbarStatus" // message only if available actions differ from when last we checked. this._sendActionBarActions(); @@ -225,8 +226,14 @@ var ActionBarHandler = { */ _sendActionBarActions: function(sendAlways) { let actions = this._getActionBarActions(); + let actionCountUnchanged = this._actionBarActions && + actions.length === this._actionBarActions.length; + let actionsMatch = actionCountUnchanged && + this._actionBarActions.every((e,i) => { + return e.id === actions[i].id; + }); - if (sendAlways || actions !== this._actionBarActions) { + if (sendAlways || !actionsMatch) { Messaging.sendRequest({ type: "TextSelection:ActionbarStatus", actions: actions, From 6e1dedaa15dd35e76ed1cf8dec0769d0a5042610 Mon Sep 17 00:00:00 2001 From: Panos Astithas Date: Tue, 1 Mar 2016 17:28:12 +0200 Subject: [PATCH 009/160] Bug 1252449 - Enable test_classifier.html and test_classifier_worker.html on e10s. r=gcp MozReview-Commit-ID: AxKMYI7nDkD --- .../tests/mochitest/classifierCommon.js | 38 ++++++++++++ .../tests/mochitest/mochitest.ini | 3 +- .../tests/mochitest/test_classifier.html | 54 ++++++----------- .../mochitest/test_classifier_worker.html | 60 +++++++------------ 4 files changed, 77 insertions(+), 78 deletions(-) create mode 100644 toolkit/components/url-classifier/tests/mochitest/classifierCommon.js diff --git a/toolkit/components/url-classifier/tests/mochitest/classifierCommon.js b/toolkit/components/url-classifier/tests/mochitest/classifierCommon.js new file mode 100644 index 00000000000..00e45ecb8a7 --- /dev/null +++ b/toolkit/components/url-classifier/tests/mochitest/classifierCommon.js @@ -0,0 +1,38 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ */ + +function doUpdate(update) { + const { classes: Cc, interfaces: Ci, results: Cr } = Components; + + let listener = { + QueryInterface: function(iid) + { + if (iid.equals(Ci.nsISupports) || + iid.equals(Ci.nsIUrlClassifierUpdateObserver)) + return this; + + throw Cr.NS_ERROR_NO_INTERFACE; + }, + updateUrlRequested: function(url) { }, + streamFinished: function(status) { }, + updateError: function(errorCode) { + sendAsyncMessage("updateError", { errorCode }); + }, + updateSuccess: function(requestedTimeout) { + sendAsyncMessage("loadTestFrame"); + } + }; + + let dbService = Cc["@mozilla.org/url-classifier/dbservice;1"] + .getService(Ci.nsIUrlClassifierDBService); + + dbService.beginUpdate(listener, "test-malware-simple,test-unwanted-simple", ""); + dbService.beginStream("", ""); + dbService.updateStream(update); + dbService.finishStream(); + dbService.finishUpdate(); +} + +addMessageListener("doUpdate", ({ testUpdate }) => { + doUpdate(testUpdate); +}); diff --git a/toolkit/components/url-classifier/tests/mochitest/mochitest.ini b/toolkit/components/url-classifier/tests/mochitest/mochitest.ini index d9356a5477f..55af28453e5 100644 --- a/toolkit/components/url-classifier/tests/mochitest/mochitest.ini +++ b/toolkit/components/url-classifier/tests/mochitest/mochitest.ini @@ -1,7 +1,8 @@ [DEFAULT] -skip-if = buildapp == 'b2g' || e10s +skip-if = buildapp == 'b2g' support-files = classifiedAnnotatedPBFrame.html + classifierCommon.js classifierFrame.html cleanWorker.js good.js diff --git a/toolkit/components/url-classifier/tests/mochitest/test_classifier.html b/toolkit/components/url-classifier/tests/mochitest/test_classifier.html index 374271addb6..2ea5bfeb5e9 100644 --- a/toolkit/components/url-classifier/tests/mochitest/test_classifier.html +++ b/toolkit/components/url-classifier/tests/mochitest/test_classifier.html @@ -13,8 +13,6 @@ diff --git a/toolkit/components/url-classifier/tests/mochitest/test_classifier_worker.html b/toolkit/components/url-classifier/tests/mochitest/test_classifier_worker.html index d74f2802521..954d674715f 100644 --- a/toolkit/components/url-classifier/tests/mochitest/test_classifier_worker.html +++ b/toolkit/components/url-classifier/tests/mochitest/test_classifier_worker.html @@ -13,9 +13,6 @@ + - +

- diff --git a/uriloader/exthandler/tests/mochitest/unsafeBidi_chromeScript.js b/uriloader/exthandler/tests/mochitest/unsafeBidi_chromeScript.js new file mode 100644 index 00000000000..16c82d818e6 --- /dev/null +++ b/uriloader/exthandler/tests/mochitest/unsafeBidi_chromeScript.js @@ -0,0 +1,28 @@ +const { classes: Cc, interfaces: Ci, utils: Cu } = Components; + +Cu.import("resource://gre/modules/XPCOMUtils.jsm"); + +const HELPERAPP_DIALOG_CONTRACT = "@mozilla.org/helperapplauncherdialog;1"; +const HELPERAPP_DIALOG_CID = + Components.ID(Cc[HELPERAPP_DIALOG_CONTRACT].number); + +const FAKE_CID = Cc["@mozilla.org/uuid-generator;1"]. + getService(Ci.nsIUUIDGenerator).generateUUID(); + +function HelperAppLauncherDialog() {} +HelperAppLauncherDialog.prototype = { + show: function(aLauncher, aWindowContext, aReason) { + sendAsyncMessage("suggestedFileName", aLauncher.suggestedFileName); + }, + QueryInterface: XPCOMUtils.generateQI([Ci.nsIHelperAppLauncherDialog]) +}; + +var registrar = Components.manager.QueryInterface(Ci.nsIComponentRegistrar); +registrar.registerFactory(FAKE_CID, "", HELPERAPP_DIALOG_CONTRACT, + XPCOMUtils._getFactory(HelperAppLauncherDialog)); + +addMessageListener("unregister", function() { + registrar.registerFactory(HELPERAPP_DIALOG_CID, "", + HELPERAPP_DIALOG_CONTRACT, null); + sendAsyncMessage("unregistered"); +}); From 1127179683d70bdb85c1878fa5a44e2073830eb8 Mon Sep 17 00:00:00 2001 From: Sebastian Hengst Date: Wed, 2 Mar 2016 15:09:16 +0100 Subject: [PATCH 011/160] Backed out changeset a1c1b0943294 (bug 1245603) for failing own test. r=failure --- .../components/extensions/ext-downloads.js | 315 +-------------- .../extensions/schemas/downloads.json | 14 +- .../test/mochitest/file_download.html | 12 - .../extensions/test/mochitest/mochitest.ini | 3 - .../mochitest/test_ext_downloads_search.html | 366 ------------------ 5 files changed, 9 insertions(+), 701 deletions(-) delete mode 100644 toolkit/components/extensions/test/mochitest/file_download.html delete mode 100644 toolkit/components/extensions/test/mochitest/test_ext_downloads_search.html diff --git a/toolkit/components/extensions/ext-downloads.js b/toolkit/components/extensions/ext-downloads.js index 985be8131b6..949084fc2af 100644 --- a/toolkit/components/extensions/ext-downloads.js +++ b/toolkit/components/extensions/ext-downloads.js @@ -20,262 +20,7 @@ const { ignoreEvent, } = ExtensionUtils; -const DOWNLOAD_ITEM_FIELDS = ["id", "url", "referrer", "filename", "incognito", - "danger", "mime", "startTime", "endTime", - "estimatedEndTime", "state", "canResume", - "error", "bytesReceived", "totalBytes", - "fileSize", "exists", - "byExtensionId", "byExtensionName"]; - -class DownloadItem { - constructor(id, download, extension) { - this.id = id; - this.download = download; - this.extension = extension; - } - - get url() { return this.download.source.url; } - get referrer() { return this.download.source.referrer; } - get filename() { return this.download.target.path; } - get incognito() { return this.download.source.isPrivate; } - get danger() { return "safe"; } // TODO - get mime() { return this.download.contentType; } - get startTime() { return this.download.startTime; } - get endTime() { return null; } // TODO - get estimatedEndTime() { return null; } // TODO - get state() { - if (this.download.succeeded) { - return "complete"; - } - if (this.download.stopped) { - return "interrupted"; - } - return "in_progress"; - } - get canResume() { - return this.download.stopped && this.download.hasPartialData; - } - get error() { - if (!this.download.stopped || this.download.succeeded) { - return null; - } - // TODO store this instead of calculating it - - if (this.download.error) { - if (this.download.error.becauseSourceFailed) { - return "NETWORK_FAILED"; // TODO - } - if (this.download.error.becauseTargetFailed) { - return "FILE_FAILED"; // TODO - } - return "CRASH"; - } - return "USER_CANCELED"; - } - get bytesReceived() { - return this.download.currentBytes; - } - get totalBytes() { - return this.download.hasProgress ? this.download.totalBytes : -1; - } - get fileSize() { - // todo: this is supposed to be post-compression - return this.download.succeeded ? this.download.target.size : -1; - } - get exists() { return this.download.target.exists; } - get byExtensionId() { return this.extension.id; } - get byExtensionName() { return this.extension.name; } - - /** - * Create a cloneable version of this object by pulling all the - * fields into simple properties (instead of getters). - * - * @returns {object} A DownloadItem with flat properties, - * suitable for cloning. - */ - serialize() { - let obj = {}; - for (let field of DOWNLOAD_ITEM_FIELDS) { - obj[field] = this[field]; - } - if (obj.startTime) { - obj.startTime = obj.startTime.toISOString(); - } - return obj; - } -} - - -// DownloadMap maps back and forth betwen the numeric identifiers used in -// the downloads WebExtension API and a Download object from the Downloads jsm. -// todo: make id and extension info persistent (bug 1247794) -const DownloadMap = { - currentId: 0, - loadPromise: null, - - // Maps numeric id -> DownloadItem - byId: new Map(), - - // Maps Download object -> DownloadItem - byDownload: new WeakMap(), - - lazyInit() { - return Downloads.getList(Downloads.ALL).then(list => { - return list.getAll().then(downloads => { - downloads.forEach(download => { - this.newFromDownload(download, null); - }); - let self = this; - return list.addView({ - onDownloadAdded(download) { - self.newFromDownload(download, null); - }, - - onDownloadRemoved(download) { - const item = self.byDownload.get(download); - if (item != null) { - self.byDownload.delete(download); - self.byId.delete(item.id); - } - }, - }); - }); - }); - }, - - getAll() { - if (this.loadPromise == null) { - this.loadPromise = this.lazyInit(); - } - return this.loadPromise.then(() => this.byId.values()); - }, - - fromId(id) { - const download = this.byId.get(id); - if (!download) { - throw new Error(`Invalid download id ${id}`); - } - return download; - }, - - newFromDownload(download, extension) { - if (this.byDownload.has(download)) { - return this.byDownload.get(download); - } - - const id = ++this.currentId; - let item = new DownloadItem(id, download, extension); - this.byId.set(id, item); - this.byDownload.set(download, item); - return item; - }, -}; - -// Create a callable function that filters a DownloadItem based on a -// query object of the type passed to search() or erase(). -function downloadQuery(query) { - let queryTerms = []; - let queryNegativeTerms = []; - if (query.query != null) { - for (let term of query.query) { - if (term[0] == "-") { - queryNegativeTerms.push(term.slice(1).toLowerCase()); - } else { - queryTerms.push(term.toLowerCase()); - } - } - } - - function normalizeTime(arg, before) { - if (arg == null) { - return before ? Number.MAX_VALUE : 0; - } - return parseInt(arg, 10); - } - - const startedBefore = normalizeTime(query.startedBefore, true); - const startedAfter = normalizeTime(query.startedAfter, false); - // const endedBefore = normalizeTime(query.endedBefore, true); - // const endedAfter = normalizeTime(query.endedAfter, false); - - const totalBytesGreater = query.totalBytesGreater || 0; - const totalBytesLess = (query.totalBytesLess != null) - ? query.totalBytesLess : Number.MAX_VALUE; - - // Handle options for which we can have a regular expression and/or - // an explicit value to match. - function makeMatch(regex, value, field) { - if (value == null && regex == null) { - return input => true; - } - - let re; - try { - re = new RegExp(regex || "", "i"); - } catch (err) { - throw new Error(`Invalid ${field}Regex: ${err.message}`); - } - if (value == null) { - return input => re.test(input); - } - - value = value.toLowerCase(); - if (re.test(value)) { - return input => (value == input); - } else { - return input => false; - } - } - - const matchFilename = makeMatch(query.filenameRegex, query.filename, "filename"); - const matchUrl = makeMatch(query.urlRegex, query.url, "url"); - - return function(item) { - const url = item.url.toLowerCase(); - const filename = item.filename.toLowerCase(); - - if (!queryTerms.every(term => url.includes(term) || filename.includes(term))) { - return false; - } - - if (queryNegativeTerms.some(term => url.includes(term) || filename.includes(term))) { - return false; - } - - if (!matchFilename(filename) || !matchUrl(url)) { - return false; - } - - if (!item.startTime) { - if (query.startedBefore != null || query.startedAfter != null) { - return false; - } - } else if (item.startTime > startedBefore || item.startTime < startedAfter) { - return false; - } - - // todo endedBefore, endedAfter - - if (item.totalBytes == -1) { - if (query.totalBytesGreater != null || query.totalBytesLess != null) { - return false; - } - } else if (item.totalBytes <= totalBytesGreater || item.totalBytes >= totalBytesLess) { - return false; - } - - // todo: include danger, paused, error - const SIMPLE_ITEMS = ["id", "mime", "startTime", "endTime", "state", - "bytesReceived", "totalBytes", "fileSize", "exists"]; - for (let field of SIMPLE_ITEMS) { - if (query[field] != null && item[field] != query[field]) { - return false; - } - } - - return true; - }; -} +let currentId = 0; extensions.registerSchemaAPI("downloads", "downloads", (extension, context) => { return { @@ -349,64 +94,12 @@ extensions.registerSchemaAPI("downloads", "downloads", (extension, context) => { download.tryToKeepPartialData = true; download.start(); - const item = DownloadMap.newFromDownload(download, extension); - return item.id; + // Without other chrome.downloads methods, we can't actually + // do anything with the id so just return a dummy value for now. + return currentId++; }); }, - search(query) { - let matchFn; - try { - matchFn = downloadQuery(query); - } catch (err) { - return Promise.reject({message: err.message}); - } - - let compareFn; - if (query.orderBy != null) { - const fields = query.orderBy.map(field => field[0] == "-" - ? {reverse: true, name: field.slice(1)} - : {reverse: false, name: field}); - - for (let field of fields) { - if (!DOWNLOAD_ITEM_FIELDS.includes(field.name)) { - return Promise.reject({message: `Invalid orderBy field ${field.name}`}); - } - } - - compareFn = (dl1, dl2) => { - for (let field of fields) { - const val1 = dl1[field.name]; - const val2 = dl2[field.name]; - - if (val1 < val2) { - return field.reverse ? 1 : -1; - } else if (val1 > val2) { - return field.reverse ? -1 : 1; - } - } - return 0; - }; - } - - return DownloadMap.getAll().then(downloads => { - if (compareFn) { - downloads = Array.from(downloads); - downloads.sort(compareFn); - } - let results = []; - for (let download of downloads) { - if (query.limit && results.length >= query.limit) { - break; - } - if (matchFn(download)) { - results.push(download.serialize()); - } - } - return results; - }); - }, - // When we do open(), check for additional downloads.open permission. // i.e.: // open(downloadId) { diff --git a/toolkit/components/extensions/schemas/downloads.json b/toolkit/components/extensions/schemas/downloads.json index f4a82f846cf..b13e314cfd2 100644 --- a/toolkit/components/extensions/schemas/downloads.json +++ b/toolkit/components/extensions/schemas/downloads.json @@ -295,7 +295,7 @@ { "name": "search", "type": "function", - "async": "callback", + "unsupported": true, "description": "Find DownloadItems. Set query to the empty object to get all DownloadItems. To get a specific DownloadItem, set only the id field.", "parameters": [ { @@ -311,26 +311,22 @@ "startedBefore": { "description": "Limits results to downloads that started before the given ms since the epoch.", "optional": true, - "type": "string", - "pattern": "^[1-9]\\d*$" + "type": "string" }, "startedAfter": { "description": "Limits results to downloads that started after the given ms since the epoch.", "optional": true, - "type": "string", - "pattern": "^[1-9]\\d*$" + "type": "string" }, "endedBefore": { "description": "Limits results to downloads that ended before the given ms since the epoch.", "optional": true, - "type": "string", - "pattern": "^[1-9]\\d*$" + "type": "string" }, "endedAfter": { "description": "Limits results to downloads that ended after the given ms since the epoch.", "optional": true, - "type": "string", - "pattern": "^[1-9]\\d*$" + "type": "string" }, "totalBytesGreater": { "description": "Limits results to downloads whose totalBytes is greater than the given integer.", diff --git a/toolkit/components/extensions/test/mochitest/file_download.html b/toolkit/components/extensions/test/mochitest/file_download.html deleted file mode 100644 index d970c63259d..00000000000 --- a/toolkit/components/extensions/test/mochitest/file_download.html +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - -
Download HTML File
- - - diff --git a/toolkit/components/extensions/test/mochitest/mochitest.ini b/toolkit/components/extensions/test/mochitest/mochitest.ini index f9a1d2f8605..b0f2beebb4e 100644 --- a/toolkit/components/extensions/test/mochitest/mochitest.ini +++ b/toolkit/components/extensions/test/mochitest/mochitest.ini @@ -22,8 +22,6 @@ support-files = file_privilege_escalation.html file_ext_test_api_injection.js file_permission_xhr.html - file_download.html - file_download.txt [test_ext_simple.html] [test_ext_schema.html] @@ -34,7 +32,6 @@ skip-if = buildapp == 'b2g' # runat != document_idle is not supported. [test_ext_contentscript_create_iframe.html] [test_ext_contentscript_api_injection.html] [test_ext_downloads.html] -[test_ext_downloads_search.html] [test_ext_i18n_css.html] [test_ext_generate.html] [test_ext_idle.html] diff --git a/toolkit/components/extensions/test/mochitest/test_ext_downloads_search.html b/toolkit/components/extensions/test/mochitest/test_ext_downloads_search.html deleted file mode 100644 index 5d92bfff53b..00000000000 --- a/toolkit/components/extensions/test/mochitest/test_ext_downloads_search.html +++ /dev/null @@ -1,366 +0,0 @@ - - - - WebExtension test - - - - - - - - - - - - From f5a1b57f56904d3a39c282111d03cd2b4b451b2f Mon Sep 17 00:00:00 2001 From: Gijs Kruitbosch Date: Mon, 29 Feb 2016 14:11:04 +0000 Subject: [PATCH 012/160] Bug 1094510 - make browser_canonizeURL.js not hit the network in e10s mode, r=mconley MozReview-Commit-ID: JlEYeir749V --- browser/base/content/test/general/browser.ini | 1 - .../test/general/browser_canonizeURL.js | 76 +++++++++++-------- .../BrowserTestUtils/BrowserTestUtils.jsm | 21 +++++ 3 files changed, 66 insertions(+), 32 deletions(-) diff --git a/browser/base/content/test/general/browser.ini b/browser/base/content/test/general/browser.ini index 585b732a4f3..dcfac57841f 100644 --- a/browser/base/content/test/general/browser.ini +++ b/browser/base/content/test/general/browser.ini @@ -290,7 +290,6 @@ skip-if = os == 'win' || e10s # Bug 1159268 - Need a content-process safe versio [browser_bug1070778.js] [browser_accesskeys.js] [browser_canonizeURL.js] -skip-if = e10s # Bug 1094510 - test hits the network in e10s mode only [browser_clipboard.js] [browser_contentAreaClick.js] [browser_contextmenu.js] diff --git a/browser/base/content/test/general/browser_canonizeURL.js b/browser/base/content/test/general/browser_canonizeURL.js index 48fd814440f..2b0fc22e7eb 100644 --- a/browser/base/content/test/general/browser_canonizeURL.js +++ b/browser/base/content/test/general/browser_canonizeURL.js @@ -1,8 +1,3 @@ -function test() { - waitForExplicitFinish(); - testNext(); -} - var pairs = [ ["example", "http://www.example.net/"], ["ex-ample", "http://www.ex-ample.net/"], @@ -20,37 +15,56 @@ var pairs = [ ["ex ample", Services.search.defaultEngine.getSubmission("ex ample", null, "keyword").uri.spec], ]; -function testNext() { - if (!pairs.length) { - finish(); - return; - } +add_task(function*() { + for (let [inputValue, expectedURL] of pairs) { + let focusEventPromise = BrowserTestUtils.waitForEvent(gURLBar, "focus"); + let messagePromise = BrowserTestUtils.waitForMessage(gBrowser.selectedBrowser.messageManager, + "browser_canonizeURL:start"); - let [inputValue, expectedURL] = pairs.shift(); + let stoppedLoadPromise = ContentTask.spawn(gBrowser.selectedBrowser, [inputValue, expectedURL], + function([inputValue, expectedURL]) { + return new Promise(resolve => { + let wpl = { + onStateChange(aWebProgress, aRequest, aStateFlags, aStatus) { + if (aStateFlags & Ci.nsIWebProgressListener.STATE_START && + aStateFlags & Ci.nsIWebProgressListener.STATE_IS_NETWORK) { + if (!aRequest || !(aRequest instanceof Ci.nsIChannel)) { + return; + } + aRequest.QueryInterface(Ci.nsIChannel); + is(aRequest.originalURI.spec, expectedURL, + "entering '" + inputValue + "' loads expected URL"); - gBrowser.addProgressListener({ - onStateChange: function onStateChange(aWebProgress, aRequest, aStateFlags, aStatus) { - if (aStateFlags & Ci.nsIWebProgressListener.STATE_START && - aStateFlags & Ci.nsIWebProgressListener.STATE_IS_NETWORK) { - is(aRequest.originalURI.spec, expectedURL, - "entering '" + inputValue + "' loads expected URL"); + webProgress.removeProgressListener(filter); + filter.removeProgressListener(wpl); + docShell.QueryInterface(Ci.nsIWebNavigation); + docShell.stop(docShell.STOP_ALL); + resolve(); + } + }, + }; + let filter = Cc["@mozilla.org/appshell/component/browser-status-filter;1"] + .createInstance(Ci.nsIWebProgress); + filter.addProgressListener(wpl, Ci.nsIWebProgress.NOTIFY_ALL); - gBrowser.removeProgressListener(this); - gBrowser.stop(); - - executeSoon(testNext); + let webProgress = docShell.QueryInterface(Ci.nsIInterfaceRequestor) + .getInterface(Ci.nsIWebProgress); + webProgress.addProgressListener(filter, Ci.nsIWebProgress.NOTIFY_ALL); + // We're sending this off to trigger the start of the this test, when all the + // listeners are in place: + sendAsyncMessage("browser_canonizeURL:start"); + }); } - } - }); + ); + + gBrowser.selectedBrowser.focus(); + gURLBar.focus(); + + yield Promise.all([focusEventPromise, messagePromise]); - gURLBar.addEventListener("focus", function onFocus() { - gURLBar.removeEventListener("focus", onFocus); gURLBar.inputField.value = inputValue.slice(0, -1); EventUtils.synthesizeKey(inputValue.slice(-1) , {}); EventUtils.synthesizeKey("VK_RETURN", { shiftKey: true }); - }); - - gBrowser.selectedBrowser.focus(); - gURLBar.focus(); - -} + yield stoppedLoadPromise; + } +}); diff --git a/testing/mochitest/BrowserTestUtils/BrowserTestUtils.jsm b/testing/mochitest/BrowserTestUtils/BrowserTestUtils.jsm index 73c7cd6e405..b7788372d70 100644 --- a/testing/mochitest/BrowserTestUtils/BrowserTestUtils.jsm +++ b/testing/mochitest/BrowserTestUtils/BrowserTestUtils.jsm @@ -591,6 +591,27 @@ this.BrowserTestUtils = { }); }, + /** + * Wait for a message to be fired from a particular message manager + * + * @param {nsIMessageManager} messageManager + * The message manager that should be used. + * @param {String} message + * The message we're waiting for. + * @param {Function} checkFn (optional) + * Optional function to invoke to check the message. + */ + waitForMessage(messageManager, message, checkFn) { + return new Promise(resolve => { + messageManager.addMessageListener(message, function onMessage(msg) { + if (!checkFn || checkFn(msg)) { + messageManager.removeMessageListener(message, onMessage); + resolve(); + } + }); + }); + }, + /** * Version of synthesizeMouse that uses the center of the target as the mouse * location. Arguments and the return value are the same. From 5a75f2a97f992475d7a36c5305756ad92c57eaf6 Mon Sep 17 00:00:00 2001 From: Manuel Casas Barrado Date: Wed, 2 Mar 2016 16:42:13 +0100 Subject: [PATCH 013/160] Bug 1245486 - Send Telemetry events for use of the Pause and Restart buttons. r=mikedeboer --- toolkit/components/telemetry/Histograms.json | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/toolkit/components/telemetry/Histograms.json b/toolkit/components/telemetry/Histograms.json index 3d0f27fdcab..48391a61dca 100644 --- a/toolkit/components/telemetry/Histograms.json +++ b/toolkit/components/telemetry/Histograms.json @@ -8480,6 +8480,15 @@ "releaseChannelCollection": "opt-out", "description": "Number of sessions where at least one chat message was exchanged" }, + "LOOP_INFOBAR_ACTION_BUTTONS": { + "alert_emails": ["firefox-dev@mozilla.org", "mbanner@mozilla.com"], + "expires_in_version": "51", + "kind": "enumerated", + "n_values": 4, + "releaseChannelCollection": "opt-out", + "bug_numbers": [1245486], + "description": "Number times info bar buttons are clicked (0=PAUSED, 1=CREATED)" + }, "E10S_STATUS": { "alert_emails": ["firefox-dev@mozilla.org"], "expires_in_version": "never", From 72202848120611d189b29d67f39283c195e865ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A3o=20Gottwald?= Date: Wed, 2 Mar 2016 17:16:59 +0100 Subject: [PATCH 014/160] Bug 1250806 - Add menuitems for recent bookmarks synchronously so that they show up in the native menubar on OS X. r=mak --- browser/base/content/browser-places.js | 65 ++++++++++++-------------- 1 file changed, 29 insertions(+), 36 deletions(-) diff --git a/browser/base/content/browser-places.js b/browser/base/content/browser-places.js index 54013d915ac..a6b1d836333 100644 --- a/browser/base/content/browser-places.js +++ b/browser/base/content/browser-places.js @@ -1379,44 +1379,37 @@ var BookmarkingUI = { aHeaderItem.nextSibling.remove(); } - PlacesUtils.history.QueryInterface(Ci.nsPIPlacesDatabase) - .asyncExecuteLegacyQueries([query], 1, options, { - handleResult: function (aResultSet) { - let onItemCommand = function (aEvent) { - let item = aEvent.target; - openUILink(item.getAttribute("targetURI"), aEvent); - CustomizableUI.hidePanelForNode(item); - }; + let onItemCommand = function (aEvent) { + let item = aEvent.target; + openUILink(item.getAttribute("targetURI"), aEvent); + CustomizableUI.hidePanelForNode(item); + }; - let fragment = document.createDocumentFragment(); - let row; - while ((row = aResultSet.getNextRow())) { - let uri = row.getResultByIndex(1); - let title = row.getResultByIndex(2); - let icon = row.getResultByIndex(6); + let fragment = document.createDocumentFragment(); + let root = PlacesUtils.history.executeQuery(query, options).root; + root.containerOpen = true; + for (let i = 0; i < root.childCount; i++) { + let node = root.getChild(i); + let uri = node.uri; + let title = node.title; + let icon = node.icon; - let item = - document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", - "menuitem"); - item.setAttribute("label", title || uri); - item.setAttribute("targetURI", uri); - item.setAttribute("class", "menuitem-iconic menuitem-with-favicon bookmark-item " + - extraCSSClass); - item.addEventListener("command", onItemCommand); - if (icon) { - let iconURL = "moz-anno:favicon:" + icon; - item.setAttribute("image", iconURL); - } - fragment.appendChild(item); - } - aHeaderItem.parentNode.insertBefore(fragment, aHeaderItem.nextSibling); - }, - handleError: function (aError) { - Cu.reportError("Error while attempting to show recent bookmarks: " + aError); - }, - handleCompletion: function (aReason) { - }, - }); + let item = + document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", + "menuitem"); + item.setAttribute("label", title || uri); + item.setAttribute("targetURI", uri); + item.setAttribute("class", "menuitem-iconic menuitem-with-favicon bookmark-item " + + extraCSSClass); + item.addEventListener("command", onItemCommand); + if (icon) { + let iconURL = "moz-anno:favicon:" + icon; + item.setAttribute("image", iconURL); + } + fragment.appendChild(item); + } + root.containerOpen = false; + aHeaderItem.parentNode.insertBefore(fragment, aHeaderItem.nextSibling); }, /** From e1b16aa829aaf8bc9ae89427b390f464c835a73c Mon Sep 17 00:00:00 2001 From: Andrew Swan Date: Wed, 2 Mar 2016 10:23:55 -0800 Subject: [PATCH 015/160] Bug 1245603 - Implement browser.downloads.search() r=kmag MozReview-Commit-ID: 9XqkfZyeS8X --- .../components/extensions/ext-downloads.js | 315 ++++++++++++++- .../extensions/schemas/downloads.json | 14 +- .../extensions/test/mochitest/chrome.ini | 2 + .../test/mochitest/file_download.html | 12 + .../extensions/test/mochitest/mochitest.ini | 1 + .../test_chrome_ext_downloads_search.html | 373 ++++++++++++++++++ 6 files changed, 708 insertions(+), 9 deletions(-) create mode 100644 toolkit/components/extensions/test/mochitest/file_download.html create mode 100644 toolkit/components/extensions/test/mochitest/test_chrome_ext_downloads_search.html diff --git a/toolkit/components/extensions/ext-downloads.js b/toolkit/components/extensions/ext-downloads.js index 949084fc2af..985be8131b6 100644 --- a/toolkit/components/extensions/ext-downloads.js +++ b/toolkit/components/extensions/ext-downloads.js @@ -20,7 +20,262 @@ const { ignoreEvent, } = ExtensionUtils; -let currentId = 0; +const DOWNLOAD_ITEM_FIELDS = ["id", "url", "referrer", "filename", "incognito", + "danger", "mime", "startTime", "endTime", + "estimatedEndTime", "state", "canResume", + "error", "bytesReceived", "totalBytes", + "fileSize", "exists", + "byExtensionId", "byExtensionName"]; + +class DownloadItem { + constructor(id, download, extension) { + this.id = id; + this.download = download; + this.extension = extension; + } + + get url() { return this.download.source.url; } + get referrer() { return this.download.source.referrer; } + get filename() { return this.download.target.path; } + get incognito() { return this.download.source.isPrivate; } + get danger() { return "safe"; } // TODO + get mime() { return this.download.contentType; } + get startTime() { return this.download.startTime; } + get endTime() { return null; } // TODO + get estimatedEndTime() { return null; } // TODO + get state() { + if (this.download.succeeded) { + return "complete"; + } + if (this.download.stopped) { + return "interrupted"; + } + return "in_progress"; + } + get canResume() { + return this.download.stopped && this.download.hasPartialData; + } + get error() { + if (!this.download.stopped || this.download.succeeded) { + return null; + } + // TODO store this instead of calculating it + + if (this.download.error) { + if (this.download.error.becauseSourceFailed) { + return "NETWORK_FAILED"; // TODO + } + if (this.download.error.becauseTargetFailed) { + return "FILE_FAILED"; // TODO + } + return "CRASH"; + } + return "USER_CANCELED"; + } + get bytesReceived() { + return this.download.currentBytes; + } + get totalBytes() { + return this.download.hasProgress ? this.download.totalBytes : -1; + } + get fileSize() { + // todo: this is supposed to be post-compression + return this.download.succeeded ? this.download.target.size : -1; + } + get exists() { return this.download.target.exists; } + get byExtensionId() { return this.extension.id; } + get byExtensionName() { return this.extension.name; } + + /** + * Create a cloneable version of this object by pulling all the + * fields into simple properties (instead of getters). + * + * @returns {object} A DownloadItem with flat properties, + * suitable for cloning. + */ + serialize() { + let obj = {}; + for (let field of DOWNLOAD_ITEM_FIELDS) { + obj[field] = this[field]; + } + if (obj.startTime) { + obj.startTime = obj.startTime.toISOString(); + } + return obj; + } +} + + +// DownloadMap maps back and forth betwen the numeric identifiers used in +// the downloads WebExtension API and a Download object from the Downloads jsm. +// todo: make id and extension info persistent (bug 1247794) +const DownloadMap = { + currentId: 0, + loadPromise: null, + + // Maps numeric id -> DownloadItem + byId: new Map(), + + // Maps Download object -> DownloadItem + byDownload: new WeakMap(), + + lazyInit() { + return Downloads.getList(Downloads.ALL).then(list => { + return list.getAll().then(downloads => { + downloads.forEach(download => { + this.newFromDownload(download, null); + }); + let self = this; + return list.addView({ + onDownloadAdded(download) { + self.newFromDownload(download, null); + }, + + onDownloadRemoved(download) { + const item = self.byDownload.get(download); + if (item != null) { + self.byDownload.delete(download); + self.byId.delete(item.id); + } + }, + }); + }); + }); + }, + + getAll() { + if (this.loadPromise == null) { + this.loadPromise = this.lazyInit(); + } + return this.loadPromise.then(() => this.byId.values()); + }, + + fromId(id) { + const download = this.byId.get(id); + if (!download) { + throw new Error(`Invalid download id ${id}`); + } + return download; + }, + + newFromDownload(download, extension) { + if (this.byDownload.has(download)) { + return this.byDownload.get(download); + } + + const id = ++this.currentId; + let item = new DownloadItem(id, download, extension); + this.byId.set(id, item); + this.byDownload.set(download, item); + return item; + }, +}; + +// Create a callable function that filters a DownloadItem based on a +// query object of the type passed to search() or erase(). +function downloadQuery(query) { + let queryTerms = []; + let queryNegativeTerms = []; + if (query.query != null) { + for (let term of query.query) { + if (term[0] == "-") { + queryNegativeTerms.push(term.slice(1).toLowerCase()); + } else { + queryTerms.push(term.toLowerCase()); + } + } + } + + function normalizeTime(arg, before) { + if (arg == null) { + return before ? Number.MAX_VALUE : 0; + } + return parseInt(arg, 10); + } + + const startedBefore = normalizeTime(query.startedBefore, true); + const startedAfter = normalizeTime(query.startedAfter, false); + // const endedBefore = normalizeTime(query.endedBefore, true); + // const endedAfter = normalizeTime(query.endedAfter, false); + + const totalBytesGreater = query.totalBytesGreater || 0; + const totalBytesLess = (query.totalBytesLess != null) + ? query.totalBytesLess : Number.MAX_VALUE; + + // Handle options for which we can have a regular expression and/or + // an explicit value to match. + function makeMatch(regex, value, field) { + if (value == null && regex == null) { + return input => true; + } + + let re; + try { + re = new RegExp(regex || "", "i"); + } catch (err) { + throw new Error(`Invalid ${field}Regex: ${err.message}`); + } + if (value == null) { + return input => re.test(input); + } + + value = value.toLowerCase(); + if (re.test(value)) { + return input => (value == input); + } else { + return input => false; + } + } + + const matchFilename = makeMatch(query.filenameRegex, query.filename, "filename"); + const matchUrl = makeMatch(query.urlRegex, query.url, "url"); + + return function(item) { + const url = item.url.toLowerCase(); + const filename = item.filename.toLowerCase(); + + if (!queryTerms.every(term => url.includes(term) || filename.includes(term))) { + return false; + } + + if (queryNegativeTerms.some(term => url.includes(term) || filename.includes(term))) { + return false; + } + + if (!matchFilename(filename) || !matchUrl(url)) { + return false; + } + + if (!item.startTime) { + if (query.startedBefore != null || query.startedAfter != null) { + return false; + } + } else if (item.startTime > startedBefore || item.startTime < startedAfter) { + return false; + } + + // todo endedBefore, endedAfter + + if (item.totalBytes == -1) { + if (query.totalBytesGreater != null || query.totalBytesLess != null) { + return false; + } + } else if (item.totalBytes <= totalBytesGreater || item.totalBytes >= totalBytesLess) { + return false; + } + + // todo: include danger, paused, error + const SIMPLE_ITEMS = ["id", "mime", "startTime", "endTime", "state", + "bytesReceived", "totalBytes", "fileSize", "exists"]; + for (let field of SIMPLE_ITEMS) { + if (query[field] != null && item[field] != query[field]) { + return false; + } + } + + return true; + }; +} extensions.registerSchemaAPI("downloads", "downloads", (extension, context) => { return { @@ -94,12 +349,64 @@ extensions.registerSchemaAPI("downloads", "downloads", (extension, context) => { download.tryToKeepPartialData = true; download.start(); - // Without other chrome.downloads methods, we can't actually - // do anything with the id so just return a dummy value for now. - return currentId++; + const item = DownloadMap.newFromDownload(download, extension); + return item.id; }); }, + search(query) { + let matchFn; + try { + matchFn = downloadQuery(query); + } catch (err) { + return Promise.reject({message: err.message}); + } + + let compareFn; + if (query.orderBy != null) { + const fields = query.orderBy.map(field => field[0] == "-" + ? {reverse: true, name: field.slice(1)} + : {reverse: false, name: field}); + + for (let field of fields) { + if (!DOWNLOAD_ITEM_FIELDS.includes(field.name)) { + return Promise.reject({message: `Invalid orderBy field ${field.name}`}); + } + } + + compareFn = (dl1, dl2) => { + for (let field of fields) { + const val1 = dl1[field.name]; + const val2 = dl2[field.name]; + + if (val1 < val2) { + return field.reverse ? 1 : -1; + } else if (val1 > val2) { + return field.reverse ? -1 : 1; + } + } + return 0; + }; + } + + return DownloadMap.getAll().then(downloads => { + if (compareFn) { + downloads = Array.from(downloads); + downloads.sort(compareFn); + } + let results = []; + for (let download of downloads) { + if (query.limit && results.length >= query.limit) { + break; + } + if (matchFn(download)) { + results.push(download.serialize()); + } + } + return results; + }); + }, + // When we do open(), check for additional downloads.open permission. // i.e.: // open(downloadId) { diff --git a/toolkit/components/extensions/schemas/downloads.json b/toolkit/components/extensions/schemas/downloads.json index b13e314cfd2..f4a82f846cf 100644 --- a/toolkit/components/extensions/schemas/downloads.json +++ b/toolkit/components/extensions/schemas/downloads.json @@ -295,7 +295,7 @@ { "name": "search", "type": "function", - "unsupported": true, + "async": "callback", "description": "Find DownloadItems. Set query to the empty object to get all DownloadItems. To get a specific DownloadItem, set only the id field.", "parameters": [ { @@ -311,22 +311,26 @@ "startedBefore": { "description": "Limits results to downloads that started before the given ms since the epoch.", "optional": true, - "type": "string" + "type": "string", + "pattern": "^[1-9]\\d*$" }, "startedAfter": { "description": "Limits results to downloads that started after the given ms since the epoch.", "optional": true, - "type": "string" + "type": "string", + "pattern": "^[1-9]\\d*$" }, "endedBefore": { "description": "Limits results to downloads that ended before the given ms since the epoch.", "optional": true, - "type": "string" + "type": "string", + "pattern": "^[1-9]\\d*$" }, "endedAfter": { "description": "Limits results to downloads that ended after the given ms since the epoch.", "optional": true, - "type": "string" + "type": "string", + "pattern": "^[1-9]\\d*$" }, "totalBytesGreater": { "description": "Limits results to downloads whose totalBytes is greater than the given integer.", diff --git a/toolkit/components/extensions/test/mochitest/chrome.ini b/toolkit/components/extensions/test/mochitest/chrome.ini index 13b50df4c46..d0b13e6cd9f 100644 --- a/toolkit/components/extensions/test/mochitest/chrome.ini +++ b/toolkit/components/extensions/test/mochitest/chrome.ini @@ -1,6 +1,8 @@ [DEFAULT] skip-if = os == 'android' support-files = + file_download.html file_download.txt [test_chrome_ext_downloads_download.html] +[test_chrome_ext_downloads_search.html] diff --git a/toolkit/components/extensions/test/mochitest/file_download.html b/toolkit/components/extensions/test/mochitest/file_download.html new file mode 100644 index 00000000000..d970c63259d --- /dev/null +++ b/toolkit/components/extensions/test/mochitest/file_download.html @@ -0,0 +1,12 @@ + + + + + + + + +
Download HTML File
+ + + diff --git a/toolkit/components/extensions/test/mochitest/mochitest.ini b/toolkit/components/extensions/test/mochitest/mochitest.ini index b0f2beebb4e..c2c49e75c12 100644 --- a/toolkit/components/extensions/test/mochitest/mochitest.ini +++ b/toolkit/components/extensions/test/mochitest/mochitest.ini @@ -22,6 +22,7 @@ support-files = file_privilege_escalation.html file_ext_test_api_injection.js file_permission_xhr.html + file_download.txt [test_ext_simple.html] [test_ext_schema.html] diff --git a/toolkit/components/extensions/test/mochitest/test_chrome_ext_downloads_search.html b/toolkit/components/extensions/test/mochitest/test_chrome_ext_downloads_search.html new file mode 100644 index 00000000000..4852fd5c918 --- /dev/null +++ b/toolkit/components/extensions/test/mochitest/test_chrome_ext_downloads_search.html @@ -0,0 +1,373 @@ + + + + WebExtension test + + + + + + + + + + + + From e6c6b204d252ced9449dce84793aac3cb2cc0bb1 Mon Sep 17 00:00:00 2001 From: Chenxia Liu Date: Wed, 2 Mar 2016 10:42:19 -0800 Subject: [PATCH 016/160] Bug 1232866 - Establish clearer IA for panel list items. r=mcomella MozReview-Commit-ID: 40quuVQxL2K --- .../mozilla/gecko/home/TwoLinePageRow.java | 29 ++++++++---------- .../drawable-hdpi/ic_url_bar_star.png | Bin 277 -> 0 bytes .../drawable-nodpi/bookmarked_star.png | Bin 0 -> 600 bytes .../drawable-xhdpi/ic_url_bar_star.png | Bin 368 -> 0 bytes .../resources/layout/two_line_page_row.xml | 23 +++++++++----- .../android/base/resources/values/dimens.xml | 2 ++ .../android/base/resources/values/styles.xml | 5 +-- 7 files changed, 34 insertions(+), 25 deletions(-) delete mode 100644 mobile/android/base/resources/drawable-hdpi/ic_url_bar_star.png create mode 100644 mobile/android/base/resources/drawable-nodpi/bookmarked_star.png delete mode 100644 mobile/android/base/resources/drawable-xhdpi/ic_url_bar_star.png diff --git a/mobile/android/base/java/org/mozilla/gecko/home/TwoLinePageRow.java b/mobile/android/base/java/org/mozilla/gecko/home/TwoLinePageRow.java index 2dd10f669a8..794482b0950 100644 --- a/mobile/android/base/java/org/mozilla/gecko/home/TwoLinePageRow.java +++ b/mobile/android/base/java/org/mozilla/gecko/home/TwoLinePageRow.java @@ -25,6 +25,7 @@ import android.text.TextUtils; import android.util.AttributeSet; import android.view.Gravity; import android.view.LayoutInflater; +import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; @@ -35,9 +36,9 @@ public class TwoLinePageRow extends LinearLayout private final TextView mTitle; private final TextView mUrl; + private final ImageView mStatusIcon; private int mSwitchToTabIconId; - private int mPageTypeIconId; private final FaviconView mFavicon; @@ -90,11 +91,14 @@ public class TwoLinePageRow extends LinearLayout setGravity(Gravity.CENTER_VERTICAL); LayoutInflater.from(context).inflate(R.layout.two_line_page_row, this); + // Merge layouts lose their padding, so set it dynamically. + setPadding(0, 0, (int) getResources().getDimension(R.dimen.page_row_padding_right), 0); + mTitle = (TextView) findViewById(R.id.title); mUrl = (TextView) findViewById(R.id.url); + mStatusIcon = (ImageView) findViewById(R.id.status_icon_bookmark); mSwitchToTabIconId = NO_ICON; - mPageTypeIconId = NO_ICON; mShowIcons = true; mFavicon = (FaviconView) findViewById(R.id.icon); @@ -173,16 +177,12 @@ public class TwoLinePageRow extends LinearLayout } mSwitchToTabIconId = iconId; - mUrl.setCompoundDrawablesWithIntrinsicBounds(mSwitchToTabIconId, 0, mPageTypeIconId, 0); + mUrl.setCompoundDrawablesWithIntrinsicBounds(mSwitchToTabIconId, 0, 0, 0); } - private void setPageTypeIcon(int iconId) { - if (mPageTypeIconId == iconId) { - return; - } - - mPageTypeIconId = iconId; - mUrl.setCompoundDrawablesWithIntrinsicBounds(mSwitchToTabIconId, 0, mPageTypeIconId, 0); + private void showBookmarkIcon(boolean toShow) { + final int visibility = toShow ? VISIBLE : GONE; + mStatusIcon.setVisibility(visibility); } /** @@ -231,13 +231,10 @@ public class TwoLinePageRow extends LinearLayout if (mShowIcons) { // The bookmark id will be 0 (null in database) when the url // is not a bookmark. - if (bookmarkId == 0) { - setPageTypeIcon(NO_ICON); - } else { - setPageTypeIcon(R.drawable.ic_url_bar_star); - } + final boolean isBookmark = bookmarkId != 0; + showBookmarkIcon(isBookmark); } else { - setPageTypeIcon(NO_ICON); + showBookmarkIcon(false); } // Use the URL instead of an empty title for consistency with the normal URL diff --git a/mobile/android/base/resources/drawable-hdpi/ic_url_bar_star.png b/mobile/android/base/resources/drawable-hdpi/ic_url_bar_star.png deleted file mode 100644 index bf18ebeb035c34c5fd29a866987abced913c4c5b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 277 zcmV+w0qXvVP)v z8`5Y-hG9HIbDEy3=^SMXPv{VAvV{j>c(8?2Gzy_3N*UpW%cC3*igG*@%JI$-?xa2( z+7Z@L@azcBQolgs2pgn);q2t#9cfh2zMsrwzHr6B9_4H%M?JehRqk{{J*`DSx b`={#-Bm-;&WSC)<00000NkvXXu0mjfVm)z= diff --git a/mobile/android/base/resources/drawable-nodpi/bookmarked_star.png b/mobile/android/base/resources/drawable-nodpi/bookmarked_star.png new file mode 100644 index 0000000000000000000000000000000000000000..641a0e1b5dc2fe2049f3f8ed19576d8ae9602ed8 GIT binary patch literal 600 zcmV-e0;m0nP)ZNc?;%fijXSQwIwzqp;J3F4Y;v^aB-dBCeAGGha-!)*H z<*y5X_&gNff^wEbN}%)(Ph1kOT+&(OsQO3fkC<+s>{{C9FU6OTG!{C`g7~+ul!UBS zND8Fa`O5qW>9a^UOP`kp@y}pV5^^*}LQ%Xlq>zM9B4I3lSp=lNhn13W10)3Ec@YUo z_z2?4=6Bh#NY@APmq?`~3$0#I&OETiviCVaToVheeo#COr1wLyXFQ6-u9pgVbHmZ|8?G7YIv0oLvusN7hd9*KFPSh6k5PH!H%~n)4O@-uk?-3bU15Z>`b4~bEwXA!>4|qmI9H7^m6{ml$FE`$w+vjvd@_vG3K&7WDahz~ z2*o{Qs}qWaR%;Mn5AqwQO{KQ@l>_l?>R52K(9OlAqaV;8adr_WCpU+Vh5m!P6a;Z}bLu2iDWXrfg(8(` z%+sKO1103$9BA{>#@~$9cGn`-plzezoVb9QZE_u=Ca$VwlFNitU z2EhbEbtK=G^N5QA?;BzQ2V?n!;1X*ES8wYPAu%RmVpE>j7b#F1BP&F9OTVw- z%yk6!2>1kh9l?M&am!(k0NXN1vdgI@2SjdK4w(Z}r@2oYOvxduZ@T692sR<-m$@90 zM_oD8`rJ22p(}`5!71n(c*QQK;Lw2JkW+AEKybwV=lmuSr(mkM6=pXSw@=C?*L=`o za!AR_T8X**!TKhLpsd+wN=QY`v_@2N^}v+Khza4mQ0t&3LxyPl%D4hcAi8rS&gY&0 O0000 - + android:paddingRight="10dp" + android:orientation="vertical"> - + tools:drawableLeft="@drawable/ic_url_bar_tab"/> + + + diff --git a/mobile/android/base/resources/values/dimens.xml b/mobile/android/base/resources/values/dimens.xml index 63d6981bcd1..676138347c0 100644 --- a/mobile/android/base/resources/values/dimens.xml +++ b/mobile/android/base/resources/values/dimens.xml @@ -79,6 +79,8 @@ 1dp -1dp + 15dp + 64dp diff --git a/mobile/android/base/resources/values/styles.xml b/mobile/android/base/resources/values/styles.xml index 6d4522ed4a9..bb6fce1d7dc 100644 --- a/mobile/android/base/resources/values/styles.xml +++ b/mobile/android/base/resources/values/styles.xml @@ -126,7 +126,6 @@ @style/TextAppearance.Widget.Home.ItemDescription false true - middle - + + + +

+

+

+

+

+ +
+
+
+
+
+ + + diff --git a/layout/reftests/css-break/box-decoration-break-bug-1249913.html b/layout/reftests/css-break/box-decoration-break-bug-1249913.html new file mode 100644 index 00000000000..67b5c753fdb --- /dev/null +++ b/layout/reftests/css-break/box-decoration-break-bug-1249913.html @@ -0,0 +1,55 @@ + + + + + 'box-decoration-break' with child overflow + + + + + + + +

+

+

+

+

+ +

+

+

+

+

+ + + diff --git a/layout/reftests/css-break/reftest.list b/layout/reftests/css-break/reftest.list index 730bc4dc908..47043bb7f88 100644 --- a/layout/reftests/css-break/reftest.list +++ b/layout/reftests/css-break/reftest.list @@ -9,3 +9,4 @@ random-if(!gtkWidget) HTTP(..) == box-decoration-break-border-image.html box-dec fuzzy-if(!Android,1,5) fuzzy-if(Android,8,6627) fuzzy-if(skiaContent,1,24) == box-decoration-break-first-letter.html box-decoration-break-first-letter-ref.html == box-decoration-break-with-bidi.html box-decoration-break-with-bidi-ref.html == box-decoration-break-bug-1235152.html box-decoration-break-bug-1235152-ref.html +!= box-decoration-break-bug-1249913.html box-decoration-break-bug-1249913-ref.html From fc6d9d52089763f1310e51b648b08b8ecf1fb6fa Mon Sep 17 00:00:00 2001 From: Mats Palmgren Date: Wed, 2 Mar 2016 23:39:34 +0100 Subject: [PATCH 115/160] Bug 1249913 - True overflow containers shouldn't have borders or background. r=dholbert --- layout/base/nsCSSRendering.cpp | 7 +++++-- layout/generic/nsFrame.cpp | 3 ++- layout/reftests/css-break/reftest.list | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/layout/base/nsCSSRendering.cpp b/layout/base/nsCSSRendering.cpp index c6cd21d0d7d..a1920c1d037 100644 --- a/layout/base/nsCSSRendering.cpp +++ b/layout/base/nsCSSRendering.cpp @@ -755,10 +755,13 @@ nsCSSRendering::PaintBorderWithStyleBorder(nsPresContext* aPresContext, } else { MOZ_ASSERT(joinedBorderArea.IsEqualEdges(aBorderArea), "Should use aBorderArea for box-decoration-break:clone"); - MOZ_ASSERT(aForFrame->GetSkipSides().IsEmpty(), + MOZ_ASSERT(aForFrame->GetSkipSides().IsEmpty() || + IS_TRUE_OVERFLOW_CONTAINER(aForFrame), "Should not skip sides for box-decoration-break:clone except " "::first-letter/line continuations or other frame types that " - "don't have borders but those shouldn't reach this point."); + "don't have borders but those shouldn't reach this point. " + "Overflow containers do reach this point though."); + border.ApplySkipSides(aSkipSides); } // Convert to dev pixels. diff --git a/layout/generic/nsFrame.cpp b/layout/generic/nsFrame.cpp index cadcb091adc..eb9f38da4cf 100644 --- a/layout/generic/nsFrame.cpp +++ b/layout/generic/nsFrame.cpp @@ -1024,7 +1024,8 @@ nsIFrame::Sides nsIFrame::GetSkipSides(const nsHTMLReflowState* aReflowState) const { if (MOZ_UNLIKELY(StyleBorder()->mBoxDecorationBreak == - NS_STYLE_BOX_DECORATION_BREAK_CLONE)) { + NS_STYLE_BOX_DECORATION_BREAK_CLONE) && + !(GetStateBits() & NS_FRAME_IS_OVERFLOW_CONTAINER)) { return Sides(); } diff --git a/layout/reftests/css-break/reftest.list b/layout/reftests/css-break/reftest.list index 47043bb7f88..e51a50a28fa 100644 --- a/layout/reftests/css-break/reftest.list +++ b/layout/reftests/css-break/reftest.list @@ -9,4 +9,4 @@ random-if(!gtkWidget) HTTP(..) == box-decoration-break-border-image.html box-dec fuzzy-if(!Android,1,5) fuzzy-if(Android,8,6627) fuzzy-if(skiaContent,1,24) == box-decoration-break-first-letter.html box-decoration-break-first-letter-ref.html == box-decoration-break-with-bidi.html box-decoration-break-with-bidi-ref.html == box-decoration-break-bug-1235152.html box-decoration-break-bug-1235152-ref.html -!= box-decoration-break-bug-1249913.html box-decoration-break-bug-1249913-ref.html +== box-decoration-break-bug-1249913.html box-decoration-break-bug-1249913-ref.html From 67a8925e73c3bfb9d7cd2e5be1b0bbf37cdb45cd Mon Sep 17 00:00:00 2001 From: Mats Palmgren Date: Wed, 2 Mar 2016 23:39:34 +0100 Subject: [PATCH 116/160] Bug 1250315 - Make match :-moz-read-only and allow context events. r=jwatt --- dom/events/EventStateManager.cpp | 2 +- dom/html/nsGenericHTMLElement.cpp | 2 +- dom/html/nsIFormControl.h | 15 +++++++- .../forms/input/number/pseudo-classes.html | 37 +++++++++++++++++++ .../reftests/forms/input/number/reftest.list | 1 + 5 files changed, 54 insertions(+), 3 deletions(-) create mode 100644 layout/reftests/forms/input/number/pseudo-classes.html diff --git a/dom/events/EventStateManager.cpp b/dom/events/EventStateManager.cpp index a7f47917a85..895e1b0893d 100644 --- a/dom/events/EventStateManager.cpp +++ b/dom/events/EventStateManager.cpp @@ -1510,7 +1510,7 @@ EventStateManager::FireContextClick() nsCOMPtr formCtrl(do_QueryInterface(mGestureDownContent)); if (formCtrl) { - allowedToDispatch = formCtrl->IsTextControl(false) || + allowedToDispatch = formCtrl->IsTextOrNumberControl(/*aExcludePassword*/ false) || formCtrl->GetType() == NS_FORM_INPUT_FILE; } else if (mGestureDownContent->IsAnyOfHTMLElements(nsGkAtoms::applet, diff --git a/dom/html/nsGenericHTMLElement.cpp b/dom/html/nsGenericHTMLElement.cpp index 99c897d8ac7..eb1098a76fa 100644 --- a/dom/html/nsGenericHTMLElement.cpp +++ b/dom/html/nsGenericHTMLElement.cpp @@ -2371,7 +2371,7 @@ nsGenericHTMLFormElement::IntrinsicState() const // Make the text controls read-write if (!state.HasState(NS_EVENT_STATE_MOZ_READWRITE) && - IsTextControl(false)) { + IsTextOrNumberControl(/*aExcludePassword*/ false)) { bool roState = GetBoolAttr(nsGkAtoms::readonly); if (!roState) { diff --git a/dom/html/nsIFormControl.h b/dom/html/nsIFormControl.h index 4c151506147..f64e193b057 100644 --- a/dom/html/nsIFormControl.h +++ b/dom/html/nsIFormControl.h @@ -176,7 +176,14 @@ public: * @param aExcludePassword to have NS_FORM_INPUT_PASSWORD returning false. * @return whether this is a text control. */ - inline bool IsTextControl(bool aExcludePassword) const ; + inline bool IsTextControl(bool aExcludePassword) const; + + /** + * Returns true if this is a text control or a number control. + * @param aExcludePassword to have NS_FORM_INPUT_PASSWORD returning false. + * @return true if this is a text control or a number control. + */ + inline bool IsTextOrNumberControl(bool aExcludePassword) const; /** * Returns whether this is a single line text control. @@ -235,6 +242,12 @@ nsIFormControl::IsTextControl(bool aExcludePassword) const IsSingleLineTextControl(aExcludePassword, type); } +bool +nsIFormControl::IsTextOrNumberControl(bool aExcludePassword) const +{ + return IsTextControl(aExcludePassword) || GetType() == NS_FORM_INPUT_NUMBER; +} + bool nsIFormControl::IsSingleLineTextControl(bool aExcludePassword) const { diff --git a/layout/reftests/forms/input/number/pseudo-classes.html b/layout/reftests/forms/input/number/pseudo-classes.html new file mode 100644 index 00000000000..a0c62f72113 --- /dev/null +++ b/layout/reftests/forms/input/number/pseudo-classes.html @@ -0,0 +1,37 @@ + + + + + Test pseudo-classes on number controls + + + + + + + + + + + + + + diff --git a/layout/reftests/forms/input/number/reftest.list b/layout/reftests/forms/input/number/reftest.list index ca7ee72901d..dbc5381bc4b 100644 --- a/layout/reftests/forms/input/number/reftest.list +++ b/layout/reftests/forms/input/number/reftest.list @@ -51,3 +51,4 @@ skip-if(B2G||Mulet) fuzzy-if(skiaContent,2,5) needs-focus == focus-handling.html # bevel which gets slightly different antialiasing after invalidation): fuzzy(128,4) == number-reframe-anon-text-field.html number-reframe-anon-text-field-ref.html +== pseudo-classes.html about:blank From 140f20fcac1f4b4b702edb1996e0ccfdaeeb72f5 Mon Sep 17 00:00:00 2001 From: Mats Palmgren Date: Wed, 2 Mar 2016 23:39:34 +0100 Subject: [PATCH 117/160] Bug 1251999 - [css-grid] Update parsing to the latest spec. r=dholbert --- layout/generic/nsGridContainerFrame.cpp | 5 ++-- layout/style/nsCSSParser.cpp | 36 ++++++++++++++----------- layout/style/nsCSSValue.h | 2 ++ 3 files changed, 24 insertions(+), 19 deletions(-) diff --git a/layout/generic/nsGridContainerFrame.cpp b/layout/generic/nsGridContainerFrame.cpp index 907343c61a2..a113871cdfc 100644 --- a/layout/generic/nsGridContainerFrame.cpp +++ b/layout/generic/nsGridContainerFrame.cpp @@ -425,9 +425,8 @@ struct MOZ_STACK_CLASS nsGridContainerFrame::TrackSizingFunctions // Note that the repeat() track size is included in |sum| in this loop. nscoord sum = 0; for (uint32_t i = 0; i < numTracks; ++i) { - // "The variant ... requires definite minimum track sizes" - // "... treating each track as its max track sizing function if that is - // definite or as its minimum track sizing function otherwise" + // "treating each track as its max track sizing function if that is + // definite or as its minimum track sizing function otherwise" // https://drafts.csswg.org/css-grid/#valdef-repeat-auto-fill const auto& maxCoord = mMaxSizingFunctions[i]; const auto* coord = &maxCoord; diff --git a/layout/style/nsCSSParser.cpp b/layout/style/nsCSSParser.cpp index 681f47aefea..3256fe86a52 100644 --- a/layout/style/nsCSSParser.cpp +++ b/layout/style/nsCSSParser.cpp @@ -946,9 +946,7 @@ protected: bool ParseGridLineNameListRepeat(nsCSSValueList** aTailPtr); bool ParseOptionalLineNameListAfterSubgrid(nsCSSValue& aValue); - // eFixedTrackSize in aFlags makes it parse a . - CSSParseResult ParseGridTrackBreadth(nsCSSValue& aValue, - GridTrackSizeFlags aFlags = GridTrackSizeFlags::eDefaultTrackSize); + CSSParseResult ParseGridTrackBreadth(nsCSSValue& aValue); // eFixedTrackSize in aFlags makes it parse a . CSSParseResult ParseGridTrackSize(nsCSSValue& aValue, GridTrackSizeFlags aFlags = GridTrackSizeFlags::eDefaultTrackSize); @@ -8575,20 +8573,15 @@ CSSParserImpl::ParseOptionalLineNameListAfterSubgrid(nsCSSValue& aValue) } } -// Parse a , or when aFlags has eFixedTrackSize. CSSParseResult -CSSParserImpl::ParseGridTrackBreadth(nsCSSValue& aValue, - GridTrackSizeFlags aFlags) +CSSParserImpl::ParseGridTrackBreadth(nsCSSValue& aValue) { - CSSParseResult result = (aFlags & GridTrackSizeFlags::eFixedTrackSize) ? - ParseNonNegativeVariant(aValue, VARIANT_LPCALC, nullptr) : - ParseNonNegativeVariant(aValue, - VARIANT_AUTO | VARIANT_LPCALC | VARIANT_KEYWORD, - nsCSSProps::kGridTrackBreadthKTable); + CSSParseResult result = ParseNonNegativeVariant(aValue, + VARIANT_AUTO | VARIANT_LPCALC | VARIANT_KEYWORD, + nsCSSProps::kGridTrackBreadthKTable); if (result == CSSParseResult::Ok || - result == CSSParseResult::Error || - (aFlags & GridTrackSizeFlags::eFixedTrackSize)) { + result == CSSParseResult::Error) { return result; } @@ -8611,8 +8604,14 @@ CSSParseResult CSSParserImpl::ParseGridTrackSize(nsCSSValue& aValue, GridTrackSizeFlags aFlags) { + const bool requireFixedSize = + !!(aFlags & GridTrackSizeFlags::eFixedTrackSize); // Attempt to parse a single . - CSSParseResult result = ParseGridTrackBreadth(aValue, aFlags); + CSSParseResult result = ParseGridTrackBreadth(aValue); + if (requireFixedSize && result == CSSParseResult::Ok && + !aValue.IsLengthPercentCalcUnit()) { + result = CSSParseResult::Error; + } if (result == CSSParseResult::Ok || result == CSSParseResult::Error) { return result; @@ -8628,10 +8627,15 @@ CSSParserImpl::ParseGridTrackSize(nsCSSValue& aValue, return CSSParseResult::NotFound; } nsCSSValue::Array* func = aValue.InitFunction(eCSSKeyword_minmax, 2); - if (ParseGridTrackBreadth(func->Item(1), aFlags) == CSSParseResult::Ok && + if (ParseGridTrackBreadth(func->Item(1)) == CSSParseResult::Ok && ExpectSymbol(',', true) && - ParseGridTrackBreadth(func->Item(2), aFlags) == CSSParseResult::Ok && + ParseGridTrackBreadth(func->Item(2)) == CSSParseResult::Ok && ExpectSymbol(')', true)) { + if (requireFixedSize && + !func->Item(1).IsLengthPercentCalcUnit() && + !func->Item(2).IsLengthPercentCalcUnit()) { + return CSSParseResult::Error; + } return CSSParseResult::Ok; } SkipUntil(')'); diff --git a/layout/style/nsCSSValue.h b/layout/style/nsCSSValue.h index cecff6ad98d..a82a15ce8f5 100644 --- a/layout/style/nsCSSValue.h +++ b/layout/style/nsCSSValue.h @@ -446,6 +446,8 @@ public: nsCSSUnit GetUnit() const { return mUnit; } bool IsLengthUnit() const { return eCSSUnit_PhysicalMillimeter <= mUnit && mUnit <= eCSSUnit_Pixel; } + bool IsLengthPercentCalcUnit() const + { return IsLengthUnit() || mUnit == eCSSUnit_Percent || IsCalcUnit(); } /** * A "fixed" length unit is one that means a specific physical length * which we try to match based on the physical characteristics of an From 83ffd89a81a237c6e003c61bbeaaa795112e0f80 Mon Sep 17 00:00:00 2001 From: Mats Palmgren Date: Wed, 2 Mar 2016 23:39:34 +0100 Subject: [PATCH 118/160] Bug 1251999 - [css-grid] Reftests for repeat(auto-fill/fit, ) where has one or more intrinsic sizing functions (one is allowed). --- .../grid-repeat-auto-fill-fit-001.html | 2 +- .../grid-repeat-auto-fill-fit-009-ref.html | 131 ++++++++++++++++++ .../grid-repeat-auto-fill-fit-009.html | 117 ++++++++++++++++ layout/reftests/css-grid/reftest.list | 1 + layout/style/test/property_database.js | 9 +- 5 files changed, 257 insertions(+), 3 deletions(-) create mode 100644 layout/reftests/css-grid/grid-repeat-auto-fill-fit-009-ref.html create mode 100644 layout/reftests/css-grid/grid-repeat-auto-fill-fit-009.html diff --git a/layout/reftests/css-grid/grid-repeat-auto-fill-fit-001.html b/layout/reftests/css-grid/grid-repeat-auto-fill-fit-001.html index 35f338c78d5..454c7863072 100644 --- a/layout/reftests/css-grid/grid-repeat-auto-fill-fit-001.html +++ b/layout/reftests/css-grid/grid-repeat-auto-fill-fit-001.html @@ -24,7 +24,7 @@ html,body { padding-right: 3px; } .r1 { grid-template-columns: [a] repeat(auto-fill, [b] 20px [c]) [d]; } -.r2 { grid-template-columns: [a] repeat(auto-fill, [b] 20px [c]) [d] 30px [e]; } +.r2 { grid-template-columns: [a] repeat(auto-fill, [b] minmax(20px,20px) [c]) [d] 30px [e]; } .r3 { grid-template-columns: [a] repeat(auto-fill, [b] 20px [c]) [d] 30px [e] 30px [f]; } fit .r1 { grid-template-columns: [a] repeat(auto-fit, [b] 20px [c]) [d]; } fit .r2 { grid-template-columns: [a] repeat(auto-fit, [b] 20px [c]) [d] 30px [e]; } diff --git a/layout/reftests/css-grid/grid-repeat-auto-fill-fit-009-ref.html b/layout/reftests/css-grid/grid-repeat-auto-fill-fit-009-ref.html new file mode 100644 index 00000000000..e475d4921fd --- /dev/null +++ b/layout/reftests/css-grid/grid-repeat-auto-fill-fit-009-ref.html @@ -0,0 +1,131 @@ + + + + + Reference: repeat(auto-fill/auto-fit) with intrinsic min- or max-sizing function + + + + + + + +
+
+
+
+
+
+
+
+ +
+ +
+
+
+
+
+
+
+
+ +
+ + + +
+
+
+
+
+
+
+
+ +
+ +
+
+
+
+
+
+
+
+ +
+ + + + diff --git a/layout/reftests/css-grid/grid-repeat-auto-fill-fit-009.html b/layout/reftests/css-grid/grid-repeat-auto-fill-fit-009.html new file mode 100644 index 00000000000..5a56a8f6c02 --- /dev/null +++ b/layout/reftests/css-grid/grid-repeat-auto-fill-fit-009.html @@ -0,0 +1,117 @@ + + + + + CSS Grid Test: repeat(auto-fill/auto-fit) with intrinsic min- or max-sizing function + + + + + + + + + +
+
+
+
+
+
+
+
+ +
+ +
+
+
+
+
+
+
+
+ +
+ + + +
+
+
+
+
+
+
+
+ +
+ +
+
+
+
+
+
+
+
+ +
+ + + + diff --git a/layout/reftests/css-grid/reftest.list b/layout/reftests/css-grid/reftest.list index a6cf942f954..5bb7650ed9b 100644 --- a/layout/reftests/css-grid/reftest.list +++ b/layout/reftests/css-grid/reftest.list @@ -110,3 +110,4 @@ skip-if(Android&&isDebugBuild) == grid-row-gap-004.html grid-row-gap-004-ref.htm == grid-repeat-auto-fill-fit-006.html grid-repeat-auto-fill-fit-006-ref.html == grid-repeat-auto-fill-fit-007.html grid-repeat-auto-fill-fit-007-ref.html == grid-repeat-auto-fill-fit-008.html grid-repeat-auto-fill-fit-008-ref.html +== grid-repeat-auto-fill-fit-009.html grid-repeat-auto-fill-fit-009-ref.html diff --git a/layout/style/test/property_database.js b/layout/style/test/property_database.js index 61de93e7b78..f7d894a1b60 100644 --- a/layout/style/test/property_database.js +++ b/layout/style/test/property_database.js @@ -5987,6 +5987,10 @@ if (IsCSSPropertyPrefEnabled("layout.css.grid.enabled")) { "[a] repeat( auto-fit,[a b] minmax(0,0) )", "[a] 40px repeat(auto-fit,[a b] minmax(1px, 0) [])", "[a] auto [b] repeat(auto-fit,[a b] minmax(1mm, 1%) [c]) [c] auto", + "repeat(auto-fill,minmax(1%,auto))", + "repeat(auto-fill,minmax(1em,min-content))", + "repeat(auto-fill,minmax(1fr,1em))", + "repeat(auto-fill,minmax(max-content,1mm))", ], invalid_values: [ "", @@ -6036,9 +6040,10 @@ if (IsCSSPropertyPrefEnabled("layout.css.grid.enabled")) { "repeat(auto-fill, 0 [] 0)", "repeat(auto-fill, min-content)", "repeat(auto-fit,max-content)", + "repeat(auto-fit,1fr)", "repeat(auto-fit,minmax(auto,auto))", - "repeat(auto-fit,[] minmax(1px, min-content))", - "repeat(auto-fit,[a] minmax(1%, auto) [])", + "repeat(auto-fit,minmax(min-content,1fr))", + "repeat(auto-fit,minmax(1fr,auto))", ], unbalanced_values: [ "(foo] 40px", From f5d82ed6c6df77d5d0d0878a4e8fec5a38c30b05 Mon Sep 17 00:00:00 2001 From: Mats Palmgren Date: Wed, 2 Mar 2016 23:39:34 +0100 Subject: [PATCH 119/160] Bug 1225005 - Clamp negative values in containing block size. r=roc --- layout/generic/crashtests/1225005.html | 4 ++++ layout/generic/crashtests/crashtests.list | 1 + layout/generic/nsFrame.cpp | 7 ++----- 3 files changed, 7 insertions(+), 5 deletions(-) create mode 100644 layout/generic/crashtests/1225005.html diff --git a/layout/generic/crashtests/1225005.html b/layout/generic/crashtests/1225005.html new file mode 100644 index 00000000000..8c2164df2ac --- /dev/null +++ b/layout/generic/crashtests/1225005.html @@ -0,0 +1,4 @@ + + +
+ diff --git a/layout/generic/crashtests/crashtests.list b/layout/generic/crashtests/crashtests.list index e7e7a146003..b23e75492d9 100644 --- a/layout/generic/crashtests/crashtests.list +++ b/layout/generic/crashtests/crashtests.list @@ -618,3 +618,4 @@ load text-overflow-bug671796.xhtml load text-overflow-bug713610.html load text-overflow-form-elements.html load text-overflow-iframe.html +asserts(4) load 1225005.html # bug 682647 and bug 448083 diff --git a/layout/generic/nsFrame.cpp b/layout/generic/nsFrame.cpp index eb9f38da4cf..40d93aedbff 100644 --- a/layout/generic/nsFrame.cpp +++ b/layout/generic/nsFrame.cpp @@ -4629,12 +4629,9 @@ nsFrame::ReflowAbsoluteFrames(nsPresContext* aPresContext, // The containing block for the abs pos kids is formed by our padding edge. nsMargin usedBorder = GetUsedBorder(); nscoord containingBlockWidth = - aDesiredSize.Width() - usedBorder.LeftRight(); - MOZ_ASSERT(containingBlockWidth >= 0); + std::max(0, aDesiredSize.Width() - usedBorder.LeftRight()); nscoord containingBlockHeight = - aDesiredSize.Height() - usedBorder.TopBottom(); - MOZ_ASSERT(containingBlockHeight >= 0); - + std::max(0, aDesiredSize.Height() - usedBorder.TopBottom()); nsContainerFrame* container = do_QueryFrame(this); NS_ASSERTION(container, "Abs-pos children only supported on container frames for now"); From 20a0f65be531cb95c931597d87f240f3e8d43493 Mon Sep 17 00:00:00 2001 From: Tooru Fujisawa Date: Thu, 3 Mar 2016 08:03:40 +0900 Subject: [PATCH 120/160] Bug 1245112 - Part 18 followup: More refactor branchTestInt32. r=nbp --- js/src/jit/MacroAssembler.h | 28 +++++++++---- js/src/jit/arm/MacroAssembler-arm-inl.h | 16 ++++++-- js/src/jit/arm/MacroAssembler-arm.h | 5 --- js/src/jit/arm64/MacroAssembler-arm64-inl.h | 16 ++++++-- js/src/jit/arm64/MacroAssembler-arm64.h | 5 --- .../MacroAssembler-mips-shared-inl.h | 12 +++--- js/src/jit/mips32/MacroAssembler-mips32-inl.h | 9 ++--- js/src/jit/mips64/MacroAssembler-mips64-inl.h | 11 +++--- js/src/jit/x64/MacroAssembler-x64-inl.h | 39 +++---------------- js/src/jit/x64/MacroAssembler-x64.h | 15 +++---- .../MacroAssembler-x86-shared-inl.h | 36 ++++++++++++++++- js/src/jit/x86/MacroAssembler-x86-inl.h | 24 ------------ js/src/jit/x86/MacroAssembler-x86.h | 5 --- 13 files changed, 104 insertions(+), 117 deletions(-) diff --git a/js/src/jit/MacroAssembler.h b/js/src/jit/MacroAssembler.h index c5290cc34c2..3e6961a43d6 100644 --- a/js/src/jit/MacroAssembler.h +++ b/js/src/jit/MacroAssembler.h @@ -921,17 +921,29 @@ class MacroAssembler : public MacroAssemblerSpecific inline void branchTestNeedsIncrementalBarrier(Condition cond, Label* label); - inline void branchTestInt32(Condition cond, Register tag, Label* label) - DEFINED_ON(arm, arm64, mips_shared, x86, x64); - inline void branchTestInt32(Condition cond, const Address& address, Label* label) - DEFINED_ON(arm, arm64, mips_shared, x86, x64); - inline void branchTestInt32(Condition cond, const BaseIndex& address, Label* label) - DEFINED_ON(arm, arm64, mips_shared, x86, x64); - inline void branchTestInt32(Condition cond, const ValueOperand& src, Label* label) PER_ARCH; + // Perform a type-test on a tag of a Value (32bits boxing), or the tagged + // value (64bits boxing). + inline void branchTestInt32(Condition cond, Register tag, Label* label) PER_SHARED_ARCH; - inline void branchTestInt32Truthy(bool truthy, const ValueOperand& operand, Label* label) + // Perform a type-test on a Value, addressed by Address or BaseIndex, or + // loaded into ValueOperand. + inline void branchTestInt32(Condition cond, const Address& address, Label* label) PER_SHARED_ARCH; + inline void branchTestInt32(Condition cond, const BaseIndex& address, Label* label) PER_SHARED_ARCH; + inline void branchTestInt32(Condition cond, const ValueOperand& value, Label* label) DEFINED_ON(arm, arm64, mips32, mips64, x86_shared); + // Checks if given Value is evaluated to true or false in a condition. + // The type of the value should match the type of the method. + inline void branchTestInt32Truthy(bool truthy, const ValueOperand& value, Label* label) + DEFINED_ON(arm, arm64, mips32, mips64, x86_shared); + + private: + + // Implementation for branchTest* methods. + template + inline void branchTestInt32Impl(Condition cond, const T& t, Label* label) + DEFINED_ON(arm, arm64, x86_shared); + //}}} check_macroassembler_style public: diff --git a/js/src/jit/arm/MacroAssembler-arm-inl.h b/js/src/jit/arm/MacroAssembler-arm-inl.h index 3084c716300..f364b7d3fdb 100644 --- a/js/src/jit/arm/MacroAssembler-arm-inl.h +++ b/js/src/jit/arm/MacroAssembler-arm-inl.h @@ -818,15 +818,23 @@ MacroAssembler::branchTestInt32(Condition cond, const BaseIndex& address, Label* } void -MacroAssembler::branchTestInt32(Condition cond, const ValueOperand& src, Label* label) +MacroAssembler::branchTestInt32(Condition cond, const ValueOperand& value, Label* label) { - branchTestInt32Impl(cond, src, label); + branchTestInt32Impl(cond, value, label); +} + +template +void +MacroAssembler::branchTestInt32Impl(Condition cond, const T& t, Label* label) +{ + Condition c = testInt32(cond, t); + ma_b(label, c); } void -MacroAssembler::branchTestInt32Truthy(bool truthy, const ValueOperand& operand, Label* label) +MacroAssembler::branchTestInt32Truthy(bool truthy, const ValueOperand& value, Label* label) { - Condition c = testInt32Truthy(truthy, operand); + Condition c = testInt32Truthy(truthy, value); ma_b(label, c); } diff --git a/js/src/jit/arm/MacroAssembler-arm.h b/js/src/jit/arm/MacroAssembler-arm.h index 92405f1a018..4991c1ffca3 100644 --- a/js/src/jit/arm/MacroAssembler-arm.h +++ b/js/src/jit/arm/MacroAssembler-arm.h @@ -762,11 +762,6 @@ class MacroAssemblerARMCompat : public MacroAssemblerARM void int32ValueToFloat32(const ValueOperand& operand, FloatRegister dest); void loadConstantFloat32(float f, FloatRegister dest); - template - void branchTestInt32Impl(Condition cond, const T & t, Label* label) { - Condition c = testInt32(cond, t); - ma_b(label, c); - } template void branchTestBoolean(Condition cond, const T & t, Label* label) { Condition c = testBoolean(cond, t); diff --git a/js/src/jit/arm64/MacroAssembler-arm64-inl.h b/js/src/jit/arm64/MacroAssembler-arm64-inl.h index 065faaca1aa..6e9673a6e5d 100644 --- a/js/src/jit/arm64/MacroAssembler-arm64-inl.h +++ b/js/src/jit/arm64/MacroAssembler-arm64-inl.h @@ -905,15 +905,23 @@ MacroAssembler::branchTestInt32(Condition cond, const BaseIndex& address, Label* } void -MacroAssembler::branchTestInt32(Condition cond, const ValueOperand& src, Label* label) +MacroAssembler::branchTestInt32(Condition cond, const ValueOperand& value, Label* label) { - branchTestInt32Impl(cond, src, label); + branchTestInt32Impl(cond, value, label); +} + +template +void +MacroAssembler::branchTestInt32Impl(Condition cond, const T& t, Label* label) +{ + Condition c = testInt32(cond, t); + B(label, c); } void -MacroAssembler::branchTestInt32Truthy(bool truthy, const ValueOperand& operand, Label* label) +MacroAssembler::branchTestInt32Truthy(bool truthy, const ValueOperand& value, Label* label) { - Condition c = testInt32Truthy(truthy, operand); + Condition c = testInt32Truthy(truthy, value); B(label, c); } diff --git a/js/src/jit/arm64/MacroAssembler-arm64.h b/js/src/jit/arm64/MacroAssembler-arm64.h index b0b90f0e4a2..67989cd7dd8 100644 --- a/js/src/jit/arm64/MacroAssembler-arm64.h +++ b/js/src/jit/arm64/MacroAssembler-arm64.h @@ -1333,11 +1333,6 @@ class MacroAssemblerCompat : public vixl::MacroAssembler B(label, c); } - template - void branchTestInt32Impl(Condition cond, T& t, Label* label) { - Condition c = testInt32(cond, t); - B(label, c); - } void branchTestDouble(Condition cond, Register tag, Label* label) { Condition c = testDouble(cond, tag); B(label, c); diff --git a/js/src/jit/mips-shared/MacroAssembler-mips-shared-inl.h b/js/src/jit/mips-shared/MacroAssembler-mips-shared-inl.h index 944511cc0f7..be0ac3e346f 100644 --- a/js/src/jit/mips-shared/MacroAssembler-mips-shared-inl.h +++ b/js/src/jit/mips-shared/MacroAssembler-mips-shared-inl.h @@ -519,17 +519,17 @@ MacroAssembler::branchTestInt32(Condition cond, Register tag, Label* label) void MacroAssembler::branchTestInt32(Condition cond, const Address& address, Label* label) { - MOZ_ASSERT(cond == Equal || cond == NotEqual); - extractTag(address, SecondScratchReg); - ma_b(SecondScratchReg, ImmTag(JSVAL_TAG_INT32), label, cond); + SecondScratchRegisterScope scratch2(*this); + extractTag(address, scratch2); + branchTestInt32(cond, scratch2, label); } void MacroAssembler::branchTestInt32(Condition cond, const BaseIndex& address, Label* label) { - MOZ_ASSERT(cond == Equal || cond == NotEqual); - extractTag(address, SecondScratchReg); - ma_b(SecondScratchReg, ImmTag(JSVAL_TAG_INT32), label, cond); + SecondScratchRegisterScope scratch2(*this); + extractTag(address, scratch2); + branchTestInt32(cond, scratch2, label); } //}}} check_macroassembler_style diff --git a/js/src/jit/mips32/MacroAssembler-mips32-inl.h b/js/src/jit/mips32/MacroAssembler-mips32-inl.h index 97a0c9c9a11..736abdf5f1e 100644 --- a/js/src/jit/mips32/MacroAssembler-mips32-inl.h +++ b/js/src/jit/mips32/MacroAssembler-mips32-inl.h @@ -291,16 +291,15 @@ MacroAssembler::branchTest64(Condition cond, Register64 lhs, Register64 rhs, Reg void MacroAssembler::branchTestInt32(Condition cond, const ValueOperand& value, Label* label) { - MOZ_ASSERT(cond == Equal || cond == NotEqual); - ma_b(value.typeReg(), ImmType(JSVAL_TYPE_INT32), label, cond); + branchTestInt32(cond, value.typeReg(), label); } - void MacroAssembler::branchTestInt32Truthy(bool b, const ValueOperand& value, Label* label) { - as_and(ScratchRegister, value.payloadReg(), value.payloadReg()); - ma_b(ScratchRegister, ScratchRegister, label, b ? NonZero : Zero); + ScratchRegisterScope scratch(*this); + as_and(scratch, value.payloadReg(), value.payloadReg()); + ma_b(scratch, scratch, label, b ? NonZero : Zero); } //}}} check_macroassembler_style diff --git a/js/src/jit/mips64/MacroAssembler-mips64-inl.h b/js/src/jit/mips64/MacroAssembler-mips64-inl.h index 95cbabc0bda..eaae7cdc9d4 100644 --- a/js/src/jit/mips64/MacroAssembler-mips64-inl.h +++ b/js/src/jit/mips64/MacroAssembler-mips64-inl.h @@ -227,16 +227,17 @@ MacroAssembler::branchTest64(Condition cond, Register64 lhs, Register64 rhs, Reg void MacroAssembler::branchTestInt32(Condition cond, const ValueOperand& value, Label* label) { - MOZ_ASSERT(cond == Equal || cond == NotEqual); - splitTag(value, SecondScratchReg); - ma_b(SecondScratchReg, ImmTag(JSVAL_TAG_INT32), label, cond); + SecondScratchRegisterScope scratch2(*this); + splitTag(value, scratch2); + branchTestInt32(cond, scratch2, label); } void MacroAssembler::branchTestInt32Truthy(bool b, const ValueOperand& value, Label* label) { - ma_dext(ScratchRegister, value.valueReg(), Imm32(0), Imm32(32)); - ma_b(ScratchRegister, ScratchRegister, label, b ? NonZero : Zero); + ScratchRegisterScope scratch(*this); + ma_dext(scratch, value.valueReg(), Imm32(0), Imm32(32)); + ma_b(scratch, scratch, label, b ? NonZero : Zero); } //}}} check_macroassembler_style diff --git a/js/src/jit/x64/MacroAssembler-x64-inl.h b/js/src/jit/x64/MacroAssembler-x64-inl.h index 41bb2c563c4..1c100b09c6a 100644 --- a/js/src/jit/x64/MacroAssembler-x64-inl.h +++ b/js/src/jit/x64/MacroAssembler-x64-inl.h @@ -398,36 +398,6 @@ MacroAssembler::branchTest64(Condition cond, Register64 lhs, Register64 rhs, Reg branchTestPtr(cond, lhs.reg, rhs.reg, label); } -void -MacroAssembler::branchTestInt32(Condition cond, Register tag, Label* label) -{ - cond = testInt32(cond, tag); - j(cond, label); -} - -void -MacroAssembler::branchTestInt32(Condition cond, const Address& address, Label* label) -{ - MOZ_ASSERT(cond == Equal || cond == NotEqual); - branchTestInt32Impl(cond, Operand(address), label); -} - -void -MacroAssembler::branchTestInt32(Condition cond, const BaseIndex& address, Label* label) -{ - ScratchRegisterScope scratch(*this); - splitTag(address, scratch); - branchTestInt32(cond, scratch, label); -} - -void -MacroAssembler::branchTestInt32(Condition cond, const ValueOperand& src, Label* label) -{ - ScratchRegisterScope scratch(*this); - splitTag(src, scratch); - branchTestInt32(cond, scratch, label); -} - //}}} check_macroassembler_style // =============================================================== @@ -469,15 +439,16 @@ MacroAssemblerX64::unboxValue(const ValueOperand& src, AnyRegister dest) } } +template void -MacroAssemblerX64::loadInt32OrDouble(const Operand& operand, FloatRegister dest) +MacroAssemblerX64::loadInt32OrDouble(const T& src, FloatRegister dest) { Label notInt32, end; - branchTestInt32Impl(Assembler::NotEqual, operand, ¬Int32); - convertInt32ToDouble(operand, dest); + asMasm().branchTestInt32(Assembler::NotEqual, src, ¬Int32); + convertInt32ToDouble(src, dest); jump(&end); bind(¬Int32); - loadDouble(operand, dest); + loadDouble(src, dest); bind(&end); } diff --git a/js/src/jit/x64/MacroAssembler-x64.h b/js/src/jit/x64/MacroAssembler-x64.h index 0dc4e826830..25172138bfb 100644 --- a/js/src/jit/x64/MacroAssembler-x64.h +++ b/js/src/jit/x64/MacroAssembler-x64.h @@ -329,9 +329,8 @@ class MacroAssemblerX64 : public MacroAssemblerX86Shared return testUndefined(cond, scratch); } Condition testInt32(Condition cond, const Address& src) { - ScratchRegisterScope scratch(asMasm()); - splitTag(src, scratch); - return testInt32(cond, scratch); + cmp32(ToUpper32(src), Imm32(Upper32Of(GetShiftedTag(JSVAL_TYPE_INT32)))); + return cond; } Condition testBoolean(Condition cond, const Address& src) { ScratchRegisterScope scratch(asMasm()); @@ -732,11 +731,6 @@ class MacroAssemblerX64 : public MacroAssemblerX86Shared MOZ_ASSERT(cond == Equal || cond == NotEqual); branchTestUndefined(cond, Operand(address), label); } - void branchTestInt32Impl(Condition cond, const Operand& operand, Label* label) { - MOZ_ASSERT(cond == Equal || cond == NotEqual); - cmp32(ToUpper32(operand), Imm32(Upper32Of(GetShiftedTag(JSVAL_TYPE_INT32)))); - j(cond, label); - } void branchTestDouble(Condition cond, const Operand& operand, Label* label) { MOZ_ASSERT(cond == Equal || cond == NotEqual); ScratchRegisterScope scratch(asMasm()); @@ -1069,12 +1063,13 @@ class MacroAssemblerX64 : public MacroAssemblerX86Shared j(cond, label); } - inline void loadInt32OrDouble(const Operand& operand, FloatRegister dest); + template + inline void loadInt32OrDouble(const T& src, FloatRegister dest); template void loadUnboxedValue(const T& src, MIRType type, AnyRegister dest) { if (dest.isFloat()) - loadInt32OrDouble(Operand(src), dest.fpu()); + loadInt32OrDouble(src, dest.fpu()); else if (type == MIRType_Int32 || type == MIRType_Boolean) movl(Operand(src), dest.gpr()); else diff --git a/js/src/jit/x86-shared/MacroAssembler-x86-shared-inl.h b/js/src/jit/x86-shared/MacroAssembler-x86-shared-inl.h index 4f2b27bd55f..f78a87c48f7 100644 --- a/js/src/jit/x86-shared/MacroAssembler-x86-shared-inl.h +++ b/js/src/jit/x86-shared/MacroAssembler-x86-shared-inl.h @@ -429,9 +429,41 @@ MacroAssembler::branchTestPtr(Condition cond, const Address& lhs, Imm32 rhs, Lab } void -MacroAssembler::branchTestInt32Truthy(bool truthy, const ValueOperand& operand, Label* label) +MacroAssembler::branchTestInt32(Condition cond, Register tag, Label* label) { - Condition cond = testInt32Truthy(truthy, operand); + branchTestInt32Impl(cond, tag, label); +} + +void +MacroAssembler::branchTestInt32(Condition cond, const Address& address, Label* label) +{ + branchTestInt32Impl(cond, address, label); +} + +void +MacroAssembler::branchTestInt32(Condition cond, const BaseIndex& address, Label* label) +{ + branchTestInt32Impl(cond, address, label); +} + +void +MacroAssembler::branchTestInt32(Condition cond, const ValueOperand& value, Label* label) +{ + branchTestInt32Impl(cond, value, label); +} + +template +void +MacroAssembler::branchTestInt32Impl(Condition cond, const T& t, Label* label) +{ + cond = testInt32(cond, t); + j(cond, label); +} + +void +MacroAssembler::branchTestInt32Truthy(bool truthy, const ValueOperand& value, Label* label) +{ + Condition cond = testInt32Truthy(truthy, value); j(cond, label); } diff --git a/js/src/jit/x86/MacroAssembler-x86-inl.h b/js/src/jit/x86/MacroAssembler-x86-inl.h index 2bddaec5795..b90e687e8eb 100644 --- a/js/src/jit/x86/MacroAssembler-x86-inl.h +++ b/js/src/jit/x86/MacroAssembler-x86-inl.h @@ -379,30 +379,6 @@ MacroAssembler::branchTest64(Condition cond, Register64 lhs, Register64 rhs, Reg } } -void -MacroAssembler::branchTestInt32(Condition cond, Register tag, Label* label) -{ - branchTestInt32Impl(cond, tag, label); -} - -void -MacroAssembler::branchTestInt32(Condition cond, const Address& address, Label* label) -{ - branchTestInt32Impl(cond, address, label); -} - -void -MacroAssembler::branchTestInt32(Condition cond, const BaseIndex& address, Label* label) -{ - branchTestInt32Impl(cond, address, label); -} - -void -MacroAssembler::branchTestInt32(Condition cond, const ValueOperand& src, Label* label) -{ - branchTestInt32Impl(cond, src, label); -} - //}}} check_macroassembler_style // =============================================================== diff --git a/js/src/jit/x86/MacroAssembler-x86.h b/js/src/jit/x86/MacroAssembler-x86.h index 53898139906..f501a7e1994 100644 --- a/js/src/jit/x86/MacroAssembler-x86.h +++ b/js/src/jit/x86/MacroAssembler-x86.h @@ -665,11 +665,6 @@ class MacroAssemblerX86 : public MacroAssemblerX86Shared j(cond, label); } template - void branchTestInt32Impl(Condition cond, const T& t, Label* label) { - cond = testInt32(cond, t); - j(cond, label); - } - template void branchTestBoolean(Condition cond, const T& t, Label* label) { cond = testBoolean(cond, t); j(cond, label); From 0bfa8420a4bc61172f5394d0ab8df83d7022cde5 Mon Sep 17 00:00:00 2001 From: Tooru Fujisawa Date: Thu, 3 Mar 2016 08:03:42 +0900 Subject: [PATCH 121/160] Bug 1245112 - Part 20: Move MacroAssembler::branchTestDouble into generic macro assembler. r=nbp --- js/src/jit/MacroAssembler.h | 10 ++++++ js/src/jit/arm/MacroAssembler-arm-inl.h | 32 +++++++++++++++++ js/src/jit/arm/MacroAssembler-arm.cpp | 2 +- js/src/jit/arm/MacroAssembler-arm.h | 6 ---- js/src/jit/arm64/MacroAssembler-arm64-inl.h | 34 +++++++++++++++++- js/src/jit/arm64/MacroAssembler-arm64.h | 17 --------- .../MacroAssembler-mips-shared-inl.h | 16 +++++++++ js/src/jit/mips32/MacroAssembler-mips32-inl.h | 14 ++++++++ js/src/jit/mips32/MacroAssembler-mips32.cpp | 35 +------------------ js/src/jit/mips32/MacroAssembler-mips32.h | 5 --- js/src/jit/mips64/MacroAssembler-mips64-inl.h | 16 +++++++++ js/src/jit/mips64/MacroAssembler-mips64.cpp | 34 +----------------- js/src/jit/mips64/MacroAssembler-mips64.h | 5 --- js/src/jit/none/MacroAssembler-none.h | 1 - js/src/jit/x64/MacroAssembler-x64-inl.h | 2 +- js/src/jit/x64/MacroAssembler-x64.h | 22 ------------ .../MacroAssembler-x86-shared-inl.h | 32 +++++++++++++++++ js/src/jit/x86/MacroAssembler-x86-inl.h | 2 +- js/src/jit/x86/MacroAssembler-x86.h | 5 --- 19 files changed, 158 insertions(+), 132 deletions(-) diff --git a/js/src/jit/MacroAssembler.h b/js/src/jit/MacroAssembler.h index 3e6961a43d6..530a3c10114 100644 --- a/js/src/jit/MacroAssembler.h +++ b/js/src/jit/MacroAssembler.h @@ -924,6 +924,8 @@ class MacroAssembler : public MacroAssemblerSpecific // Perform a type-test on a tag of a Value (32bits boxing), or the tagged // value (64bits boxing). inline void branchTestInt32(Condition cond, Register tag, Label* label) PER_SHARED_ARCH; + inline void branchTestDouble(Condition cond, Register tag, Label* label) + DEFINED_ON(arm, arm64, mips32, mips64, x86_shared); // Perform a type-test on a Value, addressed by Address or BaseIndex, or // loaded into ValueOperand. @@ -932,6 +934,11 @@ class MacroAssembler : public MacroAssemblerSpecific inline void branchTestInt32(Condition cond, const ValueOperand& value, Label* label) DEFINED_ON(arm, arm64, mips32, mips64, x86_shared); + inline void branchTestDouble(Condition cond, const Address& address, Label* label) PER_SHARED_ARCH; + inline void branchTestDouble(Condition cond, const BaseIndex& address, Label* label) PER_SHARED_ARCH; + inline void branchTestDouble(Condition cond, const ValueOperand& value, Label* label) + DEFINED_ON(arm, arm64, mips32, mips64, x86_shared); + // Checks if given Value is evaluated to true or false in a condition. // The type of the value should match the type of the method. inline void branchTestInt32Truthy(bool truthy, const ValueOperand& value, Label* label) @@ -943,6 +950,9 @@ class MacroAssembler : public MacroAssemblerSpecific template inline void branchTestInt32Impl(Condition cond, const T& t, Label* label) DEFINED_ON(arm, arm64, x86_shared); + template + inline void branchTestDoubleImpl(Condition cond, const T& t, Label* label) + DEFINED_ON(arm, arm64, x86_shared); //}}} check_macroassembler_style public: diff --git a/js/src/jit/arm/MacroAssembler-arm-inl.h b/js/src/jit/arm/MacroAssembler-arm-inl.h index f364b7d3fdb..e795fa675d0 100644 --- a/js/src/jit/arm/MacroAssembler-arm-inl.h +++ b/js/src/jit/arm/MacroAssembler-arm-inl.h @@ -838,6 +838,38 @@ MacroAssembler::branchTestInt32Truthy(bool truthy, const ValueOperand& value, La ma_b(label, c); } +void +MacroAssembler::branchTestDouble(Condition cond, Register tag, Label* label) +{ + branchTestDoubleImpl(cond, tag, label); +} + +void +MacroAssembler::branchTestDouble(Condition cond, const Address& address, Label* label) +{ + branchTestDoubleImpl(cond, address, label); +} + +void +MacroAssembler::branchTestDouble(Condition cond, const BaseIndex& address, Label* label) +{ + branchTestDoubleImpl(cond, address, label); +} + +void +MacroAssembler::branchTestDouble(Condition cond, const ValueOperand& value, Label* label) +{ + branchTestDoubleImpl(cond, value, label); +} + +template +void +MacroAssembler::branchTestDoubleImpl(Condition cond, const T& t, Label* label) +{ + Condition c = testDouble(cond, t); + ma_b(label, c); +} + //}}} check_macroassembler_style // =============================================================== diff --git a/js/src/jit/arm/MacroAssembler-arm.cpp b/js/src/jit/arm/MacroAssembler-arm.cpp index 3d9b14af981..e05f92b5589 100644 --- a/js/src/jit/arm/MacroAssembler-arm.cpp +++ b/js/src/jit/arm/MacroAssembler-arm.cpp @@ -3448,7 +3448,7 @@ void MacroAssemblerARMCompat::ensureDouble(const ValueOperand& source, FloatRegister dest, Label* failure) { Label isDouble, done; - branchTestDouble(Assembler::Equal, source.typeReg(), &isDouble); + asMasm().branchTestDouble(Assembler::Equal, source.typeReg(), &isDouble); asMasm().branchTestInt32(Assembler::NotEqual, source.typeReg(), failure); convertInt32ToDouble(source.payloadReg(), dest); diff --git a/js/src/jit/arm/MacroAssembler-arm.h b/js/src/jit/arm/MacroAssembler-arm.h index 4991c1ffca3..45ec3f16062 100644 --- a/js/src/jit/arm/MacroAssembler-arm.h +++ b/js/src/jit/arm/MacroAssembler-arm.h @@ -767,12 +767,6 @@ class MacroAssemblerARMCompat : public MacroAssemblerARM Condition c = testBoolean(cond, t); ma_b(label, c); } - - template - void branchTestDouble(Condition cond, const T & t, Label* label) { - Condition c = testDouble(cond, t); - ma_b(label, c); - } template void branchTestNull(Condition cond, const T & t, Label* label) { Condition c = testNull(cond, t); diff --git a/js/src/jit/arm64/MacroAssembler-arm64-inl.h b/js/src/jit/arm64/MacroAssembler-arm64-inl.h index 6e9673a6e5d..b8cc1fa0555 100644 --- a/js/src/jit/arm64/MacroAssembler-arm64-inl.h +++ b/js/src/jit/arm64/MacroAssembler-arm64-inl.h @@ -925,6 +925,38 @@ MacroAssembler::branchTestInt32Truthy(bool truthy, const ValueOperand& value, La B(label, c); } +void +MacroAssembler::branchTestDouble(Condition cond, Register tag, Label* label) +{ + branchTestDoubleImpl(cond, tag, label); +} + +void +MacroAssembler::branchTestDouble(Condition cond, const Address& address, Label* label) +{ + branchTestDoubleImpl(cond, address, label); +} + +void +MacroAssembler::branchTestDouble(Condition cond, const BaseIndex& address, Label* label) +{ + branchTestDoubleImpl(cond, address, label); +} + +void +MacroAssembler::branchTestDouble(Condition cond, const ValueOperand& value, Label* label) +{ + branchTestDoubleImpl(cond, value, label); +} + +template +void +MacroAssembler::branchTestDoubleImpl(Condition cond, const T& t, Label* label) +{ + Condition c = testDouble(cond, t); + B(label, c); +} + //}}} check_macroassembler_style // =============================================================== @@ -1006,7 +1038,7 @@ MacroAssemblerCompat::ensureDouble(const ValueOperand& source, FloatRegister des vixl::UseScratchRegisterScope temps(this); temps.Exclude(ARMRegister(tag, 64)); - branchTestDouble(Assembler::Equal, tag, &isDouble); + asMasm().branchTestDouble(Assembler::Equal, tag, &isDouble); asMasm().branchTestInt32(Assembler::NotEqual, tag, failure); } diff --git a/js/src/jit/arm64/MacroAssembler-arm64.h b/js/src/jit/arm64/MacroAssembler-arm64.h index 67989cd7dd8..ebeb384ba81 100644 --- a/js/src/jit/arm64/MacroAssembler-arm64.h +++ b/js/src/jit/arm64/MacroAssembler-arm64.h @@ -1332,11 +1332,6 @@ class MacroAssemblerCompat : public vixl::MacroAssembler Condition c = testUndefined(cond, tag); B(label, c); } - - void branchTestDouble(Condition cond, Register tag, Label* label) { - Condition c = testDouble(cond, tag); - B(label, c); - } void branchTestBoolean(Condition cond, Register tag, Label* label) { Condition c = testBoolean(cond, tag); B(label, c); @@ -1366,10 +1361,6 @@ class MacroAssemblerCompat : public vixl::MacroAssembler Condition c = testUndefined(cond, address); B(label, c); } - void branchTestDouble(Condition cond, const Address& address, Label* label) { - Condition c = testDouble(cond, address); - B(label, c); - } void branchTestBoolean(Condition cond, const Address& address, Label* label) { Condition c = testDouble(cond, address); B(label, c); @@ -1405,10 +1396,6 @@ class MacroAssemblerCompat : public vixl::MacroAssembler Condition c = testBoolean(cond, src); B(label, c); } - void branchTestDouble(Condition cond, const ValueOperand& src, Label* label) { - Condition c = testDouble(cond, src); - B(label, c); - } void branchTestNull(Condition cond, const ValueOperand& src, Label* label) { Condition c = testNull(cond, src); B(label, c); @@ -1440,10 +1427,6 @@ class MacroAssemblerCompat : public vixl::MacroAssembler Condition c = testBoolean(cond, address); B(label, c); } - void branchTestDouble(Condition cond, const BaseIndex& address, Label* label) { - Condition c = testDouble(cond, address); - B(label, c); - } void branchTestNull(Condition cond, const BaseIndex& address, Label* label) { Condition c = testNull(cond, address); B(label, c); diff --git a/js/src/jit/mips-shared/MacroAssembler-mips-shared-inl.h b/js/src/jit/mips-shared/MacroAssembler-mips-shared-inl.h index be0ac3e346f..514a571e192 100644 --- a/js/src/jit/mips-shared/MacroAssembler-mips-shared-inl.h +++ b/js/src/jit/mips-shared/MacroAssembler-mips-shared-inl.h @@ -532,6 +532,22 @@ MacroAssembler::branchTestInt32(Condition cond, const BaseIndex& address, Label* branchTestInt32(cond, scratch2, label); } +void +MacroAssembler::branchTestDouble(Condition cond, const Address& address, Label* label) +{ + SecondScratchRegisterScope scratch2(*this); + extractTag(address, scratch2); + branchTestDouble(cond, scratch2, label); +} + +void +MacroAssembler::branchTestDouble(Condition cond, const BaseIndex& address, Label* label) +{ + SecondScratchRegisterScope scratch2(*this); + extractTag(address, scratch2); + branchTestDouble(cond, scratch2, label); +} + //}}} check_macroassembler_style // =============================================================== diff --git a/js/src/jit/mips32/MacroAssembler-mips32-inl.h b/js/src/jit/mips32/MacroAssembler-mips32-inl.h index 736abdf5f1e..4336ecc48fd 100644 --- a/js/src/jit/mips32/MacroAssembler-mips32-inl.h +++ b/js/src/jit/mips32/MacroAssembler-mips32-inl.h @@ -302,6 +302,20 @@ MacroAssembler::branchTestInt32Truthy(bool b, const ValueOperand& value, Label* ma_b(scratch, scratch, label, b ? NonZero : Zero); } +void +MacroAssembler::branchTestDouble(Condition cond, Register tag, Label* label) +{ + MOZ_ASSERT(cond == Equal || cond == NotEqual); + Condition actual = (cond == Equal) ? Below : AboveOrEqual; + ma_b(tag, ImmTag(JSVAL_TAG_CLEAR), label, actual); +} + +void +MacroAssembler::branchTestDouble(Condition cond, const ValueOperand& value, Label* label) +{ + branchTestDouble(cond, value.typeReg(), label); +} + //}}} check_macroassembler_style // =============================================================== diff --git a/js/src/jit/mips32/MacroAssembler-mips32.cpp b/js/src/jit/mips32/MacroAssembler-mips32.cpp index e3d4d8ec31f..de2f8462ac7 100644 --- a/js/src/jit/mips32/MacroAssembler-mips32.cpp +++ b/js/src/jit/mips32/MacroAssembler-mips32.cpp @@ -1157,39 +1157,6 @@ MacroAssemblerMIPSCompat::branchTestBoolean(Condition cond, const BaseIndex& src ma_b(SecondScratchReg, ImmType(JSVAL_TYPE_BOOLEAN), label, cond); } -void -MacroAssemblerMIPSCompat::branchTestDouble(Condition cond, const ValueOperand& value, Label* label) -{ - MOZ_ASSERT(cond == Assembler::Equal || cond == Assembler::NotEqual); - Assembler::Condition actual = (cond == Equal) ? Below : AboveOrEqual; - ma_b(value.typeReg(), ImmTag(JSVAL_TAG_CLEAR), label, actual); -} - -void -MacroAssemblerMIPSCompat::branchTestDouble(Condition cond, Register tag, Label* label) -{ - MOZ_ASSERT(cond == Assembler::Equal || cond == NotEqual); - Condition actual = (cond == Equal) ? Below : AboveOrEqual; - ma_b(tag, ImmTag(JSVAL_TAG_CLEAR), label, actual); -} - -void -MacroAssemblerMIPSCompat::branchTestDouble(Condition cond, const Address& address, Label* label) -{ - MOZ_ASSERT(cond == Equal || cond == NotEqual); - extractTag(address, SecondScratchReg); - ma_b(SecondScratchReg, ImmTag(JSVAL_TAG_CLEAR), label, cond); -} - -void -MacroAssemblerMIPSCompat::branchTestDouble(Condition cond, const BaseIndex& src, Label* label) -{ - MOZ_ASSERT(cond == Equal || cond == NotEqual); - Condition actual = (cond == Equal) ? Below : AboveOrEqual; - extractTag(src, SecondScratchReg); - ma_b(SecondScratchReg, ImmTag(JSVAL_TAG_CLEAR), label, actual); -} - void MacroAssemblerMIPSCompat::branchTestNull(Condition cond, const ValueOperand& value, Label* label) { @@ -2014,7 +1981,7 @@ MacroAssemblerMIPSCompat::ensureDouble(const ValueOperand& source, FloatRegister Label* failure) { Label isDouble, done; - branchTestDouble(Assembler::Equal, source.typeReg(), &isDouble); + asMasm().branchTestDouble(Assembler::Equal, source.typeReg(), &isDouble); asMasm().branchTestInt32(Assembler::NotEqual, source.typeReg(), failure); convertInt32ToDouble(source.payloadReg(), dest); diff --git a/js/src/jit/mips32/MacroAssembler-mips32.h b/js/src/jit/mips32/MacroAssembler-mips32.h index 2098a0db84a..655f1ca7d81 100644 --- a/js/src/jit/mips32/MacroAssembler-mips32.h +++ b/js/src/jit/mips32/MacroAssembler-mips32.h @@ -381,11 +381,6 @@ class MacroAssemblerMIPSCompat : public MacroAssemblerMIPS void branchTestBoolean(Condition cond, const BaseIndex& src, Label* label); - void branchTestDouble(Condition cond, const ValueOperand& value, Label* label); - void branchTestDouble(Condition cond, Register tag, Label* label); - void branchTestDouble(Condition cond, const Address& address, Label* label); - void branchTestDouble(Condition cond, const BaseIndex& src, Label* label); - void branchTestNull(Condition cond, const ValueOperand& value, Label* label); void branchTestNull(Condition cond, Register tag, Label* label); void branchTestNull(Condition cond, const BaseIndex& src, Label* label); diff --git a/js/src/jit/mips64/MacroAssembler-mips64-inl.h b/js/src/jit/mips64/MacroAssembler-mips64-inl.h index eaae7cdc9d4..811111a49dc 100644 --- a/js/src/jit/mips64/MacroAssembler-mips64-inl.h +++ b/js/src/jit/mips64/MacroAssembler-mips64-inl.h @@ -240,6 +240,22 @@ MacroAssembler::branchTestInt32Truthy(bool b, const ValueOperand& value, Label* ma_b(scratch, scratch, label, b ? NonZero : Zero); } +void +MacroAssembler::branchTestDouble(Condition cond, Register tag, Label* label) +{ + MOZ_ASSERT(cond == Equal || cond == NotEqual); + Condition actual = (cond == Equal) ? BelowOrEqual : Above; + ma_b(tag, ImmTag(JSVAL_TAG_MAX_DOUBLE), label, actual); +} + +void +MacroAssembler::branchTestDouble(Condition cond, const ValueOperand& value, Label* label) +{ + SecondScratchRegisterScope scratch2(*this); + splitTag(value, scratch2); + branchTestDouble(cond, scratch2, label); +} + //}}} check_macroassembler_style // =============================================================== diff --git a/js/src/jit/mips64/MacroAssembler-mips64.cpp b/js/src/jit/mips64/MacroAssembler-mips64.cpp index 6e03c1edb6b..35dcfed8c54 100644 --- a/js/src/jit/mips64/MacroAssembler-mips64.cpp +++ b/js/src/jit/mips64/MacroAssembler-mips64.cpp @@ -1286,38 +1286,6 @@ MacroAssemblerMIPS64Compat::branchTestBoolean(Condition cond, const BaseIndex& s ma_b(SecondScratchReg, ImmTag(JSVAL_TAG_BOOLEAN), label, cond); } -void -MacroAssemblerMIPS64Compat::branchTestDouble(Condition cond, const ValueOperand& value, Label* label) -{ - MOZ_ASSERT(cond == Assembler::Equal || cond == NotEqual); - splitTag(value, SecondScratchReg); - branchTestDouble(cond, SecondScratchReg, label); -} - -void -MacroAssemblerMIPS64Compat::branchTestDouble(Condition cond, Register tag, Label* label) -{ - MOZ_ASSERT(cond == Assembler::Equal || cond == NotEqual); - Condition actual = (cond == Equal) ? BelowOrEqual : Above; - ma_b(tag, ImmTag(JSVAL_TAG_MAX_DOUBLE), label, actual); -} - -void -MacroAssemblerMIPS64Compat::branchTestDouble(Condition cond, const Address& address, Label* label) -{ - MOZ_ASSERT(cond == Equal || cond == NotEqual); - extractTag(address, SecondScratchReg); - branchTestDouble(cond, SecondScratchReg, label); -} - -void -MacroAssemblerMIPS64Compat::branchTestDouble(Condition cond, const BaseIndex& src, Label* label) -{ - MOZ_ASSERT(cond == Equal || cond == NotEqual); - extractTag(src, SecondScratchReg); - branchTestDouble(cond, SecondScratchReg, label); -} - void MacroAssemblerMIPS64Compat::branchTestNull(Condition cond, const ValueOperand& value, Label* label) { @@ -2174,7 +2142,7 @@ MacroAssemblerMIPS64Compat::ensureDouble(const ValueOperand& source, FloatRegist { Label isDouble, done; Register tag = splitTagForTest(source); - branchTestDouble(Assembler::Equal, tag, &isDouble); + asMasm().branchTestDouble(Assembler::Equal, tag, &isDouble); asMasm().branchTestInt32(Assembler::NotEqual, tag, failure); unboxInt32(source, ScratchRegister); diff --git a/js/src/jit/mips64/MacroAssembler-mips64.h b/js/src/jit/mips64/MacroAssembler-mips64.h index 4fc79faf3cb..d7afd088545 100644 --- a/js/src/jit/mips64/MacroAssembler-mips64.h +++ b/js/src/jit/mips64/MacroAssembler-mips64.h @@ -422,11 +422,6 @@ class MacroAssemblerMIPS64Compat : public MacroAssemblerMIPS64 void branchTestBoolean(Condition cond, const BaseIndex& src, Label* label); - void branchTestDouble(Condition cond, const ValueOperand& value, Label* label); - void branchTestDouble(Condition cond, Register tag, Label* label); - void branchTestDouble(Condition cond, const Address& address, Label* label); - void branchTestDouble(Condition cond, const BaseIndex& src, Label* label); - void branchTestNull(Condition cond, const ValueOperand& value, Label* label); void branchTestNull(Condition cond, Register tag, Label* label); void branchTestNull(Condition cond, const BaseIndex& src, Label* label); diff --git a/js/src/jit/none/MacroAssembler-none.h b/js/src/jit/none/MacroAssembler-none.h index 718043a17aa..3e525a8c335 100644 --- a/js/src/jit/none/MacroAssembler-none.h +++ b/js/src/jit/none/MacroAssembler-none.h @@ -347,7 +347,6 @@ class MacroAssemblerNone : public Assembler template void branchTestUndefined(Condition, T, Label*) { MOZ_CRASH(); } template void branchTestBoolean(Condition, T, Label*) { MOZ_CRASH(); } - template void branchTestDouble(Condition, T, Label*) { MOZ_CRASH(); } template void branchTestNull(Condition, T, Label*) { MOZ_CRASH(); } template void branchTestString(Condition, T, Label*) { MOZ_CRASH(); } template void branchTestSymbol(Condition, T, Label*) { MOZ_CRASH(); } diff --git a/js/src/jit/x64/MacroAssembler-x64-inl.h b/js/src/jit/x64/MacroAssembler-x64-inl.h index 1c100b09c6a..4084c2f0cdb 100644 --- a/js/src/jit/x64/MacroAssembler-x64-inl.h +++ b/js/src/jit/x64/MacroAssembler-x64-inl.h @@ -459,7 +459,7 @@ MacroAssemblerX64::ensureDouble(const ValueOperand& source, FloatRegister dest, { Label isDouble, done; Register tag = splitTagForTest(source); - branchTestDouble(Assembler::Equal, tag, &isDouble); + asMasm().branchTestDouble(Assembler::Equal, tag, &isDouble); asMasm().branchTestInt32(Assembler::NotEqual, tag, failure); ScratchRegisterScope scratch(asMasm()); diff --git a/js/src/jit/x64/MacroAssembler-x64.h b/js/src/jit/x64/MacroAssembler-x64.h index 25172138bfb..73aee088115 100644 --- a/js/src/jit/x64/MacroAssembler-x64.h +++ b/js/src/jit/x64/MacroAssembler-x64.h @@ -690,10 +690,6 @@ class MacroAssemblerX64 : public MacroAssemblerX86Shared cond = testUndefined(cond, tag); j(cond, label); } - void branchTestDouble(Condition cond, Register tag, Label* label) { - cond = testDouble(cond, tag); - j(cond, label); - } void branchTestBoolean(Condition cond, Register tag, Label* label) { cond = testBoolean(cond, tag); j(cond, label); @@ -731,16 +727,6 @@ class MacroAssemblerX64 : public MacroAssemblerX86Shared MOZ_ASSERT(cond == Equal || cond == NotEqual); branchTestUndefined(cond, Operand(address), label); } - void branchTestDouble(Condition cond, const Operand& operand, Label* label) { - MOZ_ASSERT(cond == Equal || cond == NotEqual); - ScratchRegisterScope scratch(asMasm()); - splitTag(operand, scratch); - branchTestDouble(cond, scratch, label); - } - void branchTestDouble(Condition cond, const Address& address, Label* label) { - MOZ_ASSERT(cond == Equal || cond == NotEqual); - branchTestDouble(cond, Operand(address), label); - } void branchTestBoolean(Condition cond, const Operand& operand, Label* label) { MOZ_ASSERT(cond == Equal || cond == NotEqual); cmp32(ToUpper32(operand), Imm32(Upper32Of(GetShiftedTag(JSVAL_TYPE_BOOLEAN)))); @@ -777,10 +763,6 @@ class MacroAssemblerX64 : public MacroAssemblerX86Shared splitTag(src, scratch); branchTestBoolean(cond, scratch, label); } - void branchTestDouble(Condition cond, const ValueOperand& src, Label* label) { - cond = testDouble(cond, src); - j(cond, label); - } void branchTestNull(Condition cond, const ValueOperand& src, Label* label) { cond = testNull(cond, src); j(cond, label); @@ -813,10 +795,6 @@ class MacroAssemblerX64 : public MacroAssemblerX86Shared splitTag(address, scratch); branchTestBoolean(cond, scratch, label); } - void branchTestDouble(Condition cond, const BaseIndex& address, Label* label) { - cond = testDouble(cond, address); - j(cond, label); - } void branchTestNull(Condition cond, const BaseIndex& address, Label* label) { cond = testNull(cond, address); j(cond, label); diff --git a/js/src/jit/x86-shared/MacroAssembler-x86-shared-inl.h b/js/src/jit/x86-shared/MacroAssembler-x86-shared-inl.h index f78a87c48f7..850ed462b1c 100644 --- a/js/src/jit/x86-shared/MacroAssembler-x86-shared-inl.h +++ b/js/src/jit/x86-shared/MacroAssembler-x86-shared-inl.h @@ -467,6 +467,38 @@ MacroAssembler::branchTestInt32Truthy(bool truthy, const ValueOperand& value, La j(cond, label); } +void +MacroAssembler::branchTestDouble(Condition cond, Register tag, Label* label) +{ + branchTestDoubleImpl(cond, tag, label); +} + +void +MacroAssembler::branchTestDouble(Condition cond, const Address& address, Label* label) +{ + branchTestDoubleImpl(cond, address, label); +} + +void +MacroAssembler::branchTestDouble(Condition cond, const BaseIndex& address, Label* label) +{ + branchTestDoubleImpl(cond, address, label); +} + +void +MacroAssembler::branchTestDouble(Condition cond, const ValueOperand& value, Label* label) +{ + branchTestDoubleImpl(cond, value, label); +} + +template +void +MacroAssembler::branchTestDoubleImpl(Condition cond, const T& t, Label* label) +{ + cond = testDouble(cond, t); + j(cond, label); +} + //}}} check_macroassembler_style // =============================================================== diff --git a/js/src/jit/x86/MacroAssembler-x86-inl.h b/js/src/jit/x86/MacroAssembler-x86-inl.h index b90e687e8eb..5995883eb21 100644 --- a/js/src/jit/x86/MacroAssembler-x86-inl.h +++ b/js/src/jit/x86/MacroAssembler-x86-inl.h @@ -476,7 +476,7 @@ void MacroAssemblerX86::ensureDouble(const ValueOperand& source, FloatRegister dest, Label* failure) { Label isDouble, done; - branchTestDouble(Assembler::Equal, source.typeReg(), &isDouble); + asMasm().branchTestDouble(Assembler::Equal, source.typeReg(), &isDouble); asMasm().branchTestInt32(Assembler::NotEqual, source.typeReg(), failure); convertInt32ToDouble(source.payloadReg(), dest); diff --git a/js/src/jit/x86/MacroAssembler-x86.h b/js/src/jit/x86/MacroAssembler-x86.h index f501a7e1994..ac627556aea 100644 --- a/js/src/jit/x86/MacroAssembler-x86.h +++ b/js/src/jit/x86/MacroAssembler-x86.h @@ -670,11 +670,6 @@ class MacroAssemblerX86 : public MacroAssemblerX86Shared j(cond, label); } template - void branchTestDouble(Condition cond, const T& t, Label* label) { - cond = testDouble(cond, t); - j(cond, label); - } - template void branchTestNull(Condition cond, const T& t, Label* label) { cond = testNull(cond, t); j(cond, label); From 4838c4714666f774359337edce7ff4842e84a002 Mon Sep 17 00:00:00 2001 From: Tooru Fujisawa Date: Thu, 3 Mar 2016 08:03:42 +0900 Subject: [PATCH 122/160] Bug 1245112 - Part 21: Move MacroAssembler::branchTestDoubleTruthy into generic macro assembler. r=nbp --- js/src/jit/MacroAssembler.h | 1 + js/src/jit/arm/MacroAssembler-arm-inl.h | 7 +++++++ js/src/jit/arm/MacroAssembler-arm.h | 4 ---- js/src/jit/arm64/MacroAssembler-arm64-inl.h | 19 +++++++++++++++++++ js/src/jit/arm64/MacroAssembler-arm64.h | 17 ----------------- .../MacroAssembler-mips-shared-inl.h | 8 ++++++++ js/src/jit/mips32/MacroAssembler-mips32.cpp | 8 -------- js/src/jit/mips32/MacroAssembler-mips32.h | 2 -- js/src/jit/mips64/MacroAssembler-mips64.cpp | 8 -------- js/src/jit/mips64/MacroAssembler-mips64.h | 2 -- js/src/jit/none/MacroAssembler-none.h | 1 - .../MacroAssembler-x86-shared-inl.h | 7 +++++++ .../x86-shared/MacroAssembler-x86-shared.h | 4 ---- 13 files changed, 42 insertions(+), 46 deletions(-) diff --git a/js/src/jit/MacroAssembler.h b/js/src/jit/MacroAssembler.h index 530a3c10114..e70613dc7bd 100644 --- a/js/src/jit/MacroAssembler.h +++ b/js/src/jit/MacroAssembler.h @@ -943,6 +943,7 @@ class MacroAssembler : public MacroAssemblerSpecific // The type of the value should match the type of the method. inline void branchTestInt32Truthy(bool truthy, const ValueOperand& value, Label* label) DEFINED_ON(arm, arm64, mips32, mips64, x86_shared); + inline void branchTestDoubleTruthy(bool truthy, FloatRegister reg, Label* label) PER_SHARED_ARCH; private: diff --git a/js/src/jit/arm/MacroAssembler-arm-inl.h b/js/src/jit/arm/MacroAssembler-arm-inl.h index e795fa675d0..d82370b2250 100644 --- a/js/src/jit/arm/MacroAssembler-arm-inl.h +++ b/js/src/jit/arm/MacroAssembler-arm-inl.h @@ -870,6 +870,13 @@ MacroAssembler::branchTestDoubleImpl(Condition cond, const T& t, Label* label) ma_b(label, c); } +void +MacroAssembler::branchTestDoubleTruthy(bool truthy, FloatRegister reg, Label* label) +{ + Condition c = testDoubleTruthy(truthy, reg); + ma_b(label, c); +} + //}}} check_macroassembler_style // =============================================================== diff --git a/js/src/jit/arm/MacroAssembler-arm.h b/js/src/jit/arm/MacroAssembler-arm.h index 45ec3f16062..3829aa8f4d9 100644 --- a/js/src/jit/arm/MacroAssembler-arm.h +++ b/js/src/jit/arm/MacroAssembler-arm.h @@ -811,10 +811,6 @@ class MacroAssemblerARMCompat : public MacroAssemblerARM Condition c = testBooleanTruthy(truthy, operand); ma_b(label, c); } - void branchTestDoubleTruthy(bool truthy, FloatRegister reg, Label* label) { - Condition c = testDoubleTruthy(truthy, reg); - ma_b(label, c); - } void branchTestStringTruthy(bool truthy, const ValueOperand& value, Label* label) { Condition c = testStringTruthy(truthy, value); ma_b(label, c); diff --git a/js/src/jit/arm64/MacroAssembler-arm64-inl.h b/js/src/jit/arm64/MacroAssembler-arm64-inl.h index b8cc1fa0555..feb3caea3e1 100644 --- a/js/src/jit/arm64/MacroAssembler-arm64-inl.h +++ b/js/src/jit/arm64/MacroAssembler-arm64-inl.h @@ -957,6 +957,25 @@ MacroAssembler::branchTestDoubleImpl(Condition cond, const T& t, Label* label) B(label, c); } +void +MacroAssembler::branchTestDoubleTruthy(bool truthy, FloatRegister reg, Label* label) +{ + Fcmp(ARMFPRegister(reg, 64), 0.0); + if (!truthy) { + // falsy values are zero, and NaN. + branch(Zero, label); + branch(Overflow, label); + } else { + // truthy values are non-zero and not nan. + // If it is overflow + Label onFalse; + branch(Zero, &onFalse); + branch(Overflow, &onFalse); + B(label); + bind(&onFalse); + } +} + //}}} check_macroassembler_style // =============================================================== diff --git a/js/src/jit/arm64/MacroAssembler-arm64.h b/js/src/jit/arm64/MacroAssembler-arm64.h index ebeb384ba81..3c480d5ebb4 100644 --- a/js/src/jit/arm64/MacroAssembler-arm64.h +++ b/js/src/jit/arm64/MacroAssembler-arm64.h @@ -1948,23 +1948,6 @@ class MacroAssemblerCompat : public vixl::MacroAssembler return truthy ? NonZero : Zero; } - void branchTestDoubleTruthy(bool truthy, FloatRegister reg, Label* label) { - Fcmp(ARMFPRegister(reg, 64), 0.0); - if (!truthy) { - // falsy values are zero, and NaN. - branch(Zero, label); - branch(Overflow, label); - } else { - // truthy values are non-zero and not nan. - // If it is overflow - Label onFalse; - branch(Zero, &onFalse); - branch(Overflow, &onFalse); - B(label); - bind(&onFalse); - } - } - Condition testBooleanTruthy(bool truthy, const ValueOperand& operand) { ARMRegister payload32(operand.valueReg(), 32); Tst(payload32, payload32); diff --git a/js/src/jit/mips-shared/MacroAssembler-mips-shared-inl.h b/js/src/jit/mips-shared/MacroAssembler-mips-shared-inl.h index 514a571e192..0060aa9354b 100644 --- a/js/src/jit/mips-shared/MacroAssembler-mips-shared-inl.h +++ b/js/src/jit/mips-shared/MacroAssembler-mips-shared-inl.h @@ -548,6 +548,14 @@ MacroAssembler::branchTestDouble(Condition cond, const BaseIndex& address, Label branchTestDouble(cond, scratch2, label); } +void +MacroAssembler::branchTestDoubleTruthy(bool b, FloatRegister value, Label* label) +{ + ma_lid(ScratchDoubleReg, 0.0); + DoubleCondition cond = b ? DoubleNotEqual : DoubleEqualOrUnordered; + ma_bc1d(value, ScratchDoubleReg, label, cond); +} + //}}} check_macroassembler_style // =============================================================== diff --git a/js/src/jit/mips32/MacroAssembler-mips32.cpp b/js/src/jit/mips32/MacroAssembler-mips32.cpp index de2f8462ac7..037221fd7b7 100644 --- a/js/src/jit/mips32/MacroAssembler-mips32.cpp +++ b/js/src/jit/mips32/MacroAssembler-mips32.cpp @@ -1613,14 +1613,6 @@ MacroAssemblerMIPSCompat::branchTestStringTruthy(bool b, const ValueOperand& val ma_b(SecondScratchReg, Imm32(0), label, b ? NotEqual : Equal); } -void -MacroAssemblerMIPSCompat::branchTestDoubleTruthy(bool b, FloatRegister value, Label* label) -{ - ma_lid(ScratchDoubleReg, 0.0); - DoubleCondition cond = b ? DoubleNotEqual : DoubleEqualOrUnordered; - ma_bc1d(value, ScratchDoubleReg, label, cond); -} - void MacroAssemblerMIPSCompat::branchTestBooleanTruthy(bool b, const ValueOperand& operand, Label* label) diff --git a/js/src/jit/mips32/MacroAssembler-mips32.h b/js/src/jit/mips32/MacroAssembler-mips32.h index 655f1ca7d81..862794dbf7c 100644 --- a/js/src/jit/mips32/MacroAssembler-mips32.h +++ b/js/src/jit/mips32/MacroAssembler-mips32.h @@ -424,8 +424,6 @@ class MacroAssemblerMIPSCompat : public MacroAssemblerMIPS void branchTestStringTruthy(bool b, const ValueOperand& value, Label* label); - void branchTestDoubleTruthy(bool b, FloatRegister value, Label* label); - void branchTestBooleanTruthy(bool b, const ValueOperand& operand, Label* label); // higher level tag testing code diff --git a/js/src/jit/mips64/MacroAssembler-mips64.cpp b/js/src/jit/mips64/MacroAssembler-mips64.cpp index 35dcfed8c54..f9c20fb2572 100644 --- a/js/src/jit/mips64/MacroAssembler-mips64.cpp +++ b/js/src/jit/mips64/MacroAssembler-mips64.cpp @@ -1837,14 +1837,6 @@ MacroAssemblerMIPS64Compat::branchTestStringTruthy(bool b, const ValueOperand& v ma_b(SecondScratchReg, Imm32(0), label, b ? NotEqual : Equal); } -void -MacroAssemblerMIPS64Compat::branchTestDoubleTruthy(bool b, FloatRegister value, Label* label) -{ - ma_lid(ScratchDoubleReg, 0.0); - DoubleCondition cond = b ? DoubleNotEqual : DoubleEqualOrUnordered; - ma_bc1d(value, ScratchDoubleReg, label, cond); -} - void MacroAssemblerMIPS64Compat::branchTestBooleanTruthy(bool b, const ValueOperand& operand, Label* label) diff --git a/js/src/jit/mips64/MacroAssembler-mips64.h b/js/src/jit/mips64/MacroAssembler-mips64.h index d7afd088545..fb0ba049f61 100644 --- a/js/src/jit/mips64/MacroAssembler-mips64.h +++ b/js/src/jit/mips64/MacroAssembler-mips64.h @@ -465,8 +465,6 @@ class MacroAssemblerMIPS64Compat : public MacroAssemblerMIPS64 void branchTestStringTruthy(bool b, const ValueOperand& value, Label* label); - void branchTestDoubleTruthy(bool b, FloatRegister value, Label* label); - void branchTestBooleanTruthy(bool b, const ValueOperand& operand, Label* label); // higher level tag testing code diff --git a/js/src/jit/none/MacroAssembler-none.h b/js/src/jit/none/MacroAssembler-none.h index 3e525a8c335..535ff6dfb00 100644 --- a/js/src/jit/none/MacroAssembler-none.h +++ b/js/src/jit/none/MacroAssembler-none.h @@ -395,7 +395,6 @@ class MacroAssemblerNone : public Assembler Condition testStringTruthy(bool, ValueOperand) { MOZ_CRASH(); } void branchTestBooleanTruthy(bool, ValueOperand, Label*) { MOZ_CRASH(); } void branchTestStringTruthy(bool, ValueOperand, Label*) { MOZ_CRASH(); } - void branchTestDoubleTruthy(bool, FloatRegister, Label*) { MOZ_CRASH(); } template void loadUnboxedValue(T, MIRType, AnyRegister) { MOZ_CRASH(); } template void storeUnboxedValue(ConstantOrRegister, MIRType, T, MIRType) { MOZ_CRASH(); } diff --git a/js/src/jit/x86-shared/MacroAssembler-x86-shared-inl.h b/js/src/jit/x86-shared/MacroAssembler-x86-shared-inl.h index 850ed462b1c..cd4ec49be91 100644 --- a/js/src/jit/x86-shared/MacroAssembler-x86-shared-inl.h +++ b/js/src/jit/x86-shared/MacroAssembler-x86-shared-inl.h @@ -499,6 +499,13 @@ MacroAssembler::branchTestDoubleImpl(Condition cond, const T& t, Label* label) j(cond, label); } +void +MacroAssembler::branchTestDoubleTruthy(bool truthy, FloatRegister reg, Label* label) +{ + Condition cond = testDoubleTruthy(truthy, reg); + j(cond, label); +} + //}}} check_macroassembler_style // =============================================================== diff --git a/js/src/jit/x86-shared/MacroAssembler-x86-shared.h b/js/src/jit/x86-shared/MacroAssembler-x86-shared.h index 963191e5da3..27ceaa6734b 100644 --- a/js/src/jit/x86-shared/MacroAssembler-x86-shared.h +++ b/js/src/jit/x86-shared/MacroAssembler-x86-shared.h @@ -582,10 +582,6 @@ class MacroAssemblerX86Shared : public Assembler vucomisd(reg, scratch); return truthy ? NonZero : Zero; } - void branchTestDoubleTruthy(bool truthy, FloatRegister reg, Label* label) { - Condition cond = testDoubleTruthy(truthy, reg); - j(cond, label); - } // Class which ensures that registers used in byte ops are compatible with // such instructions, even if the original register passed in wasn't. This From ed77fcc0f672530c86c36a1eb35589f032bfd511 Mon Sep 17 00:00:00 2001 From: Tooru Fujisawa Date: Thu, 3 Mar 2016 08:03:42 +0900 Subject: [PATCH 123/160] Bug 1245112 - Part 22: Move MacroAssembler::branchTestNumber into generic macro assembler. r=bhackett --- js/src/jit/MacroAssembler.h | 7 +++++++ js/src/jit/arm/MacroAssembler-arm-inl.h | 20 +++++++++++++++++++ js/src/jit/arm/MacroAssembler-arm.h | 5 ----- js/src/jit/arm64/MacroAssembler-arm64-inl.h | 20 +++++++++++++++++++ js/src/jit/arm64/MacroAssembler-arm64.h | 12 ----------- .../MacroAssembler-mips-shared-inl.h | 8 ++++++++ js/src/jit/mips32/MacroAssembler-mips32-inl.h | 6 ++++++ js/src/jit/mips32/MacroAssembler-mips32.cpp | 14 ------------- js/src/jit/mips32/MacroAssembler-mips32.h | 3 --- js/src/jit/mips64/MacroAssembler-mips64-inl.h | 8 ++++++++ js/src/jit/mips64/MacroAssembler-mips64.cpp | 15 -------------- js/src/jit/mips64/MacroAssembler-mips64.h | 3 --- js/src/jit/none/MacroAssembler-none.h | 1 - js/src/jit/x64/MacroAssembler-x64.h | 8 -------- .../MacroAssembler-x86-shared-inl.h | 20 +++++++++++++++++++ js/src/jit/x86/MacroAssembler-x86.h | 5 ----- 16 files changed, 89 insertions(+), 66 deletions(-) diff --git a/js/src/jit/MacroAssembler.h b/js/src/jit/MacroAssembler.h index e70613dc7bd..97ef01b987b 100644 --- a/js/src/jit/MacroAssembler.h +++ b/js/src/jit/MacroAssembler.h @@ -926,6 +926,7 @@ class MacroAssembler : public MacroAssemblerSpecific inline void branchTestInt32(Condition cond, Register tag, Label* label) PER_SHARED_ARCH; inline void branchTestDouble(Condition cond, Register tag, Label* label) DEFINED_ON(arm, arm64, mips32, mips64, x86_shared); + inline void branchTestNumber(Condition cond, Register tag, Label* label) PER_SHARED_ARCH; // Perform a type-test on a Value, addressed by Address or BaseIndex, or // loaded into ValueOperand. @@ -939,6 +940,9 @@ class MacroAssembler : public MacroAssemblerSpecific inline void branchTestDouble(Condition cond, const ValueOperand& value, Label* label) DEFINED_ON(arm, arm64, mips32, mips64, x86_shared); + inline void branchTestNumber(Condition cond, const ValueOperand& value, Label* label) + DEFINED_ON(arm, arm64, mips32, mips64, x86_shared); + // Checks if given Value is evaluated to true or false in a condition. // The type of the value should match the type of the method. inline void branchTestInt32Truthy(bool truthy, const ValueOperand& value, Label* label) @@ -954,6 +958,9 @@ class MacroAssembler : public MacroAssemblerSpecific template inline void branchTestDoubleImpl(Condition cond, const T& t, Label* label) DEFINED_ON(arm, arm64, x86_shared); + template + inline void branchTestNumberImpl(Condition cond, const T& t, Label* label) + DEFINED_ON(arm, arm64, x86_shared); //}}} check_macroassembler_style public: diff --git a/js/src/jit/arm/MacroAssembler-arm-inl.h b/js/src/jit/arm/MacroAssembler-arm-inl.h index d82370b2250..c90d3824a8e 100644 --- a/js/src/jit/arm/MacroAssembler-arm-inl.h +++ b/js/src/jit/arm/MacroAssembler-arm-inl.h @@ -877,6 +877,26 @@ MacroAssembler::branchTestDoubleTruthy(bool truthy, FloatRegister reg, Label* la ma_b(label, c); } +void +MacroAssembler::branchTestNumber(Condition cond, Register tag, Label* label) +{ + branchTestNumberImpl(cond, tag, label); +} + +void +MacroAssembler::branchTestNumber(Condition cond, const ValueOperand& value, Label* label) +{ + branchTestNumberImpl(cond, value, label); +} + +template +void +MacroAssembler::branchTestNumberImpl(Condition cond, const T& t, Label* label) +{ + cond = testNumber(cond, t); + ma_b(label, cond); +} + //}}} check_macroassembler_style // =============================================================== diff --git a/js/src/jit/arm/MacroAssembler-arm.h b/js/src/jit/arm/MacroAssembler-arm.h index 3829aa8f4d9..29224f6f1d0 100644 --- a/js/src/jit/arm/MacroAssembler-arm.h +++ b/js/src/jit/arm/MacroAssembler-arm.h @@ -792,11 +792,6 @@ class MacroAssemblerARMCompat : public MacroAssemblerARM Condition c = testUndefined(cond, t); ma_b(label, c); } - template - void branchTestNumber(Condition cond, const T& t, Label* label) { - cond = testNumber(cond, t); - ma_b(label, cond); - } template void branchTestMagic(Condition cond, const T& t, L label) { cond = testMagic(cond, t); diff --git a/js/src/jit/arm64/MacroAssembler-arm64-inl.h b/js/src/jit/arm64/MacroAssembler-arm64-inl.h index feb3caea3e1..68910315539 100644 --- a/js/src/jit/arm64/MacroAssembler-arm64-inl.h +++ b/js/src/jit/arm64/MacroAssembler-arm64-inl.h @@ -976,6 +976,26 @@ MacroAssembler::branchTestDoubleTruthy(bool truthy, FloatRegister reg, Label* la } } +void +MacroAssembler::branchTestNumber(Condition cond, Register tag, Label* label) +{ + branchTestNumberImpl(cond, tag, label); +} + +void +MacroAssembler::branchTestNumber(Condition cond, const ValueOperand& value, Label* label) +{ + branchTestNumberImpl(cond, value, label); +} + +template +void +MacroAssembler::branchTestNumberImpl(Condition cond, const T& t, Label* label) +{ + Condition c = testNumber(cond, t); + B(label, c); +} + //}}} check_macroassembler_style // =============================================================== diff --git a/js/src/jit/arm64/MacroAssembler-arm64.h b/js/src/jit/arm64/MacroAssembler-arm64.h index 3c480d5ebb4..3f9bf94ca7b 100644 --- a/js/src/jit/arm64/MacroAssembler-arm64.h +++ b/js/src/jit/arm64/MacroAssembler-arm64.h @@ -1352,10 +1352,6 @@ class MacroAssemblerCompat : public vixl::MacroAssembler Condition c = testObject(cond, tag); B(label, c); } - void branchTestNumber(Condition cond, Register tag, Label* label) { - Condition c = testNumber(cond, tag); - B(label, c); - } void branchTestUndefined(Condition cond, const Address& address, Label* label) { Condition c = testUndefined(cond, address); @@ -1381,10 +1377,6 @@ class MacroAssemblerCompat : public vixl::MacroAssembler Condition c = testObject(cond, address); B(label, c); } - void branchTestNumber(Condition cond, const Address& address, Label* label) { - Condition c = testNumber(cond, address); - B(label, c); - } // Perform a type-test on a full Value loaded into a register. // Clobbers the ScratchReg. @@ -1412,10 +1404,6 @@ class MacroAssemblerCompat : public vixl::MacroAssembler Condition c = testObject(cond, src); B(label, c); } - void branchTestNumber(Condition cond, const ValueOperand& src, Label* label) { - Condition c = testNumber(cond, src); - B(label, c); - } // Perform a type-test on a Value addressed by BaseIndex. // Clobbers the ScratchReg. diff --git a/js/src/jit/mips-shared/MacroAssembler-mips-shared-inl.h b/js/src/jit/mips-shared/MacroAssembler-mips-shared-inl.h index 0060aa9354b..d034afb8b97 100644 --- a/js/src/jit/mips-shared/MacroAssembler-mips-shared-inl.h +++ b/js/src/jit/mips-shared/MacroAssembler-mips-shared-inl.h @@ -556,6 +556,14 @@ MacroAssembler::branchTestDoubleTruthy(bool b, FloatRegister value, Label* label ma_bc1d(value, ScratchDoubleReg, label, cond); } +void +MacroAssembler::branchTestNumber(Condition cond, Register tag, Label* label) +{ + MOZ_ASSERT(cond == Equal || cond == NotEqual); + Condition actual = cond == Equal ? BelowOrEqual : Above; + ma_b(tag, ImmTag(JSVAL_UPPER_INCL_TAG_OF_NUMBER_SET), label, actual); +} + //}}} check_macroassembler_style // =============================================================== diff --git a/js/src/jit/mips32/MacroAssembler-mips32-inl.h b/js/src/jit/mips32/MacroAssembler-mips32-inl.h index 4336ecc48fd..b62c3b493ef 100644 --- a/js/src/jit/mips32/MacroAssembler-mips32-inl.h +++ b/js/src/jit/mips32/MacroAssembler-mips32-inl.h @@ -316,6 +316,12 @@ MacroAssembler::branchTestDouble(Condition cond, const ValueOperand& value, Labe branchTestDouble(cond, value.typeReg(), label); } +void +MacroAssembler::branchTestNumber(Condition cond, const ValueOperand& value, Label* label) +{ + branchTestNumber(cond, value.typeReg(), label); +} + //}}} check_macroassembler_style // =============================================================== diff --git a/js/src/jit/mips32/MacroAssembler-mips32.cpp b/js/src/jit/mips32/MacroAssembler-mips32.cpp index 037221fd7b7..264b0fa3798 100644 --- a/js/src/jit/mips32/MacroAssembler-mips32.cpp +++ b/js/src/jit/mips32/MacroAssembler-mips32.cpp @@ -1309,20 +1309,6 @@ MacroAssemblerMIPSCompat::testUndefinedSet(Condition cond, const ValueOperand& v ma_cmp_set(dest, value.typeReg(), ImmType(JSVAL_TYPE_UNDEFINED), cond); } -void -MacroAssemblerMIPSCompat::branchTestNumber(Condition cond, const ValueOperand& value, Label* label) -{ - branchTestNumber(cond, value.typeReg(), label); -} - -void -MacroAssemblerMIPSCompat::branchTestNumber(Condition cond, Register tag, Label* label) -{ - MOZ_ASSERT(cond == Equal || cond == NotEqual); - ma_b(tag, ImmTag(JSVAL_UPPER_INCL_TAG_OF_NUMBER_SET), label, - cond == Equal ? BelowOrEqual : Above); -} - void MacroAssemblerMIPSCompat::branchTestMagic(Condition cond, const ValueOperand& value, Label* label) { diff --git a/js/src/jit/mips32/MacroAssembler-mips32.h b/js/src/jit/mips32/MacroAssembler-mips32.h index 862794dbf7c..698978c8099 100644 --- a/js/src/jit/mips32/MacroAssembler-mips32.h +++ b/js/src/jit/mips32/MacroAssembler-mips32.h @@ -407,9 +407,6 @@ class MacroAssemblerMIPSCompat : public MacroAssemblerMIPS void branchTestUndefined(Condition cond, const Address& address, Label* label); void testUndefinedSet(Condition cond, const ValueOperand& value, Register dest); - void branchTestNumber(Condition cond, const ValueOperand& value, Label* label); - void branchTestNumber(Condition cond, Register tag, Label* label); - void branchTestMagic(Condition cond, const ValueOperand& value, Label* label); void branchTestMagic(Condition cond, const ValueOperand& value, wasm::JumpTarget target); void branchTestMagic(Condition cond, Register tag, Label* label); diff --git a/js/src/jit/mips64/MacroAssembler-mips64-inl.h b/js/src/jit/mips64/MacroAssembler-mips64-inl.h index 811111a49dc..da1dfe15332 100644 --- a/js/src/jit/mips64/MacroAssembler-mips64-inl.h +++ b/js/src/jit/mips64/MacroAssembler-mips64-inl.h @@ -256,6 +256,14 @@ MacroAssembler::branchTestDouble(Condition cond, const ValueOperand& value, Labe branchTestDouble(cond, scratch2, label); } +void +MacroAssembler::branchTestNumber(Condition cond, const ValueOperand& value, Label* label) +{ + SecondScratchRegisterScope scratch2(*this); + splitTag(value, scratch2); + branchTestNumber(cond, scratch2, label); +} + //}}} check_macroassembler_style // =============================================================== diff --git a/js/src/jit/mips64/MacroAssembler-mips64.cpp b/js/src/jit/mips64/MacroAssembler-mips64.cpp index f9c20fb2572..d1210588dd7 100644 --- a/js/src/jit/mips64/MacroAssembler-mips64.cpp +++ b/js/src/jit/mips64/MacroAssembler-mips64.cpp @@ -1446,21 +1446,6 @@ MacroAssemblerMIPS64Compat::testUndefinedSet(Condition cond, const ValueOperand& ma_cmp_set(dest, SecondScratchReg, ImmTag(JSVAL_TAG_UNDEFINED), cond); } -void -MacroAssemblerMIPS64Compat::branchTestNumber(Condition cond, const ValueOperand& value, Label* label) -{ - splitTag(value, SecondScratchReg); - branchTestNumber(cond, SecondScratchReg, label); -} - -void -MacroAssemblerMIPS64Compat::branchTestNumber(Condition cond, Register tag, Label* label) -{ - MOZ_ASSERT(cond == Equal || cond == NotEqual); - ma_b(tag, ImmTag(JSVAL_UPPER_INCL_TAG_OF_NUMBER_SET), label, - cond == Equal ? BelowOrEqual : Above); -} - void MacroAssemblerMIPS64Compat::branchTestMagic(Condition cond, const ValueOperand& value, Label* label) { diff --git a/js/src/jit/mips64/MacroAssembler-mips64.h b/js/src/jit/mips64/MacroAssembler-mips64.h index fb0ba049f61..e6dec77c518 100644 --- a/js/src/jit/mips64/MacroAssembler-mips64.h +++ b/js/src/jit/mips64/MacroAssembler-mips64.h @@ -448,9 +448,6 @@ class MacroAssemblerMIPS64Compat : public MacroAssemblerMIPS64 void branchTestUndefined(Condition cond, const Address& address, Label* label); void testUndefinedSet(Condition cond, const ValueOperand& value, Register dest); - void branchTestNumber(Condition cond, const ValueOperand& value, Label* label); - void branchTestNumber(Condition cond, Register tag, Label* label); - void branchTestMagic(Condition cond, const ValueOperand& value, Label* label); void branchTestMagic(Condition cond, const ValueOperand& value, wasm::JumpTarget target); void branchTestMagic(Condition cond, Register tag, Label* label); diff --git a/js/src/jit/none/MacroAssembler-none.h b/js/src/jit/none/MacroAssembler-none.h index 535ff6dfb00..650b7ff0335 100644 --- a/js/src/jit/none/MacroAssembler-none.h +++ b/js/src/jit/none/MacroAssembler-none.h @@ -351,7 +351,6 @@ class MacroAssemblerNone : public Assembler template void branchTestString(Condition, T, Label*) { MOZ_CRASH(); } template void branchTestSymbol(Condition, T, Label*) { MOZ_CRASH(); } template void branchTestObject(Condition, T, Label*) { MOZ_CRASH(); } - template void branchTestNumber(Condition, T, Label*) { MOZ_CRASH(); } template void branchTestGCThing(Condition, T, Label*) { MOZ_CRASH(); } template void branchTestPrimitive(Condition, T, Label*) { MOZ_CRASH(); } template void branchTestMagic(Condition, T, L) { MOZ_CRASH(); } diff --git a/js/src/jit/x64/MacroAssembler-x64.h b/js/src/jit/x64/MacroAssembler-x64.h index 73aee088115..65039978370 100644 --- a/js/src/jit/x64/MacroAssembler-x64.h +++ b/js/src/jit/x64/MacroAssembler-x64.h @@ -710,10 +710,6 @@ class MacroAssemblerX64 : public MacroAssemblerX86Shared cond = testObject(cond, tag); j(cond, label); } - void branchTestNumber(Condition cond, Register tag, Label* label) { - cond = testNumber(cond, tag); - j(cond, label); - } // x64 can test for certain types directly from memory when the payload // of the type is limited to 32 bits. This avoids loading into a register, @@ -779,10 +775,6 @@ class MacroAssemblerX64 : public MacroAssemblerX86Shared cond = testObject(cond, src); j(cond, label); } - void branchTestNumber(Condition cond, const ValueOperand& src, Label* label) { - cond = testNumber(cond, src); - j(cond, label); - } // Perform a type-test on a Value addressed by BaseIndex. // Clobbers the ScratchReg. diff --git a/js/src/jit/x86-shared/MacroAssembler-x86-shared-inl.h b/js/src/jit/x86-shared/MacroAssembler-x86-shared-inl.h index cd4ec49be91..36091dae9db 100644 --- a/js/src/jit/x86-shared/MacroAssembler-x86-shared-inl.h +++ b/js/src/jit/x86-shared/MacroAssembler-x86-shared-inl.h @@ -506,6 +506,26 @@ MacroAssembler::branchTestDoubleTruthy(bool truthy, FloatRegister reg, Label* la j(cond, label); } +void +MacroAssembler::branchTestNumber(Condition cond, Register tag, Label* label) +{ + branchTestNumberImpl(cond, tag, label); +} + +void +MacroAssembler::branchTestNumber(Condition cond, const ValueOperand& value, Label* label) +{ + branchTestNumberImpl(cond, value, label); +} + +template +void +MacroAssembler::branchTestNumberImpl(Condition cond, const T& t, Label* label) +{ + cond = testNumber(cond, t); + j(cond, label); +} + //}}} check_macroassembler_style // =============================================================== diff --git a/js/src/jit/x86/MacroAssembler-x86.h b/js/src/jit/x86/MacroAssembler-x86.h index ac627556aea..b6c7dcd98df 100644 --- a/js/src/jit/x86/MacroAssembler-x86.h +++ b/js/src/jit/x86/MacroAssembler-x86.h @@ -690,11 +690,6 @@ class MacroAssemblerX86 : public MacroAssemblerX86Shared j(cond, label); } template - void branchTestNumber(Condition cond, const T& t, Label* label) { - cond = testNumber(cond, t); - j(cond, label); - } - template void branchTestGCThing(Condition cond, const T& t, Label* label) { cond = testGCThing(cond, t); j(cond, label); From d594a12e1302719bfeecdcc85b5d32a9da0aa0fb Mon Sep 17 00:00:00 2001 From: Tooru Fujisawa Date: Thu, 3 Mar 2016 08:03:42 +0900 Subject: [PATCH 124/160] Bug 1245112 - Part 23: Move MacroAssembler::branchTestBoolean into generic macro assembler. r=sstangl --- js/src/jit/MacroAssembler.h | 9 ++++++ js/src/jit/arm/MacroAssembler-arm-inl.h | 32 +++++++++++++++++++ js/src/jit/arm/MacroAssembler-arm.h | 5 --- js/src/jit/arm64/MacroAssembler-arm64-inl.h | 32 +++++++++++++++++++ js/src/jit/arm64/MacroAssembler-arm64.h | 16 ---------- .../MacroAssembler-mips-shared-inl.h | 23 +++++++++++++ js/src/jit/mips32/MacroAssembler-mips32-inl.h | 7 ++++ js/src/jit/mips32/MacroAssembler-mips32.cpp | 31 ------------------ js/src/jit/mips32/MacroAssembler-mips32.h | 6 ---- js/src/jit/mips64/MacroAssembler-mips64-inl.h | 8 +++++ js/src/jit/mips64/MacroAssembler-mips64.cpp | 32 ------------------- js/src/jit/mips64/MacroAssembler-mips64.h | 6 ---- js/src/jit/none/MacroAssembler-none.h | 1 - js/src/jit/x64/MacroAssembler-x64.h | 28 ++-------------- .../MacroAssembler-x86-shared-inl.h | 32 +++++++++++++++++++ js/src/jit/x86/MacroAssembler-x86.h | 5 --- 16 files changed, 145 insertions(+), 128 deletions(-) diff --git a/js/src/jit/MacroAssembler.h b/js/src/jit/MacroAssembler.h index 97ef01b987b..98537aafd7a 100644 --- a/js/src/jit/MacroAssembler.h +++ b/js/src/jit/MacroAssembler.h @@ -927,6 +927,7 @@ class MacroAssembler : public MacroAssemblerSpecific inline void branchTestDouble(Condition cond, Register tag, Label* label) DEFINED_ON(arm, arm64, mips32, mips64, x86_shared); inline void branchTestNumber(Condition cond, Register tag, Label* label) PER_SHARED_ARCH; + inline void branchTestBoolean(Condition cond, Register tag, Label* label) PER_SHARED_ARCH; // Perform a type-test on a Value, addressed by Address or BaseIndex, or // loaded into ValueOperand. @@ -943,6 +944,11 @@ class MacroAssembler : public MacroAssemblerSpecific inline void branchTestNumber(Condition cond, const ValueOperand& value, Label* label) DEFINED_ON(arm, arm64, mips32, mips64, x86_shared); + inline void branchTestBoolean(Condition cond, const Address& address, Label* label) PER_SHARED_ARCH; + inline void branchTestBoolean(Condition cond, const BaseIndex& address, Label* label) PER_SHARED_ARCH; + inline void branchTestBoolean(Condition cond, const ValueOperand& value, Label* label) + DEFINED_ON(arm, arm64, mips32, mips64, x86_shared); + // Checks if given Value is evaluated to true or false in a condition. // The type of the value should match the type of the method. inline void branchTestInt32Truthy(bool truthy, const ValueOperand& value, Label* label) @@ -961,6 +967,9 @@ class MacroAssembler : public MacroAssemblerSpecific template inline void branchTestNumberImpl(Condition cond, const T& t, Label* label) DEFINED_ON(arm, arm64, x86_shared); + template + inline void branchTestBooleanImpl(Condition cond, const T& t, Label* label) + DEFINED_ON(arm, arm64, x86_shared); //}}} check_macroassembler_style public: diff --git a/js/src/jit/arm/MacroAssembler-arm-inl.h b/js/src/jit/arm/MacroAssembler-arm-inl.h index c90d3824a8e..8e806580745 100644 --- a/js/src/jit/arm/MacroAssembler-arm-inl.h +++ b/js/src/jit/arm/MacroAssembler-arm-inl.h @@ -897,6 +897,38 @@ MacroAssembler::branchTestNumberImpl(Condition cond, const T& t, Label* label) ma_b(label, cond); } +void +MacroAssembler::branchTestBoolean(Condition cond, Register tag, Label* label) +{ + branchTestBooleanImpl(cond, tag, label); +} + +void +MacroAssembler::branchTestBoolean(Condition cond, const Address& address, Label* label) +{ + branchTestBooleanImpl(cond, address, label); +} + +void +MacroAssembler::branchTestBoolean(Condition cond, const BaseIndex& address, Label* label) +{ + branchTestBooleanImpl(cond, address, label); +} + +void +MacroAssembler::branchTestBoolean(Condition cond, const ValueOperand& value, Label* label) +{ + branchTestBooleanImpl(cond, value, label); +} + +template +void +MacroAssembler::branchTestBooleanImpl(Condition cond, const T& t, Label* label) +{ + Condition c = testBoolean(cond, t); + ma_b(label, c); +} + //}}} check_macroassembler_style // =============================================================== diff --git a/js/src/jit/arm/MacroAssembler-arm.h b/js/src/jit/arm/MacroAssembler-arm.h index 29224f6f1d0..34b08e697e2 100644 --- a/js/src/jit/arm/MacroAssembler-arm.h +++ b/js/src/jit/arm/MacroAssembler-arm.h @@ -762,11 +762,6 @@ class MacroAssemblerARMCompat : public MacroAssemblerARM void int32ValueToFloat32(const ValueOperand& operand, FloatRegister dest); void loadConstantFloat32(float f, FloatRegister dest); - template - void branchTestBoolean(Condition cond, const T & t, Label* label) { - Condition c = testBoolean(cond, t); - ma_b(label, c); - } template void branchTestNull(Condition cond, const T & t, Label* label) { Condition c = testNull(cond, t); diff --git a/js/src/jit/arm64/MacroAssembler-arm64-inl.h b/js/src/jit/arm64/MacroAssembler-arm64-inl.h index 68910315539..8818df85a39 100644 --- a/js/src/jit/arm64/MacroAssembler-arm64-inl.h +++ b/js/src/jit/arm64/MacroAssembler-arm64-inl.h @@ -996,6 +996,38 @@ MacroAssembler::branchTestNumberImpl(Condition cond, const T& t, Label* label) B(label, c); } +void +MacroAssembler::branchTestBoolean(Condition cond, Register tag, Label* label) +{ + branchTestBooleanImpl(cond, tag, label); +} + +void +MacroAssembler::branchTestBoolean(Condition cond, const Address& address, Label* label) +{ + branchTestBooleanImpl(cond, address, label); +} + +void +MacroAssembler::branchTestBoolean(Condition cond, const BaseIndex& address, Label* label) +{ + branchTestBooleanImpl(cond, address, label); +} + +void +MacroAssembler::branchTestBoolean(Condition cond, const ValueOperand& value, Label* label) +{ + branchTestBooleanImpl(cond, value, label); +} + +template +void +MacroAssembler::branchTestBooleanImpl(Condition cond, const T& tag, Label* label) +{ + Condition c = testBoolean(cond, tag); + B(label, c); +} + //}}} check_macroassembler_style // =============================================================== diff --git a/js/src/jit/arm64/MacroAssembler-arm64.h b/js/src/jit/arm64/MacroAssembler-arm64.h index 3f9bf94ca7b..65347cd9e39 100644 --- a/js/src/jit/arm64/MacroAssembler-arm64.h +++ b/js/src/jit/arm64/MacroAssembler-arm64.h @@ -1332,10 +1332,6 @@ class MacroAssemblerCompat : public vixl::MacroAssembler Condition c = testUndefined(cond, tag); B(label, c); } - void branchTestBoolean(Condition cond, Register tag, Label* label) { - Condition c = testBoolean(cond, tag); - B(label, c); - } void branchTestNull(Condition cond, Register tag, Label* label) { Condition c = testNull(cond, tag); B(label, c); @@ -1357,10 +1353,6 @@ class MacroAssemblerCompat : public vixl::MacroAssembler Condition c = testUndefined(cond, address); B(label, c); } - void branchTestBoolean(Condition cond, const Address& address, Label* label) { - Condition c = testDouble(cond, address); - B(label, c); - } void branchTestNull(Condition cond, const Address& address, Label* label) { Condition c = testNull(cond, address); B(label, c); @@ -1384,10 +1376,6 @@ class MacroAssemblerCompat : public vixl::MacroAssembler Condition c = testUndefined(cond, src); B(label, c); } - void branchTestBoolean(Condition cond, const ValueOperand& src, Label* label) { - Condition c = testBoolean(cond, src); - B(label, c); - } void branchTestNull(Condition cond, const ValueOperand& src, Label* label) { Condition c = testNull(cond, src); B(label, c); @@ -1411,10 +1399,6 @@ class MacroAssemblerCompat : public vixl::MacroAssembler Condition c = testUndefined(cond, address); B(label, c); } - void branchTestBoolean(Condition cond, const BaseIndex& address, Label* label) { - Condition c = testBoolean(cond, address); - B(label, c); - } void branchTestNull(Condition cond, const BaseIndex& address, Label* label) { Condition c = testNull(cond, address); B(label, c); diff --git a/js/src/jit/mips-shared/MacroAssembler-mips-shared-inl.h b/js/src/jit/mips-shared/MacroAssembler-mips-shared-inl.h index d034afb8b97..891aff8e3a4 100644 --- a/js/src/jit/mips-shared/MacroAssembler-mips-shared-inl.h +++ b/js/src/jit/mips-shared/MacroAssembler-mips-shared-inl.h @@ -564,6 +564,29 @@ MacroAssembler::branchTestNumber(Condition cond, Register tag, Label* label) ma_b(tag, ImmTag(JSVAL_UPPER_INCL_TAG_OF_NUMBER_SET), label, actual); } +void +MacroAssembler::branchTestBoolean(Condition cond, Register tag, Label* label) +{ + MOZ_ASSERT(cond == Equal || cond == NotEqual); + ma_b(tag, ImmTag(JSVAL_TAG_BOOLEAN), label, cond); +} + +void +MacroAssembler::branchTestBoolean(Condition cond, const Address& address, Label* label) +{ + SecondScratchRegisterScope scratch2(*this); + extractTag(address, scratch2); + branchTestBoolean(cond, scratch2, label); +} + +void +MacroAssembler::branchTestBoolean(Condition cond, const BaseIndex& address, Label* label) +{ + SecondScratchRegisterScope scratch2(*this); + extractTag(address, scratch2); + branchTestBoolean(cond, scratch2, label); +} + //}}} check_macroassembler_style // =============================================================== diff --git a/js/src/jit/mips32/MacroAssembler-mips32-inl.h b/js/src/jit/mips32/MacroAssembler-mips32-inl.h index b62c3b493ef..e8486caa6b6 100644 --- a/js/src/jit/mips32/MacroAssembler-mips32-inl.h +++ b/js/src/jit/mips32/MacroAssembler-mips32-inl.h @@ -322,6 +322,13 @@ MacroAssembler::branchTestNumber(Condition cond, const ValueOperand& value, Labe branchTestNumber(cond, value.typeReg(), label); } +void +MacroAssembler::branchTestBoolean(Condition cond, const ValueOperand& value, Label* label) +{ + MOZ_ASSERT(cond == Equal || cond == NotEqual); + ma_b(value.typeReg(), ImmType(JSVAL_TYPE_BOOLEAN), label, cond); +} + //}}} check_macroassembler_style // =============================================================== diff --git a/js/src/jit/mips32/MacroAssembler-mips32.cpp b/js/src/jit/mips32/MacroAssembler-mips32.cpp index 264b0fa3798..4f4314ddc11 100644 --- a/js/src/jit/mips32/MacroAssembler-mips32.cpp +++ b/js/src/jit/mips32/MacroAssembler-mips32.cpp @@ -1126,37 +1126,6 @@ MacroAssemblerMIPSCompat::branchTestPrimitive(Condition cond, Register tag, Labe (cond == Equal) ? Below : AboveOrEqual); } -void -MacroAssemblerMIPSCompat:: branchTestBoolean(Condition cond, const ValueOperand& value, - Label* label) -{ - MOZ_ASSERT(cond == Assembler::Equal || cond == Assembler::NotEqual); - ma_b(value.typeReg(), ImmType(JSVAL_TYPE_BOOLEAN), label, cond); -} - -void -MacroAssemblerMIPSCompat:: branchTestBoolean(Condition cond, Register tag, Label* label) -{ - MOZ_ASSERT(cond == Assembler::Equal || cond == Assembler::NotEqual); - ma_b(tag, ImmType(JSVAL_TYPE_BOOLEAN), label, cond); -} - -void -MacroAssemblerMIPSCompat::branchTestBoolean(Condition cond, const Address& address, Label* label) -{ - MOZ_ASSERT(cond == Equal || cond == NotEqual); - extractTag(address, SecondScratchReg); - ma_b(SecondScratchReg, ImmTag(JSVAL_TAG_BOOLEAN), label, cond); -} - -void -MacroAssemblerMIPSCompat::branchTestBoolean(Condition cond, const BaseIndex& src, Label* label) -{ - MOZ_ASSERT(cond == Equal || cond == NotEqual); - extractTag(src, SecondScratchReg); - ma_b(SecondScratchReg, ImmType(JSVAL_TYPE_BOOLEAN), label, cond); -} - void MacroAssemblerMIPSCompat::branchTestNull(Condition cond, const ValueOperand& value, Label* label) { diff --git a/js/src/jit/mips32/MacroAssembler-mips32.h b/js/src/jit/mips32/MacroAssembler-mips32.h index 698978c8099..4d5f4de89a6 100644 --- a/js/src/jit/mips32/MacroAssembler-mips32.h +++ b/js/src/jit/mips32/MacroAssembler-mips32.h @@ -375,12 +375,6 @@ class MacroAssemblerMIPSCompat : public MacroAssemblerMIPS void int32ValueToFloat32(const ValueOperand& operand, FloatRegister dest); void loadConstantFloat32(float f, FloatRegister dest); - void branchTestBoolean(Condition cond, const ValueOperand& value, Label* label); - void branchTestBoolean(Condition cond, Register tag, Label* label); - void branchTestBoolean(Condition cond, const Address& address, Label* label); - void branchTestBoolean(Condition cond, const BaseIndex& src, Label* label); - - void branchTestNull(Condition cond, const ValueOperand& value, Label* label); void branchTestNull(Condition cond, Register tag, Label* label); void branchTestNull(Condition cond, const BaseIndex& src, Label* label); diff --git a/js/src/jit/mips64/MacroAssembler-mips64-inl.h b/js/src/jit/mips64/MacroAssembler-mips64-inl.h index da1dfe15332..5fe26c750b9 100644 --- a/js/src/jit/mips64/MacroAssembler-mips64-inl.h +++ b/js/src/jit/mips64/MacroAssembler-mips64-inl.h @@ -264,6 +264,14 @@ MacroAssembler::branchTestNumber(Condition cond, const ValueOperand& value, Labe branchTestNumber(cond, scratch2, label); } +void +MacroAssembler::branchTestBoolean(Condition cond, const ValueOperand& value, Label* label) +{ + SecondScratchRegisterScope scratch2(*this); + splitTag(value, scratch2); + branchTestBoolean(cond, scratch2, label); +} + //}}} check_macroassembler_style // =============================================================== diff --git a/js/src/jit/mips64/MacroAssembler-mips64.cpp b/js/src/jit/mips64/MacroAssembler-mips64.cpp index d1210588dd7..52c42fdb50f 100644 --- a/js/src/jit/mips64/MacroAssembler-mips64.cpp +++ b/js/src/jit/mips64/MacroAssembler-mips64.cpp @@ -1254,38 +1254,6 @@ MacroAssemblerMIPS64Compat::branchTestPrimitive(Condition cond, Register tag, La (cond == Equal) ? Below : AboveOrEqual); } -void -MacroAssemblerMIPS64Compat:: branchTestBoolean(Condition cond, const ValueOperand& value, - Label* label) -{ - MOZ_ASSERT(cond == Assembler::Equal || cond == Assembler::NotEqual); - splitTag(value, SecondScratchReg); - ma_b(SecondScratchReg, ImmTag(JSVAL_TAG_BOOLEAN), label, cond); -} - -void -MacroAssemblerMIPS64Compat:: branchTestBoolean(Condition cond, Register tag, Label* label) -{ - MOZ_ASSERT(cond == Assembler::Equal || cond == Assembler::NotEqual); - ma_b(tag, ImmTag(JSVAL_TAG_BOOLEAN), label, cond); -} - -void -MacroAssemblerMIPS64Compat::branchTestBoolean(Condition cond, const Address& address, Label* label) -{ - MOZ_ASSERT(cond == Equal || cond == NotEqual); - extractTag(address, SecondScratchReg); - ma_b(SecondScratchReg, ImmTag(JSVAL_TAG_BOOLEAN), label, cond); -} - -void -MacroAssemblerMIPS64Compat::branchTestBoolean(Condition cond, const BaseIndex& src, Label* label) -{ - MOZ_ASSERT(cond == Equal || cond == NotEqual); - extractTag(src, SecondScratchReg); - ma_b(SecondScratchReg, ImmTag(JSVAL_TAG_BOOLEAN), label, cond); -} - void MacroAssemblerMIPS64Compat::branchTestNull(Condition cond, const ValueOperand& value, Label* label) { diff --git a/js/src/jit/mips64/MacroAssembler-mips64.h b/js/src/jit/mips64/MacroAssembler-mips64.h index e6dec77c518..64c857b365d 100644 --- a/js/src/jit/mips64/MacroAssembler-mips64.h +++ b/js/src/jit/mips64/MacroAssembler-mips64.h @@ -416,12 +416,6 @@ class MacroAssemblerMIPS64Compat : public MacroAssemblerMIPS64 void int32ValueToFloat32(const ValueOperand& operand, FloatRegister dest); void loadConstantFloat32(float f, FloatRegister dest); - void branchTestBoolean(Condition cond, const ValueOperand& value, Label* label); - void branchTestBoolean(Condition cond, Register tag, Label* label); - void branchTestBoolean(Condition cond, const Address& address, Label* label); - void branchTestBoolean(Condition cond, const BaseIndex& src, Label* label); - - void branchTestNull(Condition cond, const ValueOperand& value, Label* label); void branchTestNull(Condition cond, Register tag, Label* label); void branchTestNull(Condition cond, const BaseIndex& src, Label* label); diff --git a/js/src/jit/none/MacroAssembler-none.h b/js/src/jit/none/MacroAssembler-none.h index 650b7ff0335..bf789720b71 100644 --- a/js/src/jit/none/MacroAssembler-none.h +++ b/js/src/jit/none/MacroAssembler-none.h @@ -346,7 +346,6 @@ class MacroAssemblerNone : public Assembler Register splitTagForTest(ValueOperand) { MOZ_CRASH(); } template void branchTestUndefined(Condition, T, Label*) { MOZ_CRASH(); } - template void branchTestBoolean(Condition, T, Label*) { MOZ_CRASH(); } template void branchTestNull(Condition, T, Label*) { MOZ_CRASH(); } template void branchTestString(Condition, T, Label*) { MOZ_CRASH(); } template void branchTestSymbol(Condition, T, Label*) { MOZ_CRASH(); } diff --git a/js/src/jit/x64/MacroAssembler-x64.h b/js/src/jit/x64/MacroAssembler-x64.h index 65039978370..e1e95bf7eb4 100644 --- a/js/src/jit/x64/MacroAssembler-x64.h +++ b/js/src/jit/x64/MacroAssembler-x64.h @@ -333,9 +333,8 @@ class MacroAssemblerX64 : public MacroAssemblerX86Shared return cond; } Condition testBoolean(Condition cond, const Address& src) { - ScratchRegisterScope scratch(asMasm()); - splitTag(src, scratch); - return testBoolean(cond, scratch); + cmp32(ToUpper32(src), Imm32(Upper32Of(GetShiftedTag(JSVAL_TYPE_BOOLEAN)))); + return cond; } Condition testDouble(Condition cond, const Address& src) { ScratchRegisterScope scratch(asMasm()); @@ -690,10 +689,6 @@ class MacroAssemblerX64 : public MacroAssemblerX86Shared cond = testUndefined(cond, tag); j(cond, label); } - void branchTestBoolean(Condition cond, Register tag, Label* label) { - cond = testBoolean(cond, tag); - j(cond, label); - } void branchTestNull(Condition cond, Register tag, Label* label) { cond = testNull(cond, tag); j(cond, label); @@ -723,15 +718,6 @@ class MacroAssemblerX64 : public MacroAssemblerX86Shared MOZ_ASSERT(cond == Equal || cond == NotEqual); branchTestUndefined(cond, Operand(address), label); } - void branchTestBoolean(Condition cond, const Operand& operand, Label* label) { - MOZ_ASSERT(cond == Equal || cond == NotEqual); - cmp32(ToUpper32(operand), Imm32(Upper32Of(GetShiftedTag(JSVAL_TYPE_BOOLEAN)))); - j(cond, label); - } - void branchTestBoolean(Condition cond, const Address& address, Label* label) { - MOZ_ASSERT(cond == Equal || cond == NotEqual); - branchTestBoolean(cond, Operand(address), label); - } void branchTestNull(Condition cond, const Operand& operand, Label* label) { MOZ_ASSERT(cond == Equal || cond == NotEqual); cmp32(ToUpper32(operand), Imm32(Upper32Of(GetShiftedTag(JSVAL_TYPE_NULL)))); @@ -754,11 +740,6 @@ class MacroAssemblerX64 : public MacroAssemblerX86Shared cond = testUndefined(cond, src); j(cond, label); } - void branchTestBoolean(Condition cond, const ValueOperand& src, Label* label) { - ScratchRegisterScope scratch(asMasm()); - splitTag(src, scratch); - branchTestBoolean(cond, scratch, label); - } void branchTestNull(Condition cond, const ValueOperand& src, Label* label) { cond = testNull(cond, src); j(cond, label); @@ -782,11 +763,6 @@ class MacroAssemblerX64 : public MacroAssemblerX86Shared cond = testUndefined(cond, address); j(cond, label); } - void branchTestBoolean(Condition cond, const BaseIndex& address, Label* label) { - ScratchRegisterScope scratch(asMasm()); - splitTag(address, scratch); - branchTestBoolean(cond, scratch, label); - } void branchTestNull(Condition cond, const BaseIndex& address, Label* label) { cond = testNull(cond, address); j(cond, label); diff --git a/js/src/jit/x86-shared/MacroAssembler-x86-shared-inl.h b/js/src/jit/x86-shared/MacroAssembler-x86-shared-inl.h index 36091dae9db..2686c183465 100644 --- a/js/src/jit/x86-shared/MacroAssembler-x86-shared-inl.h +++ b/js/src/jit/x86-shared/MacroAssembler-x86-shared-inl.h @@ -526,6 +526,38 @@ MacroAssembler::branchTestNumberImpl(Condition cond, const T& t, Label* label) j(cond, label); } +void +MacroAssembler::branchTestBoolean(Condition cond, Register tag, Label* label) +{ + branchTestBooleanImpl(cond, tag, label); +} + +void +MacroAssembler::branchTestBoolean(Condition cond, const Address& address, Label* label) +{ + branchTestBooleanImpl(cond, address, label); +} + +void +MacroAssembler::branchTestBoolean(Condition cond, const BaseIndex& address, Label* label) +{ + branchTestBooleanImpl(cond, address, label); +} + +void +MacroAssembler::branchTestBoolean(Condition cond, const ValueOperand& value, Label* label) +{ + branchTestBooleanImpl(cond, value, label); +} + +template +void +MacroAssembler::branchTestBooleanImpl(Condition cond, const T& t, Label* label) +{ + cond = testBoolean(cond, t); + j(cond, label); +} + //}}} check_macroassembler_style // =============================================================== diff --git a/js/src/jit/x86/MacroAssembler-x86.h b/js/src/jit/x86/MacroAssembler-x86.h index b6c7dcd98df..df7f36d3b3c 100644 --- a/js/src/jit/x86/MacroAssembler-x86.h +++ b/js/src/jit/x86/MacroAssembler-x86.h @@ -665,11 +665,6 @@ class MacroAssemblerX86 : public MacroAssemblerX86Shared j(cond, label); } template - void branchTestBoolean(Condition cond, const T& t, Label* label) { - cond = testBoolean(cond, t); - j(cond, label); - } - template void branchTestNull(Condition cond, const T& t, Label* label) { cond = testNull(cond, t); j(cond, label); From 425b26d13ee0a9df0867df8e3252937187497bea Mon Sep 17 00:00:00 2001 From: Tooru Fujisawa Date: Thu, 3 Mar 2016 08:03:43 +0900 Subject: [PATCH 125/160] Bug 1245112 - Part 24: Move MacroAssembler::branchTestBooleanTruthy into generic macro assembler. r=sstangl --- js/src/jit/MacroAssembler.h | 1 + js/src/jit/arm/MacroAssembler-arm-inl.h | 7 +++++++ js/src/jit/arm/MacroAssembler-arm.h | 4 ---- js/src/jit/arm64/MacroAssembler-arm64-inl.h | 7 +++++++ js/src/jit/arm64/MacroAssembler-arm64.h | 4 ---- js/src/jit/mips32/MacroAssembler-mips32-inl.h | 6 ++++++ js/src/jit/mips32/MacroAssembler-mips32.cpp | 7 ------- js/src/jit/mips32/MacroAssembler-mips32.h | 2 -- js/src/jit/mips64/MacroAssembler-mips64-inl.h | 8 ++++++++ js/src/jit/mips64/MacroAssembler-mips64.cpp | 8 -------- js/src/jit/mips64/MacroAssembler-mips64.h | 2 -- js/src/jit/none/MacroAssembler-none.h | 1 - js/src/jit/x64/MacroAssembler-x64-inl.h | 7 +++++++ js/src/jit/x64/MacroAssembler-x64.h | 4 ---- js/src/jit/x86/MacroAssembler-x86-inl.h | 7 +++++++ js/src/jit/x86/MacroAssembler-x86.h | 4 ---- 16 files changed, 43 insertions(+), 36 deletions(-) diff --git a/js/src/jit/MacroAssembler.h b/js/src/jit/MacroAssembler.h index 98537aafd7a..a391e758ae0 100644 --- a/js/src/jit/MacroAssembler.h +++ b/js/src/jit/MacroAssembler.h @@ -954,6 +954,7 @@ class MacroAssembler : public MacroAssemblerSpecific inline void branchTestInt32Truthy(bool truthy, const ValueOperand& value, Label* label) DEFINED_ON(arm, arm64, mips32, mips64, x86_shared); inline void branchTestDoubleTruthy(bool truthy, FloatRegister reg, Label* label) PER_SHARED_ARCH; + inline void branchTestBooleanTruthy(bool truthy, const ValueOperand& value, Label* label) PER_ARCH; private: diff --git a/js/src/jit/arm/MacroAssembler-arm-inl.h b/js/src/jit/arm/MacroAssembler-arm-inl.h index 8e806580745..63902612f86 100644 --- a/js/src/jit/arm/MacroAssembler-arm-inl.h +++ b/js/src/jit/arm/MacroAssembler-arm-inl.h @@ -929,6 +929,13 @@ MacroAssembler::branchTestBooleanImpl(Condition cond, const T& t, Label* label) ma_b(label, c); } +void +MacroAssembler::branchTestBooleanTruthy(bool truthy, const ValueOperand& value, Label* label) +{ + Condition c = testBooleanTruthy(truthy, value); + ma_b(label, c); +} + //}}} check_macroassembler_style // =============================================================== diff --git a/js/src/jit/arm/MacroAssembler-arm.h b/js/src/jit/arm/MacroAssembler-arm.h index 34b08e697e2..e4ce078f3fd 100644 --- a/js/src/jit/arm/MacroAssembler-arm.h +++ b/js/src/jit/arm/MacroAssembler-arm.h @@ -797,10 +797,6 @@ class MacroAssemblerARMCompat : public MacroAssemblerARM MOZ_ASSERT(cond == Equal || cond == NotEqual); branchTestValue(cond, val, MagicValue(why), label); } - void branchTestBooleanTruthy(bool truthy, const ValueOperand& operand, Label* label) { - Condition c = testBooleanTruthy(truthy, operand); - ma_b(label, c); - } void branchTestStringTruthy(bool truthy, const ValueOperand& value, Label* label) { Condition c = testStringTruthy(truthy, value); ma_b(label, c); diff --git a/js/src/jit/arm64/MacroAssembler-arm64-inl.h b/js/src/jit/arm64/MacroAssembler-arm64-inl.h index 8818df85a39..9d6e53ac3f1 100644 --- a/js/src/jit/arm64/MacroAssembler-arm64-inl.h +++ b/js/src/jit/arm64/MacroAssembler-arm64-inl.h @@ -1028,6 +1028,13 @@ MacroAssembler::branchTestBooleanImpl(Condition cond, const T& tag, Label* label B(label, c); } +void +MacroAssembler::branchTestBooleanTruthy(bool truthy, const ValueOperand& value, Label* label) +{ + Condition c = testBooleanTruthy(truthy, value); + B(label, c); +} + //}}} check_macroassembler_style // =============================================================== diff --git a/js/src/jit/arm64/MacroAssembler-arm64.h b/js/src/jit/arm64/MacroAssembler-arm64.h index 65347cd9e39..c0f3a3386ed 100644 --- a/js/src/jit/arm64/MacroAssembler-arm64.h +++ b/js/src/jit/arm64/MacroAssembler-arm64.h @@ -1925,10 +1925,6 @@ class MacroAssemblerCompat : public vixl::MacroAssembler Tst(payload32, payload32); return truthy ? NonZero : Zero; } - void branchTestBooleanTruthy(bool truthy, const ValueOperand& operand, Label* label) { - Condition c = testBooleanTruthy(truthy, operand); - B(label, c); - } Condition testStringTruthy(bool truthy, const ValueOperand& value) { vixl::UseScratchRegisterScope temps(this); const Register scratch = temps.AcquireX().asUnsized(); diff --git a/js/src/jit/mips32/MacroAssembler-mips32-inl.h b/js/src/jit/mips32/MacroAssembler-mips32-inl.h index e8486caa6b6..fa3c032795c 100644 --- a/js/src/jit/mips32/MacroAssembler-mips32-inl.h +++ b/js/src/jit/mips32/MacroAssembler-mips32-inl.h @@ -329,6 +329,12 @@ MacroAssembler::branchTestBoolean(Condition cond, const ValueOperand& value, Lab ma_b(value.typeReg(), ImmType(JSVAL_TYPE_BOOLEAN), label, cond); } +void +MacroAssembler::branchTestBooleanTruthy(bool b, const ValueOperand& value, Label* label) +{ + ma_b(value.payloadReg(), value.payloadReg(), label, b ? NonZero : Zero); +} + //}}} check_macroassembler_style // =============================================================== diff --git a/js/src/jit/mips32/MacroAssembler-mips32.cpp b/js/src/jit/mips32/MacroAssembler-mips32.cpp index 4f4314ddc11..15904b2a7b5 100644 --- a/js/src/jit/mips32/MacroAssembler-mips32.cpp +++ b/js/src/jit/mips32/MacroAssembler-mips32.cpp @@ -1568,13 +1568,6 @@ MacroAssemblerMIPSCompat::branchTestStringTruthy(bool b, const ValueOperand& val ma_b(SecondScratchReg, Imm32(0), label, b ? NotEqual : Equal); } -void -MacroAssemblerMIPSCompat::branchTestBooleanTruthy(bool b, const ValueOperand& operand, - Label* label) -{ - ma_b(operand.payloadReg(), operand.payloadReg(), label, b ? NonZero : Zero); -} - Register MacroAssemblerMIPSCompat::extractObject(const Address& address, Register scratch) { diff --git a/js/src/jit/mips32/MacroAssembler-mips32.h b/js/src/jit/mips32/MacroAssembler-mips32.h index 4d5f4de89a6..9d362eac9f6 100644 --- a/js/src/jit/mips32/MacroAssembler-mips32.h +++ b/js/src/jit/mips32/MacroAssembler-mips32.h @@ -415,8 +415,6 @@ class MacroAssemblerMIPSCompat : public MacroAssemblerMIPS void branchTestStringTruthy(bool b, const ValueOperand& value, Label* label); - void branchTestBooleanTruthy(bool b, const ValueOperand& operand, Label* label); - // higher level tag testing code Operand ToPayload(Operand base); Address ToPayload(Address base) { diff --git a/js/src/jit/mips64/MacroAssembler-mips64-inl.h b/js/src/jit/mips64/MacroAssembler-mips64-inl.h index 5fe26c750b9..3436d09703d 100644 --- a/js/src/jit/mips64/MacroAssembler-mips64-inl.h +++ b/js/src/jit/mips64/MacroAssembler-mips64-inl.h @@ -272,6 +272,14 @@ MacroAssembler::branchTestBoolean(Condition cond, const ValueOperand& value, Lab branchTestBoolean(cond, scratch2, label); } +void +MacroAssembler::branchTestBooleanTruthy(bool b, const ValueOperand& value, Label* label) +{ + SecondScratchRegisterScope scratch2(*this); + unboxBoolean(value, scratch2); + ma_b(scratch2, scratch2, label, b ? NonZero : Zero); +} + //}}} check_macroassembler_style // =============================================================== diff --git a/js/src/jit/mips64/MacroAssembler-mips64.cpp b/js/src/jit/mips64/MacroAssembler-mips64.cpp index 52c42fdb50f..6aac755ea4e 100644 --- a/js/src/jit/mips64/MacroAssembler-mips64.cpp +++ b/js/src/jit/mips64/MacroAssembler-mips64.cpp @@ -1790,14 +1790,6 @@ MacroAssemblerMIPS64Compat::branchTestStringTruthy(bool b, const ValueOperand& v ma_b(SecondScratchReg, Imm32(0), label, b ? NotEqual : Equal); } -void -MacroAssemblerMIPS64Compat::branchTestBooleanTruthy(bool b, const ValueOperand& operand, - Label* label) -{ - unboxBoolean(operand, SecondScratchReg); - ma_b(SecondScratchReg, SecondScratchReg, label, b ? NonZero : Zero); -} - Register MacroAssemblerMIPS64Compat::extractObject(const Address& address, Register scratch) { diff --git a/js/src/jit/mips64/MacroAssembler-mips64.h b/js/src/jit/mips64/MacroAssembler-mips64.h index 64c857b365d..61044746efa 100644 --- a/js/src/jit/mips64/MacroAssembler-mips64.h +++ b/js/src/jit/mips64/MacroAssembler-mips64.h @@ -456,8 +456,6 @@ class MacroAssemblerMIPS64Compat : public MacroAssemblerMIPS64 void branchTestStringTruthy(bool b, const ValueOperand& value, Label* label); - void branchTestBooleanTruthy(bool b, const ValueOperand& operand, Label* label); - // higher level tag testing code Address ToPayload(Address value) { return value; diff --git a/js/src/jit/none/MacroAssembler-none.h b/js/src/jit/none/MacroAssembler-none.h index bf789720b71..ba75c2a2802 100644 --- a/js/src/jit/none/MacroAssembler-none.h +++ b/js/src/jit/none/MacroAssembler-none.h @@ -391,7 +391,6 @@ class MacroAssemblerNone : public Assembler void loadConstantFloat32(float, FloatRegister) { MOZ_CRASH(); } Condition testInt32Truthy(bool, ValueOperand) { MOZ_CRASH(); } Condition testStringTruthy(bool, ValueOperand) { MOZ_CRASH(); } - void branchTestBooleanTruthy(bool, ValueOperand, Label*) { MOZ_CRASH(); } void branchTestStringTruthy(bool, ValueOperand, Label*) { MOZ_CRASH(); } template void loadUnboxedValue(T, MIRType, AnyRegister) { MOZ_CRASH(); } diff --git a/js/src/jit/x64/MacroAssembler-x64-inl.h b/js/src/jit/x64/MacroAssembler-x64-inl.h index 4084c2f0cdb..9b79936d21e 100644 --- a/js/src/jit/x64/MacroAssembler-x64-inl.h +++ b/js/src/jit/x64/MacroAssembler-x64-inl.h @@ -398,6 +398,13 @@ MacroAssembler::branchTest64(Condition cond, Register64 lhs, Register64 rhs, Reg branchTestPtr(cond, lhs.reg, rhs.reg, label); } +void +MacroAssembler::branchTestBooleanTruthy(bool truthy, const ValueOperand& value, Label* label) +{ + test32(value.valueReg(), value.valueReg()); + j(truthy ? NonZero : Zero, label); +} + //}}} check_macroassembler_style // =============================================================== diff --git a/js/src/jit/x64/MacroAssembler-x64.h b/js/src/jit/x64/MacroAssembler-x64.h index e1e95bf7eb4..1838c1848a2 100644 --- a/js/src/jit/x64/MacroAssembler-x64.h +++ b/js/src/jit/x64/MacroAssembler-x64.h @@ -994,10 +994,6 @@ class MacroAssemblerX64 : public MacroAssemblerX86Shared test32(operand.valueReg(), operand.valueReg()); return truthy ? NonZero : Zero; } - void branchTestBooleanTruthy(bool truthy, const ValueOperand& operand, Label* label) { - test32(operand.valueReg(), operand.valueReg()); - j(truthy ? NonZero : Zero, label); - } Condition testStringTruthy(bool truthy, const ValueOperand& value) { ScratchRegisterScope scratch(asMasm()); unboxString(value, scratch); diff --git a/js/src/jit/x86/MacroAssembler-x86-inl.h b/js/src/jit/x86/MacroAssembler-x86-inl.h index 5995883eb21..082169722f0 100644 --- a/js/src/jit/x86/MacroAssembler-x86-inl.h +++ b/js/src/jit/x86/MacroAssembler-x86-inl.h @@ -379,6 +379,13 @@ MacroAssembler::branchTest64(Condition cond, Register64 lhs, Register64 rhs, Reg } } +void +MacroAssembler::branchTestBooleanTruthy(bool truthy, const ValueOperand& value, Label* label) +{ + test32(value.payloadReg(), value.payloadReg()); + j(truthy ? NonZero : Zero, label); +} + //}}} check_macroassembler_style // =============================================================== diff --git a/js/src/jit/x86/MacroAssembler-x86.h b/js/src/jit/x86/MacroAssembler-x86.h index df7f36d3b3c..45d6e653403 100644 --- a/js/src/jit/x86/MacroAssembler-x86.h +++ b/js/src/jit/x86/MacroAssembler-x86.h @@ -830,10 +830,6 @@ class MacroAssemblerX86 : public MacroAssemblerX86Shared test32(operand.payloadReg(), operand.payloadReg()); return truthy ? NonZero : Zero; } - void branchTestBooleanTruthy(bool truthy, const ValueOperand& operand, Label* label) { - test32(operand.payloadReg(), operand.payloadReg()); - j(truthy ? NonZero : Zero, label); - } Condition testStringTruthy(bool truthy, const ValueOperand& value) { Register string = value.payloadReg(); cmp32(Operand(string, JSString::offsetOfLength()), Imm32(0)); From a0d98d5d86655a3fbd64369bf101123834cde51d Mon Sep 17 00:00:00 2001 From: Tooru Fujisawa Date: Thu, 3 Mar 2016 08:03:43 +0900 Subject: [PATCH 126/160] Bug 1245112 - Part 25: Move MacroAssembler::branchTestUndefined into generic macro assembler. r=sstangl --- js/src/jit/MacroAssembler.h | 9 ++++++ js/src/jit/arm/MacroAssembler-arm-inl.h | 32 +++++++++++++++++++ js/src/jit/arm/MacroAssembler-arm.h | 5 --- js/src/jit/arm64/MacroAssembler-arm64-inl.h | 32 +++++++++++++++++++ js/src/jit/arm64/MacroAssembler-arm64.h | 16 ---------- .../MacroAssembler-mips-shared-inl.h | 23 +++++++++++++ js/src/jit/mips32/MacroAssembler-mips32-inl.h | 6 ++++ js/src/jit/mips32/MacroAssembler-mips32.cpp | 31 ------------------ js/src/jit/mips32/MacroAssembler-mips32.h | 4 --- js/src/jit/mips64/MacroAssembler-mips64-inl.h | 8 +++++ js/src/jit/mips64/MacroAssembler-mips64.cpp | 32 ------------------- js/src/jit/mips64/MacroAssembler-mips64.h | 4 --- js/src/jit/none/MacroAssembler-none.h | 1 - js/src/jit/x64/MacroAssembler-x64.h | 26 ++------------- .../MacroAssembler-x86-shared-inl.h | 32 +++++++++++++++++++ js/src/jit/x86/MacroAssembler-x86.h | 5 --- 16 files changed, 144 insertions(+), 122 deletions(-) diff --git a/js/src/jit/MacroAssembler.h b/js/src/jit/MacroAssembler.h index a391e758ae0..eab8544ab42 100644 --- a/js/src/jit/MacroAssembler.h +++ b/js/src/jit/MacroAssembler.h @@ -923,6 +923,7 @@ class MacroAssembler : public MacroAssemblerSpecific // Perform a type-test on a tag of a Value (32bits boxing), or the tagged // value (64bits boxing). + inline void branchTestUndefined(Condition cond, Register tag, Label* label) PER_SHARED_ARCH; inline void branchTestInt32(Condition cond, Register tag, Label* label) PER_SHARED_ARCH; inline void branchTestDouble(Condition cond, Register tag, Label* label) DEFINED_ON(arm, arm64, mips32, mips64, x86_shared); @@ -931,6 +932,11 @@ class MacroAssembler : public MacroAssemblerSpecific // Perform a type-test on a Value, addressed by Address or BaseIndex, or // loaded into ValueOperand. + inline void branchTestUndefined(Condition cond, const Address& address, Label* label) PER_SHARED_ARCH; + inline void branchTestUndefined(Condition cond, const BaseIndex& address, Label* label) PER_SHARED_ARCH; + inline void branchTestUndefined(Condition cond, const ValueOperand& value, Label* label) + DEFINED_ON(arm, arm64, mips32, mips64, x86_shared); + inline void branchTestInt32(Condition cond, const Address& address, Label* label) PER_SHARED_ARCH; inline void branchTestInt32(Condition cond, const BaseIndex& address, Label* label) PER_SHARED_ARCH; inline void branchTestInt32(Condition cond, const ValueOperand& value, Label* label) @@ -960,6 +966,9 @@ class MacroAssembler : public MacroAssemblerSpecific // Implementation for branchTest* methods. template + inline void branchTestUndefinedImpl(Condition cond, const T& t, Label* label) + DEFINED_ON(arm, arm64, x86_shared); + template inline void branchTestInt32Impl(Condition cond, const T& t, Label* label) DEFINED_ON(arm, arm64, x86_shared); template diff --git a/js/src/jit/arm/MacroAssembler-arm-inl.h b/js/src/jit/arm/MacroAssembler-arm-inl.h index 63902612f86..3391bb37312 100644 --- a/js/src/jit/arm/MacroAssembler-arm-inl.h +++ b/js/src/jit/arm/MacroAssembler-arm-inl.h @@ -799,6 +799,38 @@ MacroAssembler::branchTest64(Condition cond, Register64 lhs, Register64 rhs, Reg } } +void +MacroAssembler::branchTestUndefined(Condition cond, Register tag, Label* label) +{ + branchTestUndefinedImpl(cond, tag, label); +} + +void +MacroAssembler::branchTestUndefined(Condition cond, const Address& address, Label* label) +{ + branchTestUndefinedImpl(cond, address, label); +} + +void +MacroAssembler::branchTestUndefined(Condition cond, const BaseIndex& address, Label* label) +{ + branchTestUndefinedImpl(cond, address, label); +} + +void +MacroAssembler::branchTestUndefined(Condition cond, const ValueOperand& value, Label* label) +{ + branchTestUndefinedImpl(cond, value, label); +} + +template +void +MacroAssembler::branchTestUndefinedImpl(Condition cond, const T& t, Label* label) +{ + Condition c = testUndefined(cond, t); + ma_b(label, c); +} + void MacroAssembler::branchTestInt32(Condition cond, Register tag, Label* label) { diff --git a/js/src/jit/arm/MacroAssembler-arm.h b/js/src/jit/arm/MacroAssembler-arm.h index e4ce078f3fd..7ba7beeb4fc 100644 --- a/js/src/jit/arm/MacroAssembler-arm.h +++ b/js/src/jit/arm/MacroAssembler-arm.h @@ -782,11 +782,6 @@ class MacroAssemblerARMCompat : public MacroAssemblerARM Condition c = testSymbol(cond, t); ma_b(label, c); } - template - void branchTestUndefined(Condition cond, const T & t, Label* label) { - Condition c = testUndefined(cond, t); - ma_b(label, c); - } template void branchTestMagic(Condition cond, const T& t, L label) { cond = testMagic(cond, t); diff --git a/js/src/jit/arm64/MacroAssembler-arm64-inl.h b/js/src/jit/arm64/MacroAssembler-arm64-inl.h index 9d6e53ac3f1..9843adc5442 100644 --- a/js/src/jit/arm64/MacroAssembler-arm64-inl.h +++ b/js/src/jit/arm64/MacroAssembler-arm64-inl.h @@ -886,6 +886,38 @@ MacroAssembler::branchTest64(Condition cond, Register64 lhs, Register64 rhs, Reg branchTestPtr(cond, lhs.reg, rhs.reg, label); } +void +MacroAssembler::branchTestUndefined(Condition cond, Register tag, Label* label) +{ + branchTestUndefinedImpl(cond, tag, label); +} + +void +MacroAssembler::branchTestUndefined(Condition cond, const Address& address, Label* label) +{ + branchTestUndefinedImpl(cond, address, label); +} + +void +MacroAssembler::branchTestUndefined(Condition cond, const BaseIndex& address, Label* label) +{ + branchTestUndefinedImpl(cond, address, label); +} + +void +MacroAssembler::branchTestUndefined(Condition cond, const ValueOperand& value, Label* label) +{ + branchTestUndefinedImpl(cond, value, label); +} + +template +void +MacroAssembler::branchTestUndefinedImpl(Condition cond, const T& t, Label* label) +{ + Condition c = testUndefined(cond, t); + B(label, c); +} + void MacroAssembler::branchTestInt32(Condition cond, Register tag, Label* label) { diff --git a/js/src/jit/arm64/MacroAssembler-arm64.h b/js/src/jit/arm64/MacroAssembler-arm64.h index c0f3a3386ed..6fac5641959 100644 --- a/js/src/jit/arm64/MacroAssembler-arm64.h +++ b/js/src/jit/arm64/MacroAssembler-arm64.h @@ -1328,10 +1328,6 @@ class MacroAssemblerCompat : public vixl::MacroAssembler return jumpWithPatch(label, Always, documentation); } - void branchTestUndefined(Condition cond, Register tag, Label* label) { - Condition c = testUndefined(cond, tag); - B(label, c); - } void branchTestNull(Condition cond, Register tag, Label* label) { Condition c = testNull(cond, tag); B(label, c); @@ -1349,10 +1345,6 @@ class MacroAssemblerCompat : public vixl::MacroAssembler B(label, c); } - void branchTestUndefined(Condition cond, const Address& address, Label* label) { - Condition c = testUndefined(cond, address); - B(label, c); - } void branchTestNull(Condition cond, const Address& address, Label* label) { Condition c = testNull(cond, address); B(label, c); @@ -1372,10 +1364,6 @@ class MacroAssemblerCompat : public vixl::MacroAssembler // Perform a type-test on a full Value loaded into a register. // Clobbers the ScratchReg. - void branchTestUndefined(Condition cond, const ValueOperand& src, Label* label) { - Condition c = testUndefined(cond, src); - B(label, c); - } void branchTestNull(Condition cond, const ValueOperand& src, Label* label) { Condition c = testNull(cond, src); B(label, c); @@ -1395,10 +1383,6 @@ class MacroAssemblerCompat : public vixl::MacroAssembler // Perform a type-test on a Value addressed by BaseIndex. // Clobbers the ScratchReg. - void branchTestUndefined(Condition cond, const BaseIndex& address, Label* label) { - Condition c = testUndefined(cond, address); - B(label, c); - } void branchTestNull(Condition cond, const BaseIndex& address, Label* label) { Condition c = testNull(cond, address); B(label, c); diff --git a/js/src/jit/mips-shared/MacroAssembler-mips-shared-inl.h b/js/src/jit/mips-shared/MacroAssembler-mips-shared-inl.h index 891aff8e3a4..dfa57c4fe88 100644 --- a/js/src/jit/mips-shared/MacroAssembler-mips-shared-inl.h +++ b/js/src/jit/mips-shared/MacroAssembler-mips-shared-inl.h @@ -509,6 +509,29 @@ MacroAssembler::branchTestPtr(Condition cond, const Address& lhs, Imm32 rhs, Lab branchTestPtr(cond, SecondScratchReg, rhs, label); } +void +MacroAssembler::branchTestUndefined(Condition cond, Register tag, Label* label) +{ + MOZ_ASSERT(cond == Equal || cond == NotEqual); + ma_b(tag, ImmTag(JSVAL_TAG_UNDEFINED), label, cond); +} + +void +MacroAssembler::branchTestUndefined(Condition cond, const Address& address, Label* label) +{ + SecondScratchRegisterScope scratch2(*this); + extractTag(address, scratch2); + branchTestUndefined(cond, scratch2, label); +} + +void +MacroAssembler::branchTestUndefined(Condition cond, const BaseIndex& address, Label* label) +{ + SecondScratchRegisterScope scratch2(*this); + extractTag(address, scratch2); + branchTestUndefined(cond, scratch2, label); +} + void MacroAssembler::branchTestInt32(Condition cond, Register tag, Label* label) { diff --git a/js/src/jit/mips32/MacroAssembler-mips32-inl.h b/js/src/jit/mips32/MacroAssembler-mips32-inl.h index fa3c032795c..52b15a02238 100644 --- a/js/src/jit/mips32/MacroAssembler-mips32-inl.h +++ b/js/src/jit/mips32/MacroAssembler-mips32-inl.h @@ -288,6 +288,12 @@ MacroAssembler::branchTest64(Condition cond, Register64 lhs, Register64 rhs, Reg } } +void +MacroAssembler::branchTestUndefined(Condition cond, const ValueOperand& value, Label* label) +{ + branchTestUndefined(cond, value.typeReg(), label); +} + void MacroAssembler::branchTestInt32(Condition cond, const ValueOperand& value, Label* label) { diff --git a/js/src/jit/mips32/MacroAssembler-mips32.cpp b/js/src/jit/mips32/MacroAssembler-mips32.cpp index 15904b2a7b5..801c6fe4d0e 100644 --- a/js/src/jit/mips32/MacroAssembler-mips32.cpp +++ b/js/src/jit/mips32/MacroAssembler-mips32.cpp @@ -1240,37 +1240,6 @@ MacroAssemblerMIPSCompat::branchTestSymbol(Condition cond, const BaseIndex& src, ma_b(SecondScratchReg, ImmTag(JSVAL_TAG_SYMBOL), label, cond); } -void -MacroAssemblerMIPSCompat::branchTestUndefined(Condition cond, const ValueOperand& value, - Label* label) -{ - MOZ_ASSERT(cond == Equal || cond == NotEqual); - ma_b(value.typeReg(), ImmType(JSVAL_TYPE_UNDEFINED), label, cond); -} - -void -MacroAssemblerMIPSCompat::branchTestUndefined(Condition cond, Register tag, Label* label) -{ - MOZ_ASSERT(cond == Equal || cond == NotEqual); - ma_b(tag, ImmTag(JSVAL_TAG_UNDEFINED), label, cond); -} - -void -MacroAssemblerMIPSCompat::branchTestUndefined(Condition cond, const BaseIndex& src, Label* label) -{ - MOZ_ASSERT(cond == Equal || cond == NotEqual); - extractTag(src, SecondScratchReg); - ma_b(SecondScratchReg, ImmTag(JSVAL_TAG_UNDEFINED), label, cond); -} - -void -MacroAssemblerMIPSCompat::branchTestUndefined(Condition cond, const Address& address, Label* label) -{ - MOZ_ASSERT(cond == Equal || cond == NotEqual); - extractTag(address, SecondScratchReg); - ma_b(SecondScratchReg, ImmTag(JSVAL_TAG_UNDEFINED), label, cond); -} - void MacroAssemblerMIPSCompat::testUndefinedSet(Condition cond, const ValueOperand& value, Register dest) { diff --git a/js/src/jit/mips32/MacroAssembler-mips32.h b/js/src/jit/mips32/MacroAssembler-mips32.h index 9d362eac9f6..ac872303bc4 100644 --- a/js/src/jit/mips32/MacroAssembler-mips32.h +++ b/js/src/jit/mips32/MacroAssembler-mips32.h @@ -395,10 +395,6 @@ class MacroAssemblerMIPSCompat : public MacroAssemblerMIPS void branchTestSymbol(Condition cond, const Register& tag, Label* label); void branchTestSymbol(Condition cond, const BaseIndex& src, Label* label); - void branchTestUndefined(Condition cond, const ValueOperand& value, Label* label); - void branchTestUndefined(Condition cond, Register tag, Label* label); - void branchTestUndefined(Condition cond, const BaseIndex& src, Label* label); - void branchTestUndefined(Condition cond, const Address& address, Label* label); void testUndefinedSet(Condition cond, const ValueOperand& value, Register dest); void branchTestMagic(Condition cond, const ValueOperand& value, Label* label); diff --git a/js/src/jit/mips64/MacroAssembler-mips64-inl.h b/js/src/jit/mips64/MacroAssembler-mips64-inl.h index 3436d09703d..4e90b2b6813 100644 --- a/js/src/jit/mips64/MacroAssembler-mips64-inl.h +++ b/js/src/jit/mips64/MacroAssembler-mips64-inl.h @@ -224,6 +224,14 @@ MacroAssembler::branchTest64(Condition cond, Register64 lhs, Register64 rhs, Reg branchTestPtr(cond, lhs.reg, rhs.reg, label); } +void +MacroAssembler::branchTestUndefined(Condition cond, const ValueOperand& value, Label* label) +{ + SecondScratchRegisterScope scratch2(*this); + splitTag(value, scratch2); + branchTestUndefined(cond, scratch2, label); +} + void MacroAssembler::branchTestInt32(Condition cond, const ValueOperand& value, Label* label) { diff --git a/js/src/jit/mips64/MacroAssembler-mips64.cpp b/js/src/jit/mips64/MacroAssembler-mips64.cpp index 6aac755ea4e..cded6e855a9 100644 --- a/js/src/jit/mips64/MacroAssembler-mips64.cpp +++ b/js/src/jit/mips64/MacroAssembler-mips64.cpp @@ -1374,38 +1374,6 @@ MacroAssemblerMIPS64Compat::branchTestSymbol(Condition cond, const BaseIndex& sr ma_b(SecondScratchReg, ImmTag(JSVAL_TAG_SYMBOL), label, cond); } -void -MacroAssemblerMIPS64Compat::branchTestUndefined(Condition cond, const ValueOperand& value, - Label* label) -{ - MOZ_ASSERT(cond == Equal || cond == NotEqual); - splitTag(value, SecondScratchReg); - ma_b(SecondScratchReg, ImmTag(JSVAL_TAG_UNDEFINED), label, cond); -} - -void -MacroAssemblerMIPS64Compat::branchTestUndefined(Condition cond, Register tag, Label* label) -{ - MOZ_ASSERT(cond == Equal || cond == NotEqual); - ma_b(tag, ImmTag(JSVAL_TAG_UNDEFINED), label, cond); -} - -void -MacroAssemblerMIPS64Compat::branchTestUndefined(Condition cond, const BaseIndex& src, Label* label) -{ - MOZ_ASSERT(cond == Equal || cond == NotEqual); - extractTag(src, SecondScratchReg); - ma_b(SecondScratchReg, ImmTag(JSVAL_TAG_UNDEFINED), label, cond); -} - -void -MacroAssemblerMIPS64Compat::branchTestUndefined(Condition cond, const Address& address, Label* label) -{ - MOZ_ASSERT(cond == Equal || cond == NotEqual); - extractTag(address, SecondScratchReg); - ma_b(SecondScratchReg, ImmTag(JSVAL_TAG_UNDEFINED), label, cond); -} - void MacroAssemblerMIPS64Compat::testUndefinedSet(Condition cond, const ValueOperand& value, Register dest) { diff --git a/js/src/jit/mips64/MacroAssembler-mips64.h b/js/src/jit/mips64/MacroAssembler-mips64.h index 61044746efa..d9d035f0184 100644 --- a/js/src/jit/mips64/MacroAssembler-mips64.h +++ b/js/src/jit/mips64/MacroAssembler-mips64.h @@ -436,10 +436,6 @@ class MacroAssemblerMIPS64Compat : public MacroAssemblerMIPS64 void branchTestSymbol(Condition cond, const Register& tag, Label* label); void branchTestSymbol(Condition cond, const BaseIndex& src, Label* label); - void branchTestUndefined(Condition cond, const ValueOperand& value, Label* label); - void branchTestUndefined(Condition cond, Register tag, Label* label); - void branchTestUndefined(Condition cond, const BaseIndex& src, Label* label); - void branchTestUndefined(Condition cond, const Address& address, Label* label); void testUndefinedSet(Condition cond, const ValueOperand& value, Register dest); void branchTestMagic(Condition cond, const ValueOperand& value, Label* label); diff --git a/js/src/jit/none/MacroAssembler-none.h b/js/src/jit/none/MacroAssembler-none.h index ba75c2a2802..adb335cbeca 100644 --- a/js/src/jit/none/MacroAssembler-none.h +++ b/js/src/jit/none/MacroAssembler-none.h @@ -345,7 +345,6 @@ class MacroAssemblerNone : public Assembler Register splitTagForTest(ValueOperand) { MOZ_CRASH(); } - template void branchTestUndefined(Condition, T, Label*) { MOZ_CRASH(); } template void branchTestNull(Condition, T, Label*) { MOZ_CRASH(); } template void branchTestString(Condition, T, Label*) { MOZ_CRASH(); } template void branchTestSymbol(Condition, T, Label*) { MOZ_CRASH(); } diff --git a/js/src/jit/x64/MacroAssembler-x64.h b/js/src/jit/x64/MacroAssembler-x64.h index 1838c1848a2..10d3055691d 100644 --- a/js/src/jit/x64/MacroAssembler-x64.h +++ b/js/src/jit/x64/MacroAssembler-x64.h @@ -324,9 +324,8 @@ class MacroAssemblerX64 : public MacroAssemblerX86Shared Condition testUndefined(Condition cond, const Address& src) { - ScratchRegisterScope scratch(asMasm()); - splitTag(src, scratch); - return testUndefined(cond, scratch); + cmp32(ToUpper32(src), Imm32(Upper32Of(GetShiftedTag(JSVAL_TYPE_UNDEFINED)))); + return cond; } Condition testInt32(Condition cond, const Address& src) { cmp32(ToUpper32(src), Imm32(Upper32Of(GetShiftedTag(JSVAL_TYPE_INT32)))); @@ -685,10 +684,6 @@ class MacroAssemblerX64 : public MacroAssemblerX86Shared cmp32(reg, tag); } - void branchTestUndefined(Condition cond, Register tag, Label* label) { - cond = testUndefined(cond, tag); - j(cond, label); - } void branchTestNull(Condition cond, Register tag, Label* label) { cond = testNull(cond, tag); j(cond, label); @@ -709,15 +704,6 @@ class MacroAssemblerX64 : public MacroAssemblerX86Shared // x64 can test for certain types directly from memory when the payload // of the type is limited to 32 bits. This avoids loading into a register, // accesses half as much memory, and removes a right-shift. - void branchTestUndefined(Condition cond, const Operand& operand, Label* label) { - MOZ_ASSERT(cond == Equal || cond == NotEqual); - cmp32(ToUpper32(operand), Imm32(Upper32Of(GetShiftedTag(JSVAL_TYPE_UNDEFINED)))); - j(cond, label); - } - void branchTestUndefined(Condition cond, const Address& address, Label* label) { - MOZ_ASSERT(cond == Equal || cond == NotEqual); - branchTestUndefined(cond, Operand(address), label); - } void branchTestNull(Condition cond, const Operand& operand, Label* label) { MOZ_ASSERT(cond == Equal || cond == NotEqual); cmp32(ToUpper32(operand), Imm32(Upper32Of(GetShiftedTag(JSVAL_TYPE_NULL)))); @@ -736,10 +722,6 @@ class MacroAssemblerX64 : public MacroAssemblerX86Shared // Perform a type-test on a full Value loaded into a register. // Clobbers the ScratchReg. - void branchTestUndefined(Condition cond, const ValueOperand& src, Label* label) { - cond = testUndefined(cond, src); - j(cond, label); - } void branchTestNull(Condition cond, const ValueOperand& src, Label* label) { cond = testNull(cond, src); j(cond, label); @@ -759,10 +741,6 @@ class MacroAssemblerX64 : public MacroAssemblerX86Shared // Perform a type-test on a Value addressed by BaseIndex. // Clobbers the ScratchReg. - void branchTestUndefined(Condition cond, const BaseIndex& address, Label* label) { - cond = testUndefined(cond, address); - j(cond, label); - } void branchTestNull(Condition cond, const BaseIndex& address, Label* label) { cond = testNull(cond, address); j(cond, label); diff --git a/js/src/jit/x86-shared/MacroAssembler-x86-shared-inl.h b/js/src/jit/x86-shared/MacroAssembler-x86-shared-inl.h index 2686c183465..112cd65de3d 100644 --- a/js/src/jit/x86-shared/MacroAssembler-x86-shared-inl.h +++ b/js/src/jit/x86-shared/MacroAssembler-x86-shared-inl.h @@ -428,6 +428,38 @@ MacroAssembler::branchTestPtr(Condition cond, const Address& lhs, Imm32 rhs, Lab j(cond, label); } +void +MacroAssembler::branchTestUndefined(Condition cond, Register tag, Label* label) +{ + branchTestUndefinedImpl(cond, tag, label); +} + +void +MacroAssembler::branchTestUndefined(Condition cond, const Address& address, Label* label) +{ + branchTestUndefinedImpl(cond, address, label); +} + +void +MacroAssembler::branchTestUndefined(Condition cond, const BaseIndex& address, Label* label) +{ + branchTestUndefinedImpl(cond, address, label); +} + +void +MacroAssembler::branchTestUndefined(Condition cond, const ValueOperand& value, Label* label) +{ + branchTestUndefinedImpl(cond, value, label); +} + +template +void +MacroAssembler::branchTestUndefinedImpl(Condition cond, const T& t, Label* label) +{ + cond = testUndefined(cond, t); + j(cond, label); +} + void MacroAssembler::branchTestInt32(Condition cond, Register tag, Label* label) { diff --git a/js/src/jit/x86/MacroAssembler-x86.h b/js/src/jit/x86/MacroAssembler-x86.h index 45d6e653403..e8e45b32e24 100644 --- a/js/src/jit/x86/MacroAssembler-x86.h +++ b/js/src/jit/x86/MacroAssembler-x86.h @@ -660,11 +660,6 @@ class MacroAssemblerX86 : public MacroAssemblerX86Shared // Type testing instructions can take a tag in a register or a // ValueOperand. template - void branchTestUndefined(Condition cond, const T& t, Label* label) { - cond = testUndefined(cond, t); - j(cond, label); - } - template void branchTestNull(Condition cond, const T& t, Label* label) { cond = testNull(cond, t); j(cond, label); From bfb90671948647ad328d3efc72e3cb9f36ba124a Mon Sep 17 00:00:00 2001 From: Tooru Fujisawa Date: Thu, 3 Mar 2016 08:03:43 +0900 Subject: [PATCH 127/160] Bug 1245112 - Part 26: Move MacroAssembler::branchTestString into generic macro assembler. r=sstangl --- js/src/jit/MacroAssembler.h | 8 ++++++ js/src/jit/arm/MacroAssembler-arm-inl.h | 26 +++++++++++++++++++ js/src/jit/arm/MacroAssembler-arm.h | 5 ---- js/src/jit/arm64/MacroAssembler-arm64-inl.h | 26 +++++++++++++++++++ js/src/jit/arm64/MacroAssembler-arm64.h | 16 ------------ .../MacroAssembler-mips-shared-inl.h | 15 +++++++++++ js/src/jit/mips32/MacroAssembler-mips32-inl.h | 6 +++++ js/src/jit/mips32/MacroAssembler-mips32.cpp | 21 --------------- js/src/jit/mips32/MacroAssembler-mips32.h | 4 --- js/src/jit/mips64/MacroAssembler-mips64-inl.h | 8 ++++++ js/src/jit/mips64/MacroAssembler-mips64.cpp | 22 ---------------- js/src/jit/mips64/MacroAssembler-mips64.h | 4 --- js/src/jit/none/MacroAssembler-none.h | 1 - js/src/jit/x64/MacroAssembler-x64.h | 12 --------- .../MacroAssembler-x86-shared-inl.h | 26 +++++++++++++++++++ js/src/jit/x86/MacroAssembler-x86.h | 5 ---- 16 files changed, 115 insertions(+), 90 deletions(-) diff --git a/js/src/jit/MacroAssembler.h b/js/src/jit/MacroAssembler.h index eab8544ab42..bcb311f72c4 100644 --- a/js/src/jit/MacroAssembler.h +++ b/js/src/jit/MacroAssembler.h @@ -929,6 +929,7 @@ class MacroAssembler : public MacroAssemblerSpecific DEFINED_ON(arm, arm64, mips32, mips64, x86_shared); inline void branchTestNumber(Condition cond, Register tag, Label* label) PER_SHARED_ARCH; inline void branchTestBoolean(Condition cond, Register tag, Label* label) PER_SHARED_ARCH; + inline void branchTestString(Condition cond, Register tag, Label* label) PER_SHARED_ARCH; // Perform a type-test on a Value, addressed by Address or BaseIndex, or // loaded into ValueOperand. @@ -955,6 +956,10 @@ class MacroAssembler : public MacroAssemblerSpecific inline void branchTestBoolean(Condition cond, const ValueOperand& value, Label* label) DEFINED_ON(arm, arm64, mips32, mips64, x86_shared); + inline void branchTestString(Condition cond, const BaseIndex& address, Label* label) PER_SHARED_ARCH; + inline void branchTestString(Condition cond, const ValueOperand& value, Label* label) + DEFINED_ON(arm, arm64, mips32, mips64, x86_shared); + // Checks if given Value is evaluated to true or false in a condition. // The type of the value should match the type of the method. inline void branchTestInt32Truthy(bool truthy, const ValueOperand& value, Label* label) @@ -980,6 +985,9 @@ class MacroAssembler : public MacroAssemblerSpecific template inline void branchTestBooleanImpl(Condition cond, const T& t, Label* label) DEFINED_ON(arm, arm64, x86_shared); + template + inline void branchTestStringImpl(Condition cond, const T& t, Label* label) + DEFINED_ON(arm, arm64, x86_shared); //}}} check_macroassembler_style public: diff --git a/js/src/jit/arm/MacroAssembler-arm-inl.h b/js/src/jit/arm/MacroAssembler-arm-inl.h index 3391bb37312..3606f744f1e 100644 --- a/js/src/jit/arm/MacroAssembler-arm-inl.h +++ b/js/src/jit/arm/MacroAssembler-arm-inl.h @@ -968,6 +968,32 @@ MacroAssembler::branchTestBooleanTruthy(bool truthy, const ValueOperand& value, ma_b(label, c); } +void +MacroAssembler::branchTestString(Condition cond, Register tag, Label* label) +{ + branchTestStringImpl(cond, tag, label); +} + +void +MacroAssembler::branchTestString(Condition cond, const BaseIndex& address, Label* label) +{ + branchTestStringImpl(cond, address, label); +} + +void +MacroAssembler::branchTestString(Condition cond, const ValueOperand& value, Label* label) +{ + branchTestStringImpl(cond, value, label); +} + +template +void +MacroAssembler::branchTestStringImpl(Condition cond, const T& t, Label* label) +{ + Condition c = testString(cond, t); + ma_b(label, c); +} + //}}} check_macroassembler_style // =============================================================== diff --git a/js/src/jit/arm/MacroAssembler-arm.h b/js/src/jit/arm/MacroAssembler-arm.h index 7ba7beeb4fc..2c11d36d38a 100644 --- a/js/src/jit/arm/MacroAssembler-arm.h +++ b/js/src/jit/arm/MacroAssembler-arm.h @@ -773,11 +773,6 @@ class MacroAssemblerARMCompat : public MacroAssemblerARM ma_b(label, c); } template - void branchTestString(Condition cond, const T & t, Label* label) { - Condition c = testString(cond, t); - ma_b(label, c); - } - template void branchTestSymbol(Condition cond, const T & t, Label* label) { Condition c = testSymbol(cond, t); ma_b(label, c); diff --git a/js/src/jit/arm64/MacroAssembler-arm64-inl.h b/js/src/jit/arm64/MacroAssembler-arm64-inl.h index 9843adc5442..443bb83e19c 100644 --- a/js/src/jit/arm64/MacroAssembler-arm64-inl.h +++ b/js/src/jit/arm64/MacroAssembler-arm64-inl.h @@ -1067,6 +1067,32 @@ MacroAssembler::branchTestBooleanTruthy(bool truthy, const ValueOperand& value, B(label, c); } +void +MacroAssembler::branchTestString(Condition cond, Register tag, Label* label) +{ + branchTestStringImpl(cond, tag, label); +} + +void +MacroAssembler::branchTestString(Condition cond, const BaseIndex& address, Label* label) +{ + branchTestStringImpl(cond, address, label); +} + +void +MacroAssembler::branchTestString(Condition cond, const ValueOperand& value, Label* label) +{ + branchTestStringImpl(cond, value, label); +} + +template +void +MacroAssembler::branchTestStringImpl(Condition cond, const T& t, Label* label) +{ + Condition c = testString(cond, t); + B(label, c); +} + //}}} check_macroassembler_style // =============================================================== diff --git a/js/src/jit/arm64/MacroAssembler-arm64.h b/js/src/jit/arm64/MacroAssembler-arm64.h index 6fac5641959..91e669cd4cd 100644 --- a/js/src/jit/arm64/MacroAssembler-arm64.h +++ b/js/src/jit/arm64/MacroAssembler-arm64.h @@ -1332,10 +1332,6 @@ class MacroAssemblerCompat : public vixl::MacroAssembler Condition c = testNull(cond, tag); B(label, c); } - void branchTestString(Condition cond, Register tag, Label* label) { - Condition c = testString(cond, tag); - B(label, c); - } void branchTestSymbol(Condition cond, Register tag, Label* label) { Condition c = testSymbol(cond, tag); B(label, c); @@ -1349,10 +1345,6 @@ class MacroAssemblerCompat : public vixl::MacroAssembler Condition c = testNull(cond, address); B(label, c); } - void branchTestString(Condition cond, const Address& address, Label* label) { - Condition c = testString(cond, address); - B(label, c); - } void branchTestSymbol(Condition cond, const Address& address, Label* label) { Condition c = testSymbol(cond, address); B(label, c); @@ -1368,10 +1360,6 @@ class MacroAssemblerCompat : public vixl::MacroAssembler Condition c = testNull(cond, src); B(label, c); } - void branchTestString(Condition cond, const ValueOperand& src, Label* label) { - Condition c = testString(cond, src); - B(label, c); - } void branchTestSymbol(Condition cond, const ValueOperand& src, Label* label) { Condition c = testSymbol(cond, src); B(label, c); @@ -1387,10 +1375,6 @@ class MacroAssemblerCompat : public vixl::MacroAssembler Condition c = testNull(cond, address); B(label, c); } - void branchTestString(Condition cond, const BaseIndex& address, Label* label) { - Condition c = testString(cond, address); - B(label, c); - } void branchTestSymbol(Condition cond, const BaseIndex& address, Label* label) { Condition c = testSymbol(cond, address); B(label, c); diff --git a/js/src/jit/mips-shared/MacroAssembler-mips-shared-inl.h b/js/src/jit/mips-shared/MacroAssembler-mips-shared-inl.h index dfa57c4fe88..b28d1ce0c68 100644 --- a/js/src/jit/mips-shared/MacroAssembler-mips-shared-inl.h +++ b/js/src/jit/mips-shared/MacroAssembler-mips-shared-inl.h @@ -610,6 +610,21 @@ MacroAssembler::branchTestBoolean(Condition cond, const BaseIndex& address, Labe branchTestBoolean(cond, scratch2, label); } +void +MacroAssembler::branchTestString(Condition cond, Register tag, Label* label) +{ + MOZ_ASSERT(cond == Equal || cond == NotEqual); + ma_b(tag, ImmTag(JSVAL_TAG_STRING), label, cond); +} + +void +MacroAssembler::branchTestString(Condition cond, const BaseIndex& address, Label* label) +{ + SecondScratchRegisterScope scratch2(*this); + extractTag(address, scratch2); + branchTestString(cond, scratch2, label); +} + //}}} check_macroassembler_style // =============================================================== diff --git a/js/src/jit/mips32/MacroAssembler-mips32-inl.h b/js/src/jit/mips32/MacroAssembler-mips32-inl.h index 52b15a02238..69cbab1d24c 100644 --- a/js/src/jit/mips32/MacroAssembler-mips32-inl.h +++ b/js/src/jit/mips32/MacroAssembler-mips32-inl.h @@ -341,6 +341,12 @@ MacroAssembler::branchTestBooleanTruthy(bool b, const ValueOperand& value, Label ma_b(value.payloadReg(), value.payloadReg(), label, b ? NonZero : Zero); } +void +MacroAssembler::branchTestString(Condition cond, const ValueOperand& value, Label* label) +{ + branchTestString(cond, value.typeReg(), label); +} + //}}} check_macroassembler_style // =============================================================== diff --git a/js/src/jit/mips32/MacroAssembler-mips32.cpp b/js/src/jit/mips32/MacroAssembler-mips32.cpp index 801c6fe4d0e..a3f342050d0 100644 --- a/js/src/jit/mips32/MacroAssembler-mips32.cpp +++ b/js/src/jit/mips32/MacroAssembler-mips32.cpp @@ -1198,27 +1198,6 @@ MacroAssemblerMIPSCompat::testObjectSet(Condition cond, const ValueOperand& valu ma_cmp_set(dest, value.typeReg(), ImmType(JSVAL_TYPE_OBJECT), cond); } -void -MacroAssemblerMIPSCompat::branchTestString(Condition cond, const ValueOperand& value, Label* label) -{ - branchTestString(cond, value.typeReg(), label); -} - -void -MacroAssemblerMIPSCompat::branchTestString(Condition cond, Register tag, Label* label) -{ - MOZ_ASSERT(cond == Equal || cond == NotEqual); - ma_b(tag, ImmTag(JSVAL_TAG_STRING), label, cond); -} - -void -MacroAssemblerMIPSCompat::branchTestString(Condition cond, const BaseIndex& src, Label* label) -{ - MOZ_ASSERT(cond == Equal || cond == NotEqual); - extractTag(src, SecondScratchReg); - ma_b(SecondScratchReg, ImmTag(JSVAL_TAG_STRING), label, cond); -} - void MacroAssemblerMIPSCompat::branchTestSymbol(Condition cond, const ValueOperand& value, Label* label) { diff --git a/js/src/jit/mips32/MacroAssembler-mips32.h b/js/src/jit/mips32/MacroAssembler-mips32.h index ac872303bc4..0c71a372ce2 100644 --- a/js/src/jit/mips32/MacroAssembler-mips32.h +++ b/js/src/jit/mips32/MacroAssembler-mips32.h @@ -387,10 +387,6 @@ class MacroAssemblerMIPSCompat : public MacroAssemblerMIPS void branchTestObject(Condition cond, const Address& src, Label* label); void testObjectSet(Condition cond, const ValueOperand& value, Register dest); - void branchTestString(Condition cond, const ValueOperand& value, Label* label); - void branchTestString(Condition cond, Register tag, Label* label); - void branchTestString(Condition cond, const BaseIndex& src, Label* label); - void branchTestSymbol(Condition cond, const ValueOperand& value, Label* label); void branchTestSymbol(Condition cond, const Register& tag, Label* label); void branchTestSymbol(Condition cond, const BaseIndex& src, Label* label); diff --git a/js/src/jit/mips64/MacroAssembler-mips64-inl.h b/js/src/jit/mips64/MacroAssembler-mips64-inl.h index 4e90b2b6813..45f0f67d94d 100644 --- a/js/src/jit/mips64/MacroAssembler-mips64-inl.h +++ b/js/src/jit/mips64/MacroAssembler-mips64-inl.h @@ -288,6 +288,14 @@ MacroAssembler::branchTestBooleanTruthy(bool b, const ValueOperand& value, Label ma_b(scratch2, scratch2, label, b ? NonZero : Zero); } +void +MacroAssembler::branchTestString(Condition cond, const ValueOperand& value, Label* label) +{ + SecondScratchRegisterScope scratch2(*this); + splitTag(value, scratch2); + branchTestString(cond, scratch2, label); +} + //}}} check_macroassembler_style // =============================================================== diff --git a/js/src/jit/mips64/MacroAssembler-mips64.cpp b/js/src/jit/mips64/MacroAssembler-mips64.cpp index cded6e855a9..2007c55aa6f 100644 --- a/js/src/jit/mips64/MacroAssembler-mips64.cpp +++ b/js/src/jit/mips64/MacroAssembler-mips64.cpp @@ -1330,28 +1330,6 @@ MacroAssemblerMIPS64Compat::testObjectSet(Condition cond, const ValueOperand& va ma_cmp_set(dest, SecondScratchReg, ImmTag(JSVAL_TAG_OBJECT), cond); } -void -MacroAssemblerMIPS64Compat::branchTestString(Condition cond, const ValueOperand& value, Label* label) -{ - splitTag(value, SecondScratchReg); - branchTestString(cond, SecondScratchReg, label); -} - -void -MacroAssemblerMIPS64Compat::branchTestString(Condition cond, Register tag, Label* label) -{ - MOZ_ASSERT(cond == Equal || cond == NotEqual); - ma_b(tag, ImmTag(JSVAL_TAG_STRING), label, cond); -} - -void -MacroAssemblerMIPS64Compat::branchTestString(Condition cond, const BaseIndex& src, Label* label) -{ - MOZ_ASSERT(cond == Equal || cond == NotEqual); - extractTag(src, SecondScratchReg); - ma_b(SecondScratchReg, ImmTag(JSVAL_TAG_STRING), label, cond); -} - void MacroAssemblerMIPS64Compat::branchTestSymbol(Condition cond, const ValueOperand& value, Label* label) { diff --git a/js/src/jit/mips64/MacroAssembler-mips64.h b/js/src/jit/mips64/MacroAssembler-mips64.h index d9d035f0184..51d26e17507 100644 --- a/js/src/jit/mips64/MacroAssembler-mips64.h +++ b/js/src/jit/mips64/MacroAssembler-mips64.h @@ -428,10 +428,6 @@ class MacroAssemblerMIPS64Compat : public MacroAssemblerMIPS64 void branchTestObject(Condition cond, const Address& src, Label* label); void testObjectSet(Condition cond, const ValueOperand& value, Register dest); - void branchTestString(Condition cond, const ValueOperand& value, Label* label); - void branchTestString(Condition cond, Register tag, Label* label); - void branchTestString(Condition cond, const BaseIndex& src, Label* label); - void branchTestSymbol(Condition cond, const ValueOperand& value, Label* label); void branchTestSymbol(Condition cond, const Register& tag, Label* label); void branchTestSymbol(Condition cond, const BaseIndex& src, Label* label); diff --git a/js/src/jit/none/MacroAssembler-none.h b/js/src/jit/none/MacroAssembler-none.h index adb335cbeca..3d6600ad977 100644 --- a/js/src/jit/none/MacroAssembler-none.h +++ b/js/src/jit/none/MacroAssembler-none.h @@ -346,7 +346,6 @@ class MacroAssemblerNone : public Assembler Register splitTagForTest(ValueOperand) { MOZ_CRASH(); } template void branchTestNull(Condition, T, Label*) { MOZ_CRASH(); } - template void branchTestString(Condition, T, Label*) { MOZ_CRASH(); } template void branchTestSymbol(Condition, T, Label*) { MOZ_CRASH(); } template void branchTestObject(Condition, T, Label*) { MOZ_CRASH(); } template void branchTestGCThing(Condition, T, Label*) { MOZ_CRASH(); } diff --git a/js/src/jit/x64/MacroAssembler-x64.h b/js/src/jit/x64/MacroAssembler-x64.h index 10d3055691d..f9c3bad0fd3 100644 --- a/js/src/jit/x64/MacroAssembler-x64.h +++ b/js/src/jit/x64/MacroAssembler-x64.h @@ -688,10 +688,6 @@ class MacroAssemblerX64 : public MacroAssemblerX86Shared cond = testNull(cond, tag); j(cond, label); } - void branchTestString(Condition cond, Register tag, Label* label) { - cond = testString(cond, tag); - j(cond, label); - } void branchTestSymbol(Condition cond, Register tag, Label* label) { cond = testSymbol(cond, tag); j(cond, label); @@ -726,10 +722,6 @@ class MacroAssemblerX64 : public MacroAssemblerX86Shared cond = testNull(cond, src); j(cond, label); } - void branchTestString(Condition cond, const ValueOperand& src, Label* label) { - cond = testString(cond, src); - j(cond, label); - } void branchTestSymbol(Condition cond, const ValueOperand& src, Label* label) { cond = testSymbol(cond, src); j(cond, label); @@ -745,10 +737,6 @@ class MacroAssemblerX64 : public MacroAssemblerX86Shared cond = testNull(cond, address); j(cond, label); } - void branchTestString(Condition cond, const BaseIndex& address, Label* label) { - cond = testString(cond, address); - j(cond, label); - } void branchTestSymbol(Condition cond, const BaseIndex& address, Label* label) { cond = testSymbol(cond, address); j(cond, label); diff --git a/js/src/jit/x86-shared/MacroAssembler-x86-shared-inl.h b/js/src/jit/x86-shared/MacroAssembler-x86-shared-inl.h index 112cd65de3d..6deacee31c9 100644 --- a/js/src/jit/x86-shared/MacroAssembler-x86-shared-inl.h +++ b/js/src/jit/x86-shared/MacroAssembler-x86-shared-inl.h @@ -590,6 +590,32 @@ MacroAssembler::branchTestBooleanImpl(Condition cond, const T& t, Label* label) j(cond, label); } +void +MacroAssembler::branchTestString(Condition cond, Register tag, Label* label) +{ + branchTestStringImpl(cond, tag, label); +} + +void +MacroAssembler::branchTestString(Condition cond, const BaseIndex& address, Label* label) +{ + branchTestStringImpl(cond, address, label); +} + +void +MacroAssembler::branchTestString(Condition cond, const ValueOperand& value, Label* label) +{ + branchTestStringImpl(cond, value, label); +} + +template +void +MacroAssembler::branchTestStringImpl(Condition cond, const T& t, Label* label) +{ + cond = testString(cond, t); + j(cond, label); +} + //}}} check_macroassembler_style // =============================================================== diff --git a/js/src/jit/x86/MacroAssembler-x86.h b/js/src/jit/x86/MacroAssembler-x86.h index e8e45b32e24..7f87071bf8f 100644 --- a/js/src/jit/x86/MacroAssembler-x86.h +++ b/js/src/jit/x86/MacroAssembler-x86.h @@ -665,11 +665,6 @@ class MacroAssemblerX86 : public MacroAssemblerX86Shared j(cond, label); } template - void branchTestString(Condition cond, const T& t, Label* label) { - cond = testString(cond, t); - j(cond, label); - } - template void branchTestSymbol(Condition cond, const T& t, Label* label) { cond = testSymbol(cond, t); j(cond, label); From 523bf97f4e9987552ba48affe8e3c7e66e0f0056 Mon Sep 17 00:00:00 2001 From: Tooru Fujisawa Date: Thu, 3 Mar 2016 08:03:43 +0900 Subject: [PATCH 128/160] Bug 1245112 - Part 27: Move MacroAssembler::branchTestStringTruthy into generic macro assembler. r=sstangl --- js/src/jit/MacroAssembler.h | 2 ++ js/src/jit/arm/MacroAssembler-arm-inl.h | 7 +++++++ js/src/jit/arm/MacroAssembler-arm.h | 4 ---- js/src/jit/arm64/MacroAssembler-arm64-inl.h | 7 +++++++ js/src/jit/arm64/MacroAssembler-arm64.h | 4 ---- js/src/jit/mips32/MacroAssembler-mips32-inl.h | 9 +++++++++ js/src/jit/mips32/MacroAssembler-mips32.cpp | 8 -------- js/src/jit/mips32/MacroAssembler-mips32.h | 2 -- js/src/jit/mips64/MacroAssembler-mips64-inl.h | 9 +++++++++ js/src/jit/mips64/MacroAssembler-mips64.cpp | 8 -------- js/src/jit/mips64/MacroAssembler-mips64.h | 2 -- js/src/jit/none/MacroAssembler-none.h | 1 - js/src/jit/x64/MacroAssembler-x64.h | 4 ---- js/src/jit/x86-shared/MacroAssembler-x86-shared-inl.h | 7 +++++++ js/src/jit/x86/MacroAssembler-x86.h | 4 ---- 15 files changed, 41 insertions(+), 37 deletions(-) diff --git a/js/src/jit/MacroAssembler.h b/js/src/jit/MacroAssembler.h index bcb311f72c4..8f81f725de2 100644 --- a/js/src/jit/MacroAssembler.h +++ b/js/src/jit/MacroAssembler.h @@ -966,6 +966,8 @@ class MacroAssembler : public MacroAssemblerSpecific DEFINED_ON(arm, arm64, mips32, mips64, x86_shared); inline void branchTestDoubleTruthy(bool truthy, FloatRegister reg, Label* label) PER_SHARED_ARCH; inline void branchTestBooleanTruthy(bool truthy, const ValueOperand& value, Label* label) PER_ARCH; + inline void branchTestStringTruthy(bool truthy, const ValueOperand& value, Label* label) + DEFINED_ON(arm, arm64, mips32, mips64, x86_shared); private: diff --git a/js/src/jit/arm/MacroAssembler-arm-inl.h b/js/src/jit/arm/MacroAssembler-arm-inl.h index 3606f744f1e..71e9c0be5a3 100644 --- a/js/src/jit/arm/MacroAssembler-arm-inl.h +++ b/js/src/jit/arm/MacroAssembler-arm-inl.h @@ -994,6 +994,13 @@ MacroAssembler::branchTestStringImpl(Condition cond, const T& t, Label* label) ma_b(label, c); } +void +MacroAssembler::branchTestStringTruthy(bool truthy, const ValueOperand& value, Label* label) +{ + Condition c = testStringTruthy(truthy, value); + ma_b(label, c); +} + //}}} check_macroassembler_style // =============================================================== diff --git a/js/src/jit/arm/MacroAssembler-arm.h b/js/src/jit/arm/MacroAssembler-arm.h index 2c11d36d38a..c674768e274 100644 --- a/js/src/jit/arm/MacroAssembler-arm.h +++ b/js/src/jit/arm/MacroAssembler-arm.h @@ -787,10 +787,6 @@ class MacroAssemblerARMCompat : public MacroAssemblerARM MOZ_ASSERT(cond == Equal || cond == NotEqual); branchTestValue(cond, val, MagicValue(why), label); } - void branchTestStringTruthy(bool truthy, const ValueOperand& value, Label* label) { - Condition c = testStringTruthy(truthy, value); - ma_b(label, c); - } void moveValue(const Value& val, Register type, Register data); CodeOffsetJump jumpWithPatch(RepatchLabel* label, Condition cond = Always, diff --git a/js/src/jit/arm64/MacroAssembler-arm64-inl.h b/js/src/jit/arm64/MacroAssembler-arm64-inl.h index 443bb83e19c..1f259a86462 100644 --- a/js/src/jit/arm64/MacroAssembler-arm64-inl.h +++ b/js/src/jit/arm64/MacroAssembler-arm64-inl.h @@ -1093,6 +1093,13 @@ MacroAssembler::branchTestStringImpl(Condition cond, const T& t, Label* label) B(label, c); } +void +MacroAssembler::branchTestStringTruthy(bool truthy, const ValueOperand& value, Label* label) +{ + Condition c = testStringTruthy(truthy, value); + B(label, c); +} + //}}} check_macroassembler_style // =============================================================== diff --git a/js/src/jit/arm64/MacroAssembler-arm64.h b/js/src/jit/arm64/MacroAssembler-arm64.h index 91e669cd4cd..3fdf49631dc 100644 --- a/js/src/jit/arm64/MacroAssembler-arm64.h +++ b/js/src/jit/arm64/MacroAssembler-arm64.h @@ -1906,10 +1906,6 @@ class MacroAssemblerCompat : public vixl::MacroAssembler Cmp(scratch32, Operand(0)); return truthy ? Condition::NonZero : Condition::Zero; } - void branchTestStringTruthy(bool truthy, const ValueOperand& value, Label* label) { - Condition c = testStringTruthy(truthy, value); - B(label, c); - } void int32OrDouble(Register src, ARMFPRegister dest) { Label isInt32; Label join; diff --git a/js/src/jit/mips32/MacroAssembler-mips32-inl.h b/js/src/jit/mips32/MacroAssembler-mips32-inl.h index 69cbab1d24c..2f161d8538d 100644 --- a/js/src/jit/mips32/MacroAssembler-mips32-inl.h +++ b/js/src/jit/mips32/MacroAssembler-mips32-inl.h @@ -347,6 +347,15 @@ MacroAssembler::branchTestString(Condition cond, const ValueOperand& value, Labe branchTestString(cond, value.typeReg(), label); } +void +MacroAssembler::branchTestStringTruthy(bool b, const ValueOperand& value, Label* label) +{ + Register string = value.payloadReg(); + SecondScratchRegisterScope scratch2(*this); + ma_lw(scratch2, Address(string, JSString::offsetOfLength())); + ma_b(scratch2, Imm32(0), label, b ? NotEqual : Equal); +} + //}}} check_macroassembler_style // =============================================================== diff --git a/js/src/jit/mips32/MacroAssembler-mips32.cpp b/js/src/jit/mips32/MacroAssembler-mips32.cpp index a3f342050d0..8157e7a1edd 100644 --- a/js/src/jit/mips32/MacroAssembler-mips32.cpp +++ b/js/src/jit/mips32/MacroAssembler-mips32.cpp @@ -1508,14 +1508,6 @@ MacroAssemblerMIPSCompat::loadConstantDouble(double dp, FloatRegister dest) ma_lid(dest, dp); } -void -MacroAssemblerMIPSCompat::branchTestStringTruthy(bool b, const ValueOperand& value, Label* label) -{ - Register string = value.payloadReg(); - ma_lw(SecondScratchReg, Address(string, JSString::offsetOfLength())); - ma_b(SecondScratchReg, Imm32(0), label, b ? NotEqual : Equal); -} - Register MacroAssemblerMIPSCompat::extractObject(const Address& address, Register scratch) { diff --git a/js/src/jit/mips32/MacroAssembler-mips32.h b/js/src/jit/mips32/MacroAssembler-mips32.h index 0c71a372ce2..152034825a1 100644 --- a/js/src/jit/mips32/MacroAssembler-mips32.h +++ b/js/src/jit/mips32/MacroAssembler-mips32.h @@ -405,8 +405,6 @@ class MacroAssemblerMIPSCompat : public MacroAssemblerMIPS branchTestValue(cond, val, MagicValue(why), label); } - void branchTestStringTruthy(bool b, const ValueOperand& value, Label* label); - // higher level tag testing code Operand ToPayload(Operand base); Address ToPayload(Address base) { diff --git a/js/src/jit/mips64/MacroAssembler-mips64-inl.h b/js/src/jit/mips64/MacroAssembler-mips64-inl.h index 45f0f67d94d..dd9420887e1 100644 --- a/js/src/jit/mips64/MacroAssembler-mips64-inl.h +++ b/js/src/jit/mips64/MacroAssembler-mips64-inl.h @@ -296,6 +296,15 @@ MacroAssembler::branchTestString(Condition cond, const ValueOperand& value, Labe branchTestString(cond, scratch2, label); } +void +MacroAssembler::branchTestStringTruthy(bool b, const ValueOperand& value, Label* label) +{ + SecondScratchRegisterScope scratch2(*this); + unboxString(value, scratch2); + load32(Address(scratch2, JSString::offsetOfLength()), scratch2); + ma_b(scratch2, Imm32(0), label, b ? NotEqual : Equal); +} + //}}} check_macroassembler_style // =============================================================== diff --git a/js/src/jit/mips64/MacroAssembler-mips64.cpp b/js/src/jit/mips64/MacroAssembler-mips64.cpp index 2007c55aa6f..2d58a2e54fb 100644 --- a/js/src/jit/mips64/MacroAssembler-mips64.cpp +++ b/js/src/jit/mips64/MacroAssembler-mips64.cpp @@ -1728,14 +1728,6 @@ MacroAssemblerMIPS64Compat::loadConstantDouble(double dp, FloatRegister dest) ma_lid(dest, dp); } -void -MacroAssemblerMIPS64Compat::branchTestStringTruthy(bool b, const ValueOperand& value, Label* label) -{ - unboxString(value, SecondScratchReg); - load32(Address(SecondScratchReg, JSString::offsetOfLength()), SecondScratchReg); - ma_b(SecondScratchReg, Imm32(0), label, b ? NotEqual : Equal); -} - Register MacroAssemblerMIPS64Compat::extractObject(const Address& address, Register scratch) { diff --git a/js/src/jit/mips64/MacroAssembler-mips64.h b/js/src/jit/mips64/MacroAssembler-mips64.h index 51d26e17507..e520bb2bffc 100644 --- a/js/src/jit/mips64/MacroAssembler-mips64.h +++ b/js/src/jit/mips64/MacroAssembler-mips64.h @@ -446,8 +446,6 @@ class MacroAssemblerMIPS64Compat : public MacroAssemblerMIPS64 branchTestValue(cond, val, MagicValue(why), label); } - void branchTestStringTruthy(bool b, const ValueOperand& value, Label* label); - // higher level tag testing code Address ToPayload(Address value) { return value; diff --git a/js/src/jit/none/MacroAssembler-none.h b/js/src/jit/none/MacroAssembler-none.h index 3d6600ad977..31b80137ad6 100644 --- a/js/src/jit/none/MacroAssembler-none.h +++ b/js/src/jit/none/MacroAssembler-none.h @@ -389,7 +389,6 @@ class MacroAssemblerNone : public Assembler void loadConstantFloat32(float, FloatRegister) { MOZ_CRASH(); } Condition testInt32Truthy(bool, ValueOperand) { MOZ_CRASH(); } Condition testStringTruthy(bool, ValueOperand) { MOZ_CRASH(); } - void branchTestStringTruthy(bool, ValueOperand, Label*) { MOZ_CRASH(); } template void loadUnboxedValue(T, MIRType, AnyRegister) { MOZ_CRASH(); } template void storeUnboxedValue(ConstantOrRegister, MIRType, T, MIRType) { MOZ_CRASH(); } diff --git a/js/src/jit/x64/MacroAssembler-x64.h b/js/src/jit/x64/MacroAssembler-x64.h index f9c3bad0fd3..c692b21ede8 100644 --- a/js/src/jit/x64/MacroAssembler-x64.h +++ b/js/src/jit/x64/MacroAssembler-x64.h @@ -966,10 +966,6 @@ class MacroAssemblerX64 : public MacroAssemblerX86Shared cmp32(Operand(scratch, JSString::offsetOfLength()), Imm32(0)); return truthy ? Assembler::NotEqual : Assembler::Equal; } - void branchTestStringTruthy(bool truthy, const ValueOperand& value, Label* label) { - Condition cond = testStringTruthy(truthy, value); - j(cond, label); - } template inline void loadInt32OrDouble(const T& src, FloatRegister dest); diff --git a/js/src/jit/x86-shared/MacroAssembler-x86-shared-inl.h b/js/src/jit/x86-shared/MacroAssembler-x86-shared-inl.h index 6deacee31c9..a9630f94df6 100644 --- a/js/src/jit/x86-shared/MacroAssembler-x86-shared-inl.h +++ b/js/src/jit/x86-shared/MacroAssembler-x86-shared-inl.h @@ -616,6 +616,13 @@ MacroAssembler::branchTestStringImpl(Condition cond, const T& t, Label* label) j(cond, label); } +void +MacroAssembler::branchTestStringTruthy(bool truthy, const ValueOperand& value, Label* label) +{ + Condition cond = testStringTruthy(truthy, value); + j(cond, label); +} + //}}} check_macroassembler_style // =============================================================== diff --git a/js/src/jit/x86/MacroAssembler-x86.h b/js/src/jit/x86/MacroAssembler-x86.h index 7f87071bf8f..a6bb6a2b542 100644 --- a/js/src/jit/x86/MacroAssembler-x86.h +++ b/js/src/jit/x86/MacroAssembler-x86.h @@ -825,10 +825,6 @@ class MacroAssemblerX86 : public MacroAssemblerX86Shared cmp32(Operand(string, JSString::offsetOfLength()), Imm32(0)); return truthy ? Assembler::NotEqual : Assembler::Equal; } - void branchTestStringTruthy(bool truthy, const ValueOperand& value, Label* label) { - Condition cond = testStringTruthy(truthy, value); - j(cond, label); - } template inline void loadInt32OrDouble(const T& src, FloatRegister dest); From 63e6848cd104e2a07974cfe395cea80cb87845cf Mon Sep 17 00:00:00 2001 From: Tooru Fujisawa Date: Thu, 3 Mar 2016 08:03:43 +0900 Subject: [PATCH 129/160] Bug 1245112 - Part 28: Move MacroAssembler::branchTestSymbol into generic macro assembler. r=jorendorff --- js/src/jit/MacroAssembler.h | 8 ++++++ js/src/jit/arm/MacroAssembler-arm-inl.h | 26 +++++++++++++++++++ js/src/jit/arm/MacroAssembler-arm.h | 5 ---- js/src/jit/arm64/MacroAssembler-arm64-inl.h | 26 +++++++++++++++++++ js/src/jit/arm64/MacroAssembler-arm64.h | 16 ------------ .../MacroAssembler-mips-shared-inl.h | 15 +++++++++++ js/src/jit/mips32/MacroAssembler-mips32-inl.h | 6 +++++ js/src/jit/mips32/MacroAssembler-mips32.cpp | 21 --------------- js/src/jit/mips32/MacroAssembler-mips32.h | 4 --- js/src/jit/mips64/MacroAssembler-mips64-inl.h | 8 ++++++ js/src/jit/mips64/MacroAssembler-mips64.cpp | 22 ---------------- js/src/jit/mips64/MacroAssembler-mips64.h | 4 --- js/src/jit/none/MacroAssembler-none.h | 1 - js/src/jit/x64/MacroAssembler-x64.h | 12 --------- .../MacroAssembler-x86-shared-inl.h | 26 +++++++++++++++++++ js/src/jit/x86/MacroAssembler-x86.h | 5 ---- 16 files changed, 115 insertions(+), 90 deletions(-) diff --git a/js/src/jit/MacroAssembler.h b/js/src/jit/MacroAssembler.h index 8f81f725de2..082d7c412b7 100644 --- a/js/src/jit/MacroAssembler.h +++ b/js/src/jit/MacroAssembler.h @@ -930,6 +930,7 @@ class MacroAssembler : public MacroAssemblerSpecific inline void branchTestNumber(Condition cond, Register tag, Label* label) PER_SHARED_ARCH; inline void branchTestBoolean(Condition cond, Register tag, Label* label) PER_SHARED_ARCH; inline void branchTestString(Condition cond, Register tag, Label* label) PER_SHARED_ARCH; + inline void branchTestSymbol(Condition cond, Register tag, Label* label) PER_SHARED_ARCH; // Perform a type-test on a Value, addressed by Address or BaseIndex, or // loaded into ValueOperand. @@ -960,6 +961,10 @@ class MacroAssembler : public MacroAssemblerSpecific inline void branchTestString(Condition cond, const ValueOperand& value, Label* label) DEFINED_ON(arm, arm64, mips32, mips64, x86_shared); + inline void branchTestSymbol(Condition cond, const BaseIndex& address, Label* label) PER_SHARED_ARCH; + inline void branchTestSymbol(Condition cond, const ValueOperand& value, Label* label) + DEFINED_ON(arm, arm64, mips32, mips64, x86_shared); + // Checks if given Value is evaluated to true or false in a condition. // The type of the value should match the type of the method. inline void branchTestInt32Truthy(bool truthy, const ValueOperand& value, Label* label) @@ -990,6 +995,9 @@ class MacroAssembler : public MacroAssemblerSpecific template inline void branchTestStringImpl(Condition cond, const T& t, Label* label) DEFINED_ON(arm, arm64, x86_shared); + template + inline void branchTestSymbolImpl(Condition cond, const T& t, Label* label) + DEFINED_ON(arm, arm64, x86_shared); //}}} check_macroassembler_style public: diff --git a/js/src/jit/arm/MacroAssembler-arm-inl.h b/js/src/jit/arm/MacroAssembler-arm-inl.h index 71e9c0be5a3..61f7ec62bdc 100644 --- a/js/src/jit/arm/MacroAssembler-arm-inl.h +++ b/js/src/jit/arm/MacroAssembler-arm-inl.h @@ -1001,6 +1001,32 @@ MacroAssembler::branchTestStringTruthy(bool truthy, const ValueOperand& value, L ma_b(label, c); } +void +MacroAssembler::branchTestSymbol(Condition cond, Register tag, Label* label) +{ + branchTestSymbolImpl(cond, tag, label); +} + +void +MacroAssembler::branchTestSymbol(Condition cond, const BaseIndex& address, Label* label) +{ + branchTestSymbolImpl(cond, address, label); +} + +void +MacroAssembler::branchTestSymbol(Condition cond, const ValueOperand& value, Label* label) +{ + branchTestSymbolImpl(cond, value, label); +} + +template +void +MacroAssembler::branchTestSymbolImpl(Condition cond, const T& t, Label* label) +{ + Condition c = testSymbol(cond, t); + ma_b(label, c); +} + //}}} check_macroassembler_style // =============================================================== diff --git a/js/src/jit/arm/MacroAssembler-arm.h b/js/src/jit/arm/MacroAssembler-arm.h index c674768e274..4501dfcfb3b 100644 --- a/js/src/jit/arm/MacroAssembler-arm.h +++ b/js/src/jit/arm/MacroAssembler-arm.h @@ -772,11 +772,6 @@ class MacroAssemblerARMCompat : public MacroAssemblerARM Condition c = testObject(cond, t); ma_b(label, c); } - template - void branchTestSymbol(Condition cond, const T & t, Label* label) { - Condition c = testSymbol(cond, t); - ma_b(label, c); - } template void branchTestMagic(Condition cond, const T& t, L label) { cond = testMagic(cond, t); diff --git a/js/src/jit/arm64/MacroAssembler-arm64-inl.h b/js/src/jit/arm64/MacroAssembler-arm64-inl.h index 1f259a86462..8c86d751967 100644 --- a/js/src/jit/arm64/MacroAssembler-arm64-inl.h +++ b/js/src/jit/arm64/MacroAssembler-arm64-inl.h @@ -1100,6 +1100,32 @@ MacroAssembler::branchTestStringTruthy(bool truthy, const ValueOperand& value, L B(label, c); } +void +MacroAssembler::branchTestSymbol(Condition cond, Register tag, Label* label) +{ + branchTestSymbolImpl(cond, tag, label); +} + +void +MacroAssembler::branchTestSymbol(Condition cond, const BaseIndex& address, Label* label) +{ + branchTestSymbolImpl(cond, address, label); +} + +void +MacroAssembler::branchTestSymbol(Condition cond, const ValueOperand& value, Label* label) +{ + branchTestSymbolImpl(cond, value, label); +} + +template +void +MacroAssembler::branchTestSymbolImpl(Condition cond, const T& t, Label* label) +{ + Condition c = testSymbol(cond, t); + B(label, c); +} + //}}} check_macroassembler_style // =============================================================== diff --git a/js/src/jit/arm64/MacroAssembler-arm64.h b/js/src/jit/arm64/MacroAssembler-arm64.h index 3fdf49631dc..189dd7bda9c 100644 --- a/js/src/jit/arm64/MacroAssembler-arm64.h +++ b/js/src/jit/arm64/MacroAssembler-arm64.h @@ -1332,10 +1332,6 @@ class MacroAssemblerCompat : public vixl::MacroAssembler Condition c = testNull(cond, tag); B(label, c); } - void branchTestSymbol(Condition cond, Register tag, Label* label) { - Condition c = testSymbol(cond, tag); - B(label, c); - } void branchTestObject(Condition cond, Register tag, Label* label) { Condition c = testObject(cond, tag); B(label, c); @@ -1345,10 +1341,6 @@ class MacroAssemblerCompat : public vixl::MacroAssembler Condition c = testNull(cond, address); B(label, c); } - void branchTestSymbol(Condition cond, const Address& address, Label* label) { - Condition c = testSymbol(cond, address); - B(label, c); - } void branchTestObject(Condition cond, const Address& address, Label* label) { Condition c = testObject(cond, address); B(label, c); @@ -1360,10 +1352,6 @@ class MacroAssemblerCompat : public vixl::MacroAssembler Condition c = testNull(cond, src); B(label, c); } - void branchTestSymbol(Condition cond, const ValueOperand& src, Label* label) { - Condition c = testSymbol(cond, src); - B(label, c); - } void branchTestObject(Condition cond, const ValueOperand& src, Label* label) { Condition c = testObject(cond, src); B(label, c); @@ -1375,10 +1363,6 @@ class MacroAssemblerCompat : public vixl::MacroAssembler Condition c = testNull(cond, address); B(label, c); } - void branchTestSymbol(Condition cond, const BaseIndex& address, Label* label) { - Condition c = testSymbol(cond, address); - B(label, c); - } void branchTestObject(Condition cond, const BaseIndex& address, Label* label) { Condition c = testObject(cond, address); B(label, c); diff --git a/js/src/jit/mips-shared/MacroAssembler-mips-shared-inl.h b/js/src/jit/mips-shared/MacroAssembler-mips-shared-inl.h index b28d1ce0c68..d196c3f4efa 100644 --- a/js/src/jit/mips-shared/MacroAssembler-mips-shared-inl.h +++ b/js/src/jit/mips-shared/MacroAssembler-mips-shared-inl.h @@ -625,6 +625,21 @@ MacroAssembler::branchTestString(Condition cond, const BaseIndex& address, Label branchTestString(cond, scratch2, label); } +void +MacroAssembler::branchTestSymbol(Condition cond, Register tag, Label* label) +{ + MOZ_ASSERT(cond == Equal || cond == NotEqual); + ma_b(tag, ImmTag(JSVAL_TAG_SYMBOL), label, cond); +} + +void +MacroAssembler::branchTestSymbol(Condition cond, const BaseIndex& address, Label* label) +{ + SecondScratchRegisterScope scratch2(*this); + extractTag(address, scratch2); + branchTestSymbol(cond, scratch2, label); +} + //}}} check_macroassembler_style // =============================================================== diff --git a/js/src/jit/mips32/MacroAssembler-mips32-inl.h b/js/src/jit/mips32/MacroAssembler-mips32-inl.h index 2f161d8538d..307d017b8aa 100644 --- a/js/src/jit/mips32/MacroAssembler-mips32-inl.h +++ b/js/src/jit/mips32/MacroAssembler-mips32-inl.h @@ -356,6 +356,12 @@ MacroAssembler::branchTestStringTruthy(bool b, const ValueOperand& value, Label* ma_b(scratch2, Imm32(0), label, b ? NotEqual : Equal); } +void +MacroAssembler::branchTestSymbol(Condition cond, const ValueOperand& value, Label* label) +{ + branchTestSymbol(cond, value.typeReg(), label); +} + //}}} check_macroassembler_style // =============================================================== diff --git a/js/src/jit/mips32/MacroAssembler-mips32.cpp b/js/src/jit/mips32/MacroAssembler-mips32.cpp index 8157e7a1edd..10399a70bb8 100644 --- a/js/src/jit/mips32/MacroAssembler-mips32.cpp +++ b/js/src/jit/mips32/MacroAssembler-mips32.cpp @@ -1198,27 +1198,6 @@ MacroAssemblerMIPSCompat::testObjectSet(Condition cond, const ValueOperand& valu ma_cmp_set(dest, value.typeReg(), ImmType(JSVAL_TYPE_OBJECT), cond); } -void -MacroAssemblerMIPSCompat::branchTestSymbol(Condition cond, const ValueOperand& value, Label* label) -{ - branchTestSymbol(cond, value.typeReg(), label); -} - -void -MacroAssemblerMIPSCompat::branchTestSymbol(Condition cond, const Register& tag, Label* label) -{ - MOZ_ASSERT(cond == Equal || cond == NotEqual); - ma_b(tag, ImmTag(JSVAL_TAG_SYMBOL), label, cond); -} - -void -MacroAssemblerMIPSCompat::branchTestSymbol(Condition cond, const BaseIndex& src, Label* label) -{ - MOZ_ASSERT(cond == Equal || cond == NotEqual); - extractTag(src, SecondScratchReg); - ma_b(SecondScratchReg, ImmTag(JSVAL_TAG_SYMBOL), label, cond); -} - void MacroAssemblerMIPSCompat::testUndefinedSet(Condition cond, const ValueOperand& value, Register dest) { diff --git a/js/src/jit/mips32/MacroAssembler-mips32.h b/js/src/jit/mips32/MacroAssembler-mips32.h index 152034825a1..35388fa2dd7 100644 --- a/js/src/jit/mips32/MacroAssembler-mips32.h +++ b/js/src/jit/mips32/MacroAssembler-mips32.h @@ -387,10 +387,6 @@ class MacroAssemblerMIPSCompat : public MacroAssemblerMIPS void branchTestObject(Condition cond, const Address& src, Label* label); void testObjectSet(Condition cond, const ValueOperand& value, Register dest); - void branchTestSymbol(Condition cond, const ValueOperand& value, Label* label); - void branchTestSymbol(Condition cond, const Register& tag, Label* label); - void branchTestSymbol(Condition cond, const BaseIndex& src, Label* label); - void testUndefinedSet(Condition cond, const ValueOperand& value, Register dest); void branchTestMagic(Condition cond, const ValueOperand& value, Label* label); diff --git a/js/src/jit/mips64/MacroAssembler-mips64-inl.h b/js/src/jit/mips64/MacroAssembler-mips64-inl.h index dd9420887e1..4cb75877f9b 100644 --- a/js/src/jit/mips64/MacroAssembler-mips64-inl.h +++ b/js/src/jit/mips64/MacroAssembler-mips64-inl.h @@ -305,6 +305,14 @@ MacroAssembler::branchTestStringTruthy(bool b, const ValueOperand& value, Label* ma_b(scratch2, Imm32(0), label, b ? NotEqual : Equal); } +void +MacroAssembler::branchTestSymbol(Condition cond, const ValueOperand& value, Label* label) +{ + SecondScratchRegisterScope scratch2(*this); + splitTag(value, scratch2); + branchTestSymbol(cond, scratch2, label); +} + //}}} check_macroassembler_style // =============================================================== diff --git a/js/src/jit/mips64/MacroAssembler-mips64.cpp b/js/src/jit/mips64/MacroAssembler-mips64.cpp index 2d58a2e54fb..958d535778b 100644 --- a/js/src/jit/mips64/MacroAssembler-mips64.cpp +++ b/js/src/jit/mips64/MacroAssembler-mips64.cpp @@ -1330,28 +1330,6 @@ MacroAssemblerMIPS64Compat::testObjectSet(Condition cond, const ValueOperand& va ma_cmp_set(dest, SecondScratchReg, ImmTag(JSVAL_TAG_OBJECT), cond); } -void -MacroAssemblerMIPS64Compat::branchTestSymbol(Condition cond, const ValueOperand& value, Label* label) -{ - splitTag(value, SecondScratchReg); - branchTestSymbol(cond, SecondScratchReg, label); -} - -void -MacroAssemblerMIPS64Compat::branchTestSymbol(Condition cond, const Register& tag, Label* label) -{ - MOZ_ASSERT(cond == Equal || cond == NotEqual); - ma_b(tag, ImmTag(JSVAL_TAG_SYMBOL), label, cond); -} - -void -MacroAssemblerMIPS64Compat::branchTestSymbol(Condition cond, const BaseIndex& src, Label* label) -{ - MOZ_ASSERT(cond == Equal || cond == NotEqual); - extractTag(src, SecondScratchReg); - ma_b(SecondScratchReg, ImmTag(JSVAL_TAG_SYMBOL), label, cond); -} - void MacroAssemblerMIPS64Compat::testUndefinedSet(Condition cond, const ValueOperand& value, Register dest) { diff --git a/js/src/jit/mips64/MacroAssembler-mips64.h b/js/src/jit/mips64/MacroAssembler-mips64.h index e520bb2bffc..256c0f4058c 100644 --- a/js/src/jit/mips64/MacroAssembler-mips64.h +++ b/js/src/jit/mips64/MacroAssembler-mips64.h @@ -428,10 +428,6 @@ class MacroAssemblerMIPS64Compat : public MacroAssemblerMIPS64 void branchTestObject(Condition cond, const Address& src, Label* label); void testObjectSet(Condition cond, const ValueOperand& value, Register dest); - void branchTestSymbol(Condition cond, const ValueOperand& value, Label* label); - void branchTestSymbol(Condition cond, const Register& tag, Label* label); - void branchTestSymbol(Condition cond, const BaseIndex& src, Label* label); - void testUndefinedSet(Condition cond, const ValueOperand& value, Register dest); void branchTestMagic(Condition cond, const ValueOperand& value, Label* label); diff --git a/js/src/jit/none/MacroAssembler-none.h b/js/src/jit/none/MacroAssembler-none.h index 31b80137ad6..f11d85a9643 100644 --- a/js/src/jit/none/MacroAssembler-none.h +++ b/js/src/jit/none/MacroAssembler-none.h @@ -346,7 +346,6 @@ class MacroAssemblerNone : public Assembler Register splitTagForTest(ValueOperand) { MOZ_CRASH(); } template void branchTestNull(Condition, T, Label*) { MOZ_CRASH(); } - template void branchTestSymbol(Condition, T, Label*) { MOZ_CRASH(); } template void branchTestObject(Condition, T, Label*) { MOZ_CRASH(); } template void branchTestGCThing(Condition, T, Label*) { MOZ_CRASH(); } template void branchTestPrimitive(Condition, T, Label*) { MOZ_CRASH(); } diff --git a/js/src/jit/x64/MacroAssembler-x64.h b/js/src/jit/x64/MacroAssembler-x64.h index c692b21ede8..2b5a83dbb18 100644 --- a/js/src/jit/x64/MacroAssembler-x64.h +++ b/js/src/jit/x64/MacroAssembler-x64.h @@ -688,10 +688,6 @@ class MacroAssemblerX64 : public MacroAssemblerX86Shared cond = testNull(cond, tag); j(cond, label); } - void branchTestSymbol(Condition cond, Register tag, Label* label) { - cond = testSymbol(cond, tag); - j(cond, label); - } void branchTestObject(Condition cond, Register tag, Label* label) { cond = testObject(cond, tag); j(cond, label); @@ -722,10 +718,6 @@ class MacroAssemblerX64 : public MacroAssemblerX86Shared cond = testNull(cond, src); j(cond, label); } - void branchTestSymbol(Condition cond, const ValueOperand& src, Label* label) { - cond = testSymbol(cond, src); - j(cond, label); - } void branchTestObject(Condition cond, const ValueOperand& src, Label* label) { cond = testObject(cond, src); j(cond, label); @@ -737,10 +729,6 @@ class MacroAssemblerX64 : public MacroAssemblerX86Shared cond = testNull(cond, address); j(cond, label); } - void branchTestSymbol(Condition cond, const BaseIndex& address, Label* label) { - cond = testSymbol(cond, address); - j(cond, label); - } void branchTestObject(Condition cond, const BaseIndex& address, Label* label) { cond = testObject(cond, address); j(cond, label); diff --git a/js/src/jit/x86-shared/MacroAssembler-x86-shared-inl.h b/js/src/jit/x86-shared/MacroAssembler-x86-shared-inl.h index a9630f94df6..fa254a688b8 100644 --- a/js/src/jit/x86-shared/MacroAssembler-x86-shared-inl.h +++ b/js/src/jit/x86-shared/MacroAssembler-x86-shared-inl.h @@ -623,6 +623,32 @@ MacroAssembler::branchTestStringTruthy(bool truthy, const ValueOperand& value, L j(cond, label); } +void +MacroAssembler::branchTestSymbol(Condition cond, Register tag, Label* label) +{ + branchTestSymbolImpl(cond, tag, label); +} + +void +MacroAssembler::branchTestSymbol(Condition cond, const BaseIndex& address, Label* label) +{ + branchTestSymbolImpl(cond, address, label); +} + +void +MacroAssembler::branchTestSymbol(Condition cond, const ValueOperand& value, Label* label) +{ + branchTestSymbolImpl(cond, value, label); +} + +template +void +MacroAssembler::branchTestSymbolImpl(Condition cond, const T& t, Label* label) +{ + cond = testSymbol(cond, t); + j(cond, label); +} + //}}} check_macroassembler_style // =============================================================== diff --git a/js/src/jit/x86/MacroAssembler-x86.h b/js/src/jit/x86/MacroAssembler-x86.h index a6bb6a2b542..5bb11da1efe 100644 --- a/js/src/jit/x86/MacroAssembler-x86.h +++ b/js/src/jit/x86/MacroAssembler-x86.h @@ -665,11 +665,6 @@ class MacroAssemblerX86 : public MacroAssemblerX86Shared j(cond, label); } template - void branchTestSymbol(Condition cond, const T& t, Label* label) { - cond = testSymbol(cond, t); - j(cond, label); - } - template void branchTestObject(Condition cond, const T& t, Label* label) { cond = testObject(cond, t); j(cond, label); From 7351a2d114a985c0c0c3bc5c65d214acd71fd8b9 Mon Sep 17 00:00:00 2001 From: Tooru Fujisawa Date: Thu, 3 Mar 2016 08:03:44 +0900 Subject: [PATCH 130/160] Bug 1245112 - Part 29: Move MacroAssembler::branchTestNull into generic macro assembler. r=sstangl --- js/src/jit/MacroAssembler.h | 9 ++++++ js/src/jit/arm/MacroAssembler-arm-inl.h | 32 +++++++++++++++++++ js/src/jit/arm/MacroAssembler-arm.h | 5 --- js/src/jit/arm64/MacroAssembler-arm64-inl.h | 32 +++++++++++++++++++ js/src/jit/arm64/MacroAssembler-arm64.h | 16 ---------- .../MacroAssembler-mips-shared-inl.h | 23 +++++++++++++ js/src/jit/mips32/MacroAssembler-mips32-inl.h | 6 ++++ js/src/jit/mips32/MacroAssembler-mips32.cpp | 29 ----------------- js/src/jit/mips32/MacroAssembler-mips32.h | 4 --- js/src/jit/mips64/MacroAssembler-mips64-inl.h | 8 +++++ js/src/jit/mips64/MacroAssembler-mips64.cpp | 30 ----------------- js/src/jit/mips64/MacroAssembler-mips64.h | 4 --- js/src/jit/none/MacroAssembler-none.h | 1 - js/src/jit/x64/MacroAssembler-x64.h | 27 ++-------------- .../MacroAssembler-x86-shared-inl.h | 32 +++++++++++++++++++ js/src/jit/x86/MacroAssembler-x86.h | 5 --- 16 files changed, 144 insertions(+), 119 deletions(-) diff --git a/js/src/jit/MacroAssembler.h b/js/src/jit/MacroAssembler.h index 082d7c412b7..fd3076d0b25 100644 --- a/js/src/jit/MacroAssembler.h +++ b/js/src/jit/MacroAssembler.h @@ -931,6 +931,7 @@ class MacroAssembler : public MacroAssemblerSpecific inline void branchTestBoolean(Condition cond, Register tag, Label* label) PER_SHARED_ARCH; inline void branchTestString(Condition cond, Register tag, Label* label) PER_SHARED_ARCH; inline void branchTestSymbol(Condition cond, Register tag, Label* label) PER_SHARED_ARCH; + inline void branchTestNull(Condition cond, Register tag, Label* label) PER_SHARED_ARCH; // Perform a type-test on a Value, addressed by Address or BaseIndex, or // loaded into ValueOperand. @@ -965,6 +966,11 @@ class MacroAssembler : public MacroAssemblerSpecific inline void branchTestSymbol(Condition cond, const ValueOperand& value, Label* label) DEFINED_ON(arm, arm64, mips32, mips64, x86_shared); + inline void branchTestNull(Condition cond, const Address& address, Label* label) PER_SHARED_ARCH; + inline void branchTestNull(Condition cond, const BaseIndex& address, Label* label) PER_SHARED_ARCH; + inline void branchTestNull(Condition cond, const ValueOperand& value, Label* label) + DEFINED_ON(arm, arm64, mips32, mips64, x86_shared); + // Checks if given Value is evaluated to true or false in a condition. // The type of the value should match the type of the method. inline void branchTestInt32Truthy(bool truthy, const ValueOperand& value, Label* label) @@ -998,6 +1004,9 @@ class MacroAssembler : public MacroAssemblerSpecific template inline void branchTestSymbolImpl(Condition cond, const T& t, Label* label) DEFINED_ON(arm, arm64, x86_shared); + template + inline void branchTestNullImpl(Condition cond, const T& t, Label* label) + DEFINED_ON(arm, arm64, x86_shared); //}}} check_macroassembler_style public: diff --git a/js/src/jit/arm/MacroAssembler-arm-inl.h b/js/src/jit/arm/MacroAssembler-arm-inl.h index 61f7ec62bdc..c2995c6dce3 100644 --- a/js/src/jit/arm/MacroAssembler-arm-inl.h +++ b/js/src/jit/arm/MacroAssembler-arm-inl.h @@ -1027,6 +1027,38 @@ MacroAssembler::branchTestSymbolImpl(Condition cond, const T& t, Label* label) ma_b(label, c); } +void +MacroAssembler::branchTestNull(Condition cond, Register tag, Label* label) +{ + branchTestNullImpl(cond, tag, label); +} + +void +MacroAssembler::branchTestNull(Condition cond, const Address& address, Label* label) +{ + branchTestNullImpl(cond, address, label); +} + +void +MacroAssembler::branchTestNull(Condition cond, const BaseIndex& address, Label* label) +{ + branchTestNullImpl(cond, address, label); +} + +void +MacroAssembler::branchTestNull(Condition cond, const ValueOperand& value, Label* label) +{ + branchTestNullImpl(cond, value, label); +} + +template +void +MacroAssembler::branchTestNullImpl(Condition cond, const T& t, Label* label) +{ + Condition c = testNull(cond, t); + ma_b(label, c); +} + //}}} check_macroassembler_style // =============================================================== diff --git a/js/src/jit/arm/MacroAssembler-arm.h b/js/src/jit/arm/MacroAssembler-arm.h index 4501dfcfb3b..b09f209ba58 100644 --- a/js/src/jit/arm/MacroAssembler-arm.h +++ b/js/src/jit/arm/MacroAssembler-arm.h @@ -762,11 +762,6 @@ class MacroAssemblerARMCompat : public MacroAssemblerARM void int32ValueToFloat32(const ValueOperand& operand, FloatRegister dest); void loadConstantFloat32(float f, FloatRegister dest); - template - void branchTestNull(Condition cond, const T & t, Label* label) { - Condition c = testNull(cond, t); - ma_b(label, c); - } template void branchTestObject(Condition cond, const T & t, Label* label) { Condition c = testObject(cond, t); diff --git a/js/src/jit/arm64/MacroAssembler-arm64-inl.h b/js/src/jit/arm64/MacroAssembler-arm64-inl.h index 8c86d751967..44eb6e76e7a 100644 --- a/js/src/jit/arm64/MacroAssembler-arm64-inl.h +++ b/js/src/jit/arm64/MacroAssembler-arm64-inl.h @@ -1126,6 +1126,38 @@ MacroAssembler::branchTestSymbolImpl(Condition cond, const T& t, Label* label) B(label, c); } +void +MacroAssembler::branchTestNull(Condition cond, Register tag, Label* label) +{ + branchTestNullImpl(cond, tag, label); +} + +void +MacroAssembler::branchTestNull(Condition cond, const Address& address, Label* label) +{ + branchTestNullImpl(cond, address, label); +} + +void +MacroAssembler::branchTestNull(Condition cond, const BaseIndex& address, Label* label) +{ + branchTestNullImpl(cond, address, label); +} + +void +MacroAssembler::branchTestNull(Condition cond, const ValueOperand& value, Label* label) +{ + branchTestNullImpl(cond, value, label); +} + +template +void +MacroAssembler::branchTestNullImpl(Condition cond, const T& t, Label* label) +{ + Condition c = testNull(cond, t); + B(label, c); +} + //}}} check_macroassembler_style // =============================================================== diff --git a/js/src/jit/arm64/MacroAssembler-arm64.h b/js/src/jit/arm64/MacroAssembler-arm64.h index 189dd7bda9c..ee8fc2878f4 100644 --- a/js/src/jit/arm64/MacroAssembler-arm64.h +++ b/js/src/jit/arm64/MacroAssembler-arm64.h @@ -1328,19 +1328,11 @@ class MacroAssemblerCompat : public vixl::MacroAssembler return jumpWithPatch(label, Always, documentation); } - void branchTestNull(Condition cond, Register tag, Label* label) { - Condition c = testNull(cond, tag); - B(label, c); - } void branchTestObject(Condition cond, Register tag, Label* label) { Condition c = testObject(cond, tag); B(label, c); } - void branchTestNull(Condition cond, const Address& address, Label* label) { - Condition c = testNull(cond, address); - B(label, c); - } void branchTestObject(Condition cond, const Address& address, Label* label) { Condition c = testObject(cond, address); B(label, c); @@ -1348,10 +1340,6 @@ class MacroAssemblerCompat : public vixl::MacroAssembler // Perform a type-test on a full Value loaded into a register. // Clobbers the ScratchReg. - void branchTestNull(Condition cond, const ValueOperand& src, Label* label) { - Condition c = testNull(cond, src); - B(label, c); - } void branchTestObject(Condition cond, const ValueOperand& src, Label* label) { Condition c = testObject(cond, src); B(label, c); @@ -1359,10 +1347,6 @@ class MacroAssemblerCompat : public vixl::MacroAssembler // Perform a type-test on a Value addressed by BaseIndex. // Clobbers the ScratchReg. - void branchTestNull(Condition cond, const BaseIndex& address, Label* label) { - Condition c = testNull(cond, address); - B(label, c); - } void branchTestObject(Condition cond, const BaseIndex& address, Label* label) { Condition c = testObject(cond, address); B(label, c); diff --git a/js/src/jit/mips-shared/MacroAssembler-mips-shared-inl.h b/js/src/jit/mips-shared/MacroAssembler-mips-shared-inl.h index d196c3f4efa..0cfe5122f95 100644 --- a/js/src/jit/mips-shared/MacroAssembler-mips-shared-inl.h +++ b/js/src/jit/mips-shared/MacroAssembler-mips-shared-inl.h @@ -640,6 +640,29 @@ MacroAssembler::branchTestSymbol(Condition cond, const BaseIndex& address, Label branchTestSymbol(cond, scratch2, label); } +void +MacroAssembler::branchTestNull(Condition cond, Register tag, Label* label) +{ + MOZ_ASSERT(cond == Equal || cond == NotEqual); + ma_b(tag, ImmTag(JSVAL_TAG_NULL), label, cond); +} + +void +MacroAssembler::branchTestNull(Condition cond, const Address& address, Label* label) +{ + SecondScratchRegisterScope scratch2(*this); + extractTag(address, scratch2); + branchTestNull(cond, scratch2, label); +} + +void +MacroAssembler::branchTestNull(Condition cond, const BaseIndex& address, Label* label) +{ + SecondScratchRegisterScope scratch2(*this); + extractTag(address, scratch2); + branchTestNull(cond, scratch2, label); +} + //}}} check_macroassembler_style // =============================================================== diff --git a/js/src/jit/mips32/MacroAssembler-mips32-inl.h b/js/src/jit/mips32/MacroAssembler-mips32-inl.h index 307d017b8aa..fd966e5d732 100644 --- a/js/src/jit/mips32/MacroAssembler-mips32-inl.h +++ b/js/src/jit/mips32/MacroAssembler-mips32-inl.h @@ -362,6 +362,12 @@ MacroAssembler::branchTestSymbol(Condition cond, const ValueOperand& value, Labe branchTestSymbol(cond, value.typeReg(), label); } +void +MacroAssembler::branchTestNull(Condition cond, const ValueOperand& value, Label* label) +{ + branchTestNull(cond, value.typeReg(), label); +} + //}}} check_macroassembler_style // =============================================================== diff --git a/js/src/jit/mips32/MacroAssembler-mips32.cpp b/js/src/jit/mips32/MacroAssembler-mips32.cpp index 10399a70bb8..71ae26f1813 100644 --- a/js/src/jit/mips32/MacroAssembler-mips32.cpp +++ b/js/src/jit/mips32/MacroAssembler-mips32.cpp @@ -1126,35 +1126,6 @@ MacroAssemblerMIPSCompat::branchTestPrimitive(Condition cond, Register tag, Labe (cond == Equal) ? Below : AboveOrEqual); } -void -MacroAssemblerMIPSCompat::branchTestNull(Condition cond, const ValueOperand& value, Label* label) -{ - MOZ_ASSERT(cond == Equal || cond == NotEqual); - ma_b(value.typeReg(), ImmType(JSVAL_TYPE_NULL), label, cond); -} - -void -MacroAssemblerMIPSCompat::branchTestNull(Condition cond, Register tag, Label* label) -{ - MOZ_ASSERT(cond == Equal || cond == NotEqual); - ma_b(tag, ImmTag(JSVAL_TAG_NULL), label, cond); -} - -void -MacroAssemblerMIPSCompat::branchTestNull(Condition cond, const BaseIndex& src, Label* label) -{ - MOZ_ASSERT(cond == Equal || cond == NotEqual); - extractTag(src, SecondScratchReg); - ma_b(SecondScratchReg, ImmTag(JSVAL_TAG_NULL), label, cond); -} - -void -MacroAssemblerMIPSCompat::branchTestNull(Condition cond, const Address& address, Label* label) { - MOZ_ASSERT(cond == Equal || cond == NotEqual); - extractTag(address, SecondScratchReg); - ma_b(SecondScratchReg, ImmTag(JSVAL_TAG_NULL), label, cond); -} - void MacroAssemblerMIPSCompat::testNullSet(Condition cond, const ValueOperand& value, Register dest) { diff --git a/js/src/jit/mips32/MacroAssembler-mips32.h b/js/src/jit/mips32/MacroAssembler-mips32.h index 35388fa2dd7..8a98a39f4ef 100644 --- a/js/src/jit/mips32/MacroAssembler-mips32.h +++ b/js/src/jit/mips32/MacroAssembler-mips32.h @@ -375,10 +375,6 @@ class MacroAssemblerMIPSCompat : public MacroAssemblerMIPS void int32ValueToFloat32(const ValueOperand& operand, FloatRegister dest); void loadConstantFloat32(float f, FloatRegister dest); - void branchTestNull(Condition cond, const ValueOperand& value, Label* label); - void branchTestNull(Condition cond, Register tag, Label* label); - void branchTestNull(Condition cond, const BaseIndex& src, Label* label); - void branchTestNull(Condition cond, const Address& address, Label* label); void testNullSet(Condition cond, const ValueOperand& value, Register dest); void branchTestObject(Condition cond, const ValueOperand& value, Label* label); diff --git a/js/src/jit/mips64/MacroAssembler-mips64-inl.h b/js/src/jit/mips64/MacroAssembler-mips64-inl.h index 4cb75877f9b..1fb4610fe84 100644 --- a/js/src/jit/mips64/MacroAssembler-mips64-inl.h +++ b/js/src/jit/mips64/MacroAssembler-mips64-inl.h @@ -313,6 +313,14 @@ MacroAssembler::branchTestSymbol(Condition cond, const ValueOperand& value, Labe branchTestSymbol(cond, scratch2, label); } +void +MacroAssembler::branchTestNull(Condition cond, const ValueOperand& value, Label* label) +{ + SecondScratchRegisterScope scratch2(*this); + splitTag(value, scratch2); + branchTestNull(cond, scratch2, label); +} + //}}} check_macroassembler_style // =============================================================== diff --git a/js/src/jit/mips64/MacroAssembler-mips64.cpp b/js/src/jit/mips64/MacroAssembler-mips64.cpp index 958d535778b..569026b9530 100644 --- a/js/src/jit/mips64/MacroAssembler-mips64.cpp +++ b/js/src/jit/mips64/MacroAssembler-mips64.cpp @@ -1254,36 +1254,6 @@ MacroAssemblerMIPS64Compat::branchTestPrimitive(Condition cond, Register tag, La (cond == Equal) ? Below : AboveOrEqual); } -void -MacroAssemblerMIPS64Compat::branchTestNull(Condition cond, const ValueOperand& value, Label* label) -{ - MOZ_ASSERT(cond == Equal || cond == NotEqual); - splitTag(value, SecondScratchReg); - ma_b(SecondScratchReg, ImmTag(JSVAL_TAG_NULL), label, cond); -} - -void -MacroAssemblerMIPS64Compat::branchTestNull(Condition cond, Register tag, Label* label) -{ - MOZ_ASSERT(cond == Equal || cond == NotEqual); - ma_b(tag, ImmTag(JSVAL_TAG_NULL), label, cond); -} - -void -MacroAssemblerMIPS64Compat::branchTestNull(Condition cond, const BaseIndex& src, Label* label) -{ - MOZ_ASSERT(cond == Equal || cond == NotEqual); - extractTag(src, SecondScratchReg); - ma_b(SecondScratchReg, ImmTag(JSVAL_TAG_NULL), label, cond); -} - -void -MacroAssemblerMIPS64Compat::branchTestNull(Condition cond, const Address& address, Label* label) { - MOZ_ASSERT(cond == Equal || cond == NotEqual); - extractTag(address, SecondScratchReg); - ma_b(SecondScratchReg, ImmTag(JSVAL_TAG_NULL), label, cond); -} - void MacroAssemblerMIPS64Compat::testNullSet(Condition cond, const ValueOperand& value, Register dest) { diff --git a/js/src/jit/mips64/MacroAssembler-mips64.h b/js/src/jit/mips64/MacroAssembler-mips64.h index 256c0f4058c..2a06904c970 100644 --- a/js/src/jit/mips64/MacroAssembler-mips64.h +++ b/js/src/jit/mips64/MacroAssembler-mips64.h @@ -416,10 +416,6 @@ class MacroAssemblerMIPS64Compat : public MacroAssemblerMIPS64 void int32ValueToFloat32(const ValueOperand& operand, FloatRegister dest); void loadConstantFloat32(float f, FloatRegister dest); - void branchTestNull(Condition cond, const ValueOperand& value, Label* label); - void branchTestNull(Condition cond, Register tag, Label* label); - void branchTestNull(Condition cond, const BaseIndex& src, Label* label); - void branchTestNull(Condition cond, const Address& address, Label* label); void testNullSet(Condition cond, const ValueOperand& value, Register dest); void branchTestObject(Condition cond, const ValueOperand& value, Label* label); diff --git a/js/src/jit/none/MacroAssembler-none.h b/js/src/jit/none/MacroAssembler-none.h index f11d85a9643..d65d4af6c65 100644 --- a/js/src/jit/none/MacroAssembler-none.h +++ b/js/src/jit/none/MacroAssembler-none.h @@ -345,7 +345,6 @@ class MacroAssemblerNone : public Assembler Register splitTagForTest(ValueOperand) { MOZ_CRASH(); } - template void branchTestNull(Condition, T, Label*) { MOZ_CRASH(); } template void branchTestObject(Condition, T, Label*) { MOZ_CRASH(); } template void branchTestGCThing(Condition, T, Label*) { MOZ_CRASH(); } template void branchTestPrimitive(Condition, T, Label*) { MOZ_CRASH(); } diff --git a/js/src/jit/x64/MacroAssembler-x64.h b/js/src/jit/x64/MacroAssembler-x64.h index 2b5a83dbb18..21e1ee14465 100644 --- a/js/src/jit/x64/MacroAssembler-x64.h +++ b/js/src/jit/x64/MacroAssembler-x64.h @@ -346,9 +346,8 @@ class MacroAssemblerX64 : public MacroAssemblerX86Shared return testNumber(cond, scratch); } Condition testNull(Condition cond, const Address& src) { - ScratchRegisterScope scratch(asMasm()); - splitTag(src, scratch); - return testNull(cond, scratch); + cmp32(ToUpper32(src), Imm32(Upper32Of(GetShiftedTag(JSVAL_TYPE_NULL)))); + return cond; } Condition testString(Condition cond, const Address& src) { ScratchRegisterScope scratch(asMasm()); @@ -684,10 +683,6 @@ class MacroAssemblerX64 : public MacroAssemblerX86Shared cmp32(reg, tag); } - void branchTestNull(Condition cond, Register tag, Label* label) { - cond = testNull(cond, tag); - j(cond, label); - } void branchTestObject(Condition cond, Register tag, Label* label) { cond = testObject(cond, tag); j(cond, label); @@ -696,16 +691,6 @@ class MacroAssemblerX64 : public MacroAssemblerX86Shared // x64 can test for certain types directly from memory when the payload // of the type is limited to 32 bits. This avoids loading into a register, // accesses half as much memory, and removes a right-shift. - void branchTestNull(Condition cond, const Operand& operand, Label* label) { - MOZ_ASSERT(cond == Equal || cond == NotEqual); - cmp32(ToUpper32(operand), Imm32(Upper32Of(GetShiftedTag(JSVAL_TYPE_NULL)))); - j(cond, label); - } - void branchTestNull(Condition cond, const Address& address, Label* label) { - MOZ_ASSERT(cond == Equal || cond == NotEqual); - branchTestNull(cond, Operand(address), label); - } - // This one, though, clobbers the ScratchReg. void branchTestObject(Condition cond, const Address& src, Label* label) { cond = testObject(cond, src); @@ -714,10 +699,6 @@ class MacroAssemblerX64 : public MacroAssemblerX86Shared // Perform a type-test on a full Value loaded into a register. // Clobbers the ScratchReg. - void branchTestNull(Condition cond, const ValueOperand& src, Label* label) { - cond = testNull(cond, src); - j(cond, label); - } void branchTestObject(Condition cond, const ValueOperand& src, Label* label) { cond = testObject(cond, src); j(cond, label); @@ -725,10 +706,6 @@ class MacroAssemblerX64 : public MacroAssemblerX86Shared // Perform a type-test on a Value addressed by BaseIndex. // Clobbers the ScratchReg. - void branchTestNull(Condition cond, const BaseIndex& address, Label* label) { - cond = testNull(cond, address); - j(cond, label); - } void branchTestObject(Condition cond, const BaseIndex& address, Label* label) { cond = testObject(cond, address); j(cond, label); diff --git a/js/src/jit/x86-shared/MacroAssembler-x86-shared-inl.h b/js/src/jit/x86-shared/MacroAssembler-x86-shared-inl.h index fa254a688b8..a0201a247f0 100644 --- a/js/src/jit/x86-shared/MacroAssembler-x86-shared-inl.h +++ b/js/src/jit/x86-shared/MacroAssembler-x86-shared-inl.h @@ -649,6 +649,38 @@ MacroAssembler::branchTestSymbolImpl(Condition cond, const T& t, Label* label) j(cond, label); } +void +MacroAssembler::branchTestNull(Condition cond, Register tag, Label* label) +{ + branchTestNullImpl(cond, tag, label); +} + +void +MacroAssembler::branchTestNull(Condition cond, const Address& address, Label* label) +{ + branchTestNullImpl(cond, address, label); +} + +void +MacroAssembler::branchTestNull(Condition cond, const BaseIndex& address, Label* label) +{ + branchTestNullImpl(cond, address, label); +} + +void +MacroAssembler::branchTestNull(Condition cond, const ValueOperand& value, Label* label) +{ + branchTestNullImpl(cond, value, label); +} + +template +void +MacroAssembler::branchTestNullImpl(Condition cond, const T& t, Label* label) +{ + cond = testNull(cond, t); + j(cond, label); +} + //}}} check_macroassembler_style // =============================================================== diff --git a/js/src/jit/x86/MacroAssembler-x86.h b/js/src/jit/x86/MacroAssembler-x86.h index 5bb11da1efe..0b799ec88f2 100644 --- a/js/src/jit/x86/MacroAssembler-x86.h +++ b/js/src/jit/x86/MacroAssembler-x86.h @@ -660,11 +660,6 @@ class MacroAssemblerX86 : public MacroAssemblerX86Shared // Type testing instructions can take a tag in a register or a // ValueOperand. template - void branchTestNull(Condition cond, const T& t, Label* label) { - cond = testNull(cond, t); - j(cond, label); - } - template void branchTestObject(Condition cond, const T& t, Label* label) { cond = testObject(cond, t); j(cond, label); From 6ea4e90e05475b7251532b0592f139d9d3bf8437 Mon Sep 17 00:00:00 2001 From: Tooru Fujisawa Date: Thu, 3 Mar 2016 08:03:44 +0900 Subject: [PATCH 131/160] Bug 1245112 - Part 30: Move MacroAssembler::branchTestObject into generic macro assembler. r=sstangl --- js/src/jit/MacroAssembler.h | 12 +++++++ js/src/jit/arm/MacroAssembler-arm-inl.h | 32 +++++++++++++++++++ js/src/jit/arm/MacroAssembler-arm.h | 5 --- js/src/jit/arm64/MacroAssembler-arm64-inl.h | 32 +++++++++++++++++++ js/src/jit/arm64/MacroAssembler-arm64.h | 23 ------------- .../MacroAssembler-mips-shared-inl.h | 23 +++++++++++++ js/src/jit/mips32/MacroAssembler-mips32-inl.h | 6 ++++ js/src/jit/mips32/MacroAssembler-mips32.cpp | 29 ----------------- js/src/jit/mips32/MacroAssembler-mips32.h | 4 --- js/src/jit/mips64/MacroAssembler-mips64-inl.h | 8 +++++ js/src/jit/mips64/MacroAssembler-mips64.cpp | 30 ----------------- js/src/jit/mips64/MacroAssembler-mips64.h | 4 --- js/src/jit/none/MacroAssembler-none.h | 1 - js/src/jit/x64/MacroAssembler-x64.h | 28 ---------------- .../MacroAssembler-x86-shared-inl.h | 32 +++++++++++++++++++ js/src/jit/x86/MacroAssembler-x86.h | 5 --- 16 files changed, 145 insertions(+), 129 deletions(-) diff --git a/js/src/jit/MacroAssembler.h b/js/src/jit/MacroAssembler.h index fd3076d0b25..abecef1709b 100644 --- a/js/src/jit/MacroAssembler.h +++ b/js/src/jit/MacroAssembler.h @@ -932,9 +932,12 @@ class MacroAssembler : public MacroAssemblerSpecific inline void branchTestString(Condition cond, Register tag, Label* label) PER_SHARED_ARCH; inline void branchTestSymbol(Condition cond, Register tag, Label* label) PER_SHARED_ARCH; inline void branchTestNull(Condition cond, Register tag, Label* label) PER_SHARED_ARCH; + inline void branchTestObject(Condition cond, Register tag, Label* label) PER_SHARED_ARCH; // Perform a type-test on a Value, addressed by Address or BaseIndex, or // loaded into ValueOperand. + // BaseIndex and ValueOperand variants clobber the ScratchReg on x64. + // All Variants clobber the ScratchReg on arm64. inline void branchTestUndefined(Condition cond, const Address& address, Label* label) PER_SHARED_ARCH; inline void branchTestUndefined(Condition cond, const BaseIndex& address, Label* label) PER_SHARED_ARCH; inline void branchTestUndefined(Condition cond, const ValueOperand& value, Label* label) @@ -971,6 +974,12 @@ class MacroAssembler : public MacroAssemblerSpecific inline void branchTestNull(Condition cond, const ValueOperand& value, Label* label) DEFINED_ON(arm, arm64, mips32, mips64, x86_shared); + // Clobbers the ScratchReg on x64. + inline void branchTestObject(Condition cond, const Address& address, Label* label) PER_SHARED_ARCH; + inline void branchTestObject(Condition cond, const BaseIndex& address, Label* label) PER_SHARED_ARCH; + inline void branchTestObject(Condition cond, const ValueOperand& value, Label* label) + DEFINED_ON(arm, arm64, mips32, mips64, x86_shared); + // Checks if given Value is evaluated to true or false in a condition. // The type of the value should match the type of the method. inline void branchTestInt32Truthy(bool truthy, const ValueOperand& value, Label* label) @@ -1007,6 +1016,9 @@ class MacroAssembler : public MacroAssemblerSpecific template inline void branchTestNullImpl(Condition cond, const T& t, Label* label) DEFINED_ON(arm, arm64, x86_shared); + template + inline void branchTestObjectImpl(Condition cond, const T& t, Label* label) + DEFINED_ON(arm, arm64, x86_shared); //}}} check_macroassembler_style public: diff --git a/js/src/jit/arm/MacroAssembler-arm-inl.h b/js/src/jit/arm/MacroAssembler-arm-inl.h index c2995c6dce3..b3a7591e84e 100644 --- a/js/src/jit/arm/MacroAssembler-arm-inl.h +++ b/js/src/jit/arm/MacroAssembler-arm-inl.h @@ -1059,6 +1059,38 @@ MacroAssembler::branchTestNullImpl(Condition cond, const T& t, Label* label) ma_b(label, c); } +void +MacroAssembler::branchTestObject(Condition cond, Register tag, Label* label) +{ + branchTestObjectImpl(cond, tag, label); +} + +void +MacroAssembler::branchTestObject(Condition cond, const Address& address, Label* label) +{ + branchTestObjectImpl(cond, address, label); +} + +void +MacroAssembler::branchTestObject(Condition cond, const BaseIndex& address, Label* label) +{ + branchTestObjectImpl(cond, address, label); +} + +void +MacroAssembler::branchTestObject(Condition cond, const ValueOperand& value, Label* label) +{ + branchTestObjectImpl(cond, value, label); +} + +template +void +MacroAssembler::branchTestObjectImpl(Condition cond, const T& t, Label* label) +{ + Condition c = testObject(cond, t); + ma_b(label, c); +} + //}}} check_macroassembler_style // =============================================================== diff --git a/js/src/jit/arm/MacroAssembler-arm.h b/js/src/jit/arm/MacroAssembler-arm.h index b09f209ba58..e8ac190a1a5 100644 --- a/js/src/jit/arm/MacroAssembler-arm.h +++ b/js/src/jit/arm/MacroAssembler-arm.h @@ -762,11 +762,6 @@ class MacroAssemblerARMCompat : public MacroAssemblerARM void int32ValueToFloat32(const ValueOperand& operand, FloatRegister dest); void loadConstantFloat32(float f, FloatRegister dest); - template - void branchTestObject(Condition cond, const T & t, Label* label) { - Condition c = testObject(cond, t); - ma_b(label, c); - } template void branchTestMagic(Condition cond, const T& t, L label) { cond = testMagic(cond, t); diff --git a/js/src/jit/arm64/MacroAssembler-arm64-inl.h b/js/src/jit/arm64/MacroAssembler-arm64-inl.h index 44eb6e76e7a..2c84379352b 100644 --- a/js/src/jit/arm64/MacroAssembler-arm64-inl.h +++ b/js/src/jit/arm64/MacroAssembler-arm64-inl.h @@ -1158,6 +1158,38 @@ MacroAssembler::branchTestNullImpl(Condition cond, const T& t, Label* label) B(label, c); } +void +MacroAssembler::branchTestObject(Condition cond, Register tag, Label* label) +{ + branchTestObjectImpl(cond, tag, label); +} + +void +MacroAssembler::branchTestObject(Condition cond, const Address& address, Label* label) +{ + branchTestObjectImpl(cond, address, label); +} + +void +MacroAssembler::branchTestObject(Condition cond, const BaseIndex& address, Label* label) +{ + branchTestObjectImpl(cond, address, label); +} + +void +MacroAssembler::branchTestObject(Condition cond, const ValueOperand& value, Label* label) +{ + branchTestObjectImpl(cond, value, label); +} + +template +void +MacroAssembler::branchTestObjectImpl(Condition cond, const T& t, Label* label) +{ + Condition c = testObject(cond, t); + B(label, c); +} + //}}} check_macroassembler_style // =============================================================== diff --git a/js/src/jit/arm64/MacroAssembler-arm64.h b/js/src/jit/arm64/MacroAssembler-arm64.h index ee8fc2878f4..79e1f8b120d 100644 --- a/js/src/jit/arm64/MacroAssembler-arm64.h +++ b/js/src/jit/arm64/MacroAssembler-arm64.h @@ -1328,29 +1328,6 @@ class MacroAssemblerCompat : public vixl::MacroAssembler return jumpWithPatch(label, Always, documentation); } - void branchTestObject(Condition cond, Register tag, Label* label) { - Condition c = testObject(cond, tag); - B(label, c); - } - - void branchTestObject(Condition cond, const Address& address, Label* label) { - Condition c = testObject(cond, address); - B(label, c); - } - - // Perform a type-test on a full Value loaded into a register. - // Clobbers the ScratchReg. - void branchTestObject(Condition cond, const ValueOperand& src, Label* label) { - Condition c = testObject(cond, src); - B(label, c); - } - - // Perform a type-test on a Value addressed by BaseIndex. - // Clobbers the ScratchReg. - void branchTestObject(Condition cond, const BaseIndex& address, Label* label) { - Condition c = testObject(cond, address); - B(label, c); - } template void branchTestGCThing(Condition cond, const T& src, Label* label) { Condition c = testGCThing(cond, src); diff --git a/js/src/jit/mips-shared/MacroAssembler-mips-shared-inl.h b/js/src/jit/mips-shared/MacroAssembler-mips-shared-inl.h index 0cfe5122f95..9abde7aee40 100644 --- a/js/src/jit/mips-shared/MacroAssembler-mips-shared-inl.h +++ b/js/src/jit/mips-shared/MacroAssembler-mips-shared-inl.h @@ -663,6 +663,29 @@ MacroAssembler::branchTestNull(Condition cond, const BaseIndex& address, Label* branchTestNull(cond, scratch2, label); } +void +MacroAssembler::branchTestObject(Condition cond, Register tag, Label* label) +{ + MOZ_ASSERT(cond == Equal || cond == NotEqual); + ma_b(tag, ImmTag(JSVAL_TAG_OBJECT), label, cond); +} + +void +MacroAssembler::branchTestObject(Condition cond, const Address& address, Label* label) +{ + SecondScratchRegisterScope scratch2(*this); + extractTag(address, scratch2); + branchTestObject(cond, scratch2, label); +} + +void +MacroAssembler::branchTestObject(Condition cond, const BaseIndex& address, Label* label) +{ + SecondScratchRegisterScope scratch2(*this); + extractTag(address, scratch2); + branchTestObject(cond, scratch2, label); +} + //}}} check_macroassembler_style // =============================================================== diff --git a/js/src/jit/mips32/MacroAssembler-mips32-inl.h b/js/src/jit/mips32/MacroAssembler-mips32-inl.h index fd966e5d732..e2c3e9bc7c7 100644 --- a/js/src/jit/mips32/MacroAssembler-mips32-inl.h +++ b/js/src/jit/mips32/MacroAssembler-mips32-inl.h @@ -368,6 +368,12 @@ MacroAssembler::branchTestNull(Condition cond, const ValueOperand& value, Label* branchTestNull(cond, value.typeReg(), label); } +void +MacroAssembler::branchTestObject(Condition cond, const ValueOperand& value, Label* label) +{ + branchTestObject(cond, value.typeReg(), label); +} + //}}} check_macroassembler_style // =============================================================== diff --git a/js/src/jit/mips32/MacroAssembler-mips32.cpp b/js/src/jit/mips32/MacroAssembler-mips32.cpp index 71ae26f1813..ff1d1169aaa 100644 --- a/js/src/jit/mips32/MacroAssembler-mips32.cpp +++ b/js/src/jit/mips32/MacroAssembler-mips32.cpp @@ -1133,35 +1133,6 @@ MacroAssemblerMIPSCompat::testNullSet(Condition cond, const ValueOperand& value, ma_cmp_set(dest, value.typeReg(), ImmType(JSVAL_TYPE_NULL), cond); } -void -MacroAssemblerMIPSCompat::branchTestObject(Condition cond, const ValueOperand& value, Label* label) -{ - branchTestObject(cond, value.typeReg(), label); -} - -void -MacroAssemblerMIPSCompat::branchTestObject(Condition cond, Register tag, Label* label) -{ - MOZ_ASSERT(cond == Equal || cond == NotEqual); - ma_b(tag, ImmTag(JSVAL_TAG_OBJECT), label, cond); -} - -void -MacroAssemblerMIPSCompat::branchTestObject(Condition cond, const BaseIndex& src, Label* label) -{ - MOZ_ASSERT(cond == Equal || cond == NotEqual); - extractTag(src, SecondScratchReg); - ma_b(SecondScratchReg, ImmTag(JSVAL_TAG_OBJECT), label, cond); -} - -void -MacroAssemblerMIPSCompat::branchTestObject(Condition cond, const Address& address, Label* label) -{ - MOZ_ASSERT(cond == Equal || cond == NotEqual); - extractTag(address, SecondScratchReg); - ma_b(SecondScratchReg, ImmTag(JSVAL_TAG_OBJECT), label, cond); -} - void MacroAssemblerMIPSCompat::testObjectSet(Condition cond, const ValueOperand& value, Register dest) { diff --git a/js/src/jit/mips32/MacroAssembler-mips32.h b/js/src/jit/mips32/MacroAssembler-mips32.h index 8a98a39f4ef..6e132bad43c 100644 --- a/js/src/jit/mips32/MacroAssembler-mips32.h +++ b/js/src/jit/mips32/MacroAssembler-mips32.h @@ -377,10 +377,6 @@ class MacroAssemblerMIPSCompat : public MacroAssemblerMIPS void testNullSet(Condition cond, const ValueOperand& value, Register dest); - void branchTestObject(Condition cond, const ValueOperand& value, Label* label); - void branchTestObject(Condition cond, Register tag, Label* label); - void branchTestObject(Condition cond, const BaseIndex& src, Label* label); - void branchTestObject(Condition cond, const Address& src, Label* label); void testObjectSet(Condition cond, const ValueOperand& value, Register dest); void testUndefinedSet(Condition cond, const ValueOperand& value, Register dest); diff --git a/js/src/jit/mips64/MacroAssembler-mips64-inl.h b/js/src/jit/mips64/MacroAssembler-mips64-inl.h index 1fb4610fe84..bafecf9259e 100644 --- a/js/src/jit/mips64/MacroAssembler-mips64-inl.h +++ b/js/src/jit/mips64/MacroAssembler-mips64-inl.h @@ -321,6 +321,14 @@ MacroAssembler::branchTestNull(Condition cond, const ValueOperand& value, Label* branchTestNull(cond, scratch2, label); } +void +MacroAssembler::branchTestObject(Condition cond, const ValueOperand& value, Label* label) +{ + SecondScratchRegisterScope scratch2(*this); + splitTag(value, scratch2); + branchTestObject(cond, scratch2, label); +} + //}}} check_macroassembler_style // =============================================================== diff --git a/js/src/jit/mips64/MacroAssembler-mips64.cpp b/js/src/jit/mips64/MacroAssembler-mips64.cpp index 569026b9530..60cc6e95077 100644 --- a/js/src/jit/mips64/MacroAssembler-mips64.cpp +++ b/js/src/jit/mips64/MacroAssembler-mips64.cpp @@ -1262,36 +1262,6 @@ MacroAssemblerMIPS64Compat::testNullSet(Condition cond, const ValueOperand& valu ma_cmp_set(dest, SecondScratchReg, ImmTag(JSVAL_TAG_NULL), cond); } -void -MacroAssemblerMIPS64Compat::branchTestObject(Condition cond, const ValueOperand& value, Label* label) -{ - splitTag(value, SecondScratchReg); - branchTestObject(cond, SecondScratchReg, label); -} - -void -MacroAssemblerMIPS64Compat::branchTestObject(Condition cond, Register tag, Label* label) -{ - MOZ_ASSERT(cond == Equal || cond == NotEqual); - ma_b(tag, ImmTag(JSVAL_TAG_OBJECT), label, cond); -} - -void -MacroAssemblerMIPS64Compat::branchTestObject(Condition cond, const BaseIndex& src, Label* label) -{ - MOZ_ASSERT(cond == Equal || cond == NotEqual); - extractTag(src, SecondScratchReg); - ma_b(SecondScratchReg, ImmTag(JSVAL_TAG_OBJECT), label, cond); -} - -void -MacroAssemblerMIPS64Compat::branchTestObject(Condition cond, const Address& address, Label* label) -{ - MOZ_ASSERT(cond == Equal || cond == NotEqual); - extractTag(address, SecondScratchReg); - ma_b(SecondScratchReg, ImmTag(JSVAL_TAG_OBJECT), label, cond); -} - void MacroAssemblerMIPS64Compat::testObjectSet(Condition cond, const ValueOperand& value, Register dest) { diff --git a/js/src/jit/mips64/MacroAssembler-mips64.h b/js/src/jit/mips64/MacroAssembler-mips64.h index 2a06904c970..1cf63d2c813 100644 --- a/js/src/jit/mips64/MacroAssembler-mips64.h +++ b/js/src/jit/mips64/MacroAssembler-mips64.h @@ -418,10 +418,6 @@ class MacroAssemblerMIPS64Compat : public MacroAssemblerMIPS64 void testNullSet(Condition cond, const ValueOperand& value, Register dest); - void branchTestObject(Condition cond, const ValueOperand& value, Label* label); - void branchTestObject(Condition cond, Register tag, Label* label); - void branchTestObject(Condition cond, const BaseIndex& src, Label* label); - void branchTestObject(Condition cond, const Address& src, Label* label); void testObjectSet(Condition cond, const ValueOperand& value, Register dest); void testUndefinedSet(Condition cond, const ValueOperand& value, Register dest); diff --git a/js/src/jit/none/MacroAssembler-none.h b/js/src/jit/none/MacroAssembler-none.h index d65d4af6c65..5504a558252 100644 --- a/js/src/jit/none/MacroAssembler-none.h +++ b/js/src/jit/none/MacroAssembler-none.h @@ -345,7 +345,6 @@ class MacroAssemblerNone : public Assembler Register splitTagForTest(ValueOperand) { MOZ_CRASH(); } - template void branchTestObject(Condition, T, Label*) { MOZ_CRASH(); } template void branchTestGCThing(Condition, T, Label*) { MOZ_CRASH(); } template void branchTestPrimitive(Condition, T, Label*) { MOZ_CRASH(); } template void branchTestMagic(Condition, T, L) { MOZ_CRASH(); } diff --git a/js/src/jit/x64/MacroAssembler-x64.h b/js/src/jit/x64/MacroAssembler-x64.h index 21e1ee14465..f81acb48d62 100644 --- a/js/src/jit/x64/MacroAssembler-x64.h +++ b/js/src/jit/x64/MacroAssembler-x64.h @@ -683,34 +683,6 @@ class MacroAssemblerX64 : public MacroAssemblerX86Shared cmp32(reg, tag); } - void branchTestObject(Condition cond, Register tag, Label* label) { - cond = testObject(cond, tag); - j(cond, label); - } - - // x64 can test for certain types directly from memory when the payload - // of the type is limited to 32 bits. This avoids loading into a register, - // accesses half as much memory, and removes a right-shift. - // This one, though, clobbers the ScratchReg. - void branchTestObject(Condition cond, const Address& src, Label* label) { - cond = testObject(cond, src); - j(cond, label); - } - - // Perform a type-test on a full Value loaded into a register. - // Clobbers the ScratchReg. - void branchTestObject(Condition cond, const ValueOperand& src, Label* label) { - cond = testObject(cond, src); - j(cond, label); - } - - // Perform a type-test on a Value addressed by BaseIndex. - // Clobbers the ScratchReg. - void branchTestObject(Condition cond, const BaseIndex& address, Label* label) { - cond = testObject(cond, address); - j(cond, label); - } - template void branchTestGCThing(Condition cond, const T& src, Label* label) { cond = testGCThing(cond, src); diff --git a/js/src/jit/x86-shared/MacroAssembler-x86-shared-inl.h b/js/src/jit/x86-shared/MacroAssembler-x86-shared-inl.h index a0201a247f0..f0bb71a2551 100644 --- a/js/src/jit/x86-shared/MacroAssembler-x86-shared-inl.h +++ b/js/src/jit/x86-shared/MacroAssembler-x86-shared-inl.h @@ -681,6 +681,38 @@ MacroAssembler::branchTestNullImpl(Condition cond, const T& t, Label* label) j(cond, label); } +void +MacroAssembler::branchTestObject(Condition cond, Register tag, Label* label) +{ + branchTestObjectImpl(cond, tag, label); +} + +void +MacroAssembler::branchTestObject(Condition cond, const Address& address, Label* label) +{ + branchTestObjectImpl(cond, address, label); +} + +void +MacroAssembler::branchTestObject(Condition cond, const BaseIndex& address, Label* label) +{ + branchTestObjectImpl(cond, address, label); +} + +void +MacroAssembler::branchTestObject(Condition cond, const ValueOperand& value, Label* label) +{ + branchTestObjectImpl(cond, value, label); +} + +template +void +MacroAssembler::branchTestObjectImpl(Condition cond, const T& t, Label* label) +{ + cond = testObject(cond, t); + j(cond, label); +} + //}}} check_macroassembler_style // =============================================================== diff --git a/js/src/jit/x86/MacroAssembler-x86.h b/js/src/jit/x86/MacroAssembler-x86.h index 0b799ec88f2..7c1039235d4 100644 --- a/js/src/jit/x86/MacroAssembler-x86.h +++ b/js/src/jit/x86/MacroAssembler-x86.h @@ -660,11 +660,6 @@ class MacroAssemblerX86 : public MacroAssemblerX86Shared // Type testing instructions can take a tag in a register or a // ValueOperand. template - void branchTestObject(Condition cond, const T& t, Label* label) { - cond = testObject(cond, t); - j(cond, label); - } - template void branchTestGCThing(Condition cond, const T& t, Label* label) { cond = testGCThing(cond, t); j(cond, label); From 7be8a9d1a13af14f469e4913d515b93ad92eaf41 Mon Sep 17 00:00:00 2001 From: Tooru Fujisawa Date: Thu, 3 Mar 2016 08:03:44 +0900 Subject: [PATCH 132/160] Bug 1245112 - Part 31: Move MacroAssembler::branchTestGCThing into generic macro assembler. r=jandem --- js/src/jit/MacroAssembler.h | 6 ++++++ js/src/jit/arm/MacroAssembler-arm-inl.h | 20 +++++++++++++++++++ js/src/jit/arm/MacroAssembler-arm.h | 5 ----- js/src/jit/arm64/MacroAssembler-arm64-inl.h | 20 +++++++++++++++++++ js/src/jit/arm64/MacroAssembler-arm64.h | 5 ----- .../MacroAssembler-mips-shared-inl.h | 19 ++++++++++++++++++ js/src/jit/mips32/MacroAssembler-mips32.cpp | 17 ---------------- js/src/jit/mips32/MacroAssembler-mips32.h | 3 --- js/src/jit/mips64/MacroAssembler-mips64.cpp | 17 ---------------- js/src/jit/mips64/MacroAssembler-mips64.h | 3 --- js/src/jit/none/MacroAssembler-none.h | 1 - js/src/jit/x64/MacroAssembler-x64.h | 5 ----- .../MacroAssembler-x86-shared-inl.h | 20 +++++++++++++++++++ js/src/jit/x86/MacroAssembler-x86.h | 5 ----- 14 files changed, 85 insertions(+), 61 deletions(-) diff --git a/js/src/jit/MacroAssembler.h b/js/src/jit/MacroAssembler.h index abecef1709b..df4463418d7 100644 --- a/js/src/jit/MacroAssembler.h +++ b/js/src/jit/MacroAssembler.h @@ -980,6 +980,9 @@ class MacroAssembler : public MacroAssemblerSpecific inline void branchTestObject(Condition cond, const ValueOperand& value, Label* label) DEFINED_ON(arm, arm64, mips32, mips64, x86_shared); + inline void branchTestGCThing(Condition cond, const Address& address, Label* label) PER_SHARED_ARCH; + inline void branchTestGCThing(Condition cond, const BaseIndex& address, Label* label) PER_SHARED_ARCH; + // Checks if given Value is evaluated to true or false in a condition. // The type of the value should match the type of the method. inline void branchTestInt32Truthy(bool truthy, const ValueOperand& value, Label* label) @@ -1019,6 +1022,9 @@ class MacroAssembler : public MacroAssemblerSpecific template inline void branchTestObjectImpl(Condition cond, const T& t, Label* label) DEFINED_ON(arm, arm64, x86_shared); + template + inline void branchTestGCThingImpl(Condition cond, const T& t, Label* label) + DEFINED_ON(arm, arm64, x86_shared); //}}} check_macroassembler_style public: diff --git a/js/src/jit/arm/MacroAssembler-arm-inl.h b/js/src/jit/arm/MacroAssembler-arm-inl.h index b3a7591e84e..177354b185c 100644 --- a/js/src/jit/arm/MacroAssembler-arm-inl.h +++ b/js/src/jit/arm/MacroAssembler-arm-inl.h @@ -1091,6 +1091,26 @@ MacroAssembler::branchTestObjectImpl(Condition cond, const T& t, Label* label) ma_b(label, c); } +void +MacroAssembler::branchTestGCThing(Condition cond, const Address& address, Label* label) +{ + branchTestGCThingImpl(cond, address, label); +} + +void +MacroAssembler::branchTestGCThing(Condition cond, const BaseIndex& address, Label* label) +{ + branchTestGCThingImpl(cond, address, label); +} + +template +void +MacroAssembler::branchTestGCThingImpl(Condition cond, const T& t, Label* label) +{ + Condition c = testGCThing(cond, t); + ma_b(label, c); +} + //}}} check_macroassembler_style // =============================================================== diff --git a/js/src/jit/arm/MacroAssembler-arm.h b/js/src/jit/arm/MacroAssembler-arm.h index e8ac190a1a5..91dda3becef 100644 --- a/js/src/jit/arm/MacroAssembler-arm.h +++ b/js/src/jit/arm/MacroAssembler-arm.h @@ -684,11 +684,6 @@ class MacroAssemblerARMCompat : public MacroAssemblerARM Condition testMagic(Condition cond, const BaseIndex& src); Condition testGCThing(Condition cond, const BaseIndex& src); - template - void branchTestGCThing(Condition cond, const T& t, Label* label) { - Condition c = testGCThing(cond, t); - ma_b(label, c); - } template void branchTestPrimitive(Condition cond, const T& t, Label* label) { Condition c = testPrimitive(cond, t); diff --git a/js/src/jit/arm64/MacroAssembler-arm64-inl.h b/js/src/jit/arm64/MacroAssembler-arm64-inl.h index 2c84379352b..dab3601b10c 100644 --- a/js/src/jit/arm64/MacroAssembler-arm64-inl.h +++ b/js/src/jit/arm64/MacroAssembler-arm64-inl.h @@ -1190,6 +1190,26 @@ MacroAssembler::branchTestObjectImpl(Condition cond, const T& t, Label* label) B(label, c); } +void +MacroAssembler::branchTestGCThing(Condition cond, const Address& address, Label* label) +{ + branchTestGCThingImpl(cond, address, label); +} + +void +MacroAssembler::branchTestGCThing(Condition cond, const BaseIndex& address, Label* label) +{ + branchTestGCThingImpl(cond, address, label); +} + +template +void +MacroAssembler::branchTestGCThingImpl(Condition cond, const T& src, Label* label) +{ + Condition c = testGCThing(cond, src); + B(label, c); +} + //}}} check_macroassembler_style // =============================================================== diff --git a/js/src/jit/arm64/MacroAssembler-arm64.h b/js/src/jit/arm64/MacroAssembler-arm64.h index 79e1f8b120d..4ac9755cc4c 100644 --- a/js/src/jit/arm64/MacroAssembler-arm64.h +++ b/js/src/jit/arm64/MacroAssembler-arm64.h @@ -1328,11 +1328,6 @@ class MacroAssemblerCompat : public vixl::MacroAssembler return jumpWithPatch(label, Always, documentation); } - template - void branchTestGCThing(Condition cond, const T& src, Label* label) { - Condition c = testGCThing(cond, src); - B(label, c); - } template void branchTestPrimitive(Condition cond, const T& t, Label* label) { Condition c = testPrimitive(cond, t); diff --git a/js/src/jit/mips-shared/MacroAssembler-mips-shared-inl.h b/js/src/jit/mips-shared/MacroAssembler-mips-shared-inl.h index 9abde7aee40..3b68b1207c8 100644 --- a/js/src/jit/mips-shared/MacroAssembler-mips-shared-inl.h +++ b/js/src/jit/mips-shared/MacroAssembler-mips-shared-inl.h @@ -686,6 +686,25 @@ MacroAssembler::branchTestObject(Condition cond, const BaseIndex& address, Label branchTestObject(cond, scratch2, label); } +void +MacroAssembler::branchTestGCThing(Condition cond, const Address& address, Label* label) +{ + MOZ_ASSERT(cond == Equal || cond == NotEqual); + SecondScratchRegisterScope scratch2(*this); + extractTag(address, scratch2); + ma_b(scratch2, ImmTag(JSVAL_LOWER_INCL_TAG_OF_GCTHING_SET), label, + (cond == Equal) ? AboveOrEqual : Below); +} +void +MacroAssembler::branchTestGCThing(Condition cond, const BaseIndex& address, Label* label) +{ + MOZ_ASSERT(cond == Equal || cond == NotEqual); + SecondScratchRegisterScope scratch2(*this); + extractTag(address, scratch2); + ma_b(scratch2, ImmTag(JSVAL_LOWER_INCL_TAG_OF_GCTHING_SET), label, + (cond == Equal) ? AboveOrEqual : Below); +} + //}}} check_macroassembler_style // =============================================================== diff --git a/js/src/jit/mips32/MacroAssembler-mips32.cpp b/js/src/jit/mips32/MacroAssembler-mips32.cpp index ff1d1169aaa..c001458acdf 100644 --- a/js/src/jit/mips32/MacroAssembler-mips32.cpp +++ b/js/src/jit/mips32/MacroAssembler-mips32.cpp @@ -1095,23 +1095,6 @@ MacroAssemblerMIPSCompat::ToType(Operand base) return Operand(Register::FromCode(base.base()), base.disp() + TAG_OFFSET); } -void -MacroAssemblerMIPSCompat::branchTestGCThing(Condition cond, const Address& address, Label* label) -{ - MOZ_ASSERT(cond == Equal || cond == NotEqual); - extractTag(address, SecondScratchReg); - ma_b(SecondScratchReg, ImmTag(JSVAL_LOWER_INCL_TAG_OF_GCTHING_SET), label, - (cond == Equal) ? AboveOrEqual : Below); -} -void -MacroAssemblerMIPSCompat::branchTestGCThing(Condition cond, const BaseIndex& src, Label* label) -{ - MOZ_ASSERT(cond == Equal || cond == NotEqual); - extractTag(src, SecondScratchReg); - ma_b(SecondScratchReg, ImmTag(JSVAL_LOWER_INCL_TAG_OF_GCTHING_SET), label, - (cond == Equal) ? AboveOrEqual : Below); -} - void MacroAssemblerMIPSCompat::branchTestPrimitive(Condition cond, const ValueOperand& value, Label* label) diff --git a/js/src/jit/mips32/MacroAssembler-mips32.h b/js/src/jit/mips32/MacroAssembler-mips32.h index 6e132bad43c..c11d94ed83a 100644 --- a/js/src/jit/mips32/MacroAssembler-mips32.h +++ b/js/src/jit/mips32/MacroAssembler-mips32.h @@ -309,9 +309,6 @@ class MacroAssemblerMIPSCompat : public MacroAssemblerMIPS return value.typeReg(); } - void branchTestGCThing(Condition cond, const Address& address, Label* label); - void branchTestGCThing(Condition cond, const BaseIndex& src, Label* label); - void branchTestPrimitive(Condition cond, const ValueOperand& value, Label* label); void branchTestPrimitive(Condition cond, Register tag, Label* label); diff --git a/js/src/jit/mips64/MacroAssembler-mips64.cpp b/js/src/jit/mips64/MacroAssembler-mips64.cpp index 60cc6e95077..b36d7108ca4 100644 --- a/js/src/jit/mips64/MacroAssembler-mips64.cpp +++ b/js/src/jit/mips64/MacroAssembler-mips64.cpp @@ -1222,23 +1222,6 @@ MacroAssembler::clampDoubleToUint8(FloatRegister input, Register output) bind(&done); } -void -MacroAssemblerMIPS64Compat::branchTestGCThing(Condition cond, const Address& address, Label* label) -{ - MOZ_ASSERT(cond == Equal || cond == NotEqual); - extractTag(address, SecondScratchReg); - ma_b(SecondScratchReg, ImmTag(JSVAL_LOWER_INCL_TAG_OF_GCTHING_SET), label, - (cond == Equal) ? AboveOrEqual : Below); -} -void -MacroAssemblerMIPS64Compat::branchTestGCThing(Condition cond, const BaseIndex& src, Label* label) -{ - MOZ_ASSERT(cond == Equal || cond == NotEqual); - extractTag(src, SecondScratchReg); - ma_b(SecondScratchReg, ImmTag(JSVAL_LOWER_INCL_TAG_OF_GCTHING_SET), label, - (cond == Equal) ? AboveOrEqual : Below); -} - void MacroAssemblerMIPS64Compat::branchTestPrimitive(Condition cond, const ValueOperand& value, Label* label) diff --git a/js/src/jit/mips64/MacroAssembler-mips64.h b/js/src/jit/mips64/MacroAssembler-mips64.h index 1cf63d2c813..d9fc0515ecb 100644 --- a/js/src/jit/mips64/MacroAssembler-mips64.h +++ b/js/src/jit/mips64/MacroAssembler-mips64.h @@ -337,9 +337,6 @@ class MacroAssemblerMIPS64Compat : public MacroAssemblerMIPS64 return SecondScratchReg; } - void branchTestGCThing(Condition cond, const Address& address, Label* label); - void branchTestGCThing(Condition cond, const BaseIndex& src, Label* label); - void branchTestPrimitive(Condition cond, const ValueOperand& value, Label* label); void branchTestPrimitive(Condition cond, Register tag, Label* label); diff --git a/js/src/jit/none/MacroAssembler-none.h b/js/src/jit/none/MacroAssembler-none.h index 5504a558252..a35407c2524 100644 --- a/js/src/jit/none/MacroAssembler-none.h +++ b/js/src/jit/none/MacroAssembler-none.h @@ -345,7 +345,6 @@ class MacroAssemblerNone : public Assembler Register splitTagForTest(ValueOperand) { MOZ_CRASH(); } - template void branchTestGCThing(Condition, T, Label*) { MOZ_CRASH(); } template void branchTestPrimitive(Condition, T, Label*) { MOZ_CRASH(); } template void branchTestMagic(Condition, T, L) { MOZ_CRASH(); } template void branchTestMagicValue(Condition, T, JSWhyMagic, Label*) { MOZ_CRASH(); } diff --git a/js/src/jit/x64/MacroAssembler-x64.h b/js/src/jit/x64/MacroAssembler-x64.h index f81acb48d62..22ab3948351 100644 --- a/js/src/jit/x64/MacroAssembler-x64.h +++ b/js/src/jit/x64/MacroAssembler-x64.h @@ -683,11 +683,6 @@ class MacroAssemblerX64 : public MacroAssemblerX86Shared cmp32(reg, tag); } - template - void branchTestGCThing(Condition cond, const T& src, Label* label) { - cond = testGCThing(cond, src); - j(cond, label); - } template void branchTestPrimitive(Condition cond, const T& t, Label* label) { cond = testPrimitive(cond, t); diff --git a/js/src/jit/x86-shared/MacroAssembler-x86-shared-inl.h b/js/src/jit/x86-shared/MacroAssembler-x86-shared-inl.h index f0bb71a2551..a9528c28a93 100644 --- a/js/src/jit/x86-shared/MacroAssembler-x86-shared-inl.h +++ b/js/src/jit/x86-shared/MacroAssembler-x86-shared-inl.h @@ -713,6 +713,26 @@ MacroAssembler::branchTestObjectImpl(Condition cond, const T& t, Label* label) j(cond, label); } +void +MacroAssembler::branchTestGCThing(Condition cond, const Address& address, Label* label) +{ + branchTestGCThingImpl(cond, address, label); +} + +void +MacroAssembler::branchTestGCThing(Condition cond, const BaseIndex& address, Label* label) +{ + branchTestGCThingImpl(cond, address, label); +} + +template +void +MacroAssembler::branchTestGCThingImpl(Condition cond, const T& t, Label* label) +{ + cond = testGCThing(cond, t); + j(cond, label); +} + //}}} check_macroassembler_style // =============================================================== diff --git a/js/src/jit/x86/MacroAssembler-x86.h b/js/src/jit/x86/MacroAssembler-x86.h index 7c1039235d4..0a7f8340028 100644 --- a/js/src/jit/x86/MacroAssembler-x86.h +++ b/js/src/jit/x86/MacroAssembler-x86.h @@ -660,11 +660,6 @@ class MacroAssemblerX86 : public MacroAssemblerX86Shared // Type testing instructions can take a tag in a register or a // ValueOperand. template - void branchTestGCThing(Condition cond, const T& t, Label* label) { - cond = testGCThing(cond, t); - j(cond, label); - } - template void branchTestPrimitive(Condition cond, const T& t, Label* label) { cond = testPrimitive(cond, t); j(cond, label); From abbbfb4c576d08d0da377abb81ea2a7a4fcfb722 Mon Sep 17 00:00:00 2001 From: Tooru Fujisawa Date: Thu, 3 Mar 2016 08:03:44 +0900 Subject: [PATCH 133/160] Bug 1245112 - Part 32: Move MacroAssembler::branchTestPrimitive into generic macro assembler. r=jandem --- js/src/jit/MacroAssembler.h | 7 +++++++ js/src/jit/arm/MacroAssembler-arm-inl.h | 20 +++++++++++++++++++ js/src/jit/arm/MacroAssembler-arm.h | 6 ------ js/src/jit/arm64/MacroAssembler-arm64-inl.h | 20 +++++++++++++++++++ js/src/jit/arm64/MacroAssembler-arm64.h | 5 ----- .../MacroAssembler-mips-shared-inl.h | 8 ++++++++ js/src/jit/mips32/MacroAssembler-mips32-inl.h | 6 ++++++ js/src/jit/mips32/MacroAssembler-mips32.cpp | 14 ------------- js/src/jit/mips32/MacroAssembler-mips32.h | 3 --- js/src/jit/mips64/MacroAssembler-mips64-inl.h | 8 ++++++++ js/src/jit/mips64/MacroAssembler-mips64.cpp | 15 -------------- js/src/jit/mips64/MacroAssembler-mips64.h | 3 --- js/src/jit/none/MacroAssembler-none.h | 1 - js/src/jit/x64/MacroAssembler-x64.h | 5 ----- .../MacroAssembler-x86-shared-inl.h | 20 +++++++++++++++++++ js/src/jit/x86/MacroAssembler-x86.h | 5 ----- 16 files changed, 89 insertions(+), 57 deletions(-) diff --git a/js/src/jit/MacroAssembler.h b/js/src/jit/MacroAssembler.h index df4463418d7..afb487202e8 100644 --- a/js/src/jit/MacroAssembler.h +++ b/js/src/jit/MacroAssembler.h @@ -933,6 +933,7 @@ class MacroAssembler : public MacroAssemblerSpecific inline void branchTestSymbol(Condition cond, Register tag, Label* label) PER_SHARED_ARCH; inline void branchTestNull(Condition cond, Register tag, Label* label) PER_SHARED_ARCH; inline void branchTestObject(Condition cond, Register tag, Label* label) PER_SHARED_ARCH; + inline void branchTestPrimitive(Condition cond, Register tag, Label* label) PER_SHARED_ARCH; // Perform a type-test on a Value, addressed by Address or BaseIndex, or // loaded into ValueOperand. @@ -983,6 +984,9 @@ class MacroAssembler : public MacroAssemblerSpecific inline void branchTestGCThing(Condition cond, const Address& address, Label* label) PER_SHARED_ARCH; inline void branchTestGCThing(Condition cond, const BaseIndex& address, Label* label) PER_SHARED_ARCH; + inline void branchTestPrimitive(Condition cond, const ValueOperand& value, Label* label) + DEFINED_ON(arm, arm64, mips32, mips64, x86_shared); + // Checks if given Value is evaluated to true or false in a condition. // The type of the value should match the type of the method. inline void branchTestInt32Truthy(bool truthy, const ValueOperand& value, Label* label) @@ -1025,6 +1029,9 @@ class MacroAssembler : public MacroAssemblerSpecific template inline void branchTestGCThingImpl(Condition cond, const T& t, Label* label) DEFINED_ON(arm, arm64, x86_shared); + template + inline void branchTestPrimitiveImpl(Condition cond, const T& t, Label* label) + DEFINED_ON(arm, arm64, x86_shared); //}}} check_macroassembler_style public: diff --git a/js/src/jit/arm/MacroAssembler-arm-inl.h b/js/src/jit/arm/MacroAssembler-arm-inl.h index 177354b185c..66aaa4ccb75 100644 --- a/js/src/jit/arm/MacroAssembler-arm-inl.h +++ b/js/src/jit/arm/MacroAssembler-arm-inl.h @@ -1111,6 +1111,26 @@ MacroAssembler::branchTestGCThingImpl(Condition cond, const T& t, Label* label) ma_b(label, c); } +void +MacroAssembler::branchTestPrimitive(Condition cond, Register tag, Label* label) +{ + branchTestPrimitiveImpl(cond, tag, label); +} + +void +MacroAssembler::branchTestPrimitive(Condition cond, const ValueOperand& value, Label* label) +{ + branchTestPrimitiveImpl(cond, value, label); +} + +template +void +MacroAssembler::branchTestPrimitiveImpl(Condition cond, const T& t, Label* label) +{ + Condition c = testPrimitive(cond, t); + ma_b(label, c); +} + //}}} check_macroassembler_style // =============================================================== diff --git a/js/src/jit/arm/MacroAssembler-arm.h b/js/src/jit/arm/MacroAssembler-arm.h index 91dda3becef..55cba630c81 100644 --- a/js/src/jit/arm/MacroAssembler-arm.h +++ b/js/src/jit/arm/MacroAssembler-arm.h @@ -684,12 +684,6 @@ class MacroAssemblerARMCompat : public MacroAssemblerARM Condition testMagic(Condition cond, const BaseIndex& src); Condition testGCThing(Condition cond, const BaseIndex& src); - template - void branchTestPrimitive(Condition cond, const T& t, Label* label) { - Condition c = testPrimitive(cond, t); - ma_b(label, c); - } - void branchTestValue(Condition cond, const ValueOperand& value, const Value& v, Label* label); void branchTestValue(Condition cond, const Address& valaddr, const ValueOperand& value, Label* label); diff --git a/js/src/jit/arm64/MacroAssembler-arm64-inl.h b/js/src/jit/arm64/MacroAssembler-arm64-inl.h index dab3601b10c..a8dea3c807e 100644 --- a/js/src/jit/arm64/MacroAssembler-arm64-inl.h +++ b/js/src/jit/arm64/MacroAssembler-arm64-inl.h @@ -1210,6 +1210,26 @@ MacroAssembler::branchTestGCThingImpl(Condition cond, const T& src, Label* label B(label, c); } +void +MacroAssembler::branchTestPrimitive(Condition cond, Register tag, Label* label) +{ + branchTestPrimitiveImpl(cond, tag, label); +} + +void +MacroAssembler::branchTestPrimitive(Condition cond, const ValueOperand& value, Label* label) +{ + branchTestPrimitiveImpl(cond, value, label); +} + +template +void +MacroAssembler::branchTestPrimitiveImpl(Condition cond, const T& t, Label* label) +{ + Condition c = testPrimitive(cond, t); + B(label, c); +} + //}}} check_macroassembler_style // =============================================================== diff --git a/js/src/jit/arm64/MacroAssembler-arm64.h b/js/src/jit/arm64/MacroAssembler-arm64.h index 4ac9755cc4c..3f1b978efe3 100644 --- a/js/src/jit/arm64/MacroAssembler-arm64.h +++ b/js/src/jit/arm64/MacroAssembler-arm64.h @@ -1328,11 +1328,6 @@ class MacroAssemblerCompat : public vixl::MacroAssembler return jumpWithPatch(label, Always, documentation); } - template - void branchTestPrimitive(Condition cond, const T& t, Label* label) { - Condition c = testPrimitive(cond, t); - B(label, c); - } template void branchTestMagic(Condition cond, const T& t, L label) { Condition c = testMagic(cond, t); diff --git a/js/src/jit/mips-shared/MacroAssembler-mips-shared-inl.h b/js/src/jit/mips-shared/MacroAssembler-mips-shared-inl.h index 3b68b1207c8..70fbb917937 100644 --- a/js/src/jit/mips-shared/MacroAssembler-mips-shared-inl.h +++ b/js/src/jit/mips-shared/MacroAssembler-mips-shared-inl.h @@ -705,6 +705,14 @@ MacroAssembler::branchTestGCThing(Condition cond, const BaseIndex& address, Labe (cond == Equal) ? AboveOrEqual : Below); } +void +MacroAssembler::branchTestPrimitive(Condition cond, Register tag, Label* label) +{ + MOZ_ASSERT(cond == Equal || cond == NotEqual); + ma_b(tag, ImmTag(JSVAL_UPPER_EXCL_TAG_OF_PRIMITIVE_SET), label, + (cond == Equal) ? Below : AboveOrEqual); +} + //}}} check_macroassembler_style // =============================================================== diff --git a/js/src/jit/mips32/MacroAssembler-mips32-inl.h b/js/src/jit/mips32/MacroAssembler-mips32-inl.h index e2c3e9bc7c7..eab0c0f06e6 100644 --- a/js/src/jit/mips32/MacroAssembler-mips32-inl.h +++ b/js/src/jit/mips32/MacroAssembler-mips32-inl.h @@ -374,6 +374,12 @@ MacroAssembler::branchTestObject(Condition cond, const ValueOperand& value, Labe branchTestObject(cond, value.typeReg(), label); } +void +MacroAssembler::branchTestPrimitive(Condition cond, const ValueOperand& value, Label* label) +{ + branchTestPrimitive(cond, value.typeReg(), label); +} + //}}} check_macroassembler_style // =============================================================== diff --git a/js/src/jit/mips32/MacroAssembler-mips32.cpp b/js/src/jit/mips32/MacroAssembler-mips32.cpp index c001458acdf..6a614ad7af8 100644 --- a/js/src/jit/mips32/MacroAssembler-mips32.cpp +++ b/js/src/jit/mips32/MacroAssembler-mips32.cpp @@ -1095,20 +1095,6 @@ MacroAssemblerMIPSCompat::ToType(Operand base) return Operand(Register::FromCode(base.base()), base.disp() + TAG_OFFSET); } -void -MacroAssemblerMIPSCompat::branchTestPrimitive(Condition cond, const ValueOperand& value, - Label* label) -{ - branchTestPrimitive(cond, value.typeReg(), label); -} -void -MacroAssemblerMIPSCompat::branchTestPrimitive(Condition cond, Register tag, Label* label) -{ - MOZ_ASSERT(cond == Equal || cond == NotEqual); - ma_b(tag, ImmTag(JSVAL_UPPER_EXCL_TAG_OF_PRIMITIVE_SET), label, - (cond == Equal) ? Below : AboveOrEqual); -} - void MacroAssemblerMIPSCompat::testNullSet(Condition cond, const ValueOperand& value, Register dest) { diff --git a/js/src/jit/mips32/MacroAssembler-mips32.h b/js/src/jit/mips32/MacroAssembler-mips32.h index c11d94ed83a..eedcc04b3b6 100644 --- a/js/src/jit/mips32/MacroAssembler-mips32.h +++ b/js/src/jit/mips32/MacroAssembler-mips32.h @@ -309,9 +309,6 @@ class MacroAssemblerMIPSCompat : public MacroAssemblerMIPS return value.typeReg(); } - void branchTestPrimitive(Condition cond, const ValueOperand& value, Label* label); - void branchTestPrimitive(Condition cond, Register tag, Label* label); - void branchTestValue(Condition cond, const ValueOperand& value, const Value& v, Label* label); void branchTestValue(Condition cond, const Address& valaddr, const ValueOperand& value, Label* label); diff --git a/js/src/jit/mips64/MacroAssembler-mips64-inl.h b/js/src/jit/mips64/MacroAssembler-mips64-inl.h index bafecf9259e..a4e76470dd3 100644 --- a/js/src/jit/mips64/MacroAssembler-mips64-inl.h +++ b/js/src/jit/mips64/MacroAssembler-mips64-inl.h @@ -329,6 +329,14 @@ MacroAssembler::branchTestObject(Condition cond, const ValueOperand& value, Labe branchTestObject(cond, scratch2, label); } +void +MacroAssembler::branchTestPrimitive(Condition cond, const ValueOperand& value, Label* label) +{ + SecondScratchRegisterScope scratch2(*this); + splitTag(value, scratch2); + branchTestPrimitive(cond, scratch2, label); +} + //}}} check_macroassembler_style // =============================================================== diff --git a/js/src/jit/mips64/MacroAssembler-mips64.cpp b/js/src/jit/mips64/MacroAssembler-mips64.cpp index b36d7108ca4..ecaa2ab0670 100644 --- a/js/src/jit/mips64/MacroAssembler-mips64.cpp +++ b/js/src/jit/mips64/MacroAssembler-mips64.cpp @@ -1222,21 +1222,6 @@ MacroAssembler::clampDoubleToUint8(FloatRegister input, Register output) bind(&done); } -void -MacroAssemblerMIPS64Compat::branchTestPrimitive(Condition cond, const ValueOperand& value, - Label* label) -{ - splitTag(value, SecondScratchReg); - branchTestPrimitive(cond, SecondScratchReg, label); -} -void -MacroAssemblerMIPS64Compat::branchTestPrimitive(Condition cond, Register tag, Label* label) -{ - MOZ_ASSERT(cond == Equal || cond == NotEqual); - ma_b(tag, ImmTag(JSVAL_UPPER_EXCL_TAG_OF_PRIMITIVE_SET), label, - (cond == Equal) ? Below : AboveOrEqual); -} - void MacroAssemblerMIPS64Compat::testNullSet(Condition cond, const ValueOperand& value, Register dest) { diff --git a/js/src/jit/mips64/MacroAssembler-mips64.h b/js/src/jit/mips64/MacroAssembler-mips64.h index d9fc0515ecb..a46f5751129 100644 --- a/js/src/jit/mips64/MacroAssembler-mips64.h +++ b/js/src/jit/mips64/MacroAssembler-mips64.h @@ -337,9 +337,6 @@ class MacroAssemblerMIPS64Compat : public MacroAssemblerMIPS64 return SecondScratchReg; } - void branchTestPrimitive(Condition cond, const ValueOperand& value, Label* label); - void branchTestPrimitive(Condition cond, Register tag, Label* label); - void branchTestValue(Condition cond, const ValueOperand& value, const Value& v, Label* label); void branchTestValue(Condition cond, const Address& valaddr, const ValueOperand& value, Label* label); diff --git a/js/src/jit/none/MacroAssembler-none.h b/js/src/jit/none/MacroAssembler-none.h index a35407c2524..de9e9fcef89 100644 --- a/js/src/jit/none/MacroAssembler-none.h +++ b/js/src/jit/none/MacroAssembler-none.h @@ -345,7 +345,6 @@ class MacroAssemblerNone : public Assembler Register splitTagForTest(ValueOperand) { MOZ_CRASH(); } - template void branchTestPrimitive(Condition, T, Label*) { MOZ_CRASH(); } template void branchTestMagic(Condition, T, L) { MOZ_CRASH(); } template void branchTestMagicValue(Condition, T, JSWhyMagic, Label*) { MOZ_CRASH(); } void boxDouble(FloatRegister, ValueOperand) { MOZ_CRASH(); } diff --git a/js/src/jit/x64/MacroAssembler-x64.h b/js/src/jit/x64/MacroAssembler-x64.h index 22ab3948351..813fb886aa1 100644 --- a/js/src/jit/x64/MacroAssembler-x64.h +++ b/js/src/jit/x64/MacroAssembler-x64.h @@ -683,11 +683,6 @@ class MacroAssemblerX64 : public MacroAssemblerX86Shared cmp32(reg, tag); } - template - void branchTestPrimitive(Condition cond, const T& t, Label* label) { - cond = testPrimitive(cond, t); - j(cond, label); - } template void branchTestMagic(Condition cond, const T& t, L label) { cond = testMagic(cond, t); diff --git a/js/src/jit/x86-shared/MacroAssembler-x86-shared-inl.h b/js/src/jit/x86-shared/MacroAssembler-x86-shared-inl.h index a9528c28a93..ab648e2a319 100644 --- a/js/src/jit/x86-shared/MacroAssembler-x86-shared-inl.h +++ b/js/src/jit/x86-shared/MacroAssembler-x86-shared-inl.h @@ -733,6 +733,26 @@ MacroAssembler::branchTestGCThingImpl(Condition cond, const T& t, Label* label) j(cond, label); } +void +MacroAssembler::branchTestPrimitive(Condition cond, Register tag, Label* label) +{ + branchTestPrimitiveImpl(cond, tag, label); +} + +void +MacroAssembler::branchTestPrimitive(Condition cond, const ValueOperand& value, Label* label) +{ + branchTestPrimitiveImpl(cond, value, label); +} + +template +void +MacroAssembler::branchTestPrimitiveImpl(Condition cond, const T& t, Label* label) +{ + cond = testPrimitive(cond, t); + j(cond, label); +} + //}}} check_macroassembler_style // =============================================================== diff --git a/js/src/jit/x86/MacroAssembler-x86.h b/js/src/jit/x86/MacroAssembler-x86.h index 0a7f8340028..5c20b6dfb4b 100644 --- a/js/src/jit/x86/MacroAssembler-x86.h +++ b/js/src/jit/x86/MacroAssembler-x86.h @@ -659,11 +659,6 @@ class MacroAssemblerX86 : public MacroAssemblerX86Shared // Type testing instructions can take a tag in a register or a // ValueOperand. - template - void branchTestPrimitive(Condition cond, const T& t, Label* label) { - cond = testPrimitive(cond, t); - j(cond, label); - } template void branchTestMagic(Condition cond, const T& t, L label) { cond = testMagic(cond, t); From f5782e24a0a75931fc310cebc58e349fec056751 Mon Sep 17 00:00:00 2001 From: Tooru Fujisawa Date: Thu, 3 Mar 2016 08:03:45 +0900 Subject: [PATCH 134/160] Bug 1245112 - Part 33: Move MacroAssembler::branchTestMagic into generic macro assembler. r=jandem --- js/src/jit/MacroAssembler.h | 10 +++++ js/src/jit/arm/MacroAssembler-arm-inl.h | 33 ++++++++++++++++ js/src/jit/arm/MacroAssembler-arm.h | 5 --- js/src/jit/arm64/MacroAssembler-arm64-inl.h | 33 ++++++++++++++++ js/src/jit/arm64/MacroAssembler-arm64.h | 5 --- .../MacroAssembler-mips-shared-inl.h | 23 +++++++++++ js/src/jit/mips32/MacroAssembler-mips32-inl.h | 7 ++++ js/src/jit/mips32/MacroAssembler-mips32.cpp | 37 ------------------ js/src/jit/mips32/MacroAssembler-mips32.h | 6 --- js/src/jit/mips64/MacroAssembler-mips64-inl.h | 9 +++++ js/src/jit/mips64/MacroAssembler-mips64.cpp | 39 ------------------- js/src/jit/mips64/MacroAssembler-mips64.h | 6 --- js/src/jit/none/MacroAssembler-none.h | 1 - js/src/jit/x64/MacroAssembler-x64.h | 5 --- .../MacroAssembler-x86-shared-inl.h | 33 ++++++++++++++++ js/src/jit/x86/MacroAssembler-x86.h | 7 ---- 16 files changed, 148 insertions(+), 111 deletions(-) diff --git a/js/src/jit/MacroAssembler.h b/js/src/jit/MacroAssembler.h index afb487202e8..b4e383d47d3 100644 --- a/js/src/jit/MacroAssembler.h +++ b/js/src/jit/MacroAssembler.h @@ -934,6 +934,7 @@ class MacroAssembler : public MacroAssemblerSpecific inline void branchTestNull(Condition cond, Register tag, Label* label) PER_SHARED_ARCH; inline void branchTestObject(Condition cond, Register tag, Label* label) PER_SHARED_ARCH; inline void branchTestPrimitive(Condition cond, Register tag, Label* label) PER_SHARED_ARCH; + inline void branchTestMagic(Condition cond, Register tag, Label* label) PER_SHARED_ARCH; // Perform a type-test on a Value, addressed by Address or BaseIndex, or // loaded into ValueOperand. @@ -987,6 +988,12 @@ class MacroAssembler : public MacroAssemblerSpecific inline void branchTestPrimitive(Condition cond, const ValueOperand& value, Label* label) DEFINED_ON(arm, arm64, mips32, mips64, x86_shared); + inline void branchTestMagic(Condition cond, const Address& address, Label* label) PER_SHARED_ARCH; + inline void branchTestMagic(Condition cond, const BaseIndex& address, Label* label) PER_SHARED_ARCH; + template + inline void branchTestMagic(Condition cond, const ValueOperand& value, L label) + DEFINED_ON(arm, arm64, mips32, mips64, x86_shared); + // Checks if given Value is evaluated to true or false in a condition. // The type of the value should match the type of the method. inline void branchTestInt32Truthy(bool truthy, const ValueOperand& value, Label* label) @@ -1032,6 +1039,9 @@ class MacroAssembler : public MacroAssemblerSpecific template inline void branchTestPrimitiveImpl(Condition cond, const T& t, Label* label) DEFINED_ON(arm, arm64, x86_shared); + template + inline void branchTestMagicImpl(Condition cond, const T& t, L label) + DEFINED_ON(arm, arm64, x86_shared); //}}} check_macroassembler_style public: diff --git a/js/src/jit/arm/MacroAssembler-arm-inl.h b/js/src/jit/arm/MacroAssembler-arm-inl.h index 66aaa4ccb75..c5c8b9c086c 100644 --- a/js/src/jit/arm/MacroAssembler-arm-inl.h +++ b/js/src/jit/arm/MacroAssembler-arm-inl.h @@ -1131,6 +1131,39 @@ MacroAssembler::branchTestPrimitiveImpl(Condition cond, const T& t, Label* label ma_b(label, c); } +void +MacroAssembler::branchTestMagic(Condition cond, Register tag, Label* label) +{ + branchTestMagicImpl(cond, tag, label); +} + +void +MacroAssembler::branchTestMagic(Condition cond, const Address& address, Label* label) +{ + branchTestMagicImpl(cond, address, label); +} + +void +MacroAssembler::branchTestMagic(Condition cond, const BaseIndex& address, Label* label) +{ + branchTestMagicImpl(cond, address, label); +} + +template +void +MacroAssembler::branchTestMagic(Condition cond, const ValueOperand& value, L label) +{ + branchTestMagicImpl(cond, value, label); +} + +template +void +MacroAssembler::branchTestMagicImpl(Condition cond, const T& t, L label) +{ + cond = testMagic(cond, t); + ma_b(label, cond); +} + //}}} check_macroassembler_style // =============================================================== diff --git a/js/src/jit/arm/MacroAssembler-arm.h b/js/src/jit/arm/MacroAssembler-arm.h index 55cba630c81..a0ea4ed75fc 100644 --- a/js/src/jit/arm/MacroAssembler-arm.h +++ b/js/src/jit/arm/MacroAssembler-arm.h @@ -751,11 +751,6 @@ class MacroAssemblerARMCompat : public MacroAssemblerARM void int32ValueToFloat32(const ValueOperand& operand, FloatRegister dest); void loadConstantFloat32(float f, FloatRegister dest); - template - void branchTestMagic(Condition cond, const T& t, L label) { - cond = testMagic(cond, t); - ma_b(label, cond); - } void branchTestMagicValue(Condition cond, const ValueOperand& val, JSWhyMagic why, Label* label) { MOZ_ASSERT(cond == Equal || cond == NotEqual); diff --git a/js/src/jit/arm64/MacroAssembler-arm64-inl.h b/js/src/jit/arm64/MacroAssembler-arm64-inl.h index a8dea3c807e..2e4b4f9affd 100644 --- a/js/src/jit/arm64/MacroAssembler-arm64-inl.h +++ b/js/src/jit/arm64/MacroAssembler-arm64-inl.h @@ -1230,6 +1230,39 @@ MacroAssembler::branchTestPrimitiveImpl(Condition cond, const T& t, Label* label B(label, c); } +void +MacroAssembler::branchTestMagic(Condition cond, Register tag, Label* label) +{ + branchTestMagicImpl(cond, tag, label); +} + +void +MacroAssembler::branchTestMagic(Condition cond, const Address& address, Label* label) +{ + branchTestMagicImpl(cond, address, label); +} + +void +MacroAssembler::branchTestMagic(Condition cond, const BaseIndex& address, Label* label) +{ + branchTestMagicImpl(cond, address, label); +} + +template +void +MacroAssembler::branchTestMagic(Condition cond, const ValueOperand& value, L label) +{ + branchTestMagicImpl(cond, value, label); +} + +template +void +MacroAssembler::branchTestMagicImpl(Condition cond, const T& t, L label) +{ + Condition c = testMagic(cond, t); + B(label, c); +} + //}}} check_macroassembler_style // =============================================================== diff --git a/js/src/jit/arm64/MacroAssembler-arm64.h b/js/src/jit/arm64/MacroAssembler-arm64.h index 3f1b978efe3..d44e3553e37 100644 --- a/js/src/jit/arm64/MacroAssembler-arm64.h +++ b/js/src/jit/arm64/MacroAssembler-arm64.h @@ -1328,11 +1328,6 @@ class MacroAssemblerCompat : public vixl::MacroAssembler return jumpWithPatch(label, Always, documentation); } - template - void branchTestMagic(Condition cond, const T& t, L label) { - Condition c = testMagic(cond, t); - B(label, c); - } void branchTestMagicValue(Condition cond, const ValueOperand& val, JSWhyMagic why, Label* label) { MOZ_ASSERT(cond == Equal || cond == NotEqual); branchTestValue(cond, val, MagicValue(why), label); diff --git a/js/src/jit/mips-shared/MacroAssembler-mips-shared-inl.h b/js/src/jit/mips-shared/MacroAssembler-mips-shared-inl.h index 70fbb917937..d67901e5af7 100644 --- a/js/src/jit/mips-shared/MacroAssembler-mips-shared-inl.h +++ b/js/src/jit/mips-shared/MacroAssembler-mips-shared-inl.h @@ -713,6 +713,29 @@ MacroAssembler::branchTestPrimitive(Condition cond, Register tag, Label* label) (cond == Equal) ? Below : AboveOrEqual); } +void +MacroAssembler::branchTestMagic(Condition cond, Register tag, Label* label) +{ + MOZ_ASSERT(cond == Equal || cond == NotEqual); + ma_b(tag, ImmTag(JSVAL_TAG_MAGIC), label, cond); +} + +void +MacroAssembler::branchTestMagic(Condition cond, const Address& address, Label* label) +{ + SecondScratchRegisterScope scratch2(*this); + extractTag(address, scratch2); + branchTestMagic(cond, scratch2, label); +} + +void +MacroAssembler::branchTestMagic(Condition cond, const BaseIndex& address, Label* label) +{ + SecondScratchRegisterScope scratch2(*this); + extractTag(address, scratch2); + branchTestMagic(cond, scratch2, label); +} + //}}} check_macroassembler_style // =============================================================== diff --git a/js/src/jit/mips32/MacroAssembler-mips32-inl.h b/js/src/jit/mips32/MacroAssembler-mips32-inl.h index eab0c0f06e6..271d82cdfc7 100644 --- a/js/src/jit/mips32/MacroAssembler-mips32-inl.h +++ b/js/src/jit/mips32/MacroAssembler-mips32-inl.h @@ -380,6 +380,13 @@ MacroAssembler::branchTestPrimitive(Condition cond, const ValueOperand& value, L branchTestPrimitive(cond, value.typeReg(), label); } +template +void +MacroAssembler::branchTestMagic(Condition cond, const ValueOperand& value, L label) +{ + ma_b(value.typeReg(), ImmTag(JSVAL_TAG_MAGIC), label, cond); +} + //}}} check_macroassembler_style // =============================================================== diff --git a/js/src/jit/mips32/MacroAssembler-mips32.cpp b/js/src/jit/mips32/MacroAssembler-mips32.cpp index 6a614ad7af8..aaea046e1d1 100644 --- a/js/src/jit/mips32/MacroAssembler-mips32.cpp +++ b/js/src/jit/mips32/MacroAssembler-mips32.cpp @@ -1116,43 +1116,6 @@ MacroAssemblerMIPSCompat::testUndefinedSet(Condition cond, const ValueOperand& v ma_cmp_set(dest, value.typeReg(), ImmType(JSVAL_TYPE_UNDEFINED), cond); } -void -MacroAssemblerMIPSCompat::branchTestMagic(Condition cond, const ValueOperand& value, Label* label) -{ - branchTestMagic(cond, value.typeReg(), label); -} - -void -MacroAssemblerMIPSCompat::branchTestMagic(Condition cond, const ValueOperand& value, - wasm::JumpTarget target) -{ - MOZ_ASSERT(cond == Equal || cond == NotEqual); - ma_b(value.typeReg(), ImmTag(JSVAL_TAG_MAGIC), target, cond); -} - -void -MacroAssemblerMIPSCompat::branchTestMagic(Condition cond, Register tag, Label* label) -{ - MOZ_ASSERT(cond == Equal || cond == NotEqual); - ma_b(tag, ImmTag(JSVAL_TAG_MAGIC), label, cond); -} - -void -MacroAssemblerMIPSCompat::branchTestMagic(Condition cond, const Address& address, Label* label) -{ - MOZ_ASSERT(cond == Equal || cond == NotEqual); - extractTag(address, SecondScratchReg); - ma_b(SecondScratchReg, ImmTag(JSVAL_TAG_MAGIC), label, cond); -} - -void -MacroAssemblerMIPSCompat::branchTestMagic(Condition cond, const BaseIndex& src, Label* label) -{ - MOZ_ASSERT(cond == Equal || cond == NotEqual); - extractTag(src, SecondScratchReg); - ma_b(SecondScratchReg, ImmTag(JSVAL_TAG_MAGIC), label, cond); -} - void MacroAssemblerMIPSCompat::branchTestValue(Condition cond, const ValueOperand& value, const Value& v, Label* label) diff --git a/js/src/jit/mips32/MacroAssembler-mips32.h b/js/src/jit/mips32/MacroAssembler-mips32.h index eedcc04b3b6..cc1c8a81f31 100644 --- a/js/src/jit/mips32/MacroAssembler-mips32.h +++ b/js/src/jit/mips32/MacroAssembler-mips32.h @@ -375,12 +375,6 @@ class MacroAssemblerMIPSCompat : public MacroAssemblerMIPS void testUndefinedSet(Condition cond, const ValueOperand& value, Register dest); - void branchTestMagic(Condition cond, const ValueOperand& value, Label* label); - void branchTestMagic(Condition cond, const ValueOperand& value, wasm::JumpTarget target); - void branchTestMagic(Condition cond, Register tag, Label* label); - void branchTestMagic(Condition cond, const Address& address, Label* label); - void branchTestMagic(Condition cond, const BaseIndex& src, Label* label); - void branchTestMagicValue(Condition cond, const ValueOperand& val, JSWhyMagic why, Label* label) { MOZ_ASSERT(cond == Equal || cond == NotEqual); diff --git a/js/src/jit/mips64/MacroAssembler-mips64-inl.h b/js/src/jit/mips64/MacroAssembler-mips64-inl.h index a4e76470dd3..889951b85cd 100644 --- a/js/src/jit/mips64/MacroAssembler-mips64-inl.h +++ b/js/src/jit/mips64/MacroAssembler-mips64-inl.h @@ -337,6 +337,15 @@ MacroAssembler::branchTestPrimitive(Condition cond, const ValueOperand& value, L branchTestPrimitive(cond, scratch2, label); } +template +void +MacroAssembler::branchTestMagic(Condition cond, const ValueOperand& value, L label) +{ + SecondScratchRegisterScope scratch2(*this); + splitTag(value, scratch2); + ma_b(scratch2, ImmTag(JSVAL_TAG_MAGIC), label, cond); +} + //}}} check_macroassembler_style // =============================================================== diff --git a/js/src/jit/mips64/MacroAssembler-mips64.cpp b/js/src/jit/mips64/MacroAssembler-mips64.cpp index ecaa2ab0670..ffceef78f50 100644 --- a/js/src/jit/mips64/MacroAssembler-mips64.cpp +++ b/js/src/jit/mips64/MacroAssembler-mips64.cpp @@ -1246,45 +1246,6 @@ MacroAssemblerMIPS64Compat::testUndefinedSet(Condition cond, const ValueOperand& ma_cmp_set(dest, SecondScratchReg, ImmTag(JSVAL_TAG_UNDEFINED), cond); } -void -MacroAssemblerMIPS64Compat::branchTestMagic(Condition cond, const ValueOperand& value, Label* label) -{ - splitTag(value, SecondScratchReg); - branchTestMagic(cond, SecondScratchReg, label); -} - -void -MacroAssemblerMIPS64Compat::branchTestMagic(Condition cond, const ValueOperand& value, - wasm::JumpTarget target) -{ - MOZ_ASSERT(cond == Equal || cond == NotEqual); - splitTag(value, SecondScratchReg); - ma_b(SecondScratchReg, ImmTag(JSVAL_TAG_MAGIC), target, cond); -} - -void -MacroAssemblerMIPS64Compat::branchTestMagic(Condition cond, Register tag, Label* label) -{ - MOZ_ASSERT(cond == Equal || cond == NotEqual); - ma_b(tag, ImmTag(JSVAL_TAG_MAGIC), label, cond); -} - -void -MacroAssemblerMIPS64Compat::branchTestMagic(Condition cond, const Address& address, Label* label) -{ - MOZ_ASSERT(cond == Equal || cond == NotEqual); - extractTag(address, SecondScratchReg); - ma_b(SecondScratchReg, ImmTag(JSVAL_TAG_MAGIC), label, cond); -} - -void -MacroAssemblerMIPS64Compat::branchTestMagic(Condition cond, const BaseIndex& src, Label* label) -{ - MOZ_ASSERT(cond == Equal || cond == NotEqual); - extractTag(src, SecondScratchReg); - ma_b(SecondScratchReg, ImmTag(JSVAL_TAG_MAGIC), label, cond); -} - void MacroAssemblerMIPS64Compat::branchTestValue(Condition cond, const ValueOperand& value, const Value& v, Label* label) diff --git a/js/src/jit/mips64/MacroAssembler-mips64.h b/js/src/jit/mips64/MacroAssembler-mips64.h index a46f5751129..6ffd129cdb5 100644 --- a/js/src/jit/mips64/MacroAssembler-mips64.h +++ b/js/src/jit/mips64/MacroAssembler-mips64.h @@ -416,12 +416,6 @@ class MacroAssemblerMIPS64Compat : public MacroAssemblerMIPS64 void testUndefinedSet(Condition cond, const ValueOperand& value, Register dest); - void branchTestMagic(Condition cond, const ValueOperand& value, Label* label); - void branchTestMagic(Condition cond, const ValueOperand& value, wasm::JumpTarget target); - void branchTestMagic(Condition cond, Register tag, Label* label); - void branchTestMagic(Condition cond, const Address& address, Label* label); - void branchTestMagic(Condition cond, const BaseIndex& src, Label* label); - void branchTestMagicValue(Condition cond, const ValueOperand& val, JSWhyMagic why, Label* label) { MOZ_ASSERT(cond == Equal || cond == NotEqual); diff --git a/js/src/jit/none/MacroAssembler-none.h b/js/src/jit/none/MacroAssembler-none.h index de9e9fcef89..d182005bd0f 100644 --- a/js/src/jit/none/MacroAssembler-none.h +++ b/js/src/jit/none/MacroAssembler-none.h @@ -345,7 +345,6 @@ class MacroAssemblerNone : public Assembler Register splitTagForTest(ValueOperand) { MOZ_CRASH(); } - template void branchTestMagic(Condition, T, L) { MOZ_CRASH(); } template void branchTestMagicValue(Condition, T, JSWhyMagic, Label*) { MOZ_CRASH(); } void boxDouble(FloatRegister, ValueOperand) { MOZ_CRASH(); } void boxNonDouble(JSValueType, Register, ValueOperand) { MOZ_CRASH(); } diff --git a/js/src/jit/x64/MacroAssembler-x64.h b/js/src/jit/x64/MacroAssembler-x64.h index 813fb886aa1..f90151d2ffc 100644 --- a/js/src/jit/x64/MacroAssembler-x64.h +++ b/js/src/jit/x64/MacroAssembler-x64.h @@ -683,11 +683,6 @@ class MacroAssemblerX64 : public MacroAssemblerX86Shared cmp32(reg, tag); } - template - void branchTestMagic(Condition cond, const T& t, L label) { - cond = testMagic(cond, t); - j(cond, label); - } void branchTestMagicValue(Condition cond, const ValueOperand& val, JSWhyMagic why, Label* label) { diff --git a/js/src/jit/x86-shared/MacroAssembler-x86-shared-inl.h b/js/src/jit/x86-shared/MacroAssembler-x86-shared-inl.h index ab648e2a319..d8492e24993 100644 --- a/js/src/jit/x86-shared/MacroAssembler-x86-shared-inl.h +++ b/js/src/jit/x86-shared/MacroAssembler-x86-shared-inl.h @@ -753,6 +753,39 @@ MacroAssembler::branchTestPrimitiveImpl(Condition cond, const T& t, Label* label j(cond, label); } +void +MacroAssembler::branchTestMagic(Condition cond, Register tag, Label* label) +{ + branchTestMagicImpl(cond, tag, label); +} + +void +MacroAssembler::branchTestMagic(Condition cond, const Address& address, Label* label) +{ + branchTestMagicImpl(cond, address, label); +} + +void +MacroAssembler::branchTestMagic(Condition cond, const BaseIndex& address, Label* label) +{ + branchTestMagicImpl(cond, address, label); +} + +template +void +MacroAssembler::branchTestMagic(Condition cond, const ValueOperand& value, L label) +{ + branchTestMagicImpl(cond, value, label); +} + +template +void +MacroAssembler::branchTestMagicImpl(Condition cond, const T& t, L label) +{ + cond = testMagic(cond, t); + j(cond, label); +} + //}}} check_macroassembler_style // =============================================================== diff --git a/js/src/jit/x86/MacroAssembler-x86.h b/js/src/jit/x86/MacroAssembler-x86.h index 5c20b6dfb4b..1441804b69f 100644 --- a/js/src/jit/x86/MacroAssembler-x86.h +++ b/js/src/jit/x86/MacroAssembler-x86.h @@ -657,13 +657,6 @@ class MacroAssemblerX86 : public MacroAssemblerX86Shared movl(reg, Operand(esp, arg * sizeof(intptr_t))); } - // Type testing instructions can take a tag in a register or a - // ValueOperand. - template - void branchTestMagic(Condition cond, const T& t, L label) { - cond = testMagic(cond, t); - j(cond, label); - } void branchTestMagicValue(Condition cond, const ValueOperand& val, JSWhyMagic why, Label* label) { From 8468cb2b2155ad95e07874fe7936cf0daada1622 Mon Sep 17 00:00:00 2001 From: Tooru Fujisawa Date: Thu, 3 Mar 2016 08:03:45 +0900 Subject: [PATCH 135/160] Bug 1245112 - Part 34: Move MacroAssembler::branchTestMagicValue into generic macro assembler. r=jandem --- js/src/jit/MacroAssembler-inl.h | 8 ++++++++ js/src/jit/MacroAssembler.h | 3 +++ js/src/jit/arm/MacroAssembler-arm.h | 5 ----- js/src/jit/arm64/MacroAssembler-arm64.h | 4 ---- js/src/jit/mips32/MacroAssembler-mips32.h | 6 ------ js/src/jit/mips64/MacroAssembler-mips64.h | 6 ------ js/src/jit/none/MacroAssembler-none.h | 1 - js/src/jit/x64/MacroAssembler-x64.h | 6 ------ js/src/jit/x86/MacroAssembler-x86.h | 7 ------- 9 files changed, 11 insertions(+), 35 deletions(-) diff --git a/js/src/jit/MacroAssembler-inl.h b/js/src/jit/MacroAssembler-inl.h index 9ccd45209e8..3ab0328a9da 100644 --- a/js/src/jit/MacroAssembler-inl.h +++ b/js/src/jit/MacroAssembler-inl.h @@ -510,6 +510,14 @@ MacroAssembler::branchTestNeedsIncrementalBarrier(Condition cond, Label* label) branchTest32(cond, needsBarrierAddr, Imm32(0x1), label); } +void +MacroAssembler::branchTestMagicValue(Condition cond, const ValueOperand& val, JSWhyMagic why, + Label* label) +{ + MOZ_ASSERT(cond == Equal || cond == NotEqual); + branchTestValue(cond, val, MagicValue(why), label); +} + //}}} check_macroassembler_style // =============================================================== diff --git a/js/src/jit/MacroAssembler.h b/js/src/jit/MacroAssembler.h index b4e383d47d3..ce4d0d82237 100644 --- a/js/src/jit/MacroAssembler.h +++ b/js/src/jit/MacroAssembler.h @@ -994,6 +994,9 @@ class MacroAssembler : public MacroAssemblerSpecific inline void branchTestMagic(Condition cond, const ValueOperand& value, L label) DEFINED_ON(arm, arm64, mips32, mips64, x86_shared); + inline void branchTestMagicValue(Condition cond, const ValueOperand& val, JSWhyMagic why, + Label* label); + // Checks if given Value is evaluated to true or false in a condition. // The type of the value should match the type of the method. inline void branchTestInt32Truthy(bool truthy, const ValueOperand& value, Label* label) diff --git a/js/src/jit/arm/MacroAssembler-arm.h b/js/src/jit/arm/MacroAssembler-arm.h index a0ea4ed75fc..e364daaa86b 100644 --- a/js/src/jit/arm/MacroAssembler-arm.h +++ b/js/src/jit/arm/MacroAssembler-arm.h @@ -751,11 +751,6 @@ class MacroAssemblerARMCompat : public MacroAssemblerARM void int32ValueToFloat32(const ValueOperand& operand, FloatRegister dest); void loadConstantFloat32(float f, FloatRegister dest); - void branchTestMagicValue(Condition cond, const ValueOperand& val, JSWhyMagic why, - Label* label) { - MOZ_ASSERT(cond == Equal || cond == NotEqual); - branchTestValue(cond, val, MagicValue(why), label); - } void moveValue(const Value& val, Register type, Register data); CodeOffsetJump jumpWithPatch(RepatchLabel* label, Condition cond = Always, diff --git a/js/src/jit/arm64/MacroAssembler-arm64.h b/js/src/jit/arm64/MacroAssembler-arm64.h index d44e3553e37..5f0d74abd7a 100644 --- a/js/src/jit/arm64/MacroAssembler-arm64.h +++ b/js/src/jit/arm64/MacroAssembler-arm64.h @@ -1328,10 +1328,6 @@ class MacroAssemblerCompat : public vixl::MacroAssembler return jumpWithPatch(label, Always, documentation); } - void branchTestMagicValue(Condition cond, const ValueOperand& val, JSWhyMagic why, Label* label) { - MOZ_ASSERT(cond == Equal || cond == NotEqual); - branchTestValue(cond, val, MagicValue(why), label); - } void branchTestValue(Condition cond, const ValueOperand& value, const Value& v, Label* label) { vixl::UseScratchRegisterScope temps(this); const ARMRegister scratch64 = temps.AcquireX(); diff --git a/js/src/jit/mips32/MacroAssembler-mips32.h b/js/src/jit/mips32/MacroAssembler-mips32.h index cc1c8a81f31..22cfcdb543f 100644 --- a/js/src/jit/mips32/MacroAssembler-mips32.h +++ b/js/src/jit/mips32/MacroAssembler-mips32.h @@ -375,12 +375,6 @@ class MacroAssemblerMIPSCompat : public MacroAssemblerMIPS void testUndefinedSet(Condition cond, const ValueOperand& value, Register dest); - void branchTestMagicValue(Condition cond, const ValueOperand& val, JSWhyMagic why, - Label* label) { - MOZ_ASSERT(cond == Equal || cond == NotEqual); - branchTestValue(cond, val, MagicValue(why), label); - } - // higher level tag testing code Operand ToPayload(Operand base); Address ToPayload(Address base) { diff --git a/js/src/jit/mips64/MacroAssembler-mips64.h b/js/src/jit/mips64/MacroAssembler-mips64.h index 6ffd129cdb5..9a90a41543c 100644 --- a/js/src/jit/mips64/MacroAssembler-mips64.h +++ b/js/src/jit/mips64/MacroAssembler-mips64.h @@ -416,12 +416,6 @@ class MacroAssemblerMIPS64Compat : public MacroAssemblerMIPS64 void testUndefinedSet(Condition cond, const ValueOperand& value, Register dest); - void branchTestMagicValue(Condition cond, const ValueOperand& val, JSWhyMagic why, - Label* label) { - MOZ_ASSERT(cond == Equal || cond == NotEqual); - branchTestValue(cond, val, MagicValue(why), label); - } - // higher level tag testing code Address ToPayload(Address value) { return value; diff --git a/js/src/jit/none/MacroAssembler-none.h b/js/src/jit/none/MacroAssembler-none.h index d182005bd0f..05126f85ead 100644 --- a/js/src/jit/none/MacroAssembler-none.h +++ b/js/src/jit/none/MacroAssembler-none.h @@ -345,7 +345,6 @@ class MacroAssemblerNone : public Assembler Register splitTagForTest(ValueOperand) { MOZ_CRASH(); } - template void branchTestMagicValue(Condition, T, JSWhyMagic, Label*) { MOZ_CRASH(); } void boxDouble(FloatRegister, ValueOperand) { MOZ_CRASH(); } void boxNonDouble(JSValueType, Register, ValueOperand) { MOZ_CRASH(); } template void unboxInt32(T, Register) { MOZ_CRASH(); } diff --git a/js/src/jit/x64/MacroAssembler-x64.h b/js/src/jit/x64/MacroAssembler-x64.h index f90151d2ffc..f269956b5bc 100644 --- a/js/src/jit/x64/MacroAssembler-x64.h +++ b/js/src/jit/x64/MacroAssembler-x64.h @@ -683,12 +683,6 @@ class MacroAssemblerX64 : public MacroAssemblerX86Shared cmp32(reg, tag); } - void branchTestMagicValue(Condition cond, const ValueOperand& val, JSWhyMagic why, - Label* label) - { - MOZ_ASSERT(cond == Equal || cond == NotEqual); - branchTestValue(cond, val, MagicValue(why), label); - } Condition testMagic(Condition cond, const ValueOperand& src) { ScratchRegisterScope scratch(asMasm()); splitTag(src, scratch); diff --git a/js/src/jit/x86/MacroAssembler-x86.h b/js/src/jit/x86/MacroAssembler-x86.h index 1441804b69f..7d850d4e415 100644 --- a/js/src/jit/x86/MacroAssembler-x86.h +++ b/js/src/jit/x86/MacroAssembler-x86.h @@ -657,13 +657,6 @@ class MacroAssemblerX86 : public MacroAssemblerX86Shared movl(reg, Operand(esp, arg * sizeof(intptr_t))); } - void branchTestMagicValue(Condition cond, const ValueOperand& val, JSWhyMagic why, - Label* label) - { - MOZ_ASSERT(cond == Equal || cond == NotEqual); - branchTestValue(cond, val, MagicValue(why), label); - } - // Note: this function clobbers the source register. void boxDouble(FloatRegister src, const ValueOperand& dest) { if (Assembler::HasSSE41()) { From 37d99abba1904b66ebf1e62e9ada8a0bca2d09df Mon Sep 17 00:00:00 2001 From: Tooru Fujisawa Date: Thu, 3 Mar 2016 08:03:45 +0900 Subject: [PATCH 136/160] Bug 1245112 - Part 35: Move MacroAssembler::branchTestValue into generic macro assembler. r=jandem --- js/src/jit/MacroAssembler.h | 3 + js/src/jit/arm/MacroAssembler-arm.cpp | 68 +++++++-------------- js/src/jit/arm/MacroAssembler-arm.h | 4 -- js/src/jit/arm64/MacroAssembler-arm64.cpp | 13 ++++ js/src/jit/arm64/MacroAssembler-arm64.h | 20 ------ js/src/jit/mips32/MacroAssembler-mips32.cpp | 58 +++++++----------- js/src/jit/mips32/MacroAssembler-mips32.h | 4 -- js/src/jit/mips64/MacroAssembler-mips64.cpp | 28 +++------ js/src/jit/mips64/MacroAssembler-mips64.h | 4 -- js/src/jit/none/MacroAssembler-none.h | 1 - js/src/jit/x64/MacroAssembler-x64-inl.h | 8 --- js/src/jit/x64/MacroAssembler-x64.cpp | 12 ++++ js/src/jit/x64/MacroAssembler-x64.h | 9 --- js/src/jit/x86/MacroAssembler-x86-inl.h | 17 ------ js/src/jit/x86/MacroAssembler-x86.cpp | 53 ++++++++-------- js/src/jit/x86/MacroAssembler-x86.h | 6 -- 16 files changed, 108 insertions(+), 200 deletions(-) diff --git a/js/src/jit/MacroAssembler.h b/js/src/jit/MacroAssembler.h index ce4d0d82237..4ec898985e7 100644 --- a/js/src/jit/MacroAssembler.h +++ b/js/src/jit/MacroAssembler.h @@ -997,6 +997,9 @@ class MacroAssembler : public MacroAssemblerSpecific inline void branchTestMagicValue(Condition cond, const ValueOperand& val, JSWhyMagic why, Label* label); + void branchTestValue(Condition cond, const ValueOperand& lhs, + const Value& rhs, Label* label) PER_ARCH; + // Checks if given Value is evaluated to true or false in a condition. // The type of the value should match the type of the method. inline void branchTestInt32Truthy(bool truthy, const ValueOperand& value, Label* label) diff --git a/js/src/jit/arm/MacroAssembler-arm.cpp b/js/src/jit/arm/MacroAssembler-arm.cpp index e05f92b5589..661af025bd8 100644 --- a/js/src/jit/arm/MacroAssembler-arm.cpp +++ b/js/src/jit/arm/MacroAssembler-arm.cpp @@ -2853,53 +2853,6 @@ MacroAssemblerARMCompat::testGCThing(Condition cond, const BaseIndex& address) return cond == Equal ? AboveOrEqual : Below; } -void -MacroAssemblerARMCompat::branchTestValue(Condition cond, const ValueOperand& value, - const Value& v, Label* label) -{ - // If cond == NotEqual, branch when a.payload != b.payload || a.tag != - // b.tag. If the payloads are equal, compare the tags. If the payloads are - // not equal, short circuit true (NotEqual). - // - // If cand == Equal, branch when a.payload == b.payload && a.tag == b.tag. - // If the payloads are equal, compare the tags. If the payloads are not - // equal, short circuit false (NotEqual). - jsval_layout jv = JSVAL_TO_IMPL(v); - if (v.isMarkable()) - ma_cmp(value.payloadReg(), ImmGCPtr(reinterpret_cast(v.toGCThing()))); - else - ma_cmp(value.payloadReg(), Imm32(jv.s.payload.i32)); - ma_cmp(value.typeReg(), Imm32(jv.s.tag), Equal); - ma_b(label, cond); -} - -void -MacroAssemblerARMCompat::branchTestValue(Condition cond, const Address& valaddr, - const ValueOperand& value, Label* label) -{ - MOZ_ASSERT(cond == Equal || cond == NotEqual); - ScratchRegisterScope scratch(asMasm()); - - // Check payload before tag, since payload is more likely to differ. - if (cond == NotEqual) { - ma_ldr(ToPayload(valaddr), scratch); - asMasm().branchPtr(NotEqual, scratch, value.payloadReg(), label); - - ma_ldr(ToType(valaddr), scratch); - asMasm().branchPtr(NotEqual, scratch, value.typeReg(), label); - } else { - Label fallthrough; - - ma_ldr(ToPayload(valaddr), scratch); - asMasm().branchPtr(NotEqual, scratch, value.payloadReg(), &fallthrough); - - ma_ldr(ToType(valaddr), scratch); - asMasm().branchPtr(Equal, scratch, value.typeReg(), label); - - bind(&fallthrough); - } -} - // Unboxing code. void MacroAssemblerARMCompat::unboxNonDouble(const ValueOperand& operand, Register dest) @@ -5068,4 +5021,25 @@ MacroAssembler::branchValueIsNurseryObject(Condition cond, ValueOperand value, bind(&done); } +void +MacroAssembler::branchTestValue(Condition cond, const ValueOperand& lhs, + const Value& rhs, Label* label) +{ + MOZ_ASSERT(cond == Equal || cond == NotEqual); + // If cond == NotEqual, branch when a.payload != b.payload || a.tag != + // b.tag. If the payloads are equal, compare the tags. If the payloads are + // not equal, short circuit true (NotEqual). + // + // If cand == Equal, branch when a.payload == b.payload && a.tag == b.tag. + // If the payloads are equal, compare the tags. If the payloads are not + // equal, short circuit false (NotEqual). + jsval_layout jv = JSVAL_TO_IMPL(rhs); + if (rhs.isMarkable()) + ma_cmp(lhs.payloadReg(), ImmGCPtr(reinterpret_cast(rhs.toGCThing()))); + else + ma_cmp(lhs.payloadReg(), Imm32(jv.s.payload.i32)); + ma_cmp(lhs.typeReg(), Imm32(jv.s.tag), Equal); + ma_b(label, cond); +} + //}}} check_macroassembler_style diff --git a/js/src/jit/arm/MacroAssembler-arm.h b/js/src/jit/arm/MacroAssembler-arm.h index e364daaa86b..38f8f7615f5 100644 --- a/js/src/jit/arm/MacroAssembler-arm.h +++ b/js/src/jit/arm/MacroAssembler-arm.h @@ -684,10 +684,6 @@ class MacroAssemblerARMCompat : public MacroAssemblerARM Condition testMagic(Condition cond, const BaseIndex& src); Condition testGCThing(Condition cond, const BaseIndex& src); - void branchTestValue(Condition cond, const ValueOperand& value, const Value& v, Label* label); - void branchTestValue(Condition cond, const Address& valaddr, const ValueOperand& value, - Label* label); - // Unboxing code. void unboxNonDouble(const ValueOperand& operand, Register dest); void unboxNonDouble(const Address& src, Register dest); diff --git a/js/src/jit/arm64/MacroAssembler-arm64.cpp b/js/src/jit/arm64/MacroAssembler-arm64.cpp index 72c90645a3d..413789f7e40 100644 --- a/js/src/jit/arm64/MacroAssembler-arm64.cpp +++ b/js/src/jit/arm64/MacroAssembler-arm64.cpp @@ -723,6 +723,19 @@ MacroAssembler::branchValueIsNurseryObject(Condition cond, ValueOperand value, R temp, ImmWord(nursery.nurserySize()), label); } +void +MacroAssembler::branchTestValue(Condition cond, const ValueOperand& lhs, + const Value& rhs, Label* label) +{ + MOZ_ASSERT(cond == Equal || cond == NotEqual); + vixl::UseScratchRegisterScope temps(this); + const ARMRegister scratch64 = temps.AcquireX(); + MOZ_ASSERT(scratch64.asUnsized() != lhs.valueReg()); + moveValue(rhs, ValueOperand(scratch64.asUnsized())); + Cmp(ARMRegister(lhs.valueReg(), 64), scratch64); + B(label, cond); +} + //}}} check_macroassembler_style } // namespace jit diff --git a/js/src/jit/arm64/MacroAssembler-arm64.h b/js/src/jit/arm64/MacroAssembler-arm64.h index 5f0d74abd7a..5d54773e68c 100644 --- a/js/src/jit/arm64/MacroAssembler-arm64.h +++ b/js/src/jit/arm64/MacroAssembler-arm64.h @@ -1328,26 +1328,6 @@ class MacroAssemblerCompat : public vixl::MacroAssembler return jumpWithPatch(label, Always, documentation); } - void branchTestValue(Condition cond, const ValueOperand& value, const Value& v, Label* label) { - vixl::UseScratchRegisterScope temps(this); - const ARMRegister scratch64 = temps.AcquireX(); - MOZ_ASSERT(scratch64.asUnsized() != value.valueReg()); - moveValue(v, ValueOperand(scratch64.asUnsized())); - Cmp(ARMRegister(value.valueReg(), 64), scratch64); - B(label, cond); - } - void branchTestValue(Condition cond, const Address& valaddr, const ValueOperand& value, - Label* label) - { - vixl::UseScratchRegisterScope temps(this); - const ARMRegister scratch64 = temps.AcquireX(); - MOZ_ASSERT(scratch64.asUnsized() != valaddr.base); - MOZ_ASSERT(scratch64.asUnsized() != value.valueReg()); - loadValue(valaddr, scratch64.asUnsized()); - Cmp(ARMRegister(value.valueReg(), 64), Operand(scratch64)); - B(label, cond); - } - void compareDouble(DoubleCondition cond, FloatRegister lhs, FloatRegister rhs) { Fcmp(ARMFPRegister(lhs, 64), ARMFPRegister(rhs, 64)); } diff --git a/js/src/jit/mips32/MacroAssembler-mips32.cpp b/js/src/jit/mips32/MacroAssembler-mips32.cpp index aaea046e1d1..0d731a7acc7 100644 --- a/js/src/jit/mips32/MacroAssembler-mips32.cpp +++ b/js/src/jit/mips32/MacroAssembler-mips32.cpp @@ -1116,42 +1116,6 @@ MacroAssemblerMIPSCompat::testUndefinedSet(Condition cond, const ValueOperand& v ma_cmp_set(dest, value.typeReg(), ImmType(JSVAL_TYPE_UNDEFINED), cond); } -void -MacroAssemblerMIPSCompat::branchTestValue(Condition cond, const ValueOperand& value, - const Value& v, Label* label) -{ - moveData(v, ScratchRegister); - - if (cond == Equal) { - Label done; - ma_b(value.payloadReg(), ScratchRegister, &done, NotEqual, ShortJump); - { - ma_b(value.typeReg(), Imm32(getType(v)), label, Equal); - } - bind(&done); - } else { - MOZ_ASSERT(cond == NotEqual); - ma_b(value.payloadReg(), ScratchRegister, label, NotEqual); - - ma_b(value.typeReg(), Imm32(getType(v)), label, NotEqual); - } -} - -void -MacroAssemblerMIPSCompat::branchTestValue(Condition cond, const Address& valaddr, - const ValueOperand& value, Label* label) -{ - MOZ_ASSERT(cond == Equal || cond == NotEqual); - - // Load tag. - ma_lw(ScratchRegister, Address(valaddr.base, valaddr.offset + TAG_OFFSET)); - asMasm().branchPtr(cond, ScratchRegister, value.typeReg(), label); - - // Load payload - ma_lw(ScratchRegister, Address(valaddr.base, valaddr.offset + PAYLOAD_OFFSET)); - asMasm().branchPtr(cond, ScratchRegister, value.payloadReg(), label); -} - // unboxing code void MacroAssemblerMIPSCompat::unboxNonDouble(const ValueOperand& operand, Register dest) @@ -2192,4 +2156,26 @@ MacroAssembler::branchValueIsNurseryObject(Condition cond, ValueOperand value, bind(&done); } +void +MacroAssembler::branchTestValue(Condition cond, const ValueOperand& lhs, + const Value& rhs, Label* label) +{ + MOZ_ASSERT(cond == Equal || cond == NotEqual); + ScratchRegisterScope scratch(*this); + moveData(rhs, scratch); + + if (cond == Equal) { + Label done; + ma_b(lhs.payloadReg(), scratch, &done, NotEqual, ShortJump); + { + ma_b(lhs.typeReg(), Imm32(getType(rhs)), label, Equal); + } + bind(&done); + } else { + ma_b(lhs.payloadReg(), scratch, label, NotEqual); + + ma_b(lhs.typeReg(), Imm32(getType(rhs)), label, NotEqual); + } +} + //}}} check_macroassembler_style diff --git a/js/src/jit/mips32/MacroAssembler-mips32.h b/js/src/jit/mips32/MacroAssembler-mips32.h index 22cfcdb543f..8cffed1eed0 100644 --- a/js/src/jit/mips32/MacroAssembler-mips32.h +++ b/js/src/jit/mips32/MacroAssembler-mips32.h @@ -309,10 +309,6 @@ class MacroAssemblerMIPSCompat : public MacroAssemblerMIPS return value.typeReg(); } - void branchTestValue(Condition cond, const ValueOperand& value, const Value& v, Label* label); - void branchTestValue(Condition cond, const Address& valaddr, const ValueOperand& value, - Label* label); - // unboxing code void unboxNonDouble(const ValueOperand& operand, Register dest); void unboxNonDouble(const Address& src, Register dest); diff --git a/js/src/jit/mips64/MacroAssembler-mips64.cpp b/js/src/jit/mips64/MacroAssembler-mips64.cpp index ffceef78f50..5ceabf0f0ea 100644 --- a/js/src/jit/mips64/MacroAssembler-mips64.cpp +++ b/js/src/jit/mips64/MacroAssembler-mips64.cpp @@ -1246,24 +1246,6 @@ MacroAssemblerMIPS64Compat::testUndefinedSet(Condition cond, const ValueOperand& ma_cmp_set(dest, SecondScratchReg, ImmTag(JSVAL_TAG_UNDEFINED), cond); } -void -MacroAssemblerMIPS64Compat::branchTestValue(Condition cond, const ValueOperand& value, - const Value& v, Label* label) -{ - MOZ_ASSERT(cond == Equal || cond == NotEqual); - moveValue(v, ScratchRegister); - ma_b(value.valueReg(), ScratchRegister, label, cond); -} - -void -MacroAssemblerMIPS64Compat::branchTestValue(Condition cond, const Address& valaddr, - const ValueOperand& value, Label* label) -{ - MOZ_ASSERT(cond == Equal || cond == NotEqual); - loadPtr(Address(valaddr.base, valaddr.offset), ScratchRegister); - ma_b(value.valueReg(), ScratchRegister, label, cond); -} - // unboxing code void MacroAssemblerMIPS64Compat::unboxNonDouble(const ValueOperand& operand, Register dest) @@ -2338,4 +2320,14 @@ MacroAssembler::branchValueIsNurseryObject(Condition cond, ValueOperand value, SecondScratchReg, Imm32(nursery.nurserySize()), label); } +void +MacroAssembler::branchTestValue(Condition cond, const ValueOperand& lhs, + const Value& rhs, Label* label) +{ + MOZ_ASSERT(cond == Equal || cond == NotEqual); + ScratchRegisterScope scratch(*this); + moveValue(rhs, scratch); + ma_b(lhs.valueReg(), scratch, label, cond); +} + //}}} check_macroassembler_style diff --git a/js/src/jit/mips64/MacroAssembler-mips64.h b/js/src/jit/mips64/MacroAssembler-mips64.h index 9a90a41543c..dcb2be112ac 100644 --- a/js/src/jit/mips64/MacroAssembler-mips64.h +++ b/js/src/jit/mips64/MacroAssembler-mips64.h @@ -337,10 +337,6 @@ class MacroAssemblerMIPS64Compat : public MacroAssemblerMIPS64 return SecondScratchReg; } - void branchTestValue(Condition cond, const ValueOperand& value, const Value& v, Label* label); - void branchTestValue(Condition cond, const Address& valaddr, const ValueOperand& value, - Label* label); - // unboxing code void unboxNonDouble(const ValueOperand& operand, Register dest); void unboxNonDouble(const Address& src, Register dest); diff --git a/js/src/jit/none/MacroAssembler-none.h b/js/src/jit/none/MacroAssembler-none.h index 05126f85ead..b5a402f6874 100644 --- a/js/src/jit/none/MacroAssembler-none.h +++ b/js/src/jit/none/MacroAssembler-none.h @@ -234,7 +234,6 @@ class MacroAssemblerNone : public Assembler CodeOffsetJump jumpWithPatch(RepatchLabel*, Condition, Label* doc = nullptr) { MOZ_CRASH(); } CodeOffsetJump backedgeJump(RepatchLabel* label, Label* doc = nullptr) { MOZ_CRASH(); } - template void branchTestValue(Condition, T, S, Label*) { MOZ_CRASH(); } void testNullSet(Condition, ValueOperand, Register) { MOZ_CRASH(); } void testObjectSet(Condition, ValueOperand, Register) { MOZ_CRASH(); } void testUndefinedSet(Condition, ValueOperand, Register) { MOZ_CRASH(); } diff --git a/js/src/jit/x64/MacroAssembler-x64-inl.h b/js/src/jit/x64/MacroAssembler-x64-inl.h index 9b79936d21e..d0d82d83513 100644 --- a/js/src/jit/x64/MacroAssembler-x64-inl.h +++ b/js/src/jit/x64/MacroAssembler-x64-inl.h @@ -414,14 +414,6 @@ MacroAssemblerX64::incrementInt32Value(const Address& addr) asMasm().addPtr(Imm32(1), addr); } -void -MacroAssemblerX64::branchTestValue(Condition cond, const Address& valaddr, const - ValueOperand& value, Label* label) -{ - MOZ_ASSERT(cond == Equal || cond == NotEqual); - asMasm().branchPtr(cond, valaddr, value.valueReg(), label); -} - template void MacroAssemblerX64::branchPtrImpl(Condition cond, const T& lhs, const S& rhs, Label* label) diff --git a/js/src/jit/x64/MacroAssembler-x64.cpp b/js/src/jit/x64/MacroAssembler-x64.cpp index 0fd81b97592..58bf83243ad 100644 --- a/js/src/jit/x64/MacroAssembler-x64.cpp +++ b/js/src/jit/x64/MacroAssembler-x64.cpp @@ -467,4 +467,16 @@ MacroAssembler::branchValueIsNurseryObject(Condition cond, ValueOperand value, R scratch, Imm32(nursery.nurserySize()), label); } +void +MacroAssembler::branchTestValue(Condition cond, const ValueOperand& lhs, + const Value& rhs, Label* label) +{ + MOZ_ASSERT(cond == Equal || cond == NotEqual); + ScratchRegisterScope scratch(*this); + MOZ_ASSERT(lhs.valueReg() != scratch); + moveValue(rhs, scratch); + cmpPtr(lhs.valueReg(), scratch); + j(cond, label); +} + //}}} check_macroassembler_style diff --git a/js/src/jit/x64/MacroAssembler-x64.h b/js/src/jit/x64/MacroAssembler-x64.h index f269956b5bc..421c3558aee 100644 --- a/js/src/jit/x64/MacroAssembler-x64.h +++ b/js/src/jit/x64/MacroAssembler-x64.h @@ -691,15 +691,6 @@ class MacroAssemblerX64 : public MacroAssemblerX86Shared Condition testError(Condition cond, const ValueOperand& src) { return testMagic(cond, src); } - void branchTestValue(Condition cond, const ValueOperand& value, const Value& v, Label* label) { - ScratchRegisterScope scratch(asMasm()); - MOZ_ASSERT(value.valueReg() != scratch); - moveValue(v, scratch); - cmpPtr(value.valueReg(), scratch); - j(cond, label); - } - inline void branchTestValue(Condition cond, const Address& valaddr, const ValueOperand& value, - Label* label); void testNullSet(Condition cond, const ValueOperand& value, Register dest) { cond = testNull(cond, value); diff --git a/js/src/jit/x86/MacroAssembler-x86-inl.h b/js/src/jit/x86/MacroAssembler-x86-inl.h index 082169722f0..37f90f3f77a 100644 --- a/js/src/jit/x86/MacroAssembler-x86-inl.h +++ b/js/src/jit/x86/MacroAssembler-x86-inl.h @@ -412,23 +412,6 @@ MacroAssemblerX86::convertUInt32ToFloat32(Register src, FloatRegister dest) convertDoubleToFloat32(dest, dest); } -void -MacroAssemblerX86::branchTestValue(Condition cond, const Address& valaddr, const ValueOperand& value, - Label* label) -{ - MOZ_ASSERT(cond == Equal || cond == NotEqual); - // Check payload before tag, since payload is more likely to differ. - if (cond == NotEqual) { - branchPtrImpl(NotEqual, payloadOf(valaddr), value.payloadReg(), label); - branchPtrImpl(NotEqual, tagOf(valaddr), value.typeReg(), label); - } else { - Label fallthrough; - branchPtrImpl(NotEqual, payloadOf(valaddr), value.payloadReg(), &fallthrough); - branchPtrImpl(Equal, tagOf(valaddr), value.typeReg(), label); - bind(&fallthrough); - } -} - template void MacroAssemblerX86::branchPtrImpl(Condition cond, const T& lhs, const S& rhs, Label* label) diff --git a/js/src/jit/x86/MacroAssembler-x86.cpp b/js/src/jit/x86/MacroAssembler-x86.cpp index 5705ec9e748..9bbd83d6ee0 100644 --- a/js/src/jit/x86/MacroAssembler-x86.cpp +++ b/js/src/jit/x86/MacroAssembler-x86.cpp @@ -273,32 +273,6 @@ MacroAssemblerX86::handleFailureWithHandlerTail(void* handler) jmp(Operand(esp, offsetof(ResumeFromException, target))); } -void -MacroAssemblerX86::branchTestValue(Condition cond, const ValueOperand& value, const Value& v, Label* label) -{ - jsval_layout jv = JSVAL_TO_IMPL(v); - if (v.isMarkable()) - cmpPtr(value.payloadReg(), ImmGCPtr(reinterpret_cast(v.toGCThing()))); - else - cmpPtr(value.payloadReg(), ImmWord(jv.s.payload.i32)); - - if (cond == Equal) { - Label done; - j(NotEqual, &done); - { - cmp32(value.typeReg(), Imm32(jv.s.tag)); - j(Equal, label); - } - bind(&done); - } else { - MOZ_ASSERT(cond == NotEqual); - j(NotEqual, label); - - cmp32(value.typeReg(), Imm32(jv.s.tag)); - j(NotEqual, label); - } -} - template void MacroAssemblerX86::storeUnboxedValue(ConstantOrRegister value, MIRType valueType, const T& dest, @@ -501,4 +475,31 @@ MacroAssembler::branchValueIsNurseryObject(Condition cond, ValueOperand value, R bind(&done); } +void +MacroAssembler::branchTestValue(Condition cond, const ValueOperand& lhs, + const Value& rhs, Label* label) +{ + MOZ_ASSERT(cond == Equal || cond == NotEqual); + jsval_layout jv = JSVAL_TO_IMPL(rhs); + if (rhs.isMarkable()) + cmpPtr(lhs.payloadReg(), ImmGCPtr(reinterpret_cast(rhs.toGCThing()))); + else + cmpPtr(lhs.payloadReg(), ImmWord(jv.s.payload.i32)); + + if (cond == Equal) { + Label done; + j(NotEqual, &done); + { + cmp32(lhs.typeReg(), Imm32(jv.s.tag)); + j(Equal, label); + } + bind(&done); + } else { + j(NotEqual, label); + + cmp32(lhs.typeReg(), Imm32(jv.s.tag)); + j(NotEqual, label); + } +} + //}}} check_macroassembler_style diff --git a/js/src/jit/x86/MacroAssembler-x86.h b/js/src/jit/x86/MacroAssembler-x86.h index 7d850d4e415..540a4e017e0 100644 --- a/js/src/jit/x86/MacroAssembler-x86.h +++ b/js/src/jit/x86/MacroAssembler-x86.h @@ -467,12 +467,6 @@ class MacroAssemblerX86 : public MacroAssemblerX86Shared return cond == Equal ? AboveOrEqual : Below; } - - - void branchTestValue(Condition cond, const ValueOperand& value, const Value& v, Label* label); - inline void branchTestValue(Condition cond, const Address& valaddr, const ValueOperand& value, - Label* label); - void testNullSet(Condition cond, const ValueOperand& value, Register dest) { cond = testNull(cond, value); emitSet(cond, dest); From b33ed46a6d8b4fc010f788c694de0a0cfa720891 Mon Sep 17 00:00:00 2001 From: Tooru Fujisawa Date: Thu, 3 Mar 2016 08:03:45 +0900 Subject: [PATCH 137/160] Bug 1245112 - Part 36: Move MacroAssembler::branchPtrImpl into generic macro assembler. r=nbp --- js/src/jit/MacroAssembler.h | 6 +++++- js/src/jit/x64/MacroAssembler-x64-inl.h | 8 -------- js/src/jit/x64/MacroAssembler-x64.h | 3 --- js/src/jit/x86-shared/MacroAssembler-x86-shared-inl.h | 8 ++++++++ js/src/jit/x86/MacroAssembler-x86-inl.h | 8 -------- js/src/jit/x86/MacroAssembler-x86.h | 3 --- 6 files changed, 13 insertions(+), 23 deletions(-) diff --git a/js/src/jit/MacroAssembler.h b/js/src/jit/MacroAssembler.h index 4ec898985e7..044eb10969e 100644 --- a/js/src/jit/MacroAssembler.h +++ b/js/src/jit/MacroAssembler.h @@ -1011,7 +1011,11 @@ class MacroAssembler : public MacroAssemblerSpecific private: - // Implementation for branchTest* methods. + // Implementation for branch* methods. + template + inline void branchPtrImpl(Condition cond, const T& lhs, const S& rhs, Label* label) + DEFINED_ON(x86_shared); + template inline void branchTestUndefinedImpl(Condition cond, const T& t, Label* label) DEFINED_ON(arm, arm64, x86_shared); diff --git a/js/src/jit/x64/MacroAssembler-x64-inl.h b/js/src/jit/x64/MacroAssembler-x64-inl.h index d0d82d83513..db01ce42229 100644 --- a/js/src/jit/x64/MacroAssembler-x64-inl.h +++ b/js/src/jit/x64/MacroAssembler-x64-inl.h @@ -414,14 +414,6 @@ MacroAssemblerX64::incrementInt32Value(const Address& addr) asMasm().addPtr(Imm32(1), addr); } -template -void -MacroAssemblerX64::branchPtrImpl(Condition cond, const T& lhs, const S& rhs, Label* label) -{ - cmpPtr(Operand(lhs), rhs); - j(cond, label); -} - void MacroAssemblerX64::unboxValue(const ValueOperand& src, AnyRegister dest) { diff --git a/js/src/jit/x64/MacroAssembler-x64.h b/js/src/jit/x64/MacroAssembler-x64.h index 421c3558aee..955e2884fcd 100644 --- a/js/src/jit/x64/MacroAssembler-x64.h +++ b/js/src/jit/x64/MacroAssembler-x64.h @@ -523,9 +523,6 @@ class MacroAssemblerX64 : public MacroAssemblerX86Shared // Common interface. ///////////////////////////////////////////////////////////////// - template - inline void branchPtrImpl(Condition cond, const T& lhs, const S& rhs, Label* label); - CodeOffsetJump jumpWithPatch(RepatchLabel* label, Label* documentation = nullptr) { JmpSrc src = jmpSrc(label); return CodeOffsetJump(size(), addPatchableJump(src, Relocation::HARDCODED)); diff --git a/js/src/jit/x86-shared/MacroAssembler-x86-shared-inl.h b/js/src/jit/x86-shared/MacroAssembler-x86-shared-inl.h index d8492e24993..6d56c72096d 100644 --- a/js/src/jit/x86-shared/MacroAssembler-x86-shared-inl.h +++ b/js/src/jit/x86-shared/MacroAssembler-x86-shared-inl.h @@ -295,6 +295,14 @@ MacroAssembler::branchPtr(Condition cond, const Address& lhs, ImmWord rhs, Label branchPtrImpl(cond, lhs, rhs, label); } +template +void +MacroAssembler::branchPtrImpl(Condition cond, const T& lhs, const S& rhs, Label* label) +{ + cmpPtr(Operand(lhs), rhs); + j(cond, label); +} + template CodeOffsetJump MacroAssembler::branchPtrWithPatch(Condition cond, Register lhs, T rhs, RepatchLabel* label) diff --git a/js/src/jit/x86/MacroAssembler-x86-inl.h b/js/src/jit/x86/MacroAssembler-x86-inl.h index 37f90f3f77a..649bffc8cc1 100644 --- a/js/src/jit/x86/MacroAssembler-x86-inl.h +++ b/js/src/jit/x86/MacroAssembler-x86-inl.h @@ -412,14 +412,6 @@ MacroAssemblerX86::convertUInt32ToFloat32(Register src, FloatRegister dest) convertDoubleToFloat32(dest, dest); } -template -void -MacroAssemblerX86::branchPtrImpl(Condition cond, const T& lhs, const S& rhs, Label* label) -{ - cmpPtr(Operand(lhs), rhs); - j(cond, label); -} - void MacroAssemblerX86::unboxValue(const ValueOperand& src, AnyRegister dest) { diff --git a/js/src/jit/x86/MacroAssembler-x86.h b/js/src/jit/x86/MacroAssembler-x86.h index 540a4e017e0..a4cfad8b173 100644 --- a/js/src/jit/x86/MacroAssembler-x86.h +++ b/js/src/jit/x86/MacroAssembler-x86.h @@ -554,9 +554,6 @@ class MacroAssemblerX86 : public MacroAssemblerX86Shared j(cond, label); } - template - inline void branchPtrImpl(Condition cond, const T& lhs, const S& rhs, Label* label); - CodeOffsetJump jumpWithPatch(RepatchLabel* label, Label* documentation = nullptr) { jump(label); return CodeOffsetJump(size()); From 9d32799a5c8514a25d3fb4bc70ecf83c4067be82 Mon Sep 17 00:00:00 2001 From: Ehsan Akhgari Date: Sat, 27 Feb 2016 14:45:12 -0500 Subject: [PATCH 138/160] Bug 1249542 - Remove the prefs for History API push/pop/replaceState; r=bzbarsky These prefs don't even work properly, and they can break Web content in pretty bad ways for the users who have them set. --- dom/base/nsGlobalWindow.cpp | 7 ------- dom/base/nsHistory.cpp | 11 ----------- modules/libpref/init/all.js | 3 --- 3 files changed, 21 deletions(-) diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp index 3a3049bfe34..21cafa56c82 100644 --- a/dom/base/nsGlobalWindow.cpp +++ b/dom/base/nsGlobalWindow.cpp @@ -457,8 +457,6 @@ nsGlobalWindow::DOMMinTimeoutValue() const { // CIDs static NS_DEFINE_CID(kXULControllersCID, NS_XULCONTROLLERS_CID); -static const char sPopStatePrefStr[] = "browser.history.allowPopState"; - #define NETWORK_UPLOAD_EVENT_NAME NS_LITERAL_STRING("moznetworkupload") #define NETWORK_DOWNLOAD_EVENT_NAME NS_LITERAL_STRING("moznetworkdownload") @@ -9917,11 +9915,6 @@ nsGlobalWindow::DispatchSyncPopState() NS_ASSERTION(nsContentUtils::IsSafeToRunScript(), "Must be safe to run script here."); - // Check that PopState hasn't been pref'ed off. - if (!Preferences::GetBool(sPopStatePrefStr, false)) { - return NS_OK; - } - nsresult rv = NS_OK; // Bail if the window is frozen. diff --git a/dom/base/nsHistory.cpp b/dom/base/nsHistory.cpp index a320743429d..3459df4b0cc 100644 --- a/dom/base/nsHistory.cpp +++ b/dom/base/nsHistory.cpp @@ -25,11 +25,6 @@ using namespace mozilla; using namespace mozilla::dom; -static const char* sAllowPushStatePrefStr = - "browser.history.allowPushState"; -static const char* sAllowReplaceStatePrefStr = - "browser.history.allowReplaceState"; - // // History class implementation // @@ -304,12 +299,6 @@ nsHistory::PushOrReplaceState(JSContext* aCx, JS::Handle aData, return; } - // Check that PushState hasn't been pref'ed off. - if (!Preferences::GetBool(aReplace ? sAllowReplaceStatePrefStr : - sAllowPushStatePrefStr, false)) { - return; - } - // AddState might run scripts, so we need to hold a strong reference to the // docShell here to keep it from going away. nsCOMPtr docShell = win->GetDocShell(); diff --git a/modules/libpref/init/all.js b/modules/libpref/init/all.js index 391c79b5977..b765cb10dbc 100644 --- a/modules/libpref/init/all.js +++ b/modules/libpref/init/all.js @@ -4486,9 +4486,6 @@ pref("html5.flushtimer.initialdelay", 120); pref("html5.flushtimer.subsequentdelay", 120); // Push/Pop/Replace State prefs -pref("browser.history.allowPushState", true); -pref("browser.history.allowReplaceState", true); -pref("browser.history.allowPopState", true); pref("browser.history.maxStateObjectSize", 655360); pref("browser.meta_refresh_when_inactive.disabled", false); From 62b4feccb45692e59ad26227ad4297013b8a0c7c Mon Sep 17 00:00:00 2001 From: Bobby Holley Date: Wed, 2 Mar 2016 15:01:01 -0800 Subject: [PATCH 139/160] Bug 1253078 - Switch MOZ_STYLO environmental variable to MOZ_DISABLE_STYLO. r=dholbert --- layout/base/nsPresContext.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/layout/base/nsPresContext.h b/layout/base/nsPresContext.h index 318459418fe..f103f6b54c1 100644 --- a/layout/base/nsPresContext.h +++ b/layout/base/nsPresContext.h @@ -1087,9 +1087,13 @@ public: static bool StyloEnabled() { + // Stylo (the Servo backend for Gecko's style system) is generally enabled + // or disabled at compile-time. However, we provide the additional capability + // to disable it dynamically in stylo-enabled builds via an environmental + // variable. #ifdef MOZ_STYLO - static bool enabled = PR_GetEnv("MOZ_STYLO"); - return enabled; + static bool disabled = PR_GetEnv("MOZ_DISABLE_STYLO"); + return !disabled; #else return false; #endif From 52c146dfc2cf8a7b3d083a00826331aa02c0d9b6 Mon Sep 17 00:00:00 2001 From: Ehsan Akhgari Date: Thu, 25 Feb 2016 18:12:20 -0500 Subject: [PATCH 140/160] Bug 1251448 - Add support for RequestInit.referrer; r=jdm --- dom/bindings/Errors.msg | 1 + dom/fetch/Request.cpp | 147 ++++++++++++++++-- dom/webidl/Request.webidl | 1 + .../policies/referrer-origin-worker.html.ini | 4 +- .../api/policies/referrer-origin.html.ini | 5 - .../fetch/api/request/request-error.html.ini | 6 - .../api/request/request-init-001.sub.html.ini | 12 -- 7 files changed, 141 insertions(+), 35 deletions(-) delete mode 100644 testing/web-platform/meta/fetch/api/policies/referrer-origin.html.ini diff --git a/dom/bindings/Errors.msg b/dom/bindings/Errors.msg index 54da8ba66d1..8e4c3f953c9 100644 --- a/dom/bindings/Errors.msg +++ b/dom/bindings/Errors.msg @@ -61,6 +61,7 @@ MSG_DEF(MSG_PERMISSION_DENIED_TO_PASS_ARG, 1, JSEXN_TYPEERR, "Permission denied MSG_DEF(MSG_MISSING_REQUIRED_DICTIONARY_MEMBER, 1, JSEXN_TYPEERR, "Missing required {0}.") MSG_DEF(MSG_INVALID_REQUEST_METHOD, 1, JSEXN_TYPEERR, "Invalid request method {0}.") MSG_DEF(MSG_INVALID_REQUEST_MODE, 1, JSEXN_TYPEERR, "Invalid request mode {0}.") +MSG_DEF(MSG_INVALID_REFERRER_URL, 1, JSEXN_TYPEERR, "Invalid referrer URL {0}.") MSG_DEF(MSG_FETCH_BODY_CONSUMED_ERROR, 0, JSEXN_TYPEERR, "Body has already been consumed.") MSG_DEF(MSG_RESPONSE_INVALID_STATUSTEXT_ERROR, 0, JSEXN_TYPEERR, "Response statusText may not contain newline or carriage return.") MSG_DEF(MSG_FETCH_FAILED, 0, JSEXN_TYPEERR, "NetworkError when attempting to fetch resource.") diff --git a/dom/fetch/Request.cpp b/dom/fetch/Request.cpp index df842770324..41e15ffa155 100644 --- a/dom/fetch/Request.cpp +++ b/dom/fetch/Request.cpp @@ -91,9 +91,9 @@ Request::GetInternalRequest() } namespace { -void -GetRequestURLFromDocument(nsIDocument* aDocument, const nsAString& aInput, - nsAString& aRequestURL, ErrorResult& aRv) +already_AddRefed +ParseURLFromDocument(nsIDocument* aDocument, const nsAString& aInput, + ErrorResult& aRv) { MOZ_ASSERT(aDocument); MOZ_ASSERT(NS_IsMainThread()); @@ -103,6 +103,16 @@ GetRequestURLFromDocument(nsIDocument* aDocument, const nsAString& aInput, aRv = NS_NewURI(getter_AddRefs(resolvedURI), aInput, nullptr, baseURI); if (NS_WARN_IF(aRv.Failed())) { aRv.ThrowTypeError(aInput); + } + return resolvedURI.forget(); +} + +void +GetRequestURLFromDocument(nsIDocument* aDocument, const nsAString& aInput, + nsAString& aRequestURL, ErrorResult& aRv) +{ + nsCOMPtr resolvedURI = ParseURLFromDocument(aDocument, aInput, aRv); + if (aRv.Failed()) { return; } @@ -132,9 +142,8 @@ GetRequestURLFromDocument(nsIDocument* aDocument, const nsAString& aInput, CopyUTF8toUTF16(spec, aRequestURL); } -void -GetRequestURLFromChrome(const nsAString& aInput, nsAString& aRequestURL, - ErrorResult& aRv) +already_AddRefed +ParseURLFromChrome(const nsAString& aInput, ErrorResult& aRv) { MOZ_ASSERT(NS_IsMainThread()); @@ -142,6 +151,16 @@ GetRequestURLFromChrome(const nsAString& aInput, nsAString& aRequestURL, aRv = NS_NewURI(getter_AddRefs(uri), aInput, nullptr, nullptr); if (NS_WARN_IF(aRv.Failed())) { aRv.ThrowTypeError(aInput); + } + return uri.forget(); +} + +void +GetRequestURLFromChrome(const nsAString& aInput, nsAString& aRequestURL, + ErrorResult& aRv) +{ + nsCOMPtr uri = ParseURLFromChrome(aInput, aRv); + if (aRv.Failed()) { return; } @@ -171,9 +190,9 @@ GetRequestURLFromChrome(const nsAString& aInput, nsAString& aRequestURL, CopyUTF8toUTF16(spec, aRequestURL); } -void -GetRequestURLFromWorker(const GlobalObject& aGlobal, const nsAString& aInput, - nsAString& aRequestURL, ErrorResult& aRv) +already_AddRefed +ParseURLFromWorker(const GlobalObject& aGlobal, const nsAString& aInput, + ErrorResult& aRv) { workers::WorkerPrivate* worker = workers::GetCurrentThreadWorkerPrivate(); MOZ_ASSERT(worker); @@ -184,6 +203,16 @@ GetRequestURLFromWorker(const GlobalObject& aGlobal, const nsAString& aInput, workers::URL::Constructor(aGlobal, aInput, baseURL, aRv); if (NS_WARN_IF(aRv.Failed())) { aRv.ThrowTypeError(aInput); + } + return url.forget(); +} + +void +GetRequestURLFromWorker(const GlobalObject& aGlobal, const nsAString& aInput, + nsAString& aRequestURL, ErrorResult& aRv) +{ + RefPtr url = ParseURLFromWorker(aGlobal, aInput, aRv); + if (aRv.Failed()) { return; } @@ -215,6 +244,38 @@ GetRequestURLFromWorker(const GlobalObject& aGlobal, const nsAString& aInput, } } +class ReferrerSameOriginChecker final : public workers::WorkerMainThreadRunnable +{ +public: + ReferrerSameOriginChecker(workers::WorkerPrivate* aWorkerPrivate, + const nsAString& aReferrerURL, + nsresult& aResult) + : workers::WorkerMainThreadRunnable(aWorkerPrivate), + mReferrerURL(aReferrerURL), + mResult(aResult) + { + mWorkerPrivate->AssertIsOnWorkerThread(); + } + + bool + MainThreadRun() override + { + nsCOMPtr uri; + if (NS_SUCCEEDED(NS_NewURI(getter_AddRefs(uri), mReferrerURL))) { + nsCOMPtr principal = mWorkerPrivate->GetPrincipal(); + if (principal) { + mResult = principal->CheckMayLoad(uri, /* report */ false, + /* allowIfInheritsPrincipal */ false); + } + } + return true; + } + +private: + const nsString mReferrerURL; + nsresult& mResult; +}; + } // namespace /*static*/ already_AddRefed @@ -290,6 +351,74 @@ Request::Constructor(const GlobalObject& aGlobal, return nullptr; } + if (aInit.IsAnyMemberPresent()) { + request->SetReferrer(NS_LITERAL_STRING(kFETCH_CLIENT_REFERRER_STR)); + } + if (aInit.mReferrer.WasPassed()) { + const nsString& referrer = aInit.mReferrer.Value(); + if (referrer.IsEmpty()) { + request->SetReferrer(NS_LITERAL_STRING("")); + } else { + nsAutoString referrerURL; + if (NS_IsMainThread()) { + nsIDocument* doc = GetEntryDocument(); + nsCOMPtr uri; + if (doc) { + uri = ParseURLFromDocument(doc, referrer, aRv); + } else { + // If we don't have a document, we must assume that this is a full URL. + uri = ParseURLFromChrome(referrer, aRv); + } + if (NS_WARN_IF(aRv.Failed())) { + aRv.ThrowTypeError(referrer); + return nullptr; + } + nsAutoCString spec; + uri->GetSpec(spec); + CopyUTF8toUTF16(spec, referrerURL); + if (!referrerURL.EqualsLiteral(kFETCH_CLIENT_REFERRER_STR)) { + nsCOMPtr principal = global->PrincipalOrNull(); + if (principal) { + nsresult rv = principal->CheckMayLoad(uri, /* report */ false, + /* allowIfInheritsPrincipal */ false); + if (NS_FAILED(rv)) { + aRv.ThrowTypeError(referrer); + return nullptr; + } + } + } + } else { + RefPtr url = ParseURLFromWorker(aGlobal, referrer, aRv); + if (NS_WARN_IF(aRv.Failed())) { + aRv.ThrowTypeError(referrer); + return nullptr; + } + url->Stringify(referrerURL, aRv); + if (NS_WARN_IF(aRv.Failed())) { + aRv.ThrowTypeError(referrer); + return nullptr; + } + if (!referrerURL.EqualsLiteral(kFETCH_CLIENT_REFERRER_STR)) { + workers::WorkerPrivate* worker = workers::GetCurrentThreadWorkerPrivate(); + nsresult rv = NS_OK; + // ReferrerSameOriginChecker uses a sync loop to get the main thread + // to perform the same-origin check. Overall, on Workers this method + // can create 3 sync loops (two for constructing URLs and one here) so + // in the future we may want to optimize it all by off-loading all of + // this work in a single sync loop. + RefPtr checker = + new ReferrerSameOriginChecker(worker, referrerURL, rv); + checker->Dispatch(aRv); + if (aRv.Failed() || NS_FAILED(rv)) { + aRv.ThrowTypeError(referrer); + return nullptr; + } + } + } + request->SetReferrer(referrerURL); + } + } + if (mode != RequestMode::EndGuard_) { request->ClearCreatedByFetchEvent(); request->SetMode(mode); diff --git a/dom/webidl/Request.webidl b/dom/webidl/Request.webidl index 3265f22649e..8485e6466bd 100644 --- a/dom/webidl/Request.webidl +++ b/dom/webidl/Request.webidl @@ -39,6 +39,7 @@ dictionary RequestInit { ByteString method; HeadersInit headers; BodyInit? body; + USVString referrer; RequestMode mode; RequestCredentials credentials; RequestCache cache; diff --git a/testing/web-platform/meta/fetch/api/policies/referrer-origin-worker.html.ini b/testing/web-platform/meta/fetch/api/policies/referrer-origin-worker.html.ini index c73b106ce69..3265e37b9c0 100644 --- a/testing/web-platform/meta/fetch/api/policies/referrer-origin-worker.html.ini +++ b/testing/web-platform/meta/fetch/api/policies/referrer-origin-worker.html.ini @@ -2,7 +2,5 @@ type: testharness [Request's referrer is origin] expected: FAIL - - [Throw a TypeError referrer is not same-origin with origin] - expected: FAIL + bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1251378 diff --git a/testing/web-platform/meta/fetch/api/policies/referrer-origin.html.ini b/testing/web-platform/meta/fetch/api/policies/referrer-origin.html.ini deleted file mode 100644 index 8cacdaf63a1..00000000000 --- a/testing/web-platform/meta/fetch/api/policies/referrer-origin.html.ini +++ /dev/null @@ -1,5 +0,0 @@ -[referrer-origin.html] - type: testharness - [Throw a TypeError referrer is not same-origin with origin] - expected: FAIL - diff --git a/testing/web-platform/meta/fetch/api/request/request-error.html.ini b/testing/web-platform/meta/fetch/api/request/request-error.html.ini index 7cb6f6c9ab4..dd682ec3284 100644 --- a/testing/web-platform/meta/fetch/api/request/request-error.html.ini +++ b/testing/web-platform/meta/fetch/api/request/request-error.html.ini @@ -3,12 +3,6 @@ [RequestInit's window is not null] expected: FAIL - [RequestInit's referrer is invalid] - expected: FAIL - - [RequestInit's referrer has invalid origin] - expected: FAIL - [RequestInit's mode is no-cors and integrity is not empty] expected: FAIL diff --git a/testing/web-platform/meta/fetch/api/request/request-init-001.sub.html.ini b/testing/web-platform/meta/fetch/api/request/request-init-001.sub.html.ini index a64059daa19..dff50ae293b 100644 --- a/testing/web-platform/meta/fetch/api/request/request-init-001.sub.html.ini +++ b/testing/web-platform/meta/fetch/api/request/request-init-001.sub.html.ini @@ -1,17 +1,5 @@ [request-init-001.sub.html] type: testharness - [Check referrer init value of /relative/ressource and associated getter] - expected: FAIL - - [Check referrer init value of http://web-platform.test:8000/relative/ressource?query=true#fragment and associated getter] - expected: FAIL - - [Check referrer init value of http://web-platform.test:8000/ and associated getter] - expected: FAIL - - [Check referrer init value of and associated getter] - expected: FAIL - [Check referrerPolicy init value of and associated getter] expected: FAIL From 18356f50419b8607a51fd7a8c6a315a8c4af615a Mon Sep 17 00:00:00 2001 From: Nathan Froyd Date: Wed, 2 Mar 2016 11:43:58 -0500 Subject: [PATCH 141/160] Bug 1252901 - don't use ScopedFreePtrTraits in MediaEngineWrapper.h; r=jesup ScopedFreePtrTraits is somewhat of an internal implementation detail of Scoped.h, and it's not hard to write out the two static functions we need from ScopedFreePtrTraits anyway. Removing this means that we can clear the way for ScopedFreePtr to be removed. --- media/webrtc/signaling/src/common/MediaEngineWrapper.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/media/webrtc/signaling/src/common/MediaEngineWrapper.h b/media/webrtc/signaling/src/common/MediaEngineWrapper.h index a9ccf0cf08e..f9b1a34152f 100755 --- a/media/webrtc/signaling/src/common/MediaEngineWrapper.h +++ b/media/webrtc/signaling/src/common/MediaEngineWrapper.h @@ -19,8 +19,10 @@ namespace mozilla * */ template -struct ScopedCustomReleaseTraits0 : public ScopedFreePtrTraits +struct ScopedCustomReleaseTraits0 { + typedef T* type; + static T* empty() { return nullptr; } static void release(T* ptr) { if(ptr) From 6f1edf36ac8e8d5458773c9a73a2c1b74ea39bfd Mon Sep 17 00:00:00 2001 From: Chris Manchester Date: Wed, 2 Mar 2016 16:25:56 -0800 Subject: [PATCH 142/160] Bug 1253076 - Handle the case defines are not present to avoid artifact build bustage when processing symbols files. r=glandium MozReview-Commit-ID: 25oUlS12hec --- python/mozbuild/mozbuild/frontend/emitter.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/python/mozbuild/mozbuild/frontend/emitter.py b/python/mozbuild/mozbuild/frontend/emitter.py index ced915e7719..1a7e17f46d6 100644 --- a/python/mozbuild/mozbuild/frontend/emitter.py +++ b/python/mozbuild/mozbuild/frontend/emitter.py @@ -570,9 +570,12 @@ class TreeMetadataEmitter(LoggingMixin): script = mozpath.join( mozpath.dirname(mozpath.dirname(__file__)), 'action', 'generate_symbols_file.py') + defines = () + if lib.defines: + defines = lib.defines.get_defines() yield GeneratedFile(context, script, 'generate_symbols_file', lib.symbols_file, - [symbols_file.full_path], lib.defines.get_defines()) + [symbols_file.full_path], defines) if static_lib: lib = StaticLibrary(context, libname, **static_args) self._libs[libname].append(lib) From 2d99104d55be81c809de499b251d9b5a109e91cf Mon Sep 17 00:00:00 2001 From: Bobby Holley Date: Fri, 13 Nov 2015 22:37:58 -0800 Subject: [PATCH 143/160] Bug 1252980 - Link the geckolib into libxul and define MOZ_STYLO if --with-servo=PATH is passed. r=gps --- old-configure.in | 21 +++++++++++++++++++++ toolkit/library/moz.build | 1 + 2 files changed, 22 insertions(+) diff --git a/old-configure.in b/old-configure.in index e8422fd50ee..974796d12bc 100644 --- a/old-configure.in +++ b/old-configure.in @@ -7589,6 +7589,27 @@ if test -n "$DISABLE_MOZ_RIL_GEOLOC"; then fi AC_SUBST(DISABLE_MOZ_RIL_GEOLOC) +dnl ======================================================== +dnl = Use the Servo Style System for Gecko. +dnl = +dnl = This linkage setup is temporary, and for experimental +dnl = purposes. We will vendor servo and integrate the build +dnl = systems before actually shipping anything. +dnl ======================================================== +MOZ_ARG_WITH_STRING(servo, +[ --with-servo=SERVO_TARGET_DIR + Absolute path of the target directory where libgeckoservo can + be found. This is generally servo_src_dir/target/release. + Passing this flag enables experimental integration with the + servo style system], + SERVO_TARGET_DIR=$withval, + SERVO_TARGET_DIR=) +if test -n "$SERVO_TARGET_DIR"; then + MOZ_SERVO_LIBS="-L${SERVO_TARGET_DIR} -lgeckoservo" + AC_DEFINE(MOZ_STYLO) + AC_SUBST_LIST(MOZ_SERVO_LIBS) +fi + dnl ======================================================== dnl = dnl = Misc. Options diff --git a/toolkit/library/moz.build b/toolkit/library/moz.build index 1058679373f..a678f59f03d 100644 --- a/toolkit/library/moz.build +++ b/toolkit/library/moz.build @@ -212,6 +212,7 @@ if CONFIG['OS_ARCH'] == 'Linux' and CONFIG['OS_TARGET'] != 'Android': OS_LIBS += CONFIG['MOZ_CAIRO_OSLIBS'] OS_LIBS += CONFIG['MOZ_WEBRTC_X11_LIBS'] +OS_LIBS += CONFIG['MOZ_SERVO_LIBS'] if CONFIG['MOZ_NATIVE_JPEG']: OS_LIBS += CONFIG['MOZ_JPEG_LIBS'] From e9df04935ab05b8f27ce21009023f160a9a14901 Mon Sep 17 00:00:00 2001 From: Rail Aliiev Date: Wed, 2 Mar 2016 19:50:30 -0500 Subject: [PATCH 144/160] Bug 1252725 - artifacts tasks should be reclaimed to avoid timeouts r=jlund a=testing DONTBUILD --- testing/mozharness/mozharness/mozilla/taskcluster_helper.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/testing/mozharness/mozharness/mozilla/taskcluster_helper.py b/testing/mozharness/mozharness/mozilla/taskcluster_helper.py index d357e74ac73..6192f9ec3d2 100644 --- a/testing/mozharness/mozharness/mozilla/taskcluster_helper.py +++ b/testing/mozharness/mozharness/mozilla/taskcluster_helper.py @@ -116,6 +116,9 @@ class Taskcluster(LogMixin): mime_type = self.get_mime_type(os.path.splitext(filename)[1]) self.info("Create reference artifact: filename=%s mimetype=%s url=%s" % (filename, mime_type, url)) + # reclaim the task to avoid "claim-expired" errors + self.taskcluster_queue.reclaimTask( + task['status']['taskId'], task['status']['runs'][-1]['runId']) self.taskcluster_queue.createArtifact( task['status']['taskId'], task['status']['runs'][-1]['runId'], From 9b9a2131f1170b48632347ad17914fdfb8a17ee2 Mon Sep 17 00:00:00 2001 From: Gregory Szorc Date: Thu, 25 Feb 2016 10:40:31 -0800 Subject: [PATCH 145/160] Bug 1250991 - Indent code; r=mshal This file is so hard to read. Add some indentation to make it easier to grok. I also converted some useless tabs to spaces. MozReview-Commit-ID: 7DFKeW66uD6 --- toolkit/mozapps/installer/upload-files.mk | 420 +++++++++++----------- 1 file changed, 212 insertions(+), 208 deletions(-) diff --git a/toolkit/mozapps/installer/upload-files.mk b/toolkit/mozapps/installer/upload-files.mk index 375bb443e97..fb331d0b22d 100644 --- a/toolkit/mozapps/installer/upload-files.mk +++ b/toolkit/mozapps/installer/upload-files.mk @@ -113,136 +113,140 @@ CREATE_FINAL_TAR = $(TAR) -c --owner=0 --group=0 --numeric-owner \ UNPACK_TAR = tar -xf- ifeq ($(MOZ_PKG_FORMAT),TAR) -PKG_SUFFIX = .tar -INNER_MAKE_PACKAGE = $(CREATE_FINAL_TAR) - $(MOZ_PKG_DIR) > $(PACKAGE) -INNER_UNMAKE_PACKAGE = $(UNPACK_TAR) < $(UNPACKAGE) -MAKE_SDK = $(CREATE_FINAL_TAR) - $(MOZ_APP_NAME)-sdk > '$(SDK)' + PKG_SUFFIX = .tar + INNER_MAKE_PACKAGE = $(CREATE_FINAL_TAR) - $(MOZ_PKG_DIR) > $(PACKAGE) + INNER_UNMAKE_PACKAGE = $(UNPACK_TAR) < $(UNPACKAGE) + MAKE_SDK = $(CREATE_FINAL_TAR) - $(MOZ_APP_NAME)-sdk > '$(SDK)' endif + ifeq ($(MOZ_PKG_FORMAT),TGZ) -PKG_SUFFIX = .tar.gz -INNER_MAKE_PACKAGE = $(CREATE_FINAL_TAR) - $(MOZ_PKG_DIR) | gzip -vf9 > $(PACKAGE) -INNER_UNMAKE_PACKAGE = gunzip -c $(UNPACKAGE) | $(UNPACK_TAR) -MAKE_SDK = $(CREATE_FINAL_TAR) - $(MOZ_APP_NAME)-sdk | gzip -vf9 > '$(SDK)' + PKG_SUFFIX = .tar.gz + INNER_MAKE_PACKAGE = $(CREATE_FINAL_TAR) - $(MOZ_PKG_DIR) | gzip -vf9 > $(PACKAGE) + INNER_UNMAKE_PACKAGE = gunzip -c $(UNPACKAGE) | $(UNPACK_TAR) + MAKE_SDK = $(CREATE_FINAL_TAR) - $(MOZ_APP_NAME)-sdk | gzip -vf9 > '$(SDK)' endif + ifeq ($(MOZ_PKG_FORMAT),BZ2) -PKG_SUFFIX = .tar.bz2 -ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT)) -INNER_MAKE_PACKAGE = $(CREATE_FINAL_TAR) - -C $(STAGEPATH)$(MOZ_PKG_DIR) $(_APPNAME) | bzip2 -vf > $(PACKAGE) -else -INNER_MAKE_PACKAGE = $(CREATE_FINAL_TAR) - $(MOZ_PKG_DIR) | bzip2 -vf > $(PACKAGE) -endif -INNER_UNMAKE_PACKAGE = bunzip2 -c $(UNPACKAGE) | $(UNPACK_TAR) -MAKE_SDK = $(CREATE_FINAL_TAR) - $(MOZ_APP_NAME)-sdk | bzip2 -vf > '$(SDK)' + PKG_SUFFIX = .tar.bz2 + ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT)) + INNER_MAKE_PACKAGE = $(CREATE_FINAL_TAR) - -C $(STAGEPATH)$(MOZ_PKG_DIR) $(_APPNAME) | bzip2 -vf > $(PACKAGE) + else + INNER_MAKE_PACKAGE = $(CREATE_FINAL_TAR) - $(MOZ_PKG_DIR) | bzip2 -vf > $(PACKAGE) + endif + INNER_UNMAKE_PACKAGE = bunzip2 -c $(UNPACKAGE) | $(UNPACK_TAR) + MAKE_SDK = $(CREATE_FINAL_TAR) - $(MOZ_APP_NAME)-sdk | bzip2 -vf > '$(SDK)' endif + ifeq ($(MOZ_PKG_FORMAT),ZIP) -ifdef MOZ_EXTERNAL_SIGNING_FORMAT -# We can't use sha2signcode on zip files -MOZ_EXTERNAL_SIGNING_FORMAT := $(filter-out sha2signcode,$(MOZ_EXTERNAL_SIGNING_FORMAT)) -endif -PKG_SUFFIX = .zip -INNER_MAKE_PACKAGE = $(ZIP) -r9D $(PACKAGE) $(MOZ_PKG_DIR) \ - -x \*/.mkdir.done -INNER_UNMAKE_PACKAGE = $(UNZIP) $(UNPACKAGE) -MAKE_SDK = $(call py_action,zip,'$(SDK)' $(MOZ_APP_NAME)-sdk) + ifdef MOZ_EXTERNAL_SIGNING_FORMAT + # We can't use sha2signcode on zip files + MOZ_EXTERNAL_SIGNING_FORMAT := $(filter-out sha2signcode,$(MOZ_EXTERNAL_SIGNING_FORMAT)) + endif + PKG_SUFFIX = .zip + INNER_MAKE_PACKAGE = $(ZIP) -r9D $(PACKAGE) $(MOZ_PKG_DIR) \ + -x \*/.mkdir.done + INNER_UNMAKE_PACKAGE = $(UNZIP) $(UNPACKAGE) + MAKE_SDK = $(call py_action,zip,'$(SDK)' $(MOZ_APP_NAME)-sdk) endif + ifeq ($(MOZ_PKG_FORMAT),SFX7Z) -PKG_SUFFIX = .exe -INNER_MAKE_PACKAGE = rm -f app.7z && \ - mv $(MOZ_PKG_DIR) core && \ - $(CYGWIN_WRAPPER) 7z a -r -t7z app.7z -mx -m0=BCJ2 -m1=LZMA:d25 \ - -m2=LZMA:d19 -m3=LZMA:d19 -mb0:1 -mb0s1:2 -mb0s2:3 && \ - mv core $(MOZ_PKG_DIR) && \ - cat $(SFX_HEADER) app.7z > $(PACKAGE) && \ - chmod 0755 $(PACKAGE) -INNER_UNMAKE_PACKAGE = $(CYGWIN_WRAPPER) 7z x $(UNPACKAGE) core && \ - mv core $(MOZ_PKG_DIR) + PKG_SUFFIX = .exe + INNER_MAKE_PACKAGE = rm -f app.7z && \ + mv $(MOZ_PKG_DIR) core && \ + $(CYGWIN_WRAPPER) 7z a -r -t7z app.7z -mx -m0=BCJ2 -m1=LZMA:d25 \ + -m2=LZMA:d19 -m3=LZMA:d19 -mb0:1 -mb0s1:2 -mb0s2:3 && \ + mv core $(MOZ_PKG_DIR) && \ + cat $(SFX_HEADER) app.7z > $(PACKAGE) && \ + chmod 0755 $(PACKAGE) + INNER_UNMAKE_PACKAGE = $(CYGWIN_WRAPPER) 7z x $(UNPACKAGE) core && \ + mv core $(MOZ_PKG_DIR) endif #Create an RPM file ifeq ($(MOZ_PKG_FORMAT),RPM) -PKG_SUFFIX = .rpm -MOZ_NUMERIC_APP_VERSION = $(shell echo $(MOZ_PKG_VERSION) | sed 's/[^0-9.].*//' ) -MOZ_RPM_RELEASE = $(shell echo $(MOZ_PKG_VERSION) | sed 's/[0-9.]*//' ) + PKG_SUFFIX = .rpm + MOZ_NUMERIC_APP_VERSION = $(shell echo $(MOZ_PKG_VERSION) | sed 's/[^0-9.].*//' ) + MOZ_RPM_RELEASE = $(shell echo $(MOZ_PKG_VERSION) | sed 's/[0-9.]*//' ) -RPMBUILD_TOPDIR=$(ABS_DIST)/rpmbuild -RPMBUILD_RPMDIR=$(ABS_DIST) -RPMBUILD_SRPMDIR=$(ABS_DIST) -RPMBUILD_SOURCEDIR=$(RPMBUILD_TOPDIR)/SOURCES -RPMBUILD_SPECDIR=$(topsrcdir)/toolkit/mozapps/installer/linux/rpm -RPMBUILD_BUILDDIR=$(ABS_DIST)/.. + RPMBUILD_TOPDIR=$(ABS_DIST)/rpmbuild + RPMBUILD_RPMDIR=$(ABS_DIST) + RPMBUILD_SRPMDIR=$(ABS_DIST) + RPMBUILD_SOURCEDIR=$(RPMBUILD_TOPDIR)/SOURCES + RPMBUILD_SPECDIR=$(topsrcdir)/toolkit/mozapps/installer/linux/rpm + RPMBUILD_BUILDDIR=$(ABS_DIST)/.. -SPEC_FILE = $(RPMBUILD_SPECDIR)/mozilla.spec -RPM_INCIDENTALS=$(topsrcdir)/toolkit/mozapps/installer/linux/rpm + SPEC_FILE = $(RPMBUILD_SPECDIR)/mozilla.spec + RPM_INCIDENTALS=$(topsrcdir)/toolkit/mozapps/installer/linux/rpm -RPM_CMD = \ - echo Creating RPM && \ - $(PYTHON) -m mozbuild.action.preprocessor \ - -DMOZ_APP_NAME=$(MOZ_APP_NAME) \ - -DMOZ_APP_DISPLAYNAME='$(MOZ_APP_DISPLAYNAME)' \ - $(RPM_INCIDENTALS)/mozilla.desktop \ - -o $(RPMBUILD_SOURCEDIR)/$(MOZ_APP_NAME).desktop && \ - rm -rf $(ABS_DIST)/$(TARGET_CPU) && \ - $(RPMBUILD) -bb \ - $(SPEC_FILE) \ - --target $(TARGET_CPU) \ - --buildroot $(RPMBUILD_TOPDIR)/BUILDROOT \ - --define 'moz_app_name $(MOZ_APP_NAME)' \ - --define 'moz_app_displayname $(MOZ_APP_DISPLAYNAME)' \ - --define 'moz_app_version $(MOZ_APP_VERSION)' \ - --define 'moz_numeric_app_version $(MOZ_NUMERIC_APP_VERSION)' \ - --define 'moz_rpm_release $(MOZ_RPM_RELEASE)' \ - --define 'buildid $(BUILDID)' \ - --define 'moz_source_repo $(shell awk '$$2 == "MOZ_SOURCE_REPO" {print $$3}' $(DEPTH)/source-repo.h)' \ - --define 'moz_source_stamp $(shell awk '$$2 == "MOZ_SOURCE_STAMP" {print $$3}' $(DEPTH)/source-repo.h)' \ - --define 'moz_branding_directory $(topsrcdir)/$(MOZ_BRANDING_DIRECTORY)' \ - --define '_topdir $(RPMBUILD_TOPDIR)' \ - --define '_rpmdir $(RPMBUILD_RPMDIR)' \ - --define '_sourcedir $(RPMBUILD_SOURCEDIR)' \ - --define '_specdir $(RPMBUILD_SPECDIR)' \ - --define '_srcrpmdir $(RPMBUILD_SRPMDIR)' \ - --define '_builddir $(RPMBUILD_BUILDDIR)' \ - --define '_prefix $(prefix)' \ - --define '_libdir $(libdir)' \ - --define '_bindir $(bindir)' \ - --define '_datadir $(datadir)' \ - --define '_installdir $(installdir)' + RPM_CMD = \ + echo Creating RPM && \ + $(PYTHON) -m mozbuild.action.preprocessor \ + -DMOZ_APP_NAME=$(MOZ_APP_NAME) \ + -DMOZ_APP_DISPLAYNAME='$(MOZ_APP_DISPLAYNAME)' \ + $(RPM_INCIDENTALS)/mozilla.desktop \ + -o $(RPMBUILD_SOURCEDIR)/$(MOZ_APP_NAME).desktop && \ + rm -rf $(ABS_DIST)/$(TARGET_CPU) && \ + $(RPMBUILD) -bb \ + $(SPEC_FILE) \ + --target $(TARGET_CPU) \ + --buildroot $(RPMBUILD_TOPDIR)/BUILDROOT \ + --define 'moz_app_name $(MOZ_APP_NAME)' \ + --define 'moz_app_displayname $(MOZ_APP_DISPLAYNAME)' \ + --define 'moz_app_version $(MOZ_APP_VERSION)' \ + --define 'moz_numeric_app_version $(MOZ_NUMERIC_APP_VERSION)' \ + --define 'moz_rpm_release $(MOZ_RPM_RELEASE)' \ + --define 'buildid $(BUILDID)' \ + --define 'moz_source_repo $(shell awk '$$2 == "MOZ_SOURCE_REPO" {print $$3}' $(DEPTH)/source-repo.h)' \ + --define 'moz_source_stamp $(shell awk '$$2 == "MOZ_SOURCE_STAMP" {print $$3}' $(DEPTH)/source-repo.h)' \ + --define 'moz_branding_directory $(topsrcdir)/$(MOZ_BRANDING_DIRECTORY)' \ + --define '_topdir $(RPMBUILD_TOPDIR)' \ + --define '_rpmdir $(RPMBUILD_RPMDIR)' \ + --define '_sourcedir $(RPMBUILD_SOURCEDIR)' \ + --define '_specdir $(RPMBUILD_SPECDIR)' \ + --define '_srcrpmdir $(RPMBUILD_SRPMDIR)' \ + --define '_builddir $(RPMBUILD_BUILDDIR)' \ + --define '_prefix $(prefix)' \ + --define '_libdir $(libdir)' \ + --define '_bindir $(bindir)' \ + --define '_datadir $(datadir)' \ + --define '_installdir $(installdir)' -ifdef ENABLE_TESTS -RPM_CMD += \ - --define 'createtests yes' \ - --define '_testsinstalldir $(shell basename $(installdir))' -endif + ifdef ENABLE_TESTS + RPM_CMD += \ + --define 'createtests yes' \ + --define '_testsinstalldir $(shell basename $(installdir))' + endif -ifdef INSTALL_SDK -RPM_CMD += \ - --define 'createdevel yes' \ - --define '_idldir $(idldir)' \ - --define '_sdkdir $(sdkdir)' \ - --define '_includedir $(includedir)' -endif + ifdef INSTALL_SDK + RPM_CMD += \ + --define 'createdevel yes' \ + --define '_idldir $(idldir)' \ + --define '_sdkdir $(sdkdir)' \ + --define '_includedir $(includedir)' + endif -#For each of the main, tests, sdk rpms we want to make sure that -#if they exist that they are in objdir/dist/ and that they get -#uploaded and that they are beside the other build artifacts -MAIN_RPM= $(MOZ_APP_NAME)-$(MOZ_NUMERIC_APP_VERSION)-$(MOZ_RPM_RELEASE).$(BUILDID).$(TARGET_CPU)$(PKG_SUFFIX) -UPLOAD_EXTRA_FILES += $(MAIN_RPM) -RPM_CMD += && mv $(TARGET_CPU)/$(MAIN_RPM) $(ABS_DIST)/ + #For each of the main, tests, sdk rpms we want to make sure that + #if they exist that they are in objdir/dist/ and that they get + #uploaded and that they are beside the other build artifacts + MAIN_RPM= $(MOZ_APP_NAME)-$(MOZ_NUMERIC_APP_VERSION)-$(MOZ_RPM_RELEASE).$(BUILDID).$(TARGET_CPU)$(PKG_SUFFIX) + UPLOAD_EXTRA_FILES += $(MAIN_RPM) + RPM_CMD += && mv $(TARGET_CPU)/$(MAIN_RPM) $(ABS_DIST)/ -ifdef ENABLE_TESTS -TESTS_RPM=$(MOZ_APP_NAME)-tests-$(MOZ_NUMERIC_APP_VERSION)-$(MOZ_RPM_RELEASE).$(BUILDID).$(TARGET_CPU)$(PKG_SUFFIX) -UPLOAD_EXTRA_FILES += $(TESTS_RPM) -RPM_CMD += && mv $(TARGET_CPU)/$(TESTS_RPM) $(ABS_DIST)/ -endif + ifdef ENABLE_TESTS + TESTS_RPM=$(MOZ_APP_NAME)-tests-$(MOZ_NUMERIC_APP_VERSION)-$(MOZ_RPM_RELEASE).$(BUILDID).$(TARGET_CPU)$(PKG_SUFFIX) + UPLOAD_EXTRA_FILES += $(TESTS_RPM) + RPM_CMD += && mv $(TARGET_CPU)/$(TESTS_RPM) $(ABS_DIST)/ + endif -ifdef INSTALL_SDK -SDK_RPM=$(MOZ_APP_NAME)-devel-$(MOZ_NUMERIC_APP_VERSION)-$(MOZ_RPM_RELEASE).$(BUILDID).$(TARGET_CPU)$(PKG_SUFFIX) -UPLOAD_EXTRA_FILES += $(SDK_RPM) -RPM_CMD += && mv $(TARGET_CPU)/$(SDK_RPM) $(ABS_DIST)/ -endif + ifdef INSTALL_SDK + SDK_RPM=$(MOZ_APP_NAME)-devel-$(MOZ_NUMERIC_APP_VERSION)-$(MOZ_RPM_RELEASE).$(BUILDID).$(TARGET_CPU)$(PKG_SUFFIX) + UPLOAD_EXTRA_FILES += $(SDK_RPM) + RPM_CMD += && mv $(TARGET_CPU)/$(SDK_RPM) $(ABS_DIST)/ + endif -INNER_MAKE_PACKAGE = $(RPM_CMD) -#Avoiding rpm repacks, going to try creating/uploading xpi in rpm files instead -INNER_UNMAKE_PACKAGE = $(error Try using rpm2cpio and cpio) + INNER_MAKE_PACKAGE = $(RPM_CMD) + #Avoiding rpm repacks, going to try creating/uploading xpi in rpm files instead + INNER_UNMAKE_PACKAGE = $(error Try using rpm2cpio and cpio) endif #Create an RPM file @@ -539,70 +543,70 @@ INNER_UNMAKE_PACKAGE = \ endif ifeq ($(MOZ_PKG_FORMAT),DMG) -PKG_SUFFIX = .dmg + PKG_SUFFIX = .dmg -_ABS_MOZSRCDIR = $(shell cd $(MOZILLA_DIR) && pwd) -PKG_DMG_SOURCE = $(STAGEPATH)$(MOZ_PKG_DIR) -INNER_MAKE_PACKAGE = $(call py_action,make_dmg,'$(PKG_DMG_SOURCE)' '$(PACKAGE)') -INNER_UNMAKE_PACKAGE = \ - set -ex; \ - rm -rf $(ABS_DIST)/unpack.tmp; \ - mkdir -p $(ABS_DIST)/unpack.tmp; \ - $(_ABS_MOZSRCDIR)/build/package/mac_osx/unpack-diskimage $(UNPACKAGE) /tmp/$(MOZ_PKG_APPNAME)-unpack $(ABS_DIST)/unpack.tmp; \ - rsync -a '$(ABS_DIST)/unpack.tmp/$(_APPNAME)' $(MOZ_PKG_DIR); \ - test -n '$(MOZ_PKG_MAC_DSSTORE)' && \ - rsync -a '$(ABS_DIST)/unpack.tmp/.DS_Store' '$(MOZ_PKG_MAC_DSSTORE)'; \ - test -n '$(MOZ_PKG_MAC_BACKGROUND)' && \ - rsync -a '$(ABS_DIST)/unpack.tmp/.background/$(notdir $(MOZ_PKG_MAC_BACKGROUND))' '$(MOZ_PKG_MAC_BACKGROUND)'; \ - test -n '$(MOZ_PKG_MAC_ICON)' && \ - rsync -a '$(ABS_DIST)/unpack.tmp/.VolumeIcon.icns' '$(MOZ_PKG_MAC_ICON)'; \ - rm -rf $(ABS_DIST)/unpack.tmp; \ - if test -n '$(MOZ_PKG_MAC_RSRC)' ; then \ - cp $(UNPACKAGE) $(MOZ_PKG_APPNAME).tmp.dmg && \ - hdiutil unflatten $(MOZ_PKG_APPNAME).tmp.dmg && \ - { /Developer/Tools/DeRez -skip plst -skip blkx $(MOZ_PKG_APPNAME).tmp.dmg > '$(MOZ_PKG_MAC_RSRC)' || { rm -f $(MOZ_PKG_APPNAME).tmp.dmg && false; }; } && \ - rm -f $(MOZ_PKG_APPNAME).tmp.dmg; \ - fi -# The plst and blkx resources are skipped because they belong to each -# individual dmg and are created by hdiutil. -SDK_SUFFIX = .tar.bz2 -MAKE_SDK = $(CREATE_FINAL_TAR) - $(MOZ_APP_NAME)-sdk | bzip2 -vf > '$(SDK)' + _ABS_MOZSRCDIR = $(shell cd $(MOZILLA_DIR) && pwd) + PKG_DMG_SOURCE = $(STAGEPATH)$(MOZ_PKG_DIR) + INNER_MAKE_PACKAGE = $(call py_action,make_dmg,'$(PKG_DMG_SOURCE)' '$(PACKAGE)') + INNER_UNMAKE_PACKAGE = \ + set -ex; \ + rm -rf $(ABS_DIST)/unpack.tmp; \ + mkdir -p $(ABS_DIST)/unpack.tmp; \ + $(_ABS_MOZSRCDIR)/build/package/mac_osx/unpack-diskimage $(UNPACKAGE) /tmp/$(MOZ_PKG_APPNAME)-unpack $(ABS_DIST)/unpack.tmp; \ + rsync -a '$(ABS_DIST)/unpack.tmp/$(_APPNAME)' $(MOZ_PKG_DIR); \ + test -n '$(MOZ_PKG_MAC_DSSTORE)' && \ + rsync -a '$(ABS_DIST)/unpack.tmp/.DS_Store' '$(MOZ_PKG_MAC_DSSTORE)'; \ + test -n '$(MOZ_PKG_MAC_BACKGROUND)' && \ + rsync -a '$(ABS_DIST)/unpack.tmp/.background/$(notdir $(MOZ_PKG_MAC_BACKGROUND))' '$(MOZ_PKG_MAC_BACKGROUND)'; \ + test -n '$(MOZ_PKG_MAC_ICON)' && \ + rsync -a '$(ABS_DIST)/unpack.tmp/.VolumeIcon.icns' '$(MOZ_PKG_MAC_ICON)'; \ + rm -rf $(ABS_DIST)/unpack.tmp; \ + if test -n '$(MOZ_PKG_MAC_RSRC)' ; then \ + cp $(UNPACKAGE) $(MOZ_PKG_APPNAME).tmp.dmg && \ + hdiutil unflatten $(MOZ_PKG_APPNAME).tmp.dmg && \ + { /Developer/Tools/DeRez -skip plst -skip blkx $(MOZ_PKG_APPNAME).tmp.dmg > '$(MOZ_PKG_MAC_RSRC)' || { rm -f $(MOZ_PKG_APPNAME).tmp.dmg && false; }; } && \ + rm -f $(MOZ_PKG_APPNAME).tmp.dmg; \ + fi + # The plst and blkx resources are skipped because they belong to each + # individual dmg and are created by hdiutil. + SDK_SUFFIX = .tar.bz2 + MAKE_SDK = $(CREATE_FINAL_TAR) - $(MOZ_APP_NAME)-sdk | bzip2 -vf > '$(SDK)' endif ifdef MOZ_INTERNAL_SIGNING_FORMAT -MOZ_SIGN_PREPARED_PACKAGE_CMD=$(MOZ_SIGN_CMD) $(foreach f,$(MOZ_INTERNAL_SIGNING_FORMAT),-f $(f)) $(foreach i,$(SIGN_INCLUDES),-i $(i)) $(foreach x,$(SIGN_EXCLUDES),-x $(x)) -ifeq (WINNT,$(OS_ARCH)) -MOZ_SIGN_PREPARED_PACKAGE_CMD += --nsscmd '$(ABS_DIST)/bin/shlibsign$(BIN_SUFFIX) -v -i' -endif + MOZ_SIGN_PREPARED_PACKAGE_CMD=$(MOZ_SIGN_CMD) $(foreach f,$(MOZ_INTERNAL_SIGNING_FORMAT),-f $(f)) $(foreach i,$(SIGN_INCLUDES),-i $(i)) $(foreach x,$(SIGN_EXCLUDES),-x $(x)) + ifeq (WINNT,$(OS_ARCH)) + MOZ_SIGN_PREPARED_PACKAGE_CMD += --nsscmd '$(ABS_DIST)/bin/shlibsign$(BIN_SUFFIX) -v -i' + endif endif # For final GPG / authenticode signing / dmg signing if required ifdef MOZ_EXTERNAL_SIGNING_FORMAT -MOZ_SIGN_PACKAGE_CMD=$(MOZ_SIGN_CMD) $(foreach f,$(MOZ_EXTERNAL_SIGNING_FORMAT),-f $(f)) + MOZ_SIGN_PACKAGE_CMD=$(MOZ_SIGN_CMD) $(foreach f,$(MOZ_EXTERNAL_SIGNING_FORMAT),-f $(f)) endif ifdef MOZ_SIGN_PREPARED_PACKAGE_CMD -ifeq (Darwin, $(OS_ARCH)) -MAKE_PACKAGE = (cd $(STAGEPATH)$(MOZ_PKG_DIR)$(_RESPATH) && $(CREATE_PRECOMPLETE_CMD)) \ - && cd ./$(PKG_DMG_SOURCE) && $(MOZ_SIGN_PREPARED_PACKAGE_CMD) $(MOZ_MACBUNDLE_NAME) \ - && cd $(PACKAGE_BASE_DIR) && $(INNER_MAKE_PACKAGE) -else -MAKE_PACKAGE = $(MOZ_SIGN_PREPARED_PACKAGE_CMD) $(MOZ_PKG_DIR) \ - && $(or $(call MAKE_SIGN_EME_VOUCHER,$(STAGEPATH)$(MOZ_PKG_DIR)),true) \ - && (cd $(STAGEPATH)$(MOZ_PKG_DIR)$(_RESPATH) && $(CREATE_PRECOMPLETE_CMD)) \ - && $(INNER_MAKE_PACKAGE) -endif #Darwin + ifeq (Darwin, $(OS_ARCH)) + MAKE_PACKAGE = (cd $(STAGEPATH)$(MOZ_PKG_DIR)$(_RESPATH) && $(CREATE_PRECOMPLETE_CMD)) \ + && cd ./$(PKG_DMG_SOURCE) && $(MOZ_SIGN_PREPARED_PACKAGE_CMD) $(MOZ_MACBUNDLE_NAME) \ + && cd $(PACKAGE_BASE_DIR) && $(INNER_MAKE_PACKAGE) + else + MAKE_PACKAGE = $(MOZ_SIGN_PREPARED_PACKAGE_CMD) $(MOZ_PKG_DIR) \ + && $(or $(call MAKE_SIGN_EME_VOUCHER,$(STAGEPATH)$(MOZ_PKG_DIR)),true) \ + && (cd $(STAGEPATH)$(MOZ_PKG_DIR)$(_RESPATH) && $(CREATE_PRECOMPLETE_CMD)) \ + && $(INNER_MAKE_PACKAGE) + endif #Darwin else -MAKE_PACKAGE = (cd $(STAGEPATH)$(MOZ_PKG_DIR)$(_RESPATH) && $(CREATE_PRECOMPLETE_CMD)) && $(INNER_MAKE_PACKAGE) + MAKE_PACKAGE = (cd $(STAGEPATH)$(MOZ_PKG_DIR)$(_RESPATH) && $(CREATE_PRECOMPLETE_CMD)) && $(INNER_MAKE_PACKAGE) endif ifdef MOZ_SIGN_PACKAGE_CMD -MAKE_PACKAGE += && $(MOZ_SIGN_PACKAGE_CMD) '$(PACKAGE)' + MAKE_PACKAGE += && $(MOZ_SIGN_PACKAGE_CMD) '$(PACKAGE)' endif ifdef MOZ_SIGN_CMD -MAKE_SDK += && $(MOZ_SIGN_CMD) -f gpg '$(SDK)' + MAKE_SDK += && $(MOZ_SIGN_CMD) -f gpg '$(SDK)' endif NO_PKG_FILES += \ @@ -643,23 +647,23 @@ NO_PKG_FILES += \ # If a manifest has not been supplied, the following # files should be excluded from the package too ifndef MOZ_PKG_MANIFEST -NO_PKG_FILES += ssltunnel* + NO_PKG_FILES += ssltunnel* endif ifdef MOZ_DMD -NO_PKG_FILES += SmokeDMD + NO_PKG_FILES += SmokeDMD endif DEFINES += -DDLL_PREFIX=$(DLL_PREFIX) -DDLL_SUFFIX=$(DLL_SUFFIX) -DBIN_SUFFIX=$(BIN_SUFFIX) ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT)) -DEFINES += -DDIR_MACOS=Contents/MacOS/ -DDIR_RESOURCES=Contents/Resources/ + DEFINES += -DDIR_MACOS=Contents/MacOS/ -DDIR_RESOURCES=Contents/Resources/ else -DEFINES += -DDIR_MACOS= -DDIR_RESOURCES= + DEFINES += -DDIR_MACOS= -DDIR_RESOURCES= endif ifdef MOZ_FOLD_LIBS -DEFINES += -DMOZ_FOLD_LIBS=1 + DEFINES += -DMOZ_FOLD_LIBS=1 endif GARBAGE += $(DIST)/$(PACKAGE) $(PACKAGE) @@ -675,32 +679,32 @@ PKG_ARG = , '$(pkg)' # from the now deprecated MOZ_PKG_MANIFEST_P when MOZ_PKG_MANIFEST is not # defined. ifndef MOZ_PKG_MANIFEST -ifdef MOZ_PKG_MANIFEST_P -MOZ_PKG_MANIFEST := $(MOZ_PKG_MANIFEST_P) -endif # MOZ_PKG_MANIFEST_P + ifdef MOZ_PKG_MANIFEST_P + MOZ_PKG_MANIFEST := $(MOZ_PKG_MANIFEST_P) + endif # MOZ_PKG_MANIFEST_P endif # MOZ_PKG_MANIFEST # For smooth transition of comm-central ifndef MOZ_PACKAGER_FORMAT -ifeq ($(MOZ_CHROME_FILE_FORMAT),flat) -ifdef MOZ_OMNIJAR -MOZ_PACKAGER_FORMAT := omni -else -MOZ_PACKAGER_FORMAT := flat -endif -endif + ifeq ($(MOZ_CHROME_FILE_FORMAT),flat) + ifdef MOZ_OMNIJAR + MOZ_PACKAGER_FORMAT := omni + else + MOZ_PACKAGER_FORMAT := flat + endif + endif endif ifndef MOZ_PACKAGER_FORMAT -MOZ_PACKAGER_FORMAT = $(error MOZ_PACKAGER_FORMAT is not set) + MOZ_PACKAGER_FORMAT = $(error MOZ_PACKAGER_FORMAT is not set) endif ifneq (android,$(MOZ_WIDGET_TOOLKIT)) -OPTIMIZEJARS = 1 -ifneq (gonk,$(MOZ_WIDGET_TOOLKIT)) -ifdef NIGHTLY_BUILD -DISABLE_JAR_COMPRESSION = 1 -endif -endif + OPTIMIZEJARS = 1 + ifneq (gonk,$(MOZ_WIDGET_TOOLKIT)) + ifdef NIGHTLY_BUILD + DISABLE_JAR_COMPRESSION = 1 + endif + endif endif # A js binary is needed to perform verification of JavaScript minification. @@ -708,13 +712,13 @@ endif # (such as release automation) can provide their own js binary to enable # verification when cross-compiling. ifndef JS_BINARY -ifndef CROSS_COMPILE -JS_BINARY = $(wildcard $(DIST)/bin/js) -endif + ifndef CROSS_COMPILE + JS_BINARY = $(wildcard $(DIST)/bin/js) + endif endif ifeq ($(OS_TARGET), WINNT) -INSTALLER_PACKAGE = $(DIST)/$(PKG_INST_PATH)$(PKG_INST_BASENAME).exe + INSTALLER_PACKAGE = $(DIST)/$(PKG_INST_PATH)$(PKG_INST_BASENAME).exe endif # These are necessary because some of our packages/installers contain spaces @@ -736,13 +740,13 @@ CHECKSUM_FILES = $(CHECKSUM_FILE) # Upload MAR tools only if AB_CD is unset or en_US ifeq (,$(AB_CD:en-US=)) -ifeq (WINNT,$(OS_TARGET)) -UPLOAD_EXTRA_FILES += host/bin/mar.exe -UPLOAD_EXTRA_FILES += host/bin/mbsdiff.exe -else -UPLOAD_EXTRA_FILES += host/bin/mar -UPLOAD_EXTRA_FILES += host/bin/mbsdiff -endif + ifeq (WINNT,$(OS_TARGET)) + UPLOAD_EXTRA_FILES += host/bin/mar.exe + UPLOAD_EXTRA_FILES += host/bin/mbsdiff.exe + else + UPLOAD_EXTRA_FILES += host/bin/mar + UPLOAD_EXTRA_FILES += host/bin/mbsdiff + endif endif UPLOAD_FILES= \ @@ -772,41 +776,41 @@ UPLOAD_FILES= \ $(if $(UPLOAD_EXTRA_FILES), $(foreach f, $(UPLOAD_EXTRA_FILES), $(wildcard $(DIST)/$(f)))) ifdef MOZ_CRASHREPORTER_UPLOAD_FULL_SYMBOLS -UPLOAD_FILES += \ - $(call QUOTED_WILDCARD,$(DIST)/$(PKG_PATH)$(SYMBOL_FULL_ARCHIVE_BASENAME).zip) + UPLOAD_FILES += \ + $(call QUOTED_WILDCARD,$(DIST)/$(PKG_PATH)$(SYMBOL_FULL_ARCHIVE_BASENAME).zip) endif ifdef MOZ_CODE_COVERAGE -UPLOAD_FILES += \ - $(call QUOTED_WILDCARD,$(DIST)/$(PKG_PATH)$(CODE_COVERAGE_ARCHIVE_BASENAME).zip) + UPLOAD_FILES += \ + $(call QUOTED_WILDCARD,$(DIST)/$(PKG_PATH)$(CODE_COVERAGE_ARCHIVE_BASENAME).zip) endif ifdef UNIFY_DIST -UNIFY_ARCH := $(notdir $(patsubst %/,%,$(dir $(UNIFY_DIST)))) -UPLOAD_FILES += \ - $(call QUOTED_WILDCARD,$(UNIFY_DIST)/$(SDK_PATH)$(PKG_BASENAME)-$(UNIFY_ARCH).sdk$(SDK_SUFFIX)) \ - $(call QUOTED_WILDCARD,$(UNIFY_DIST)/$(SDK_PATH)$(PKG_BASENAME)-$(UNIFY_ARCH).sdk$(SDK_SUFFIX).asc) + UNIFY_ARCH := $(notdir $(patsubst %/,%,$(dir $(UNIFY_DIST)))) + UPLOAD_FILES += \ + $(call QUOTED_WILDCARD,$(UNIFY_DIST)/$(SDK_PATH)$(PKG_BASENAME)-$(UNIFY_ARCH).sdk$(SDK_SUFFIX)) \ + $(call QUOTED_WILDCARD,$(UNIFY_DIST)/$(SDK_PATH)$(PKG_BASENAME)-$(UNIFY_ARCH).sdk$(SDK_SUFFIX).asc) endif SIGN_CHECKSUM_CMD= ifdef MOZ_SIGN_CMD -# If we're signing with gpg, we'll have a bunch of extra detached signatures to -# upload. We also want to sign our checksums file -SIGN_CHECKSUM_CMD=$(MOZ_SIGN_CMD) -f gpg $(CHECKSUM_FILE) + # If we're signing with gpg, we'll have a bunch of extra detached signatures to + # upload. We also want to sign our checksums file + SIGN_CHECKSUM_CMD=$(MOZ_SIGN_CMD) -f gpg $(CHECKSUM_FILE) -CHECKSUM_FILES += $(CHECKSUM_FILE).asc -UPLOAD_FILES += $(call QUOTED_WILDCARD,$(DIST)/$(COMPLETE_MAR).asc) -UPLOAD_FILES += $(call QUOTED_WILDCARD,$(wildcard $(DIST)/$(PARTIAL_MAR).asc)) -UPLOAD_FILES += $(call QUOTED_WILDCARD,$(INSTALLER_PACKAGE).asc) -UPLOAD_FILES += $(call QUOTED_WILDCARD,$(DIST)/$(PACKAGE).asc) + CHECKSUM_FILES += $(CHECKSUM_FILE).asc + UPLOAD_FILES += $(call QUOTED_WILDCARD,$(DIST)/$(COMPLETE_MAR).asc) + UPLOAD_FILES += $(call QUOTED_WILDCARD,$(wildcard $(DIST)/$(PARTIAL_MAR).asc)) + UPLOAD_FILES += $(call QUOTED_WILDCARD,$(INSTALLER_PACKAGE).asc) + UPLOAD_FILES += $(call QUOTED_WILDCARD,$(DIST)/$(PACKAGE).asc) endif ifdef MOZ_STUB_INSTALLER -UPLOAD_FILES += $(call QUOTED_WILDCARD,$(DIST)/$(PKG_INST_PATH)$(PKG_STUB_BASENAME).exe) + UPLOAD_FILES += $(call QUOTED_WILDCARD,$(DIST)/$(PKG_INST_PATH)$(PKG_STUB_BASENAME).exe) endif ifndef MOZ_PKG_SRCDIR -MOZ_PKG_SRCDIR = $(topsrcdir) + MOZ_PKG_SRCDIR = $(topsrcdir) endif SRC_TAR_PREFIX = $(MOZ_APP_NAME)-$(MOZ_PKG_VERSION) @@ -819,7 +823,7 @@ SRC_TAR_EXCLUDE_PATHS += \ --exclude='$(MOZILLA_DIR)/Makefile' \ --exclude='$(MOZILLA_DIR)/dist' ifdef MOZ_OBJDIR -SRC_TAR_EXCLUDE_PATHS += --exclude='$(MOZ_OBJDIR)' + SRC_TAR_EXCLUDE_PATHS += --exclude='$(MOZ_OBJDIR)' endif CREATE_SOURCE_TAR = $(TAR) -c --owner=0 --group=0 --numeric-owner \ --mode=go-w $(SRC_TAR_EXCLUDE_PATHS) --transform='s,^\./,$(SRC_TAR_PREFIX)/,' -f @@ -832,9 +836,9 @@ SOURCE_UPLOAD_FILES = $(SOURCE_TAR) HG ?= hg CREATE_HG_BUNDLE_CMD = $(HG) -v -R $(topsrcdir) bundle --base null ifdef HG_BUNDLE_REVISION -CREATE_HG_BUNDLE_CMD += -r $(HG_BUNDLE_REVISION) + CREATE_HG_BUNDLE_CMD += -r $(HG_BUNDLE_REVISION) endif CREATE_HG_BUNDLE_CMD += $(HG_BUNDLE_FILE) ifdef UPLOAD_HG_BUNDLE -SOURCE_UPLOAD_FILES += $(HG_BUNDLE_FILE) + SOURCE_UPLOAD_FILES += $(HG_BUNDLE_FILE) endif From 5429c3569f9847615d348545dfbbf31bd23654e8 Mon Sep 17 00:00:00 2001 From: Michael Kaply Date: Wed, 2 Mar 2016 15:04:38 -0600 Subject: [PATCH 146/160] Bug 782924 - Allow locale specific preferences in distribution.ini; r=mixedpuppy --- browser/components/distribution.js | 57 ++++++++++++++++--- .../components/tests/unit/distribution.ini | 24 +++++++- .../tests/unit/test_distribution.js | 22 ++++++- 3 files changed, 92 insertions(+), 11 deletions(-) diff --git a/browser/components/distribution.js b/browser/components/distribution.js index 19f278f4208..49f100efafb 100644 --- a/browser/components/distribution.js +++ b/browser/components/distribution.js @@ -346,11 +346,47 @@ DistributionCustomizer.prototype = { Cu.reportError(e); } + var usedPreferences = []; + + if (sections["Preferences-" + this._locale]) { + for (let key of enumerate(this._ini.getKeys("Preferences-" + this._locale))) { + try { + let value = this._ini.getString("Preferences-" + this._locale, key); + if (value) { + Preferences.set(key, parseValue(value)); + } + usedPreferences.push(key); + } catch (e) { /* ignore bad prefs and move on */ } + } + } + + if (sections["Preferences-" + this._language]) { + for (let key of enumerate(this._ini.getKeys("Preferences-" + this._language))) { + if (usedPreferences.indexOf(key) > -1) { + continue; + } + try { + let value = this._ini.getString("Preferences-" + this._language, key); + if (value) { + Preferences.set(key, parseValue(value)); + } + usedPreferences.push(key); + } catch (e) { /* ignore bad prefs and move on */ } + } + } + if (sections["Preferences"]) { for (let key of enumerate(this._ini.getKeys("Preferences"))) { + if (usedPreferences.indexOf(key) > -1) { + continue; + } try { - let value = parseValue(this._ini.getString("Preferences", key)); - Preferences.set(key, value); + let value = this._ini.getString("Preferences", key); + if (value) { + value = value.replace(/%LOCALE%/g, this._locale); + value = value.replace(/%LANGUAGE%/g, this._language); + Preferences.set(key, parseValue(value)); + } } catch (e) { /* ignore bad prefs and move on */ } } } @@ -363,8 +399,9 @@ DistributionCustomizer.prototype = { if (sections["LocalizablePreferences-" + this._locale]) { for (let key of enumerate(this._ini.getKeys("LocalizablePreferences-" + this._locale))) { try { - let value = parseValue(this._ini.getString("LocalizablePreferences-" + this._locale, key)); - if (value !== undefined) { + let value = this._ini.getString("LocalizablePreferences-" + this._locale, key); + if (value) { + value = parseValue(value); localizedStr.data = "data:text/plain," + key + "=" + value; defaults._prefBranch.setComplexValue(key, Ci.nsIPrefLocalizedString, localizedStr); } @@ -379,8 +416,9 @@ DistributionCustomizer.prototype = { continue; } try { - let value = parseValue(this._ini.getString("LocalizablePreferences-" + this._language, key)); - if (value !== undefined) { + let value = this._ini.getString("LocalizablePreferences-" + this._language, key); + if (value) { + value = parseValue(value); localizedStr.data = "data:text/plain," + key + "=" + value; defaults._prefBranch.setComplexValue(key, Ci.nsIPrefLocalizedString, localizedStr); } @@ -395,13 +433,14 @@ DistributionCustomizer.prototype = { continue; } try { - let value = parseValue(this._ini.getString("LocalizablePreferences", key)); - if (value !== undefined) { + let value = this._ini.getString("LocalizablePreferences", key); + if (value) { + value = parseValue(value); value = value.replace(/%LOCALE%/g, this._locale); value = value.replace(/%LANGUAGE%/g, this._language); localizedStr.data = "data:text/plain," + key + "=" + value; - defaults._prefBranch.setComplexValue(key, Ci.nsIPrefLocalizedString, localizedStr); } + defaults._prefBranch.setComplexValue(key, Ci.nsIPrefLocalizedString, localizedStr); } catch (e) { /* ignore bad prefs and move on */ } } } diff --git a/browser/components/tests/unit/distribution.ini b/browser/components/tests/unit/distribution.ini index 618fa1ebfa7..d7d29880833 100644 --- a/browser/components/tests/unit/distribution.ini +++ b/browser/components/tests/unit/distribution.ini @@ -13,6 +13,28 @@ distribution.test.string.noquotes=Test String distribution.test.int=777 distribution.test.bool.true=true distribution.test.bool.false=false +distribution.test.empty= + +distribution.test.pref.locale="%LOCALE%" +distribution.test.pref.language.reset="Preference Set" +distribution.test.pref.locale.reset="Preference Set" +distribution.test.pref.locale.set="Preference Set" +distribution.test.pref.language.set="Preference Set" + +[Preferences-en] +distribution.test.pref.language.en="en" +distribution.test.pref.language.reset= +distribution.test.pref.language.set="Language Set" +distribution.test.pref.locale.set="Language Set" + +[Preferences-en-US] +distribution.test.pref.locale.en-US="en-US" +distribution.test.pref.locale.reset= +distribution.test.pref.locale.set="Locale Set" + + +[Preferences-de] +distribution.test.pref.language.de="de" [LocalizablePreferences] distribution.test.locale="%LOCALE%" @@ -33,4 +55,4 @@ distribution.test.locale.reset= distribution.test.locale.set="Locale Set" [LocalizablePreferences-de] -distribution.test.locale.de="de" +distribution.test.language.de="de" diff --git a/browser/components/tests/unit/test_distribution.js b/browser/components/tests/unit/test_distribution.js index efb2e6b2a71..15353a4b44d 100644 --- a/browser/components/tests/unit/test_distribution.js +++ b/browser/components/tests/unit/test_distribution.js @@ -71,10 +71,30 @@ add_task(function* () { Assert.equal(Services.prefs.getIntPref("distribution.test.int"), 777); Assert.equal(Services.prefs.getBoolPref("distribution.test.bool.true"), true); Assert.equal(Services.prefs.getBoolPref("distribution.test.bool.false"), false); + + Assert.throws(() => Services.prefs.getCharPref("distribution.test.empty")); + Assert.throws(() => Services.prefs.getIntPref("distribution.test.empty")); + Assert.throws(() => Services.prefs.getBoolPref("distribution.test.empty")); + + Assert.equal(Services.prefs.getCharPref("distribution.test.pref.locale"), "en-US"); + Assert.equal(Services.prefs.getCharPref("distribution.test.pref.language.en"), "en"); + Assert.equal(Services.prefs.getCharPref("distribution.test.pref.locale.en-US"), "en-US"); + Assert.throws(() => Services.prefs.getCharPref("distribution.test.pref.language.de")); + // This value was never set because of the empty language specific pref + Assert.throws(() => Services.prefs.getCharPref("distribution.test.pref.language.reset")); + // This value was never set because of the empty locale specific pref + Assert.throws(() => Services.prefs.getCharPref("distribution.test.pref.locale.reset")); + // This value was overridden by a locale specific setting + Assert.equal(Services.prefs.getCharPref("distribution.test.pref.locale.set"), "Locale Set"); + // This value was overridden by a language specific setting + Assert.equal(Services.prefs.getCharPref("distribution.test.pref.language.set"), "Language Set"); + // Language should not override locale + Assert.notEqual(Services.prefs.getCharPref("distribution.test.pref.locale.set"), "Language Set"); + Assert.equal(Services.prefs.getComplexValue("distribution.test.locale", Ci.nsIPrefLocalizedString).data, "en-US"); Assert.equal(Services.prefs.getComplexValue("distribution.test.language.en", Ci.nsIPrefLocalizedString).data, "en"); Assert.equal(Services.prefs.getComplexValue("distribution.test.locale.en-US", Ci.nsIPrefLocalizedString).data, "en-US"); - Assert.throws(() => Services.prefs.getComplexValue("distribution.test.locale.de", Ci.nsIPrefLocalizedString)); + Assert.throws(() => Services.prefs.getComplexValue("distribution.test.language.de", Ci.nsIPrefLocalizedString)); // This value was never set because of the empty language specific pref Assert.throws(() => Services.prefs.getComplexValue("distribution.test.language.reset", Ci.nsIPrefLocalizedString)); // This value was never set because of the empty locale specific pref From e89e2e407597ae5322c6a91d66e9146ec2488320 Mon Sep 17 00:00:00 2001 From: Michael Comella Date: Wed, 2 Mar 2016 10:46:49 -0800 Subject: [PATCH 147/160] Bug 1251656 - Add comment explaining why browser.db upgrade case 27 is missing. r=ahunt MozReview-Commit-ID: KOlJ6q5cWUq --- .../base/java/org/mozilla/gecko/db/BrowserDatabaseHelper.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mobile/android/base/java/org/mozilla/gecko/db/BrowserDatabaseHelper.java b/mobile/android/base/java/org/mozilla/gecko/db/BrowserDatabaseHelper.java index 25ec4bade8a..477028729fb 100644 --- a/mobile/android/base/java/org/mozilla/gecko/db/BrowserDatabaseHelper.java +++ b/mobile/android/base/java/org/mozilla/gecko/db/BrowserDatabaseHelper.java @@ -1222,6 +1222,8 @@ public final class BrowserDatabaseHelper extends SQLiteOpenHelper { upgradeDatabaseFrom25to26(db); break; + // case 27 occurs in UrlMetadataTable.onUpgrade + case 28: upgradeDatabaseFrom27to28(db); break; From 79b56fe2d1e475cd01de6dcfd91b72e665fb3147 Mon Sep 17 00:00:00 2001 From: Wes Kocher Date: Wed, 2 Mar 2016 14:42:04 -0800 Subject: [PATCH 148/160] Backed out 2 changesets (bug 946857) for testBrowserDatabaseHelperUpgrades failures Backed out changeset 9e4c8d1ffd3c (bug 946857) Backed out changeset ca822e985ba5 (bug 946857) MozReview-Commit-ID: DkVkUgEX7AJ --- mobile/android/base/AndroidManifest.xml.in | 5 - .../org/mozilla/gecko/db/BrowserContract.java | 61 -- .../gecko/db/BrowserDatabaseHelper.java | 79 +-- .../org/mozilla/gecko/db/LoginsProvider.java | 520 ------------------ .../mozilla/gecko/db/PasswordsProvider.java | 24 - mobile/android/base/moz.build | 1 - .../android/BrowserContractHelpers.java | 1 - .../android/tests/browser/robocop/robocop.ini | 2 - .../gecko/tests/testLoginsProvider.java | 387 ------------- .../gecko/tests/testPasswordProvider.java | 21 - 10 files changed, 1 insertion(+), 1100 deletions(-) delete mode 100644 mobile/android/base/java/org/mozilla/gecko/db/LoginsProvider.java delete mode 100644 mobile/android/tests/browser/robocop/src/org/mozilla/gecko/tests/testLoginsProvider.java diff --git a/mobile/android/base/AndroidManifest.xml.in b/mobile/android/base/AndroidManifest.xml.in index 2e4d2dbf54e..c7df6482b63 100644 --- a/mobile/android/base/AndroidManifest.xml.in +++ b/mobile/android/base/AndroidManifest.xml.in @@ -293,11 +293,6 @@ android:exported="false" android:process="@MANGLED_ANDROID_PACKAGE_NAME@.PasswordsProvider"/> - - LOGIN_PROJECTION_MAP; - private static final HashMap DELETED_LOGIN_PROJECTION_MAP; - private static final HashMap DISABLED_HOSTS_PROJECTION_MAP; - - private static final String DEFAULT_LOGINS_SORT_ORDER = Logins.HOSTNAME + " ASC"; - private static final String DEFAULT_DELETED_LOGINS_SORT_ORDER = DeletedLogins.TIME_DELETED + " ASC"; - private static final String DEFAULT_DISABLED_HOSTS_SORT_ORDER = LoginsDisabledHosts.HOSTNAME + " ASC"; - private static final String WHERE_GUID_IS_NULL = DeletedLogins.GUID + " IS NULL"; - private static final String WHERE_GUID_IS_VALUE = DeletedLogins.GUID + " = ?"; - - protected static final String INDEX_LOGINS_HOSTNAME = "login_hostname_index"; - protected static final String INDEX_LOGINS_HOSTNAME_FORM_SUBMIT_URL = "login_hostname_formSubmitURL_index"; - protected static final String INDEX_LOGINS_HOSTNAME_HTTP_REALM = "login_hostname_httpRealm_index"; - - static { - URI_MATCHER.addURI(BrowserContract.LOGINS_AUTHORITY, "logins", LOGINS); - URI_MATCHER.addURI(BrowserContract.LOGINS_AUTHORITY, "logins/#", LOGINS_ID); - URI_MATCHER.addURI(BrowserContract.LOGINS_AUTHORITY, "deleted-logins", DELETED_LOGINS); - URI_MATCHER.addURI(BrowserContract.LOGINS_AUTHORITY, "deleted-logins/#", DELETED_LOGINS_ID); - URI_MATCHER.addURI(BrowserContract.LOGINS_AUTHORITY, "logins-disabled-hosts", DISABLED_HOSTS); - URI_MATCHER.addURI(BrowserContract.LOGINS_AUTHORITY, "logins-disabled-hosts/hostname/*", DISABLED_HOSTS_HOSTNAME); - - LOGIN_PROJECTION_MAP = new HashMap<>(); - LOGIN_PROJECTION_MAP.put(Logins._ID, Logins._ID); - LOGIN_PROJECTION_MAP.put(Logins.HOSTNAME, Logins.HOSTNAME); - LOGIN_PROJECTION_MAP.put(Logins.HTTP_REALM, Logins.HTTP_REALM); - LOGIN_PROJECTION_MAP.put(Logins.FORM_SUBMIT_URL, Logins.FORM_SUBMIT_URL); - LOGIN_PROJECTION_MAP.put(Logins.USERNAME_FIELD, Logins.USERNAME_FIELD); - LOGIN_PROJECTION_MAP.put(Logins.PASSWORD_FIELD, Logins.PASSWORD_FIELD); - LOGIN_PROJECTION_MAP.put(Logins.ENCRYPTED_USERNAME, Logins.ENCRYPTED_USERNAME); - LOGIN_PROJECTION_MAP.put(Logins.ENCRYPTED_PASSWORD, Logins.ENCRYPTED_PASSWORD); - LOGIN_PROJECTION_MAP.put(Logins.GUID, Logins.GUID); - LOGIN_PROJECTION_MAP.put(Logins.ENC_TYPE, Logins.ENC_TYPE); - LOGIN_PROJECTION_MAP.put(Logins.TIME_CREATED, Logins.TIME_CREATED); - LOGIN_PROJECTION_MAP.put(Logins.TIME_LAST_USED, Logins.TIME_LAST_USED); - LOGIN_PROJECTION_MAP.put(Logins.TIME_PASSWORD_CHANGED, Logins.TIME_PASSWORD_CHANGED); - LOGIN_PROJECTION_MAP.put(Logins.TIMES_USED, Logins.TIMES_USED); - - DELETED_LOGIN_PROJECTION_MAP = new HashMap<>(); - DELETED_LOGIN_PROJECTION_MAP.put(DeletedLogins._ID, DeletedLogins._ID); - DELETED_LOGIN_PROJECTION_MAP.put(DeletedLogins.GUID, DeletedLogins.GUID); - DELETED_LOGIN_PROJECTION_MAP.put(DeletedLogins.TIME_DELETED, DeletedLogins.TIME_DELETED); - - DISABLED_HOSTS_PROJECTION_MAP = new HashMap<>(); - DISABLED_HOSTS_PROJECTION_MAP.put(LoginsDisabledHosts._ID, LoginsDisabledHosts._ID); - DISABLED_HOSTS_PROJECTION_MAP.put(LoginsDisabledHosts.HOSTNAME, LoginsDisabledHosts.HOSTNAME); - } - - private static String projectColumn(String table, String column) { - return table + "." + column; - } - - private static String selectColumn(String table, String column) { - return projectColumn(table, column) + " = ?"; - } - - @Override - protected Uri insertInTransaction(Uri uri, ContentValues values) { - trace("Calling insert in transaction on URI: " + uri); - - final int match = URI_MATCHER.match(uri); - final SQLiteDatabase db = getWritableDatabase(uri); - final long id; - String guid; - - setupDefaultValues(values, uri); - switch (match) { - case LOGINS: - removeDeletedLoginsByGUIDInTransaction(values, db); - // Encrypt sensitive data. - encryptContentValueFields(values); - guid = values.getAsString(Logins.GUID); - debug("Inserting login in database with GUID: " + guid); - id = db.insertOrThrow(TABLE_LOGINS, Logins.GUID, values); - break; - - case DELETED_LOGINS: - guid = values.getAsString(DeletedLogins.GUID); - debug("Inserting deleted-login in database with GUID: " + guid); - id = db.insertOrThrow(TABLE_DELETED_LOGINS, DeletedLogins.GUID, values); - break; - - case DISABLED_HOSTS: - String hostname = values.getAsString(LoginsDisabledHosts.HOSTNAME); - debug("Inserting disabled-host in database with hostname: " + hostname); - id = db.insertOrThrow(TABLE_DISABLED_HOSTS, LoginsDisabledHosts.HOSTNAME, values); - break; - - default: - throw new UnsupportedOperationException("Unknown insert URI " + uri); - } - - debug("Inserted ID in database: " + id); - - if (id >= 0) { - return ContentUris.withAppendedId(uri, id); - } - - return null; - } - - @Override - @SuppressWarnings("fallthrough") - protected int deleteInTransaction(Uri uri, String selection, String[] selectionArgs) { - trace("Calling delete in transaction on URI: " + uri); - - final int match = URI_MATCHER.match(uri); - final String table; - final SQLiteDatabase db = getWritableDatabase(uri); - - beginWrite(db); - switch (match) { - case LOGINS_ID: - trace("Delete on LOGINS_ID: " + uri); - selection = DBUtils.concatenateWhere(selection, selectColumn(TABLE_LOGINS, Logins._ID)); - selectionArgs = DBUtils.appendSelectionArgs(selectionArgs, - new String[]{Long.toString(ContentUris.parseId(uri))}); - // Store the deleted client in deleted-logins table. - final String guid = getLoginGUIDByID(selection, selectionArgs, db); - if (guid == null) { - // No matching logins found for the id. - return 0; - } - boolean isInsertSuccessful = storeDeletedLoginForGUIDInTransaction(guid, db); - if (!isInsertSuccessful) { - // Failed to insert into deleted-logins, return early. - return 0; - } - // fall through - case LOGINS: - trace("Delete on LOGINS: " + uri); - table = TABLE_LOGINS; - break; - - case DELETED_LOGINS_ID: - trace("Delete on DELETED_LOGINS_ID: " + uri); - selection = DBUtils.concatenateWhere(selection, selectColumn(TABLE_DELETED_LOGINS, DeletedLogins._ID)); - selectionArgs = DBUtils.appendSelectionArgs(selectionArgs, - new String[]{Long.toString(ContentUris.parseId(uri))}); - // fall through - case DELETED_LOGINS: - trace("Delete on DELETED_LOGINS_ID: " + uri); - table = TABLE_DELETED_LOGINS; - break; - - case DISABLED_HOSTS_HOSTNAME: - trace("Delete on DISABLED_HOSTS_HOSTNAME: " + uri); - selection = DBUtils.concatenateWhere(selection, selectColumn(TABLE_DISABLED_HOSTS, LoginsDisabledHosts.HOSTNAME)); - selectionArgs = DBUtils.appendSelectionArgs(selectionArgs, - new String[]{uri.getLastPathSegment()}); - // fall through - case DISABLED_HOSTS: - trace("Delete on DISABLED_HOSTS: " + uri); - table = TABLE_DISABLED_HOSTS; - break; - - default: - throw new UnsupportedOperationException("Unknown delete URI " + uri); - } - - debug("Deleting " + table + " for URI: " + uri); - return db.delete(table, selection, selectionArgs); - } - - @Override - @SuppressWarnings("fallthrough") - protected int updateInTransaction(Uri uri, ContentValues values, String selection, String[] selectionArgs) { - trace("Calling update in transaction on URI: " + uri); - - final int match = URI_MATCHER.match(uri); - final SQLiteDatabase db = getWritableDatabase(uri); - final String table; - - beginWrite(db); - switch (match) { - case LOGINS_ID: - trace("Update on LOGINS_ID: " + uri); - selection = DBUtils.concatenateWhere(selection, selectColumn(TABLE_LOGINS, Logins._ID)); - selectionArgs = DBUtils.appendSelectionArgs(selectionArgs, - new String[]{Long.toString(ContentUris.parseId(uri))}); - - case LOGINS: - trace("Update on LOGINS: " + uri); - table = TABLE_LOGINS; - // Encrypt sensitive data. - encryptContentValueFields(values); - break; - - default: - throw new UnsupportedOperationException("Unknown update URI " + uri); - } - - trace("Updating " + table + " on URI: " + uri); - return db.update(table, values, selection, selectionArgs); - - } - - @Override - @SuppressWarnings("fallthrough") - public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) { - trace("Calling query on URI: " + uri); - - final SQLiteDatabase db = getReadableDatabase(uri); - final int match = URI_MATCHER.match(uri); - final String groupBy = null; - final SQLiteQueryBuilder qb = new SQLiteQueryBuilder(); - final String limit = uri.getQueryParameter(BrowserContract.PARAM_LIMIT); - - switch (match) { - case LOGINS_ID: - trace("Query is on LOGINS_ID: " + uri); - selection = DBUtils.concatenateWhere(selection, selectColumn(TABLE_LOGINS, Logins._ID)); - selectionArgs = DBUtils.appendSelectionArgs(selectionArgs, - new String[] { Long.toString(ContentUris.parseId(uri)) }); - - // fall through - case LOGINS: - trace("Query is on LOGINS: " + uri); - if (TextUtils.isEmpty(sortOrder)) { - sortOrder = DEFAULT_LOGINS_SORT_ORDER; - } else { - debug("Using sort order " + sortOrder + "."); - } - - qb.setProjectionMap(LOGIN_PROJECTION_MAP); - qb.setTables(TABLE_LOGINS); - break; - - case DELETED_LOGINS_ID: - trace("Query is on DELETED_LOGINS_ID: " + uri); - selection = DBUtils.concatenateWhere(selection, selectColumn(TABLE_DELETED_LOGINS, DeletedLogins._ID)); - selectionArgs = DBUtils.appendSelectionArgs(selectionArgs, - new String[] { Long.toString(ContentUris.parseId(uri)) }); - - // fall through - case DELETED_LOGINS: - trace("Query is on DELETED_LOGINS: " + uri); - if (TextUtils.isEmpty(sortOrder)) { - sortOrder = DEFAULT_DELETED_LOGINS_SORT_ORDER; - } else { - debug("Using sort order " + sortOrder + "."); - } - - qb.setProjectionMap(DELETED_LOGIN_PROJECTION_MAP); - qb.setTables(TABLE_DELETED_LOGINS); - break; - - case DISABLED_HOSTS_HOSTNAME: - trace("Query is on DISABLED_HOSTS_HOSTNAME: " + uri); - selection = DBUtils.concatenateWhere(selection, selectColumn(TABLE_DISABLED_HOSTS, LoginsDisabledHosts.HOSTNAME)); - selectionArgs = DBUtils.appendSelectionArgs(selectionArgs, - new String[] { uri.getLastPathSegment() }); - - // fall through - case DISABLED_HOSTS: - trace("Query is on DISABLED_HOSTS: " + uri); - if (TextUtils.isEmpty(sortOrder)) { - sortOrder = DEFAULT_DISABLED_HOSTS_SORT_ORDER; - } else { - debug("Using sort order " + sortOrder + "."); - } - - qb.setProjectionMap(DISABLED_HOSTS_PROJECTION_MAP); - qb.setTables(TABLE_DISABLED_HOSTS); - break; - - default: - throw new UnsupportedOperationException("Unknown query URI " + uri); - } - - trace("Running built query."); - Cursor cursor = qb.query(db, projection, selection, selectionArgs, groupBy, null, sortOrder, limit); - // If decryptManyCursorRows does not return the original cursor, it closes it, so there's - // no need to close here. - cursor = decryptManyCursorRows(cursor); - cursor.setNotificationUri(getContext().getContentResolver(), BrowserContract.LOGINS_AUTHORITY_URI); - return cursor; - } - - @Override - public String getType(@NonNull Uri uri) { - final int match = URI_MATCHER.match(uri); - - switch (match) { - case LOGINS: - return Logins.CONTENT_TYPE; - - case LOGINS_ID: - return Logins.CONTENT_ITEM_TYPE; - - case DELETED_LOGINS: - return DeletedLogins.CONTENT_TYPE; - - case DELETED_LOGINS_ID: - return DeletedLogins.CONTENT_ITEM_TYPE; - - case DISABLED_HOSTS: - return LoginsDisabledHosts.CONTENT_TYPE; - - case DISABLED_HOSTS_HOSTNAME: - return LoginsDisabledHosts.CONTENT_ITEM_TYPE; - - default: - throw new UnsupportedOperationException("Unknown type " + uri); - } - } - - /** - * Caller is responsible for invoking this method inside a transaction. - */ - private String getLoginGUIDByID(final String selection, final String[] selectionArgs, final SQLiteDatabase db) { - final Cursor cursor = db.query(Logins.TABLE_LOGINS, new String[]{Logins.GUID}, selection, selectionArgs, null, null, DEFAULT_LOGINS_SORT_ORDER); - try { - if (!cursor.moveToFirst()) { - return null; - } - return cursor.getString(cursor.getColumnIndexOrThrow(Logins.GUID)); - } finally { - cursor.close(); - } - } - - /** - * Caller is responsible for invoking this method inside a transaction. - */ - private boolean storeDeletedLoginForGUIDInTransaction(final String guid, final SQLiteDatabase db) { - if (guid == null) { - return false; - } - final ContentValues values = new ContentValues(); - values.put(DeletedLogins.GUID, guid); - values.put(DeletedLogins.TIME_DELETED, System.currentTimeMillis()); - return db.insert(TABLE_DELETED_LOGINS, DeletedLogins.GUID, values) > 0; - } - - /** - * Caller is responsible for invoking this method inside a transaction. - */ - private void removeDeletedLoginsByGUIDInTransaction(ContentValues values, SQLiteDatabase db) { - if (values.containsKey(Logins.GUID)) { - final String guid = values.getAsString(Logins.GUID); - if (guid == null) { - db.delete(TABLE_DELETED_LOGINS, WHERE_GUID_IS_NULL, null); - } else { - String[] args = new String[]{guid}; - db.delete(TABLE_DELETED_LOGINS, WHERE_GUID_IS_VALUE, args); - } - } - } - - private void setupDefaultValues(ContentValues values, Uri uri) throws IllegalArgumentException { - final int match = URI_MATCHER.match(uri); - final long now = System.currentTimeMillis(); - switch (match) { - case DELETED_LOGINS: - values.put(DeletedLogins.TIME_DELETED, now); - // deleted-logins must contain a guid - if (!values.containsKey(DeletedLogins.GUID)) { - throw new IllegalArgumentException("Must provide GUID for deleted-login"); - } - break; - - case LOGINS: - values.put(Logins.TIME_CREATED, now); - // Generate GUID for new login. Don't override specified GUIDs. - if (!values.containsKey(Logins.GUID)) { - final String guid = Utils.generateGuid(); - values.put(Logins.GUID, guid); - } - // The database happily accepts strings for long values; this just lets us re-use - // the existing helper method. - String nowString = Long.toString(now); - DBUtils.replaceKey(values, null, Logins.HTTP_REALM, null); - DBUtils.replaceKey(values, null, Logins.FORM_SUBMIT_URL, null); - DBUtils.replaceKey(values, null, Logins.ENC_TYPE, "0"); - DBUtils.replaceKey(values, null, Logins.TIME_LAST_USED, nowString); - DBUtils.replaceKey(values, null, Logins.TIME_PASSWORD_CHANGED, nowString); - DBUtils.replaceKey(values, null, Logins.TIMES_USED, "0"); - break; - - case DISABLED_HOSTS: - if (!values.containsKey(LoginsDisabledHosts.HOSTNAME)) { - throw new IllegalArgumentException("Must provide hostname for disabled-host"); - } - break; - - default: - throw new UnsupportedOperationException("Unknown URI in setupDefaultValues " + uri); - } - } - - private void encryptContentValueFields(final ContentValues values) { - if (values.containsKey(Logins.ENCRYPTED_PASSWORD)) { - final String res = encrypt(values.getAsString(Logins.ENCRYPTED_PASSWORD)); - values.put(Logins.ENCRYPTED_PASSWORD, res); - } - - if (values.containsKey(Logins.ENCRYPTED_USERNAME)) { - final String res = encrypt(values.getAsString(Logins.ENCRYPTED_USERNAME)); - values.put(Logins.ENCRYPTED_USERNAME, res); - } - } - - /** - * Replace each password and username encrypted ciphertext with its equivalent decrypted - * plaintext in the given cursor. - *

- * The encryption algorithm used to protect logins is unspecified; and further, a consumer of - * consumers should never have access to encrypted ciphertext. - * - * @param cursor containing at least one of password and username encrypted ciphertexts. - * @return a new {@link Cursor} with password and username decrypted plaintexts. - */ - private Cursor decryptManyCursorRows(final Cursor cursor) { - final int passwordIndex = cursor.getColumnIndex(Logins.ENCRYPTED_PASSWORD); - final int usernameIndex = cursor.getColumnIndex(Logins.ENCRYPTED_USERNAME); - - if (passwordIndex == -1 && usernameIndex == -1) { - return cursor; - } - - // Special case, decrypt the encrypted username or password before returning the cursor. - final MatrixCursor newCursor = new MatrixCursor(cursor.getColumnNames(), cursor.getColumnCount()); - try { - for (cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext()) { - final ContentValues values = new ContentValues(); - DatabaseUtils.cursorRowToContentValues(cursor, values); - - if (passwordIndex > -1) { - String decrypted = decrypt(values.getAsString(Logins.ENCRYPTED_PASSWORD)); - values.put(Logins.ENCRYPTED_PASSWORD, decrypted); - } - - if (usernameIndex > -1) { - String decrypted = decrypt(values.getAsString(Logins.ENCRYPTED_USERNAME)); - values.put(Logins.ENCRYPTED_USERNAME, decrypted); - } - - final MatrixCursor.RowBuilder rowBuilder = newCursor.newRow(); - for (String key : cursor.getColumnNames()) { - rowBuilder.add(values.get(key)); - } - } - } finally { - // Close the old cursor before returning the new one. - cursor.close(); - } - - return newCursor; - } - - private String encrypt(@NonNull String initialValue) { - try { - final Cipher cipher = getCipher(Cipher.ENCRYPT_MODE); - return Base64.encodeToString(cipher.doFinal(initialValue.getBytes("UTF-8")), Base64.URL_SAFE); - } catch (Exception e) { - debug("encryption failed : " + e); - throw new IllegalStateException("Logins encryption failed", e); - } - } - - private String decrypt(@NonNull String initialValue) { - try { - final Cipher cipher = getCipher(Cipher.DECRYPT_MODE); - return new String(cipher.doFinal(Base64.decode(initialValue.getBytes("UTF-8"), Base64.URL_SAFE))); - } catch (Exception e) { - debug("Decryption failed : " + e); - throw new IllegalStateException("Logins decryption failed", e); - } - } - - private Cipher getCipher(int mode) throws UnsupportedEncodingException, GeneralSecurityException { - return new NullCipher(); - } -} diff --git a/mobile/android/base/java/org/mozilla/gecko/db/PasswordsProvider.java b/mobile/android/base/java/org/mozilla/gecko/db/PasswordsProvider.java index c9f3acadae9..590d9322cb9 100644 --- a/mobile/android/base/java/org/mozilla/gecko/db/PasswordsProvider.java +++ b/mobile/android/base/java/org/mozilla/gecko/db/PasswordsProvider.java @@ -13,7 +13,6 @@ import org.mozilla.gecko.GeckoEvent; import org.mozilla.gecko.GeckoMessageReceiver; import org.mozilla.gecko.NSSBridge; import org.mozilla.gecko.db.BrowserContract.DeletedPasswords; -import org.mozilla.gecko.db.BrowserContract.GeckoDisabledHosts; import org.mozilla.gecko.db.BrowserContract.Passwords; import org.mozilla.gecko.mozglue.GeckoLoader; import org.mozilla.gecko.sqlite.MatrixBlobCursor; @@ -31,13 +30,11 @@ import android.util.Log; public class PasswordsProvider extends SQLiteBridgeContentProvider { static final String TABLE_PASSWORDS = "moz_logins"; static final String TABLE_DELETED_PASSWORDS = "moz_deleted_logins"; - static final String TABLE_DISABLED_HOSTS = "moz_disabledHosts"; private static final String TELEMETRY_TAG = "SQLITEBRIDGE_PROVIDER_PASSWORDS"; private static final int PASSWORDS = 100; private static final int DELETED_PASSWORDS = 101; - private static final int DISABLED_HOSTS = 102; static final String DEFAULT_PASSWORDS_SORT_ORDER = Passwords.HOSTNAME + " ASC"; static final String DEFAULT_DELETED_PASSWORDS_SORT_ORDER = DeletedPasswords.TIME_DELETED + " ASC"; @@ -46,7 +43,6 @@ public class PasswordsProvider extends SQLiteBridgeContentProvider { private static final HashMap PASSWORDS_PROJECTION_MAP; private static final HashMap DELETED_PASSWORDS_PROJECTION_MAP; - private static final HashMap DISABLED_HOSTS_PROJECTION_MAP; // this should be kept in sync with the version in toolkit/components/passwordmgr/storage-mozStorage.js private static final int DB_VERSION = 5; @@ -86,11 +82,6 @@ public class PasswordsProvider extends SQLiteBridgeContentProvider { DELETED_PASSWORDS_PROJECTION_MAP.put(DeletedPasswords.ID, DeletedPasswords.ID); DELETED_PASSWORDS_PROJECTION_MAP.put(DeletedPasswords.GUID, DeletedPasswords.GUID); DELETED_PASSWORDS_PROJECTION_MAP.put(DeletedPasswords.TIME_DELETED, DeletedPasswords.TIME_DELETED); - - URI_MATCHER.addURI(BrowserContract.PASSWORDS_AUTHORITY, "disabled-hosts", DISABLED_HOSTS); - - DISABLED_HOSTS_PROJECTION_MAP = new HashMap(); - DISABLED_HOSTS_PROJECTION_MAP.put(GeckoDisabledHosts.HOSTNAME, GeckoDisabledHosts.HOSTNAME); } public PasswordsProvider() { @@ -143,9 +134,6 @@ public class PasswordsProvider extends SQLiteBridgeContentProvider { case DELETED_PASSWORDS: return DeletedPasswords.CONTENT_TYPE; - case DISABLED_HOSTS: - return GeckoDisabledHosts.CONTENT_TYPE; - default: throw new UnsupportedOperationException("Unknown type " + uri); } @@ -161,9 +149,6 @@ public class PasswordsProvider extends SQLiteBridgeContentProvider { case PASSWORDS: return TABLE_PASSWORDS; - case DISABLED_HOSTS: - return TABLE_DISABLED_HOSTS; - default: throw new UnsupportedOperationException("Unknown table " + uri); } @@ -183,9 +168,6 @@ public class PasswordsProvider extends SQLiteBridgeContentProvider { case PASSWORDS: return DEFAULT_PASSWORDS_SORT_ORDER; - case DISABLED_HOSTS: - return null; - default: throw new UnsupportedOperationException("Unknown URI " + uri); } @@ -228,12 +210,6 @@ public class PasswordsProvider extends SQLiteBridgeContentProvider { DBUtils.replaceKey(values, null, Passwords.TIMES_USED, "0"); break; - case DISABLED_HOSTS: - if (!values.containsKey(GeckoDisabledHosts.HOSTNAME)) { - throw new IllegalArgumentException("Must provide a hostname for a disabled host"); - } - break; - default: throw new UnsupportedOperationException("Unknown URI " + uri); } diff --git a/mobile/android/base/moz.build b/mobile/android/base/moz.build index e5352f353ab..02bf4aa8f38 100644 --- a/mobile/android/base/moz.build +++ b/mobile/android/base/moz.build @@ -227,7 +227,6 @@ gbjar.sources += ['java/org/mozilla/gecko/' + x for x in [ 'db/LocalTabsAccessor.java', 'db/LocalUrlAnnotations.java', 'db/LocalURLMetadata.java', - 'db/LoginsProvider.java', 'db/PasswordsProvider.java', 'db/PerProfileDatabaseProvider.java', 'db/PerProfileDatabases.java', diff --git a/mobile/android/services/src/main/java/org/mozilla/gecko/sync/repositories/android/BrowserContractHelpers.java b/mobile/android/services/src/main/java/org/mozilla/gecko/sync/repositories/android/BrowserContractHelpers.java index 016bed01ee3..eaeedf3b275 100644 --- a/mobile/android/services/src/main/java/org/mozilla/gecko/sync/repositories/android/BrowserContractHelpers.java +++ b/mobile/android/services/src/main/java/org/mozilla/gecko/sync/repositories/android/BrowserContractHelpers.java @@ -40,7 +40,6 @@ public class BrowserContractHelpers extends BrowserContract { public static final Uri DELETED_FORM_HISTORY_CONTENT_URI = withSyncAndProfile(DeletedFormHistory.CONTENT_URI); public static final Uri TABS_CONTENT_URI = withSyncAndProfile(Tabs.CONTENT_URI); public static final Uri CLIENTS_CONTENT_URI = withSyncAndProfile(Clients.CONTENT_URI); - public static final Uri LOGINS_CONTENT_URI = withSyncAndProfile(Logins.CONTENT_URI); public static final String[] PasswordColumns = new String[] { Passwords.ID, diff --git a/mobile/android/tests/browser/robocop/robocop.ini b/mobile/android/tests/browser/robocop/robocop.ini index ca679e83862..0ea5186f236 100644 --- a/mobile/android/tests/browser/robocop/robocop.ini +++ b/mobile/android/tests/browser/robocop/robocop.ini @@ -142,5 +142,3 @@ skip-if = android_version == "10" # testStumblerSetting disabled on Android 4.3, bug 1145846 [src/org/mozilla/gecko/tests/testStumblerSetting.java] skip-if = android_version == "10" || android_version == "18" - -[src/org/mozilla/gecko/tests/testLoginsProvider.java] diff --git a/mobile/android/tests/browser/robocop/src/org/mozilla/gecko/tests/testLoginsProvider.java b/mobile/android/tests/browser/robocop/src/org/mozilla/gecko/tests/testLoginsProvider.java deleted file mode 100644 index 10dde28cd47..00000000000 --- a/mobile/android/tests/browser/robocop/src/org/mozilla/gecko/tests/testLoginsProvider.java +++ /dev/null @@ -1,387 +0,0 @@ -/* 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/. */ - -package org.mozilla.gecko.tests; - -import android.content.ContentProvider; -import android.content.ContentUris; -import android.content.ContentValues; -import android.database.Cursor; -import android.database.sqlite.SQLiteDatabase; -import android.net.Uri; - -import org.mozilla.gecko.db.BrowserContract; -import org.mozilla.gecko.db.BrowserContract.DeletedLogins; -import org.mozilla.gecko.db.BrowserContract.Logins; -import org.mozilla.gecko.db.BrowserContract.LoginsDisabledHosts; -import org.mozilla.gecko.db.LoginsProvider; - -import java.util.concurrent.Callable; - -import static org.mozilla.gecko.db.BrowserContract.CommonColumns._ID; -import static org.mozilla.gecko.db.BrowserContract.DeletedLogins.TABLE_DELETED_LOGINS; -import static org.mozilla.gecko.db.BrowserContract.Logins.TABLE_LOGINS; -import static org.mozilla.gecko.db.BrowserContract.LoginsDisabledHosts.TABLE_DISABLED_HOSTS; - -public class testLoginsProvider extends ContentProviderTest { - - private static final String DB_NAME = "browser.db"; - - private final TestCase[] TESTS_TO_RUN = { - new InsertLoginsTest(), - new UpdateLoginsTest(), - new DeleteLoginsTest(), - new InsertDeletedLoginsTest(), - new InsertDeletedLoginsFailureTest(), - new DisabledHostsInsertTest(), - new DisabledHostsInsertFailureTest(), - new InsertLoginsWithDefaultValuesTest(), - new InsertLoginsWithDuplicateGuidFailureTest(), - new DeleteLoginsByNonExistentGuidTest(), - }; - - /** - * Factory function that makes new LoginsProvider instances. - *

- * We want a fresh provider each test, so this should be invoked in - * setUp before each individual test. - */ - private static final Callable sProviderFactory = new Callable() { - @Override - public ContentProvider call() { - return new LoginsProvider(); - } - }; - - @Override - public void setUp() throws Exception { - super.setUp(sProviderFactory, BrowserContract.LOGINS_AUTHORITY, DB_NAME); - for (TestCase test: TESTS_TO_RUN) { - mTests.add(test); - } - } - - public void testLoginProviderTests() throws Exception { - for (Runnable test : mTests) { - final String testName = test.getClass().getSimpleName(); - setTestName(testName); - ensureEmptyDatabase(); - mAsserter.dumpLog("testLoginsProvider: Database empty - Starting " + testName + "."); - test.run(); - } - } - - /** - * Wipe DB. - */ - private void ensureEmptyDatabase() { - getWritableDatabase(Logins.CONTENT_URI).delete(TABLE_LOGINS, null, null); - getWritableDatabase(DeletedLogins.CONTENT_URI).delete(TABLE_DELETED_LOGINS, null, null); - getWritableDatabase(LoginsDisabledHosts.CONTENT_URI).delete(TABLE_DISABLED_HOSTS, null, null); - } - - private SQLiteDatabase getWritableDatabase(Uri uri) { - Uri testUri = appendUriParam(uri, BrowserContract.PARAM_IS_TEST, "1"); - DelegatingTestContentProvider delegateProvider = (DelegatingTestContentProvider) mProvider; - LoginsProvider loginsProvider = (LoginsProvider) delegateProvider.getTargetProvider(); - return loginsProvider.getWritableDatabaseForTesting(testUri); - } - - /** - * LoginsProvider insert logins test. - */ - private class InsertLoginsTest extends TestCase { - @Override - public void test() throws Exception { - ContentValues contentValues = createLogin("http://www.example.com", "http://www.example.com", - "http://www.example.com", "username1", "password1", "username1", "password1", "guid1"); - long id = ContentUris.parseId(mProvider.insert(BrowserContract.Logins.CONTENT_URI, contentValues)); - verifyLoginExists(contentValues, id); - Cursor cursor = mProvider.query(Logins.CONTENT_URI, null, Logins.GUID + " = ?", new String[] { "guid1" }, null); - verifyRowMatches(contentValues, cursor, "logins found"); - - // Empty ("") encrypted username and password are valid. - contentValues = createLogin("http://www.example.com", "http://www.example.com", - "http://www.example.com", "username1", "password1", "", "", "guid2"); - id = ContentUris.parseId(mProvider.insert(BrowserContract.Logins.CONTENT_URI, contentValues)); - verifyLoginExists(contentValues, id); - cursor = mProvider.query(Logins.CONTENT_URI, null, Logins.GUID + " = ?", new String[] { "guid2" }, null); - verifyRowMatches(contentValues, cursor, "logins found"); - } - } - - /** - * LoginsProvider updates logins test. - */ - private class UpdateLoginsTest extends TestCase { - @Override - public void test() throws Exception { - final String guid1 = "guid1"; - ContentValues contentValues = createLogin("http://www.example.com", "http://www.example.com", - "http://www.example.com", "username1", "password1", "username1", "password1", guid1); - long timeBeforeCreated = System.currentTimeMillis(); - long id = ContentUris.parseId(mProvider.insert(BrowserContract.Logins.CONTENT_URI, contentValues)); - long timeAfterCreated = System.currentTimeMillis(); - verifyLoginExists(contentValues, id); - - Cursor cursor = getLoginById(id); - try { - mAsserter.ok(cursor.moveToFirst(), "cursor is not empty", ""); - verifyBounded(timeBeforeCreated, cursor.getLong(cursor.getColumnIndexOrThrow(Logins.TIME_CREATED)), timeAfterCreated); - } finally { - cursor.close(); - } - - contentValues.put(BrowserContract.Logins.ENCRYPTED_USERNAME, "username2"); - contentValues.put(Logins.ENCRYPTED_PASSWORD, "password2"); - - Uri updateUri = Logins.CONTENT_URI.buildUpon().appendPath(String.valueOf(id)).build(); - int numUpdated = mProvider.update(updateUri, contentValues, null, null); - mAsserter.is(1, numUpdated, "Correct number updated"); - verifyLoginExists(contentValues, id); - - contentValues.put(BrowserContract.Logins.ENCRYPTED_USERNAME, "username1"); - contentValues.put(Logins.ENCRYPTED_PASSWORD, "password1"); - - updateUri = Logins.CONTENT_URI; - numUpdated = mProvider.update(updateUri, contentValues, Logins.GUID + " = ?", new String[]{guid1}); - mAsserter.is(1, numUpdated, "Correct number updated"); - verifyLoginExists(contentValues, id); - } - } - - /** - * LoginsProvider deletion logins test. - * - inserts a new logins - * - deletes the logins and verify deleted-logins table has entry for deleted guid. - */ - private class DeleteLoginsTest extends TestCase { - @Override - public void test() throws Exception { - final String guid1 = "guid1"; - ContentValues contentValues = createLogin("http://www.example.com", "http://www.example.com", - "http://www.example.com", "username1", "password1", "username1", "password1", guid1); - long id = ContentUris.parseId(mProvider.insert(Logins.CONTENT_URI, contentValues)); - verifyLoginExists(contentValues, id); - - Uri deletedUri = Logins.CONTENT_URI.buildUpon().appendPath(String.valueOf(id)).build(); - int numDeleted = mProvider.delete(deletedUri, null, null); - mAsserter.is(1, numDeleted, "Correct number deleted"); - verifyNoRowExists(Logins.CONTENT_URI, "No login entry found"); - - contentValues = new ContentValues(); - contentValues.put(DeletedLogins.GUID, guid1); - Cursor cursor = mProvider.query(DeletedLogins.CONTENT_URI, null, null, null, null); - verifyRowMatches(contentValues, cursor, "deleted-login found"); - cursor = mProvider.query(DeletedLogins.CONTENT_URI, null, DeletedLogins.GUID + " = ?", new String[] { guid1 }, null); - verifyRowMatches(contentValues, cursor, "deleted-login found"); - } - } - - /** - * LoginsProvider re-insert logins test. - * - inserts a row into deleted-logins - * - insert the same login (matching guid) and verify deleted-logins table is empty. - */ - private class InsertDeletedLoginsTest extends TestCase { - @Override - public void test() throws Exception { - ContentValues contentValues = new ContentValues(); - contentValues.put(DeletedLogins.GUID, "guid1"); - long id = ContentUris.parseId(mProvider.insert(DeletedLogins.CONTENT_URI, contentValues)); - final Uri insertedUri = DeletedLogins.CONTENT_URI.buildUpon().appendPath(String.valueOf(id)).build(); - Cursor cursor = mProvider.query(insertedUri, null, null, null, null); - verifyRowMatches(contentValues, cursor, "deleted-login found"); - verifyNoRowExists(BrowserContract.Logins.CONTENT_URI, "No login entry found"); - - contentValues = createLogin("http://www.example.com", "http://www.example.com", - "http://www.example.com", "username1", "password1", "username1", "password1", "guid1"); - id = ContentUris.parseId(mProvider.insert(Logins.CONTENT_URI, contentValues)); - verifyLoginExists(contentValues, id); - verifyNoRowExists(DeletedLogins.CONTENT_URI, "No deleted-login entry found"); - } - } - - /** - * LoginsProvider insert Deleted logins test. - * - inserts a row into deleted-login without GUID. - */ - private class InsertDeletedLoginsFailureTest extends TestCase { - @Override - public void test() throws Exception { - ContentValues contentValues = new ContentValues(); - try { - mProvider.insert(DeletedLogins.CONTENT_URI, contentValues); - fail("Failed to throw IllegalArgumentException while missing GUID"); - } catch (Exception e) { - mAsserter.is(e.getClass(), IllegalArgumentException.class, "IllegalArgumentException thrown for invalid GUID"); - } - } - } - - /** - * LoginsProvider disabled host test. - * - inserts a disabled-host - * - delete the inserted disabled-host and verify disabled-hosts table is empty. - */ - private class DisabledHostsInsertTest extends TestCase { - @Override - public void test() throws Exception { - final String hostname = "localhost"; - final ContentValues contentValues = new ContentValues(); - contentValues.put(LoginsDisabledHosts.HOSTNAME, hostname); - mProvider.insert(LoginsDisabledHosts.CONTENT_URI, contentValues); - final Uri insertedUri = LoginsDisabledHosts.CONTENT_URI.buildUpon().appendPath("hostname").appendPath(hostname).build(); - final Cursor cursor = mProvider.query(insertedUri, null, null, null, null); - verifyRowMatches(contentValues, cursor, "disabled-hosts found"); - - final Uri deletedUri = LoginsDisabledHosts.CONTENT_URI.buildUpon().appendPath("hostname").appendPath(hostname).build(); - final int numDeleted = mProvider.delete(deletedUri, null, null); - mAsserter.is(1, numDeleted, "Correct number deleted"); - verifyNoRowExists(LoginsDisabledHosts.CONTENT_URI, "No disabled-hosts entry found"); - } - } - - /** - * LoginsProvider disabled host insert failure testcase. - * - inserts a disabled-host without providing hostname - */ - private class DisabledHostsInsertFailureTest extends TestCase { - @Override - public void test() throws Exception { - final String hostname = "localhost"; - final ContentValues contentValues = new ContentValues(); - try { - mProvider.insert(LoginsDisabledHosts.CONTENT_URI, contentValues); - fail("Failed to throw IllegalArgumentException while missing hostname"); - } catch (Exception e) { - mAsserter.is(e.getClass(), IllegalArgumentException.class, "IllegalArgumentException thrown for invalid hostname"); - } - } - } - - /** - * LoginsProvider login insertion with default values test. - * - insert a login missing GUID, FORM_SUBMIT_URL, HTTP_REALM and verify default values are set. - */ - private class InsertLoginsWithDefaultValuesTest extends TestCase { - @Override - protected void test() throws Exception { - ContentValues contentValues = createLogin("http://www.example.com", "http://www.example.com", - "http://www.example.com", "username1", "password1", "username1", "password1", null); - // Remove GUID, HTTP_REALM, FORM_SUBMIT_URL from content values - contentValues.remove(Logins.GUID); - contentValues.remove(Logins.FORM_SUBMIT_URL); - contentValues.remove(Logins.HTTP_REALM); - - long id = ContentUris.parseId(mProvider.insert(BrowserContract.Logins.CONTENT_URI, contentValues)); - Cursor cursor = getLoginById(id); - assertNotNull(cursor); - cursor.moveToFirst(); - - mAsserter.isnot(cursor.getString(cursor.getColumnIndex(Logins.GUID)), null, "GUID is not null"); - mAsserter.is(cursor.getString(cursor.getColumnIndex(Logins.HTTP_REALM)), null, "HTTP_REALM is not null"); - mAsserter.is(cursor.getString(cursor.getColumnIndex(Logins.FORM_SUBMIT_URL)), null, "FORM_SUBMIT_URL is not null"); - mAsserter.isnot(cursor.getString(cursor.getColumnIndex(Logins.TIME_LAST_USED)), null, "TIME_LAST_USED is not null"); - mAsserter.isnot(cursor.getString(cursor.getColumnIndex(Logins.TIME_CREATED)), null, "TIME_CREATED is not null"); - mAsserter.isnot(cursor.getString(cursor.getColumnIndex(Logins.TIME_PASSWORD_CHANGED)), null, "TIME_PASSWORD_CHANGED is not null"); - mAsserter.is(cursor.getString(cursor.getColumnIndex(Logins.ENC_TYPE)), "0", "ENC_TYPE is 0"); - mAsserter.is(cursor.getString(cursor.getColumnIndex(Logins.TIMES_USED)), "0", "TIMES_USED is 0"); - - // Verify other values. - verifyRowMatches(contentValues, cursor, "Updated login found"); - } - } - - /** - * LoginsProvider login insertion with duplicate GUID test. - * - insert two different logins with same GUID and verify that only one login exists. - */ - private class InsertLoginsWithDuplicateGuidFailureTest extends TestCase { - @Override - protected void test() throws Exception { - final String guid = "guid1"; - ContentValues contentValues = createLogin("http://www.example.com", "http://www.example.com", - "http://www.example.com", "username1", "password1", "username1", "password1", guid); - long id1 = ContentUris.parseId(mProvider.insert(BrowserContract.Logins.CONTENT_URI, contentValues)); - verifyLoginExists(contentValues, id1); - - // Insert another login with duplicate GUID. - contentValues = createLogin("http://www.example2.com", "http://www.example2.com", - "http://www.example2.com", "username2", "password2", "username2", "password2", guid); - Uri insertUri = mProvider.insert(Logins.CONTENT_URI, contentValues); - mAsserter.is(insertUri, null, "Duplicate Guid insertion id1"); - - // Verify login with id1 still exists. - verifyLoginExists(contentValues, id1); - } - } - - /** - * LoginsProvider deletion by non-existent GUID test. - * - delete a login with random GUID and verify that no entry was deleted. - */ - private class DeleteLoginsByNonExistentGuidTest extends TestCase { - @Override - protected void test() throws Exception { - Uri deletedUri = Logins.CONTENT_URI; - int numDeleted = mProvider.delete(deletedUri, Logins.GUID + "= ?", new String[] { "guid1" }); - mAsserter.is(0, numDeleted, "Correct number deleted"); - } - } - - private void verifyBounded(long left, long middle, long right) { - mAsserter.ok(left <= middle, "Left <= middle", left + " <= " + middle); - mAsserter.ok(middle <= right, "Middle <= right", middle + " <= " + right); - } - - private Cursor getById(Uri uri, long id, String[] projection) { - return mProvider.query(uri, projection, - _ID + " = ?", - new String[] { String.valueOf(id) }, - null); - } - - private Cursor getLoginById(long id) { - return getById(Logins.CONTENT_URI, id, null); - } - - private void verifyLoginExists(ContentValues contentValues, long id) { - Cursor cursor = getLoginById(id); - verifyRowMatches(contentValues, cursor, "Updated login found"); - } - - private void verifyRowMatches(ContentValues contentValues, Cursor cursor, String name) { - try { - mAsserter.ok(cursor.moveToFirst(), name, "cursor is not empty"); - CursorMatches(cursor, contentValues); - } finally { - cursor.close(); - } - } - - private void verifyNoRowExists(Uri contentUri, String name) { - Cursor cursor = mProvider.query(contentUri, null, null, null, null); - try { - mAsserter.is(0, cursor.getCount(), name); - } finally { - cursor.close(); - } - } - - private ContentValues createLogin(String hostname, String httpRealm, String formSubmitUrl, - String usernameField, String passwordField, String encryptedUsername, - String encryptedPassword, String guid) { - final ContentValues values = new ContentValues(); - values.put(Logins.HOSTNAME, hostname); - values.put(Logins.HTTP_REALM, httpRealm); - values.put(Logins.FORM_SUBMIT_URL, formSubmitUrl); - values.put(Logins.USERNAME_FIELD, usernameField); - values.put(Logins.PASSWORD_FIELD, passwordField); - values.put(Logins.ENCRYPTED_USERNAME, encryptedUsername); - values.put(Logins.ENCRYPTED_PASSWORD, encryptedPassword); - values.put(Logins.GUID, guid); - return values; - } -} diff --git a/mobile/android/tests/browser/robocop/src/org/mozilla/gecko/tests/testPasswordProvider.java b/mobile/android/tests/browser/robocop/src/org/mozilla/gecko/tests/testPasswordProvider.java index 8a2cc357e4b..c57f8a7f00f 100644 --- a/mobile/android/tests/browser/robocop/src/org/mozilla/gecko/tests/testPasswordProvider.java +++ b/mobile/android/tests/browser/robocop/src/org/mozilla/gecko/tests/testPasswordProvider.java @@ -6,8 +6,6 @@ package org.mozilla.gecko.tests; import java.io.File; -import org.mozilla.gecko.db.BrowserContract; -import org.mozilla.gecko.db.BrowserContract.GeckoDisabledHosts; import org.mozilla.gecko.db.BrowserContract.Passwords; import android.content.ContentResolver; @@ -22,8 +20,6 @@ import android.net.Uri; * - inserts a password * - updates a password * - deletes a password - * - inserts a disabled host - * - queries for disabled host */ public class testPasswordProvider extends BaseTest { private static final String DB_NAME = "signons.sqlite"; @@ -69,23 +65,6 @@ public class testPasswordProvider extends BaseTest { cvs = new ContentValues[0]; c = cr.query(passwordUri, null, null, null, null); SqliteCompare(c, cvs); - - ContentValues values = new ContentValues(); - values.put("hostname", "http://www.example.com"); - - // Attempt to insert into the db. - Uri disabledHostUri = GeckoDisabledHosts.CONTENT_URI; - builder = disabledHostUri.buildUpon(); - disabledHostUri = builder.appendQueryParameter("profilePath", mProfile).build(); - - uri = cr.insert(disabledHostUri, values); - expectedUri = disabledHostUri.buildUpon().appendPath("1").build(); - mAsserter.is(uri.toString(), expectedUri.toString(), "Insert returned correct uri"); - Cursor cursor = cr.query(disabledHostUri, null, null, null, null); - assertNotNull(cursor); - assertEquals(1, cursor.getCount()); - cursor.moveToFirst(); - CursorMatches(cursor, values); } @Override From 889a65ddedc32ab342ef3b85f6983d2ad3853e61 Mon Sep 17 00:00:00 2001 From: Mark Hammond Date: Thu, 3 Mar 2016 12:20:41 +1100 Subject: [PATCH 149/160] Bug 1249574 - send the notification about synced tab state changing as the tabs engine is enabled or disabled. r=rnewman --- services/sync/modules/SyncedTabs.jsm | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/services/sync/modules/SyncedTabs.jsm b/services/sync/modules/SyncedTabs.jsm index 3eea56bc646..9c790711c90 100644 --- a/services/sync/modules/SyncedTabs.jsm +++ b/services/sync/modules/SyncedTabs.jsm @@ -208,6 +208,9 @@ let SyncedTabsInternal = { Preferences.reset("services.sync.lastTabFetch"); Services.obs.notifyObservers(null, TOPIC_TABS_CHANGED, null); break; + case "nsPref:changed": + Services.obs.notifyObservers(null, TOPIC_TABS_CHANGED, null); + break; default: break; } @@ -232,6 +235,10 @@ let SyncedTabsInternal = { Services.obs.addObserver(SyncedTabsInternal, "weave:engine:sync:finish", false); Services.obs.addObserver(SyncedTabsInternal, "weave:service:start-over", false); +// Observe the pref the indicates the state of the tabs engine has changed. +// This will force consumers to re-evaluate the state of sync and update +// accordingly. +Services.prefs.addObserver("services.sync.engine.tabs", SyncedTabsInternal, false); // The public interface. this.SyncedTabs = { From 5cb50e7417e8fc35433cf28339b48a42521fbd02 Mon Sep 17 00:00:00 2001 From: Kris Maglione Date: Sat, 27 Feb 2016 15:29:42 -0800 Subject: [PATCH 150/160] Bug 1190663: [webext] Add tests for window.close() in browserAction and pageAction popups. r=rpl MozReview-Commit-ID: 8r08YRw7IGr --- browser/components/extensions/ext-utils.js | 24 ++++++++- .../browser_ext_browserAction_popup.js | 49 ++++++++++++++----- .../browser/browser_ext_pageAction_popup.js | 39 ++++++++++++--- .../extensions/test/browser/head.js | 14 +++++- 4 files changed, 104 insertions(+), 22 deletions(-) diff --git a/browser/components/extensions/ext-utils.js b/browser/components/extensions/ext-utils.js index 480054e1325..54aacc39b3a 100644 --- a/browser/components/extensions/ext-utils.js +++ b/browser/components/extensions/ext-utils.js @@ -125,6 +125,19 @@ global.makeWidgetId = id => { return id.replace(/[^a-z0-9_-]/g, "_"); }; +function promisePopupShown(popup) { + return new Promise(resolve => { + if (popup.state == "open") { + resolve(); + } else { + popup.addEventListener("popupshown", function onPopupShown(event) { + popup.removeEventListener("popupshown", onPopupShown); + resolve(); + }); + } + }); +} + class BasePopup { constructor(extension, viewNode, popupURL) { let popupURI = Services.io.newURI(popupURL, null, extension.baseURI); @@ -254,6 +267,10 @@ class BasePopup { // Resizes the browser to match the preferred size of the content. resizeBrowser() { + if (!this.browser) { + return; + } + let width, height; try { let w = {}, h = {}; @@ -310,7 +327,12 @@ global.PanelPopup = class PanelPopup extends BasePopup { } closePopup() { - this.viewNode.hidePopup(); + promisePopupShown(this.viewNode).then(() => { + // Make sure we're not already destroyed. + if (this.viewNode) { + this.viewNode.hidePopup(); + } + }); } }; diff --git a/browser/components/extensions/test/browser/browser_ext_browserAction_popup.js b/browser/components/extensions/test/browser/browser_ext_browserAction_popup.js index a4f5fb8afb5..ea7dfd65839 100644 --- a/browser/components/extensions/test/browser/browser_ext_browserAction_popup.js +++ b/browser/components/extensions/test/browser/browser_ext_browserAction_popup.js @@ -3,6 +3,8 @@ "use strict"; function* testInArea(area) { + let scriptPage = url => ``; + let extension = ExtensionTestUtils.loadExtension({ manifest: { "background": { @@ -14,17 +16,22 @@ function* testInArea(area) { }, files: { - "popup-a.html": ``, + "popup-a.html": scriptPage("popup-a.js"), "popup-a.js": function() { browser.runtime.sendMessage("from-popup-a"); + browser.runtime.onMessage.addListener(msg => { + if (msg == "close-popup") { + window.close(); + } + }); }, - "data/popup-b.html": ``, + "data/popup-b.html": scriptPage("popup-b.js"), "data/popup-b.js": function() { browser.runtime.sendMessage("from-popup-b"); }, - "data/background.html": ``, + "data/background.html": scriptPage("background.js"), "data/background.js": function() { let sendClick; @@ -51,26 +58,37 @@ function* testInArea(area) { }, () => { browser.browserAction.setPopup({popup: "/popup-a.html"}); - sendClick({expectEvent: false, expectPopup: "a"}); + sendClick({expectEvent: false, expectPopup: "a", runNextTest: true}); + }, + () => { + browser.test.sendMessage("next-test", {expectClosed: true}); + browser.runtime.sendMessage("close-popup"); }, ]; let expect = {}; - sendClick = ({expectEvent, expectPopup}) => { - expect = {event: expectEvent, popup: expectPopup}; + sendClick = ({expectEvent, expectPopup, runNextTest}) => { + expect = {event: expectEvent, popup: expectPopup, runNextTest}; browser.test.sendMessage("send-click"); }; browser.runtime.onMessage.addListener(msg => { - if (expect.popup) { + if (msg == "close-popup") { + return; + } else if (expect.popup) { browser.test.assertEq(msg, `from-popup-${expect.popup}`, "expected popup opened"); } else { - browser.test.fail("unexpected popup"); + browser.test.fail(`unexpected popup: ${msg}`); } expect.popup = null; - browser.test.sendMessage("next-test"); + if (expect.runNextTest) { + expect.runNextTest = false; + tests.shift()(); + } else { + browser.test.sendMessage("next-test"); + } }); browser.browserAction.onClicked.addListener(() => { @@ -107,13 +125,20 @@ function* testInArea(area) { }); let widget; - extension.onMessage("next-test", Task.async(function* () { + extension.onMessage("next-test", Task.async(function* (expecting = {}) { if (!widget) { widget = getBrowserActionWidget(extension); CustomizableUI.addWidgetToArea(widget.id, area); } - - yield closeBrowserAction(extension); + if (expecting.expectClosed) { + let panel = getBrowserActionPopup(extension); + ok(panel, "Expect panel to exist"); + yield promisePopupShown(panel); + yield promisePopupHidden(panel); + ok(true, "Panel is closed"); + } else { + yield closeBrowserAction(extension); + } extension.sendMessage("next-test"); })); diff --git a/browser/components/extensions/test/browser/browser_ext_pageAction_popup.js b/browser/components/extensions/test/browser/browser_ext_pageAction_popup.js index 488c96d1dc7..a609ae10330 100644 --- a/browser/components/extensions/test/browser/browser_ext_pageAction_popup.js +++ b/browser/components/extensions/test/browser/browser_ext_pageAction_popup.js @@ -19,6 +19,11 @@ add_task(function* testPageActionPopup() { "popup-a.html": scriptPage("popup-a.js"), "popup-a.js": function() { browser.runtime.sendMessage("from-popup-a"); + browser.runtime.onMessage.addListener(msg => { + if (msg == "close-popup") { + window.close(); + } + }); }, "data/popup-b.html": scriptPage("popup-b.js"), @@ -55,26 +60,37 @@ add_task(function* testPageActionPopup() { }, () => { browser.pageAction.setPopup({tabId, popup: "/popup-a.html"}); - sendClick({expectEvent: false, expectPopup: "a"}); + sendClick({expectEvent: false, expectPopup: "a", runNextTest: true}); + }, + () => { + browser.test.sendMessage("next-test", {expectClosed: true}); + browser.runtime.sendMessage("close-popup"); }, ]; let expect = {}; - sendClick = ({expectEvent, expectPopup}) => { - expect = {event: expectEvent, popup: expectPopup}; + sendClick = ({expectEvent, expectPopup, runNextTest}) => { + expect = {event: expectEvent, popup: expectPopup, runNextTest}; browser.test.sendMessage("send-click"); }; browser.runtime.onMessage.addListener(msg => { - if (expect.popup) { + if (msg == "close-popup") { + return; + } else if (expect.popup) { browser.test.assertEq(msg, `from-popup-${expect.popup}`, "expected popup opened"); } else { - browser.test.fail("unexpected popup"); + browser.test.fail(`unexpected popup: ${msg}`); } expect.popup = null; - browser.test.sendMessage("next-test"); + if (expect.runNextTest) { + expect.runNextTest = false; + tests.shift()(); + } else { + browser.test.sendMessage("next-test"); + } }); browser.pageAction.onClicked.addListener(() => { @@ -118,12 +134,19 @@ add_task(function* testPageActionPopup() { clickPageAction(extension); }); - extension.onMessage("next-test", Task.async(function* () { + extension.onMessage("next-test", Task.async(function* (expecting = {}) { let panel = document.getElementById(panelId); - if (panel) { + if (expecting.expectClosed) { + ok(panel, "Expect panel to exist"); + yield promisePopupShown(panel); + yield promisePopupHidden(panel); + ok(true, `Panel is closed`); + } else if (panel) { yield promisePopupShown(panel); panel.hidePopup(); + } + if (panel) { panel = document.getElementById(panelId); is(panel, null, "panel successfully removed from document after hiding"); } diff --git a/browser/components/extensions/test/browser/head.js b/browser/components/extensions/test/browser/head.js index a43e1fcf6b0..232c188e336 100644 --- a/browser/components/extensions/test/browser/head.js +++ b/browser/components/extensions/test/browser/head.js @@ -7,7 +7,7 @@ * clickBrowserAction clickPageAction * getBrowserActionPopup getPageActionPopup * closeBrowserAction closePageAction - * promisePopupShown + * promisePopupShown promisePopupHidden */ var {AppConstants} = Cu.import("resource://gre/modules/AppConstants.jsm"); @@ -59,6 +59,16 @@ function promisePopupShown(popup) { }); } +function promisePopupHidden(popup) { + return new Promise(resolve => { + let onPopupHidden = event => { + popup.removeEventListener("popuphidden", onPopupHidden); + resolve(); + }; + popup.addEventListener("popuphidden", onPopupHidden); + }); +} + function getBrowserActionWidget(extension) { return CustomizableUI.getWidget(makeWidgetId(extension.id) + "-browser-action"); } @@ -68,6 +78,8 @@ function getBrowserActionPopup(extension, win = window) { if (group.areaType == CustomizableUI.TYPE_TOOLBAR) { return win.document.getElementById("customizationui-widget-panel"); + } else { + return win.PanelUI.panel; } return null; } From f27a70edc5658482be73c1022ede07c6c9f8eb41 Mon Sep 17 00:00:00 2001 From: Kris Maglione Date: Wed, 2 Mar 2016 19:50:22 -0800 Subject: [PATCH 151/160] Backed out changeset 09d8e3caf51d (bug 1190663) for intermittent mochitest failures on Windows MozReview-Commit-ID: BsHw1BxNF2t --- browser/components/extensions/ext-utils.js | 24 +-------- .../browser_ext_browserAction_popup.js | 49 +++++-------------- .../browser/browser_ext_pageAction_popup.js | 39 +++------------ .../extensions/test/browser/head.js | 14 +----- 4 files changed, 22 insertions(+), 104 deletions(-) diff --git a/browser/components/extensions/ext-utils.js b/browser/components/extensions/ext-utils.js index 54aacc39b3a..480054e1325 100644 --- a/browser/components/extensions/ext-utils.js +++ b/browser/components/extensions/ext-utils.js @@ -125,19 +125,6 @@ global.makeWidgetId = id => { return id.replace(/[^a-z0-9_-]/g, "_"); }; -function promisePopupShown(popup) { - return new Promise(resolve => { - if (popup.state == "open") { - resolve(); - } else { - popup.addEventListener("popupshown", function onPopupShown(event) { - popup.removeEventListener("popupshown", onPopupShown); - resolve(); - }); - } - }); -} - class BasePopup { constructor(extension, viewNode, popupURL) { let popupURI = Services.io.newURI(popupURL, null, extension.baseURI); @@ -267,10 +254,6 @@ class BasePopup { // Resizes the browser to match the preferred size of the content. resizeBrowser() { - if (!this.browser) { - return; - } - let width, height; try { let w = {}, h = {}; @@ -327,12 +310,7 @@ global.PanelPopup = class PanelPopup extends BasePopup { } closePopup() { - promisePopupShown(this.viewNode).then(() => { - // Make sure we're not already destroyed. - if (this.viewNode) { - this.viewNode.hidePopup(); - } - }); + this.viewNode.hidePopup(); } }; diff --git a/browser/components/extensions/test/browser/browser_ext_browserAction_popup.js b/browser/components/extensions/test/browser/browser_ext_browserAction_popup.js index ea7dfd65839..a4f5fb8afb5 100644 --- a/browser/components/extensions/test/browser/browser_ext_browserAction_popup.js +++ b/browser/components/extensions/test/browser/browser_ext_browserAction_popup.js @@ -3,8 +3,6 @@ "use strict"; function* testInArea(area) { - let scriptPage = url => ``; - let extension = ExtensionTestUtils.loadExtension({ manifest: { "background": { @@ -16,22 +14,17 @@ function* testInArea(area) { }, files: { - "popup-a.html": scriptPage("popup-a.js"), + "popup-a.html": ``, "popup-a.js": function() { browser.runtime.sendMessage("from-popup-a"); - browser.runtime.onMessage.addListener(msg => { - if (msg == "close-popup") { - window.close(); - } - }); }, - "data/popup-b.html": scriptPage("popup-b.js"), + "data/popup-b.html": ``, "data/popup-b.js": function() { browser.runtime.sendMessage("from-popup-b"); }, - "data/background.html": scriptPage("background.js"), + "data/background.html": ``, "data/background.js": function() { let sendClick; @@ -58,37 +51,26 @@ function* testInArea(area) { }, () => { browser.browserAction.setPopup({popup: "/popup-a.html"}); - sendClick({expectEvent: false, expectPopup: "a", runNextTest: true}); - }, - () => { - browser.test.sendMessage("next-test", {expectClosed: true}); - browser.runtime.sendMessage("close-popup"); + sendClick({expectEvent: false, expectPopup: "a"}); }, ]; let expect = {}; - sendClick = ({expectEvent, expectPopup, runNextTest}) => { - expect = {event: expectEvent, popup: expectPopup, runNextTest}; + sendClick = ({expectEvent, expectPopup}) => { + expect = {event: expectEvent, popup: expectPopup}; browser.test.sendMessage("send-click"); }; browser.runtime.onMessage.addListener(msg => { - if (msg == "close-popup") { - return; - } else if (expect.popup) { + if (expect.popup) { browser.test.assertEq(msg, `from-popup-${expect.popup}`, "expected popup opened"); } else { - browser.test.fail(`unexpected popup: ${msg}`); + browser.test.fail("unexpected popup"); } expect.popup = null; - if (expect.runNextTest) { - expect.runNextTest = false; - tests.shift()(); - } else { - browser.test.sendMessage("next-test"); - } + browser.test.sendMessage("next-test"); }); browser.browserAction.onClicked.addListener(() => { @@ -125,20 +107,13 @@ function* testInArea(area) { }); let widget; - extension.onMessage("next-test", Task.async(function* (expecting = {}) { + extension.onMessage("next-test", Task.async(function* () { if (!widget) { widget = getBrowserActionWidget(extension); CustomizableUI.addWidgetToArea(widget.id, area); } - if (expecting.expectClosed) { - let panel = getBrowserActionPopup(extension); - ok(panel, "Expect panel to exist"); - yield promisePopupShown(panel); - yield promisePopupHidden(panel); - ok(true, "Panel is closed"); - } else { - yield closeBrowserAction(extension); - } + + yield closeBrowserAction(extension); extension.sendMessage("next-test"); })); diff --git a/browser/components/extensions/test/browser/browser_ext_pageAction_popup.js b/browser/components/extensions/test/browser/browser_ext_pageAction_popup.js index a609ae10330..488c96d1dc7 100644 --- a/browser/components/extensions/test/browser/browser_ext_pageAction_popup.js +++ b/browser/components/extensions/test/browser/browser_ext_pageAction_popup.js @@ -19,11 +19,6 @@ add_task(function* testPageActionPopup() { "popup-a.html": scriptPage("popup-a.js"), "popup-a.js": function() { browser.runtime.sendMessage("from-popup-a"); - browser.runtime.onMessage.addListener(msg => { - if (msg == "close-popup") { - window.close(); - } - }); }, "data/popup-b.html": scriptPage("popup-b.js"), @@ -60,37 +55,26 @@ add_task(function* testPageActionPopup() { }, () => { browser.pageAction.setPopup({tabId, popup: "/popup-a.html"}); - sendClick({expectEvent: false, expectPopup: "a", runNextTest: true}); - }, - () => { - browser.test.sendMessage("next-test", {expectClosed: true}); - browser.runtime.sendMessage("close-popup"); + sendClick({expectEvent: false, expectPopup: "a"}); }, ]; let expect = {}; - sendClick = ({expectEvent, expectPopup, runNextTest}) => { - expect = {event: expectEvent, popup: expectPopup, runNextTest}; + sendClick = ({expectEvent, expectPopup}) => { + expect = {event: expectEvent, popup: expectPopup}; browser.test.sendMessage("send-click"); }; browser.runtime.onMessage.addListener(msg => { - if (msg == "close-popup") { - return; - } else if (expect.popup) { + if (expect.popup) { browser.test.assertEq(msg, `from-popup-${expect.popup}`, "expected popup opened"); } else { - browser.test.fail(`unexpected popup: ${msg}`); + browser.test.fail("unexpected popup"); } expect.popup = null; - if (expect.runNextTest) { - expect.runNextTest = false; - tests.shift()(); - } else { - browser.test.sendMessage("next-test"); - } + browser.test.sendMessage("next-test"); }); browser.pageAction.onClicked.addListener(() => { @@ -134,19 +118,12 @@ add_task(function* testPageActionPopup() { clickPageAction(extension); }); - extension.onMessage("next-test", Task.async(function* (expecting = {}) { + extension.onMessage("next-test", Task.async(function* () { let panel = document.getElementById(panelId); - if (expecting.expectClosed) { - ok(panel, "Expect panel to exist"); - yield promisePopupShown(panel); - yield promisePopupHidden(panel); - ok(true, `Panel is closed`); - } else if (panel) { + if (panel) { yield promisePopupShown(panel); panel.hidePopup(); - } - if (panel) { panel = document.getElementById(panelId); is(panel, null, "panel successfully removed from document after hiding"); } diff --git a/browser/components/extensions/test/browser/head.js b/browser/components/extensions/test/browser/head.js index 232c188e336..a43e1fcf6b0 100644 --- a/browser/components/extensions/test/browser/head.js +++ b/browser/components/extensions/test/browser/head.js @@ -7,7 +7,7 @@ * clickBrowserAction clickPageAction * getBrowserActionPopup getPageActionPopup * closeBrowserAction closePageAction - * promisePopupShown promisePopupHidden + * promisePopupShown */ var {AppConstants} = Cu.import("resource://gre/modules/AppConstants.jsm"); @@ -59,16 +59,6 @@ function promisePopupShown(popup) { }); } -function promisePopupHidden(popup) { - return new Promise(resolve => { - let onPopupHidden = event => { - popup.removeEventListener("popuphidden", onPopupHidden); - resolve(); - }; - popup.addEventListener("popuphidden", onPopupHidden); - }); -} - function getBrowserActionWidget(extension) { return CustomizableUI.getWidget(makeWidgetId(extension.id) + "-browser-action"); } @@ -78,8 +68,6 @@ function getBrowserActionPopup(extension, win = window) { if (group.areaType == CustomizableUI.TYPE_TOOLBAR) { return win.document.getElementById("customizationui-widget-panel"); - } else { - return win.PanelUI.panel; } return null; } From 655e4b16dfe4f623833872b1815489698e4994a4 Mon Sep 17 00:00:00 2001 From: Kris Maglione Date: Sat, 27 Feb 2016 15:29:42 -0800 Subject: [PATCH 152/160] Bug 1190663: [webext] Add tests for window.close() in browserAction and pageAction popups. r=rpl MozReview-Commit-ID: 8r08YRw7IGr --- browser/components/extensions/ext-utils.js | 24 ++++++++- .../browser_ext_browserAction_popup.js | 54 +++++++++++++++---- .../browser/browser_ext_pageAction_popup.js | 46 +++++++++++++--- .../extensions/test/browser/head.js | 14 ++++- 4 files changed, 117 insertions(+), 21 deletions(-) diff --git a/browser/components/extensions/ext-utils.js b/browser/components/extensions/ext-utils.js index 480054e1325..54aacc39b3a 100644 --- a/browser/components/extensions/ext-utils.js +++ b/browser/components/extensions/ext-utils.js @@ -125,6 +125,19 @@ global.makeWidgetId = id => { return id.replace(/[^a-z0-9_-]/g, "_"); }; +function promisePopupShown(popup) { + return new Promise(resolve => { + if (popup.state == "open") { + resolve(); + } else { + popup.addEventListener("popupshown", function onPopupShown(event) { + popup.removeEventListener("popupshown", onPopupShown); + resolve(); + }); + } + }); +} + class BasePopup { constructor(extension, viewNode, popupURL) { let popupURI = Services.io.newURI(popupURL, null, extension.baseURI); @@ -254,6 +267,10 @@ class BasePopup { // Resizes the browser to match the preferred size of the content. resizeBrowser() { + if (!this.browser) { + return; + } + let width, height; try { let w = {}, h = {}; @@ -310,7 +327,12 @@ global.PanelPopup = class PanelPopup extends BasePopup { } closePopup() { - this.viewNode.hidePopup(); + promisePopupShown(this.viewNode).then(() => { + // Make sure we're not already destroyed. + if (this.viewNode) { + this.viewNode.hidePopup(); + } + }); } }; diff --git a/browser/components/extensions/test/browser/browser_ext_browserAction_popup.js b/browser/components/extensions/test/browser/browser_ext_browserAction_popup.js index a4f5fb8afb5..e2f1a8d7faa 100644 --- a/browser/components/extensions/test/browser/browser_ext_browserAction_popup.js +++ b/browser/components/extensions/test/browser/browser_ext_browserAction_popup.js @@ -3,6 +3,8 @@ "use strict"; function* testInArea(area) { + let scriptPage = url => ``; + let extension = ExtensionTestUtils.loadExtension({ manifest: { "background": { @@ -14,17 +16,22 @@ function* testInArea(area) { }, files: { - "popup-a.html": ``, + "popup-a.html": scriptPage("popup-a.js"), "popup-a.js": function() { browser.runtime.sendMessage("from-popup-a"); + browser.runtime.onMessage.addListener(msg => { + if (msg == "close-popup") { + window.close(); + } + }); }, - "data/popup-b.html": ``, + "data/popup-b.html": scriptPage("popup-b.js"), "data/popup-b.js": function() { browser.runtime.sendMessage("from-popup-b"); }, - "data/background.html": ``, + "data/background.html": scriptPage("background.js"), "data/background.js": function() { let sendClick; @@ -51,26 +58,36 @@ function* testInArea(area) { }, () => { browser.browserAction.setPopup({popup: "/popup-a.html"}); - sendClick({expectEvent: false, expectPopup: "a"}); + sendClick({expectEvent: false, expectPopup: "a", runNextTest: true}); + }, + () => { + browser.test.sendMessage("next-test", {expectClosed: true}); }, ]; let expect = {}; - sendClick = ({expectEvent, expectPopup}) => { - expect = {event: expectEvent, popup: expectPopup}; + sendClick = ({expectEvent, expectPopup, runNextTest}) => { + expect = {event: expectEvent, popup: expectPopup, runNextTest}; browser.test.sendMessage("send-click"); }; browser.runtime.onMessage.addListener(msg => { - if (expect.popup) { + if (msg == "close-popup") { + return; + } else if (expect.popup) { browser.test.assertEq(msg, `from-popup-${expect.popup}`, "expected popup opened"); } else { - browser.test.fail("unexpected popup"); + browser.test.fail(`unexpected popup: ${msg}`); } expect.popup = null; - browser.test.sendMessage("next-test"); + if (expect.runNextTest) { + expect.runNextTest = false; + tests.shift()(); + } else { + browser.test.sendMessage("next-test"); + } }); browser.browserAction.onClicked.addListener(() => { @@ -85,6 +102,11 @@ function* testInArea(area) { }); browser.test.onMessage.addListener((msg) => { + if (msg == "close-popup") { + browser.runtime.sendMessage("close-popup"); + return; + } + if (msg != "next-test") { browser.test.fail("Expecting 'next-test' message"); } @@ -107,13 +129,23 @@ function* testInArea(area) { }); let widget; - extension.onMessage("next-test", Task.async(function* () { + extension.onMessage("next-test", Task.async(function* (expecting = {}) { if (!widget) { widget = getBrowserActionWidget(extension); CustomizableUI.addWidgetToArea(widget.id, area); } + if (expecting.expectClosed) { + let panel = getBrowserActionPopup(extension); + ok(panel, "Expect panel to exist"); + yield promisePopupShown(panel); - yield closeBrowserAction(extension); + extension.sendMessage("close-popup"); + + yield promisePopupHidden(panel); + ok(true, "Panel is closed"); + } else { + yield closeBrowserAction(extension); + } extension.sendMessage("next-test"); })); diff --git a/browser/components/extensions/test/browser/browser_ext_pageAction_popup.js b/browser/components/extensions/test/browser/browser_ext_pageAction_popup.js index 488c96d1dc7..a7a5047c45b 100644 --- a/browser/components/extensions/test/browser/browser_ext_pageAction_popup.js +++ b/browser/components/extensions/test/browser/browser_ext_pageAction_popup.js @@ -19,6 +19,11 @@ add_task(function* testPageActionPopup() { "popup-a.html": scriptPage("popup-a.js"), "popup-a.js": function() { browser.runtime.sendMessage("from-popup-a"); + browser.runtime.onMessage.addListener(msg => { + if (msg == "close-popup") { + window.close(); + } + }); }, "data/popup-b.html": scriptPage("popup-b.js"), @@ -55,26 +60,36 @@ add_task(function* testPageActionPopup() { }, () => { browser.pageAction.setPopup({tabId, popup: "/popup-a.html"}); - sendClick({expectEvent: false, expectPopup: "a"}); + sendClick({expectEvent: false, expectPopup: "a", runNextTest: true}); + }, + () => { + browser.test.sendMessage("next-test", {expectClosed: true}); }, ]; let expect = {}; - sendClick = ({expectEvent, expectPopup}) => { - expect = {event: expectEvent, popup: expectPopup}; + sendClick = ({expectEvent, expectPopup, runNextTest}) => { + expect = {event: expectEvent, popup: expectPopup, runNextTest}; browser.test.sendMessage("send-click"); }; browser.runtime.onMessage.addListener(msg => { - if (expect.popup) { + if (msg == "close-popup") { + return; + } else if (expect.popup) { browser.test.assertEq(msg, `from-popup-${expect.popup}`, "expected popup opened"); } else { - browser.test.fail("unexpected popup"); + browser.test.fail(`unexpected popup: ${msg}`); } expect.popup = null; - browser.test.sendMessage("next-test"); + if (expect.runNextTest) { + expect.runNextTest = false; + tests.shift()(); + } else { + browser.test.sendMessage("next-test"); + } }); browser.pageAction.onClicked.addListener(() => { @@ -89,6 +104,11 @@ add_task(function* testPageActionPopup() { }); browser.test.onMessage.addListener((msg) => { + if (msg == "close-popup") { + browser.runtime.sendMessage("close-popup"); + return; + } + if (msg != "next-test") { browser.test.fail("Expecting 'next-test' message"); } @@ -118,12 +138,22 @@ add_task(function* testPageActionPopup() { clickPageAction(extension); }); - extension.onMessage("next-test", Task.async(function* () { + extension.onMessage("next-test", Task.async(function* (expecting = {}) { let panel = document.getElementById(panelId); - if (panel) { + if (expecting.expectClosed) { + ok(panel, "Expect panel to exist"); + yield promisePopupShown(panel); + + extension.sendMessage("close-popup"); + + yield promisePopupHidden(panel); + ok(true, `Panel is closed`); + } else if (panel) { yield promisePopupShown(panel); panel.hidePopup(); + } + if (panel) { panel = document.getElementById(panelId); is(panel, null, "panel successfully removed from document after hiding"); } diff --git a/browser/components/extensions/test/browser/head.js b/browser/components/extensions/test/browser/head.js index a43e1fcf6b0..232c188e336 100644 --- a/browser/components/extensions/test/browser/head.js +++ b/browser/components/extensions/test/browser/head.js @@ -7,7 +7,7 @@ * clickBrowserAction clickPageAction * getBrowserActionPopup getPageActionPopup * closeBrowserAction closePageAction - * promisePopupShown + * promisePopupShown promisePopupHidden */ var {AppConstants} = Cu.import("resource://gre/modules/AppConstants.jsm"); @@ -59,6 +59,16 @@ function promisePopupShown(popup) { }); } +function promisePopupHidden(popup) { + return new Promise(resolve => { + let onPopupHidden = event => { + popup.removeEventListener("popuphidden", onPopupHidden); + resolve(); + }; + popup.addEventListener("popuphidden", onPopupHidden); + }); +} + function getBrowserActionWidget(extension) { return CustomizableUI.getWidget(makeWidgetId(extension.id) + "-browser-action"); } @@ -68,6 +78,8 @@ function getBrowserActionPopup(extension, win = window) { if (group.areaType == CustomizableUI.TYPE_TOOLBAR) { return win.document.getElementById("customizationui-widget-panel"); + } else { + return win.PanelUI.panel; } return null; } From 430c98917a65cc4de7aae57cee884f8d05369652 Mon Sep 17 00:00:00 2001 From: Gregory Szorc Date: Wed, 2 Mar 2016 16:30:03 -0800 Subject: [PATCH 153/160] Bug 1250991 - Move APK upload files code to own file; r=mshal This is several hundred lines of make goo that makes upload-files.mk even harder to read than it actually is. Extract it to its own file. I performed a `hg cp` to preserve file history so blame continues to work. MozReview-Commit-ID: IpoPE79m9SX --- toolkit/mozapps/installer/upload-files-APK.mk | 295 ++++++++++++++++++ toolkit/mozapps/installer/upload-files.mk | 289 +---------------- 2 files changed, 296 insertions(+), 288 deletions(-) create mode 100644 toolkit/mozapps/installer/upload-files-APK.mk diff --git a/toolkit/mozapps/installer/upload-files-APK.mk b/toolkit/mozapps/installer/upload-files-APK.mk new file mode 100644 index 00000000000..d1b034c42a5 --- /dev/null +++ b/toolkit/mozapps/installer/upload-files-APK.mk @@ -0,0 +1,295 @@ +# 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/. + +# This file should ONLY be included from upload-files.mk. It was +# split into its own file to increase comprehension of +# upload-files.mk. + +include $(MOZILLA_DIR)/config/android-common.mk + +DIST_FILES = + +# Place the files in the order they are going to be opened by the linker +ifndef MOZ_FOLD_LIBS +DIST_FILES += \ + libnspr4.so \ + libplc4.so \ + libplds4.so \ + libmozsqlite3.so \ + libnssutil3.so \ + $(NULL) +endif +DIST_FILES += libnss3.so +ifndef MOZ_FOLD_LIBS +DIST_FILES += \ + libssl3.so \ + libsmime3.so \ + $(NULL) +endif +DIST_FILES += \ + liblgpllibs.so \ + libxul.so \ + libnssckbi.so \ + libfreebl3.so \ + libsoftokn3.so \ + resources.arsc \ + AndroidManifest.xml \ + chrome \ + components \ + defaults \ + modules \ + hyphenation \ + res \ + lib \ + extensions \ + application.ini \ + package-name.txt \ + ua-update.json \ + platform.ini \ + greprefs.js \ + browserconfig.properties \ + blocklist.xml \ + chrome.manifest \ + update.locale \ + removed-files \ + $(NULL) + +NON_DIST_FILES = \ + classes.dex \ + $(NULL) + +UPLOAD_EXTRA_FILES += gecko-unsigned-unaligned.apk + +DIST_FILES += $(MOZ_CHILD_PROCESS_NAME) + +GECKO_APP_AP_PATH = $(topobjdir)/mobile/android/base + +ifdef ENABLE_TESTS +INNER_ROBOCOP_PACKAGE=true +ifeq ($(MOZ_BUILD_APP),mobile/android) +UPLOAD_EXTRA_FILES += robocop.apk +UPLOAD_EXTRA_FILES += fennec_ids.txt +UPLOAD_EXTRA_FILES += geckoview_library/geckoview_library.zip +UPLOAD_EXTRA_FILES += geckoview_library/geckoview_assets.zip + +# Robocop/Robotium tests, Android Background tests, and Fennec need to +# be signed with the same key, which means release signing them all. + +ifndef MOZ_BUILD_MOBILE_ANDROID_WITH_GRADLE +robocop_apk := $(topobjdir)/mobile/android/tests/browser/robocop/robocop-debug-unsigned-unaligned.apk +else +robocop_apk := $(topobjdir)/gradle/build/mobile/android/app/outputs/apk/app-automation-debug-androidTest-unaligned.apk +endif + +# Normally, $(NSINSTALL) would be used instead of cp, but INNER_ROBOCOP_PACKAGE +# is used in a series of commands that run under a "cd something", while +# $(NSINSTALL) is relative. +INNER_ROBOCOP_PACKAGE= \ + cp $(GECKO_APP_AP_PATH)/fennec_ids.txt $(ABS_DIST) && \ + $(call RELEASE_SIGN_ANDROID_APK,$(robocop_apk),$(ABS_DIST)/robocop.apk) +endif +else +INNER_ROBOCOP_PACKAGE=echo 'Testing is disabled - No Android Robocop for you' +endif + +ifdef MOZ_ANDROID_PACKAGE_INSTALL_BOUNCER +INNER_INSTALL_BOUNCER_PACKAGE=true +ifdef ENABLE_TESTS +UPLOAD_EXTRA_FILES += bouncer.apk + +bouncer_package=$(ABS_DIST)/bouncer.apk + +# Package and release sign the install bouncer APK. This assumes that the main +# APK (that is, $(PACKAGE)) has already been produced, and verifies that the +# bouncer APK and the main APK define the same set of permissions. The +# intention is to avoid permission-related surprises when bouncing to the +# installation process in the Play Store. N.b.: sort -u is Posix and saves +# invoking uniq separately. diff -u is *not* Posix, so we only add -c. +INNER_INSTALL_BOUNCER_PACKAGE=\ + $(call RELEASE_SIGN_ANDROID_APK,$(topobjdir)/mobile/android/bouncer/bouncer-unsigned-unaligned.apk,$(bouncer_package)) && \ + ($(AAPT) dump permissions $(PACKAGE) | sort -u > $(PACKAGE).permissions && \ + $(AAPT) dump permissions $(bouncer_package) | sort -u > $(bouncer_package).permissions && \ + diff -c $(PACKAGE).permissions $(bouncer_package).permissions || \ + (echo "*** Error: The permissions of the bouncer package differ from the permissions of the main package. Ensure the bouncer and main package Android manifests agree, rebuild mobile/android, and re-package." && exit 1)) +else +INNER_INSTALL_BOUNCER_PACKAGE=echo 'Testing is disabled, so the install bouncer is disabled - No trampolines for you' +endif # ENABLE_TESTS +else +INNER_INSTALL_BOUNCER_PACKAGE=echo 'Install bouncer is disabled - No trampolines for you' +endif # MOZ_ANDROID_PACKAGE_INSTALL_BOUNCER + +# Create geckoview_library/geckoview_{assets,library}.zip for third-party GeckoView consumers. +ifdef NIGHTLY_BUILD +ifndef MOZ_DISABLE_GECKOVIEW +INNER_MAKE_GECKOVIEW_LIBRARY= \ + $(MAKE) -C ../mobile/android/geckoview_library package +else +INNER_MAKE_GECKOVIEW_LIBRARY=echo 'GeckoView library packaging is disabled' +endif +else +INNER_MAKE_GECKOVIEW_LIBRARY=echo 'GeckoView library packaging is only enabled on Nightly' +endif + +# Create Android ARchives and metadata for download by local +# developers using Gradle. +ifdef MOZ_ANDROID_GECKOLIBS_AAR +ifndef MOZ_DISABLE_GECKOVIEW +geckoaar-revision := $(BUILDID) + +UPLOAD_EXTRA_FILES += \ + geckolibs-$(geckoaar-revision).aar \ + geckolibs-$(geckoaar-revision).aar.sha1 \ + geckolibs-$(geckoaar-revision).pom \ + geckolibs-$(geckoaar-revision).pom.sha1 \ + ivy-geckolibs-$(geckoaar-revision).xml \ + ivy-geckolibs-$(geckoaar-revision).xml.sha1 \ + geckoview-$(geckoaar-revision).aar \ + geckoview-$(geckoaar-revision).aar.sha1 \ + geckoview-$(geckoaar-revision).pom \ + geckoview-$(geckoaar-revision).pom.sha1 \ + ivy-geckoview-$(geckoaar-revision).xml \ + ivy-geckoview-$(geckoaar-revision).xml.sha1 \ + $(NULL) + +INNER_MAKE_GECKOLIBS_AAR= \ + $(PYTHON) -m mozbuild.action.package_geckolibs_aar \ + --verbose \ + --revision $(geckoaar-revision) \ + --topsrcdir '$(topsrcdir)' \ + --distdir '$(ABS_DIST)' \ + --appname '$(MOZ_APP_NAME)' \ + --purge-old \ + '$(ABS_DIST)' +else +INNER_MAKE_GECKOLIBS_AAR=echo 'Android geckolibs.aar packaging requires packaging geckoview' +endif # MOZ_DISABLE_GECKOVIEW +else +INNER_MAKE_GECKOLIBS_AAR=echo 'Android geckolibs.aar packaging is disabled' +endif # MOZ_ANDROID_GECKOLIBS_AAR + +ifdef MOZ_OMX_PLUGIN +DIST_FILES += libomxplugin.so libomxplugingb.so libomxplugingb235.so \ + libomxpluginhc.so libomxpluginkk.so +endif + +SO_LIBRARIES := $(filter %.so,$(DIST_FILES)) +# These libraries are placed in the assets/$(ANDROID_CPU_ARCH) directory by packager.py. +ASSET_SO_LIBRARIES := $(addprefix assets/$(ANDROID_CPU_ARCH)/,$(filter-out libmozglue.so $(MOZ_CHILD_PROCESS_NAME),$(SO_LIBRARIES))) + +DIST_FILES := $(filter-out $(SO_LIBRARIES),$(DIST_FILES)) +NON_DIST_FILES += libmozglue.so $(MOZ_CHILD_PROCESS_NAME) $(ASSET_SO_LIBRARIES) + +ifdef MOZ_ENABLE_SZIP +# These libraries are szipped in-place in the +# assets/$(ANDROID_CPU_ARCH) directory. +SZIP_LIBRARIES := $(ASSET_SO_LIBRARIES) +endif + +ifndef COMPILE_ENVIRONMENT +# Any Fennec binary libraries we download are already szipped. +ALREADY_SZIPPED=1 +endif + +# Fennec's OMNIJAR_NAME can include a directory; for example, it might +# be "assets/omni.ja". This path specifies where the omni.ja file +# lives in the APK, but should not root the resources it contains +# under assets/ (i.e., resources should not live at chrome://assets/). +# packager.py writes /omni.ja in order to be consistent with the +# layout expected by language repacks. Therefore, we move it to the +# correct path here, in INNER_MAKE_PACKAGE. See comment about +# OMNIJAR_NAME in configure.in. + +# OMNIJAR_DIR is './' for "omni.ja", 'assets/' for "assets/omni.ja". +OMNIJAR_DIR := $(dir $(OMNIJAR_NAME)) +OMNIJAR_NAME := $(notdir $(OMNIJAR_NAME)) + +# We force build an ap_ that does not check dependencies below. +# Language repacks take advantage of this unchecked dependency ap_ to +# insert additional resources (translated strings) into the ap_ +# without the build system's participation. This can do the wrong +# thing if there are resource changes in between build time and +# package time. We try to prevent mismatched resources by erroring +# out if the compiled resource IDs are not the same as the resource +# IDs being packaged. If we're doing a single locale repack, however, +# we don't have a complete object directory, so we can't compare +# resource IDs. + +# A note on the res/ directory. We unzip the ap_ during packaging, +# which produces the res/ directory. This directory is then included +# in the final package. When we unpack (during locale repacks), we +# need to remove the res/ directory because these resources confuse +# the l10n packaging script that updates omni.ja: the script tries to +# localize the contents of the res/ directory, which fails. Instead, +# after the l10n packaging script completes, we build the ap_ +# described above (which includes freshly localized Android resources) +# and the res/ directory is taken from the ap_ as part of the regular +# packaging. + +PKG_SUFFIX = .apk + +INNER_SZIP_LIBRARIES = \ + $(if $(ALREADY_SZIPPED),,$(foreach lib,$(SZIP_LIBRARIES),host/bin/szip $(MOZ_SZIP_FLAGS) $(STAGEPATH)$(MOZ_PKG_DIR)$(_BINPATH)/$(lib) && )) true + +ifdef MOZ_BUILD_MOBILE_ANDROID_WITH_GRADLE +INNER_CHECK_R_TXT=echo 'No R.txt checking for you!' +else +INNER_CHECK_R_TXT=\ + ((test ! -f $(GECKO_APP_AP_PATH)/R.txt && echo "*** Warning: The R.txt that is being packaged might not agree with the R.txt that was built. This is normal during l10n repacks.") || \ + diff $(GECKO_APP_AP_PATH)/R.txt $(GECKO_APP_AP_PATH)/gecko-nodeps/R.txt >/dev/null || \ + (echo "*** Error: The R.txt that was built and the R.txt that is being packaged are not the same. Rebuild mobile/android/base and re-package." && exit 1)) +endif + +# Insert $(STAGEPATH)$(MOZ_PKG_DIR)$(_BINPATH)/classes.dex into +# $(ABS_DIST)/gecko.ap_, producing $(ABS_DIST)/gecko.apk. +INNER_MAKE_APK = \ + ( cd $(STAGEPATH)$(MOZ_PKG_DIR)$(_BINPATH) && \ + unzip -o $(ABS_DIST)/gecko.ap_ && \ + rm $(ABS_DIST)/gecko.ap_ && \ + $(ZIP) -r9D $(ABS_DIST)/gecko.ap_ assets && \ + $(ZIP) $(if $(ALREADY_SZIPPED),-0 ,$(if $(MOZ_ENABLE_SZIP),-0 ))$(ABS_DIST)/gecko.ap_ $(ASSET_SO_LIBRARIES) && \ + $(ZIP) -r9D $(ABS_DIST)/gecko.ap_ $(DIST_FILES) -x $(NON_DIST_FILES) $(SZIP_LIBRARIES) && \ + $(if $(filter-out ./,$(OMNIJAR_DIR)), \ + mkdir -p $(OMNIJAR_DIR) && mv $(OMNIJAR_NAME) $(OMNIJAR_DIR) && ) \ + $(ZIP) -0 $(ABS_DIST)/gecko.ap_ $(OMNIJAR_DIR)$(OMNIJAR_NAME)) && \ + rm -f $(ABS_DIST)/gecko.apk && \ + cp $(ABS_DIST)/gecko.ap_ $(ABS_DIST)/gecko.apk && \ + $(ZIP) -j0 $(ABS_DIST)/gecko.apk $(STAGEPATH)$(MOZ_PKG_DIR)$(_BINPATH)/classes.dex && \ + cp $(ABS_DIST)/gecko.apk $(ABS_DIST)/gecko-unsigned-unaligned.apk && \ + $(RELEASE_JARSIGNER) $(ABS_DIST)/gecko.apk && \ + $(ZIPALIGN) -f -v 4 $(ABS_DIST)/gecko.apk $(PACKAGE) + +ifeq ($(MOZ_BUILD_APP),mobile/android) +INNER_MAKE_PACKAGE = \ + $(INNER_SZIP_LIBRARIES) && \ + make -C $(GECKO_APP_AP_PATH) gecko-nodeps.ap_ && \ + cp $(GECKO_APP_AP_PATH)/gecko-nodeps.ap_ $(ABS_DIST)/gecko.ap_ && \ + $(INNER_CHECK_R_TXT) && \ + $(INNER_MAKE_APK) && \ + $(INNER_ROBOCOP_PACKAGE) && \ + $(INNER_INSTALL_BOUNCER_PACKAGE) && \ + $(INNER_MAKE_GECKOLIBS_AAR) && \ + $(INNER_MAKE_GECKOVIEW_LIBRARY) +endif + +ifeq ($(MOZ_BUILD_APP),mobile/android/b2gdroid) +INNER_MAKE_PACKAGE = \ + $(INNER_SZIP_LIBRARIES) && \ + cp $(topobjdir)/mobile/android/b2gdroid/app/classes.dex $(ABS_DIST)/classes.dex && \ + cp $(topobjdir)/mobile/android/b2gdroid/app/b2gdroid-unsigned-unaligned.apk $(ABS_DIST)/gecko.ap_ && \ + $(INNER_MAKE_APK) +endif + +# Language repacks root the resources contained in assets/omni.ja +# under assets/, but the repacks expect them to be rooted at /. +# Therefore, we we move the omnijar back to / so the resources are +# under the root here, in INNER_UNMAKE_PACKAGE. See comments about +# OMNIJAR_NAME earlier in this file and in configure.in. + +INNER_UNMAKE_PACKAGE = \ + mkdir $(MOZ_PKG_DIR) && \ + ( cd $(MOZ_PKG_DIR) && \ + $(UNZIP) $(UNPACKAGE) && \ + rm -rf res \ + $(if $(filter-out ./,$(OMNIJAR_DIR)), \ + && mv $(OMNIJAR_DIR)$(OMNIJAR_NAME) $(OMNIJAR_NAME)) ) diff --git a/toolkit/mozapps/installer/upload-files.mk b/toolkit/mozapps/installer/upload-files.mk index fb331d0b22d..66448097314 100644 --- a/toolkit/mozapps/installer/upload-files.mk +++ b/toolkit/mozapps/installer/upload-files.mk @@ -252,294 +252,7 @@ endif #Create an RPM file ifeq ($(MOZ_PKG_FORMAT),APK) - -include $(MOZILLA_DIR)/config/android-common.mk - -DIST_FILES = - -# Place the files in the order they are going to be opened by the linker -ifndef MOZ_FOLD_LIBS -DIST_FILES += \ - libnspr4.so \ - libplc4.so \ - libplds4.so \ - libmozsqlite3.so \ - libnssutil3.so \ - $(NULL) -endif -DIST_FILES += libnss3.so -ifndef MOZ_FOLD_LIBS -DIST_FILES += \ - libssl3.so \ - libsmime3.so \ - $(NULL) -endif -DIST_FILES += \ - liblgpllibs.so \ - libxul.so \ - libnssckbi.so \ - libfreebl3.so \ - libsoftokn3.so \ - resources.arsc \ - AndroidManifest.xml \ - chrome \ - components \ - defaults \ - modules \ - hyphenation \ - res \ - lib \ - extensions \ - application.ini \ - package-name.txt \ - ua-update.json \ - platform.ini \ - greprefs.js \ - browserconfig.properties \ - blocklist.xml \ - chrome.manifest \ - update.locale \ - removed-files \ - $(NULL) - -NON_DIST_FILES = \ - classes.dex \ - $(NULL) - -UPLOAD_EXTRA_FILES += gecko-unsigned-unaligned.apk - -DIST_FILES += $(MOZ_CHILD_PROCESS_NAME) - -GECKO_APP_AP_PATH = $(topobjdir)/mobile/android/base - -ifdef ENABLE_TESTS -INNER_ROBOCOP_PACKAGE=true -ifeq ($(MOZ_BUILD_APP),mobile/android) -UPLOAD_EXTRA_FILES += robocop.apk -UPLOAD_EXTRA_FILES += fennec_ids.txt -UPLOAD_EXTRA_FILES += geckoview_library/geckoview_library.zip -UPLOAD_EXTRA_FILES += geckoview_library/geckoview_assets.zip - -# Robocop/Robotium tests, Android Background tests, and Fennec need to -# be signed with the same key, which means release signing them all. - -ifndef MOZ_BUILD_MOBILE_ANDROID_WITH_GRADLE -robocop_apk := $(topobjdir)/mobile/android/tests/browser/robocop/robocop-debug-unsigned-unaligned.apk -else -robocop_apk := $(topobjdir)/gradle/build/mobile/android/app/outputs/apk/app-automation-debug-androidTest-unaligned.apk -endif - -# Normally, $(NSINSTALL) would be used instead of cp, but INNER_ROBOCOP_PACKAGE -# is used in a series of commands that run under a "cd something", while -# $(NSINSTALL) is relative. -INNER_ROBOCOP_PACKAGE= \ - cp $(GECKO_APP_AP_PATH)/fennec_ids.txt $(ABS_DIST) && \ - $(call RELEASE_SIGN_ANDROID_APK,$(robocop_apk),$(ABS_DIST)/robocop.apk) -endif -else -INNER_ROBOCOP_PACKAGE=echo 'Testing is disabled - No Android Robocop for you' -endif - -ifdef MOZ_ANDROID_PACKAGE_INSTALL_BOUNCER -INNER_INSTALL_BOUNCER_PACKAGE=true -ifdef ENABLE_TESTS -UPLOAD_EXTRA_FILES += bouncer.apk - -bouncer_package=$(ABS_DIST)/bouncer.apk - -# Package and release sign the install bouncer APK. This assumes that the main -# APK (that is, $(PACKAGE)) has already been produced, and verifies that the -# bouncer APK and the main APK define the same set of permissions. The -# intention is to avoid permission-related surprises when bouncing to the -# installation process in the Play Store. N.b.: sort -u is Posix and saves -# invoking uniq separately. diff -u is *not* Posix, so we only add -c. -INNER_INSTALL_BOUNCER_PACKAGE=\ - $(call RELEASE_SIGN_ANDROID_APK,$(topobjdir)/mobile/android/bouncer/bouncer-unsigned-unaligned.apk,$(bouncer_package)) && \ - ($(AAPT) dump permissions $(PACKAGE) | sort -u > $(PACKAGE).permissions && \ - $(AAPT) dump permissions $(bouncer_package) | sort -u > $(bouncer_package).permissions && \ - diff -c $(PACKAGE).permissions $(bouncer_package).permissions || \ - (echo "*** Error: The permissions of the bouncer package differ from the permissions of the main package. Ensure the bouncer and main package Android manifests agree, rebuild mobile/android, and re-package." && exit 1)) -else -INNER_INSTALL_BOUNCER_PACKAGE=echo 'Testing is disabled, so the install bouncer is disabled - No trampolines for you' -endif # ENABLE_TESTS -else -INNER_INSTALL_BOUNCER_PACKAGE=echo 'Install bouncer is disabled - No trampolines for you' -endif # MOZ_ANDROID_PACKAGE_INSTALL_BOUNCER - -# Create geckoview_library/geckoview_{assets,library}.zip for third-party GeckoView consumers. -ifdef NIGHTLY_BUILD -ifndef MOZ_DISABLE_GECKOVIEW -INNER_MAKE_GECKOVIEW_LIBRARY= \ - $(MAKE) -C ../mobile/android/geckoview_library package -else -INNER_MAKE_GECKOVIEW_LIBRARY=echo 'GeckoView library packaging is disabled' -endif -else -INNER_MAKE_GECKOVIEW_LIBRARY=echo 'GeckoView library packaging is only enabled on Nightly' -endif - -# Create Android ARchives and metadata for download by local -# developers using Gradle. -ifdef MOZ_ANDROID_GECKOLIBS_AAR -ifndef MOZ_DISABLE_GECKOVIEW -geckoaar-revision := $(BUILDID) - -UPLOAD_EXTRA_FILES += \ - geckolibs-$(geckoaar-revision).aar \ - geckolibs-$(geckoaar-revision).aar.sha1 \ - geckolibs-$(geckoaar-revision).pom \ - geckolibs-$(geckoaar-revision).pom.sha1 \ - ivy-geckolibs-$(geckoaar-revision).xml \ - ivy-geckolibs-$(geckoaar-revision).xml.sha1 \ - geckoview-$(geckoaar-revision).aar \ - geckoview-$(geckoaar-revision).aar.sha1 \ - geckoview-$(geckoaar-revision).pom \ - geckoview-$(geckoaar-revision).pom.sha1 \ - ivy-geckoview-$(geckoaar-revision).xml \ - ivy-geckoview-$(geckoaar-revision).xml.sha1 \ - $(NULL) - -INNER_MAKE_GECKOLIBS_AAR= \ - $(PYTHON) -m mozbuild.action.package_geckolibs_aar \ - --verbose \ - --revision $(geckoaar-revision) \ - --topsrcdir '$(topsrcdir)' \ - --distdir '$(ABS_DIST)' \ - --appname '$(MOZ_APP_NAME)' \ - --purge-old \ - '$(ABS_DIST)' -else -INNER_MAKE_GECKOLIBS_AAR=echo 'Android geckolibs.aar packaging requires packaging geckoview' -endif # MOZ_DISABLE_GECKOVIEW -else -INNER_MAKE_GECKOLIBS_AAR=echo 'Android geckolibs.aar packaging is disabled' -endif # MOZ_ANDROID_GECKOLIBS_AAR - -ifdef MOZ_OMX_PLUGIN -DIST_FILES += libomxplugin.so libomxplugingb.so libomxplugingb235.so \ - libomxpluginhc.so libomxpluginkk.so -endif - -SO_LIBRARIES := $(filter %.so,$(DIST_FILES)) -# These libraries are placed in the assets/$(ANDROID_CPU_ARCH) directory by packager.py. -ASSET_SO_LIBRARIES := $(addprefix assets/$(ANDROID_CPU_ARCH)/,$(filter-out libmozglue.so $(MOZ_CHILD_PROCESS_NAME),$(SO_LIBRARIES))) - -DIST_FILES := $(filter-out $(SO_LIBRARIES),$(DIST_FILES)) -NON_DIST_FILES += libmozglue.so $(MOZ_CHILD_PROCESS_NAME) $(ASSET_SO_LIBRARIES) - -ifdef MOZ_ENABLE_SZIP -# These libraries are szipped in-place in the -# assets/$(ANDROID_CPU_ARCH) directory. -SZIP_LIBRARIES := $(ASSET_SO_LIBRARIES) -endif - -ifndef COMPILE_ENVIRONMENT -# Any Fennec binary libraries we download are already szipped. -ALREADY_SZIPPED=1 -endif - -# Fennec's OMNIJAR_NAME can include a directory; for example, it might -# be "assets/omni.ja". This path specifies where the omni.ja file -# lives in the APK, but should not root the resources it contains -# under assets/ (i.e., resources should not live at chrome://assets/). -# packager.py writes /omni.ja in order to be consistent with the -# layout expected by language repacks. Therefore, we move it to the -# correct path here, in INNER_MAKE_PACKAGE. See comment about -# OMNIJAR_NAME in configure.in. - -# OMNIJAR_DIR is './' for "omni.ja", 'assets/' for "assets/omni.ja". -OMNIJAR_DIR := $(dir $(OMNIJAR_NAME)) -OMNIJAR_NAME := $(notdir $(OMNIJAR_NAME)) - -# We force build an ap_ that does not check dependencies below. -# Language repacks take advantage of this unchecked dependency ap_ to -# insert additional resources (translated strings) into the ap_ -# without the build system's participation. This can do the wrong -# thing if there are resource changes in between build time and -# package time. We try to prevent mismatched resources by erroring -# out if the compiled resource IDs are not the same as the resource -# IDs being packaged. If we're doing a single locale repack, however, -# we don't have a complete object directory, so we can't compare -# resource IDs. - -# A note on the res/ directory. We unzip the ap_ during packaging, -# which produces the res/ directory. This directory is then included -# in the final package. When we unpack (during locale repacks), we -# need to remove the res/ directory because these resources confuse -# the l10n packaging script that updates omni.ja: the script tries to -# localize the contents of the res/ directory, which fails. Instead, -# after the l10n packaging script completes, we build the ap_ -# described above (which includes freshly localized Android resources) -# and the res/ directory is taken from the ap_ as part of the regular -# packaging. - -PKG_SUFFIX = .apk - -INNER_SZIP_LIBRARIES = \ - $(if $(ALREADY_SZIPPED),,$(foreach lib,$(SZIP_LIBRARIES),host/bin/szip $(MOZ_SZIP_FLAGS) $(STAGEPATH)$(MOZ_PKG_DIR)$(_BINPATH)/$(lib) && )) true - -ifdef MOZ_BUILD_MOBILE_ANDROID_WITH_GRADLE -INNER_CHECK_R_TXT=echo 'No R.txt checking for you!' -else -INNER_CHECK_R_TXT=\ - ((test ! -f $(GECKO_APP_AP_PATH)/R.txt && echo "*** Warning: The R.txt that is being packaged might not agree with the R.txt that was built. This is normal during l10n repacks.") || \ - diff $(GECKO_APP_AP_PATH)/R.txt $(GECKO_APP_AP_PATH)/gecko-nodeps/R.txt >/dev/null || \ - (echo "*** Error: The R.txt that was built and the R.txt that is being packaged are not the same. Rebuild mobile/android/base and re-package." && exit 1)) -endif - -# Insert $(STAGEPATH)$(MOZ_PKG_DIR)$(_BINPATH)/classes.dex into -# $(ABS_DIST)/gecko.ap_, producing $(ABS_DIST)/gecko.apk. -INNER_MAKE_APK = \ - ( cd $(STAGEPATH)$(MOZ_PKG_DIR)$(_BINPATH) && \ - unzip -o $(ABS_DIST)/gecko.ap_ && \ - rm $(ABS_DIST)/gecko.ap_ && \ - $(ZIP) -r9D $(ABS_DIST)/gecko.ap_ assets && \ - $(ZIP) $(if $(ALREADY_SZIPPED),-0 ,$(if $(MOZ_ENABLE_SZIP),-0 ))$(ABS_DIST)/gecko.ap_ $(ASSET_SO_LIBRARIES) && \ - $(ZIP) -r9D $(ABS_DIST)/gecko.ap_ $(DIST_FILES) -x $(NON_DIST_FILES) $(SZIP_LIBRARIES) && \ - $(if $(filter-out ./,$(OMNIJAR_DIR)), \ - mkdir -p $(OMNIJAR_DIR) && mv $(OMNIJAR_NAME) $(OMNIJAR_DIR) && ) \ - $(ZIP) -0 $(ABS_DIST)/gecko.ap_ $(OMNIJAR_DIR)$(OMNIJAR_NAME)) && \ - rm -f $(ABS_DIST)/gecko.apk && \ - cp $(ABS_DIST)/gecko.ap_ $(ABS_DIST)/gecko.apk && \ - $(ZIP) -j0 $(ABS_DIST)/gecko.apk $(STAGEPATH)$(MOZ_PKG_DIR)$(_BINPATH)/classes.dex && \ - cp $(ABS_DIST)/gecko.apk $(ABS_DIST)/gecko-unsigned-unaligned.apk && \ - $(RELEASE_JARSIGNER) $(ABS_DIST)/gecko.apk && \ - $(ZIPALIGN) -f -v 4 $(ABS_DIST)/gecko.apk $(PACKAGE) - -ifeq ($(MOZ_BUILD_APP),mobile/android) -INNER_MAKE_PACKAGE = \ - $(INNER_SZIP_LIBRARIES) && \ - make -C $(GECKO_APP_AP_PATH) gecko-nodeps.ap_ && \ - cp $(GECKO_APP_AP_PATH)/gecko-nodeps.ap_ $(ABS_DIST)/gecko.ap_ && \ - $(INNER_CHECK_R_TXT) && \ - $(INNER_MAKE_APK) && \ - $(INNER_ROBOCOP_PACKAGE) && \ - $(INNER_INSTALL_BOUNCER_PACKAGE) && \ - $(INNER_MAKE_GECKOLIBS_AAR) && \ - $(INNER_MAKE_GECKOVIEW_LIBRARY) -endif - -ifeq ($(MOZ_BUILD_APP),mobile/android/b2gdroid) -INNER_MAKE_PACKAGE = \ - $(INNER_SZIP_LIBRARIES) && \ - cp $(topobjdir)/mobile/android/b2gdroid/app/classes.dex $(ABS_DIST)/classes.dex && \ - cp $(topobjdir)/mobile/android/b2gdroid/app/b2gdroid-unsigned-unaligned.apk $(ABS_DIST)/gecko.ap_ && \ - $(INNER_MAKE_APK) -endif - -# Language repacks root the resources contained in assets/omni.ja -# under assets/, but the repacks expect them to be rooted at /. -# Therefore, we we move the omnijar back to / so the resources are -# under the root here, in INNER_UNMAKE_PACKAGE. See comments about -# OMNIJAR_NAME earlier in this file and in configure.in. - -INNER_UNMAKE_PACKAGE = \ - mkdir $(MOZ_PKG_DIR) && \ - ( cd $(MOZ_PKG_DIR) && \ - $(UNZIP) $(UNPACKAGE) && \ - rm -rf res \ - $(if $(filter-out ./,$(OMNIJAR_DIR)), \ - && mv $(OMNIJAR_DIR)$(OMNIJAR_NAME) $(OMNIJAR_NAME)) ) +include $(MOZILLA_DIR)/toolkit/mozapps/installer/upload-files-$(MOZ_PKG_FORMAT).mk endif ifeq ($(MOZ_PKG_FORMAT),DMG) From 0016aabac5bc2390bd2c51f0470c9ea38e8cdae9 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Thu, 3 Mar 2016 09:21:49 +1100 Subject: [PATCH 154/160] Bug 1252790 - Remove RuleHashTableOps. r=dbaron. It's a confusing and non-standard way of doing things. --- layout/style/nsCSSRuleProcessor.cpp | 157 ++++++++++++---------------- 1 file changed, 65 insertions(+), 92 deletions(-) diff --git a/layout/style/nsCSSRuleProcessor.cpp b/layout/style/nsCSSRuleProcessor.cpp index e43d5cf4723..f9805b8de50 100644 --- a/layout/style/nsCSSRuleProcessor.cpp +++ b/layout/style/nsCSSRuleProcessor.cpp @@ -195,58 +195,70 @@ RuleHash_CIHashKey(PLDHashTable *table, const void *key) return HashString(str); } -typedef nsIAtom* -(* RuleHashGetKey) (PLDHashTable *table, const PLDHashEntryHdr *entry); - -struct RuleHashTableOps { - const PLDHashTableOps ops; - // Extra callback to avoid duplicating the matchEntry callback for - // each table. (There used to be a getKey callback in - // PLDHashTableOps.) - RuleHashGetKey getKey; -}; - -inline const RuleHashTableOps* -ToLocalOps(const PLDHashTableOps *aOps) +static inline nsCSSSelector* +SubjectSelectorForRuleHash(const PLDHashEntryHdr *hdr) { - return (const RuleHashTableOps*) - (((const char*) aOps) - offsetof(RuleHashTableOps, ops)); + auto entry = static_cast(hdr); + nsCSSSelector* selector = entry->mRules[0].mSelector; + if (selector->IsPseudoElement()) { + selector = selector->mNext; + } + return selector; } -static bool -RuleHash_CIMatchEntry(PLDHashTable *table, const PLDHashEntryHdr *hdr, - const void *key) +static inline bool +CIMatchAtoms(const void* key, nsIAtom *entry_atom) { - nsIAtom *match_atom = const_cast(static_cast - (key)); - // Use our extra |getKey| callback to avoid code duplication. - nsIAtom *entry_atom = ToLocalOps(table->Ops())->getKey(table, hdr); + auto match_atom = const_cast(static_cast(key)); // Check for case-sensitive match first. - if (match_atom == entry_atom) + if (match_atom == entry_atom) { return true; + } // Use EqualsIgnoreASCIICase instead of full on unicode case conversion // in order to save on performance. This is only used in quirks mode // anyway. - return nsContentUtils::EqualsIgnoreASCIICase(nsDependentAtomString(entry_atom), nsDependentAtomString(match_atom)); } -static bool -RuleHash_CSMatchEntry(PLDHashTable *table, const PLDHashEntryHdr *hdr, - const void *key) +static inline bool +CSMatchAtoms(const void* key, nsIAtom *entry_atom) { - nsIAtom *match_atom = const_cast(static_cast - (key)); - // Use our extra |getKey| callback to avoid code duplication. - nsIAtom *entry_atom = ToLocalOps(table->Ops())->getKey(table, hdr); - + auto match_atom = const_cast(static_cast(key)); return match_atom == entry_atom; } +static bool +RuleHash_ClassCIMatchEntry(PLDHashTable *table, const PLDHashEntryHdr *hdr, + const void *key) +{ + return CIMatchAtoms(key, SubjectSelectorForRuleHash(hdr)->mClassList->mAtom); +} + +static bool +RuleHash_IdCIMatchEntry(PLDHashTable *table, const PLDHashEntryHdr *hdr, + const void *key) +{ + return CIMatchAtoms(key, SubjectSelectorForRuleHash(hdr)->mIDList->mAtom); +} + +static bool +RuleHash_ClassCSMatchEntry(PLDHashTable *table, const PLDHashEntryHdr *hdr, + const void *key) +{ + return CSMatchAtoms(key, SubjectSelectorForRuleHash(hdr)->mClassList->mAtom); +} + +static bool +RuleHash_IdCSMatchEntry(PLDHashTable *table, const PLDHashEntryHdr *hdr, + const void *key) +{ + return CSMatchAtoms(key, SubjectSelectorForRuleHash(hdr)->mIDList->mAtom); +} + static void RuleHash_InitEntry(PLDHashEntryHdr *hdr, const void *key) { @@ -278,8 +290,7 @@ static bool RuleHash_TagTable_MatchEntry(PLDHashTable *table, const PLDHashEntryHdr *hdr, const void *key) { - nsIAtom *match_atom = const_cast(static_cast - (key)); + nsIAtom *match_atom = const_cast(static_cast(key)); nsIAtom *entry_atom = static_cast(hdr)->mTag; return match_atom == entry_atom; @@ -314,30 +325,6 @@ RuleHash_TagTable_MoveEntry(PLDHashTable *table, const PLDHashEntryHdr *from, oldEntry->~RuleHashTagTableEntry(); } -static nsIAtom* -RuleHash_ClassTable_GetKey(PLDHashTable *table, const PLDHashEntryHdr *hdr) -{ - const RuleHashTableEntry *entry = - static_cast(hdr); - nsCSSSelector* selector = entry->mRules[0].mSelector; - if (selector->IsPseudoElement()) { - selector = selector->mNext; - } - return selector->mClassList->mAtom; -} - -static nsIAtom* -RuleHash_IdTable_GetKey(PLDHashTable *table, const PLDHashEntryHdr *hdr) -{ - const RuleHashTableEntry *entry = - static_cast(hdr); - nsCSSSelector* selector = entry->mRules[0].mSelector; - if (selector->IsPseudoElement()) { - selector = selector->mNext; - } - return selector->mIDList->mAtom; -} - static PLDHashNumber RuleHash_NameSpaceTable_HashKey(PLDHashTable *table, const void *key) { @@ -368,51 +355,39 @@ static const PLDHashTableOps RuleHash_TagTable_Ops = { }; // Case-sensitive ops. -static const RuleHashTableOps RuleHash_ClassTable_CSOps = { - { +static const PLDHashTableOps RuleHash_ClassTable_CSOps = { PLDHashTable::HashVoidPtrKeyStub, - RuleHash_CSMatchEntry, + RuleHash_ClassCSMatchEntry, RuleHash_MoveEntry, RuleHash_ClearEntry, RuleHash_InitEntry - }, - RuleHash_ClassTable_GetKey }; // Case-insensitive ops. -static const RuleHashTableOps RuleHash_ClassTable_CIOps = { - { +static const PLDHashTableOps RuleHash_ClassTable_CIOps = { RuleHash_CIHashKey, - RuleHash_CIMatchEntry, + RuleHash_ClassCIMatchEntry, RuleHash_MoveEntry, RuleHash_ClearEntry, RuleHash_InitEntry - }, - RuleHash_ClassTable_GetKey }; // Case-sensitive ops. -static const RuleHashTableOps RuleHash_IdTable_CSOps = { - { +static const PLDHashTableOps RuleHash_IdTable_CSOps = { PLDHashTable::HashVoidPtrKeyStub, - RuleHash_CSMatchEntry, + RuleHash_IdCSMatchEntry, RuleHash_MoveEntry, RuleHash_ClearEntry, RuleHash_InitEntry - }, - RuleHash_IdTable_GetKey }; // Case-insensitive ops. -static const RuleHashTableOps RuleHash_IdTable_CIOps = { - { +static const PLDHashTableOps RuleHash_IdTable_CIOps = { RuleHash_CIHashKey, - RuleHash_CIMatchEntry, + RuleHash_IdCIMatchEntry, RuleHash_MoveEntry, RuleHash_ClearEntry, RuleHash_InitEntry - }, - RuleHash_IdTable_GetKey }; static const PLDHashTableOps RuleHash_NameSpaceTable_Ops = { @@ -492,11 +467,11 @@ protected: RuleHash::RuleHash(bool aQuirksMode) : mRuleCount(0), - mIdTable(aQuirksMode ? &RuleHash_IdTable_CIOps.ops - : &RuleHash_IdTable_CSOps.ops, + mIdTable(aQuirksMode ? &RuleHash_IdTable_CIOps + : &RuleHash_IdTable_CSOps, sizeof(RuleHashTableEntry)), - mClassTable(aQuirksMode ? &RuleHash_ClassTable_CIOps.ops - : &RuleHash_ClassTable_CSOps.ops, + mClassTable(aQuirksMode ? &RuleHash_ClassTable_CIOps + : &RuleHash_ClassTable_CSOps, sizeof(RuleHashTableEntry)), mTagTable(&RuleHash_TagTable_Ops, sizeof(RuleHashTagTableEntry)), mNameSpaceTable(&RuleHash_NameSpaceTable_Ops, sizeof(RuleHashTableEntry)), @@ -842,11 +817,12 @@ AtomSelector_MoveEntry(PLDHashTable *table, const PLDHashEntryHdr *from, oldEntry->~AtomSelectorEntry(); } -static nsIAtom* -AtomSelector_GetKey(PLDHashTable *table, const PLDHashEntryHdr *hdr) +static bool +AtomSelector_CIMatchEntry(PLDHashTable *table, const PLDHashEntryHdr *hdr, + const void *key) { const AtomSelectorEntry *entry = static_cast(hdr); - return entry->mAtom; + return CIMatchAtoms(key, entry->mAtom); } // Case-sensitive ops. @@ -859,15 +835,12 @@ static const PLDHashTableOps AtomSelector_CSOps = { }; // Case-insensitive ops. -static const RuleHashTableOps AtomSelector_CIOps = { - { +static const PLDHashTableOps AtomSelector_CIOps = { RuleHash_CIHashKey, - RuleHash_CIMatchEntry, + AtomSelector_CIMatchEntry, AtomSelector_MoveEntry, AtomSelector_ClearEntry, AtomSelector_InitEntry - }, - AtomSelector_GetKey }; //-------------------------------- @@ -877,10 +850,10 @@ struct RuleCascadeData { : mRuleHash(aQuirksMode), mStateSelectors(), mSelectorDocumentStates(0), - mClassSelectors(aQuirksMode ? &AtomSelector_CIOps.ops + mClassSelectors(aQuirksMode ? &AtomSelector_CIOps : &AtomSelector_CSOps, sizeof(AtomSelectorEntry)), - mIdSelectors(aQuirksMode ? &AtomSelector_CIOps.ops + mIdSelectors(aQuirksMode ? &AtomSelector_CIOps : &AtomSelector_CSOps, sizeof(AtomSelectorEntry)), // mAttributeSelectors is matching on the attribute _name_, not the From 34b70fe573e74a842b707656ffde7d5098d718d4 Mon Sep 17 00:00:00 2001 From: Kim Moir Date: Wed, 2 Mar 2016 16:36:31 -0500 Subject: [PATCH 155/160] Bug 1252908 - [beetmover] refresh AV database on every run r=rail a=testing DONTBUILD MozReview-Commit-ID: Ceo1dF3tyVS --- release/docker/beet-mover/Dockerfile | 2 ++ release/docker/beet-mover/requirements.txt | 2 ++ testing/mozharness/scripts/release/beet_mover.py | 6 ++++++ 3 files changed, 10 insertions(+) create mode 100644 release/docker/beet-mover/requirements.txt diff --git a/release/docker/beet-mover/Dockerfile b/release/docker/beet-mover/Dockerfile index f109c0e247d..fd260cdc51c 100644 --- a/release/docker/beet-mover/Dockerfile +++ b/release/docker/beet-mover/Dockerfile @@ -16,4 +16,6 @@ RUN apt-get -q update \ wget \ && apt-get clean +COPY requirements.txt /tmp/ +RUN pip install -r /tmp/requirements.txt RUN freshclam --verbose diff --git a/release/docker/beet-mover/requirements.txt b/release/docker/beet-mover/requirements.txt new file mode 100644 index 00000000000..b4f746aa9a4 --- /dev/null +++ b/release/docker/beet-mover/requirements.txt @@ -0,0 +1,2 @@ +sh +redo diff --git a/testing/mozharness/scripts/release/beet_mover.py b/testing/mozharness/scripts/release/beet_mover.py index d71885599bf..a11ec01a71b 100755 --- a/testing/mozharness/scripts/release/beet_mover.py +++ b/testing/mozharness/scripts/release/beet_mover.py @@ -15,6 +15,8 @@ import pprint import re from os import listdir from os.path import isfile, join +import sh +import redo sys.path.insert(1, os.path.dirname(os.path.dirname(sys.path[0]))) from mozharness.base.log import FATAL @@ -309,6 +311,10 @@ class BeetMover(BaseScript, VirtualenvMixin, object): def _scan_files(self): """Scan the files we've collected. We do the download and scan concurrently to make it easier to have a coherent log afterwards. Uses the venv python.""" + self.info("Refreshing clamav db...") + redo.retry(lambda: + sh.freshclam("--stdout", "--verbose", _timeout=300, _err_to_out=True)) + self.info("Done.") external_tools_path = os.path.join( os.path.abspath(os.path.dirname(os.path.dirname(mozharness.__file__))), 'external_tools') self.run_command([self.query_python_path(), os.path.join(external_tools_path,'extract_and_run_command.py'), From 0c8498c977aacc0839fd35e68c2cc015f9869fb7 Mon Sep 17 00:00:00 2001 From: Chris Pearce Date: Thu, 3 Mar 2016 11:02:17 +1300 Subject: [PATCH 156/160] Bug 1252168 - Don't send CDM unsupported notifications from Gecko to chrome. r=kentuckyfriedtakahe MozReview-Commit-ID: FDfpeEt3HfT --- dom/media/eme/MediaKeySystemAccess.cpp | 6 ++++++ dom/media/test/test_eme_request_notifications.html | 5 ----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/dom/media/eme/MediaKeySystemAccess.cpp b/dom/media/eme/MediaKeySystemAccess.cpp index bac3fdfb637..46f114e4fc6 100644 --- a/dom/media/eme/MediaKeySystemAccess.cpp +++ b/dom/media/eme/MediaKeySystemAccess.cpp @@ -577,6 +577,12 @@ MediaKeySystemAccess::NotifyObservers(nsPIDOMWindowInner* aWindow, const nsAString& aKeySystem, MediaKeySystemStatus aStatus) { + if (aStatus == MediaKeySystemStatus::Cdm_not_supported) { + // Ignore, since there's nothing the user can do to rectify this, and we + // don't want the prompt to confuse them. + // TODO: Remove places that call with this entirely. + return; + } RequestMediaKeySystemAccessNotification data; data.mKeySystem = aKeySystem; data.mStatus = aStatus; diff --git a/dom/media/test/test_eme_request_notifications.html b/dom/media/test/test_eme_request_notifications.html index 91c38400b1a..06c4e3cf516 100644 --- a/dom/media/test/test_eme_request_notifications.html +++ b/dom/media/test/test_eme_request_notifications.html @@ -74,11 +74,6 @@ var tests = [ expectedStatus: 'cdm-disabled', prefs: [["media.eme.enabled", true], ["media.eme.clearkey.enabled", false]] }, - { - keySystem: 'unsupported-keysystem', - shouldPass: false, - expectedStatus: 'cdm-not-supported' - }, { keySystem: CLEARKEY_ID + '.10000' , // A stupendously high min CDM version, presumably not installed. shouldPass: false, From 314f13a438550d456ba148c62ad0fd0c8b8bf65d Mon Sep 17 00:00:00 2001 From: Ryan VanderMeulen Date: Tue, 1 Mar 2016 16:13:49 -0500 Subject: [PATCH 157/160] Bug 1252348 - Skip the dom/canvas mochitests on OSX debug e10s. --- dom/canvas/test/crossorigin/mochitest.ini | 1 + dom/canvas/test/mochitest.ini | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/dom/canvas/test/crossorigin/mochitest.ini b/dom/canvas/test/crossorigin/mochitest.ini index 0903fd9cd32..547e2849263 100644 --- a/dom/canvas/test/crossorigin/mochitest.ini +++ b/dom/canvas/test/crossorigin/mochitest.ini @@ -1,4 +1,5 @@ [DEFAULT] +skip-if = e10s && debug && os == 'mac' # Bug 1252348 support-files = image-allow-credentials.png image-allow-credentials.png^headers^ diff --git a/dom/canvas/test/mochitest.ini b/dom/canvas/test/mochitest.ini index f42d52f2fb3..52eb291c4e6 100644 --- a/dom/canvas/test/mochitest.ini +++ b/dom/canvas/test/mochitest.ini @@ -1,5 +1,5 @@ [DEFAULT] -skip-if = e10s && debug && os == 'win' # Bug 1252677 +skip-if = e10s && debug && (os == 'win' || os == 'mac') # Bug 1252677 for Windows, Bug 1252348 for Mac support-files = android.json file_drawImage_document_domain.html From c4cfde66e90ff85f946494394909669ffaa17111 Mon Sep 17 00:00:00 2001 From: Ryan VanderMeulen Date: Wed, 2 Mar 2016 21:44:18 -0500 Subject: [PATCH 158/160] Bug 1253037 - Skip browser_net_sort-01.js on OSX debug e10s. --- devtools/client/netmonitor/test/browser.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/devtools/client/netmonitor/test/browser.ini b/devtools/client/netmonitor/test/browser.ini index 2c48a6f8eac..86378d2cd54 100644 --- a/devtools/client/netmonitor/test/browser.ini +++ b/devtools/client/netmonitor/test/browser.ini @@ -114,6 +114,7 @@ skip-if = e10s # Bug 1091612 [browser_net_simple-request-details.js] [browser_net_simple-request.js] [browser_net_sort-01.js] +skip-if = (e10s && debug && os == 'mac') # Bug 1253037 [browser_net_sort-02.js] [browser_net_sort-03.js] [browser_net_statistics-01.js] From 9095d747e45bbbfc74902bf4196fbf8a59d6b412 Mon Sep 17 00:00:00 2001 From: Ryan VanderMeulen Date: Tue, 1 Mar 2016 16:56:41 -0500 Subject: [PATCH 159/160] Bug 1252630 - Move the asyncPan skip-if for APZ reftests to the manifest level instead of per-test. r=kats --- gfx/layers/apz/test/reftest/reftest.list | 12 ++-- layout/reftests/async-scrolling/reftest.list | 62 ++++++++++---------- layout/reftests/reftest.list | 4 +- 3 files changed, 39 insertions(+), 39 deletions(-) diff --git a/gfx/layers/apz/test/reftest/reftest.list b/gfx/layers/apz/test/reftest/reftest.list index 6fe3cfd2cd7..c09fffa8c9c 100644 --- a/gfx/layers/apz/test/reftest/reftest.list +++ b/gfx/layers/apz/test/reftest/reftest.list @@ -1,11 +1,11 @@ # The following tests test the async positioning of the scrollbars. # Basic root-frame scrollbar with async scrolling -skip-if(!asyncPan) fuzzy-if(Android,6,8) == async-scrollbar-1-v.html async-scrollbar-1-v-ref.html -skip-if(!asyncPan) fuzzy-if(Android,6,8) == async-scrollbar-1-h.html async-scrollbar-1-h-ref.html -skip-if(!asyncPan) fuzzy-if(Android,6,8) == async-scrollbar-1-vh.html async-scrollbar-1-vh-ref.html -skip-if(!asyncPan) fuzzy-if(Android,6,8) == async-scrollbar-1-v-rtl.html async-scrollbar-1-v-rtl-ref.html -skip-if(!asyncPan) fuzzy-if(Android,6,8) == async-scrollbar-1-h-rtl.html async-scrollbar-1-h-rtl-ref.html -skip-if(!asyncPan) fuzzy-if(Android,6,8) == async-scrollbar-1-vh-rtl.html async-scrollbar-1-vh-rtl-ref.html +fuzzy-if(Android,6,8) == async-scrollbar-1-v.html async-scrollbar-1-v-ref.html +fuzzy-if(Android,6,8) == async-scrollbar-1-h.html async-scrollbar-1-h-ref.html +fuzzy-if(Android,6,8) == async-scrollbar-1-vh.html async-scrollbar-1-vh-ref.html +fuzzy-if(Android,6,8) == async-scrollbar-1-v-rtl.html async-scrollbar-1-v-rtl-ref.html +fuzzy-if(Android,6,8) == async-scrollbar-1-h-rtl.html async-scrollbar-1-h-rtl-ref.html +fuzzy-if(Android,6,8) == async-scrollbar-1-vh-rtl.html async-scrollbar-1-vh-rtl-ref.html # Different async zoom levels. Since the scrollthumb gets async-scaled in the # compositor, the border-radius ends of the scrollthumb are going to be a little diff --git a/layout/reftests/async-scrolling/reftest.list b/layout/reftests/async-scrolling/reftest.list index 76f485a34e7..a0da87ff361 100644 --- a/layout/reftests/async-scrolling/reftest.list +++ b/layout/reftests/async-scrolling/reftest.list @@ -1,43 +1,43 @@ -skip-if(!asyncPan) == bg-fixed-1.html bg-fixed-1-ref.html -skip-if(!asyncPan) == bg-fixed-cover-1.html bg-fixed-cover-1-ref.html -skip-if(!asyncPan) == bg-fixed-cover-2.html bg-fixed-cover-2-ref.html -skip-if(!asyncPan) == bg-fixed-cover-3.html bg-fixed-cover-3-ref.html -skip-if(!asyncPan) == bg-fixed-child.html bg-fixed-child-ref.html -skip-if(!asyncPan) == bg-fixed-child-clip-1.html bg-fixed-child-clip-ref.html -skip-if(!asyncPan) == bg-fixed-child-clip-2.html bg-fixed-child-clip-ref.html +== bg-fixed-1.html bg-fixed-1-ref.html +== bg-fixed-cover-1.html bg-fixed-cover-1-ref.html +== bg-fixed-cover-2.html bg-fixed-cover-2-ref.html +== bg-fixed-cover-3.html bg-fixed-cover-3-ref.html +== bg-fixed-child.html bg-fixed-child-ref.html +== bg-fixed-child-clip-1.html bg-fixed-child-clip-ref.html +== bg-fixed-child-clip-2.html bg-fixed-child-clip-ref.html fuzzy(1,246) fuzzy-if(skiaContent,2,160) skip-if(!asyncPan) == bg-fixed-child-mask.html bg-fixed-child-mask-ref.html -skip-if(!asyncPan) == bg-fixed-in-opacity.html bg-fixed-in-opacity-ref.html -skip-if(!asyncPan) == bg-fixed-child-no-culling.html bg-fixed-child-no-culling-ref.html +== bg-fixed-in-opacity.html bg-fixed-in-opacity-ref.html +== bg-fixed-child-no-culling.html bg-fixed-child-no-culling-ref.html fuzzy-if(B2G,2,5366) fuzzy-if(Android,2,4000) skip-if(!asyncPan||((browserIsRemote&&winWidget))) == bg-fixed-transformed-image.html bg-fixed-transformed-image-ref.html -skip-if(!asyncPan) == element-1.html element-1-ref.html -pref(layers.force-active,true) skip-if(!asyncPan) == iframe-1.html iframe-1-ref.html -skip-if(!asyncPan) == nested-1.html nested-1-ref.html -skip-if(!asyncPan) == nested-2.html nested-2-ref.html -skip-if(!asyncPan) == position-fixed-1.html position-fixed-1-ref.html -skip-if(!asyncPan) == position-fixed-2.html position-fixed-2-ref.html -skip-if(!asyncPan) == position-fixed-body.html position-fixed-body-ref.html -skip-if(!asyncPan) == position-fixed-cover-1.html position-fixed-cover-1-ref.html -skip-if(!asyncPan) == position-fixed-cover-2.html position-fixed-cover-2-ref.html -skip-if(!asyncPan) == position-fixed-cover-3.html position-fixed-cover-3-ref.html -skip-if(!asyncPan) fuzzy-if(Android,5,4) == position-fixed-transformed-1.html position-fixed-transformed-1-ref.html -skip-if(!asyncPan) == split-layers-1.html split-layers-1-ref.html -skip-if(!asyncPan) == split-layers-multi-scrolling-1.html split-layers-multi-scrolling-1-ref.html +== element-1.html element-1-ref.html +pref(layers.force-active,true) == iframe-1.html iframe-1-ref.html +== nested-1.html nested-1-ref.html +== nested-2.html nested-2-ref.html +== position-fixed-1.html position-fixed-1-ref.html +== position-fixed-2.html position-fixed-2-ref.html +== position-fixed-body.html position-fixed-body-ref.html +== position-fixed-cover-1.html position-fixed-cover-1-ref.html +== position-fixed-cover-2.html position-fixed-cover-2-ref.html +== position-fixed-cover-3.html position-fixed-cover-3-ref.html +fuzzy-if(Android,5,4) skip-if(!asyncPan) == position-fixed-transformed-1.html position-fixed-transformed-1-ref.html +== split-layers-1.html split-layers-1-ref.html +== split-layers-multi-scrolling-1.html split-layers-multi-scrolling-1-ref.html fuzzy-if(skiaContent,1,32000) skip-if(!asyncPan||(browserIsRemote&&winWidget)) == split-opacity-layers-1.html split-opacity-layers-1-ref.html -skip-if(!asyncPan) == sticky-pos-scrollable-1.html sticky-pos-scrollable-1-ref.html -skip-if(!asyncPan) == fixed-pos-scrollable-1.html fixed-pos-scrollable-1-ref.html -skip-if(!asyncPan) == culling-1.html culling-1-ref.html -skip-if(!asyncPan) == position-fixed-iframe-1.html position-fixed-iframe-1-ref.html -skip-if(!asyncPan) == position-fixed-iframe-2.html position-fixed-iframe-2-ref.html +== sticky-pos-scrollable-1.html sticky-pos-scrollable-1-ref.html +== fixed-pos-scrollable-1.html fixed-pos-scrollable-1-ref.html +== culling-1.html culling-1-ref.html +== position-fixed-iframe-1.html position-fixed-iframe-1-ref.html +== position-fixed-iframe-2.html position-fixed-iframe-2-ref.html fuzzy-if(skiaContent,1,10000) skip-if(!asyncPan) == position-fixed-in-scroll-container.html position-fixed-in-scroll-container-ref.html fuzzy(1,60000) skip-if(!asyncPan) == group-opacity-surface-size-1.html group-opacity-surface-size-1-ref.html -skip-if(!asyncPan) == position-sticky-transformed.html position-sticky-transformed-ref.html +== position-sticky-transformed.html position-sticky-transformed-ref.html # for the following tests, we want to disable the low-precision buffer # as it will expand the displayport beyond what the test specifies in # its reftest-displayport attributes, and interfere with where we expect # checkerboarding to occur default-preferences pref(layers.low-precision-buffer,false) -skip-if(!asyncPan) == checkerboard-1.html checkerboard-1-ref.html -skip-if(!asyncPan) == checkerboard-2.html checkerboard-2-ref.html -skip-if(!asyncPan) == checkerboard-3.html checkerboard-3-ref.html +== checkerboard-1.html checkerboard-1-ref.html +== checkerboard-2.html checkerboard-2-ref.html +== checkerboard-3.html checkerboard-3-ref.html default-preferences diff --git a/layout/reftests/reftest.list b/layout/reftests/reftest.list index a0bc2991a28..92c6d4344e9 100644 --- a/layout/reftests/reftest.list +++ b/layout/reftests/reftest.list @@ -19,7 +19,7 @@ include w3c-css/received/reftest.list include abs-pos/reftest.list include position-relative/reftest.list -include async-scrolling/reftest.list +skip-if(!asyncPan) include async-scrolling/reftest.list # backgrounds/ include backgrounds/reftest.list @@ -411,4 +411,4 @@ include invalidation/reftest.list include ../../dom/encoding/test/reftest/reftest.list # APZ/async positioning tests -include ../../gfx/layers/apz/test/reftest/reftest.list +skip-if(!asyncPan) include ../../gfx/layers/apz/test/reftest/reftest.list From 97cbccbc1b39af2b19a0fda91551c0bc585f9b5e Mon Sep 17 00:00:00 2001 From: Ryan VanderMeulen Date: Tue, 1 Mar 2016 16:29:30 -0500 Subject: [PATCH 160/160] Bug 1252266 - Fuzz some APZ reftests with off-by-one failures. --- layout/reftests/async-scrolling/reftest.list | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/layout/reftests/async-scrolling/reftest.list b/layout/reftests/async-scrolling/reftest.list index a0da87ff361..4b80c0bd873 100644 --- a/layout/reftests/async-scrolling/reftest.list +++ b/layout/reftests/async-scrolling/reftest.list @@ -8,7 +8,7 @@ fuzzy(1,246) fuzzy-if(skiaContent,2,160) skip-if(!asyncPan) == bg-fixed-child-mask.html bg-fixed-child-mask-ref.html == bg-fixed-in-opacity.html bg-fixed-in-opacity-ref.html == bg-fixed-child-no-culling.html bg-fixed-child-no-culling-ref.html -fuzzy-if(B2G,2,5366) fuzzy-if(Android,2,4000) skip-if(!asyncPan||((browserIsRemote&&winWidget))) == bg-fixed-transformed-image.html bg-fixed-transformed-image-ref.html +fuzzy-if(B2G,2,5366) fuzzy-if(Android,2,4000) fuzzy-if(browserIsRemote&&cocoaWidget,2,179524) fuzzy-if(browserIsRemote&&winWidget,1,74590) skip-if(!asyncPan) == bg-fixed-transformed-image.html bg-fixed-transformed-image-ref.html == element-1.html element-1-ref.html pref(layers.force-active,true) == iframe-1.html iframe-1-ref.html == nested-1.html nested-1-ref.html @@ -22,13 +22,13 @@ pref(layers.force-active,true) == iframe-1.html iframe-1-ref.html fuzzy-if(Android,5,4) skip-if(!asyncPan) == position-fixed-transformed-1.html position-fixed-transformed-1-ref.html == split-layers-1.html split-layers-1-ref.html == split-layers-multi-scrolling-1.html split-layers-multi-scrolling-1-ref.html -fuzzy-if(skiaContent,1,32000) skip-if(!asyncPan||(browserIsRemote&&winWidget)) == split-opacity-layers-1.html split-opacity-layers-1-ref.html +fuzzy-if(skiaContent,1,32000) fuzzy-if(browserIsRemote&&(cocoaWidget||winWidget),1,240000) skip-if(!asyncPan) == split-opacity-layers-1.html split-opacity-layers-1-ref.html == sticky-pos-scrollable-1.html sticky-pos-scrollable-1-ref.html == fixed-pos-scrollable-1.html fixed-pos-scrollable-1-ref.html == culling-1.html culling-1-ref.html == position-fixed-iframe-1.html position-fixed-iframe-1-ref.html == position-fixed-iframe-2.html position-fixed-iframe-2-ref.html -fuzzy-if(skiaContent,1,10000) skip-if(!asyncPan) == position-fixed-in-scroll-container.html position-fixed-in-scroll-container-ref.html +fuzzy-if(skiaContent||(browserIsRemote&&cocoaWidget),1,10000) skip-if(!asyncPan) == position-fixed-in-scroll-container.html position-fixed-in-scroll-container-ref.html fuzzy(1,60000) skip-if(!asyncPan) == group-opacity-surface-size-1.html group-opacity-surface-size-1-ref.html == position-sticky-transformed.html position-sticky-transformed-ref.html