use of com.oracle.truffle.espresso.descriptors.Symbol.Name in project graal by oracle.
the class VM method defineJavaBaseModule.
@SuppressWarnings("try")
public void defineJavaBaseModule(StaticObject module, String[] packages, SubstitutionProfiler profiler) {
Meta meta = getMeta();
StaticObject loader = meta.java_lang_Module_loader.getObject(module);
if (!StaticObject.isNull(loader)) {
profiler.profile(10);
throw meta.throwExceptionWithMessage(meta.java_lang_IllegalArgumentException, "Class loader must be the bootclass loader");
}
PackageTable pkgTable = getRegistries().getBootClassRegistry().packages();
ModuleEntry javaBaseEntry = getRegistries().getJavaBaseModule();
try (EntryTable.BlockLock block = pkgTable.write()) {
if (getRegistries().javaBaseDefined()) {
profiler.profile(9);
throw meta.throwException(meta.java_lang_InternalError);
}
for (String pkg : packages) {
Symbol<Name> pkgName = getNames().getOrCreate(pkg);
if (pkgTable.lookup(pkgName) == null) {
pkgTable.createAndAddEntry(pkgName, javaBaseEntry);
}
}
javaBaseEntry.setModule(module);
meta.HIDDEN_MODULE_ENTRY.setHiddenObject(module, javaBaseEntry);
getRegistries().processFixupList(module);
}
}
use of com.oracle.truffle.espresso.descriptors.Symbol.Name in project graal by oracle.
the class VM method JVM_GetSimpleBinaryName.
@VmImpl(isJni = true)
@JavaType(String.class)
public StaticObject JVM_GetSimpleBinaryName(@JavaType(Class.class) StaticObject self) {
Klass k = self.getMirrorKlass();
if (k.isPrimitive() || k.isArray()) {
return StaticObject.NULL;
}
ObjectKlass klass = (ObjectKlass) k;
RuntimeConstantPool pool = klass.getConstantPool();
InnerClassesAttribute inner = klass.getInnerClasses();
for (InnerClassesAttribute.Entry entry : inner.entries()) {
int innerClassIndex = entry.innerClassIndex;
if (innerClassIndex != 0) {
if (pool.classAt(innerClassIndex).getName(pool) == klass.getName()) {
if (pool.resolvedKlassAt(k, innerClassIndex) == k) {
if (entry.innerNameIndex != 0) {
Symbol<Name> innerName = pool.symbolAt(entry.innerNameIndex);
return getMeta().toGuestString(innerName);
} else {
break;
}
}
}
}
}
return StaticObject.NULL;
}
use of com.oracle.truffle.espresso.descriptors.Symbol.Name in project graal by oracle.
the class MethodVerifier method verifyInvokeDynamic.
private void verifyInvokeDynamic(int bci, OperandStack stack) {
// Check padding
verifyGuarantee(code.readByte(bci + 2) == 0 && code.readByte(bci + 3) == 0, "bytes 3 and 4 after invokedynamic must be 0.");
PoolConstant pc = poolAt(code.readCPI(bci));
// Check CP validity
verifyGuarantee(pc.tag() == ConstantPool.Tag.INVOKEDYNAMIC, "Invalid CP constant for INVOKEDYNAMIC: " + pc.toString());
pc.validate(pool);
InvokeDynamicConstant idc = (InvokeDynamicConstant) pc;
Symbol<Name> name = idc.getName(pool);
// Check invokedynamic does not call initializers
verifyGuarantee(!isInstanceInit(name) && !isClassInit(name), "Invalid bootstrap method name: " + name);
// Check and pop arguments
Operand[] parsedSig = getOperandSig(idc.getSignature(pool));
assert parsedSig.length > 0 : "Empty descriptor for method";
for (int i = parsedSig.length - 2; i >= 0; i--) {
stack.pop(parsedSig[i]);
}
// push result
Operand returnKind = parsedSig[parsedSig.length - 1];
if (returnKind != Void) {
stack.push(returnKind);
}
}
use of com.oracle.truffle.espresso.descriptors.Symbol.Name in project graal by oracle.
the class MethodVerifier method verifyInvokeInterface.
private void verifyInvokeInterface(int bci, OperandStack stack) {
// Check padding.
verifyGuarantee(code.readUByte(bci + 4) == 0, "4th byte after INVOKEINTERFACE must be 0.");
// Check CP validity
MethodRefConstant mrc = getMethodRefConstant(bci);
// Checks versioning
Symbol<Name> calledMethodName = mrc.getName(pool);
// Check guest is not invoking <clinit>
verifyGuarantee(!isClassInit(calledMethodName), "Invocation of class initializer!");
// Only INVOKESPECIAL can call <init>
verifyGuarantee(!isInstanceInit(calledMethodName), "Invocation of instance initializer with opcode other than INVOKESPECIAL");
Symbol<Signature> calledMethodSignature = mrc.getSignature(pool);
Operand[] parsedSig = getOperandSig(calledMethodSignature);
// Check signature is well formed.
assert parsedSig.length > 0 : "Method ref with no return value !";
// Pop arguments
// Check signature conforms with count argument
int count = code.readUByte(bci + 3);
verifyGuarantee(count > 0, "Invalid count argument for INVOKEINTERFACE: " + count);
// Has a receiver.
int descCount = 1;
for (int i = parsedSig.length - 2; i >= 0; i--) {
descCount++;
if (isType2(parsedSig[i])) {
descCount++;
}
stack.pop(parsedSig[i]);
}
verifyGuarantee(count == descCount, "Inconsistent redundant argument count for INVOKEINTERFACE.");
assert Validation.validClassNameEntry(mrc.getHolderKlassName(pool));
Symbol<Type> methodHolder = getTypes().fromName(mrc.getHolderKlassName(pool));
Operand methodHolderOp = kindToOperand(methodHolder);
checkInit(stack.popRef(methodHolderOp));
Operand returnOp = parsedSig[parsedSig.length - 1];
if (!(returnOp == Void)) {
stack.push(returnOp);
}
}
use of com.oracle.truffle.espresso.descriptors.Symbol.Name in project graal by oracle.
the class VM method fillInElement.
private void fillInElement(@JavaType(StackTraceElement.class) StaticObject ste, VM.StackElement element, Method classGetName) {
Method m = element.getMethod();
Klass k = m.getDeclaringKlass();
StaticObject guestClass = k.mirror();
StaticObject loader = k.getDefiningClassLoader();
ModuleEntry module = k.module();
// Fill in class name
getMeta().java_lang_StackTraceElement_declaringClass.setObject(ste, classGetName.invokeDirect(guestClass));
getMeta().java_lang_StackTraceElement_declaringClassObject.setObject(ste, guestClass);
// Fill in loader name
if (!StaticObject.isNull(loader)) {
StaticObject loaderName = getMeta().java_lang_ClassLoader_name.getObject(loader);
if (!StaticObject.isNull(loader)) {
getMeta().java_lang_StackTraceElement_classLoaderName.setObject(ste, loaderName);
}
}
// Fill in method name
Symbol<Name> mname = m.getName();
getMeta().java_lang_StackTraceElement_methodName.setObject(ste, getMeta().toGuestString(mname));
// Fill in module
if (module.isNamed()) {
getMeta().java_lang_StackTraceElement_moduleName.setObject(ste, getMeta().toGuestString(module.getName()));
// TODO: module version
}
// Fill in source information
getMeta().java_lang_StackTraceElement_fileName.setObject(ste, getMeta().toGuestString(m.getSourceFile()));
getMeta().java_lang_StackTraceElement_lineNumber.setInt(ste, m.bciToLineNumber(element.getBCI()));
}
Aggregations