author | darcy |
Fri, 27 Sep 2019 08:57:25 -0700 | |
changeset 58379 | 8511c662083b |
parent 47216 | 71c04702a3d5 |
permissions | -rw-r--r-- |
26055
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
diff
changeset
|
1 |
/* |
58379
8511c662083b
8231557: Suppress warnings on non-serializable instance fields in jdk.scripting.nashorn module
darcy
parents:
47216
diff
changeset
|
2 |
* Copyright (c) 2010, 2019, Oracle and/or its affiliates. All rights reserved. |
26055
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
diff
changeset
|
4 |
* |
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. Oracle designates this |
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
diff
changeset
|
8 |
* particular file as subject to the "Classpath" exception as provided |
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
diff
changeset
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
diff
changeset
|
10 |
* |
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
diff
changeset
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
diff
changeset
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
diff
changeset
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
diff
changeset
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
diff
changeset
|
15 |
* accompanied this code). |
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
diff
changeset
|
16 |
* |
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
diff
changeset
|
17 |
* You should have received a copy of the GNU General Public License version |
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
diff
changeset
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
diff
changeset
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
diff
changeset
|
20 |
* |
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
diff
changeset
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
diff
changeset
|
22 |
* or visit www.oracle.com if you need additional information or have any |
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
diff
changeset
|
23 |
* questions. |
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
diff
changeset
|
24 |
*/ |
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
diff
changeset
|
25 |
|
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
diff
changeset
|
26 |
package jdk.nashorn.internal.runtime; |
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
diff
changeset
|
27 |
|
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
diff
changeset
|
28 |
import java.io.Serializable; |
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
diff
changeset
|
29 |
import java.util.Arrays; |
30056
06d201382b55
8053905: Eager code generation fails for earley boyer with split threshold set to 1000
hannesw
parents:
28126
diff
changeset
|
30 |
import java.util.HashMap; |
26055
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
diff
changeset
|
31 |
import java.util.Map; |
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
diff
changeset
|
32 |
|
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
diff
changeset
|
33 |
/** |
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
diff
changeset
|
34 |
* Class representing a persistent compiled script. |
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
diff
changeset
|
35 |
*/ |
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
diff
changeset
|
36 |
public final class StoredScript implements Serializable { |
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
diff
changeset
|
37 |
|
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
diff
changeset
|
38 |
/** Compilation id */ |
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
diff
changeset
|
39 |
private final int compilationId; |
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
diff
changeset
|
40 |
|
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
diff
changeset
|
41 |
/** Main class name. */ |
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
diff
changeset
|
42 |
private final String mainClassName; |
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
diff
changeset
|
43 |
|
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
diff
changeset
|
44 |
/** Map of class names to class bytes. */ |
58379
8511c662083b
8231557: Suppress warnings on non-serializable instance fields in jdk.scripting.nashorn module
darcy
parents:
47216
diff
changeset
|
45 |
@SuppressWarnings("serial") // Not statically typed as Serializable |
26055
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
diff
changeset
|
46 |
private final Map<String, byte[]> classBytes; |
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
diff
changeset
|
47 |
|
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
diff
changeset
|
48 |
/** Constants array. */ |
58379
8511c662083b
8231557: Suppress warnings on non-serializable instance fields in jdk.scripting.nashorn module
darcy
parents:
47216
diff
changeset
|
49 |
@SuppressWarnings("serial") // Not statically typed as Serializable |
26055
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
diff
changeset
|
50 |
private final Object[] constants; |
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
diff
changeset
|
51 |
|
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
diff
changeset
|
52 |
/** Function initializers */ |
58379
8511c662083b
8231557: Suppress warnings on non-serializable instance fields in jdk.scripting.nashorn module
darcy
parents:
47216
diff
changeset
|
53 |
@SuppressWarnings("serial") // Not statically typed as Serializable |
26055
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
diff
changeset
|
54 |
private final Map<Integer, FunctionInitializer> initializers; |
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
diff
changeset
|
55 |
|
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
diff
changeset
|
56 |
private static final long serialVersionUID = 2958227232195298340L; |
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
diff
changeset
|
57 |
|
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
diff
changeset
|
58 |
/** |
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
diff
changeset
|
59 |
* Constructor. |
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
diff
changeset
|
60 |
* |
26768
751b0f427090
8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents:
26764
diff
changeset
|
61 |
* @param compilationId compilation id |
26055
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
diff
changeset
|
62 |
* @param mainClassName main class name |
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
diff
changeset
|
63 |
* @param classBytes map of class names to class bytes |
28126 | 64 |
* @param initializers initializer map, id -> FunctionInitializer |
26055
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
diff
changeset
|
65 |
* @param constants constants array |
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
diff
changeset
|
66 |
*/ |
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
diff
changeset
|
67 |
public StoredScript(final int compilationId, final String mainClassName, final Map<String, byte[]> classBytes, final Map<Integer, FunctionInitializer> initializers, final Object[] constants) { |
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
diff
changeset
|
68 |
this.compilationId = compilationId; |
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
diff
changeset
|
69 |
this.mainClassName = mainClassName; |
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
diff
changeset
|
70 |
this.classBytes = classBytes; |
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
diff
changeset
|
71 |
this.constants = constants; |
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
diff
changeset
|
72 |
this.initializers = initializers; |
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
diff
changeset
|
73 |
} |
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
diff
changeset
|
74 |
|
26768
751b0f427090
8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents:
26764
diff
changeset
|
75 |
/** |
751b0f427090
8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents:
26764
diff
changeset
|
76 |
* Get the compilation id for this StoredScript |
751b0f427090
8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents:
26764
diff
changeset
|
77 |
* @return compilation id |
751b0f427090
8025435: Optimistic builtins support, implemented initial optimistic versions of push, pop, and charCodeAt
lagergren
parents:
26764
diff
changeset
|
78 |
*/ |
26055
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
diff
changeset
|
79 |
public int getCompilationId() { |
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
diff
changeset
|
80 |
return compilationId; |
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
diff
changeset
|
81 |
} |
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
diff
changeset
|
82 |
|
32530 | 83 |
private Map<String, Class<?>> installClasses(final Source source, final CodeInstaller installer) { |
30056
06d201382b55
8053905: Eager code generation fails for earley boyer with split threshold set to 1000
hannesw
parents:
28126
diff
changeset
|
84 |
final Map<String, Class<?>> installedClasses = new HashMap<>(); |
06d201382b55
8053905: Eager code generation fails for earley boyer with split threshold set to 1000
hannesw
parents:
28126
diff
changeset
|
85 |
final byte[] mainClassBytes = classBytes.get(mainClassName); |
06d201382b55
8053905: Eager code generation fails for earley boyer with split threshold set to 1000
hannesw
parents:
28126
diff
changeset
|
86 |
final Class<?> mainClass = installer.install(mainClassName, mainClassBytes); |
06d201382b55
8053905: Eager code generation fails for earley boyer with split threshold set to 1000
hannesw
parents:
28126
diff
changeset
|
87 |
|
06d201382b55
8053905: Eager code generation fails for earley boyer with split threshold set to 1000
hannesw
parents:
28126
diff
changeset
|
88 |
installedClasses.put(mainClassName, mainClass); |
06d201382b55
8053905: Eager code generation fails for earley boyer with split threshold set to 1000
hannesw
parents:
28126
diff
changeset
|
89 |
|
06d201382b55
8053905: Eager code generation fails for earley boyer with split threshold set to 1000
hannesw
parents:
28126
diff
changeset
|
90 |
for (final Map.Entry<String, byte[]> entry : classBytes.entrySet()) { |
06d201382b55
8053905: Eager code generation fails for earley boyer with split threshold set to 1000
hannesw
parents:
28126
diff
changeset
|
91 |
final String className = entry.getKey(); |
06d201382b55
8053905: Eager code generation fails for earley boyer with split threshold set to 1000
hannesw
parents:
28126
diff
changeset
|
92 |
|
06d201382b55
8053905: Eager code generation fails for earley boyer with split threshold set to 1000
hannesw
parents:
28126
diff
changeset
|
93 |
if (!className.equals(mainClassName)) { |
06d201382b55
8053905: Eager code generation fails for earley boyer with split threshold set to 1000
hannesw
parents:
28126
diff
changeset
|
94 |
installedClasses.put(className, installer.install(className, entry.getValue())); |
06d201382b55
8053905: Eager code generation fails for earley boyer with split threshold set to 1000
hannesw
parents:
28126
diff
changeset
|
95 |
} |
06d201382b55
8053905: Eager code generation fails for earley boyer with split threshold set to 1000
hannesw
parents:
28126
diff
changeset
|
96 |
} |
06d201382b55
8053905: Eager code generation fails for earley boyer with split threshold set to 1000
hannesw
parents:
28126
diff
changeset
|
97 |
|
06d201382b55
8053905: Eager code generation fails for earley boyer with split threshold set to 1000
hannesw
parents:
28126
diff
changeset
|
98 |
installer.initialize(installedClasses.values(), source, constants); |
06d201382b55
8053905: Eager code generation fails for earley boyer with split threshold set to 1000
hannesw
parents:
28126
diff
changeset
|
99 |
return installedClasses; |
06d201382b55
8053905: Eager code generation fails for earley boyer with split threshold set to 1000
hannesw
parents:
28126
diff
changeset
|
100 |
} |
06d201382b55
8053905: Eager code generation fails for earley boyer with split threshold set to 1000
hannesw
parents:
28126
diff
changeset
|
101 |
|
32530 | 102 |
FunctionInitializer installFunction(final RecompilableScriptFunctionData data, final CodeInstaller installer) { |
30056
06d201382b55
8053905: Eager code generation fails for earley boyer with split threshold set to 1000
hannesw
parents:
28126
diff
changeset
|
103 |
final Map<String, Class<?>> installedClasses = installClasses(data.getSource(), installer); |
06d201382b55
8053905: Eager code generation fails for earley boyer with split threshold set to 1000
hannesw
parents:
28126
diff
changeset
|
104 |
|
06d201382b55
8053905: Eager code generation fails for earley boyer with split threshold set to 1000
hannesw
parents:
28126
diff
changeset
|
105 |
assert initializers != null; |
06d201382b55
8053905: Eager code generation fails for earley boyer with split threshold set to 1000
hannesw
parents:
28126
diff
changeset
|
106 |
assert initializers.size() == 1; |
06d201382b55
8053905: Eager code generation fails for earley boyer with split threshold set to 1000
hannesw
parents:
28126
diff
changeset
|
107 |
final FunctionInitializer initializer = initializers.values().iterator().next(); |
06d201382b55
8053905: Eager code generation fails for earley boyer with split threshold set to 1000
hannesw
parents:
28126
diff
changeset
|
108 |
|
06d201382b55
8053905: Eager code generation fails for earley boyer with split threshold set to 1000
hannesw
parents:
28126
diff
changeset
|
109 |
for (int i = 0; i < constants.length; i++) { |
06d201382b55
8053905: Eager code generation fails for earley boyer with split threshold set to 1000
hannesw
parents:
28126
diff
changeset
|
110 |
if (constants[i] instanceof RecompilableScriptFunctionData) { |
06d201382b55
8053905: Eager code generation fails for earley boyer with split threshold set to 1000
hannesw
parents:
28126
diff
changeset
|
111 |
// replace deserialized function data with the ones we already have |
06d201382b55
8053905: Eager code generation fails for earley boyer with split threshold set to 1000
hannesw
parents:
28126
diff
changeset
|
112 |
final RecompilableScriptFunctionData newData = data.getScriptFunctionData(((RecompilableScriptFunctionData) constants[i]).getFunctionNodeId()); |
06d201382b55
8053905: Eager code generation fails for earley boyer with split threshold set to 1000
hannesw
parents:
28126
diff
changeset
|
113 |
assert newData != null; |
06d201382b55
8053905: Eager code generation fails for earley boyer with split threshold set to 1000
hannesw
parents:
28126
diff
changeset
|
114 |
newData.initTransients(data.getSource(), installer); |
06d201382b55
8053905: Eager code generation fails for earley boyer with split threshold set to 1000
hannesw
parents:
28126
diff
changeset
|
115 |
constants[i] = newData; |
06d201382b55
8053905: Eager code generation fails for earley boyer with split threshold set to 1000
hannesw
parents:
28126
diff
changeset
|
116 |
} |
06d201382b55
8053905: Eager code generation fails for earley boyer with split threshold set to 1000
hannesw
parents:
28126
diff
changeset
|
117 |
} |
06d201382b55
8053905: Eager code generation fails for earley boyer with split threshold set to 1000
hannesw
parents:
28126
diff
changeset
|
118 |
|
06d201382b55
8053905: Eager code generation fails for earley boyer with split threshold set to 1000
hannesw
parents:
28126
diff
changeset
|
119 |
initializer.setCode(installedClasses.get(initializer.getClassName())); |
06d201382b55
8053905: Eager code generation fails for earley boyer with split threshold set to 1000
hannesw
parents:
28126
diff
changeset
|
120 |
return initializer; |
26055
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
diff
changeset
|
121 |
} |
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
diff
changeset
|
122 |
|
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
diff
changeset
|
123 |
/** |
30056
06d201382b55
8053905: Eager code generation fails for earley boyer with split threshold set to 1000
hannesw
parents:
28126
diff
changeset
|
124 |
* Install as script. |
06d201382b55
8053905: Eager code generation fails for earley boyer with split threshold set to 1000
hannesw
parents:
28126
diff
changeset
|
125 |
* |
06d201382b55
8053905: Eager code generation fails for earley boyer with split threshold set to 1000
hannesw
parents:
28126
diff
changeset
|
126 |
* @param source the source |
06d201382b55
8053905: Eager code generation fails for earley boyer with split threshold set to 1000
hannesw
parents:
28126
diff
changeset
|
127 |
* @param installer the installer |
06d201382b55
8053905: Eager code generation fails for earley boyer with split threshold set to 1000
hannesw
parents:
28126
diff
changeset
|
128 |
* @return main script class |
26055
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
diff
changeset
|
129 |
*/ |
32530 | 130 |
Class<?> installScript(final Source source, final CodeInstaller installer) { |
30056
06d201382b55
8053905: Eager code generation fails for earley boyer with split threshold set to 1000
hannesw
parents:
28126
diff
changeset
|
131 |
|
06d201382b55
8053905: Eager code generation fails for earley boyer with split threshold set to 1000
hannesw
parents:
28126
diff
changeset
|
132 |
final Map<String, Class<?>> installedClasses = installClasses(source, installer); |
26055
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
diff
changeset
|
133 |
|
30056
06d201382b55
8053905: Eager code generation fails for earley boyer with split threshold set to 1000
hannesw
parents:
28126
diff
changeset
|
134 |
for (final Object constant : constants) { |
06d201382b55
8053905: Eager code generation fails for earley boyer with split threshold set to 1000
hannesw
parents:
28126
diff
changeset
|
135 |
if (constant instanceof RecompilableScriptFunctionData) { |
06d201382b55
8053905: Eager code generation fails for earley boyer with split threshold set to 1000
hannesw
parents:
28126
diff
changeset
|
136 |
final RecompilableScriptFunctionData data = (RecompilableScriptFunctionData) constant; |
06d201382b55
8053905: Eager code generation fails for earley boyer with split threshold set to 1000
hannesw
parents:
28126
diff
changeset
|
137 |
data.initTransients(source, installer); |
06d201382b55
8053905: Eager code generation fails for earley boyer with split threshold set to 1000
hannesw
parents:
28126
diff
changeset
|
138 |
final FunctionInitializer initializer = initializers.get(data.getFunctionNodeId()); |
06d201382b55
8053905: Eager code generation fails for earley boyer with split threshold set to 1000
hannesw
parents:
28126
diff
changeset
|
139 |
if (initializer != null) { |
06d201382b55
8053905: Eager code generation fails for earley boyer with split threshold set to 1000
hannesw
parents:
28126
diff
changeset
|
140 |
initializer.setCode(installedClasses.get(initializer.getClassName())); |
06d201382b55
8053905: Eager code generation fails for earley boyer with split threshold set to 1000
hannesw
parents:
28126
diff
changeset
|
141 |
data.initializeCode(initializer); |
06d201382b55
8053905: Eager code generation fails for earley boyer with split threshold set to 1000
hannesw
parents:
28126
diff
changeset
|
142 |
} |
06d201382b55
8053905: Eager code generation fails for earley boyer with split threshold set to 1000
hannesw
parents:
28126
diff
changeset
|
143 |
} |
26764
c777787a937d
8046202: Make persistent code store more flexible
hannesw
parents:
26068
diff
changeset
|
144 |
} |
30056
06d201382b55
8053905: Eager code generation fails for earley boyer with split threshold set to 1000
hannesw
parents:
28126
diff
changeset
|
145 |
|
06d201382b55
8053905: Eager code generation fails for earley boyer with split threshold set to 1000
hannesw
parents:
28126
diff
changeset
|
146 |
return installedClasses.get(mainClassName); |
26055
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
diff
changeset
|
147 |
} |
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
diff
changeset
|
148 |
|
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
diff
changeset
|
149 |
@Override |
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
diff
changeset
|
150 |
public int hashCode() { |
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
diff
changeset
|
151 |
int hash = mainClassName.hashCode(); |
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
diff
changeset
|
152 |
hash = 31 * hash + classBytes.hashCode(); |
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
diff
changeset
|
153 |
hash = 31 * hash + Arrays.hashCode(constants); |
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
diff
changeset
|
154 |
return hash; |
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
diff
changeset
|
155 |
} |
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
diff
changeset
|
156 |
|
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
diff
changeset
|
157 |
@Override |
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
diff
changeset
|
158 |
public boolean equals(final Object obj) { |
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
diff
changeset
|
159 |
if (obj == this) { |
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
diff
changeset
|
160 |
return true; |
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
diff
changeset
|
161 |
} |
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
diff
changeset
|
162 |
if (!(obj instanceof StoredScript)) { |
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
diff
changeset
|
163 |
return false; |
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
diff
changeset
|
164 |
} |
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
diff
changeset
|
165 |
|
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
diff
changeset
|
166 |
final StoredScript cs = (StoredScript) obj; |
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
diff
changeset
|
167 |
return mainClassName.equals(cs.mainClassName) |
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
diff
changeset
|
168 |
&& classBytes.equals(cs.classBytes) |
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
diff
changeset
|
169 |
&& Arrays.equals(constants, cs.constants); |
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
diff
changeset
|
170 |
} |
fe8be844ba50
8043956: Make code caching work with optimistic typing and lazy compilation
hannesw
parents:
diff
changeset
|
171 |
} |