blob: 6e1853bbd7d333cd033f23e0722e7d4606de9d5b [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"
Vladimir Marko41b175a2015-05-19 18:08:00 +010025#include "utils.h"
Andreas Gampe53c913b2014-08-12 23:19:23 -070026
27namespace art {
28
Andreas Gampe0b9203e2015-01-22 20:39:27 -080029CompilationUnit::CompilationUnit(ArenaPool* pool, InstructionSet isa, CompilerDriver* driver,
30 ClassLinker* linker)
31 : compiler_driver(driver),
32 class_linker(linker),
Andreas Gampe53c913b2014-08-12 23:19:23 -070033 dex_file(nullptr),
34 class_loader(nullptr),
35 class_def_idx(0),
36 method_idx(0),
Andreas Gampe53c913b2014-08-12 23:19:23 -070037 access_flags(0),
38 invoke_type(kDirect),
39 shorty(nullptr),
40 disable_opt(0),
41 enable_debug(0),
42 verbose(false),
Andreas Gampe0b9203e2015-01-22 20:39:27 -080043 instruction_set(isa),
44 target64(Is64BitInstructionSet(isa)),
Andreas Gampe53c913b2014-08-12 23:19:23 -070045 arena(pool),
46 arena_stack(pool),
47 mir_graph(nullptr),
48 cg(nullptr),
49 timings("QuickCompiler", true, false),
50 print_pass(false) {
51}
52
53CompilationUnit::~CompilationUnit() {
Razvan A Lupusorubd25d4b2014-07-02 18:16:51 -070054 overridden_pass_options.clear();
Andreas Gampe53c913b2014-08-12 23:19:23 -070055}
56
57void CompilationUnit::StartTimingSplit(const char* label) {
58 if (compiler_driver->GetDumpPasses()) {
59 timings.StartTiming(label);
60 }
61}
62
63void CompilationUnit::NewTimingSplit(const char* label) {
64 if (compiler_driver->GetDumpPasses()) {
65 timings.EndTiming();
66 timings.StartTiming(label);
67 }
68}
69
70void 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