hotspot/src/share/vm/c1/c1_Compilation.cpp
author rehn
Tue, 15 Mar 2016 14:41:07 +0100
changeset 37161 e881f320966e
parent 35576 1f1cca67a48e
child 37248 11a660dbbb8e
permissions -rw-r--r--
8150015: Integrate TraceTime with Unified Logging more seamlessly Reviewed-by: coleenp, dholmes
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
37161
e881f320966e 8150015: Integrate TraceTime with Unified Logging more seamlessly
rehn
parents: 35576
diff changeset
     2
 * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5353
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5353
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5353
diff changeset
    21
 * questions.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7389
diff changeset
    25
#include "precompiled.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7389
diff changeset
    26
#include "c1/c1_CFGPrinter.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7389
diff changeset
    27
#include "c1/c1_Compilation.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7389
diff changeset
    28
#include "c1/c1_IR.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7389
diff changeset
    29
#include "c1/c1_LIRAssembler.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7389
diff changeset
    30
#include "c1/c1_LinearScan.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7389
diff changeset
    31
#include "c1/c1_MacroAssembler.hpp"
29081
c61eb4914428 8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents: 26913
diff changeset
    32
#include "c1/c1_RangeCheckElimination.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7389
diff changeset
    33
#include "c1/c1_ValueMap.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7389
diff changeset
    34
#include "c1/c1_ValueStack.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 7389
diff changeset
    35
#include "code/debugInfoRec.hpp"
13964
01a2b863cc61 7177003: C1: LogCompilation support
vlivanov
parents: 13883
diff changeset
    36
#include "compiler/compileLog.hpp"
33451
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents: 33160
diff changeset
    37
#include "compiler/compilerDirectives.hpp"
29081
c61eb4914428 8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents: 26913
diff changeset
    38
#include "runtime/sharedRuntime.hpp"
37161
e881f320966e 8150015: Integrate TraceTime with Unified Logging more seamlessly
rehn
parents: 35576
diff changeset
    39
