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 // the address of this variable is used to identify the pass
79 char DisassemblerPass::ID = 0;
80 
81 // register pass
82 static PassRegistry<DisassemblerPass> X("DisassemblerPass");
83 
84 } // end namespace compiler2
85 } // end namespace jit
86 } // end namespace cacao
87 
88 
89 /*
90  * These are local overrides for various environment variables in Emacs.
91  * Please do not remove this and leave it at the end of the file, where
92  * Emacs will automagically detect them.
93  * ---------------------------------------------------------------------
94  * Local variables:
95  * mode: c++
96  * indent-tabs-mode: t
97  * c-basic-offset: 4
98  * tab-width: 4
99  * End:
100  * vim:noexpandtab:sw=4:ts=4:
101  */
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:85
jitdata * get_jitdata() const
Definition: JITData.hpp:51
u1 * mcode
Definition: code.hpp:83
BasicBlockMap::const_iterator begin() const
Definition: CodeGenPass.hpp:72
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:73
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:84