Mercurial > hg > truffle
comparison graal/com.oracle.jvmci.compiler/src/com/oracle/jvmci/compiler/CompilerThread.java @ 21780:3d15183f3c93
Introduce Compiler interface in jvmci. Use it from jvmci.hotspot.CompilationTask
author | Gilles Duboscq <gilles.m.duboscq@oracle.com> |
---|---|
date | Wed, 03 Jun 2015 15:47:54 +0200 |
parents | graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/CompilerThread.java@b1530a6cce8c |
children |
comparison
equal
deleted
inserted
replaced
21779:20ace3139510 | 21780:3d15183f3c93 |
---|---|
1 /* | |
2 * Copyright (c) 2012, 2014, 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 */ | |
23 package com.oracle.jvmci.compiler; | |
24 | |
25 import com.oracle.jvmci.compiler.CompilerThreadFactory.*; | |
26 import com.oracle.jvmci.debug.*; | |
27 | |
28 /** | |
29 * A compiler thread is a daemon thread that runs at {@link Thread#MAX_PRIORITY} and executes in the | |
30 * context of a thread-local {@linkplain JVMCIDebugConfig debug configuration}. | |
31 */ | |
32 public class CompilerThread extends Thread { | |
33 | |
34 private final DebugConfigAccess debugConfigAccess; | |
35 | |
36 public CompilerThread(Runnable r, String namePrefix, DebugConfigAccess debugConfigAccess) { | |
37 super(r); | |
38 this.setName(namePrefix + "-" + this.getId()); | |
39 this.setPriority(Thread.MAX_PRIORITY); | |
40 this.setDaemon(true); | |
41 this.debugConfigAccess = debugConfigAccess; | |
42 } | |
43 | |
44 @Override | |
45 public void run() { | |
46 JVMCIDebugConfig debugConfig = debugConfigAccess.getDebugConfig(); | |
47 setContextClassLoader(getClass().getClassLoader()); | |
48 try { | |
49 super.run(); | |
50 } finally { | |
51 if (debugConfig != null) { | |
52 for (DebugDumpHandler dumpHandler : debugConfig.dumpHandlers()) { | |
53 try { | |
54 dumpHandler.close(); | |
55 } catch (Throwable t) { | |
56 } | |
57 } | |
58 } | |
59 } | |
60 } | |
61 } |