Exemple #1
0
void GraalCompiler::compile_method(methodHandle method, int entry_bci, CompileTask* task) {
  GRAAL_EXCEPTION_CONTEXT

  bool is_osr = entry_bci != InvocationEntryBci;
  if (_bootstrapping && is_osr) {
      // no OSR compilations during bootstrap - the compiler is just too slow at this point,
      // and we know that there are no endless loops
      return;
  }

  HandleMark hm;
  ResourceMark rm;
  JavaValue result(T_VOID);
  JavaCallArguments args;
  args.push_long((jlong) (address) method());
  args.push_int(entry_bci);
  args.push_long((jlong) (address) task);
  args.push_int(task->compile_id());
  JavaCalls::call_static(&result, SystemDictionary::CompilationTask_klass(), vmSymbols::compileMetaspaceMethod_name(), vmSymbols::compileMetaspaceMethod_signature(), &args, CHECK_ABORT);

  _methodsCompiled++;
}
Exemple #2
0
oop LiveFrameStream::create_primitive_value_instance(StackValueCollection* values, int i, TRAPS) {
    Klass* k = SystemDictionary::resolve_or_null(vmSymbols::java_lang_LiveStackFrameInfo(), CHECK_NULL);
    instanceKlassHandle ik (THREAD, k);

    JavaValue result(T_OBJECT);
    JavaCallArguments args;
    Symbol* signature = NULL;

    // ## TODO: type is only available in LocalVariable table, if present.
    // ## StackValue type is T_INT or T_OBJECT.
    switch (values->at(i)->type()) {
    case T_INT:
        args.push_int(values->int_at(i));
        signature = vmSymbols::asPrimitive_int_signature();
        break;

    case T_LONG:
        args.push_long(values->long_at(i));
        signature = vmSymbols::asPrimitive_long_signature();
        break;

    case T_FLOAT:
        args.push_float(values->float_at(i));
        signature = vmSymbols::asPrimitive_float_signature();
        break;

    case T_DOUBLE:
        args.push_double(values->double_at(i));
        signature = vmSymbols::asPrimitive_double_signature();
        break;

    case T_BYTE:
        args.push_int(values->int_at(i));
        signature = vmSymbols::asPrimitive_byte_signature();
        break;

    case T_SHORT:
        args.push_int(values->int_at(i));
        signature = vmSymbols::asPrimitive_short_signature();
        break;

    case T_CHAR:
        args.push_int(values->int_at(i));
        signature = vmSymbols::asPrimitive_char_signature();
        break;

    case T_BOOLEAN:
        args.push_int(values->int_at(i));
        signature = vmSymbols::asPrimitive_boolean_signature();
        break;

    case T_OBJECT:
        return values->obj_at(i)();

    case T_CONFLICT:
        // put a non-null slot
        args.push_int(0);
        signature = vmSymbols::asPrimitive_int_signature();
        break;

    default:
        ShouldNotReachHere();
    }
    JavaCalls::call_static(&result,
                           ik,
                           vmSymbols::asPrimitive_name(),
                           signature,
                           &args,
                           CHECK_NULL);
    return (instanceOop) result.get_jobject();
}
 inline void do_int()    { if (!is_return_type()) _jca->push_int(next_arg(T_INT)->int_field(java_lang_boxing_object::value_offset_in_bytes(T_INT))); }
