Example #1
0
 /** Symbolically executes the corresponding Java Virtual Machine instruction. */
 public void visitDUP2_X2(DUP2_X2 o) {
   Type t = stack().pop();
   if (t.getSize() == 2) {
     Type u = stack().pop();
     if (u.getSize() == 2) {
       stack().push(t);
       stack().push(u);
       stack().push(t);
     } else {
       Type v = stack().pop();
       stack().push(t);
       stack().push(v);
       stack().push(u);
       stack().push(t);
     }
   } else { // t.getSize() is 1
     Type u = stack().pop();
     Type v = stack().pop();
     if (v.getSize() == 2) {
       stack().push(u);
       stack().push(t);
       stack().push(v);
       stack().push(u);
       stack().push(t);
     } else {
       Type w = stack().pop();
       stack().push(u);
       stack().push(t);
       stack().push(w);
       stack().push(v);
       stack().push(u);
       stack().push(t);
     }
   }
 }
 private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
   Type type = db.lookupType("constantPoolCacheOopDesc");
   constants = new OopField(type.getOopField("_constant_pool"), 0);
   baseOffset = type.getSize();
   Type elType = db.lookupType("ConstantPoolCacheEntry");
   elementSize = elType.getSize();
   length = new CIntField(type.getCIntegerField("_length"), 0);
 }
Example #3
0
 private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
   Type type = db.lookupType("constantPoolOopDesc");
   tags = new OopField(type.getOopField("_tags"), 0);
   cache = new OopField(type.getOopField("_cache"), 0);
   poolHolder = new OopField(type.getOopField("_pool_holder"), 0);
   length = new CIntField(type.getCIntegerField("_length"), 0);
   headerSize = type.getSize();
   elementSize = 0;
 }
  private static synchronized void initialize(TypeDataBase db) {
    Type type = db.lookupType("InterpreterCodelet");

    sizeField = type.getCIntegerField("_size");
    descriptionField = type.getAddressField("_description");
    isSafepointSafeField = type.getJIntField("_is_safepoint_safe");
    bytecodeField = type.getCIntegerField("_bytecode");

    instanceSize = type.getSize();
  }
Example #5
0
  private static void loadExplicitArgumentsOnStack(
      @NotNull Type ownerType,
      boolean isStatic,
      @NotNull JvmMethodSignature signature,
      @NotNull CallGenerator callGenerator) {
    int var = 0;
    if (!isStatic) {
      callGenerator.putValueIfNeeded(ownerType, StackValue.local(var, ownerType));
      var += ownerType.getSize();
    }

    for (JvmMethodParameterSignature parameterSignature : signature.getValueParameters()) {
      if (parameterSignature.getKind() != JvmMethodParameterKind.VALUE) {
        Type type = parameterSignature.getAsmType();
        callGenerator.putValueIfNeeded(type, StackValue.local(var, type));
        var += type.getSize();
      }
    }
  }
Example #6
0
 /** Symbolically executes the corresponding Java Virtual Machine instruction. */
 public void visitDUP2(DUP2 o) {
   Type t = stack().pop();
   if (t.getSize() == 2) {
     stack().push(t);
     stack().push(t);
   } else { // t.getSize() is 1
     Type u = stack().pop();
     stack().push(u);
     stack().push(t);
     stack().push(u);
     stack().push(t);
   }
 }
Example #7
0
  public static void putStackValuesIntoLocals(
      List<Type> directOrder, int shift, InstructionAdapter iv, String descriptor) {
    Type[] actualParams = Type.getArgumentTypes(descriptor);
    assert actualParams.length == directOrder.size()
        : "Number of expected and actual params should be equals!";

    int size = 0;
    for (Type next : directOrder) {
      size += next.getSize();
    }

    shift += size;
    int index = directOrder.size();

    for (Type next : Lists.reverse(directOrder)) {
      shift -= next.getSize();
      Type typeOnStack = actualParams[--index];
      if (!typeOnStack.equals(next)) {
        StackValue.onStack(typeOnStack).put(next, iv);
      }
      iv.store(shift, next);
    }
  }
Example #8
0
 /** Symbolically executes the corresponding Java Virtual Machine instruction. */
 public void visitDUP_X2(DUP_X2 o) {
   Type w1 = stack().pop();
   Type w2 = stack().pop();
   if (w2.getSize() == 2) {
     stack().push(w1);
     stack().push(w2);
     stack().push(w1);
   } else {
     Type w3 = stack().pop();
     stack().push(w1);
     stack().push(w3);
     stack().push(w2);
     stack().push(w1);
   }
 }
