Mercurial > hg > truffle
annotate graal/com.oracle.graal.baseline/src/com/oracle/graal/baseline/BaselineCompiler.java @ 18408:2c3666f44855
Truffle: initial commit of object API implementation
author | Andreas Woess <andreas.woess@jku.at> |
---|---|
date | Tue, 18 Nov 2014 23:19:43 +0100 |
parents | 7e0563f0d249 |
children | 323ac2b4d988 |
rev | line source |
---|---|
14127 | 1 /* |
2 * Copyright (c) 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.graal.baseline; | |
24 | |
15259
d90e5c22ba55
Move GraalOptions to graal.compiler.common.
Josef Eisl <josef.eisl@jku.at>
parents:
14991
diff
changeset
|
25 import static com.oracle.graal.compiler.common.GraalOptions.*; |
14127 | 26 |
27 import com.oracle.graal.api.code.*; | |
28 import com.oracle.graal.api.meta.*; | |
29 import com.oracle.graal.bytecode.*; | |
14790
3518daf2f9bc
Add call to GraalCompiler.emitCode() from BaselineCompiler.
Josef Eisl <josef.eisl@jku.at>
parents:
14127
diff
changeset
|
30 import com.oracle.graal.compiler.*; |
3518daf2f9bc
Add call to GraalCompiler.emitCode() from BaselineCompiler.
Josef Eisl <josef.eisl@jku.at>
parents:
14127
diff
changeset
|
31 import com.oracle.graal.compiler.target.*; |
14127 | 32 import com.oracle.graal.debug.*; |
33 import com.oracle.graal.java.*; | |
14790
3518daf2f9bc
Add call to GraalCompiler.emitCode() from BaselineCompiler.
Josef Eisl <josef.eisl@jku.at>
parents:
14127
diff
changeset
|
34 import com.oracle.graal.lir.asm.*; |
14919
bd08e610e6f3
BaselineCompiler: create BytecodeParser.
Josef Eisl <josef.eisl@jku.at>
parents:
14902
diff
changeset
|
35 import com.oracle.graal.phases.*; |
14127 | 36 |
37 /** | |
38 * The {@code GraphBuilder} class parses the bytecode of a method and builds the IR graph. | |
39 */ | |
40 @SuppressWarnings("all") | |
14925
48935ef7664f
Remove deprecated BytecodeParser interface.
Josef Eisl <josef.eisl@jku.at>
parents:
14924
diff
changeset
|
41 public class BaselineCompiler { |
14127 | 42 |
43 public BaselineCompiler(GraphBuilderConfiguration graphBuilderConfig, MetaAccessProvider metaAccess) { | |
44 this.graphBuilderConfig = graphBuilderConfig; | |
45 this.metaAccess = metaAccess; | |
46 } | |
47 | |
48 private final MetaAccessProvider metaAccess; | |
49 | |
50 private final GraphBuilderConfiguration graphBuilderConfig; | |
51 | |
14790
3518daf2f9bc
Add call to GraalCompiler.emitCode() from BaselineCompiler.
Josef Eisl <josef.eisl@jku.at>
parents:
14127
diff
changeset
|
52 public CompilationResult generate(ResolvedJavaMethod method, int entryBCI, Backend backend, CompilationResult compilationResult, ResolvedJavaMethod installedCodeOwner, |
14919
bd08e610e6f3
BaselineCompiler: create BytecodeParser.
Josef Eisl <josef.eisl@jku.at>
parents:
14902
diff
changeset
|
53 CompilationResultBuilderFactory factory, OptimisticOptimizations optimisticOpts) { |
bd08e610e6f3
BaselineCompiler: create BytecodeParser.
Josef Eisl <josef.eisl@jku.at>
parents:
14902
diff
changeset
|
54 ProfilingInfo profilingInfo = method.getProfilingInfo(); |
14127 | 55 assert method.getCode() != null : "method must contain bytecodes: " + method; |
14919
bd08e610e6f3
BaselineCompiler: create BytecodeParser.
Josef Eisl <josef.eisl@jku.at>
parents:
14902
diff
changeset
|
56 BytecodeStream stream = new BytecodeStream(method.getCode()); |
bd08e610e6f3
BaselineCompiler: create BytecodeParser.
Josef Eisl <josef.eisl@jku.at>
parents:
14902
diff
changeset
|
57 ConstantPool constantPool = method.getConstantPool(); |
14127 | 58 TTY.Filter filter = new TTY.Filter(PrintFilter.getValue(), method); |
14790
3518daf2f9bc
Add call to GraalCompiler.emitCode() from BaselineCompiler.
Josef Eisl <josef.eisl@jku.at>
parents:
14127
diff
changeset
|
59 |
15306
7e0563f0d249
Rename LIRFrameStateBuilder to BaselineFrameStateBuilder.
Josef Eisl <josef.eisl@jku.at>
parents:
15259
diff
changeset
|
60 BaselineFrameStateBuilder frameState = new BaselineFrameStateBuilder(method); |
14919
bd08e610e6f3
BaselineCompiler: create BytecodeParser.
Josef Eisl <josef.eisl@jku.at>
parents:
14902
diff
changeset
|
61 |
14927
93de07975ea9
Create dedicated BaselineBytecodeParser, BytecodeLIRBuilder and amd64 specialization.
Josef Eisl <josef.eisl@jku.at>
parents:
14926
diff
changeset
|
62 BaselineBytecodeParser parser = new BaselineBytecodeParser(metaAccess, method, graphBuilderConfig, optimisticOpts, frameState, stream, profilingInfo, constantPool, entryBCI, backend); |
14827
2ed3233503b8
Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
14824
diff
changeset
|
63 |
2ed3233503b8
Starting point of the baseline bytecode parser
Niclas Adlertz <niclas.adlertz@oracle.com>
parents:
14824
diff
changeset
|
64 // build blocks and LIR instructions |
14127 | 65 try { |
14919
bd08e610e6f3
BaselineCompiler: create BytecodeParser.
Josef Eisl <josef.eisl@jku.at>
parents:
14902
diff
changeset
|
66 parser.build(); |
14127 | 67 } finally { |
68 filter.remove(); | |
69 } | |
14802
10dde0063f5a
BaselineCompiler: update LIRBlock.
Josef Eisl <josef.eisl@jku.at>
parents:
14790
diff
changeset
|
70 |
14790
3518daf2f9bc
Add call to GraalCompiler.emitCode() from BaselineCompiler.
Josef Eisl <josef.eisl@jku.at>
parents:
14127
diff
changeset
|
71 // emitCode |
3518daf2f9bc
Add call to GraalCompiler.emitCode() from BaselineCompiler.
Josef Eisl <josef.eisl@jku.at>
parents:
14127
diff
changeset
|
72 Assumptions assumptions = new Assumptions(OptAssumptions.getValue()); |
14927
93de07975ea9
Create dedicated BaselineBytecodeParser, BytecodeLIRBuilder and amd64 specialization.
Josef Eisl <josef.eisl@jku.at>
parents:
14926
diff
changeset
|
73 GraalCompiler.emitCode(backend, assumptions, parser.getLIRGenerationResult(), compilationResult, installedCodeOwner, factory); |
14790
3518daf2f9bc
Add call to GraalCompiler.emitCode() from BaselineCompiler.
Josef Eisl <josef.eisl@jku.at>
parents:
14127
diff
changeset
|
74 |
3518daf2f9bc
Add call to GraalCompiler.emitCode() from BaselineCompiler.
Josef Eisl <josef.eisl@jku.at>
parents:
14127
diff
changeset
|
75 return compilationResult; |
14127 | 76 } |
77 } |