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

Commit

Permalink
Resolve merge conflict.
Browse files Browse the repository at this point in the history
  • Loading branch information
anatol1234 committed Jul 13, 2018
2 parents ca34e1a + 189d300 commit b857fca
Show file tree
Hide file tree
Showing 37 changed files with 1,508 additions and 1,007 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ mx.sulong/eclipse-launches/**
mx.sulong/libs/*.ll
mx.sulong/libs/*.bc
mx.sulong/*.iml
mx.sulong/.project
mx.sulong/.pydevproject
.DS_Store
build.xml
workingsets.xml
Expand All @@ -29,6 +31,9 @@ projects/*/\bin
projects/*/\.checkstyle
projects/*/*.iml
projects/*/\.factorypath
projects/SULONG.dist/
projects/SULONG_LAUNCHER.dist/
projects/SULONG_TEST.dist/

cache/**
projects/com.oracle.truffle.llvm.bench/languagegame/**
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ Set `JAVA_HOME` to point to the extracted labsjdk from above:
Sulong partially consists of C/C++ code that is compiled using `make`. To speed
up the build process you can edit the `MAKEFLAGS` environment variable:

echo MAKEFLAGS=-j9 > sulong/mx.sulong/env
echo MAKEFLAGS=-j9 >> sulong/mx.sulong/env

Finally, build the project:

Expand Down
2 changes: 1 addition & 1 deletion ci.hocon
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
overlay = 28a74bfc8ad6d6a7cffc2b7835f6cc27cd03993a
overlay = 285c321ec6602bca64076afe572c7b116977c01b

java8: {name: labsjdk, version: "8u172-jvmci-0.46", platformspecific: true}
eclipse: {name: eclipse, version: "4.5.2", platformspecific: true}
Expand Down
99 changes: 57 additions & 42 deletions mx.sulong/mx_sulong.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@
# re-export SulongTestSuite class so it can be used from suite.py
from mx_testsuites import SulongTestSuite #pylint: disable=unused-import

os.environ["LC_NUMERIC"] = "C" # required for some testcases

_suite = mx.suite('sulong')
_mx = join(_suite.dir, "mx.sulong")
_root = join(_suite.dir, "projects")
Expand Down Expand Up @@ -132,47 +130,64 @@ def getUnittestLibraryDependencies(libs_files_path):
libs += l.readline().split()
return [mx_subst.path_substitutions.substitute(lib) for lib in libs]

class TemporaryEnv(object):
def __init__(self, key, value):
self.key = key
self.value = value
self.old_value = None

def __enter__(self):
self.old_value = os.environ.get(self.key)
os.environ[self.key] = self.value

def __exit__(self, ex_type, value, traceback):
if self.old_value is None:
del os.environ[self.key]
else:
os.environ[self.key] = self.old_value

def _sulong_gate_runner(args, tasks):
with Task('CheckCopyright', tasks, tags=['style']) as t:
if t:
if mx.checkcopyrights(['--primary']) != 0:
t.abort('Copyright errors found. Please run "mx checkcopyrights --primary -- --fix" to fix them.')
with Task('ClangFormat', tasks, tags=['style', 'clangformat']) as t:
if t: clangformatcheck()
with Task('Rustfmt', tasks, tags=['style', 'rustfmt']) as t:
if t: rustfmtcheck()
with Task('TestBenchmarks', tasks, tags=['benchmarks', 'sulongMisc']) as t:
if t: mx_testsuites.runSuite('shootout')
with Task('TestTypes', tasks, tags=['type', 'sulongMisc']) as t:
if t: mx_testsuites.runSuite('type')
with Task('TestPipe', tasks, tags=['pipe', 'sulongMisc']) as t:
if t: mx_testsuites.runSuite('pipe')
with Task('TestLLVM', tasks, tags=['llvm']) as t:
if t: mx_testsuites.runSuite('llvm')
with Task('TestNWCC', tasks, tags=['nwcc']) as t:
if t: mx_testsuites.runSuite('nwcc')
with Task('TestGCCParserTorture', tasks, tags=['parser']) as t:
if t: mx_testsuites.runSuite('parserTorture')
with Task('TestGCC_C', tasks, tags=['gcc_c']) as t:
if t: mx_testsuites.runSuite('gcc_c')
with Task('TestGCC_CPP', tasks, tags=['gcc_cpp']) as t:
if t: mx_testsuites.runSuite('gcc_cpp')
with Task('TestGCC_Fortran', tasks, tags=['gcc_fortran']) as t:
if t: mx_testsuites.runSuite('gcc_fortran')
with Task("TestSulong", tasks, tags=['sulong', 'sulongBasic']) as t:
if t: mx_unittest.unittest(['SulongSuite'])
with Task("TestInterop", tasks, tags=['interop', 'sulongBasic']) as t:
if t: mx_unittest.unittest(['com.oracle.truffle.llvm.test.interop'])
with Task("TestDebug", tasks, tags=['debug', 'sulongBasic']) as t:
if t: mx_unittest.unittest(['LLVMDebugTest'])
with Task('TestAssembly', tasks, tags=['assembly', 'sulongMisc']) as t:
if t: mx_testsuites.runSuite('assembly')
with Task('TestArgs', tasks, tags=['args', 'sulongMisc']) as t:
if t: mx_testsuites.runSuite('args')
with Task('TestCallback', tasks, tags=['callback', 'sulongMisc']) as t:
if t: mx_testsuites.runSuite('callback')
with Task('TestVarargs', tasks, tags=['vaargs', 'sulongMisc']) as t:
if t: mx_testsuites.runSuite('vaargs')
with TemporaryEnv('LC_ALL', 'C'):
with Task('CheckCopyright', tasks, tags=['style']) as t:
if t:
if mx.checkcopyrights(['--primary']) != 0:
t.abort('Copyright errors found. Please run "mx checkcopyrights --primary -- --fix" to fix them.')
with Task('ClangFormat', tasks, tags=['style', 'clangformat']) as t:
if t: clangformatcheck()
with Task('Rustfmt', tasks, tags=['style', 'rustfmt']) as t:
if t: rustfmtcheck()
with Task('TestBenchmarks', tasks, tags=['benchmarks', 'sulongMisc']) as t:
if t: mx_testsuites.runSuite('shootout')
with Task('TestTypes', tasks, tags=['type', 'sulongMisc']) as t:
if t: mx_testsuites.runSuite('type')
with Task('TestPipe', tasks, tags=['pipe', 'sulongMisc']) as t:
if t: mx_testsuites.runSuite('pipe')
with Task('TestLLVM', tasks, tags=['llvm']) as t:
if t: mx_testsuites.runSuite('llvm')
with Task('TestNWCC', tasks, tags=['nwcc']) as t:
if t: mx_testsuites.runSuite('nwcc')
with Task('TestGCCParserTorture', tasks, tags=['parser']) as t:
if t: mx_testsuites.runSuite('parserTorture')
with Task('TestGCC_C', tasks, tags=['gcc_c']) as t:
if t: mx_testsuites.runSuite('gcc_c')
with Task('TestGCC_CPP', tasks, tags=['gcc_cpp']) as t:
if t: mx_testsuites.runSuite('gcc_cpp')
with Task('TestGCC_Fortran', tasks, tags=['gcc_fortran']) as t:
if t: mx_testsuites.runSuite('gcc_fortran')
with Task("TestSulong", tasks, tags=['sulong', 'sulongBasic']) as t:
if t: mx_unittest.unittest(['SulongSuite'])
with Task("TestInterop", tasks, tags=['interop', 'sulongBasic']) as t:
if t: mx_unittest.unittest(['com.oracle.truffle.llvm.test.interop'])
with Task("TestDebug", tasks, tags=['debug', 'sulongBasic']) as t:
if t: mx_unittest.unittest(['LLVMDebugTest'])
with Task('TestAssembly', tasks, tags=['assembly', 'sulongMisc']) as t:
if t: mx_testsuites.runSuite('assembly')
with Task('TestArgs', tasks, tags=['args', 'sulongMisc']) as t:
if t: mx_testsuites.runSuite('args')
with Task('TestCallback', tasks, tags=['callback', 'sulongMisc']) as t:
if t: mx_testsuites.runSuite('callback')
with Task('TestVarargs', tasks, tags=['vaargs', 'sulongMisc']) as t:
if t: mx_testsuites.runSuite('vaargs')

add_gate_runner(_suite, _sulong_gate_runner)

Expand Down
2 changes: 1 addition & 1 deletion mx.sulong/suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
{
"name" : "truffle",
"subdir" : True,
"version" : "a2267424f072edbef5916cd519a08a0514658bdd",
"version" : "dc37c9a244fc97a92b7b37f716e484cb4b7ee5ed",
"urls" : [
{"url" : "https://github.com/graalvm/graal", "kind" : "git"},
{"url" : "https://curio.ssw.jku.at/nexus/content/repositories/snapshots", "kind" : "binary"},
Expand Down
11 changes: 7 additions & 4 deletions projects/com.oracle.truffle.llvm.libraries.bitcode/src/crt0.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#else
#define AT_NULL 0
#define AT_PLATFORM 15
#define AT_RANDOM 25
#define AT_EXECFN 31
typedef struct {
uint64_t a_type;
Expand Down Expand Up @@ -76,10 +77,10 @@ void __sulong_init_libc(char **envp, char *pn) {
// nothing to do
}

void __sulong_init_context(void **argv_java_byte_arrays, void **envp_java_byte_arrays) {
void __sulong_init_context(void **argv_java_byte_arrays, void **envp_java_byte_arrays, void **random_java_byte_array) {
int argc = polyglot_get_array_size(argv_java_byte_arrays);
int envc = polyglot_get_array_size(envp_java_byte_arrays);
int auxc = 3;
int auxc = 4;

size_t total_argument_size = sizeof(void *) + (argc + 1) * sizeof(char *) + (envc + 1) * sizeof(char *) + auxc * sizeof(Elf64_auxv_t);
long *p = __sulong_start_arguments = malloc(total_argument_size);
Expand All @@ -98,8 +99,10 @@ void __sulong_init_context(void **argv_java_byte_arrays, void **envp_java_byte_a
aux[0].a_un.a_val = (uint64_t)argv[0];
aux[1].a_type = AT_PLATFORM;
aux[1].a_un.a_val = (uint64_t) "x86_64";
aux[2].a_type = AT_NULL;
aux[2].a_un.a_val = 0;
aux[2].a_type = AT_RANDOM;
aux[2].a_un.a_val = (uint64_t)__sulong_byte_array_to_native(random_java_byte_array);
aux[3].a_type = AT_NULL;
aux[3].a_un.a_val = 0;

__sulong_init_libc(envp, argv[0]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,68 +29,62 @@
*/
package com.oracle.truffle.llvm.nodes.asm.syscall;

