use of com.oracle.truffle.espresso.runtime.StaticObject in project graal by oracle.
the class Management method GetMemoryUsage.
@ManagementImpl
@JavaType(Object.class)
public StaticObject GetMemoryUsage(@SuppressWarnings("unused") boolean heap) {
Method init = getMeta().java_lang_management_MemoryUsage.lookupDeclaredMethod(Symbol.Name._init_, getSignatures().makeRaw(Symbol.Type._void, Symbol.Type._long, Symbol.Type._long, Symbol.Type._long, Symbol.Type._long));
StaticObject instance = getMeta().java_lang_management_MemoryUsage.allocateInstance();
init.invokeDirect(instance, 0L, 0L, 0L, 0L);
return instance;
}
use of com.oracle.truffle.espresso.runtime.StaticObject in project graal by oracle.
the class VM method JVM_ClassLoaderDepth.
@VmImpl(isJni = true)
public int JVM_ClassLoaderDepth() {
PrivilegedStack stack = getPrivilegedStack();
Integer res = Truffle.getRuntime().iterateFrames(new FrameInstanceVisitor<Integer>() {
int depth = 0;
@Override
public Integer visitFrame(FrameInstance frameInstance) {
Method m = getMethodFromFrame(frameInstance);
if (m != null) {
if (isTrustedFrame(frameInstance, stack)) {
return -1;
}
if (!m.isNative()) {
ObjectKlass klass = m.getDeclaringKlass();
StaticObject loader = klass.getDefiningClassLoader();
if (StaticObject.notNull(loader) && !isTrustedLoader(loader)) {
return depth;
}
depth++;
}
}
return null;
}
});
return res == null ? -1 : res;
}
use of com.oracle.truffle.espresso.runtime.StaticObject in project graal by oracle.
the class VM method JVM_DefineModule.
@VmImpl(isJni = true)
@TruffleBoundary
public void JVM_DefineModule(@JavaType(internalName = "Ljava/lang/Module;") StaticObject module, boolean is_open, @SuppressWarnings("unused") @JavaType(String.class) StaticObject version, @SuppressWarnings("unused") @JavaType(String.class) StaticObject location, @Pointer TruffleObject pkgs, int num_package, @Inject Meta meta, @Inject SubstitutionProfiler profiler) {
if (StaticObject.isNull(module)) {
profiler.profile(0);
throw meta.throwNullPointerException();
}
if (num_package < 0) {
profiler.profile(1);
throw meta.throwExceptionWithMessage(meta.java_lang_IllegalArgumentException, "num_package must be >= 0");
}
if (getUncached().isNull(pkgs) && num_package > 0) {
profiler.profile(2);
throw meta.throwExceptionWithMessage(meta.java_lang_IllegalArgumentException, "num_packages must be 0 if packages is null");
}
if (!meta.java_lang_Module.isAssignableFrom(module.getKlass())) {
profiler.profile(3);
throw meta.throwExceptionWithMessage(meta.java_lang_IllegalArgumentException, "module is not an instance of java.lang.Module");
}
StaticObject guestName = meta.java_lang_Module_name.getObject(module);
if (StaticObject.isNull(guestName)) {
profiler.profile(4);
throw meta.throwExceptionWithMessage(meta.java_lang_IllegalArgumentException, "modue name cannot be null");
}
String hostName = meta.toHostString(guestName);
if (hostName.equals(JAVA_BASE)) {
profiler.profile(5);
defineJavaBaseModule(module, extractNativePackages(pkgs, num_package, profiler), profiler);
return;
}
profiler.profile(6);
defineModule(module, hostName, is_open, extractNativePackages(pkgs, num_package, profiler), profiler);
}
use of com.oracle.truffle.espresso.runtime.StaticObject in project graal by oracle.
the class VM method getGuestReflectiveMethodRoot.
// endregion stack inspection
// region annotations
@JavaType(java.lang.reflect.Method.class)
private static StaticObject getGuestReflectiveMethodRoot(@JavaType(java.lang.reflect.Method.class) StaticObject seed, Meta meta) {
assert InterpreterToVM.instanceOf(seed, meta.java_lang_reflect_Method);
StaticObject curMethod = seed;
Method target = null;
while (target == null) {
target = (Method) meta.HIDDEN_METHOD_KEY.getHiddenObject(curMethod);
if (target == null) {
curMethod = meta.java_lang_reflect_Method_root.getObject(curMethod);
}
}
return curMethod;
}
use of com.oracle.truffle.espresso.runtime.StaticObject in project graal by oracle.
the class VM method getACCUntil11.
private StaticObject getACCUntil11() {
ArrayList<StaticObject> domains = new ArrayList<>();
final PrivilegedStack stack = getPrivilegedStack();
final boolean[] isPrivileged = new boolean[] { false };
StaticObject context = Truffle.getRuntime().iterateFrames(new FrameInstanceVisitor<StaticObject>() {
StaticObject prevDomain = StaticObject.NULL;
@Override
public StaticObject visitFrame(FrameInstance frameInstance) {
Method m = getMethodFromFrame(frameInstance);
if (m != null) {
if (stack.compare(frameInstance)) {
isPrivileged[0] = true;
}
StaticObject domain = JVM_GetProtectionDomain(m.getDeclaringKlass().mirror());
if (domain != prevDomain && domain != StaticObject.NULL) {
domains.add(domain);
prevDomain = domain;
}
if (isPrivileged[0]) {
return stack.peekContext();
}
}
return null;
}
});
return getAccFromContext(domains, isPrivileged[0], context);
}
Aggregations