Exemplo n.º 1
0
  @Override
  public long getMemorySize(Constant constant) {
    if (constant.getKind() == Kind.Object) {
      HotSpotResolvedObjectType lookupJavaType =
          (HotSpotResolvedObjectType) this.lookupJavaType(constant);

      if (lookupJavaType == null) {
        return 0;
      } else {
        if (lookupJavaType.isArray()) {
          // TODO(tw): Add compressed pointer support.
          int length = Array.getLength(HotSpotObjectConstant.asObject(constant));
          ResolvedJavaType elementType = lookupJavaType.getComponentType();
          Kind elementKind = elementType.getKind();
          final int headerSize = HotSpotGraalRuntime.getArrayBaseOffset(elementKind);
          int sizeOfElement = HotSpotGraalRuntime.runtime().getTarget().getSizeInBytes(elementKind);
          int alignment = HotSpotGraalRuntime.runtime().getTarget().wordSize;
          int log2ElementSize = CodeUtil.log2(sizeOfElement);
          return NewObjectSnippets.computeArrayAllocationSize(
              length, alignment, headerSize, log2ElementSize);
        }
        return lookupJavaType.instanceSize();
      }
    } else {
      return constant.getKind().getByteCount();
    }
  }
Exemplo n.º 2
0
 public DeoptimizationAction decodeDeoptAction(Constant constant) {
   HotSpotVMConfig config = runtime.getConfig();
   int actionValue =
       ((~constant.asInt()) >> config.deoptimizationActionShift)
           & intMaskRight(config.deoptimizationActionBits);
   DeoptimizationAction action = convertDeoptAction(actionValue);
   return action;
 }
Exemplo n.º 3
0
 public ResolvedJavaMethod lookupJavaConstructor(Constructor<?> reflectionConstructor) {
   try {
     Class<?> holder = reflectionConstructor.getDeclaringClass();
     final int slot = reflectionConstructorSlot.getInt(reflectionConstructor);
     final long metaspaceMethod = runtime.getCompilerToVM().getMetaspaceMethod(holder, slot);
     return HotSpotResolvedJavaMethod.fromMetaspace(metaspaceMethod);
   } catch (IllegalArgumentException | IllegalAccessException e) {
     throw new GraalInternalError(e);
   }
 }
Exemplo n.º 4
0
 public DeoptimizationReason convertDeoptReason(int reason) {
   HotSpotVMConfig config = runtime.getConfig();
   if (reason == config.deoptReasonNone) {
     return DeoptimizationReason.None;
   }
   if (reason == config.deoptReasonNullCheck) {
     return DeoptimizationReason.NullCheckException;
   }
   if (reason == config.deoptReasonRangeCheck) {
     return DeoptimizationReason.BoundsCheckException;
   }
   if (reason == config.deoptReasonClassCheck) {
     return DeoptimizationReason.ClassCastException;
   }
   if (reason == config.deoptReasonArrayCheck) {
     return DeoptimizationReason.ArrayStoreException;
   }
   if (reason == config.deoptReasonUnreached0) {
     return DeoptimizationReason.UnreachedCode;
   }
   if (reason == config.deoptReasonTypeCheckInlining) {
     return DeoptimizationReason.TypeCheckedInliningViolated;
   }
   if (reason == config.deoptReasonOptimizedTypeCheck) {
     return DeoptimizationReason.OptimizedTypeCheckViolated;
   }
   if (reason == config.deoptReasonNotCompiledExceptionHandler) {
     return DeoptimizationReason.NotCompiledExceptionHandler;
   }
   if (reason == config.deoptReasonUnresolved) {
     return DeoptimizationReason.Unresolved;
   }
   if (reason == config.deoptReasonJsrMismatch) {
     return DeoptimizationReason.JavaSubroutineMismatch;
   }
   if (reason == config.deoptReasonDiv0Check) {
     return DeoptimizationReason.ArithmeticException;
   }
   if (reason == config.deoptReasonConstraint) {
     return DeoptimizationReason.RuntimeConstraint;
   }
   if (reason == config.deoptReasonLoopLimitCheck) {
     return DeoptimizationReason.LoopLimitCheck;
   }
   if (reason == config.deoptReasonAliasing) {
     return DeoptimizationReason.Aliasing;
   }
   if (reason == config.deoptReasonTransferToInterpreter) {
     return DeoptimizationReason.TransferToInterpreter;
   }
   throw GraalInternalError.shouldNotReachHere(Integer.toHexString(reason));
 }
 /**
  * Modifies the {@link GraphBuilderConfiguration} to build extra {@linkplain DebugInfoMode#Simple
  * debug info} if the VM {@linkplain CompilerToVM#shouldDebugNonSafepoints() requests} it.
  *
  * @param gbs the current graph builder suite
  * @return a possibly modified graph builder suite
  */
 public static PhaseSuite<HighTierContext> withSimpleDebugInfoIfRequested(
     PhaseSuite<HighTierContext> gbs) {
   if (HotSpotGraalRuntime.runtime().getCompilerToVM().shouldDebugNonSafepoints()) {
     PhaseSuite<HighTierContext> newGbs = gbs.copy();
     GraphBuilderPhase graphBuilderPhase =
         (GraphBuilderPhase) newGbs.findPhase(GraphBuilderPhase.class).previous();
     GraphBuilderConfiguration graphBuilderConfig = graphBuilderPhase.getGraphBuilderConfig();
     GraphBuilderPhase newGraphBuilderPhase =
         new GraphBuilderPhase(graphBuilderConfig.withDebugInfoMode(DebugInfoMode.Simple));
     newGbs.findPhase(GraphBuilderPhase.class).set(newGraphBuilderPhase);
     return newGbs;
   }
   return gbs;
 }
