| Index: test/mjsunit/manual-parallel-recompile.js
|
| diff --git a/test/mjsunit/regress/regress-2339.js b/test/mjsunit/manual-parallel-recompile.js
|
| similarity index 63%
|
| copy from test/mjsunit/regress/regress-2339.js
|
| copy to test/mjsunit/manual-parallel-recompile.js
|
| index b16821dbade251a765a715a0bd18a4665dca125a..7eb26960396f4f60c6df045cf1775b08c75a68ad 100644
|
| --- a/test/mjsunit/regress/regress-2339.js
|
| +++ b/test/mjsunit/manual-parallel-recompile.js
|
| @@ -26,34 +26,55 @@
|
| // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
| // Flags: --allow-natives-syntax --expose-gc
|
| +// Flags: --parallel-recompilation --manual-parallel-recompilation
|
|
|
| -/**
|
| - * The possible optimization states of a function. Must be in sync with the
|
| - * return values of Runtime_GetOptimizationStatus() in runtime.cc!
|
| - */
|
| +function assertOptimized(fun) {
|
| + // This assertion takes --always-opt and --nocrankshaft flags into account.
|
| + assertTrue(%GetOptimizationStatus(fun) != 2);
|
| +}
|
| +
|
| +function assertUnoptimized(fun) {
|
| + assertTrue(%GetOptimizationStatus(fun) != 1);
|
| +}
|
|
|
| -var OptimizationState = {
|
| - YES: 1,
|
| - NO: 2,
|
| - ALWAYS: 3,
|
| - NEVER: 4
|
| -};
|
| +function f(x) {
|
| + var xx = x * x;
|
| + var xxstr = xx.toString();
|
| + return xxstr.length;
|
| +}
|
|
|
| -function simple() {
|
| - return simple_two_args(0, undefined);
|
| +function g(x) {
|
| + var xxx = Math.sqrt(x) | 0;
|
| + var xxxstr = xxx.toString();
|
| + return xxxstr.length;
|
| }
|
|
|
| -function simple_two_args(always_zero, always_undefined) {
|
| - var always_five = always_undefined || 5;
|
| - return always_zero * always_five * .5;
|
| +function k(x) {
|
| + return x * x;
|
| }
|
|
|
| +f(g(1));
|
| +f(g(2));
|
| +assertUnoptimized(f);
|
| +assertUnoptimized(g);
|
|
|
| -simple();
|
| -simple();
|
| -%OptimizeFunctionOnNextCall(simple);
|
| -simple();
|
| -var raw_optimized = %GetOptimizationStatus(simple);
|
| -assertFalse(raw_optimized == OptimizationState.NO);
|
| +%ForceParallelRecompile(f);
|
| +%ForceParallelRecompile(g);
|
| +assertUnoptimized(f);
|
| +assertUnoptimized(g);
|
| +
|
| +var sum = 0;
|
| +for (var i = 0; i < 10000; i++) sum += f(i) + g(i);
|
| gc();
|
|
|
| +assertEquals(95274, sum);
|
| +assertUnoptimized(f);
|
| +assertUnoptimized(g);
|
| +
|
| +%InstallRecompiledCode(f);
|
| +assertOptimized(f);
|
| +assertUnoptimized(g);
|
| +
|
| +%InstallRecompiledCode("the rest");
|
| +assertOptimized(g);
|
| +
|
|
|