Exemple #4
0
static Handle createGcInfo(GCMemoryManager *gcManager, GCStatInfo *gcStatInfo,TRAPS) {

  // Fill the arrays of MemoryUsage objects with before and after GC
  // per pool memory usage

  Klass* mu_klass = Management::java_lang_management_MemoryUsage_klass(CHECK_NH);
  instanceKlassHandle mu_kh(THREAD, mu_klass);

  // The array allocations below should use a handle containing mu_klass
  // as the first allocation could trigger a GC, causing the actual
  // klass oop to move, and leaving mu_klass pointing to the old
  // location.
  objArrayOop bu = oopFactory::new_objArray(mu_kh(), MemoryService::num_memory_pools(), CHECK_NH);
  objArrayHandle usage_before_gc_ah(THREAD, bu);
  objArrayOop au = oopFactory::new_objArray(mu_kh(), MemoryService::num_memory_pools(), CHECK_NH);
  objArrayHandle usage_after_gc_ah(THREAD, au);

  for (int i = 0; i < MemoryService::num_memory_pools(); i++) {
    Handle before_usage = MemoryService::create_MemoryUsage_obj(gcStatInfo->before_gc_usage_for_pool(i), CHECK_NH);
    Handle after_usage;

    MemoryUsage u = gcStatInfo->after_gc_usage_for_pool(i);
    if (u.max_size() == 0 && u.used() > 0) {
      // If max size == 0, this pool is a survivor space.
      // Set max size = -1 since the pools will be swapped after GC.
      MemoryUsage usage(u.init_size(), u.used(), u.committed(), (size_t)-1);
      after_usage = MemoryService::create_MemoryUsage_obj(usage, CHECK_NH);
    } else {
        after_usage = MemoryService::create_MemoryUsage_obj(u, CHECK_NH);
    }
    usage_before_gc_ah->obj_at_put(i, before_usage());
    usage_after_gc_ah->obj_at_put(i, after_usage());
  }

  // Current implementation only has 1 attribute (number of GC threads)
  // The type is 'I'
  objArrayOop extra_args_array = oopFactory::new_objArray(SystemDictionary::Integer_klass(), 1, CHECK_NH);
  objArrayHandle extra_array (THREAD, extra_args_array);
  Klass* itKlass = SystemDictionary::Integer_klass();
  instanceKlassHandle intK(THREAD, itKlass);

  instanceHandle extra_arg_val = intK->allocate_instance_handle(CHECK_NH);

  {
    JavaValue res(T_VOID);
    JavaCallArguments argsInt;
    argsInt.push_oop(extra_arg_val);
    argsInt.push_int(gcManager->num_gc_threads());

    JavaCalls::call_special(&res,
                            intK,
                            vmSymbols::object_initializer_name(),
                            vmSymbols::int_void_signature(),
                            &argsInt,
                            CHECK_NH);
  }
  extra_array->obj_at_put(0,extra_arg_val());

  Klass* gcInfoklass = Management::com_sun_management_GcInfo_klass(CHECK_NH);
  instanceKlassHandle ik(THREAD, gcInfoklass);

  Handle gcInfo_instance = ik->allocate_instance_handle(CHECK_NH);

  JavaValue constructor_result(T_VOID);
  JavaCallArguments constructor_args(16);
  constructor_args.push_oop(gcInfo_instance);
  constructor_args.push_oop(getGcInfoBuilder(gcManager,THREAD));
  constructor_args.push_long(gcStatInfo->gc_index());
  constructor_args.push_long(Management::ticks_to_ms(gcStatInfo->start_time()));
  constructor_args.push_long(Management::ticks_to_ms(gcStatInfo->end_time()));
  constructor_args.push_oop(usage_before_gc_ah);
  constructor_args.push_oop(usage_after_gc_ah);
  constructor_args.push_oop(extra_array);

  JavaCalls::call_special(&constructor_result,
                          ik,
                          vmSymbols::object_initializer_name(),
                          vmSymbols::com_sun_management_GcInfo_constructor_signature(),
                          &constructor_args,
                          CHECK_NH);

  return Handle(gcInfo_instance());
}
 inline void do_char()   { if (!is_return_type()) _jca->push_int(next_arg(T_CHAR)->char_field(java_lang_boxing_object::value_offset_in_bytes(T_CHAR))); }
 inline void do_bool()   { if (!is_return_type()) _jca->push_int(next_arg(T_BOOLEAN)->bool_field(java_lang_boxing_object::value_offset_in_bytes(T_BOOLEAN))); }