Example #9
0
  private static void generateLocalVariableTable(
      @NotNull MethodVisitor mv,
      @NotNull JvmMethodSignature jvmMethodSignature,
      @NotNull FunctionDescriptor functionDescriptor,
      @Nullable Type thisType,
      @NotNull Label methodBegin,
      @NotNull Label methodEnd,
      @NotNull OwnerKind ownerKind) {
    Iterator<ValueParameterDescriptor> valueParameters =
        functionDescriptor.getValueParameters().iterator();
    List<JvmMethodParameterSignature> params = jvmMethodSignature.getValueParameters();
    int shift = 0;

    boolean isStatic = AsmUtil.isStaticMethod(ownerKind, functionDescriptor);
    if (!isStatic) {
      // add this
      if (thisType != null) {
        mv.visitLocalVariable(
            "this", thisType.getDescriptor(), null, methodBegin, methodEnd, shift);
      } else {
        // TODO: provide thisType for callable reference
      }
      shift++;
    }

    for (int i = 0; i < params.size(); i++) {
      JvmMethodParameterSignature param = params.get(i);
      JvmMethodParameterKind kind = param.getKind();
      String parameterName;

      if (kind == JvmMethodParameterKind.VALUE) {
        ValueParameterDescriptor parameter = valueParameters.next();
        parameterName = parameter.getName().asString();
      } else {
        String lowercaseKind = kind.name().toLowerCase();
        parameterName = needIndexForVar(kind) ? "$" + lowercaseKind + "$" + i : "$" + lowercaseKind;
      }

      Type type = param.getAsmType();
      mv.visitLocalVariable(
          parameterName, type.getDescriptor(), null, methodBegin, methodEnd, shift);
      shift += type.getSize();
    }
  }
Example #10
0
  private static void generateDelegateToMethodBody(
      boolean isStatic,
      @NotNull MethodVisitor mv,
      @NotNull Method asmMethod,
      @NotNull String classToDelegateTo) {
    InstructionAdapter iv = new InstructionAdapter(mv);
    Type[] argTypes = asmMethod.getArgumentTypes();

    // The first line of some package file is written to the line number attribute of a static
    // delegate to allow to 'step into' it
    // This is similar to what javac does with bridge methods
    Label label = new Label();
    iv.visitLabel(label);
    iv.visitLineNumber(1, label);

    int k = isStatic ? 0 : 1;
    for (Type argType : argTypes) {
      iv.load(k, argType);
      k += argType.getSize();
    }
    iv.invokestatic(classToDelegateTo, asmMethod.getName(), asmMethod.getDescriptor(), false);
    iv.areturn(asmMethod.getReturnType());
  }
Example #11
0
  private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
    Type type = db.lookupType("methodOopDesc");
    constMethod = new OopField(type.getOopField("_constMethod"), 0);
    constants = new OopField(type.getOopField("_constants"), 0);
    methodSize = new CIntField(type.getCIntegerField("_method_size"), 0);
    maxStack = new CIntField(type.getCIntegerField("_max_stack"), 0);
    maxLocals = new CIntField(type.getCIntegerField("_max_locals"), 0);
    sizeOfParameters = new CIntField(type.getCIntegerField("_size_of_parameters"), 0);
    accessFlags = new CIntField(type.getCIntegerField("_access_flags"), 0);
    code = type.getAddressField("_code");
    vtableIndex = new CIntField(type.getCIntegerField("_vtable_index"), 0);
    if (!VM.getVM().isCore()) {
      invocationCounter = new CIntField(type.getCIntegerField("_invocation_counter"), 0);
    }
    bytecodeOffset = type.getSize();

    /*
    interpreterEntry           = type.getAddressField("_interpreter_entry");
    fromCompiledCodeEntryPoint = type.getAddressField("_from_compiled_code_entry_point");

    */
    objectInitializerName = null;
    classInitializerName = null;
  }
