use of com.oracle.truffle.espresso.descriptors.Symbol.Type in project graal by oracle.
the class BytecodeNode method popBasicArgumentsWithArray.
// Effort to prevent double copies. Erases sub-word primitive types.
@ExplodeLoop
public static Object[] popBasicArgumentsWithArray(VirtualFrame frame, int top, final Symbol<Type>[] signature, Object[] args, final int argCount, int start) {
// Use basic types
CompilerAsserts.partialEvaluationConstant(argCount);
CompilerAsserts.partialEvaluationConstant(signature);
int argAt = top - 1;
for (int i = argCount - 1; i >= 0; --i) {
Symbol<Type> argType = Signatures.parameterType(signature, i);
if (argType.length() == 1) {
// @formatter:off
switch(argType.byteAt(0)) {
// fall through
case 'Z':
// fall through
case 'B':
// fall through
case 'S':
// fall through
case 'C':
case 'I':
args[i + start] = popInt(frame, argAt);
break;
case 'F':
args[i + start] = popFloat(frame, argAt);
break;
case 'J':
args[i + start] = popLong(frame, argAt);
--argAt;
break;
case 'D':
args[i + start] = popDouble(frame, argAt);
--argAt;
break;
default:
CompilerDirectives.transferToInterpreter();
throw EspressoError.shouldNotReachHere();
}
// @formatter:on
} else {
args[i + start] = popObject(frame, argAt);
}
--argAt;
}
return args;
}
use of com.oracle.truffle.espresso.descriptors.Symbol.Type in project graal by oracle.
the class JniEnv method GetStaticFieldID.
/**
* <h3>jfieldID GetStaticFieldID(JNIEnv *env, jclass clazz, const char *name, const char *sig);
* </h3>
* <p>
* Returns the field ID for a static field of a class. The field is specified by its name and
* signature. The GetStatic<type>Field and SetStatic<type>Field families of accessor functions
* use field IDs to retrieve static fields.
* <p>
* GetStaticFieldID() causes an uninitialized class to be initialized.
*
* @param clazz a Java class object.
* @param namePtr the static field name in a 0-terminated modified UTF-8 string.
* @param typePtr the field signature in a 0-terminated modified UTF-8 string.
* @return a field ID, or NULL if the specified static field cannot be found.
* @throws NoSuchFieldError if the specified static field cannot be found.
* @throws ExceptionInInitializerError if the class initializer fails due to an exception.
* @throws OutOfMemoryError if the system runs out of memory.
*/
@JniImpl
@Handle(Field.class)
public long GetStaticFieldID(@JavaType(Class.class) StaticObject clazz, @Pointer TruffleObject namePtr, @Pointer TruffleObject typePtr) {
String name = NativeUtils.interopPointerToString(namePtr);
String type = NativeUtils.interopPointerToString(typePtr);
assert name != null && type != null;
Field field = null;
Symbol<Name> fieldName = getNames().lookup(name);
if (fieldName != null) {
Symbol<Type> fieldType = getTypes().lookup(type);
if (fieldType != null) {
Klass klass = clazz.getMirrorKlass();
klass.safeInitialize();
// Lookup only if name and type are known symbols.
field = klass.lookupField(fieldName, fieldType, Klass.LookupMode.STATIC_ONLY);
assert field == null || field.getType().equals(fieldType);
}
}
if (field == null || !field.isStatic()) {
Meta meta = getMeta();
throw meta.throwExceptionWithMessage(meta.java_lang_NoSuchFieldError, name);
}
return fieldIds.handlify(field);
}
use of com.oracle.truffle.espresso.descriptors.Symbol.Type in project graal by oracle.
the class ClassRegistry method defineKlass.
@SuppressWarnings("try")
public ObjectKlass defineKlass(Symbol<Type> typeOrNull, final byte[] bytes, ClassDefinitionInfo info) {
Meta meta = getMeta();
ParserKlass parserKlass;
try (DebugCloseable parse = KLASS_PARSE.scope(getContext().getTimers())) {
parserKlass = getParserKlass(bytes, typeOrNull, info);
}
Symbol<Type> type = typeOrNull == null ? parserKlass.getType() : typeOrNull;
if (info.addedToRegistry()) {
Klass maybeLoaded = findLoadedKlass(type);
if (maybeLoaded != null) {
throw meta.throwExceptionWithMessage(meta.java_lang_LinkageError, "Class " + type + " already defined");
}
}
Symbol<Type> superKlassType = parserKlass.getSuperKlass();
ObjectKlass klass = createKlass(meta, parserKlass, type, superKlassType, info);
if (info.addedToRegistry()) {
registerKlass(klass, type);
} else if (info.isStrongHidden()) {
registerStrongHiddenClass(klass);
}
return klass;
}
use of com.oracle.truffle.espresso.descriptors.Symbol.Type in project graal by oracle.
the class MethodVerifier method verifyPutField.
private void verifyPutField(int bci, OperandStack stack, int curOpcode) {
// Check CP validity
PoolConstant pc = poolAt(code.readCPI(bci));
verifyGuarantee(pc.tag() == ConstantPool.Tag.FIELD_REF, "Invalid CP constant for PUTFIELD: " + pc.toString());
pc.validate(pool);
// Obtain field info
FieldRefConstant frc = (FieldRefConstant) pc;
assert Validation.validFieldDescriptor(frc.getType(pool));
Symbol<Type> fieldDesc = frc.getType(pool);
Operand toPut = stack.pop(kindToOperand(fieldDesc));
checkInit(toPut);
if (curOpcode == PUTFIELD) {
// Pop and check verifier
assert Validation.validClassNameEntry(frc.getHolderKlassName(pool));
Symbol<Type> fieldHolderType = getTypes().fromName(frc.getHolderKlassName(pool));
Operand fieldHolder = kindToOperand(fieldHolderType);
Operand receiver = checkInitAccess(stack.popRef(fieldHolder), fieldHolder);
verifyGuarantee(!receiver.isArrayType(), "Trying to access field of an array type: " + receiver);
if (!receiver.isUninitThis()) {
checkProtectedMember(receiver, fieldHolderType, frc, false);
}
}
}
use of com.oracle.truffle.espresso.descriptors.Symbol.Type in project graal by oracle.
the class MethodVerifier method getTypeFromPool.
private Symbol<Type> getTypeFromPool(int c, String s) {
PoolConstant pc = poolAt(c);
verifyGuarantee(pc.tag() == CLASS, s + pc.toString());
pc.validate(pool);
ClassConstant cc = (ClassConstant) pc;
assert Validation.validClassNameEntry(cc.getName(pool));
Symbol<Type> type = getTypes().fromName(cc.getName(pool));
return type;
}
Aggregations