Mercurial > hg > truffle
annotate test/compiler/stable/StableConfiguration.java @ 19078:5447a27a6fd7
Make StackUsePosList and StackInterval final.
author | Josef Eisl <josef.eisl@jku.at> |
---|---|
date | Fri, 30 Jan 2015 15:39:59 +0100 |
parents | ee1c924763d2 |
children |
rev | line source |
---|---|
18004
ee1c924763d2
8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents:
diff
changeset
|
1 /* |
ee1c924763d2
8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents:
diff
changeset
|
2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. |
ee1c924763d2
8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
ee1c924763d2
8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents:
diff
changeset
|
4 * |
ee1c924763d2
8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
ee1c924763d2
8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
ee1c924763d2
8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents:
diff
changeset
|
7 * published by the Free Software Foundation. Oracle designates this |
ee1c924763d2
8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents:
diff
changeset
|
8 * particular file as subject to the "Classpath" exception as provided |
ee1c924763d2
8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents:
diff
changeset
|
9 * by Oracle in the LICENSE file that accompanied this code. |
ee1c924763d2
8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents:
diff
changeset
|
10 * |
ee1c924763d2
8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents:
diff
changeset
|
11 * This code is distributed in the hope that it will be useful, but WITHOUT |
ee1c924763d2
8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents:
diff
changeset
|
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
ee1c924763d2
8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents:
diff
changeset
|
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
ee1c924763d2
8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents:
diff
changeset
|
14 * version 2 for more details (a copy is included in the LICENSE file that |
ee1c924763d2
8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents:
diff
changeset
|
15 * accompanied this code). |
ee1c924763d2
8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents:
diff
changeset
|
16 * |
ee1c924763d2
8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents:
diff
changeset
|
17 * You should have received a copy of the GNU General Public License version |
ee1c924763d2
8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents:
diff
changeset
|
18 * 2 along with this work; if not, write to the Free Software Foundation, |
ee1c924763d2
8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents:
diff
changeset
|
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
ee1c924763d2
8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents:
diff
changeset
|
20 * |
ee1c924763d2
8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents:
diff
changeset
|
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
ee1c924763d2
8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents:
diff
changeset
|
22 * or visit www.oracle.com if you need additional information or have any |
ee1c924763d2
8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents:
diff
changeset
|
23 * questions. |
ee1c924763d2
8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents:
diff
changeset
|
24 */ |
ee1c924763d2
8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents:
diff
changeset
|
25 package java.lang.invoke; |
ee1c924763d2
8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents:
diff
changeset
|
26 |
ee1c924763d2
8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents:
diff
changeset
|
27 import java.lang.reflect.Method; |
ee1c924763d2
8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents:
diff
changeset
|
28 import java.util.Properties; |
ee1c924763d2
8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents:
diff
changeset
|
29 import sun.hotspot.WhiteBox; |
ee1c924763d2
8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents:
diff
changeset
|
30 |
ee1c924763d2
8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents:
diff
changeset
|
31 public class StableConfiguration { |
ee1c924763d2
8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents:
diff
changeset
|
32 static final WhiteBox WB = WhiteBox.getWhiteBox(); |
ee1c924763d2
8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents:
diff
changeset
|
33 static final boolean isStableEnabled; |
ee1c924763d2
8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents:
diff
changeset
|
34 static final boolean isServerWithStable; |
ee1c924763d2
8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents:
diff
changeset
|
35 |
ee1c924763d2
8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents:
diff
changeset
|
36 static { |
ee1c924763d2
8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents:
diff
changeset
|
37 Boolean value = WB.getBooleanVMFlag("FoldStableValues"); |
ee1c924763d2
8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents:
diff
changeset
|
38 isStableEnabled = (value == null ? false : value); |
ee1c924763d2
8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents:
diff
changeset
|
39 isServerWithStable = isStableEnabled && get(); |
ee1c924763d2
8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents:
diff
changeset
|
40 System.out.println("@Stable: " + (isStableEnabled ? "enabled" : "disabled")); |
ee1c924763d2
8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents:
diff
changeset
|
41 System.out.println("Server Compiler: " + get()); |
ee1c924763d2
8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents:
diff
changeset
|
42 } |
ee1c924763d2
8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents:
diff
changeset
|
43 |
ee1c924763d2
8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents:
diff
changeset
|
44 // ::get() is among immediately compiled methods. |
ee1c924763d2
8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents:
diff
changeset
|
45 static boolean get() { |
ee1c924763d2
8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents:
diff
changeset
|
46 try { |
ee1c924763d2
8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents:
diff
changeset
|
47 Method m = StableConfiguration.class.getDeclaredMethod("get"); |
ee1c924763d2
8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents:
diff
changeset
|
48 int level = WB.getMethodCompilationLevel(m); |
ee1c924763d2
8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents:
diff
changeset
|
49 if (level > 0) { |
ee1c924763d2
8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents:
diff
changeset
|
50 return (level == 4); |
ee1c924763d2
8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents:
diff
changeset
|
51 } else { |
ee1c924763d2
8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents:
diff
changeset
|
52 String javaVM = System.getProperty("java.vm.name", ""); |
ee1c924763d2
8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents:
diff
changeset
|
53 if (javaVM.contains("Server")) return true; |
ee1c924763d2
8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents:
diff
changeset
|
54 if (javaVM.contains("Client")) return false; |
ee1c924763d2
8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents:
diff
changeset
|
55 throw new Error("Unknown VM type: "+javaVM); |
ee1c924763d2
8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents:
diff
changeset
|
56 } |
ee1c924763d2
8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents:
diff
changeset
|
57 } catch (NoSuchMethodException e) { |
ee1c924763d2
8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents:
diff
changeset
|
58 throw new Error(e); |
ee1c924763d2
8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents:
diff
changeset
|
59 } |
ee1c924763d2
8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents:
diff
changeset
|
60 } |
ee1c924763d2
8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents:
diff
changeset
|
61 |
ee1c924763d2
8043546: C1 optimizes @Stable instance fields with default values
vlivanov
parents:
diff
changeset
|
62 } |