Example #12
0
 private static void initialize(TypeDataBase db) throws WrongTypeException {
   Type type = db.lookupType("arrayOopDesc");
   typeSize = (int) type.getSize();
 }
  private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
    Type type = db.lookupType("instanceKlass");
    arrayKlasses = new OopField(type.getOopField("_array_klasses"), Oop.getHeaderSize());
    methods = new OopField(type.getOopField("_methods"), Oop.getHeaderSize());
    methodOrdering = new OopField(type.getOopField("_method_ordering"), Oop.getHeaderSize());
    localInterfaces = new OopField(type.getOopField("_local_interfaces"), Oop.getHeaderSize());
    transitiveInterfaces =
        new OopField(type.getOopField("_transitive_interfaces"), Oop.getHeaderSize());
    nofImplementors =
        new CIntField(type.getCIntegerField("_nof_implementors"), Oop.getHeaderSize());
    IMPLEMENTORS_LIMIT = db.lookupIntConstant("instanceKlass::implementors_limit").intValue();
    implementors = new OopField[IMPLEMENTORS_LIMIT];
    for (int i = 0; i < IMPLEMENTORS_LIMIT; i++) {
      long arrayOffset = Oop.getHeaderSize() + (i * db.getAddressSize());
      implementors[i] = new OopField(type.getOopField("_implementors[0]"), arrayOffset);
    }
    fields = new OopField(type.getOopField("_fields"), Oop.getHeaderSize());
    constants = new OopField(type.getOopField("_constants"), Oop.getHeaderSize());
    classLoader = new OopField(type.getOopField("_class_loader"), Oop.getHeaderSize());
    protectionDomain = new OopField(type.getOopField("_protection_domain"), Oop.getHeaderSize());
    signers = new OopField(type.getOopField("_signers"), Oop.getHeaderSize());
    sourceFileName = new OopField(type.getOopField("_source_file_name"), Oop.getHeaderSize());
    sourceDebugExtension =
        new OopField(type.getOopField("_source_debug_extension"), Oop.getHeaderSize());
    innerClasses = new OopField(type.getOopField("_inner_classes"), Oop.getHeaderSize());
    nonstaticFieldSize =
        new CIntField(type.getCIntegerField("_nonstatic_field_size"), Oop.getHeaderSize());
    staticFieldSize =
        new CIntField(type.getCIntegerField("_static_field_size"), Oop.getHeaderSize());
    staticOopFieldSize =
        new CIntField(type.getCIntegerField("_static_oop_field_size"), Oop.getHeaderSize());
    nonstaticOopMapSize =
        new CIntField(type.getCIntegerField("_nonstatic_oop_map_size"), Oop.getHeaderSize());
    isMarkedDependent =
        new CIntField(type.getCIntegerField("_is_marked_dependent"), Oop.getHeaderSize());
    initState = new CIntField(type.getCIntegerField("_init_state"), Oop.getHeaderSize());
    vtableLen = new CIntField(type.getCIntegerField("_vtable_len"), Oop.getHeaderSize());
    itableLen = new CIntField(type.getCIntegerField("_itable_len"), Oop.getHeaderSize());
    breakpoints = type.getAddressField("_breakpoints");
    genericSignature = new OopField(type.getOopField("_generic_signature"), Oop.getHeaderSize());
    majorVersion = new CIntField(type.getCIntegerField("_major_version"), Oop.getHeaderSize());
    minorVersion = new CIntField(type.getCIntegerField("_minor_version"), Oop.getHeaderSize());
    headerSize = alignObjectOffset(Oop.getHeaderSize() + type.getSize());

    // read field offset constants
    ACCESS_FLAGS_OFFSET = db.lookupIntConstant("instanceKlass::access_flags_offset").intValue();
    NAME_INDEX_OFFSET = db.lookupIntConstant("instanceKlass::name_index_offset").intValue();
    SIGNATURE_INDEX_OFFSET =
        db.lookupIntConstant("instanceKlass::signature_index_offset").intValue();
    INITVAL_INDEX_OFFSET = db.lookupIntConstant("instanceKlass::initval_index_offset").intValue();
    LOW_OFFSET = db.lookupIntConstant("instanceKlass::low_offset").intValue();
    HIGH_OFFSET = db.lookupIntConstant("instanceKlass::high_offset").intValue();
    GENERIC_SIGNATURE_INDEX_OFFSET =
        db.lookupIntConstant("instanceKlass::generic_signature_offset").intValue();
    NEXT_OFFSET = db.lookupIntConstant("instanceKlass::next_offset").intValue();
    // read ClassState constants
    CLASS_STATE_UNPARSABLE_BY_GC =
        db.lookupIntConstant("instanceKlass::unparsable_by_gc").intValue();
    CLASS_STATE_ALLOCATED = db.lookupIntConstant("instanceKlass::allocated").intValue();
    CLASS_STATE_LOADED = db.lookupIntConstant("instanceKlass::loaded").intValue();
    CLASS_STATE_LINKED = db.lookupIntConstant("instanceKlass::linked").intValue();
    CLASS_STATE_BEING_INITIALIZED =
        db.lookupIntConstant("instanceKlass::being_initialized").intValue();
    CLASS_STATE_FULLY_INITIALIZED =
        db.lookupIntConstant("instanceKlass::fully_initialized").intValue();
    CLASS_STATE_INITIALIZATION_ERROR =
        db.lookupIntConstant("instanceKlass::initialization_error").intValue();
  }
Example #14
0
 /** Symbolically executes the corresponding Java Virtual Machine instruction. */
 public void visitPOP2(POP2 o) {
   Type t = stack().pop();
   if (t.getSize() == 1) {
     stack().pop();
   }
 }