< prev index next >

src/hotspot/share/runtime/sharedRuntime.cpp

Print this page
rev 63603 : Micro-optimize SharedRuntime::get_referenced_objects


  26 #include "jvm.h"
  27 #include "aot/aotLoader.hpp"
  28 #include "classfile/stringTable.hpp"
  29 #include "classfile/systemDictionary.hpp"
  30 #include "classfile/vmSymbols.hpp"
  31 #include "code/codeCache.hpp"
  32 #include "code/compiledIC.hpp"
  33 #include "code/icBuffer.hpp"
  34 #include "code/compiledMethod.inline.hpp"
  35 #include "code/scopeDesc.hpp"
  36 #include "code/vtableStubs.hpp"
  37 #include "compiler/abstractCompiler.hpp"
  38 #include "compiler/compileBroker.hpp"
  39 #include "compiler/disassembler.hpp"
  40 #include "gc/shared/barrierSet.hpp"
  41 #include "gc/shared/gcLocker.inline.hpp"
  42 #include "interpreter/interpreter.hpp"
  43 #include "interpreter/interpreterRuntime.hpp"
  44 #include "jfr/jfrEvents.hpp"
  45 #include "logging/log.hpp"

  46 #include "memory/metaspaceShared.hpp"
  47 #include "memory/resourceArea.hpp"
  48 #include "memory/universe.hpp"

  49 #include "oops/klass.hpp"
  50 #include "oops/method.inline.hpp"
  51 #include "oops/objArrayKlass.hpp"
  52 #include "oops/oop.inline.hpp"
  53 #include "prims/forte.hpp"
  54 #include "prims/jvmtiExport.hpp"
  55 #include "prims/methodHandles.hpp"
  56 #include "prims/nativeLookup.hpp"
  57 #include "runtime/arguments.hpp"
  58 #include "runtime/atomic.hpp"
  59 #include "runtime/biasedLocking.hpp"
  60 #include "runtime/frame.inline.hpp"
  61 #include "runtime/handles.inline.hpp"
  62 #include "runtime/init.hpp"
  63 #include "runtime/interfaceSupport.inline.hpp"
  64 #include "runtime/java.hpp"
  65 #include "runtime/javaCalls.hpp"

  66 #include "runtime/sharedRuntime.hpp"
  67 #include "runtime/stubRoutines.hpp"
  68 #include "runtime/synchronizer.hpp"
  69 #include "runtime/vframe.inline.hpp"
  70 #include "runtime/vframeArray.hpp"
  71 #include "utilities/copy.hpp"
  72 #include "utilities/dtrace.hpp"
  73 #include "utilities/events.hpp"
  74 #include "utilities/hashtable.inline.hpp"
  75 #include "utilities/macros.hpp"
  76 #include "utilities/xmlstream.hpp"
  77 #ifdef COMPILER1
  78 #include "c1/c1_Runtime1.hpp"
  79 #endif
  80 
  81 // Shared stub locations
  82 RuntimeStub*        SharedRuntime::_wrong_method_blob;
  83 RuntimeStub*        SharedRuntime::_wrong_method_abstract_blob;
  84 RuntimeStub*        SharedRuntime::_ic_miss_blob;
  85 RuntimeStub*        SharedRuntime::_resolve_opt_virtual_call_blob;


