< prev index next >

src/share/vm/shark/sharkRuntime.cpp

Print this page




  24  */
  25 
  26 #include "precompiled.hpp"
  27 #include "runtime/atomic.hpp"
  28 #include "runtime/biasedLocking.hpp"
  29 #include "runtime/deoptimization.hpp"
  30 #include "runtime/thread.hpp"
  31 #include "shark/llvmHeaders.hpp"
  32 #include "shark/sharkRuntime.hpp"
  33 #include "utilities/macros.hpp"
  34 #ifdef ZERO
  35 # include "stack_zero.inline.hpp"
  36 #endif
  37 
  38 using namespace llvm;
  39 
  40 JRT_ENTRY(int, SharkRuntime::find_exception_handler(JavaThread* thread,
  41                                                     int*        indexes,
  42                                                     int         num_indexes))
  43   constantPoolHandle pool(thread, method(thread)->constants());
  44   KlassHandle exc_klass(thread, ((oop) tos_at(thread, 0))->klass());
  45 
  46   for (int i = 0; i < num_indexes; i++) {
  47     Klass* tmp = pool->klass_at(indexes[i], CHECK_0);
  48     KlassHandle chk_klass(thread, tmp);
  49 
  50     if (exc_klass() == chk_klass())
  51       return i;
  52 
  53     if (exc_klass()->is_subtype_of(chk_klass()))
  54       return i;
  55   }
  56 
  57   return -1;
  58 JRT_END
  59 
  60 JRT_ENTRY(void, SharkRuntime::monitorenter(JavaThread*      thread,
  61                                            BasicObjectLock* lock))
  62   if (PrintBiasedLockingStatistics)
  63     Atomic::inc(BiasedLocking::slow_path_entry_count_addr());
  64 
  65   Handle object(thread, lock->obj());
  66   assert(Universe::heap()->is_in_reserved_or_null(object()), "should be");
  67   if (UseBiasedLocking) {
  68     // Retry fast entry if bias is revoked to avoid unnecessary inflation
  69     ObjectSynchronizer::fast_enter(object, lock->lock(), true, CHECK);
  70   } else {
  71     ObjectSynchronizer::slow_enter(object, lock->lock(), CHECK);
  72   }
  73   assert(Universe::heap()->is_in_reserved_or_null(lock->obj()), "should be");
  74 JRT_END
  75 
  76 JRT_ENTRY(void, SharkRuntime::monitorexit(JavaThread*      thread,
  77                                           BasicObjectLock* lock))
  78   Handle object(thread, lock->obj());
  79   assert(Universe::heap()->is_in_reserved_or_null(object()), "should be");
  80   if (lock == NULL || object()->is_unlocked()) {
  81     THROW(vmSymbols::java_lang_IllegalMonitorStateException());
  82   }
  83   ObjectSynchronizer::slow_exit(object(), lock->lock(), thread);
  84 JRT_END
  85 
  86 JRT_ENTRY(void, SharkRuntime::new_instance(JavaThread* thread, int index))
  87   Klass* k_oop = method(thread)->constants()->klass_at(index, CHECK);
  88   instanceKlassHandle klass(THREAD, k_oop);
  89 
  90   // Make sure we are not instantiating an abstract klass
  91   klass->check_valid_for_instantiation(true, CHECK);
  92 
  93   // Make sure klass is initialized
  94   klass->initialize(CHECK);
  95 
  96   // At this point the class may not be fully initialized
  97   // because of recursive initialization. If it is fully
  98   // initialized & has_finalized is not set, we rewrite
  99   // it into its fast version (Note: no locking is needed
 100   // here since this is an atomic byte write and can be
 101   // done more than once).
 102   //
 103   // Note: In case of classes with has_finalized we don't
 104   //       rewrite since that saves us an extra check in
 105   //       the fast version which then would call the
 106   //       slow version anyway (and do a call back into
 107   //       Java).
 108   //       If we have a breakpoint, then we don't rewrite




  24  */
  25 
  26 #include "precompiled.hpp"
  27 #include "runtime/atomic.hpp"
  28 #include "runtime/biasedLocking.hpp"
  29 #include "runtime/deoptimization.hpp"
  30 #include "runtime/thread.hpp"
  31 #include "shark/llvmHeaders.hpp"
  32 #include "shark/sharkRuntime.hpp"
  33 #include "utilities/macros.hpp"
  34 #ifdef ZERO
  35 # include "stack_zero.inline.hpp"
  36 #endif
  37 
  38 using namespace llvm;
  39 
  40 JRT_ENTRY(int, SharkRuntime::find_exception_handler(JavaThread* thread,
  41                                                     int*        indexes,
  42                                                     int         num_indexes))
  43   constantPoolHandle pool(thread, method(thread)->constants());
  44   Klass* exc_klass = ((oop) tos_at(thread, 0))->klass();
  45 
  46   for (int i = 0; i < num_indexes; i++) {
  47     Klass* tmp = pool->klass_at(indexes[i], CHECK_0);

  48 
  49     if (exc_klass() == tmp)
  50       return i;
  51 
  52     if (exc_klass()->is_subtype_of(tmp))
  53       return i;
  54   }
  55 
  56   return -1;
  57 JRT_END
  58 
  59 JRT_ENTRY(void, SharkRuntime::monitorenter(JavaThread*      thread,
  60                                            BasicObjectLock* lock))
  61   if (PrintBiasedLockingStatistics)
  62     Atomic::inc(BiasedLocking::slow_path_entry_count_addr());
  63 
  64   Handle object(thread, lock->obj());
  65   assert(Universe::heap()->is_in_reserved_or_null(object()), "should be");
  66   if (UseBiasedLocking) {
  67     // Retry fast entry if bias is revoked to avoid unnecessary inflation
  68     ObjectSynchronizer::fast_enter(object, lock->lock(), true, CHECK);
  69   } else {
  70     ObjectSynchronizer::slow_enter(object, lock->lock(), CHECK);
  71   }
  72   assert(Universe::heap()->is_in_reserved_or_null(lock->obj()), "should be");
  73 JRT_END
  74 
  75 JRT_ENTRY(void, SharkRuntime::monitorexit(JavaThread*      thread,
  76                                           BasicObjectLock* lock))
  77   Handle object(thread, lock->obj());
  78   assert(Universe::heap()->is_in_reserved_or_null(object()), "should be");
  79   if (lock == NULL || object()->is_unlocked()) {
  80     THROW(vmSymbols::java_lang_IllegalMonitorStateException());
  81   }
  82   ObjectSynchronizer::slow_exit(object(), lock->lock(), thread);
  83 JRT_END
  84 
  85 JRT_ENTRY(void, SharkRuntime::new_instance(JavaThread* thread, int index))
  86   Klass* k_oop = method(thread)->constants()->klass_at(index, CHECK);
  87   InstanceKlass* klass = InstanceKlass::cast(k);
  88 
  89   // Make sure we are not instantiating an abstract klass
  90   klass->check_valid_for_instantiation(true, CHECK);
  91 
  92   // Make sure klass is initialized
  93   klass->initialize(CHECK);
  94 
  95   // At this point the class may not be fully initialized
  96   // because of recursive initialization. If it is fully
  97   // initialized & has_finalized is not set, we rewrite
  98   // it into its fast version (Note: no locking is needed
  99   // here since this is an atomic byte write and can be
 100   // done more than once).
 101   //
 102   // Note: In case of classes with has_finalized we don't
 103   //       rewrite since that saves us an extra check in
 104   //       the fast version which then would call the
 105   //       slow version anyway (and do a call back into
 106   //       Java).
 107   //       If we have a breakpoint, then we don't rewrite


< prev index next >