1 /*
2 * Copyright (C) 2014 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
17 #include "compiler_ir.h"
18
19 #include "arch/instruction_set_features.h"
20 #include "base/dumpable.h"
21 #include "dex_flags.h"
22 #include "dex/quick/mir_to_lir.h"
23 #include "driver/compiler_driver.h"
24 #include "mir_graph.h"
25 #include "utils.h"
26
27 namespace art {
28
CompilationUnit(ArenaPool * pool,InstructionSet isa,CompilerDriver * driver,ClassLinker * linker)29 CompilationUnit::CompilationUnit(ArenaPool* pool, InstructionSet isa, CompilerDriver* driver,
30 ClassLinker* linker)
31 : compiler_driver(driver),
32 class_linker(linker),
33 dex_file(nullptr),
34 class_loader(nullptr),
35 class_def_idx(0),
36 method_idx(0),
37 access_flags(0),
38 invoke_type(kDirect),
39 shorty(nullptr),
40 disable_opt(0),
41 enable_debug(0),
42 verbose(false),
43 instruction_set(isa),
44 target64(Is64BitInstructionSet(isa)),
45 arena(pool),
46 arena_stack(pool),
47 mir_graph(nullptr),
48 cg(nullptr),
49 timings("QuickCompiler", true, false),
50 print_pass(false) {
51 }
52
~CompilationUnit()53 CompilationUnit::~CompilationUnit() {
54 overridden_pass_options.clear();
55 }
56
StartTimingSplit(const char * label)57 void CompilationUnit::StartTimingSplit(const char* label) {
58 if (compiler_driver->GetDumpPasses()) {
59 timings.StartTiming(label);
60 }
61 }
62
NewTimingSplit(const char * label)63 void CompilationUnit::NewTimingSplit(const char* label) {
64 if (compiler_driver->GetDumpPasses()) {
65 timings.EndTiming();
66 timings.StartTiming(label);
67 }
68 }
69
EndTiming()70 void CompilationUnit::EndTiming() {
71 if (compiler_driver->GetDumpPasses()) {
72 timings.EndTiming();
73 if (enable_debug & (1 << kDebugTimings)) {
74 LOG(INFO) << "TIMINGS " << PrettyMethod(method_idx, *dex_file);
75 LOG(INFO) << Dumpable<TimingLogger>(timings);
76 }
77 }
78 }
79
80 } // namespace art
81