author | sundar |
Wed, 06 May 2015 20:04:42 +0530 | |
changeset 30394 | 72a59e4dffea |
parent 26373 | cd907cf7bf7a |
permissions | -rw-r--r-- |
16147 | 1 |
/* |
16151 | 2 |
* Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. |
16147 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
24778
2ff5d7041566
8044638: Tidy up Nashorn codebase for code standards
attila
parents:
24743
diff
changeset
|
4 |
* |
16147 | 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. |
|
24778
2ff5d7041566
8044638: Tidy up Nashorn codebase for code standards
attila
parents:
24743
diff
changeset
|
8 |
* |
16147 | 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). |
|
24778
2ff5d7041566
8044638: Tidy up Nashorn codebase for code standards
attila
parents:
24743
diff
changeset
|
14 |
* |
16147 | 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. |
|
24778
2ff5d7041566
8044638: Tidy up Nashorn codebase for code standards
attila
parents:
24743
diff
changeset
|
18 |
* |
16147 | 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 |
*/ |
|
23 |
||
24 |
/** |
|
25821
fbb51e67d2a7
8048869: Reduce compile time by about 5% by removing the Class.casts from the AST nodes
lagergren
parents:
24778
diff
changeset
|
25 |
* Make sure that we run with the class cache off to so that every |
fbb51e67d2a7
8048869: Reduce compile time by about 5% by removing the Class.casts from the AST nodes
lagergren
parents:
24778
diff
changeset
|
26 |
* run produces compile time and with optimistic type info caching |
fbb51e67d2a7
8048869: Reduce compile time by about 5% by removing the Class.casts from the AST nodes
lagergren
parents:
24778
diff
changeset
|
27 |
* and persistent code store off, for the same reasons. These last two |
fbb51e67d2a7
8048869: Reduce compile time by about 5% by removing the Class.casts from the AST nodes
lagergren
parents:
24778
diff
changeset
|
28 |
* are currently default, but this is not guaranteed to be the case |
fbb51e67d2a7
8048869: Reduce compile time by about 5% by removing the Class.casts from the AST nodes
lagergren
parents:
24778
diff
changeset
|
29 |
* forever, so make this test future safe, we specify them explicitly |
fbb51e67d2a7
8048869: Reduce compile time by about 5% by removing the Class.casts from the AST nodes
lagergren
parents:
24778
diff
changeset
|
30 |
* |
fbb51e67d2a7
8048869: Reduce compile time by about 5% by removing the Class.casts from the AST nodes
lagergren
parents:
24778
diff
changeset
|
31 |
* This means that if you use this subtest as a compilation test |
fbb51e67d2a7
8048869: Reduce compile time by about 5% by removing the Class.casts from the AST nodes
lagergren
parents:
24778
diff
changeset
|
32 |
* harness, pass the arguments: |
fbb51e67d2a7
8048869: Reduce compile time by about 5% by removing the Class.casts from the AST nodes
lagergren
parents:
24778
diff
changeset
|
33 |
* |
26067
b32ccc3a76c9
8055199: Tidy up Nashorn codebase for code standards (August 2014)
attila
parents:
25821
diff
changeset
|
34 |
* -scripting -Dnashorn.typeInfo.disabled=true --class-cache-size=0 |
25821
fbb51e67d2a7
8048869: Reduce compile time by about 5% by removing the Class.casts from the AST nodes
lagergren
parents:
24778
diff
changeset
|
35 |
* --persistent-code-cache=false |
fbb51e67d2a7
8048869: Reduce compile time by about 5% by removing the Class.casts from the AST nodes
lagergren
parents:
24778
diff
changeset
|
36 |
* |
fbb51e67d2a7
8048869: Reduce compile time by about 5% by removing the Class.casts from the AST nodes
lagergren
parents:
24778
diff
changeset
|
37 |
* @subtest |
24778
2ff5d7041566
8044638: Tidy up Nashorn codebase for code standards
attila
parents:
24743
diff
changeset
|
38 |
*/ |
16147 | 39 |
|
25821
fbb51e67d2a7
8048869: Reduce compile time by about 5% by removing the Class.casts from the AST nodes
lagergren
parents:
24778
diff
changeset
|
40 |
load(__DIR__ + 'octane-payload.js'); |
fbb51e67d2a7
8048869: Reduce compile time by about 5% by removing the Class.casts from the AST nodes
lagergren
parents:
24778
diff
changeset
|
41 |
|
fbb51e67d2a7
8048869: Reduce compile time by about 5% by removing the Class.casts from the AST nodes
lagergren
parents:
24778
diff
changeset
|
42 |
var DEFAULT_ITERS = 1; //default is one iteration through each benchmark |
26067
b32ccc3a76c9
8055199: Tidy up Nashorn codebase for code standards (August 2014)
attila
parents:
25821
diff
changeset
|
43 |
var iters = DEFAULT_ITERS; |
25821
fbb51e67d2a7
8048869: Reduce compile time by about 5% by removing the Class.casts from the AST nodes
lagergren
parents:
24778
diff
changeset
|
44 |
var args = []; |
fbb51e67d2a7
8048869: Reduce compile time by about 5% by removing the Class.casts from the AST nodes
lagergren
parents:
24778
diff
changeset
|
45 |
|
fbb51e67d2a7
8048869: Reduce compile time by about 5% by removing the Class.casts from the AST nodes
lagergren
parents:
24778
diff
changeset
|
46 |
if (typeof $ARGS !== 'undefined') { |
fbb51e67d2a7
8048869: Reduce compile time by about 5% by removing the Class.casts from the AST nodes
lagergren
parents:
24778
diff
changeset
|
47 |
args = $ARGS; |
fbb51e67d2a7
8048869: Reduce compile time by about 5% by removing the Class.casts from the AST nodes
lagergren
parents:
24778
diff
changeset
|
48 |
} else if (typeof arguments !== 'undefined' && arguments.length != 0) { |
fbb51e67d2a7
8048869: Reduce compile time by about 5% by removing the Class.casts from the AST nodes
lagergren
parents:
24778
diff
changeset
|
49 |
args = arguments; |
fbb51e67d2a7
8048869: Reduce compile time by about 5% by removing the Class.casts from the AST nodes
lagergren
parents:
24778
diff
changeset
|
50 |
} |
fbb51e67d2a7
8048869: Reduce compile time by about 5% by removing the Class.casts from the AST nodes
lagergren
parents:
24778
diff
changeset
|
51 |
|
fbb51e67d2a7
8048869: Reduce compile time by about 5% by removing the Class.casts from the AST nodes
lagergren
parents:
24778
diff
changeset
|
52 |
var onlyTheseTests = []; |
fbb51e67d2a7
8048869: Reduce compile time by about 5% by removing the Class.casts from the AST nodes
lagergren
parents:
24778
diff
changeset
|
53 |
var verbose = false; |
fbb51e67d2a7
8048869: Reduce compile time by about 5% by removing the Class.casts from the AST nodes
lagergren
parents:
24778
diff
changeset
|
54 |
|
fbb51e67d2a7
8048869: Reduce compile time by about 5% by removing the Class.casts from the AST nodes
lagergren
parents:
24778
diff
changeset
|
55 |
for (var i = 0; i < args.length; ) { |
fbb51e67d2a7
8048869: Reduce compile time by about 5% by removing the Class.casts from the AST nodes
lagergren
parents:
24778
diff
changeset
|
56 |
var arg = args[i]; |
fbb51e67d2a7
8048869: Reduce compile time by about 5% by removing the Class.casts from the AST nodes
lagergren
parents:
24778
diff
changeset
|
57 |
if (arg === '--iterations') { |
26067
b32ccc3a76c9
8055199: Tidy up Nashorn codebase for code standards (August 2014)
attila
parents:
25821
diff
changeset
|
58 |
iters = +args[++i]; |
25821
fbb51e67d2a7
8048869: Reduce compile time by about 5% by removing the Class.casts from the AST nodes
lagergren
parents:
24778
diff
changeset
|
59 |
} else if (arg === '--verbose') { |
26067
b32ccc3a76c9
8055199: Tidy up Nashorn codebase for code standards (August 2014)
attila
parents:
25821
diff
changeset
|
60 |
verbose = true; |
25821
fbb51e67d2a7
8048869: Reduce compile time by about 5% by removing the Class.casts from the AST nodes
lagergren
parents:
24778
diff
changeset
|
61 |
} else { |
26067
b32ccc3a76c9
8055199: Tidy up Nashorn codebase for code standards (August 2014)
attila
parents:
25821
diff
changeset
|
62 |
onlyTheseTests.push(arg); |
25821
fbb51e67d2a7
8048869: Reduce compile time by about 5% by removing the Class.casts from the AST nodes
lagergren
parents:
24778
diff
changeset
|
63 |
} |
fbb51e67d2a7
8048869: Reduce compile time by about 5% by removing the Class.casts from the AST nodes
lagergren
parents:
24778
diff
changeset
|
64 |
i++; |
fbb51e67d2a7
8048869: Reduce compile time by about 5% by removing the Class.casts from the AST nodes
lagergren
parents:
24778
diff
changeset
|
65 |
} |
fbb51e67d2a7
8048869: Reduce compile time by about 5% by removing the Class.casts from the AST nodes
lagergren
parents:
24778
diff
changeset
|
66 |
|
fbb51e67d2a7
8048869: Reduce compile time by about 5% by removing the Class.casts from the AST nodes
lagergren
parents:
24778
diff
changeset
|
67 |
if (isNaN(iters)) { |
fbb51e67d2a7
8048869: Reduce compile time by about 5% by removing the Class.casts from the AST nodes
lagergren
parents:
24778
diff
changeset
|
68 |
iters = DEFAULT_ITERS; |
fbb51e67d2a7
8048869: Reduce compile time by about 5% by removing the Class.casts from the AST nodes
lagergren
parents:
24778
diff
changeset
|
69 |
} |
fbb51e67d2a7
8048869: Reduce compile time by about 5% by removing the Class.casts from the AST nodes
lagergren
parents:
24778
diff
changeset
|
70 |
|
fbb51e67d2a7
8048869: Reduce compile time by about 5% by removing the Class.casts from the AST nodes
lagergren
parents:
24778
diff
changeset
|
71 |
if (iters != DEFAULT_ITERS) { |
fbb51e67d2a7
8048869: Reduce compile time by about 5% by removing the Class.casts from the AST nodes
lagergren
parents:
24778
diff
changeset
|
72 |
print("Running " + iters + " iterations of each compilation."); |
fbb51e67d2a7
8048869: Reduce compile time by about 5% by removing the Class.casts from the AST nodes
lagergren
parents:
24778
diff
changeset
|
73 |
} |
fbb51e67d2a7
8048869: Reduce compile time by about 5% by removing the Class.casts from the AST nodes
lagergren
parents:
24778
diff
changeset
|
74 |
|
fbb51e67d2a7
8048869: Reduce compile time by about 5% by removing the Class.casts from the AST nodes
lagergren
parents:
24778
diff
changeset
|
75 |
function print_if_verbose(x) { |
fbb51e67d2a7
8048869: Reduce compile time by about 5% by removing the Class.casts from the AST nodes
lagergren
parents:
24778
diff
changeset
|
76 |
if (verbose) { |
26067
b32ccc3a76c9
8055199: Tidy up Nashorn codebase for code standards (August 2014)
attila
parents:
25821
diff
changeset
|
77 |
print(x); |
25821
fbb51e67d2a7
8048869: Reduce compile time by about 5% by removing the Class.casts from the AST nodes
lagergren
parents:
24778
diff
changeset
|
78 |
} |
fbb51e67d2a7
8048869: Reduce compile time by about 5% by removing the Class.casts from the AST nodes
lagergren
parents:
24778
diff
changeset
|
79 |
} |
fbb51e67d2a7
8048869: Reduce compile time by about 5% by removing the Class.casts from the AST nodes
lagergren
parents:
24778
diff
changeset
|
80 |
|
fbb51e67d2a7
8048869: Reduce compile time by about 5% by removing the Class.casts from the AST nodes
lagergren
parents:
24778
diff
changeset
|
81 |
function contains(a, obj) { |
fbb51e67d2a7
8048869: Reduce compile time by about 5% by removing the Class.casts from the AST nodes
lagergren
parents:
24778
diff
changeset
|
82 |
for (var i = 0; i < a.length; i++) { |
fbb51e67d2a7
8048869: Reduce compile time by about 5% by removing the Class.casts from the AST nodes
lagergren
parents:
24778
diff
changeset
|
83 |
if (a[i] === obj) { |
fbb51e67d2a7
8048869: Reduce compile time by about 5% by removing the Class.casts from the AST nodes
lagergren
parents:
24778
diff
changeset
|
84 |
return true; |
fbb51e67d2a7
8048869: Reduce compile time by about 5% by removing the Class.casts from the AST nodes
lagergren
parents:
24778
diff
changeset
|
85 |
} |
fbb51e67d2a7
8048869: Reduce compile time by about 5% by removing the Class.casts from the AST nodes
lagergren
parents:
24778
diff
changeset
|
86 |
} |
fbb51e67d2a7
8048869: Reduce compile time by about 5% by removing the Class.casts from the AST nodes
lagergren
parents:
24778
diff
changeset
|
87 |
return false; |
fbb51e67d2a7
8048869: Reduce compile time by about 5% by removing the Class.casts from the AST nodes
lagergren
parents:
24778
diff
changeset
|
88 |
} |
fbb51e67d2a7
8048869: Reduce compile time by about 5% by removing the Class.casts from the AST nodes
lagergren
parents:
24778
diff
changeset
|
89 |
|
fbb51e67d2a7
8048869: Reduce compile time by about 5% by removing the Class.casts from the AST nodes
lagergren
parents:
24778
diff
changeset
|
90 |
var testsCompiled = []; |
fbb51e67d2a7
8048869: Reduce compile time by about 5% by removing the Class.casts from the AST nodes
lagergren
parents:
24778
diff
changeset
|
91 |
|
fbb51e67d2a7
8048869: Reduce compile time by about 5% by removing the Class.casts from the AST nodes
lagergren
parents:
24778
diff
changeset
|
92 |
for (var j in tests) { |
fbb51e67d2a7
8048869: Reduce compile time by about 5% by removing the Class.casts from the AST nodes
lagergren
parents:
24778
diff
changeset
|
93 |
var test_name = tests[j].name; |
fbb51e67d2a7
8048869: Reduce compile time by about 5% by removing the Class.casts from the AST nodes
lagergren
parents:
24778
diff
changeset
|
94 |
var files = tests[j].files; |
fbb51e67d2a7
8048869: Reduce compile time by about 5% by removing the Class.casts from the AST nodes
lagergren
parents:
24778
diff
changeset
|
95 |
|
fbb51e67d2a7
8048869: Reduce compile time by about 5% by removing the Class.casts from the AST nodes
lagergren
parents:
24778
diff
changeset
|
96 |
if (onlyTheseTests.length > 0 && !contains(onlyTheseTests, test_name)) { |
26067
b32ccc3a76c9
8055199: Tidy up Nashorn codebase for code standards (August 2014)
attila
parents:
25821
diff
changeset
|
97 |
print_if_verbose("Skipping " + test_name); |
b32ccc3a76c9
8055199: Tidy up Nashorn codebase for code standards (August 2014)
attila
parents:
25821
diff
changeset
|
98 |
continue; |
25821
fbb51e67d2a7
8048869: Reduce compile time by about 5% by removing the Class.casts from the AST nodes
lagergren
parents:
24778
diff
changeset
|
99 |
} |
fbb51e67d2a7
8048869: Reduce compile time by about 5% by removing the Class.casts from the AST nodes
lagergren
parents:
24778
diff
changeset
|
100 |
|
fbb51e67d2a7
8048869: Reduce compile time by about 5% by removing the Class.casts from the AST nodes
lagergren
parents:
24778
diff
changeset
|
101 |
if (!contains(testsCompiled, test_name)) { |
26067
b32ccc3a76c9
8055199: Tidy up Nashorn codebase for code standards (August 2014)
attila
parents:
25821
diff
changeset
|
102 |
testsCompiled.push(test_name); |
25821
fbb51e67d2a7
8048869: Reduce compile time by about 5% by removing the Class.casts from the AST nodes
lagergren
parents:
24778
diff
changeset
|
103 |
} |
fbb51e67d2a7
8048869: Reduce compile time by about 5% by removing the Class.casts from the AST nodes
lagergren
parents:
24778
diff
changeset
|
104 |
|
fbb51e67d2a7
8048869: Reduce compile time by about 5% by removing the Class.casts from the AST nodes
lagergren
parents:
24778
diff
changeset
|
105 |
var str = "Compiling '" + test_name + "'..."; |
fbb51e67d2a7
8048869: Reduce compile time by about 5% by removing the Class.casts from the AST nodes
lagergren
parents:
24778
diff
changeset
|
106 |
if (files.length > 1) { |
26067
b32ccc3a76c9
8055199: Tidy up Nashorn codebase for code standards (August 2014)
attila
parents:
25821
diff
changeset
|
107 |
str += " (" + files.length + " files)"; |
25821
fbb51e67d2a7
8048869: Reduce compile time by about 5% by removing the Class.casts from the AST nodes
lagergren
parents:
24778
diff
changeset
|
108 |
} |
fbb51e67d2a7
8048869: Reduce compile time by about 5% by removing the Class.casts from the AST nodes
lagergren
parents:
24778
diff
changeset
|
109 |
if (iters != 1) { |
26067
b32ccc3a76c9
8055199: Tidy up Nashorn codebase for code standards (August 2014)
attila
parents:
25821
diff
changeset
|
110 |
str += " (" + iters + " times)"; |
25821
fbb51e67d2a7
8048869: Reduce compile time by about 5% by removing the Class.casts from the AST nodes
lagergren
parents:
24778
diff
changeset
|
111 |
} |
fbb51e67d2a7
8048869: Reduce compile time by about 5% by removing the Class.casts from the AST nodes
lagergren
parents:
24778
diff
changeset
|
112 |
str + "..."; |
fbb51e67d2a7
8048869: Reduce compile time by about 5% by removing the Class.casts from the AST nodes
lagergren
parents:
24778
diff
changeset
|
113 |
print(str); |
fbb51e67d2a7
8048869: Reduce compile time by about 5% by removing the Class.casts from the AST nodes
lagergren
parents:
24778
diff
changeset
|
114 |
|
fbb51e67d2a7
8048869: Reduce compile time by about 5% by removing the Class.casts from the AST nodes
lagergren
parents:
24778
diff
changeset
|
115 |
for (var iteration = 0; iteration < iters; iteration++) { |
fbb51e67d2a7
8048869: Reduce compile time by about 5% by removing the Class.casts from the AST nodes
lagergren
parents:
24778
diff
changeset
|
116 |
|
26067
b32ccc3a76c9
8055199: Tidy up Nashorn codebase for code standards (August 2014)
attila
parents:
25821
diff
changeset
|
117 |
//get a new global to avoid symbol pollution and reloads of base |
b32ccc3a76c9
8055199: Tidy up Nashorn codebase for code standards (August 2014)
attila
parents:
25821
diff
changeset
|
118 |
//in the same namespace |
b32ccc3a76c9
8055199: Tidy up Nashorn codebase for code standards (August 2014)
attila
parents:
25821
diff
changeset
|
119 |
var newGlobal = loadWithNewGlobal({script:'this', name:'test'}); |
25821
fbb51e67d2a7
8048869: Reduce compile time by about 5% by removing the Class.casts from the AST nodes
lagergren
parents:
24778
diff
changeset
|
120 |
|
26067
b32ccc3a76c9
8055199: Tidy up Nashorn codebase for code standards (August 2014)
attila
parents:
25821
diff
changeset
|
121 |
//load base into the new global so we get BenchmarkSuite etc |
b32ccc3a76c9
8055199: Tidy up Nashorn codebase for code standards (August 2014)
attila
parents:
25821
diff
changeset
|
122 |
newGlobal.load(base); |
25821
fbb51e67d2a7
8048869: Reduce compile time by about 5% by removing the Class.casts from the AST nodes
lagergren
parents:
24778
diff
changeset
|
123 |
|
26067
b32ccc3a76c9
8055199: Tidy up Nashorn codebase for code standards (August 2014)
attila
parents:
25821
diff
changeset
|
124 |
//load all files in the single benchmark |
b32ccc3a76c9
8055199: Tidy up Nashorn codebase for code standards (August 2014)
attila
parents:
25821
diff
changeset
|
125 |
for (var k in files) { |
b32ccc3a76c9
8055199: Tidy up Nashorn codebase for code standards (August 2014)
attila
parents:
25821
diff
changeset
|
126 |
var file = files[k]; |
b32ccc3a76c9
8055199: Tidy up Nashorn codebase for code standards (August 2014)
attila
parents:
25821
diff
changeset
|
127 |
if (iteration >= 0) { //only display message on first iteration |
b32ccc3a76c9
8055199: Tidy up Nashorn codebase for code standards (August 2014)
attila
parents:
25821
diff
changeset
|
128 |
var str2 = "\t"; |
b32ccc3a76c9
8055199: Tidy up Nashorn codebase for code standards (August 2014)
attila
parents:
25821
diff
changeset
|
129 |
if (iters > 1) { |
b32ccc3a76c9
8055199: Tidy up Nashorn codebase for code standards (August 2014)
attila
parents:
25821
diff
changeset
|
130 |
str2 += " [iteration " + (iteration + 1) + "]"; |
b32ccc3a76c9
8055199: Tidy up Nashorn codebase for code standards (August 2014)
attila
parents:
25821
diff
changeset
|
131 |
} |
b32ccc3a76c9
8055199: Tidy up Nashorn codebase for code standards (August 2014)
attila
parents:
25821
diff
changeset
|
132 |
str2 += " processing file: " + file + "..."; |
b32ccc3a76c9
8055199: Tidy up Nashorn codebase for code standards (August 2014)
attila
parents:
25821
diff
changeset
|
133 |
print_if_verbose(str2); |
b32ccc3a76c9
8055199: Tidy up Nashorn codebase for code standards (August 2014)
attila
parents:
25821
diff
changeset
|
134 |
} |
26373
cd907cf7bf7a
8054343: Nashorn: Some tests fails on windows with AccessControlException
yan
parents:
26067
diff
changeset
|
135 |
newGlobal.load(new java.io.File(path + file).toURL()); |
26067
b32ccc3a76c9
8055199: Tidy up Nashorn codebase for code standards (August 2014)
attila
parents:
25821
diff
changeset
|
136 |
} |
25821
fbb51e67d2a7
8048869: Reduce compile time by about 5% by removing the Class.casts from the AST nodes
lagergren
parents:
24778
diff
changeset
|
137 |
} |
fbb51e67d2a7
8048869: Reduce compile time by about 5% by removing the Class.casts from the AST nodes
lagergren
parents:
24778
diff
changeset
|
138 |
print("Done."); |
fbb51e67d2a7
8048869: Reduce compile time by about 5% by removing the Class.casts from the AST nodes
lagergren
parents:
24778
diff
changeset
|
139 |
} |
fbb51e67d2a7
8048869: Reduce compile time by about 5% by removing the Class.casts from the AST nodes
lagergren
parents:
24778
diff
changeset
|
140 |
|
fbb51e67d2a7
8048869: Reduce compile time by about 5% by removing the Class.casts from the AST nodes
lagergren
parents:
24778
diff
changeset
|
141 |
if (testsCompiled.length == 0) { |
fbb51e67d2a7
8048869: Reduce compile time by about 5% by removing the Class.casts from the AST nodes
lagergren
parents:
24778
diff
changeset
|
142 |
print("Error: no tests given to compile"); |
fbb51e67d2a7
8048869: Reduce compile time by about 5% by removing the Class.casts from the AST nodes
lagergren
parents:
24778
diff
changeset
|
143 |
} |