comparison graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/VMToCompilerImpl.java @ 7530:5e3d1a68664e

applied mx eclipseformat to all Java files
author Doug Simon <doug.simon@oracle.com>
date Wed, 23 Jan 2013 16:34:57 +0100
parents 225002aba5a5
children a200d10867f1
comparison
equal deleted inserted replaced
7529:4a11124a3563 7530:5e3d1a68664e
89 Class<?> mirror = type.mirror(); 89 Class<?> mirror = type.mirror();
90 unsafe.putObject(mirror, offset, type); 90 unsafe.putObject(mirror, offset, type);
91 assert unsafe.getObject(mirror, offset) == type; 91 assert unsafe.getObject(mirror, offset) == type;
92 } 92 }
93 93
94
95 public void startCompiler() throws Throwable { 94 public void startCompiler() throws Throwable {
96 95
97 long offset = HotSpotGraalRuntime.getInstance().getConfig().graalMirrorInClassOffset; 96 long offset = HotSpotGraalRuntime.getInstance().getConfig().graalMirrorInClassOffset;
98 initMirror(typeBoolean, offset); 97 initMirror(typeBoolean, offset);
99 initMirror(typeChar, offset); 98 initMirror(typeChar, offset);
131 130
132 // Install intrinsics. 131 // Install intrinsics.
133 GraalCompiler compiler = graalRuntime.getCompiler(); 132 GraalCompiler compiler = graalRuntime.getCompiler();
134 final HotSpotRuntime runtime = (HotSpotRuntime) compiler.runtime; 133 final HotSpotRuntime runtime = (HotSpotRuntime) compiler.runtime;
135 if (GraalOptions.Intrinsify) { 134 if (GraalOptions.Intrinsify) {
136 Debug.scope("InstallSnippets", new Object[] {new DebugDumpScope("InstallSnippets"), compiler}, new Runnable() { 135 Debug.scope("InstallSnippets", new Object[]{new DebugDumpScope("InstallSnippets"), compiler}, new Runnable() {
137 136
138 @Override 137 @Override
139 public void run() { 138 public void run() {
140 // Snippets cannot have speculative optimizations since they have to be valid for the entire run of the VM. 139 // Snippets cannot have speculative optimizations since they have to be valid
140 // for the entire run of the VM.
141 Assumptions assumptions = new Assumptions(false); 141 Assumptions assumptions = new Assumptions(false);
142 SnippetInstaller installer = new HotSpotSnippetInstaller(runtime, assumptions, runtime.getGraalRuntime().getTarget()); 142 SnippetInstaller installer = new HotSpotSnippetInstaller(runtime, assumptions, runtime.getGraalRuntime().getTarget());
143 GraalIntrinsics.installIntrinsics(installer); 143 GraalIntrinsics.installIntrinsics(installer);
144 runtime.installSnippets(installer, assumptions); 144 runtime.installSnippets(installer, assumptions);
145 } 145 }
179 t.start(); 179 t.start();
180 } 180 }
181 } 181 }
182 182
183 /** 183 /**
184 * This method is the first method compiled during bootstrapping. Put any code in there that warms up compiler paths 184 * This method is the first method compiled during bootstrapping. Put any code in there that
185 * that are otherwise not exercised during bootstrapping and lead to later deoptimization when application code is 185 * warms up compiler paths that are otherwise not exercised during bootstrapping and lead to
186 * compiled. 186 * later deoptimization when application code is compiled.
187 */ 187 */
188 @SuppressWarnings("unused") 188 @SuppressWarnings("unused")
189 @Deprecated 189 @Deprecated
190 private synchronized void compileWarmup() { 190 private synchronized void compileWarmup() {
191 // Method is synchronized to exercise the synchronization code in the compiler. 191 // Method is synchronized to exercise the synchronization code in the compiler.
274 shutdownCompileQueue(slowCompileQueue); 274 shutdownCompileQueue(slowCompileQueue);
275 } finally { 275 } finally {
276 CompilationTask.withinEnqueue.set(Boolean.FALSE); 276 CompilationTask.withinEnqueue.set(Boolean.FALSE);
277 } 277 }
278 278
279
280 if (Debug.isEnabled()) { 279 if (Debug.isEnabled()) {
281 List<DebugValueMap> topLevelMaps = DebugValueMap.getTopLevelMaps(); 280 List<DebugValueMap> topLevelMaps = DebugValueMap.getTopLevelMaps();
282 List<DebugValue> debugValues = KeyRegistry.getDebugValues(); 281 List<DebugValue> debugValues = KeyRegistry.getDebugValues();
283 if (debugValues.size() > 0) { 282 if (debugValues.size() > 0) {
284 ArrayList<DebugValue> sortedValues = new ArrayList<>(debugValues); 283 ArrayList<DebugValue> sortedValues = new ArrayList<>(debugValues);
376 return compileMethod(method, entryBCI, blocking, priority); 375 return compileMethod(method, entryBCI, blocking, priority);
377 } 376 }
378 377
379 /** 378 /**
380 * Compiles a method to machine code. 379 * Compiles a method to machine code.
381 * @return true if the method is in the queue (either added to the queue or already in the queue) 380 *
381 * @return true if the method is in the queue (either added to the queue or already in the
382 * queue)
382 */ 383 */
383 public boolean compileMethod(final HotSpotResolvedJavaMethod method, final int entryBCI, boolean blocking, int priority) throws Throwable { 384 public boolean compileMethod(final HotSpotResolvedJavaMethod method, final int entryBCI, boolean blocking, int priority) throws Throwable {
384 CompilationTask current = method.currentTask(); 385 CompilationTask current = method.currentTask();
385 boolean osrCompilation = entryBCI != StructuredGraph.INVOCATION_ENTRY_BCI; 386 boolean osrCompilation = entryBCI != StructuredGraph.INVOCATION_ENTRY_BCI;
386 if (osrCompilation && bootstrapRunning) { 387 if (osrCompilation && bootstrapRunning) {
387 // no OSR compilations during bootstrap - the compiler is just too slow at this point, and we know that there are no endless loops 388 // no OSR compilations during bootstrap - the compiler is just too slow at this point,
389 // and we know that there are no endless loops
388 return current != null; 390 return current != null;
389 } 391 }
390 392
391 if (CompilationTask.withinEnqueue.get()) { 393 if (CompilationTask.withinEnqueue.get()) {
392 // This is required to avoid deadlocking a compiler thread. The issue is that a 394 // This is required to avoid deadlocking a compiler thread. The issue is that a
399 401
400 try { 402 try {
401 if (!blocking && current != null) { 403 if (!blocking && current != null) {
402 if (current.isInProgress()) { 404 if (current.isInProgress()) {
403 if (current.getEntryBCI() == entryBCI) { 405 if (current.getEntryBCI() == entryBCI) {
404 // a compilation with the correct bci is already in progress, so just return true 406 // a compilation with the correct bci is already in progress, so just return
407 // true
405 return true; 408 return true;
406 } 409 }
407 } else { 410 } else {
408 if (GraalOptions.PriorityCompileQueue) { 411 if (GraalOptions.PriorityCompileQueue) {
409 // normally compilation tasks will only be re-queued when they get a priority boost, so cancel the old task and add a new one 412 // normally compilation tasks will only be re-queued when they get a
413 // priority boost, so cancel the old task and add a new one
410 current.cancel(); 414 current.cancel();
411 } else { 415 } else {
412 // without a prioritizing compile queue it makes no sense to re-queue the compilation task 416 // without a prioritizing compile queue it makes no sense to re-queue the
417 // compilation task
413 return true; 418 return true;
414 } 419 }
415 } 420 }
416 } 421 }
417 422
505 return new HotSpotUnresolvedJavaType(HotSpotUnresolvedJavaType.getFullName(name, dims), name, dims); 510 return new HotSpotUnresolvedJavaType(HotSpotUnresolvedJavaType.getFullName(name, dims), name, dims);
506 } 511 }
507 } 512 }
508 513
509 @Override 514 @Override
510 public HotSpotResolvedObjectType createResolvedJavaType(long metaspaceKlass, 515 public HotSpotResolvedObjectType createResolvedJavaType(long metaspaceKlass, String name, String simpleName, Class javaMirror, boolean hasFinalizableSubclass, int sizeOrSpecies) {
511 String name, 516 HotSpotResolvedObjectType type = new HotSpotResolvedObjectType(metaspaceKlass, name, simpleName, javaMirror, hasFinalizableSubclass, sizeOrSpecies);
512 String simpleName,
513 Class javaMirror,
514 boolean hasFinalizableSubclass,
515 int sizeOrSpecies) {
516 HotSpotResolvedObjectType type = new HotSpotResolvedObjectType(
517 metaspaceKlass,
518 name,
519 simpleName,
520 javaMirror,
521 hasFinalizableSubclass,
522 sizeOrSpecies);
523 517
524 long offset = HotSpotGraalRuntime.getInstance().getConfig().graalMirrorInClassOffset; 518 long offset = HotSpotGraalRuntime.getInstance().getConfig().graalMirrorInClassOffset;
525 if (!unsafe.compareAndSwapObject(javaMirror, offset, null, type)) { 519 if (!unsafe.compareAndSwapObject(javaMirror, offset, null, type)) {
526 // lost the race - return the existing value instead 520 // lost the race - return the existing value instead
527 type = (HotSpotResolvedObjectType) unsafe.getObject(javaMirror, offset); 521 type = (HotSpotResolvedObjectType) unsafe.getObject(javaMirror, offset);