Skip to content
This repository has been archived by the owner on Aug 22, 2019. It is now read-only.

Commit

Permalink
Fix type of vtable in LLVMLangStartInternal and add gate check for Ru…
Browse files Browse the repository at this point in the history
…st 1.27.1.
  • Loading branch information
anatol1234 committed Jul 13, 2018
1 parent b857fca commit 2d847ba
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ matrix:
- libc++1
- libc++-dev
- env: LLVM_VER=3.9 GATE_TAGS='sulongBasic' COMPILE_COMMAND='mx build'
language: rust
rust: 1.27.1
addons:
apt:
sources:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
import com.oracle.truffle.llvm.nodes.intrinsics.rust.LLVMStartFactory.LLVMClosureDispatchNodeGen;
import com.oracle.truffle.llvm.runtime.LLVMFunctionDescriptor;
import com.oracle.truffle.llvm.runtime.datalayout.DataLayout;
import com.oracle.truffle.llvm.runtime.global.LLVMGlobal;
import com.oracle.truffle.llvm.runtime.memory.LLVMMemory;
import com.oracle.truffle.llvm.runtime.memory.LLVMStack.StackPointer;
import com.oracle.truffle.llvm.runtime.nodes.api.LLVMExpressionNode;
Expand All @@ -52,8 +51,11 @@
import com.oracle.truffle.llvm.runtime.pointer.LLVMNativePointer;
import com.oracle.truffle.llvm.runtime.pointer.LLVMPointer;
import com.oracle.truffle.llvm.runtime.types.FunctionType;
import com.oracle.truffle.llvm.runtime.types.PointerType;
import com.oracle.truffle.llvm.runtime.types.PrimitiveType;
import com.oracle.truffle.llvm.runtime.types.StructureType;
import com.oracle.truffle.llvm.runtime.types.Type;
import com.oracle.truffle.llvm.runtime.types.VoidType;

public abstract class LLVMStart extends LLVMIntrinsic {

Expand Down Expand Up @@ -88,19 +90,19 @@ protected long doOp(StackPointer stackPointer, LLVMFunctionDescriptor main, long
public abstract static class LLVMLangStartInternal extends LLVMStart {

@TruffleBoundary
protected LangStartVtableType createLangStartVtable(Type vtableType) {
protected LangStartVtableType createLangStartVtable() {
DataLayout dataSpecConverter = getContextReference().get().getDataSpecConverter();
return LangStartVtableType.create(dataSpecConverter, vtableType);
return LangStartVtableType.create(dataSpecConverter);
}

@Specialization
@SuppressWarnings("unused")
protected long doOp(StackPointer stackPointer, LLVMNativePointer mainPointer, LLVMGlobal vtable, long argc, LLVMPointer argv,
protected long doOp(StackPointer stackPointer, LLVMNativePointer mainPointer, LLVMPointer vtable, long argc, LLVMPointer argv,
@Cached("createToNativeWithTarget()") LLVMToNativeNode toNative,
@Cached("getClosureDispatchNode()") LLVMClosureDispatchNode fnDispatchNode,
@Cached("getClosureDispatchNode()") LLVMClosureDispatchNode dropInPlaceDispatchNode) {
LLVMMemory memory = getLLVMMemory();
LangStartVtableType langStartVtable = createLangStartVtable(vtable.getPointeeType());
LangStartVtableType langStartVtable = createLangStartVtable();
LLVMNativePointer vtablePointer = toNative.executeWithTarget(vtable);
LLVMNativePointer fn = readFn(memory, vtablePointer, langStartVtable);
LLVMNativePointer dropInPlace = readDropInPlace(memory, vtablePointer, langStartVtable);
Expand Down Expand Up @@ -138,8 +140,13 @@ long readDropInPlace(LLVMMemory memory, long address) {
return memory.getFunctionPointer(LLVMNativePointer.create(address));
}

static LangStartVtableType create(DataLayout datalayout, Type vtableType) {
return new LangStartVtableType(datalayout, (StructureType) vtableType);
static LangStartVtableType create(DataLayout datalayout) {
FunctionType dropInPlace = new FunctionType(VoidType.INSTANCE, new Type[]{new PointerType(PointerType.I8)}, false);
FunctionType langStartClosure = new FunctionType(PrimitiveType.I32, new Type[]{new PointerType(PointerType.I8)}, false);
FunctionType fn = new FunctionType(PrimitiveType.I32, new Type[]{PointerType.I8}, false);
StructureType type = new StructureType(false, new Type[]{new PointerType(dropInPlace), PrimitiveType.I64, PrimitiveType.I64, new PointerType(langStartClosure),
new PointerType(langStartClosure), new PointerType(fn)});
return new LangStartVtableType(datalayout, type);
}

}
Expand Down

0 comments on commit 2d847ba

Please sign in to comment.