CACAO
DisassemblerPass.cpp
Go to the documentation of this file.
1 /* src/vm/jit/compiler2/DisassemblerPass.cpp - DisassemblerPass
2 
3  Copyright (C) 2013
4  CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
5 
6  This file is part of CACAO.
7 
8  This program is free software; you can redistribute it and/or
9  modify it under the terms of the GNU General Public License as
10  published by the Free Software Foundation; either version 2, or (at
11  your option) any later version.
12 
13  This program is distributed in the hope that it will be useful, but
14  WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with this program; if not, write to the Free Software
20  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21  02110-1301, USA.
22 
23 */
24 
30 
31 #include "vm/jit/jit.hpp"
32 #include "vm/jit/disass.hpp"
33 #include "vm/jit/code.hpp"
34 
35 
36 #include "toolbox/logging.hpp"
37 
38 #define DEBUG_NAME "compiler2/DisassemblerPass"
39 
40 namespace cacao {
41 namespace jit {
42 namespace compiler2 {
43 
44 Option<bool> DisassemblerPass::enabled("DisassemblerPass","compiler2: enable DisassemblerPass",false,::cacao::option::xx_root());
45 
47 #if defined(ENABLE_DISASSEMBLER)
48  codeinfo *cd = JD.get_jitdata()->code;
49  u1 *start = cd->entrypoint;
50 #if 0
51  u1 *end = cd->mcode + cd->mcodelength;
52 
53  LOG2("DisassemblerPass: start: " << start << " end " << end << nl);
54 
55  disassemble(start, end);
56 #else
57  CodeGenPass *CG = get_Pass<CodeGenPass>();
58  for (CodeGenPass::BasicBlockMap::const_iterator i = CG->begin(), e = CG->end(); i != e ; ++i) {
59  u1 *end = start + i->second;
60  dbg() << BoldWhite << *i->first << " " << reset_color;
61  print_ptr_container(dbg(),i->first->pred_begin(),i->first->pred_end()) << nl;
62  //dbg() << hex << start << " - " << end << dec << " size: " << i->second<< nl;
63  for (; start < end; )
64  start = disassinstr(start);
65  start = end;
66  }
67 #endif
68 
69 #endif
70  return true;
71 }
72 
75  return PU;
76 }
77 
78 // register pass
79 static PassRegistry<DisassemblerPass> X("DisassemblerPass");
80 
81 } // end namespace compiler2
82 } // end namespace jit
83 } // end namespace cacao
84 
85 
86 /*
87  * These are local overrides for various environment variables in Emacs.
88  * Please do not remove this and leave it at the end of the file, where
89  * Emacs will automagically detect them.
90  * ---------------------------------------------------------------------
91  * Local variables:
92  * mode: c++
93  * indent-tabs-mode: t
94  * c-basic-offset: 4
95  * tab-width: 4
96  * End:
97  * vim:noexpandtab:sw=4:ts=4:
98  */
virtual PassUsage & get_PassUsage(PassUsage &PU) const
Set the requirements for the pass.
u1 * disassinstr(u1 *code)
Definition: disass.cpp:48
codeinfo * code
Definition: jit.hpp:128
virtual bool run(JITData &JD)
Run the Pass.
CodeGenPass TODO: more info.
Definition: CodeGenPass.hpp:49
uint8_t u1
Definition: types.hpp:40
s4 mcodelength
Definition: code.hpp:84
jitdata * get_jitdata() const
Definition: JITData.hpp:51
u1 * mcode
Definition: code.hpp:82
BasicBlockMap::const_iterator begin() const
Definition: CodeGenPass.hpp:97
Stores the interdependencies of a pass.
Definition: PassUsage.hpp:55
MIIterator i
#define LOG2(STMT)
Definition: logging.hpp:93
ResetColor reset_color
Definition: OStream.cpp:61
MIIterator e
OptionPrefix & xx_root()
Definition: Option.cpp:39
void disassemble(u1 *start, u1 *end)
Definition: disass.cpp:403
OStream & print_ptr_container(OStream &OS, _ForwardIterator i, const _ForwardIterator &e)
Definition: OStream.hpp:448
BasicBlockMap::const_iterator end() const
Definition: CodeGenPass.hpp:98
static PassRegistry< BasicBlockSchedulingPass > X("BasicBlockSchedulingPass")
Nl nl
Definition: OStream.cpp:56
OStream & dbg()
The default destination for logging messages.
void add_requires()
PassName is required.
Definition: PassUsage.hpp:78
u1 * entrypoint
Definition: code.hpp:83