CACAO
Value.cpp
Go to the documentation of this file.
1 /* src/vm/jit/compiler2/Value.cpp - Value
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 
27 #include "toolbox/logging.hpp"
28 
29 #define DEBUG_NAME "compiler2/Value"
30 
31 namespace cacao {
32 namespace jit {
33 namespace compiler2 {
34 
36  if (!V)
37  return OS << "Value NULL";
38  return OS << *V;
39 }
41  OS << "[Value ";
42  for(UserListTy::const_iterator i = user_list.begin(), e = user_list.end(); i != e; ++i) {
43  Instruction *I = *i;
44  OS << I->get_id() << " ";
45  }
46  return print_users(OS) << "]";
47 }
49  OS << "Users of " << this << nl ;
50  for(UserListTy::const_iterator i = user_list.begin(), e = user_list.end(); i != e; ++i) {
51  OS << "user: " << *i << nl;
52  }
53  return OS;
54 }
56  LOG("Value::replace_value(this=" << this << ",v=" << v << ")" << nl );
59  while ( (i = user_list.begin() ) != e ) {
60  #ifndef NDEBUG
61  size_t size = user_list.size();
62  #endif
63  DEBUG(print_users(dbg()));
64  Instruction *I = *i;
65  LOG("replacing value " << this << " with " << v << nl );
66  assert(I);
67  I->replace_op(this, v);
68  assert( size > user_list.size());
69  }
70 }
71 #if 0
72 void Value::remove_user(Instruction* I) {
73  #if 0 & NDEBUG
74  size_t size = user_list.size();
75  #endif
76  LOG("Value::remove_user(this=" << this << ",I=" << I << ")" << nl );
77  user_list.remove(I);
78  #if 0
79  if (!( size > user_list.size())) {
80  WARING_MSG("corrupt double link detected","Instruction " << I << " used " << this);
81  }
82  UserListTy::iterator f = user_list.find(I);
83  if (f != user_list.end()) {
84  user_list.erase(f);
85  }
86  user_list.erase(std::find(user_list.begin(),user_list.end(),I));
87  #endif
88 }
89 #endif
91 {
92 #if 0
93 #ifndef NDEBUG
94  size_t size = user_list.size();
95 #endif
96 
97  LOG("Value::~Value(this=" << this << ")" << nl );
100  while ( (i = user_list.begin() ) != e ) {
101  Instruction *I = *i;
102  assert(I);
103  I->replace_op(this, NULL);
104  assert( --size == user_list.size());
105  }
106 #endif
107 }
108 
109 } // end namespace cacao
110 } // end namespace jit
111 } // end namespace compiler2
112 
113 
114 /*
115  * These are local overrides for various environment variables in Emacs.
116  * Please do not remove this and leave it at the end of the file, where
117  * Emacs will automagically detect them.
118  * ---------------------------------------------------------------------
119  * Local variables:
120  * mode: c++
121  * indent-tabs-mode: t
122  * c-basic-offset: 4
123  * tab-width: 4
124  * End:
125  * vim:noexpandtab:sw=4:ts=4:
126  */
virtual OStream & print(OStream &OS) const
print
Definition: Value.cpp:40
#define DEBUG(STMT)
Execute debug statements in your current module.
Definition: Debug.hpp:125
_Base::const_iterator const_iterator
JNIEnv jthread jobject jclass jlong size
Definition: jvmti.h:387
void replace_value(Value *v)
Replace this Value this the new one in all users.
Definition: Value.cpp:55
int get_id() const
return a unique identifier for this instruction
Simple stream class for formatted output.
Definition: OStream.hpp:141
Instruction super class.
Definition: Instruction.hpp:73
OStream & operator<<(OStream &OS, const Conditional::CondID &cond)
Definition: Conditional.cpp:34
void replace_op(Value *v_old, Value *v_new)
Definition: Instruction.cpp:66
MIIterator i
OStream & OS
OStream & print_users(OStream &OS) const
Definition: Value.cpp:48
MIIterator e
#define LOG(STMT)
Analogous to DEBUG.
Definition: logging.hpp:91
_Base::iterator iterator
#define I(value)
Definition: codegen.c:279
Nl nl
Definition: OStream.cpp:56
OStream & dbg()
The default destination for logging messages.