Ejemplo 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();
    }
  }
Ejemplo n.º 2
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;
 }
Ejemplo n.º 3
0
 public ResolvedJavaType lookupJavaType(Constant constant) {
   if (constant.isNull() || !(constant instanceof HotSpotObjectConstant)) {
     return null;
   }
   Object o = HotSpotObjectConstant.asObject(constant);
   return HotSpotResolvedObjectType.fromClass(o.getClass());
 }
Ejemplo n.º 4
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;
 }
Ejemplo n.º 5
0
 public int decodeDebugId(Constant constant) {
   HotSpotVMConfig config = runtime.getConfig();
   return ((~constant.asInt()) >> config.deoptimizationDebugIdShift)
       & intMaskRight(config.deoptimizationDebugIdBits);
 }