Exemple #7
0
// Returns an instanceHandle of a MemoryPool object.
// It creates a MemoryPool instance when the first time
// this function is called.
instanceOop MemoryPool::get_memory_pool_instance(TRAPS) {
  // Must do an acquire so as to force ordering of subsequent
  // loads from anything _memory_pool_obj points to or implies.
  instanceOop pool_obj = (instanceOop)OrderAccess::load_ptr_acquire(&_memory_pool_obj);
  if (pool_obj == NULL) {
    // It's ok for more than one thread to execute the code up to the locked region.
    // Extra pool instances will just be gc'ed.
    klassOop k = Management::sun_management_ManagementFactory_klass(CHECK_NULL);
    instanceKlassHandle ik(THREAD, k);

    Handle pool_name = java_lang_String::create_from_str(_name, CHECK_NULL);
    jlong usage_threshold_value = (_usage_threshold->is_high_threshold_supported() ? 0 : -1L);
    jlong gc_usage_threshold_value = (_gc_usage_threshold->is_high_threshold_supported() ? 0 : -1L);

    JavaValue result(T_OBJECT);
    JavaCallArguments args;
    args.push_oop(pool_name);           // Argument 1
    args.push_int((int) is_heap());     // Argument 2

    symbolHandle method_name = vmSymbolHandles::createMemoryPool_name();
    symbolHandle signature = vmSymbolHandles::createMemoryPool_signature();

    args.push_long(usage_threshold_value);    // Argument 3
    args.push_long(gc_usage_threshold_value); // Argument 4

    JavaCalls::call_static(&result,
                           ik,
                           method_name,
                           signature,
                           &args,
                           CHECK_NULL);

    instanceOop p = (instanceOop) result.get_jobject();
    instanceHandle pool(THREAD, p);

    {
      // Get lock since another thread may have create the instance
      MutexLocker ml(Management_lock);

      // Check if another thread has created the pool.  We reload
      // _memory_pool_obj here because some other thread may have
      // initialized it while we were executing the code before the lock.
      //
      // The lock has done an acquire, so the load can't float above it,
      // but we need to do a load_acquire as above.
      pool_obj = (instanceOop)OrderAccess::load_ptr_acquire(&_memory_pool_obj);
      if (pool_obj != NULL) {
         return pool_obj;
      }

      // Get the address of the object we created via call_special.
      pool_obj = pool();

      // Use store barrier to make sure the memory accesses associated
      // with creating the pool are visible before publishing its address.
      // The unlock will publish the store to _memory_pool_obj because
      // it does a release first.
      OrderAccess::release_store_ptr(&_memory_pool_obj, pool_obj);
    }
  }

  return pool_obj;
}
void JVMCICompiler::compile_method(const methodHandle& method, int entry_bci, JVMCIEnv* env) {
  JVMCI_EXCEPTION_CONTEXT

  bool is_osr = entry_bci != InvocationEntryBci;
  if (_bootstrapping && is_osr) {
      // no OSR compilations during bootstrap - the compiler is just too slow at this point,
      // and we know that there are no endless loops
      return;
  }

  JVMCIRuntime::initialize_well_known_classes(CHECK_ABORT);

  HandleMark hm;
  Handle receiver = JVMCIRuntime::get_HotSpotJVMCIRuntime(CHECK_ABORT);

  JavaValue method_result(T_OBJECT);
  JavaCallArguments args;
  args.push_long((jlong) (address) method());
  JavaCalls::call_static(&method_result, SystemDictionary::HotSpotResolvedJavaMethodImpl_klass(),
                         vmSymbols::fromMetaspace_name(), vmSymbols::method_fromMetaspace_signature(), &args, THREAD);

  JavaValue result(T_OBJECT);
  if (!HAS_PENDING_EXCEPTION) {
    JavaCallArguments args;
    args.push_oop(receiver);
    args.push_oop((oop)method_result.get_jobject());
    args.push_int(entry_bci);
    args.push_long((jlong) (address) env);
    args.push_int(env->task()->compile_id());
    JavaCalls::call_special(&result, receiver->klass(),
                            vmSymbols::compileMethod_name(), vmSymbols::compileMethod_signature(), &args, THREAD);
  }

  // An uncaught exception was thrown during compilation.  Generally these
  // should be handled by the Java code in some useful way but if they leak
  // through to here report them instead of dying or silently ignoring them.
  if (HAS_PENDING_EXCEPTION) {
    Handle exception(THREAD, PENDING_EXCEPTION);
    CLEAR_PENDING_EXCEPTION;

    java_lang_Throwable::java_printStackTrace(exception, THREAD);

    env->set_failure("exception throw", false);
  } else {
    oop result_object = (oop) result.get_jobject();
    if (result_object != NULL) {
      oop failure_message = CompilationRequestResult::failureMessage(result_object);
      if (failure_message != NULL) {
        const char* failure_reason = java_lang_String::as_utf8_string(failure_message);
        env->set_failure(failure_reason, CompilationRequestResult::retry(result_object) != 0);
      } else {
        if (env->task()->code() == NULL) {
          env->set_failure("no nmethod produced", true);
        } else {
          env->task()->set_num_inlined_bytecodes(CompilationRequestResult::inlinedBytecodes(result_object));
          Atomic::inc(&_methods_compiled);
        }
      }
    } else {
      assert(false, "JVMCICompiler.compileMethod should always return non-null");
    }
  }
}
 virtual void pushInt(jint i) { _javaArgs->push_int(i); }