blob: 7bfc9bae91644c104f1ae9db388b41c4be03aaf4 [file] [log] [blame]
Brian Carlstrom751d4ed2013-07-18 16:20:16 -07001/*
2 * Copyright (C) 2013 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
Brian Carlstrom7940e442013-07-12 13:46:57 -070017#ifdef ART_SEA_IR_MODE
18#include <llvm/Support/Threading.h>
19#include "base/logging.h"
20#include "dex/portable/mir_to_gbc.h"
21#include "driver/compiler_driver.h"
22#include "leb128.h"
23#include "llvm/llvm_compilation_unit.h"
24#include "mirror/object.h"
25#include "runtime.h"
26#include "sea_ir/sea.h"
27
28namespace art {
29
30static CompiledMethod* CompileMethodWithSeaIr(CompilerDriver& compiler,
31 const CompilerBackend compiler_backend,
32 const DexFile::CodeItem* code_item,
33 uint32_t access_flags, InvokeType invoke_type,
34 uint32_t class_def_idx, uint32_t method_idx,
35 jobject class_loader, const DexFile& dex_file
36#if defined(ART_USE_PORTABLE_COMPILER)
37 , llvm::LlvmCompilationUnit* llvm_compilation_unit
38#endif
39) {
40 // NOTE: Instead of keeping the convention from the Dalvik frontend.cc
41 // and silencing the cpplint.py warning, I just corrected the formatting.
42 VLOG(compiler) << "Compiling " << PrettyMethod(method_idx, dex_file) << "...";
43 sea_ir::SeaGraph* sg = sea_ir::SeaGraph::GetCurrentGraph();
44 sg->CompileMethod(code_item, class_def_idx, method_idx, dex_file);
45 sg->DumpSea("/tmp/temp.dot");
46 CHECK(0 && "No SEA compiled function exists yet.");
47 return NULL;
48}
49
50
51CompiledMethod* SeaIrCompileOneMethod(CompilerDriver& compiler,
52 const CompilerBackend backend,
53 const DexFile::CodeItem* code_item,
54 uint32_t access_flags,
55 InvokeType invoke_type,
56 uint32_t class_def_idx,
57 uint32_t method_idx,
58 jobject class_loader,
59 const DexFile& dex_file,
60 llvm::LlvmCompilationUnit* llvm_compilation_unit) {
61 return CompileMethodWithSeaIr(compiler, backend, code_item, access_flags, invoke_type, class_def_idx,
62 method_idx, class_loader, dex_file
63#if defined(ART_USE_PORTABLE_COMPILER)
64 , llvm_compilation_unit
65#endif
66 ); // NOLINT
67}
68
69extern "C" art::CompiledMethod*
70 SeaIrCompileMethod(art::CompilerDriver& compiler,
71 const art::DexFile::CodeItem* code_item,
72 uint32_t access_flags, art::InvokeType invoke_type,
73 uint32_t class_def_idx, uint32_t method_idx, jobject class_loader,
74 const art::DexFile& dex_file) {
75 // TODO: check method fingerprint here to determine appropriate backend type. Until then, use build default
76 art::CompilerBackend backend = compiler.GetCompilerBackend();
77 return art::SeaIrCompileOneMethod(compiler, backend, code_item, access_flags, invoke_type,
78 class_def_idx, method_idx, class_loader, dex_file,
79 NULL /* use thread llvm_info */);
80}
81#endif
82
83} // end namespace art