WARNING! Access to this system is limited to authorised users only.
Unauthorised users may be subject to prosecution.
Unauthorised access to this system is a criminal offence under Australian law (Federal Crimes Act 1914 Part VIA)
It is a criminal offence to:
(1) Obtain access to data without authority. -Penalty 2 years imprisonment.
(2) Damage, delete, alter or insert data without authority. -Penalty 10 years imprisonment.
User activity is monitored and recorded. Anyone using this system expressly consents to such monitoring and recording.

Commit c225bf8a authored by Kunshan Wang's avatar Kunshan Wang
Browse files

Loading array supports NULL.

parent 8876d93c
......@@ -46,15 +46,18 @@ classpath.h: classpath.txt
xxd -i classpath.txt > classpath.h
.PHONY: tests
tests: test_client
tests: test_client test_client2
test_client: test_client.c libmurefimpl2start.so
$(CC) `./refimpl2-config --istart --cflags --libs` -o $@ $<
test_client2: test_client2.c libmurefimpl2start.so
$(CC) `./refimpl2-config --istart --cflags --libs` -o $@ $<
.PHONY: clean veryclean
clean:
rm *.so test_client
rm *.so test_client test_client2
veryclean:
rm *.so test_client classpath.txt classpath.h
rm *.so test_client test_client2 classpath.txt classpath.h
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h> // write
#include <refimpl2-start.h>
#include <muapi.h>
const char *hw_string = "Hello world!\n";
const char *hw2_string = "Goodbye world!\n";
const char *gc_conf =
"sosSize=524288\n"
"losSize=524288\n"
"globalSize=1048576\n"
"stackSize=32768\n"
"vmLog=DEBUG\n"
;
int main() {
MuVM *mvm = mu_refimpl2_new_ex(gc_conf);
//MuCtx *ctx = mvm->new_context(mvm);
//mvm->execute(mvm);
mu_refimpl2_close(mvm);
return 0;
}
......@@ -512,6 +512,9 @@ object NativeMuHelpers {
}
def readFromValueFakArray[T <: MuValue](faks: MuValueFakArrayPtr, len: Long): Seq[T] = {
if (faks == 0L) {
Seq()
} else {
for (i <- 0L until len) yield {
val addr = faks + i * WORD_SIZE_BYTES
val valFak = theMemory.getAddress(addr)
......@@ -519,8 +522,12 @@ object NativeMuHelpers {
v.asInstanceOf[T]
}
}
}
def readFromFlagArray(flags: MuValueFakArrayPtr, len: Long): Seq[Flag] = {
if (flags == 0L) {
Seq()
} else {
val flagVals = for (i <- 0L until len) yield {
val addr = flags + i * 32
val flagVal = theMemory.getInt(addr)
......@@ -528,6 +535,7 @@ object NativeMuHelpers {
}
flagVals.map(intToFlag)
}
}
implicit class MuCtxExtras(val ctx: MuCtx) extends AnyVal {
def newConstIntEx(b: MuBundleNode, ty: MuTypeNode, values: LongPtr, nvalues: Int): MuConstNode = {
......@@ -695,12 +703,17 @@ object NativeMuHelpers {
}
object ClientAccessibleClassExposer {
import NativeClientSupport._
logger.debug("Creating mirror...")
// Reflection utils.
val mirror = ru.runtimeMirror(getClass.getClassLoader)
val MAX_NAME_SIZE = 65536
logger.debug("Types for common types...")
// Type objects for common types.
val TUnit = ru.typeTag[Unit].tpe
val TByte = ru.typeTag[Byte].tpe
......@@ -808,6 +821,8 @@ object ClientAccessibleClassExposer {
case t if t <:< TOptMuValue => JType.POINTER
}
logger.debug("Allocating Mu error number memory...")
val MU_NATIVE_ERRNO = 6481626 // muErrno is set to this number if an exception is thrown
val muErrorPtr = jnrMemoryManager.allocateDirect(16)
......@@ -842,6 +857,8 @@ object ClientAccessibleClassExposer {
class ClientAccessibleClassExposer[T: ru.TypeTag: ClassTag](obj: T) {
import ClientAccessibleClassExposer._
logger.debug("Creating closure handles...")
/**
* A list of JFFI closure handles, one for each declared method in obj, in the declared order.
*/
......@@ -1014,7 +1031,9 @@ object NativeClientSupport {
val stringPool = HashMap[String, Pointer]()
// These "exposer" can repeatedly generate function tables.
logger.debug("Creating Mu VM Exposer...")
val muVMExposer = new ClientAccessibleClassExposer(NativeMuVM)
logger.debug("Creating Mu Ctx Exposer...")
val muCtxExposer = new ClientAccessibleClassExposer(NativeMuCtx)
// Expose and unexpose objects
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment