hotspot/src/share/vm/ci/ciObject.cpp
changeset 3908 24b55ad4c228
parent 1 489c9b5090e2
child 5547 f4b087cbb361
equal deleted inserted replaced
3906:6767b0c66883 3908:24b55ad4c228
    53   } else {
    53   } else {
    54     _handle = JNIHandles::make_global(o);
    54     _handle = JNIHandles::make_global(o);
    55   }
    55   }
    56   _klass = NULL;
    56   _klass = NULL;
    57   _ident = 0;
    57   _ident = 0;
       
    58   init_flags_from(o);
    58 }
    59 }
    59 
    60 
    60 // ------------------------------------------------------------------
    61 // ------------------------------------------------------------------
    61 // ciObject::ciObject
    62 // ciObject::ciObject
    62 //
    63 //
    67   } else {
    68   } else {
    68     _handle = JNIHandles::make_global(h);
    69     _handle = JNIHandles::make_global(h);
    69   }
    70   }
    70   _klass = NULL;
    71   _klass = NULL;
    71   _ident = 0;
    72   _ident = 0;
       
    73   init_flags_from(h());
    72 }
    74 }
    73 
    75 
    74 // ------------------------------------------------------------------
    76 // ------------------------------------------------------------------
    75 // ciObject::ciObject
    77 // ciObject::ciObject
    76 //
    78 //
   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