Mercurial > hg > graal-compiler
annotate graal/com.oracle.truffle.api/src/com/oracle/truffle/api/utilities/BranchProfile.java @ 13874:c35d86f53ace
fix Truffle JavaDoc
author | Christian Wirth <christian.wirth@oracle.com> |
---|---|
date | Wed, 05 Feb 2014 11:38:00 +0100 |
parents | 8531c47138dc |
children | a0200c215fb2 64dcb92ee75a |
rev | line source |
---|---|
13335
8531c47138dc
Truffle: introduced new profiling utility BranchProfile.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
1 /* |
8531c47138dc
Truffle: introduced new profiling utility BranchProfile.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
2 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. |
8531c47138dc
Truffle: introduced new profiling utility BranchProfile.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
8531c47138dc
Truffle: introduced new profiling utility BranchProfile.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
4 * |
8531c47138dc
Truffle: introduced new profiling utility BranchProfile.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
8531c47138dc
Truffle: introduced new profiling utility BranchProfile.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
8531c47138dc
Truffle: introduced new profiling utility BranchProfile.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. Oracle designates this |
8531c47138dc
Truffle: introduced new profiling utility BranchProfile.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
8 * particular file as subject to the "Classpath" exception as provided |
8531c47138dc
Truffle: introduced new profiling utility BranchProfile.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
9 * by Oracle in the LICENSE file that accompanied this code. |
8531c47138dc
Truffle: introduced new profiling utility BranchProfile.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
10 * |
8531c47138dc
Truffle: introduced new profiling utility BranchProfile.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
11 * This code is distributed in the hope that it will be useful, but WITHOUT |
8531c47138dc
Truffle: introduced new profiling utility BranchProfile.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
8531c47138dc
Truffle: introduced new profiling utility BranchProfile.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
8531c47138dc
Truffle: introduced new profiling utility BranchProfile.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
14 * version 2 for more details (a copy is included in the LICENSE file that |
8531c47138dc
Truffle: introduced new profiling utility BranchProfile.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
15 * accompanied this code). |
8531c47138dc
Truffle: introduced new profiling utility BranchProfile.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
16 * |
8531c47138dc
Truffle: introduced new profiling utility BranchProfile.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
17 * You should have received a copy of the GNU General Public License version |
8531c47138dc
Truffle: introduced new profiling utility BranchProfile.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
18 * 2 along with this work; if not, write to the Free Software Foundation, |
8531c47138dc
Truffle: introduced new profiling utility BranchProfile.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
8531c47138dc
Truffle: introduced new profiling utility BranchProfile.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
20 * |
8531c47138dc
Truffle: introduced new profiling utility BranchProfile.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
8531c47138dc
Truffle: introduced new profiling utility BranchProfile.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
22 * or visit www.oracle.com if you need additional information or have any |
8531c47138dc
Truffle: introduced new profiling utility BranchProfile.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
23 * questions. |
8531c47138dc
Truffle: introduced new profiling utility BranchProfile.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
24 */ |
8531c47138dc
Truffle: introduced new profiling utility BranchProfile.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
25 package com.oracle.truffle.api.utilities; |
8531c47138dc
Truffle: introduced new profiling utility BranchProfile.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
26 |
8531c47138dc
Truffle: introduced new profiling utility BranchProfile.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
27 import com.oracle.truffle.api.*; |
8531c47138dc
Truffle: introduced new profiling utility BranchProfile.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
28 import com.oracle.truffle.api.CompilerDirectives.*; |
8531c47138dc
Truffle: introduced new profiling utility BranchProfile.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
29 |
8531c47138dc
Truffle: introduced new profiling utility BranchProfile.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
30 /** |
8531c47138dc
Truffle: introduced new profiling utility BranchProfile.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
31 * Utility class to speculate on branches to be never visited. If the {@link #enter()} method is |
8531c47138dc
Truffle: introduced new profiling utility BranchProfile.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
32 * invoked first the optimized code is invalidated and the branch where {@link #enter()} is invoked |
8531c47138dc
Truffle: introduced new profiling utility BranchProfile.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
33 * is enabled for compilation. Otherwise if the {@link #enter()} method was never invoked the branch |
8531c47138dc
Truffle: introduced new profiling utility BranchProfile.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
34 * will not get compiled. |
8531c47138dc
Truffle: introduced new profiling utility BranchProfile.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
35 */ |
8531c47138dc
Truffle: introduced new profiling utility BranchProfile.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
36 public final class BranchProfile { |
8531c47138dc
Truffle: introduced new profiling utility BranchProfile.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
37 |
8531c47138dc
Truffle: introduced new profiling utility BranchProfile.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
38 @CompilationFinal private boolean visited; |
8531c47138dc
Truffle: introduced new profiling utility BranchProfile.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
39 |
8531c47138dc
Truffle: introduced new profiling utility BranchProfile.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
40 public void enter() { |
8531c47138dc
Truffle: introduced new profiling utility BranchProfile.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
41 if (!visited) { |
8531c47138dc
Truffle: introduced new profiling utility BranchProfile.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
42 CompilerDirectives.transferToInterpreterAndInvalidate(); |
8531c47138dc
Truffle: introduced new profiling utility BranchProfile.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
43 visited = true; |
8531c47138dc
Truffle: introduced new profiling utility BranchProfile.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
44 } |
8531c47138dc
Truffle: introduced new profiling utility BranchProfile.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
45 } |
8531c47138dc
Truffle: introduced new profiling utility BranchProfile.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
46 |
8531c47138dc
Truffle: introduced new profiling utility BranchProfile.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
47 } |