blob: 7fc1b0303540585b20456743eb51bf1dbe22c04a [file] [log] [blame]
Andreas Gampe53c913b2014-08-12 23:19:23 -07001/*
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
Andreas Gampe0b9203e2015-01-22 20:39:27 -080019#include "arch/instruction_set_features.h"
Ian Rogersc7dd2952014-10-21 23:31:19 -070020#include "base/dumpable.h"
Andreas Gampe0b9203e2015-01-22 20:39:27 -080021#include "dex_flags.h"
Andreas Gampe9c462082015-01-27 14:31:40 -080022#include "dex/quick/mir_to_lir.h"
Andreas Gampe0b9203e2015-01-22 20:39:27 -080023#include "driver/compiler_driver.h"
Andreas Gampe53c913b2014-08-12 23:19:23 -070024#include "mir_graph.h"
25
26namespace art {
27
Andreas Gampe0b9203e2015-01-22 20:39:27 -080028CompilationUnit::CompilationUnit(ArenaPool* pool, InstructionSet isa, CompilerDriver* driver,
29 ClassLinker* linker)
30 : compiler_driver(driver),
31 class_linker(linker),
Andreas Gampe53c913b2014-08-12 23:19:23 -070032 dex_file(nullptr),
33 class_loader(nullptr),
34 class_def_idx(0),
35 method_idx(0),
Andreas Gampe53c913b2014-08-12 23:19:23 -070036 access_flags(0),
37 invoke_type(kDirect),
38 shorty(nullptr),
39 disable_opt(0),
40 enable_debug(0),
41 verbose(false),
Andreas Gampe0b9203e2015-01-22 20:39:27 -080042 instruction_set(isa),
43 target64(Is64BitInstructionSet(isa)),
Andreas Gampe53c913b2014-08-12 23:19:23 -070044 arena(pool),
45 arena_stack(pool),
46 mir_graph(nullptr),
47 cg(nullptr),
48 timings("QuickCompiler", true, false),
49 print_pass(false) {
50}
51
52CompilationUnit::~CompilationUnit() {
Razvan A Lupusorubd25d4b2014-07-02 18:16:51 -070053 overridden_pass_options.clear();
Andreas Gampe53c913b2014-08-12 23:19:23 -070054}
55
56void CompilationUnit::StartTimingSplit(const char* label) {
57 if (compiler_driver->GetDumpPasses()) {
58 timings.StartTiming(label);
59 }
60}
61
62void CompilationUnit::NewTimingSplit(const char* label) {
63 if (compiler_driver->GetDumpPasses()) {
64 timings.EndTiming();
65 timings.StartTiming(label);
66 }
67}
68
69void CompilationUnit::EndTiming() {
70 if (compiler_driver->GetDumpPasses()) {
71 timings.EndTiming();
72 if (enable_debug & (1 << kDebugTimings)) {
73 LOG(INFO) << "TIMINGS " << PrettyMethod(method_idx, *dex_file);
74 LOG(INFO) << Dumpable<TimingLogger>(timings);
75 }
76 }
77}
78
79} // namespace art