Exemplo n.º 6
0
 @Override
 public Constant encodeDeoptActionAndReason(
     DeoptimizationAction action, DeoptimizationReason reason, int debugId) {
   HotSpotVMConfig config = runtime.getConfig();
   int actionValue = convertDeoptAction(action);
   int reasonValue = convertDeoptReason(reason);
   int debugValue = debugId & intMaskRight(config.deoptimizationDebugIdBits);
   Constant c =
       Constant.forInt(
           ~((debugValue << config.deoptimizationDebugIdShift)
               | (reasonValue << config.deoptimizationReasonShift)
               | (actionValue << config.deoptimizationActionShift)));
   assert c.asInt() < 0;
   return c;
 }
Exemplo n.º 7
0
 public int convertDeoptAction(DeoptimizationAction action) {
   HotSpotVMConfig config = runtime.getConfig();
   switch (action) {
     case None:
       return config.deoptActionNone;
     case RecompileIfTooManyDeopts:
       return config.deoptActionMaybeRecompile;
     case InvalidateReprofile:
       return config.deoptActionReinterpret;
     case InvalidateRecompile:
       return config.deoptActionMakeNotEntrant;
     case InvalidateStopCompiling:
       return config.deoptActionMakeNotCompilable;
     default:
       throw GraalInternalError.shouldNotReachHere();
   }
 }
Exemplo n.º 8
0
 public DeoptimizationAction convertDeoptAction(int action) {
   HotSpotVMConfig config = runtime.getConfig();
   if (action == config.deoptActionNone) {
     return DeoptimizationAction.None;
   }
   if (action == config.deoptActionMaybeRecompile) {
     return DeoptimizationAction.RecompileIfTooManyDeopts;
   }
   if (action == config.deoptActionReinterpret) {
     return DeoptimizationAction.InvalidateReprofile;
   }
   if (action == config.deoptActionMakeNotEntrant) {
     return DeoptimizationAction.InvalidateRecompile;
   }
   if (action == config.deoptActionMakeNotCompilable) {
     return DeoptimizationAction.InvalidateStopCompiling;
   }
   throw GraalInternalError.shouldNotReachHere();
 }
Exemplo n.º 9
0
 public int convertDeoptReason(DeoptimizationReason reason) {
   HotSpotVMConfig config = runtime.getConfig();
   switch (reason) {
     case None:
       return config.deoptReasonNone;
     case NullCheckException:
       return config.deoptReasonNullCheck;
     case BoundsCheckException:
       return config.deoptReasonRangeCheck;
     case ClassCastException:
       return config.deoptReasonClassCheck;
     case ArrayStoreException:
       return config.deoptReasonArrayCheck;
     case UnreachedCode:
       return config.deoptReasonUnreached0;
     case TypeCheckedInliningViolated:
       return config.deoptReasonTypeCheckInlining;
     case OptimizedTypeCheckViolated:
       return config.deoptReasonOptimizedTypeCheck;
     case NotCompiledExceptionHandler:
       return config.deoptReasonNotCompiledExceptionHandler;
     case Unresolved:
       return config.deoptReasonUnresolved;
     case JavaSubroutineMismatch:
       return config.deoptReasonJsrMismatch;
     case ArithmeticException:
       return config.deoptReasonDiv0Check;
     case RuntimeConstraint:
       return config.deoptReasonConstraint;
     case LoopLimitCheck:
       return config.deoptReasonLoopLimitCheck;
     case Aliasing:
       return config.deoptReasonAliasing;
     case TransferToInterpreter:
       return config.deoptReasonTransferToInterpreter;
     default:
       throw GraalInternalError.shouldNotReachHere();
   }
 }
Exemplo n.º 10
0
 public int decodeDebugId(Constant constant) {
   HotSpotVMConfig config = runtime.getConfig();
   return ((~constant.asInt()) >> config.deoptimizationDebugIdShift)
       & intMaskRight(config.deoptimizationDebugIdBits);
 }