3200       break;
3201     } else {
3202       fr = fr.java_sender();
3203     }
3204   }
3205   return activation;
3206 }
3207 
3208 void SharedRuntime::on_slowpath_allocation_exit(JavaThread* thread) {
3209   // After any safepoint, just before going back to compiled code,
3210   // we inform the GC that we will be doing initializing writes to
3211   // this object in the future without emitting card-marks, so
3212   // GC may take any compensating steps.
3213 
3214   oop new_obj = thread->vm_result();
3215   if (new_obj == NULL) return;
3216 
3217   BarrierSet *bs = BarrierSet::barrier_set();
3218   bs->on_slowpath_allocation_exit(thread, new_obj);
3219 }






























































  26 #include "jvm.h"
  27 #include "aot/aotLoader.hpp"
  28 #include "classfile/stringTable.hpp"
  29 #include "classfile/systemDictionary.hpp"
  30 #include "classfile/vmSymbols.hpp"
  31 #include "code/codeCache.hpp"
  32 #include "code/compiledIC.hpp"
  33 #include "code/icBuffer.hpp"
  34 #include "code/compiledMethod.inline.hpp"
  35 #include "code/scopeDesc.hpp"
  36 #include "code/vtableStubs.hpp"
  37 #include "compiler/abstractCompiler.hpp"
  38 #include "compiler/compileBroker.hpp"
  39 #include "compiler/disassembler.hpp"
  40 #include "gc/shared/barrierSet.hpp"
  41 #include "gc/shared/gcLocker.inline.hpp"
  42 #include "interpreter/interpreter.hpp"
  43 #include "interpreter/interpreterRuntime.hpp"
  44 #include "jfr/jfrEvents.hpp"
  45 #include "logging/log.hpp"
  46 #include "memory/iterator.inline.hpp"
  47 #include "memory/metaspaceShared.hpp"
  48 #include "memory/resourceArea.hpp"
  49 #include "memory/universe.hpp"
  50 #include "oops/instanceKlass.inline.hpp"
  51 #include "oops/klass.hpp"
  52 #include "oops/method.inline.hpp"
  53 #include "oops/objArrayKlass.hpp"
  54 #include "oops/oop.inline.hpp"
  55 #include "prims/forte.hpp"
  56 #include "prims/jvmtiExport.hpp"
  57 #include "prims/methodHandles.hpp"
  58 #include "prims/nativeLookup.hpp"
  59 #include "runtime/arguments.hpp"
  60 #include "runtime/atomic.hpp"
  61 #include "runtime/biasedLocking.hpp"
  62 #include "runtime/frame.inline.hpp"
  63 #include "runtime/handles.inline.hpp"
  64 #include "runtime/init.hpp"
  65 #include "runtime/interfaceSupport.inline.hpp"
  66 #include "runtime/java.hpp"
  67 #include "runtime/javaCalls.hpp"
  68 #include "runtime/jniHandles.inline.hpp"
  69 #include "runtime/sharedRuntime.hpp"
  70 #include "runtime/stubRoutines.hpp"
  71 #include "runtime/synchronizer.hpp"
  72 #include "runtime/vframe.inline.hpp"
  73 #include "runtime/vframeArray.hpp"
  74 #include "utilities/copy.hpp"
  75 #include "utilities/dtrace.hpp"
  76 #include "utilities/events.hpp"
  77 #include "utilities/hashtable.inline.hpp"
  78 #include "utilities/macros.hpp"
  79 #include "utilities/xmlstream.hpp"
  80 #ifdef COMPILER1
  81 #include "c1/c1_Runtime1.hpp"
  82 #endif
  83 
  84 // Shared stub locations
  85 RuntimeStub*        SharedRuntime::_wrong_method_blob;
  86 RuntimeStub*        SharedRuntime::_wrong_method_abstract_blob;
  87 RuntimeStub*        SharedRuntime::_ic_miss_blob;
  88 RuntimeStub*        SharedRuntime::_resolve_opt_virtual_call_blob;


3203       break;
3204     } else {
3205       fr = fr.java_sender();
3206     }
3207   }
3208   return activation;
3209 }
3210 
3211 void SharedRuntime::on_slowpath_allocation_exit(JavaThread* thread) {
3212   // After any safepoint, just before going back to compiled code,
3213   // we inform the GC that we will be doing initializing writes to
3214   // this object in the future without emitting card-marks, so
3215   // GC may take any compensating steps.
3216 
3217   oop new_obj = thread->vm_result();
3218   if (new_obj == NULL) return;
3219 
3220   BarrierSet *bs = BarrierSet::barrier_set();
3221   bs->on_slowpath_allocation_exit(thread, new_obj);
3222 }
3223 
3224 class GetReferencedObjectsClosure : public BasicOopIterateClosure {
3225 private:
3226   objArrayOopDesc* const _result;
3227   int _count;
3228 public:
3229   GetReferencedObjectsClosure(objArrayOopDesc* result) : _result(result), _count(0) {}
3230 
3231   template <typename T> void do_oop_nv(T* p) {
3232     oop o = HeapAccess<>::oop_load(p);
3233     if (!CompressedOops::is_null(o)) {
3234       _result->obj_at_put(_count++, o);
3235     }
3236   }
3237 
3238   int count() { return _count; }
3239 
3240   virtual void do_oop(oop* p)       { do_oop_nv(p); }
3241   virtual void do_oop(narrowOop* p) { do_oop_nv(p); }
3242 
3243   // Don't use the oop verification code in the oop_oop_iterate framework.
3244   debug_only(virtual bool should_verify_oops() { return false; })
3245 };
3246 
3247 JRT_LEAF(jint, SharedRuntime::get_referenced_objects(oopDesc* obj, objArrayOopDesc* ref_buf))
3248   assert(Universe::heap()->is_in(obj), "object should be in heap: " PTR_FORMAT, p2i(obj));
3249   assert(Universe::heap()->is_in(ref_buf), "ref buf should be in heap: " PTR_FORMAT, p2i(ref_buf));
3250 
3251   InstanceKlass* k = InstanceKlass::cast(obj->klass());
3252 
3253   int count = 0;
3254   {
3255     InstanceKlass* ik = k;
3256     while (ik != NULL) {
3257       count += ik->nonstatic_oop_field_count();
3258       ik = ik->superklass();
3259     }
3260   }
3261 
3262   if (count == 0) {
3263     return 0;
3264   }
3265 
3266   if (count > ref_buf->length()) {
3267     return -1;
3268   }
3269 
3270   GetReferencedObjectsClosure cl(ref_buf);
3271 
3272 #ifdef _LP64
3273   if (UseCompressedOops) {
3274     k->oop_oop_iterate<narrowOop>(obj, &cl);
3275   } else
3276 #endif
3277   {
3278     k->oop_oop_iterate<oop>(obj, &cl);
3279   }
3280 
3281   return cl.count();
3282 JRT_END
< prev index next >