Bug 1808675 - Remove iteratorTemp indirection in Map/Set iterators. r=iain

This makes a Set for-of micro-benchmark measurably faster.

Differential Revision: https://phabricator.services.mozilla.com/D166039
This commit is contained in:
Jan de Mooij 2023-01-06 08:04:10 +00:00
parent 4fda6823be
commit 7993229384
2 changed files with 6 additions and 18 deletions

View File

@ -53,10 +53,7 @@ function MapForEach(callbackfn, thisArg = undefined) {
var entries = callFunction(std_Map_entries, M);
// Inlined: MapIteratorNext
var mapIterationResultPair = iteratorTemp.mapIterationResultPair;
if (!mapIterationResultPair) {
mapIterationResultPair = iteratorTemp.mapIterationResultPair = CreateMapIterationResultPair();
}
var mapIterationResultPair = globalMapIterationResultPair;
while (true) {
var done = GetNextMapEntryForIterator(entries, mapIterationResultPair);
@ -73,7 +70,7 @@ function MapForEach(callbackfn, thisArg = undefined) {
}
}
var iteratorTemp = { mapIterationResultPair: null };
var globalMapIterationResultPair = CreateMapIterationResultPair();
function MapIteratorNext() {
// Step 1.
@ -91,10 +88,7 @@ function MapIteratorNext() {
// Steps 4-5 (implemented in GetNextMapEntryForIterator).
// Steps 8-9 (omitted).
var mapIterationResultPair = iteratorTemp.mapIterationResultPair;
if (!mapIterationResultPair) {
mapIterationResultPair = iteratorTemp.mapIterationResultPair = CreateMapIterationResultPair();
}
var mapIterationResultPair = globalMapIterationResultPair;
var retVal = { value: undefined, done: true };

View File

@ -523,10 +523,7 @@ function SetForEach(callbackfn, thisArg = undefined) {
var values = callFunction(std_Set_values, S);
// Inlined: SetIteratorNext
var setIterationResult = setIteratorTemp.setIterationResult;
if (!setIterationResult) {
setIterationResult = setIteratorTemp.setIterationResult = CreateSetIterationResult();
}
var setIterationResult = globalSetIterationResult;
while (true) {
var done = GetNextSetEntryForIterator(values, setIterationResult);
@ -550,7 +547,7 @@ function $SetSpecies() {
}
SetCanonicalName($SetSpecies, "get [Symbol.species]");
var setIteratorTemp = { setIterationResult: null };
var globalSetIterationResult = CreateSetIterationResult();
function SetIteratorNext() {
// Step 1.
@ -568,10 +565,7 @@ function SetIteratorNext() {
// Steps 4-5 (implemented in GetNextSetEntryForIterator).
// Steps 8-9 (omitted).
var setIterationResult = setIteratorTemp.setIterationResult;
if (!setIterationResult) {
setIterationResult = setIteratorTemp.setIterationResult = CreateSetIterationResult();
}
var setIterationResult = globalSetIterationResult;
var retVal = { value: undefined, done: true };