#include "runtime/timerTrace.hpp"
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
typedef enum {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
  _t_compile,
26913
9ad70cd32368 8058968: Compiler time traces should be improved
shade
parents: 24018
diff changeset
    43
    _t_setup,
9ad70cd32368 8058968: Compiler time traces should be improved
shade
parents: 24018
diff changeset
    44
    _t_buildIR,
9ad70cd32368 8058968: Compiler time traces should be improved
shade
parents: 24018
diff changeset
    45
      _t_hir_parse,
9ad70cd32368 8058968: Compiler time traces should be improved
shade
parents: 24018
diff changeset
    46
      _t_gvn,
9ad70cd32368 8058968: Compiler time traces should be improved
shade
parents: 24018
diff changeset
    47
      _t_optimize_blocks,
9ad70cd32368 8058968: Compiler time traces should be improved
shade
parents: 24018
diff changeset
    48
      _t_optimize_null_checks,
9ad70cd32368 8058968: Compiler time traces should be improved
shade
parents: 24018
diff changeset
    49
      _t_rangeCheckElimination,
9ad70cd32368 8058968: Compiler time traces should be improved
shade
parents: 24018
diff changeset
    50
    _t_emit_lir,
9ad70cd32368 8058968: Compiler time traces should be improved
shade
parents: 24018
diff changeset
    51
      _t_linearScan,
9ad70cd32368 8058968: Compiler time traces should be improved
shade
parents: 24018
diff changeset
    52
      _t_lirGeneration,
9ad70cd32368 8058968: Compiler time traces should be improved
shade
parents: 24018
diff changeset
    53
    _t_codeemit,
9ad70cd32368 8058968: Compiler time traces should be improved
shade
parents: 24018
diff changeset
    54
    _t_codeinstall,
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
  max_phase_timers
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
} TimerName;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
static const char * timer_name[] = {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
  "compile",
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
  "setup",
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
  "buildIR",
26913
9ad70cd32368 8058968: Compiler time traces should be improved
shade
parents: 24018
diff changeset
    62
  "parse_hir",
9ad70cd32368 8058968: Compiler time traces should be improved
shade
parents: 24018
diff changeset
    63
  "gvn",
16611
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 14628
diff changeset
    64
  "optimize_blocks",
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 14628
diff changeset
    65
  "optimize_null_checks",
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 14628
diff changeset
    66
  "rangeCheckElimination",
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
  "emit_lir",
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
  "linearScan",
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
  "lirGeneration",
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
  "codeemit",
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
  "codeinstall"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
static elapsedTimer timers[max_phase_timers];
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
static int totalInstructionNodes = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
class PhaseTraceTime: public TraceTime {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
 private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
  JavaThread* _thread;
13964
01a2b863cc61 7177003: C1: LogCompilation support
vlivanov
parents: 13883
diff changeset
    80
  CompileLog* _log;
19712
b0bdff06b6fb 8022456: LogCompilation tool does not work with C1 output again
vlivanov
parents: 16611
diff changeset
    81
  TimerName _timer;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
 public:
13964
01a2b863cc61 7177003: C1: LogCompilation support
vlivanov
parents: 13883
diff changeset
    84
  PhaseTraceTime(TimerName timer)
19712
b0bdff06b6fb 8022456: LogCompilation tool does not work with C1 output again
vlivanov
parents: 16611
diff changeset
    85
  : TraceTime("", &timers[timer], CITime || CITimeEach, Verbose),
b0bdff06b6fb 8022456: LogCompilation tool does not work with C1 output again
vlivanov
parents: 16611
diff changeset
    86
    _log(NULL), _timer(timer)
b0bdff06b6fb 8022456: LogCompilation tool does not work with C1 output again
vlivanov
parents: 16611
diff changeset
    87
  {
13964
01a2b863cc61 7177003: C1: LogCompilation support
vlivanov
parents: 13883
diff changeset
    88
    if (Compilation::current() != NULL) {
01a2b863cc61 7177003: C1: LogCompilation support
vlivanov
parents: 13883
diff changeset
    89
      _log = Compilation::current()->log();
01a2b863cc61 7177003: C1: LogCompilation support
vlivanov
parents: 13883
diff changeset
    90
    }
01a2b863cc61 7177003: C1: LogCompilation support
vlivanov
parents: 13883
diff changeset
    91
01a2b863cc61 7177003: C1: LogCompilation support
vlivanov
parents: 13883
diff changeset
    92
    if (_log != NULL) {
19712
b0bdff06b6fb 8022456: LogCompilation tool does not work with C1 output again
vlivanov
parents: 16611
diff changeset
    93
      _log->begin_head("phase name='%s'", timer_name[_timer]);
13964
01a2b863cc61 7177003: C1: LogCompilation support
vlivanov
parents: 13883
diff changeset
    94
      _log->stamp();
01a2b863cc61 7177003: C1: LogCompilation support
vlivanov
parents: 13883
diff changeset
    95
      _log->end_head();
01a2b863cc61 7177003: C1: LogCompilation support
vlivanov
parents: 13883
diff changeset
    96
    }
01a2b863cc61 7177003: C1: LogCompilation support
vlivanov
parents: 13883
diff changeset
    97
  }
01a2b863cc61 7177003: C1: LogCompilation support
vlivanov
parents: 13883
diff changeset
    98
01a2b863cc61 7177003: C1: LogCompilation support
vlivanov
parents: 13883
diff changeset
    99
  ~PhaseTraceTime() {
01a2b863cc61 7177003: C1: LogCompilation support
vlivanov
parents: 13883
diff changeset
   100
    if (_log != NULL)
19712
b0bdff06b6fb 8022456: LogCompilation tool does not work with C1 output again
vlivanov
parents: 16611
diff changeset
   101
      _log->done("phase name='%s'", timer_name[_timer]);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
// Implementation of Compilation
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
void Compilation::maybe_print_current_instruction() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
  if (_current_instruction != NULL && _last_instruction_printed != _current_instruction) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
    _last_instruction_printed = _current_instruction;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
    _current_instruction->print_line();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
#endif // PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
DebugInformationRecorder* Compilation::debug_info_recorder() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
  return _env->debug_info();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
Dependencies* Compilation::dependency_recorder() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
  return _env->dependencies();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
void Compilation::initialize() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
  // Use an oop recorder bound to the CI environment.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
  // (The default oop recorder is ignorant of the CI.)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
  OopRecorder* ooprec = new OopRecorder(_env->arena());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
  _env->set_oop_recorder(ooprec);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
  _env->set_debug_info(new DebugInformationRecorder(ooprec));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
  debug_info_recorder()->set_oopmaps(new OopMapSet());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
  _env->set_dependencies(new Dependencies(_env));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
void Compilation::build_hir() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
  CHECK_BAILOUT();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
  // setup ir
14628
74164bb6ec39 8003983: LogCompilation tool is broken since c1 support
neliasso
parents: 13974
diff changeset
   144
  CompileLog* log = this->log();
74164bb6ec39 8003983: LogCompilation tool is broken since c1 support
neliasso
parents: 13974
diff changeset
   145
  if (log != NULL) {
74164bb6ec39 8003983: LogCompilation tool is broken since c1 support
neliasso
parents: 13974
diff changeset
   146
    log->begin_head("parse method='%d' ",
74164bb6ec39 8003983: LogCompilation tool is broken since c1 support
neliasso
parents: 13974
diff changeset
   147
                    log->identify(_method));
74164bb6ec39 8003983: LogCompilation tool is broken since c1 support
neliasso
parents: 13974
diff changeset
   148
    log->stamp();
74164bb6ec39 8003983: LogCompilation tool is broken since c1 support
neliasso
parents: 13974
diff changeset
   149
    log->end_head();
74164bb6ec39 8003983: LogCompilation tool is broken since c1 support
neliasso
parents: 13974
diff changeset
   150
  }
26913
9ad70cd32368 8058968: Compiler time traces should be improved
shade
parents: 24018
diff changeset
   151
  {
9ad70cd32368 8058968: Compiler time traces should be improved
shade
parents: 24018
diff changeset
   152
    PhaseTraceTime timeit(_t_hir_parse);
9ad70cd32368 8058968: Compiler time traces should be improved
shade
parents: 24018
diff changeset
   153
    _hir = new IR(this, method(), osr_bci());
9ad70cd32368 8058968: Compiler time traces should be improved
shade
parents: 24018
diff changeset
   154
  }
14628
74164bb6ec39 8003983: LogCompilation tool is broken since c1 support
neliasso
parents: 13974
diff changeset
   155
  if (log)  log->done("parse");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
  if (!_hir->is_valid()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
    bailout("invalid parsing");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
    return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
  if (PrintCFGToFile) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
    CFGPrinter::print_cfg(_hir, "After Generation of HIR", true, false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
  if (PrintCFG || PrintCFG0) { tty->print_cr("CFG after parsing"); _hir->print(true); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
  if (PrintIR  || PrintIR0 ) { tty->print_cr("IR after parsing"); _hir->print(false); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
  _hir->verify();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
  if (UseC1Optimizations) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
    NEEDS_CLEANUP
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
    // optimization
16611
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 14628
diff changeset
   177
    PhaseTraceTime timeit(_t_optimize_blocks);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
16611
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 14628
diff changeset
   179
    _hir->optimize_blocks();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
  _hir->verify();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
  _hir->split_critical_edges();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
  if (PrintCFG || PrintCFG1) { tty->print_cr("CFG after optimizations"); _hir->print(true); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
  if (PrintIR  || PrintIR1 ) { tty->print_cr("IR after optimizations"); _hir->print(false); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
  _hir->verify();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
  // compute block ordering for code generation
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
  // the control flow must not be changed from here on
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
  _hir->compute_code();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
  if (UseGlobalValueNumbering) {
16611
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 14628
diff changeset
   198
    // No resource mark here! LoopInvariantCodeMotion can allocate ValueStack objects.
26913
9ad70cd32368 8058968: Compiler time traces should be improved
shade
parents: 24018
diff changeset
   199
    PhaseTraceTime timeit(_t_gvn);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
    int instructions = Instruction::number_of_instructions();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
    GlobalValueNumbering gvn(_hir);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
    assert(instructions == Instruction::number_of_instructions(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
           "shouldn't have created an instructions");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
16611
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 14628
diff changeset
   206
  _hir->verify();
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 14628
diff changeset
   207
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 14628
diff changeset
   208
#ifndef PRODUCT
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 14628
diff changeset
   209
  if (PrintCFGToFile) {
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 14628
diff changeset
   210
    CFGPrinter::print_cfg(_hir, "Before RangeCheckElimination", true, false);
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 14628
diff changeset
   211
  }
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 14628
diff changeset
   212
#endif
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 14628
diff changeset
   213
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 14628
diff changeset
   214
  if (RangeCheckElimination) {
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 14628
diff changeset
   215
    if (_hir->osr_entry() == NULL) {
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 14628
diff changeset
   216
      PhaseTraceTime timeit(_t_rangeCheckElimination);
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 14628
diff changeset
   217
      RangeCheckElimination::eliminate(_hir);
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 14628
diff changeset
   218
    }
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 14628
diff changeset
   219
  }
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 14628
diff changeset
   220
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 14628
diff changeset
   221
#ifndef PRODUCT
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 14628
diff changeset
   222
  if (PrintCFGToFile) {
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 14628
diff changeset
   223
    CFGPrinter::print_cfg(_hir, "After RangeCheckElimination", true, false);
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 14628
diff changeset
   224
  }
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 14628
diff changeset
   225
#endif
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 14628
diff changeset
   226
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 14628
diff changeset
   227
  if (UseC1Optimizations) {
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 14628
diff changeset
   228
    // loop invariant code motion reorders instructions and range
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 14628
diff changeset
   229
    // check elimination adds new instructions so do null check
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 14628
diff changeset
   230
    // elimination after.
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 14628
diff changeset
   231
    NEEDS_CLEANUP
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 14628
diff changeset
   232
    // optimization
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 14628
diff changeset
   233
    PhaseTraceTime timeit(_t_optimize_null_checks);
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 14628
diff changeset
   234
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 14628
diff changeset
   235
    _hir->eliminate_null_checks();
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 14628
diff changeset
   236
  }
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 14628
diff changeset
   237
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 14628
diff changeset
   238
  _hir->verify();
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 14628
diff changeset
   239
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
  // compute use counts after global value numbering
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
  _hir->compute_use_counts();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
  if (PrintCFG || PrintCFG2) { tty->print_cr("CFG before code generation"); _hir->code()->print(true); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
  if (PrintIR  || PrintIR2 ) { tty->print_cr("IR before code generation"); _hir->code()->print(false, true); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
  _hir->verify();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
void Compilation::emit_lir() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
  CHECK_BAILOUT();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
  LIRGenerator gen(this, method());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
  {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
    PhaseTraceTime timeit(_t_lirGeneration);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
    hir()->iterate_linear_scan_order(&gen);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
  CHECK_BAILOUT();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
  {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
    PhaseTraceTime timeit(_t_linearScan);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
    LinearScan* allocator = new LinearScan(hir(), &gen, frame_map());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
    set_allocator(allocator);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
    // Assign physical registers to LIR operands using a linear scan algorithm.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
    allocator->do_linear_scan();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
    CHECK_BAILOUT();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   271
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
    _max_spills = allocator->max_spills();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
  if (BailoutAfterLIR) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
    if (PrintLIR && !bailed_out()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
      print_LIR(hir()->code());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
    bailout("Bailing out because of -XX:+BailoutAfterLIR");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
void Compilation::emit_code_epilog(LIR_Assembler* assembler) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
  CHECK_BAILOUT();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
4752
67a506670cd0 6921352: JSR 292 needs its own deopt handler
twisti
parents: 4749
diff changeset
   287
  CodeOffsets* code_offsets = assembler->offsets();
67a506670cd0 6921352: JSR 292 needs its own deopt handler
twisti
parents: 4749
diff changeset
   288
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
  // generate code or slow cases
489c9b5090e2 Initial load
duke
parents:
diff changeset
   290
  assembler->emit_slow_case_stubs();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   291
  CHECK_BAILOUT();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   292
489c9b5090e2 Initial load
duke
parents:
diff changeset
   293
  // generate exception adapters
489c9b5090e2 Initial load
duke
parents:
diff changeset
   294
  assembler->emit_exception_entries(exception_info_list());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   295
  CHECK_BAILOUT();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   296
4752
67a506670cd0 6921352: JSR 292 needs its own deopt handler
twisti
parents: 4749
diff changeset
   297
  // Generate code for exception handler.
67a506670cd0 6921352: JSR 292 needs its own deopt handler
twisti
parents: 4749
diff changeset
   298
  code_offsets->set_value(CodeOffsets::Exceptions, assembler->emit_exception_handler());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   299
  CHECK_BAILOUT();
4752
67a506670cd0 6921352: JSR 292 needs its own deopt handler
twisti
parents: 4749
diff changeset
   300
67a506670cd0 6921352: JSR 292 needs its own deopt handler
twisti
parents: 4749
diff changeset
   301
  // Generate code for deopt handler.
67a506670cd0 6921352: JSR 292 needs its own deopt handler
twisti
parents: 4749
diff changeset
   302
  code_offsets->set_value(CodeOffsets::Deopt, assembler->emit_deopt_handler());
67a506670cd0 6921352: JSR 292 needs its own deopt handler
twisti
parents: 4749
diff changeset
   303
  CHECK_BAILOUT();
67a506670cd0 6921352: JSR 292 needs its own deopt handler
twisti
parents: 4749
diff changeset
   304
6186
7eef4cda471c 6975855: don't emit deopt MH handler in C1 if not required
twisti
parents: 5897
diff changeset
   305
  // Emit the MethodHandle deopt handler code (if required).
7eef4cda471c 6975855: don't emit deopt MH handler in C1 if not required
twisti
parents: 5897
diff changeset
   306
  if (has_method_handle_invokes()) {
7eef4cda471c 6975855: don't emit deopt MH handler in C1 if not required
twisti
parents: 5897
diff changeset
   307
    // We can use the same code as for the normal deopt handler, we
7eef4cda471c 6975855: don't emit deopt MH handler in C1 if not required
twisti
parents: 5897
diff changeset
   308
    // just need a different entry point address.
7eef4cda471c 6975855: don't emit deopt MH handler in C1 if not required
twisti
parents: 5897
diff changeset
   309
    code_offsets->set_value(CodeOffsets::DeoptMH, assembler->emit_deopt_handler());
7eef4cda471c 6975855: don't emit deopt MH handler in C1 if not required
twisti
parents: 5897
diff changeset
   310
    CHECK_BAILOUT();
7eef4cda471c 6975855: don't emit deopt MH handler in C1 if not required
twisti
parents: 5897
diff changeset
   311
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   312
5334
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 4752
diff changeset
   313
  // Emit the handler to remove the activation from the stack and
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 4752
diff changeset
   314
  // dispatch to the caller.
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 4752
diff changeset
   315
  offsets()->set_value(CodeOffsets::UnwindHandler, assembler->emit_unwind_handler());
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 4752
diff changeset
   316
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   317
  // done
489c9b5090e2 Initial load
duke
parents:
diff changeset
   318
  masm()->flush();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   319
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   320
489c9b5090e2 Initial load
duke
parents:
diff changeset
   321
7722
f0bd3dd3192f 7009268: guarantee(middle - slop > start) failed: need enough space to divide up
bobv
parents: 7432
diff changeset
   322
bool Compilation::setup_code_buffer(CodeBuffer* code, int call_stub_estimate) {
5707
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
   323
  // Preinitialize the consts section to some large size:
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
   324
  int locs_buffer_size = 20 * (relocInfo::length_limit + sizeof(relocInfo));
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
   325
  char* locs_buffer = NEW_RESOURCE_ARRAY(char, locs_buffer_size);
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
   326
  code->insts()->initialize_shared_locs((relocInfo*)locs_buffer,
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
   327
                                        locs_buffer_size / sizeof(relocInfo));
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
   328
  code->initialize_consts_size(Compilation::desired_max_constant_size());
5897
999579cc3f72 6962980: C1: stub area should take into account method handle deopt stub
iveresov
parents: 5707
diff changeset
   329
  // Call stubs + two deopt handlers (regular and MH) + exception handler
33160
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 29081
diff changeset
   330
  int call_stub_size = LIR_Assembler::call_stub_size;
c59f1676d27e 8136421: JEP 243: Java-Level JVM Compiler Interface
twisti
parents: 29081
diff changeset
   331
  int stub_size = (call_stub_estimate * call_stub_size) +
7722
f0bd3dd3192f 7009268: guarantee(middle - slop > start) failed: need enough space to divide up
bobv
parents: 7432
diff changeset
   332
                   LIR_Assembler::exception_handler_size +
f0bd3dd3192f 7009268: guarantee(middle - slop > start) failed: need enough space to divide up
bobv
parents: 7432
diff changeset
   333
                   (2 * LIR_Assembler::deopt_handler_size);
f0bd3dd3192f 7009268: guarantee(middle - slop > start) failed: need enough space to divide up
bobv
parents: 7432
diff changeset
   334
  if (stub_size >= code->insts_capacity()) return false;
f0bd3dd3192f 7009268: guarantee(middle - slop > start) failed: need enough space to divide up
bobv
parents: 7432
diff changeset
   335
  code->initialize_stubs_size(stub_size);
f0bd3dd3192f 7009268: guarantee(middle - slop > start) failed: need enough space to divide up
bobv
parents: 7432
diff changeset
   336
  return true;
5707
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
   337
}
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
   338
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
   339
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   340
int Compilation::emit_code_body() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   341
  // emit code
7722
f0bd3dd3192f 7009268: guarantee(middle - slop > start) failed: need enough space to divide up
bobv
parents: 7432
diff changeset
   342
  if (!setup_code_buffer(code(), allocator()->num_calls())) {
f0bd3dd3192f 7009268: guarantee(middle - slop > start) failed: need enough space to divide up
bobv
parents: 7432
diff changeset
   343
    BAILOUT_("size requested greater than avail code buffer size", 0);
f0bd3dd3192f 7009268: guarantee(middle - slop > start) failed: need enough space to divide up
bobv
parents: 7432
diff changeset
   344
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   345
  code()->initialize_oop_recorder(env()->oop_recorder());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   346
489c9b5090e2 Initial load
duke
parents:
diff changeset
   347
  _masm = new C1_MacroAssembler(code());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   348
  _masm->set_oop_recorder(env()->oop_recorder());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   349
489c9b5090e2 Initial load
duke
parents:
diff changeset
   350
  LIR_Assembler lir_asm(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   351
489c9b5090e2 Initial load
duke
parents:
diff changeset
   352
  lir_asm.emit_code(hir()->code());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   353
  CHECK_BAILOUT_(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   354
489c9b5090e2 Initial load
duke
parents:
diff changeset
   355
  emit_code_epilog(&lir_asm);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   356
  CHECK_BAILOUT_(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   357
489c9b5090e2 Initial load
duke
parents:
diff changeset
   358
  generate_exception_handler_table();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   359
489c9b5090e2 Initial load
duke
parents:
diff changeset
   360
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   361
  if (PrintExceptionHandlers && Verbose) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   362
    exception_handler_table()->print();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   363
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   364
#endif /* PRODUCT */
489c9b5090e2 Initial load
duke
parents:
diff changeset
   365
489c9b5090e2 Initial load
duke
parents:
diff changeset
   366
  return frame_map()->framesize();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   367
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   368
489c9b5090e2 Initial load
duke
parents:
diff changeset
   369
489c9b5090e2 Initial load
duke
parents:
diff changeset
   370
int Compilation::compile_java_method() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   371
  assert(!method()->is_native(), "should not reach here");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   372
489c9b5090e2 Initial load
duke
parents:
diff changeset
   373
  if (BailoutOnExceptionHandlers) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   374
    if (method()->has_exception_handlers()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   375
      bailout("linear scan can't handle exception handlers");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   376
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   377
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   378
489c9b5090e2 Initial load
duke
parents:
diff changeset
   379
  CHECK_BAILOUT_(no_frame_size);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   380
7432
f06f1253c317 7003554: (tiered) assert(is_null_object() || handle() != NULL) failed: cannot embed null pointer
iveresov
parents: 7397
diff changeset
   381
  if (is_profiling() && !method()->ensure_method_data()) {
f06f1253c317 7003554: (tiered) assert(is_null_object() || handle() != NULL) failed: cannot embed null pointer
iveresov
parents: 7397
diff changeset
   382
    BAILOUT_("mdo allocation failed", no_frame_size);
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6418
diff changeset
   383
  }
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6418
diff changeset
   384
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   385
  {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   386
    PhaseTraceTime timeit(_t_buildIR);
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6418
diff changeset
   387
    build_hir();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   388
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   389
  if (BailoutAfterHIR) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   390
    BAILOUT_("Bailing out because of -XX:+BailoutAfterHIR", no_frame_size);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   391
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   392
489c9b5090e2 Initial load
duke
parents:
diff changeset
   393
489c9b5090e2 Initial load
duke
parents:
diff changeset
   394
  {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   395
    PhaseTraceTime timeit(_t_emit_lir);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   396
489c9b5090e2 Initial load
duke
parents:
diff changeset
   397
    _frame_map = new FrameMap(method(), hir()->number_of_locks(), MAX2(4, hir()->max_stack()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   398
    emit_lir();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   399
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   400
  CHECK_BAILOUT_(no_frame_size);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   401
489c9b5090e2 Initial load
duke
parents:
diff changeset
   402
  {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   403
    PhaseTraceTime timeit(_t_codeemit);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   404
    return emit_code_body();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   405
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   406
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   407
489c9b5090e2 Initial load
duke
parents:
diff changeset
   408
void Compilation::install_code(int frame_size) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   409
  // frame_size is in 32-bit words so adjust it intptr_t words
489c9b5090e2 Initial load
duke
parents:
diff changeset
   410
  assert(frame_size == frame_map()->framesize(), "must match");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   411
  assert(in_bytes(frame_map()->framesize_in_bytes()) % sizeof(intptr_t) == 0, "must be at least pointer aligned");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   412
  _env->register_method(
489c9b5090e2 Initial load
duke
parents:
diff changeset
   413
    method(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   414
    osr_bci(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   415
    &_offsets,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   416
    in_bytes(_frame_map->sp_offset_for_orig_pc()),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   417
    code(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   418
    in_bytes(frame_map()->framesize_in_bytes()) / sizeof(intptr_t),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   419
    debug_info_recorder()->_oopmaps,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   420
    exception_handler_table(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   421
    implicit_exception_table(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   422
    compiler(),
13883
6979b9850feb 7196199: java/text/Bidi/Bug6665028.java failed: Bidi run count incorrect
kvn
parents: 13391
diff changeset
   423
    has_unsafe_access(),
35576
1f1cca67a48e 8147433: PrintNMethods no longer works with JVMCI
never
parents: 35071
diff changeset
   424
    SharedRuntime::is_wide_vector(max_vector_size())
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   425
  );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   426
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   427
489c9b5090e2 Initial load
duke
parents:
diff changeset
   428
489c9b5090e2 Initial load
duke
parents:
diff changeset
   429
void Compilation::compile_method() {
26913
9ad70cd32368 8058968: Compiler time traces should be improved
shade
parents: 24018
diff changeset
   430
  {
9ad70cd32368 8058968: Compiler time traces should be improved
shade
parents: 24018
diff changeset
   431
    PhaseTraceTime timeit(_t_setup);
9ad70cd32368 8058968: Compiler time traces should be improved
shade
parents: 24018
diff changeset
   432
9ad70cd32368 8058968: Compiler time traces should be improved
shade
parents: 24018
diff changeset
   433
    // setup compilation
9ad70cd32368 8058968: Compiler time traces should be improved
shade
parents: 24018
diff changeset
   434
    initialize();
9ad70cd32368 8058968: Compiler time traces should be improved
shade
parents: 24018
diff changeset
   435
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   436
489c9b5090e2 Initial load
duke
parents:
diff changeset
   437
  if (!method()->can_be_compiled()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   438
    // Prevent race condition 6328518.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   439
    // This can happen if the method is obsolete or breakpointed.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   440
    bailout("Bailing out because method is not compilable");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   441
    return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   442
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   443
2867
69187054225f 6788527: Server vm intermittently fails with assertion "live value must not be garbage" with fastdebug bits
kvn
parents: 1
diff changeset
   444
  if (_env->jvmti_can_hotswap_or_post_breakpoint()) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   445
    // We can assert evol_method because method->can_be_compiled is true.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   446
    dependency_recorder()->assert_evol_method(method());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   447
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   448
33451
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents: 33160
diff changeset
   449
  if (directive()->BreakAtCompileOption) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   450
    BREAKPOINT;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   451
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   452
489c9b5090e2 Initial load
duke
parents:
diff changeset
   453
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   454
  if (PrintCFGToFile) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   455
    CFGPrinter::print_compilation(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   456
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   457
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   458
489c9b5090e2 Initial load
duke
parents:
diff changeset
   459
  // compile method
489c9b5090e2 Initial load
duke
parents:
diff changeset
   460
  int frame_size = compile_java_method();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   461
489c9b5090e2 Initial load
duke
parents:
diff changeset
   462
  // bailout if method couldn't be compiled
489c9b5090e2 Initial load
duke
parents:
diff changeset
   463
  // Note: make sure we mark the method as not compilable!
489c9b5090e2 Initial load
duke
parents:
diff changeset
   464
  CHECK_BAILOUT();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   465
489c9b5090e2 Initial load
duke
parents:
diff changeset
   466
  if (InstallMethods) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   467
    // install code
489c9b5090e2 Initial load
duke
parents:
diff changeset
   468
    PhaseTraceTime timeit(_t_codeinstall);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   469
    install_code(frame_size);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   470
  }
13964
01a2b863cc61 7177003: C1: LogCompilation support
vlivanov
parents: 13883
diff changeset
   471
01a2b863cc61 7177003: C1: LogCompilation support
vlivanov
parents: 13883
diff changeset
   472
  if (log() != NULL) // Print code cache state into compiler log
01a2b863cc61 7177003: C1: LogCompilation support
vlivanov
parents: 13883
diff changeset
   473
    log()->code_cache_state();
01a2b863cc61 7177003: C1: LogCompilation support
vlivanov
parents: 13883
diff changeset
   474
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   475
  totalInstructionNodes += Instruction::number_of_instructions();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   476
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   477
489c9b5090e2 Initial load
duke
parents:
diff changeset
   478
489c9b5090e2 Initial load
duke
parents:
diff changeset
   479
void Compilation::generate_exception_handler_table() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   480
  // Generate an ExceptionHandlerTable from the exception handler
489c9b5090e2 Initial load
duke
parents:
diff changeset
   481
  // information accumulated during the compilation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   482
  ExceptionInfoList* info_list = exception_info_list();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   483
489c9b5090e2 Initial load
duke
parents:
diff changeset
   484
  if (info_list->length() == 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   485
    return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   486
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   487
489c9b5090e2 Initial load
duke
parents:
diff changeset
   488
  // allocate some arrays for use by the collection code.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   489
  const int num_handlers = 5;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   490
  GrowableArray<intptr_t>* bcis = new GrowableArray<intptr_t>(num_handlers);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   491
  GrowableArray<intptr_t>* scope_depths = new GrowableArray<intptr_t>(num_handlers);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   492
  GrowableArray<intptr_t>* pcos = new GrowableArray<intptr_t>(num_handlers);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   493
489c9b5090e2 Initial load
duke
parents:
diff changeset
   494
  for (int i = 0; i < info_list->length(); i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   495
    ExceptionInfo* info = info_list->at(i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   496
    XHandlers* handlers = info->exception_handlers();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   497
489c9b5090e2 Initial load
duke
parents:
diff changeset
   498
    // empty the arrays
489c9b5090e2 Initial load
duke
parents:
diff changeset
   499
    bcis->trunc_to(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   500
    scope_depths->trunc_to(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   501
    pcos->trunc_to(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   502
489c9b5090e2 Initial load
duke
parents:
diff changeset
   503
    for (int i = 0; i < handlers->length(); i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   504
      XHandler* handler = handlers->handler_at(i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   505
      assert(handler->entry_pco() != -1, "must have been generated");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   506
489c9b5090e2 Initial load
duke
parents:
diff changeset
   507
      int e = bcis->find(handler->handler_bci());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   508
      if (e >= 0 && scope_depths->at(e) == handler->scope_count()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   509
        // two different handlers are declared to dispatch to the same
489c9b5090e2 Initial load
duke
parents:
diff changeset
   510
        // catch bci.  During parsing we created edges for each
489c9b5090e2 Initial load
duke
parents:
diff changeset
   511
        // handler but we really only need one.  The exception handler
489c9b5090e2 Initial load
duke
parents:
diff changeset
   512
        // table will also get unhappy if we try to declare both since
489c9b5090e2 Initial load
duke
parents:
diff changeset
   513
        // it's nonsensical.  Just skip this handler.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   514
        continue;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   515
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   516
489c9b5090e2 Initial load
duke
parents:
diff changeset
   517
      bcis->append(handler->handler_bci());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   518
      if (handler->handler_bci() == -1) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   519
        // insert a wildcard handler at scope depth 0 so that the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   520
        // exception lookup logic with find it.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   521
        scope_depths->append(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   522
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   523
        scope_depths->append(handler->scope_count());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   524
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   525
      pcos->append(handler->entry_pco());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   526
489c9b5090e2 Initial load
duke
parents:
diff changeset
   527
      // stop processing once we hit a catch any
489c9b5090e2 Initial load
duke
parents:
diff changeset
   528
      if (handler->is_catch_all()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   529
        assert(i == handlers->length() - 1, "catch all must be last handler");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   530
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   531
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   532
    exception_handler_table()->add_subtable(info->pco(), bcis, scope_depths, pcos);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   533
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   534
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   535
489c9b5090e2 Initial load
duke
parents:
diff changeset
   536
5707
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
   537
Compilation::Compilation(AbstractCompiler* compiler, ciEnv* env, ciMethod* method,
33451
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents: 33160
diff changeset
   538
                         int osr_bci, BufferBlob* buffer_blob, DirectiveSet* directive)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   539
: _compiler(compiler)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   540
, _env(env)
33451
0712796e4039 8137167: JEP165: Compiler Control: Implementation task
neliasso
parents: 33160
diff changeset
   541
, _directive(directive)
13964
01a2b863cc61 7177003: C1: LogCompilation support
vlivanov
parents: 13883
diff changeset
   542
, _log(env->log())
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   543
, _method(method)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   544
, _osr_bci(osr_bci)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   545
, _hir(NULL)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   546
, _max_spills(-1)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   547
, _frame_map(NULL)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   548
, _masm(NULL)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   549
, _has_exception_handlers(false)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   550
, _has_fpu_code(true)   // pessimistic assumption
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6418
diff changeset
   551
, _would_profile(false)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   552
, _has_unsafe_access(false)
6186
7eef4cda471c 6975855: don't emit deopt MH handler in C1 if not required
twisti
parents: 5897
diff changeset
   553
, _has_method_handle_invokes(false)
35071
a0910b1d3e0d 8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents: 33451
diff changeset
   554
, _has_reserved_stack_access(method->has_reserved_stack_access())
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   555
, _bailout_msg(NULL)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   556
, _exception_info_list(NULL)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   557
, _allocator(NULL)
5707
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
   558
, _next_id(0)
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
   559
, _next_block_id(0)
6418
6671edbd230e 6978355: renaming for 6961697
twisti
parents: 6186
diff changeset
   560
, _code(buffer_blob)
16611
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 14628
diff changeset
   561
, _has_access_indexed(false)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   562
, _current_instruction(NULL)
24018
77b156916bab 8032410: compiler/uncommontrap/TestStackBangRbp.java times out on Solaris-Sparc V9
roland
parents: 22234
diff changeset
   563
, _interpreter_frame_size(0)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   564
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   565
, _last_instruction_printed(NULL)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   566
#endif // PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   567
{
489c9b5090e2 Initial load
duke
parents:
diff changeset
   568
  PhaseTraceTime timeit(_t_compile);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   569
  _arena = Thread::current()->resource_area();
5707
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
   570
  _env->set_compiler_data(this);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   571
  _exception_info_list = new ExceptionInfoList();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   572
  _implicit_exception_table.set_size(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   573
  compile_method();
7389
93110864f81e 7000349: Tiered reacts incorrectly to C1 compilation failures
iveresov
parents: 6453
diff changeset
   574
  if (bailed_out()) {
93110864f81e 7000349: Tiered reacts incorrectly to C1 compilation failures
iveresov
parents: 6453
diff changeset
   575
    _env->record_method_not_compilable(bailout_msg(), !TieredCompilation);
93110864f81e 7000349: Tiered reacts incorrectly to C1 compilation failures
iveresov
parents: 6453
diff changeset
   576
    if (is_profiling()) {
93110864f81e 7000349: Tiered reacts incorrectly to C1 compilation failures
iveresov
parents: 6453
diff changeset
   577
      // Compilation failed, create MDO, which would signal the interpreter
93110864f81e 7000349: Tiered reacts incorrectly to C1 compilation failures
iveresov
parents: 6453
diff changeset
   578
      // to start profiling on its own.
7432
f06f1253c317 7003554: (tiered) assert(is_null_object() || handle() != NULL) failed: cannot embed null pointer
iveresov
parents: 7397
diff changeset
   579
      _method->ensure_method_data();
7389
93110864f81e 7000349: Tiered reacts incorrectly to C1 compilation failures
iveresov
parents: 6453
diff changeset
   580
    }
8322
8f11ba61239f 7017434: Tiered needs to support reprofiling
iveresov
parents: 7722
diff changeset
   581
  } else if (is_profiling()) {
7432
f06f1253c317 7003554: (tiered) assert(is_null_object() || handle() != NULL) failed: cannot embed null pointer
iveresov
parents: 7397
diff changeset
   582
    ciMethodData *md = method->method_data_or_null();
8322
8f11ba61239f 7017434: Tiered needs to support reprofiling
iveresov
parents: 7722
diff changeset
   583
    if (md != NULL) {
8f11ba61239f 7017434: Tiered needs to support reprofiling
iveresov
parents: 7722
diff changeset
   584
      md->set_would_profile(_would_profile);
8f11ba61239f 7017434: Tiered needs to support reprofiling
iveresov
parents: 7722
diff changeset
   585
    }
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6418
diff changeset
   586
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   587
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   588
489c9b5090e2 Initial load
duke
parents:
diff changeset
   589
Compilation::~Compilation() {
5707
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5547
diff changeset
   590
  _env->set_compiler_data(NULL);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   591
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   592
489c9b5090e2 Initial load
duke
parents:
diff changeset
   593
void Compilation::add_exception_handlers_for_pco(int pco, XHandlers* exception_handlers) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   594
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   595
  if (PrintExceptionHandlers && Verbose) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   596
    tty->print_cr("  added exception scope for pco %d", pco);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   597
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   598
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   599
  // Note: we do not have program counters for these exception handlers yet
489c9b5090e2 Initial load
duke
parents:
diff changeset
   600
  exception_info_list()->push(new ExceptionInfo(pco, exception_handlers));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   601
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   602
489c9b5090e2 Initial load
duke
parents:
diff changeset
   603
489c9b5090e2 Initial load
duke
parents:
diff changeset
   604
void Compilation::notice_inlined_method(ciMethod* method) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   605
  _env->notice_inlined_method(method);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   606
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   607
489c9b5090e2 Initial load
duke
parents:
diff changeset
   608
489c9b5090e2 Initial load
duke
parents:
diff changeset
   609
void Compilation::bailout(const char* msg) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   610
  assert(msg != NULL, "bailout message must exist");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   611
  if (!bailed_out()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   612
    // keep first bailout message
13391
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 10508
diff changeset
   613
    if (PrintCompilation || PrintBailouts) tty->print_cr("compilation bailout: %s", msg);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   614
    _bailout_msg = msg;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   615
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   616
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   617
20702
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 19712
diff changeset
   618
ciKlass* Compilation::cha_exact_type(ciType* type) {
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 19712
diff changeset
   619
  if (type != NULL && type->is_loaded() && type->is_instance_klass()) {
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 19712
diff changeset
   620
    ciInstanceKlass* ik = type->as_instance_klass();
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 19712
diff changeset
   621
    assert(ik->exact_klass() == NULL, "no cha for final klass");
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 19712
diff changeset
   622
    if (DeoptC1 && UseCHA && !(ik->has_subklass() || ik->is_interface())) {
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 19712
diff changeset
   623
      dependency_recorder()->assert_leaf_type(ik);
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 19712
diff changeset
   624
      return ik;
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 19712
diff changeset
   625
    }
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 19712
diff changeset
   626
  }
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 19712
diff changeset
   627
  return NULL;
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 19712
diff changeset
   628
}
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   629
489c9b5090e2 Initial load
duke
parents:
diff changeset
   630
void Compilation::print_timers() {
26913
9ad70cd32368 8058968: Compiler time traces should be improved
shade
parents: 24018
diff changeset
   631
  tty->print_cr("    C1 Compile Time:      %7.3f s",      timers[_t_compile].seconds());
9ad70cd32368 8058968: Compiler time traces should be improved
shade
parents: 24018
diff changeset
   632
  tty->print_cr("       Setup time:          %7.3f s",    timers[_t_setup].seconds());
9ad70cd32368 8058968: Compiler time traces should be improved
shade
parents: 24018
diff changeset
   633
9ad70cd32368 8058968: Compiler time traces should be improved
shade
parents: 24018
diff changeset
   634
  {
9ad70cd32368 8058968: Compiler time traces should be improved
shade
parents: 24018
diff changeset
   635
    tty->print_cr("       Build HIR:           %7.3f s",    timers[_t_buildIR].seconds());
9ad70cd32368 8058968: Compiler time traces should be improved
shade
parents: 24018
diff changeset
   636
    tty->print_cr("         Parse:               %7.3f s", timers[_t_hir_parse].seconds());
9ad70cd32368 8058968: Compiler time traces should be improved
shade
parents: 24018
diff changeset
   637
    tty->print_cr("         Optimize blocks:     %7.3f s", timers[_t_optimize_blocks].seconds());
9ad70cd32368 8058968: Compiler time traces should be improved
shade
parents: 24018
diff changeset
   638
    tty->print_cr("         GVN:                 %7.3f s", timers[_t_gvn].seconds());
9ad70cd32368 8058968: Compiler time traces should be improved
shade
parents: 24018
diff changeset
   639
    tty->print_cr("         Null checks elim:    %7.3f s", timers[_t_optimize_null_checks].seconds());
9ad70cd32368 8058968: Compiler time traces should be improved
shade
parents: 24018
diff changeset
   640
    tty->print_cr("         Range checks elim:   %7.3f s", timers[_t_rangeCheckElimination].seconds());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   641
26913
9ad70cd32368 8058968: Compiler time traces should be improved
shade
parents: 24018
diff changeset
   642
    double other = timers[_t_buildIR].seconds() -
9ad70cd32368 8058968: Compiler time traces should be improved
shade
parents: 24018
diff changeset
   643
      (timers[_t_hir_parse].seconds() +
9ad70cd32368 8058968: Compiler time traces should be improved
shade
parents: 24018
diff changeset
   644
       timers[_t_optimize_blocks].seconds() +
9ad70cd32368 8058968: Compiler time traces should be improved
shade
parents: 24018
diff changeset
   645
       timers[_t_gvn].seconds() +
9ad70cd32368 8058968: Compiler time traces should be improved
shade
parents: 24018
diff changeset
   646
       timers[_t_optimize_null_checks].seconds() +
9ad70cd32368 8058968: Compiler time traces should be improved
shade
parents: 24018
diff changeset
   647
       timers[_t_rangeCheckElimination].seconds());
9ad70cd32368 8058968: Compiler time traces should be improved
shade
parents: 24018
diff changeset
   648
    if (other > 0) {
9ad70cd32368 8058968: Compiler time traces should be improved
shade
parents: 24018
diff changeset
   649
      tty->print_cr("         Other:               %7.3f s", other);
9ad70cd32368 8058968: Compiler time traces should be improved
shade
parents: 24018
diff changeset
   650
    }
9ad70cd32368 8058968: Compiler time traces should be improved
shade
parents: 24018
diff changeset
   651
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   652
26913
9ad70cd32368 8058968: Compiler time traces should be improved
shade
parents: 24018
diff changeset
   653
  {
9ad70cd32368 8058968: Compiler time traces should be improved
shade
parents: 24018
diff changeset
   654
    tty->print_cr("       Emit LIR:            %7.3f s",    timers[_t_emit_lir].seconds());
9ad70cd32368 8058968: Compiler time traces should be improved
shade
parents: 24018
diff changeset
   655
    tty->print_cr("         LIR Gen:             %7.3f s",   timers[_t_lirGeneration].seconds());
9ad70cd32368 8058968: Compiler time traces should be improved
shade
parents: 24018
diff changeset
   656
    tty->print_cr("         Linear Scan:         %7.3f s",   timers[_t_linearScan].seconds());
9ad70cd32368 8058968: Compiler time traces should be improved
shade
parents: 24018
diff changeset
   657
    NOT_PRODUCT(LinearScan::print_timers(timers[_t_linearScan].seconds()));
9ad70cd32368 8058968: Compiler time traces should be improved
shade
parents: 24018
diff changeset
   658
9ad70cd32368 8058968: Compiler time traces should be improved
shade
parents: 24018
diff changeset
   659
    double other = timers[_t_emit_lir].seconds() -
9ad70cd32368 8058968: Compiler time traces should be improved
shade
parents: 24018
diff changeset
   660
      (timers[_t_lirGeneration].seconds() +
9ad70cd32368 8058968: Compiler time traces should be improved
shade
parents: 24018
diff changeset
   661
       timers[_t_linearScan].seconds());
9ad70cd32368 8058968: Compiler time traces should be improved
shade
parents: 24018
diff changeset
   662
    if (other > 0) {
9ad70cd32368 8058968: Compiler time traces should be improved
shade
parents: 24018
diff changeset
   663
      tty->print_cr("         Other:               %7.3f s", other);
9ad70cd32368 8058968: Compiler time traces should be improved
shade
parents: 24018
diff changeset
   664
    }
9ad70cd32368 8058968: Compiler time traces should be improved
shade
parents: 24018
diff changeset
   665
  }
9ad70cd32368 8058968: Compiler time traces should be improved
shade
parents: 24018
diff changeset
   666
9ad70cd32368 8058968: Compiler time traces should be improved
shade
parents: 24018
diff changeset
   667
  tty->print_cr("       Code Emission:       %7.3f s",    timers[_t_codeemit].seconds());
9ad70cd32368 8058968: Compiler time traces should be improved
shade
parents: 24018
diff changeset
   668
  tty->print_cr("       Code Installation:   %7.3f s",    timers[_t_codeinstall].seconds());
9ad70cd32368 8058968: Compiler time traces should be improved
shade
parents: 24018
diff changeset
   669
9ad70cd32368 8058968: Compiler time traces should be improved
shade
parents: 24018
diff changeset
   670
  double other = timers[_t_compile].seconds() -
9ad70cd32368 8058968: Compiler time traces should be improved
shade
parents: 24018
diff changeset
   671
      (timers[_t_setup].seconds() +
9ad70cd32368 8058968: Compiler time traces should be improved
shade
parents: 24018
diff changeset
   672
       timers[_t_buildIR].seconds() +
9ad70cd32368 8058968: Compiler time traces should be improved
shade
parents: 24018
diff changeset
   673
       timers[_t_emit_lir].seconds() +
9ad70cd32368 8058968: Compiler time traces should be improved
shade
parents: 24018
diff changeset
   674
       timers[_t_codeemit].seconds() +
9ad70cd32368 8058968: Compiler time traces should be improved
shade
parents: 24018
diff changeset
   675
       timers[_t_codeinstall].seconds());
9ad70cd32368 8058968: Compiler time traces should be improved
shade
parents: 24018
diff changeset
   676
  if (other > 0) {
9ad70cd32368 8058968: Compiler time traces should be improved
shade
parents: 24018
diff changeset
   677
    tty->print_cr("       Other:               %7.3f s", other);
9ad70cd32368 8058968: Compiler time traces should be improved
shade
parents: 24018
diff changeset
   678
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   679
489c9b5090e2 Initial load
duke
parents:
diff changeset
   680
  NOT_PRODUCT(LinearScan::print_statistics());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   681
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   682
489c9b5090e2 Initial load
duke
parents:
diff changeset
   683
489c9b5090e2 Initial load
duke
parents:
diff changeset
   684
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   685
void Compilation::compile_only_this_method() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   686
  ResourceMark rm;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   687
  fileStream stream(fopen("c1_compile_only", "wt"));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   688
  stream.print_cr("# c1 compile only directives");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   689
  compile_only_this_scope(&stream, hir()->top_scope());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   690
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   691
489c9b5090e2 Initial load
duke
parents:
diff changeset
   692
489c9b5090e2 Initial load
duke
parents:
diff changeset
   693
void Compilation::compile_only_this_scope(outputStream* st, IRScope* scope) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   694
  st->print("CompileOnly=");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   695
  scope->method()->holder()->name()->print_symbol_on(st);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   696
  st->print(".");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   697
  scope->method()->name()->print_symbol_on(st);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   698
  st->cr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   699
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   700
489c9b5090e2 Initial load
duke
parents:
diff changeset
   701
489c9b5090e2 Initial load
duke
parents:
diff changeset
   702
void Compilation::exclude_this_method() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   703
  fileStream stream(fopen(".hotspot_compiler", "at"));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   704
  stream.print("exclude ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   705
  method()->holder()->name()->print_symbol_on(&stream);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   706
  stream.print(" ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   707
  method()->name()->print_symbol_on(&stream);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   708
  stream.cr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   709
  stream.cr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   710
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   711
#endif