equal
deleted
inserted
replaced
57 } else { |
57 } else { |
58 Handle obj(Thread::current(), o); |
58 Handle obj(Thread::current(), o); |
59 _handle = JNIHandles::make_global(obj); |
59 _handle = JNIHandles::make_global(obj); |
60 } |
60 } |
61 _klass = NULL; |
61 _klass = NULL; |
62 init_flags_from(o); |
62 assert(oopDesc::is_oop_or_null(o), "Checking"); |
63 } |
63 } |
64 |
64 |
65 // ------------------------------------------------------------------ |
65 // ------------------------------------------------------------------ |
66 // ciObject::ciObject |
66 // ciObject::ciObject |
67 // |
67 // |
71 _handle = JNIHandles::make_local(h()); |
71 _handle = JNIHandles::make_local(h()); |
72 } else { |
72 } else { |
73 _handle = JNIHandles::make_global(h); |
73 _handle = JNIHandles::make_global(h); |
74 } |
74 } |
75 _klass = NULL; |
75 _klass = NULL; |
76 init_flags_from(h()); |
76 assert(oopDesc::is_oop_or_null(h()), "Checking"); |
77 } |
77 } |
78 |
78 |
79 // ------------------------------------------------------------------ |
79 // ------------------------------------------------------------------ |
80 // ciObject::ciObject |
80 // ciObject::ciObject |
81 // |
81 // |
163 // |
163 // |
164 // This method should be changed to return an generified address |
164 // This method should be changed to return an generified address |
165 // to discourage use of the JNI handle. |
165 // to discourage use of the JNI handle. |
166 jobject ciObject::constant_encoding() { |
166 jobject ciObject::constant_encoding() { |
167 assert(is_null_object() || handle() != NULL, "cannot embed null pointer"); |
167 assert(is_null_object() || handle() != NULL, "cannot embed null pointer"); |
168 assert(can_be_constant(), "oop must be NULL or perm"); |
|
169 return handle(); |
168 return handle(); |
170 } |
|
171 |
|
172 // ------------------------------------------------------------------ |
|
173 // ciObject::can_be_constant |
|
174 bool ciObject::can_be_constant() { |
|
175 if (ScavengeRootsInCode >= 1) return true; // now everybody can encode as a constant |
|
176 return handle() == NULL; |
|
177 } |
169 } |
178 |
170 |
179 // ------------------------------------------------------------------ |
171 // ------------------------------------------------------------------ |
180 // ciObject::should_be_constant() |
172 // ciObject::should_be_constant() |
181 bool ciObject::should_be_constant() { |
173 bool ciObject::should_be_constant() { |
191 if (klass() == env->String_klass() || klass() == env->Class_klass()) { |
183 if (klass() == env->String_klass() || klass() == env->Class_klass()) { |
192 return true; |
184 return true; |
193 } |
185 } |
194 if (klass()->is_subclass_of(env->MethodHandle_klass()) || |
186 if (klass()->is_subclass_of(env->MethodHandle_klass()) || |
195 klass()->is_subclass_of(env->CallSite_klass())) { |
187 klass()->is_subclass_of(env->CallSite_klass())) { |
196 assert(ScavengeRootsInCode >= 1, "must be"); |
|
197 // We want to treat these aggressively. |
188 // We want to treat these aggressively. |
198 return true; |
189 return true; |
199 } |
190 } |
200 |
191 |
201 return handle() == NULL; |
192 return handle() == NULL; |
202 } |
|
203 |
|
204 // ------------------------------------------------------------------ |
|
205 // ciObject::should_be_constant() |
|
206 void ciObject::init_flags_from(oop x) { |
|
207 int flags = 0; |
|
208 if (x != NULL) { |
|
209 assert(Universe::heap()->is_in_reserved(x), "must be"); |
|
210 if (Universe::heap()->is_scavengable(x)) |
|
211 flags |= SCAVENGABLE_FLAG; |
|
212 } |
|
213 _ident |= flags; |
|
214 } |
193 } |
215 |
194 |
216 // ------------------------------------------------------------------ |
195 // ------------------------------------------------------------------ |
217 // ciObject::print |
196 // ciObject::print |
218 // |
197 // |
221 // Implementation note: dispatch to the virtual print_impl behavior |
200 // Implementation note: dispatch to the virtual print_impl behavior |
222 // for this ciObject. |
201 // for this ciObject. |
223 void ciObject::print(outputStream* st) { |
202 void ciObject::print(outputStream* st) { |
224 st->print("<%s", type_string()); |
203 st->print("<%s", type_string()); |
225 GUARDED_VM_ENTRY(print_impl(st);) |
204 GUARDED_VM_ENTRY(print_impl(st);) |
226 st->print(" ident=%d %s address=" INTPTR_FORMAT ">", ident(), |
205 st->print(" ident=%d address=" INTPTR_FORMAT ">", ident(), p2i(this)); |
227 is_scavengable() ? "SCAVENGABLE" : "", |
|
228 p2i((address)this)); |
|
229 } |
206 } |
230 |
207 |
231 // ------------------------------------------------------------------ |
208 // ------------------------------------------------------------------ |
232 // ciObject::print_oop |
209 // ciObject::print_oop |
233 // |
210 // |