-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable Jitting Generators and Async Functions
- exclude ARM which has not been tested - excludes code running with debugger attached (not tested) - excludes functions containing try/catch (not tested) - excludes Module globals (unlikely to benefit) - add tests for bugs fixed above
- Loading branch information
Showing
4 changed files
with
109 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,93 @@ | ||
//------------------------------------------------------------------------------------------------------- | ||
// Copyright (C) Microsoft. All rights reserved. | ||
// Copyright (c) 2021 ChakraCore Project Contributors. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information. | ||
//------------------------------------------------------------------------------------------------------- | ||
|
||
let results = 0; | ||
let test = 0; | ||
const verbose = WScript.Arguments[0] != "summary"; | ||
|
||
function check(actual, expected) { | ||
if (actual != expected) | ||
throw new Error("Generator produced " + actual + " instead of " + expected); | ||
if (verbose) | ||
print('Result ' + ++results + ' Generator correctly produced ' + actual); | ||
} | ||
|
||
function title (name) { | ||
if (verbose) { | ||
print("Beginning Test " + ++test + ": " + name); | ||
results = 0; | ||
} | ||
} | ||
|
||
|
||
// Test 1 - const that is unused/replaced with undefined | ||
function* foo() { | ||
title("const that is unused/replaced with undefined"); | ||
function* gf1() { | ||
const temp2 = null; | ||
while (true) { | ||
yield temp2; | ||
} | ||
} | ||
|
||
const gen = foo(); | ||
const gen = gf1(); | ||
|
||
check(gen.next().value, null); | ||
check(gen.next().value, null); | ||
check(gen.next().value, null); | ||
|
||
// Test 2 - load for-in enumerator in nested for-in loop | ||
title("load for-in enumerator in nested for-in loop"); | ||
const arr = [0, 1, 2]; | ||
function* gf2() { | ||
for (let a in arr) { | ||
for (let b in arr) { | ||
yield a + b; | ||
} | ||
} | ||
} | ||
|
||
const gen2 = gf2(); | ||
|
||
check(gen2.next().value, "00"); | ||
check(gen2.next().value, "01"); | ||
check(gen2.next().value, "02"); | ||
check(gen2.next().value, "10"); | ||
check(gen2.next().value, "11"); | ||
check(gen2.next().value, "12"); | ||
check(gen2.next().value, "20"); | ||
check(gen2.next().value, "21"); | ||
check(gen2.next().value, "22"); | ||
check(gen2.next().value, undefined); | ||
|
||
// Test 3 - Bail on no profile losing loop control variable | ||
title("Bail on no profile losing loop control variable"); | ||
function* gf3() { | ||
for (let i = 0; i < 3; ++i) { | ||
yield i; | ||
} | ||
} | ||
|
||
const gen3 = gf3(); | ||
|
||
check(gen3.next().value, 0); | ||
check(gen3.next().value, 1); | ||
check(gen3.next().value, 2); | ||
|
||
// Test 4 - yield* iterator fails to be restored after Bail on No Profile | ||
title("Bail on no profile losing yield* iterator") | ||
function* gf4() { | ||
yield 0; | ||
yield* [1,2,3]; | ||
} | ||
|
||
const gen4 = gf4(); | ||
|
||
gen.next(); | ||
gen.next(); | ||
gen.next(); | ||
check(gen4.next().value, 0); | ||
check(gen4.next().value, 1); | ||
check(gen4.next().value, 2); | ||
check(gen4.next().value, 3); | ||
|
||
print("Pass"); | ||
print("pass"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters