156 int ciObject::hash() { |
158 int ciObject::hash() { |
157 return ident() * 31; |
159 return ident() * 31; |
158 } |
160 } |
159 |
161 |
160 // ------------------------------------------------------------------ |
162 // ------------------------------------------------------------------ |
161 // ciObject::encoding |
163 // ciObject::constant_encoding |
162 // |
164 // |
163 // The address which the compiler should embed into the |
165 // The address which the compiler should embed into the |
164 // generated code to represent this oop. This address |
166 // generated code to represent this oop. This address |
165 // is not the true address of the oop -- it will get patched |
167 // is not the true address of the oop -- it will get patched |
166 // during nmethod creation. |
168 // during nmethod creation. |
170 // Implementation note: we use the handle as the encoding. The |
172 // Implementation note: we use the handle as the encoding. The |
171 // nmethod constructor resolves the handle and patches in the oop. |
173 // nmethod constructor resolves the handle and patches in the oop. |
172 // |
174 // |
173 // This method should be changed to return an generified address |
175 // This method should be changed to return an generified address |
174 // to discourage use of the JNI handle. |
176 // to discourage use of the JNI handle. |
175 jobject ciObject::encoding() { |
177 jobject ciObject::constant_encoding() { |
176 assert(is_null_object() || handle() != NULL, "cannot embed null pointer"); |
178 assert(is_null_object() || handle() != NULL, "cannot embed null pointer"); |
177 assert(has_encoding(), "oop must be NULL or perm"); |
179 assert(can_be_constant(), "oop must be NULL or perm"); |
178 return handle(); |
180 return handle(); |
179 } |
181 } |
180 |
182 |
181 // ------------------------------------------------------------------ |
183 // ------------------------------------------------------------------ |
182 // ciObject::has_encoding |
184 // ciObject::can_be_constant |
183 bool ciObject::has_encoding() { |
185 bool ciObject::can_be_constant() { |
184 return handle() == NULL || is_perm(); |
186 if (ScavengeRootsInCode >= 1) return true; // now everybody can encode as a constant |
|
187 return handle() == NULL || !is_scavengable(); |
|
188 } |
|
189 |
|
190 // ------------------------------------------------------------------ |
|
191 // ciObject::should_be_constant() |
|
192 bool ciObject::should_be_constant() { |
|
193 if (ScavengeRootsInCode >= 2) return true; // force everybody to be a constant |
|
194 return handle() == NULL || !is_scavengable(); |
185 } |
195 } |
186 |
196 |
187 |
197 |
188 // ------------------------------------------------------------------ |
198 // ------------------------------------------------------------------ |
189 // ciObject::print |
199 // ciObject::print |
193 // Implementation note: dispatch to the virtual print_impl behavior |
203 // Implementation note: dispatch to the virtual print_impl behavior |
194 // for this ciObject. |
204 // for this ciObject. |
195 void ciObject::print(outputStream* st) { |
205 void ciObject::print(outputStream* st) { |
196 st->print("<%s", type_string()); |
206 st->print("<%s", type_string()); |
197 GUARDED_VM_ENTRY(print_impl(st);) |
207 GUARDED_VM_ENTRY(print_impl(st);) |
198 st->print(" ident=%d %s address=0x%x>", ident(), |
208 st->print(" ident=%d %s%s address=0x%x>", ident(), |
199 is_perm() ? "PERM" : "", |
209 is_perm() ? "PERM" : "", |
|
210 is_scavengable() ? "SCAVENGABLE" : "", |
200 (address)this); |
211 (address)this); |
201 } |
212 } |
202 |
213 |
203 // ------------------------------------------------------------------ |
214 // ------------------------------------------------------------------ |
204 // ciObject::print_oop |
215 // ciObject::print_oop |