test/script/basic/compile-octane.js

Tue, 21 Mar 2017 13:41:57 -0700

author
asaha
date
Tue, 21 Mar 2017 13:41:57 -0700
changeset 2160
1df40fe54cd6
parent 1106
ac111e4cb1dc
child 1205
4112748288bb
permissions
-rw-r--r--

Merge

     1 /*
     2  * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     8  *
     9  * This code is distributed in the hope that it will be useful, but WITHOUT
    10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    12  * version 2 for more details (a copy is included in the LICENSE file that
    13  * accompanied this code).
    14  *
    15  * You should have received a copy of the GNU General Public License version
    16  * 2 along with this work; if not, write to the Free Software Foundation,
    17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    18  *
    19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    20  * or visit www.oracle.com if you need additional information or have any
    21  * questions.
    22  */
    24 /**
    25  * Make sure that we run with the class cache off to so that every
    26  * run produces compile time and with optimistic type info caching
    27  * and persistent code store off, for the same reasons. These last two
    28  * are currently default, but this is not guaranteed to be the case
    29  * forever, so make this test future safe, we specify them explicitly
    30  *
    31  * This means that if you use this subtest as a compilation test
    32  * harness, pass the arguments:
    33  *
    34  * -scripting -Dnashorn.typeInfo.disabled=true --class-cache-size=0
    35  * --persistent-code-cache=false
    36  *
    37  * @subtest
    38  */
    40 load(__DIR__ + 'octane-payload.js');
    42 var DEFAULT_ITERS = 1; //default is one iteration through each benchmark
    43 var iters = DEFAULT_ITERS;
    44 var args = [];
    46 if (typeof $ARGS !== 'undefined') {
    47     args = $ARGS;
    48 } else if (typeof arguments !== 'undefined' && arguments.length != 0) {
    49     args = arguments;
    50 }
    52 var onlyTheseTests = [];
    53 var verbose = false;
    55 for (var i = 0; i < args.length; ) {
    56     var arg = args[i];
    57     if (arg === '--iterations') {
    58     iters = +args[++i];
    59     } else if (arg === '--verbose') {
    60     verbose = true;
    61     } else {
    62     onlyTheseTests.push(arg);
    63     }
    64     i++;
    65 }
    67 if (isNaN(iters)) {
    68     iters = DEFAULT_ITERS;
    69 }
    71 if (iters != DEFAULT_ITERS) {
    72     print("Running " + iters + " iterations of each compilation.");
    73 }
    75 function print_if_verbose(x) {
    76     if (verbose) {
    77     print(x);
    78     }
    79 }
    81 function contains(a, obj) {
    82     for (var i = 0; i < a.length; i++) {
    83         if (a[i] === obj) {
    84             return true;
    85         }
    86     }
    87     return false;
    88 }
    90 var testsCompiled = [];
    92 for (var j in tests) {
    93     var test_name = tests[j].name;
    94     var files = tests[j].files;
    96     if (onlyTheseTests.length > 0 && !contains(onlyTheseTests, test_name)) {
    97     print_if_verbose("Skipping " + test_name);
    98     continue;
    99     }
   101     if (!contains(testsCompiled, test_name)) {
   102     testsCompiled.push(test_name);
   103     }
   105     var str = "Compiling '" + test_name + "'...";
   106     if (files.length > 1) {
   107     str += " (" + files.length + " files)";
   108     }
   109     if (iters != 1) {
   110     str += " (" + iters + " times)";
   111     }
   112     str + "...";
   113     print(str);
   115     for (var iteration = 0; iteration < iters; iteration++) {
   117     //get a new global to avoid symbol pollution and reloads of base
   118     //in the same namespace
   119     var newGlobal = loadWithNewGlobal({script:'this', name:'test'});
   121     //load base into the new global so we get BenchmarkSuite etc
   122     newGlobal.load(base);
   124     //load all files in the single benchmark
   125     for (var k in files) {
   126         var file = files[k];
   127         if (iteration >= 0) { //only display message on first iteration
   128         var str2 = "\t";
   129         if (iters > 1) {
   130             str2 += " [iteration " + (iteration + 1) + "]";
   131         }
   132         str2 += " processing file: " + file + "...";
   133         print_if_verbose(str2);
   134         }
   135         newGlobal.load(new java.io.File(path + file).toURL());
   136     }
   137     }
   138     print("Done.");
   139 }
   141 if (testsCompiled.length == 0) {
   142     print("Error: no tests given to compile");
   143 }

mercurial