use of com.oracle.svm.core.c.CGlobalDataImpl in project graal by oracle.
the class CGlobalDataFeature method registerInvocationPlugins.
@Override
public void registerInvocationPlugins(Providers providers, SnippetReflectionProvider snippetReflection, InvocationPlugins invocationPlugins, boolean hosted) {
Registration r = new Registration(invocationPlugins, CGlobalData.class);
r.register1("get", Receiver.class, new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) {
VMError.guarantee(receiver.get().isConstant(), "Accessed CGlobalData is not a compile-time constant: " + b.getMethod().asStackTraceElement(b.bci()));
CGlobalDataImpl<?> data = (CGlobalDataImpl<?>) SubstrateObjectConstant.asObject(receiver.get().asConstant());
CGlobalDataInfo info = CGlobalDataFeature.this.map.get(data);
b.addPush(targetMethod.getSignature().getReturnKind(), new CGlobalDataLoadAddressNode(info));
return true;
}
});
}
use of com.oracle.svm.core.c.CGlobalDataImpl in project graal by oracle.
the class CGlobalDataFeature method layout.
private void layout() {
assert !isLayouted() : "Already layouted";
final int wordSize = ConfigurationValues.getTarget().wordSize;
int offset = 0;
for (Entry<CGlobalDataImpl<?>, CGlobalDataInfo> entry : map.entrySet()) {
CGlobalDataImpl<?> data = entry.getKey();
CGlobalDataInfo info = entry.getValue();
int size;
byte[] bytes = null;
if (data.bytesSupplier != null) {
bytes = data.bytesSupplier.get();
size = bytes.length;
} else {
if (data.sizeSupplier != null) {
size = data.sizeSupplier.getAsInt();
} else {
assert data.symbolName != null : "CGlobalData without bytes, size, or referenced symbol";
/*
* A symbol reference: we support only instruction-pointer-relative addressing
* with 32-bit immediates, which might not be sufficient for the target symbol's
* address. Therefore, reserve space for a word with the symbol's true address.
*/
size = wordSize;
}
}
info.assign(offset, bytes);
offset += size;
// align
offset = (offset + (wordSize - 1)) & ~(wordSize - 1);
}
totalSize = offset;
assert isLayouted();
}
Aggregations