annotate src/share/vm/c1/c1_Compilation.hpp @ 1397:b4776199210f

6943485: JVMTI always on capabilities change code generation too much Reviewed-by: twisti, dcubed
author never
date Mon, 26 Apr 2010 23:59:45 -0700
parents a61af66fc99e
children c18cbe5936b8
rev   line source
duke@0 1 /*
never@1397 2 * Copyright 1999-2010 Sun Microsystems, Inc. All Rights Reserved.
duke@0 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@0 4 *
duke@0 5 * This code is free software; you can redistribute it and/or modify it
duke@0 6 * under the terms of the GNU General Public License version 2 only, as
duke@0 7 * published by the Free Software Foundation.
duke@0 8 *
duke@0 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@0 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@0 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@0 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@0 13 * accompanied this code).
duke@0 14 *
duke@0 15 * You should have received a copy of the GNU General Public License version
duke@0 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@0 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@0 18 *
duke@0 19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
duke@0 20 * CA 95054 USA or visit www.sun.com if you need additional information or
duke@0 21 * have any questions.
duke@0 22 *
duke@0 23 */
duke@0 24
duke@0 25 class BlockBegin;
duke@0 26 class CompilationResourceObj;
duke@0 27 class XHandlers;
duke@0 28 class ExceptionInfo;
duke@0 29 class DebugInformationRecorder;
duke@0 30 class FrameMap;
duke@0 31 class IR;
duke@0 32 class IRScope;
duke@0 33 class Instruction;
duke@0 34 class LinearScan;
duke@0 35 class OopMap;
duke@0 36 class LIR_Emitter;
duke@0 37 class LIR_Assembler;
duke@0 38 class CodeEmitInfo;
duke@0 39 class ciEnv;
duke@0 40 class ciMethod;
duke@0 41 class ValueStack;
duke@0 42 class LIR_OprDesc;
duke@0 43 class C1_MacroAssembler;
duke@0 44 class CFGPrinter;
duke@0 45 typedef LIR_OprDesc* LIR_Opr;
duke@0 46
duke@0 47
duke@0 48 define_array(BasicTypeArray, BasicType)
duke@0 49 define_stack(BasicTypeList, BasicTypeArray)
duke@0 50
duke@0 51 define_array(ExceptionInfoArray, ExceptionInfo*)
duke@0 52 define_stack(ExceptionInfoList, ExceptionInfoArray)
duke@0 53
duke@0 54 class Compilation: public StackObj {
duke@0 55 friend class CompilationResourceObj;
duke@0 56 private:
duke@0 57
duke@0 58 static Arena* _arena;
duke@0 59 static Arena* arena() { return _arena; }
duke@0 60
duke@0 61 static Compilation* _compilation;
duke@0 62
duke@0 63 private:
duke@0 64 // compilation specifics
duke@0 65 AbstractCompiler* _compiler;
duke@0 66 ciEnv* _env;
duke@0 67 ciMethod* _method;
duke@0 68 int _osr_bci;
duke@0 69 IR* _hir;
duke@0 70 int _max_spills;
duke@0 71 FrameMap* _frame_map;
duke@0 72 C1_MacroAssembler* _masm;
duke@0 73 bool _has_exception_handlers;
duke@0 74 bool _has_fpu_code;
duke@0 75 bool _has_unsafe_access;
duke@0 76 const char* _bailout_msg;
duke@0 77 ExceptionInfoList* _exception_info_list;
duke@0 78 ExceptionHandlerTable _exception_handler_table;
duke@0 79 ImplicitExceptionTable _implicit_exception_table;
duke@0 80 LinearScan* _allocator;
duke@0 81 CodeOffsets _offsets;
duke@0 82 CodeBuffer _code;
duke@0 83
duke@0 84 // compilation helpers
duke@0 85 void initialize();
duke@0 86 void build_hir();
duke@0 87 void emit_lir();
duke@0 88
duke@0 89 void emit_code_epilog(LIR_Assembler* assembler);
duke@0 90 int emit_code_body();
duke@0 91
duke@0 92 int compile_java_method();
duke@0 93 void install_code(int frame_size);
duke@0 94 void compile_method();
duke@0 95
duke@0 96 void generate_exception_handler_table();
duke@0 97
duke@0 98 ExceptionInfoList* exception_info_list() const { return _exception_info_list; }
duke@0 99 ExceptionHandlerTable* exception_handler_table() { return &_exception_handler_table; }
duke@0 100
duke@0 101 LinearScan* allocator() { return _allocator; }
duke@0 102 void set_allocator(LinearScan* allocator) { _allocator = allocator; }
duke@0 103
duke@0 104 Instruction* _current_instruction; // the instruction currently being processed
duke@0 105 #ifndef PRODUCT
duke@0 106 Instruction* _last_instruction_printed; // the last instruction printed during traversal
duke@0 107 #endif // PRODUCT
duke@0 108
duke@0 109 public:
duke@0 110 // creation
duke@0 111 Compilation(AbstractCompiler* compiler, ciEnv* env, ciMethod* method, int osr_bci);
duke@0 112 ~Compilation();
duke@0 113
duke@0 114 static Compilation* current_compilation() { return _compilation; }
duke@0 115
duke@0 116 // accessors
duke@0 117 ciEnv* env() const { return _env; }
duke@0 118 AbstractCompiler* compiler() const { return _compiler; }
duke@0 119 bool has_exception_handlers() const { return _has_exception_handlers; }
duke@0 120 bool has_fpu_code() const { return _has_fpu_code; }
duke@0 121 bool has_unsafe_access() const { return _has_unsafe_access; }
duke@0 122 ciMethod* method() const { return _method; }
duke@0 123 int osr_bci() const { return _osr_bci; }
duke@0 124 bool is_osr_compile() const { return osr_bci() >= 0; }
duke@0 125 IR* hir() const { return _hir; }
duke@0 126 int max_spills() const { return _max_spills; }
duke@0 127 FrameMap* frame_map() const { return _frame_map; }
duke@0 128 CodeBuffer* code() { return &_code; }
duke@0 129 C1_MacroAssembler* masm() const { return _masm; }
duke@0 130 CodeOffsets* offsets() { return &_offsets; }
duke@0 131
duke@0 132 // setters
duke@0 133 void set_has_exception_handlers(bool f) { _has_exception_handlers = f; }
duke@0 134 void set_has_fpu_code(bool f) { _has_fpu_code = f; }
duke@0 135 void set_has_unsafe_access(bool f) { _has_unsafe_access = f; }
duke@0 136 // Add a set of exception handlers covering the given PC offset
duke@0 137 void add_exception_handlers_for_pco(int pco, XHandlers* exception_handlers);
duke@0 138 // Statistics gathering
duke@0 139 void notice_inlined_method(ciMethod* method);
duke@0 140
duke@0 141 DebugInformationRecorder* debug_info_recorder() const; // = _env->debug_info();
duke@0 142 Dependencies* dependency_recorder() const; // = _env->dependencies()
duke@0 143 ImplicitExceptionTable* implicit_exception_table() { return &_implicit_exception_table; }
duke@0 144
duke@0 145 Instruction* current_instruction() const { return _current_instruction; }
duke@0 146 Instruction* set_current_instruction(Instruction* instr) {
duke@0 147 Instruction* previous = _current_instruction;
duke@0 148 _current_instruction = instr;
duke@0 149 return previous;
duke@0 150 }
duke@0 151
duke@0 152 #ifndef PRODUCT
duke@0 153 void maybe_print_current_instruction();
duke@0 154 #endif // PRODUCT
duke@0 155
duke@0 156 // error handling
duke@0 157 void bailout(const char* msg);
duke@0 158 bool bailed_out() const { return _bailout_msg != NULL; }
duke@0 159 const char* bailout_msg() const { return _bailout_msg; }
duke@0 160
duke@0 161 // timers
duke@0 162 static void print_timers();
duke@0 163
duke@0 164 #ifndef PRODUCT
duke@0 165 // debugging support.
duke@0 166 // produces a file named c1compileonly in the current directory with
duke@0 167 // directives to compile only the current method and it's inlines.
duke@0 168 // The file can be passed to the command line option -XX:Flags=<filename>
duke@0 169 void compile_only_this_method();
duke@0 170 void compile_only_this_scope(outputStream* st, IRScope* scope);
duke@0 171 void exclude_this_method();
duke@0 172 #endif // PRODUCT
duke@0 173 };
duke@0 174
duke@0 175
duke@0 176 // Macro definitions for unified bailout-support
duke@0 177 // The methods bailout() and bailed_out() are present in all classes
duke@0 178 // that might bailout, but forward all calls to Compilation
duke@0 179 #define BAILOUT(msg) { bailout(msg); return; }
duke@0 180 #define BAILOUT_(msg, res) { bailout(msg); return res; }
duke@0 181
duke@0 182 #define CHECK_BAILOUT() { if (bailed_out()) return; }
duke@0 183 #define CHECK_BAILOUT_(res) { if (bailed_out()) return res; }
duke@0 184
duke@0 185
duke@0 186 class InstructionMark: public StackObj {
duke@0 187 private:
duke@0 188 Compilation* _compilation;
duke@0 189 Instruction* _previous;
duke@0 190
duke@0 191 public:
duke@0 192 InstructionMark(Compilation* compilation, Instruction* instr) {
duke@0 193 _compilation = compilation;
duke@0 194 _previous = _compilation->set_current_instruction(instr);
duke@0 195 }
duke@0 196 ~InstructionMark() {
duke@0 197 _compilation->set_current_instruction(_previous);
duke@0 198 }
duke@0 199 };
duke@0 200
duke@0 201
duke@0 202 //----------------------------------------------------------------------
duke@0 203 // Base class for objects allocated by the compiler in the compilation arena
duke@0 204 class CompilationResourceObj ALLOCATION_SUPER_CLASS_SPEC {
duke@0 205 public:
duke@0 206 void* operator new(size_t size) { return Compilation::arena()->Amalloc(size); }
duke@0 207 void operator delete(void* p) {} // nothing to do
duke@0 208 };
duke@0 209
duke@0 210
duke@0 211 //----------------------------------------------------------------------
duke@0 212 // Class for aggregating exception handler information.
duke@0 213
duke@0 214 // Effectively extends XHandlers class with PC offset of
duke@0 215 // potentially exception-throwing instruction.
duke@0 216 // This class is used at the end of the compilation to build the
duke@0 217 // ExceptionHandlerTable.
duke@0 218 class ExceptionInfo: public CompilationResourceObj {
duke@0 219 private:
duke@0 220 int _pco; // PC of potentially exception-throwing instruction
duke@0 221 XHandlers* _exception_handlers; // flat list of exception handlers covering this PC
duke@0 222
duke@0 223 public:
duke@0 224 ExceptionInfo(int pco, XHandlers* exception_handlers)
duke@0 225 : _pco(pco)
duke@0 226 , _exception_handlers(exception_handlers)
duke@0 227 { }
duke@0 228
duke@0 229 int pco() { return _pco; }
duke@0 230 XHandlers* exception_handlers() { return _exception_handlers; }
duke@0 231 };