import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.api.dsl.Cached;
import static com.oracle.truffle.llvm.nodes.asm.syscall.LLVMAMD64Time.CLOCK_MONOTONIC;
import static com.oracle.truffle.llvm.nodes.asm.syscall.LLVMAMD64Time.CLOCK_REALTIME;

import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.llvm.runtime.memory.LLVMMemory;
import com.oracle.truffle.llvm.nodes.memory.store.LLVMI64StoreNode;
import com.oracle.truffle.llvm.nodes.memory.store.LLVMI64StoreNodeGen;
import com.oracle.truffle.llvm.runtime.memory.LLVMSyscallOperationNode;
import com.oracle.truffle.llvm.runtime.pointer.LLVMNativePointer;

import static com.oracle.truffle.llvm.nodes.asm.syscall.LLVMAMD64Time.CLOCK_MONOTONIC;
import static com.oracle.truffle.llvm.nodes.asm.syscall.LLVMAMD64Time.CLOCK_REALTIME;
import com.oracle.truffle.llvm.runtime.pointer.LLVMPointer;

public abstract class LLVMAMD64SyscallClockGetTimeNode extends LLVMSyscallOperationNode {

@Child private LLVMI64StoreNode writeI64;

public LLVMAMD64SyscallClockGetTimeNode() {
this.writeI64 = LLVMI64StoreNodeGen.create(null, null);
}

@Override
public final String getName() {
return "clock_gettime";
}

@Specialization
protected long doI64(long clkId, LLVMNativePointer tp,
@Cached("getLLVMMemory()") LLVMMemory memory) {
return clockGetTime(memory, (int) clkId, tp);
protected long doI64(long clkId, LLVMPointer tp) {
return clockGetTime((int) clkId, tp);
}

@Specialization
protected long doI64(long clkId, long tp,
@Cached("getLLVMMemory()") LLVMMemory memory) {
return doI64(clkId, LLVMNativePointer.create(tp), memory);
}

@TruffleBoundary
private static long currentTimeMillis() {
return System.currentTimeMillis();
}

@TruffleBoundary
private static long nanoTime() {
return System.nanoTime();
protected long doI64(long clkId, long tp) {
return doI64(clkId, LLVMNativePointer.create(tp));
}

private static int clockGetTime(LLVMMemory memory, int clkId, LLVMNativePointer timespec) {
private int clockGetTime(int clkId, LLVMPointer timespec) {
long s;
long ns;
switch (clkId) {
case CLOCK_REALTIME: {
long t = currentTimeMillis();
long t = System.currentTimeMillis();
s = t / 1000;
ns = (t % 1000) * 1000000;
break;
}
case CLOCK_MONOTONIC: {
long t = nanoTime();
long t = System.nanoTime();
s = t / 1000000000L;
ns = (t % 1000000000L);
break;
}
default:
return -LLVMAMD64Error.EINVAL;
}
LLVMNativePointer ptr = timespec;
memory.putI64(ptr, s);
LLVMPointer ptr = timespec;
writeI64.executeWithTarget(ptr, s);
ptr = ptr.increment(8);
memory.putI64(ptr, ns);
writeI64.executeWithTarget(ptr, ns);
return 0;
}
}
Loading

0 comments on commit b857fca

Please sign in to comment.