[vmkit-commits] [vmkit] r138266 - in /vmkit/trunk: lib/J3/Compiler/JavaJITCompiler.cpp lib/J3/VMCore/Jnjvm.cpp lib/Mvm/MMTk/MvmGC.cpp lib/Mvm/MMTk/MvmGC.h mmtk/java/src/org/j3/bindings/Bindings.java mmtk/java/src/org/j3/options/OptionSet.java mmtk/magic/LowerJavaRT.cpp mmtk/mmtk-alloc/Selected.cpp mmtk/mmtk-j3/MMTkObject.h mmtk/mmtk-j3/RuntimeHelpers.cpp mmtk/mmtk-j3/VM.cpp tools/j3/Main.cpp tools/precompiler/Precompiler.cpp tools/vmjc/vmjc.cpp
Nicolas Geoffray
nicolas.geoffray at lip6.fr
Mon Aug 22 13:09:06 PDT 2011
Author: geoffray
Date: Mon Aug 22 15:09:06 2011
New Revision: 138266
URL: http://llvm.org/viewvc/llvm-project?rev=138266&view=rev
Log:
Parse command line flags for gc.
Modified:
vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp
vmkit/trunk/lib/J3/VMCore/Jnjvm.cpp
vmkit/trunk/lib/Mvm/MMTk/MvmGC.cpp
vmkit/trunk/lib/Mvm/MMTk/MvmGC.h
vmkit/trunk/mmtk/java/src/org/j3/bindings/Bindings.java
vmkit/trunk/mmtk/java/src/org/j3/options/OptionSet.java
vmkit/trunk/mmtk/magic/LowerJavaRT.cpp
vmkit/trunk/mmtk/mmtk-alloc/Selected.cpp
vmkit/trunk/mmtk/mmtk-j3/MMTkObject.h
vmkit/trunk/mmtk/mmtk-j3/RuntimeHelpers.cpp
vmkit/trunk/mmtk/mmtk-j3/VM.cpp
vmkit/trunk/tools/j3/Main.cpp
vmkit/trunk/tools/precompiler/Precompiler.cpp
vmkit/trunk/tools/vmjc/vmjc.cpp
Modified: vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp?rev=138266&r1=138265&r2=138266&view=diff
==============================================================================
--- vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp (original)
+++ vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp Mon Aug 22 15:09:06 2011
@@ -345,7 +345,7 @@
llvm::llvm_shutdown_obj X;
mvm::MvmModule::initialise();
- mvm::Collector::initialise();
+ mvm::Collector::initialise(argc, argv);
mvm::ThreadAllocator allocator;
char** newArgv = (char**)allocator.Allocate((argc + 1) * sizeof(char*));
Modified: vmkit/trunk/lib/J3/VMCore/Jnjvm.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/VMCore/Jnjvm.cpp?rev=138266&r1=138265&r2=138266&view=diff
==============================================================================
--- vmkit/trunk/lib/J3/VMCore/Jnjvm.cpp (original)
+++ vmkit/trunk/lib/J3/VMCore/Jnjvm.cpp Mon Aug 22 15:09:06 2011
@@ -1423,7 +1423,7 @@
// Helper function to run J3 without JIT.
extern "C" int StartJnjvmWithoutJIT(int argc, char** argv, char* mainClass) {
- mvm::Collector::initialise();
+ mvm::Collector::initialise(argc, argv);
mvm::ThreadAllocator allocator;
char** newArgv = (char**)allocator.Allocate((argc + 1) * sizeof(char*));
Modified: vmkit/trunk/lib/Mvm/MMTk/MvmGC.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/MMTk/MvmGC.cpp?rev=138266&r1=138265&r2=138266&view=diff
==============================================================================
--- vmkit/trunk/lib/Mvm/MMTk/MvmGC.cpp (original)
+++ vmkit/trunk/lib/Mvm/MMTk/MvmGC.cpp Mon Aug 22 15:09:06 2011
@@ -143,7 +143,7 @@
// Do nothing.
}
-void Collector::initialise() {
+void Collector::initialise(int argc, char** argv) {
}
bool Collector::needsWriteBarrier() {
Modified: vmkit/trunk/lib/Mvm/MMTk/MvmGC.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/MMTk/MvmGC.h?rev=138266&r1=138265&r2=138266&view=diff
==============================================================================
--- vmkit/trunk/lib/Mvm/MMTk/MvmGC.h (original)
+++ vmkit/trunk/lib/Mvm/MMTk/MvmGC.h Mon Aug 22 15:09:06 2011
@@ -84,7 +84,7 @@
static void collect();
- static void initialise();
+ static void initialise(int argc, char** argv);
static int getMaxMemory() {
return 0;
Modified: vmkit/trunk/mmtk/java/src/org/j3/bindings/Bindings.java
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/mmtk/java/src/org/j3/bindings/Bindings.java?rev=138266&r1=138265&r2=138266&view=diff
==============================================================================
--- vmkit/trunk/mmtk/java/src/org/j3/bindings/Bindings.java (original)
+++ vmkit/trunk/mmtk/java/src/org/j3/bindings/Bindings.java Mon Aug 22 15:09:06 2011
@@ -10,6 +10,7 @@
package org.j3.bindings;
import org.j3.config.Selected;
+import org.j3.options.OptionSet;
import org.mmtk.plan.MutatorContext;
import org.mmtk.plan.Plan;
import org.mmtk.plan.TraceLocal;
@@ -25,6 +26,17 @@
import org.vmmagic.unboxed.Extent;
import org.vmmagic.unboxed.ObjectReference;
+import org.vmutil.options.AddressOption;
+import org.vmutil.options.BooleanOption;
+import org.vmutil.options.EnumOption;
+import org.vmutil.options.FloatOption;
+import org.vmutil.options.IntOption;
+import org.vmutil.options.MicrosecondsOption;
+import org.vmutil.options.Option;
+import org.vmutil.options.PagesOption;
+import org.vmutil.options.StringOption;
+
+
public final class Bindings {
@Inline
private static Address gcmalloc(int size, ObjectReference virtualTable) {
@@ -94,7 +106,10 @@
}
@Inline
- private static void boot(Extent minSize, Extent maxSize) {
+ private static void boot(Extent minSize, Extent maxSize, String[] arguments) {
+ if (arguments != null) {
+ OptionSet.parseOptions(arguments);
+ }
HeapGrowthManager.boot(minSize, maxSize);
Plan plan = Selected.Plan.get();
plan.boot();
Modified: vmkit/trunk/mmtk/java/src/org/j3/options/OptionSet.java
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/mmtk/java/src/org/j3/options/OptionSet.java?rev=138266&r1=138265&r2=138266&view=diff
==============================================================================
--- vmkit/trunk/mmtk/java/src/org/j3/options/OptionSet.java (original)
+++ vmkit/trunk/mmtk/java/src/org/j3/options/OptionSet.java Mon Aug 22 15:09:06 2011
@@ -124,7 +124,10 @@
* @param message The message associated with the warning.
*/
protected void warn(Option o, String message) {
- VM.sysWriteln("WARNING: Option '" + o.getKey() + "' : " + message);
+ VM.sysWrite("WARNING: Option '");
+ VM.sysWrite(o.getKey());
+ VM.sysWrite("' : ");
+ VM.sysWriteln(message);
}
/**
@@ -135,7 +138,11 @@
* @param message The error message associated with the failure.
*/
protected void fail(Option o, String message) {
- VM.sysFail("ERROR: Option '" + o.getKey() + "' : " + message);
+ VM.sysWrite("Error: Option '");
+ VM.sysWrite(o.getKey());
+ VM.sysWrite("' : ");
+ VM.sysWriteln(message);
+ VM.sysFail("");
}
/**
@@ -158,4 +165,325 @@
protected Extent pagesToBytes(int pages) {
return Word.fromIntZeroExtend(pages).lsh(Constants.LOG_BYTES_IN_PAGE).toExtent();
}
+
+ public static void parseOptions(String[] args) {
+ for (int i = 0; i < args.length; i++) {
+ gc.parseOption(args[i]);
+ }
+ }
+
+ private boolean parseOption(String arg) {
+ // First handle the "option commands"
+ if (arg.equals("help")) {
+ printHelp();
+ return true;
+ }
+ if (arg.equals("printOptions")) {
+ printOptions();
+ return true;
+ }
+ if (arg.length() == 0) {
+ printHelp();
+ return true;
+ }
+
+ // Required format of arg is 'name=value'
+ // Split into 'name' and 'value' strings
+ int split = arg.indexOf('=');
+ if (split == -1) {
+ VM.sysWrite("Illegal option specification: ");
+ VM.sysWrite(arg);
+ VM.sysWriteln(". Must be specified as a name-value pair in the form of option=value");
+ return false;
+ }
+
+ String name = arg.substring(0, split);
+ String value = arg.substring(split + 1);
+
+ Option o = getOption(name);
+
+ if (o == null) return false;
+
+ switch (o.getType()) {
+ case Option.BOOLEAN_OPTION:
+ if (value.equals("true")) {
+ ((BooleanOption) o).setValue(true);
+ return true;
+ } else if (value.equals("false")) {
+ ((BooleanOption) o).setValue(false);
+ return true;
+ }
+ return false;
+
+ case Option.INT_OPTION: {
+ int ival = parseInt(value, (IntOption) o);
+ ((IntOption) o).setValue(ival);
+ return true;
+ }
+ case Option.ADDRESS_OPTION: {
+ int ival = parseInt(value, null);
+ if (ival != 0) {
+ ((AddressOption) o).setValue(ival);
+ } else {
+ VM.sysWrite("Invalid value for ");
+ VM.sysWriteln(o.getName());
+ }
+ return true;
+ }
+ case Option.FLOAT_OPTION: {
+ float fval = parseFloat(value, (FloatOption) o);
+ ((FloatOption) o).setValue(fval);
+ return true;
+ }
+ case Option.STRING_OPTION:
+ ((StringOption) o).setValue(value);
+ return true;
+
+ case Option.ENUM_OPTION:
+ ((EnumOption) o).setValue(value);
+ return true;
+
+ case Option.PAGES_OPTION:
+ long pval = parseMemorySize(o.getName(), name, "b", 1, arg, value);
+ if (pval < 0) return false;
+ ((PagesOption) o).setBytes(Extent.fromIntSignExtend((int)pval));
+ return true;
+
+ case Option.MICROSECONDS_OPTION:
+ int mval = parseInt(value, null);
+ ((MicrosecondsOption) o).setMicroseconds(mval);
+ return true;
+ }
+
+ // None of the above tests matched, so this wasn't an option
+ return false;
+ }
+
+ private static int parseNumber(String arg, int base, int start, int end) {
+ int value = 0;
+ for (int i = start; i < end; i++) {
+ value = value * base;
+ char c = arg.charAt(i);
+ switch (c) {
+ case '0': break;
+ case '1': value += 1; break;
+ case '2': value += 2; break;
+ case '3': value += 3; break;
+ case '4': value += 4; break;
+ case '5': value += 5; break;
+ case '6': value += 6; break;
+ case '7': value += 7; break;
+ case '8': value += 8; break;
+ case '9': value += 9; break;
+ default:
+ return -1;
+ }
+ }
+ return value;
+ }
+
+ private static int parseInt(String arg, IntOption option) {
+ int base = 10;
+ int i = 0;
+ boolean isNegative = false;
+ if (arg.charAt(0) == '-') {
+ i++;
+ isNegative = true;
+ } else if (arg.length() > 1 && arg.charAt(0) == '0' && arg.charAt(1) == 'x') {
+ i += 2;
+ base = 16;
+ }
+ int value = parseNumber(arg, base, i, arg.length());
+ if (value == -1) {
+ if (option != null) {
+ VM.sysWrite("Invalid value for ");
+ VM.sysWriteln(option.getName());
+ return option.getValue();
+ } else {
+ return 0;
+ }
+ }
+ return isNegative ? -value : value;
+ }
+
+ private static float parseFloat(String arg, FloatOption option) {
+ boolean isNegative = false;
+ int start = 0;
+ if (arg.charAt(0) == '-') {
+ start++;
+ isNegative = true;
+ }
+ int dot = arg.indexOf('.');
+ if (dot == -1) {
+ int value = parseNumber(arg, 10, start, arg.length());
+ if (value == -1) {
+ VM.sysWrite("Invalid value for ");
+ VM.sysWriteln(option.getName());
+ return option.getValue();
+ }
+ return (float) (isNegative ? -value : value);
+ } else {
+ int value = parseNumber(arg, 10, start, dot);
+ if (value == -1) {
+ VM.sysWrite("Invalid value for ");
+ VM.sysWriteln(option.getName());
+ return option.getValue();
+ }
+ int intDecimal = parseNumber(arg, 10, dot + 1, arg.length());
+ if (intDecimal == -1) {
+ VM.sysWrite("Invalid value for ");
+ VM.sysWriteln(option.getName());
+ return option.getValue();
+ }
+ double divide = 1;
+ for (int i = 1; i < arg.length() - dot; i++) {
+ divide *= 10;
+ }
+ double decimal = ((double) intDecimal) / divide;
+ return (float)(decimal + value);
+ }
+ }
+
+ private static long parseMemorySize(String sizeName,
+ String sizeFlag,
+ String defaultFactor,
+ int roundTo,
+ String fullArg,
+ String subArg) {
+ return 0L;
+ }
+
+
+ private void printHelp() {
+ VM.sysWriteln("Commands");
+ VM.sysWrite(prefix);
+ VM.sysWriteln("[:help]\t\t\tPrint brief description of arguments");
+ VM.sysWrite(prefix);
+ VM.sysWriteln(":printOptions\t\tPrint the current values of options");
+ VM.sysWriteln();
+
+ //Begin generated help messages
+ VM.sysWrite("Boolean Options (");
+ VM.sysWrite(prefix);
+ VM.sysWrite(":<option>=true or ");
+ VM.sysWrite(prefix);
+ VM.sysWriteln(":<option>=false)");
+ VM.sysWriteln("Option Description");
+
+ Option o = getFirst();
+ while (o != null) {
+ if (o.getType() == Option.BOOLEAN_OPTION) {
+ String key = o.getKey();
+ VM.sysWrite(key);
+ for (int c = key.length(); c < 39;c++) {
+ VM.sysWrite(" ");
+ }
+ VM.sysWriteln(o.getDescription());
+ }
+ o = o.getNext();
+ }
+
+ VM.sysWrite("\nValue Options (");
+ VM.sysWrite(prefix);
+ VM.sysWriteln(":<option>=<value>)");
+ VM.sysWriteln("Option Type Description");
+
+ o = getFirst();
+ while (o != null) {
+ if (o.getType() != Option.BOOLEAN_OPTION &&
+ o.getType() != Option.ENUM_OPTION) {
+ String key = o.getKey();
+ VM.sysWrite(key);
+ for (int c = key.length(); c < 31;c++) {
+ VM.sysWrite(" ");
+ }
+ switch (o.getType()) {
+ case Option.INT_OPTION: VM.sysWrite("int "); break;
+ case Option.ADDRESS_OPTION: VM.sysWrite("address "); break;
+ case Option.FLOAT_OPTION: VM.sysWrite("float "); break;
+ case Option.MICROSECONDS_OPTION: VM.sysWrite("usec "); break;
+ case Option.PAGES_OPTION: VM.sysWrite("bytes "); break;
+ case Option.STRING_OPTION: VM.sysWrite("string "); break;
+ }
+ VM.sysWriteln(o.getDescription());
+ }
+ o = o.getNext();
+ }
+
+ VM.sysWriteln("\nSelection Options (set option to one of an enumeration of possible values)");
+
+ o = getFirst();
+ while (o != null) {
+ if (o.getType() == Option.ENUM_OPTION) {
+ String key = o.getKey();
+ VM.sysWrite(key);
+ for (int c = key.length(); c < 31; c++) {
+ VM.sysWrite(" ");
+ }
+ VM.sysWriteln(o.getDescription());
+ VM.sysWrite(" { ");
+ boolean first = true;
+ for (String val : ((EnumOption)o).getValues()) {
+ VM.sysWrite(first ? "" : ", ");
+ VM.sysWrite(val);
+ first = false;
+ }
+ VM.sysWriteln(" }");
+ }
+ o = o.getNext();
+ }
+ }
+
+ private void printOptions() {
+ VM.sysWriteln("Current value of GC options");
+
+ Option o = getFirst();
+ while (o != null) {
+ if (o.getType() == Option.BOOLEAN_OPTION) {
+ String key = o.getKey();
+ VM.sysWrite("\t");
+ VM.sysWrite(key);
+ for (int c = key.length(); c < 31; c++) {
+ VM.sysWrite(" ");
+ }
+ VM.sysWrite(" = ");
+ logValue(o, false);
+ VM.sysWriteln();
+ }
+ o = o.getNext();
+ }
+
+ o = getFirst();
+ while (o != null) {
+ if (o.getType() != Option.BOOLEAN_OPTION &&
+ o.getType() != Option.ENUM_OPTION) {
+ String key = o.getKey();
+ VM.sysWrite("\t");
+ VM.sysWrite(key);
+ for (int c = key.length(); c < 31; c++) {
+ VM.sysWrite(" ");
+ }
+ VM.sysWrite(" = ");
+ logValue(o, false);
+ VM.sysWriteln();
+ }
+ o = o.getNext();
+ }
+
+ o = getFirst();
+ while (o != null) {
+ if (o.getType() == Option.ENUM_OPTION) {
+ String key = o.getKey();
+ VM.sysWrite("\t");
+ VM.sysWrite(key);
+ for (int c = key.length(); c < 31; c++) {
+ VM.sysWrite(" ");
+ }
+ VM.sysWrite(" = ");
+ logValue(o, false);
+ VM.sysWriteln();
+ }
+ o = o.getNext();
+ }
+ }
}
Modified: vmkit/trunk/mmtk/magic/LowerJavaRT.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/mmtk/magic/LowerJavaRT.cpp?rev=138266&r1=138265&r2=138266&view=diff
==============================================================================
--- vmkit/trunk/mmtk/magic/LowerJavaRT.cpp (original)
+++ vmkit/trunk/mmtk/magic/LowerJavaRT.cpp Mon Aug 22 15:09:06 2011
@@ -55,6 +55,36 @@
F = Function::Create(GV.getFunctionType(),
GlobalValue::ExternalLinkage, "MMTkGetClass", &M);
GV.replaceAllUsesWith(F);
+ } else if (!strcmp(GV.getName().data(), "JnJVM_java_lang_String_equals__Ljava_lang_Object_2")) {
+ Function* F = M.getFunction("MMTkStringEquals");
+ if (!F)
+ F = Function::Create(GV.getFunctionType(),
+ GlobalValue::ExternalLinkage, "MMTkStringEquals", &M);
+ GV.replaceAllUsesWith(F);
+ } else if (!strcmp(GV.getName().data(), "JnJVM_java_lang_String_length__")) {
+ Function* F = M.getFunction("MMTkStringLength");
+ if (!F)
+ F = Function::Create(GV.getFunctionType(),
+ GlobalValue::ExternalLinkage, "MMTkStringLength", &M);
+ GV.replaceAllUsesWith(F);
+ } else if (!strcmp(GV.getName().data(), "JnJVM_java_lang_String_indexOf__I")) {
+ Function* F = M.getFunction("MMTkStringIndexOf");
+ if (!F)
+ F = Function::Create(GV.getFunctionType(),
+ GlobalValue::ExternalLinkage, "MMTkStringIndexOf", &M);
+ GV.replaceAllUsesWith(F);
+ } else if (!strcmp(GV.getName().data(), "JnJVM_java_lang_String_substring__II")) {
+ Function* F = M.getFunction("MMTkStringSubstringII");
+ if (!F)
+ F = Function::Create(GV.getFunctionType(),
+ GlobalValue::ExternalLinkage, "MMTkStringSubstringII", &M);
+ GV.replaceAllUsesWith(F);
+ } else if (!strcmp(GV.getName().data(), "JnJVM_java_lang_String_substring__I")) {
+ Function* F = M.getFunction("MMTkStringSubstringI");
+ if (!F)
+ F = Function::Create(GV.getFunctionType(),
+ GlobalValue::ExternalLinkage, "MMTkStringSubstringI", &M);
+ GV.replaceAllUsesWith(F);
} else {
GV.replaceAllUsesWith(Constant::getNullValue(GV.getType()));
}
Modified: vmkit/trunk/mmtk/mmtk-alloc/Selected.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/mmtk/mmtk-alloc/Selected.cpp?rev=138266&r1=138265&r2=138266&view=diff
==============================================================================
--- vmkit/trunk/mmtk/mmtk-alloc/Selected.cpp (original)
+++ vmkit/trunk/mmtk/mmtk-alloc/Selected.cpp Mon Aug 22 15:09:06 2011
@@ -9,6 +9,7 @@
#include "MutatorThread.h"
#include "MvmGC.h"
+#include "../mmtk-j3/MMTkObject.h"
#include "mvm/VirtualMachine.h"
@@ -24,7 +25,7 @@
extern "C" intptr_t JnJVM_org_j3_bindings_Bindings_allocateMutator__I(int32_t) ALWAYS_INLINE;
extern "C" void JnJVM_org_j3_bindings_Bindings_freeMutator__Lorg_mmtk_plan_MutatorContext_2(intptr_t) ALWAYS_INLINE;
-extern "C" void JnJVM_org_j3_bindings_Bindings_boot__Lorg_vmmagic_unboxed_Extent_2Lorg_vmmagic_unboxed_Extent_2(intptr_t, intptr_t) ALWAYS_INLINE;
+extern "C" void JnJVM_org_j3_bindings_Bindings_boot__Lorg_vmmagic_unboxed_Extent_2Lorg_vmmagic_unboxed_Extent_2_3Ljava_lang_String_2(intptr_t, intptr_t, mmtk::MMTkObjectArray*) ALWAYS_INLINE;
extern "C" void JnJVM_org_j3_bindings_Bindings_processEdge__Lorg_mmtk_plan_TransitiveClosure_2Lorg_vmmagic_unboxed_ObjectReference_2Lorg_vmmagic_unboxed_Address_2(
uintptr_t closure, void* source, void* slot) ALWAYS_INLINE;
@@ -156,8 +157,52 @@
Java_org_j3_mmtk_Collection_triggerCollection__I(NULL, 2);
}
-void Collector::initialise() {
- JnJVM_org_j3_bindings_Bindings_boot__Lorg_vmmagic_unboxed_Extent_2Lorg_vmmagic_unboxed_Extent_2(20 * 1024 * 1024, 100 * 1024 * 1024);
+int argc;
+char** argv;
+
+void Collector::initialise(int argc, char** argv) {
+ static const char* kPrefix = "-X:gc:";
+ static const int kPrefixLength = strlen(kPrefix);
+
+ int i = 1;
+ int count = 0;
+ ThreadAllocator allocator;
+ mmtk::MMTkObjectArray* arguments = NULL;
+ while (i < argc && argv[i][0] == '-') {
+ if (!strncmp(argv[i], kPrefix, kPrefixLength)) {
+ count++;
+ }
+ i++;
+ }
+
+ if (count > 0) {
+ arguments = reinterpret_cast<mmtk::MMTkObjectArray*>(
+ malloc(sizeof(mmtk::MMTkObjectArray) + count * sizeof(mmtk::MMTkString*)));
+ arguments->size = count;
+ i = 1;
+ int arrayIndex = 0;
+ while (i < argc && argv[i][0] == '-') {
+ if (!strncmp(argv[i], kPrefix, kPrefixLength)) {
+ int size = strlen(argv[i]) - kPrefixLength;
+ mmtk::MMTkArray* array = reinterpret_cast<mmtk::MMTkArray*>(
+ allocator.Allocate(sizeof(mmtk::MMTkArray) + size * sizeof(uint16_t)));
+ array->size = size;
+ for (uint32_t j = 0; j < array->size; j++) {
+ array->elements[j] = argv[i][j + kPrefixLength];
+ }
+ mmtk::MMTkString* str = reinterpret_cast<mmtk::MMTkString*>(
+ allocator.Allocate(sizeof(mmtk::MMTkString)));
+ str->value = array;
+ str->count = array->size;
+ str->offset = 0;
+ arguments->elements[arrayIndex++] = str;
+ }
+ i++;
+ }
+ assert(arrayIndex == count);
+ }
+
+ JnJVM_org_j3_bindings_Bindings_boot__Lorg_vmmagic_unboxed_Extent_2Lorg_vmmagic_unboxed_Extent_2_3Ljava_lang_String_2(20 * 1024 * 1024, 100 * 1024 * 1024, arguments);
}
extern "C" void* MMTkMutatorAllocate(uint32_t size, VirtualTable* VT) {
Modified: vmkit/trunk/mmtk/mmtk-j3/MMTkObject.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/mmtk/mmtk-j3/MMTkObject.h?rev=138266&r1=138265&r2=138266&view=diff
==============================================================================
--- vmkit/trunk/mmtk/mmtk-j3/MMTkObject.h (original)
+++ vmkit/trunk/mmtk/mmtk-j3/MMTkObject.h Mon Aug 22 15:09:06 2011
@@ -36,6 +36,11 @@
uint16_t elements[1];
};
+struct MMTkObjectArray : public MMTkObject {
+ uintptr_t size;
+ MMTkObject* elements[1];
+};
+
struct MMTkString : public MMTkObject {
MMTkArray* value;
int32_t count;
Modified: vmkit/trunk/mmtk/mmtk-j3/RuntimeHelpers.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/mmtk/mmtk-j3/RuntimeHelpers.cpp?rev=138266&r1=138265&r2=138266&view=diff
==============================================================================
--- vmkit/trunk/mmtk/mmtk-j3/RuntimeHelpers.cpp (original)
+++ vmkit/trunk/mmtk/mmtk-j3/RuntimeHelpers.cpp Mon Aug 22 15:09:06 2011
@@ -12,11 +12,49 @@
namespace mmtk {
extern "C" uint16_t MMTkCharAt(MMTkString* str, uint32_t index) {
- return str->value->elements[index];
+ return str->value->elements[index + str->offset];
}
extern "C" MMTkObject* MMTkGetClass(MMTkObject* obj) {
return obj->virtualTable->cl->delegatee;
}
+extern "C" uint8_t MMTkStringEquals(MMTkString* first, MMTkString* second) {
+ if (first->count != second->count) return 0;
+ for (int i = 0; i < first->count; i++) {
+ if (first->value->elements[i + first->offset]
+ != second->value->elements[i + second->offset]) {
+ return 0;
+ }
+ }
+ return 1;
+}
+
+extern "C" int32_t MMTkStringLength(MMTkString* obj) {
+ return obj->count;
+}
+
+extern "C" int32_t MMTkStringIndexOf(MMTkString* obj, uint16_t c) {
+ for (int i = 0; i < obj->count; i++) {
+ if (obj->value->elements[i + obj->offset] == c) return i;
+ }
+ return -1;
+}
+
+extern "C" MMTkString* MMTkStringSubstringII(MMTkString* obj, int32_t start, int32_t end) {
+ MMTkString* str = new MMTkString();
+ str->value = obj->value;
+ str->count = end - start;
+ str->offset = start + obj->offset;
+ return str;
+}
+
+extern "C" MMTkString* MMTkStringSubstringI(MMTkString* obj, int32_t start) {
+ MMTkString* str = new MMTkString();
+ str->value = obj->value;
+ str->count = obj->count - start;
+ str->offset = start + obj->offset;
+ return str;
+}
+
}
Modified: vmkit/trunk/mmtk/mmtk-j3/VM.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/mmtk/mmtk-j3/VM.cpp?rev=138266&r1=138265&r2=138266&view=diff
==============================================================================
--- vmkit/trunk/mmtk/mmtk-j3/VM.cpp (original)
+++ vmkit/trunk/mmtk/mmtk-j3/VM.cpp Mon Aug 22 15:09:06 2011
@@ -12,13 +12,38 @@
namespace mmtk {
-extern "C" void Java_org_j3_runtime_VM_sysWrite__Lorg_vmmagic_unboxed_Extent_2 (uintptr_t e) { UNIMPLEMENTED(); }
-extern "C" void Java_org_j3_runtime_VM_sysWrite__Lorg_vmmagic_unboxed_Address_2 (uintptr_t a) { UNIMPLEMENTED(); }
-extern "C" void Java_org_j3_runtime_VM_sysWrite__F (float f) { UNIMPLEMENTED(); }
-extern "C" void Java_org_j3_runtime_VM_sysWrite__I (int i) { UNIMPLEMENTED(); }
-extern "C" void Java_org_j3_runtime_VM_sysWrite__Ljava_lang_String_2 (MMTkString* msg) { UNIMPLEMENTED(); }
-extern "C" void Java_org_j3_runtime_VM_sysWriteln__ () { UNIMPLEMENTED(); }
-extern "C" void Java_org_j3_runtime_VM_sysWriteln__Ljava_lang_String_2 (MMTkString* msg) { UNIMPLEMENTED(); }
+extern "C" void Java_org_j3_runtime_VM_sysWrite__Lorg_vmmagic_unboxed_Extent_2 (void* e) {
+ fprintf(stderr, "%p", e);
+}
+
+extern "C" void Java_org_j3_runtime_VM_sysWrite__Lorg_vmmagic_unboxed_Address_2 (void* a) {
+ fprintf(stderr, "%p", a);
+}
+
+extern "C" void Java_org_j3_runtime_VM_sysWrite__F (float f) {
+ fprintf(stderr, "%f", f);
+}
+
+extern "C" void Java_org_j3_runtime_VM_sysWrite__I (int i) {
+ fprintf(stderr, "%d", i);
+}
+
+extern "C" void Java_org_j3_runtime_VM_sysWrite__Ljava_lang_String_2 (MMTkString* msg) {
+ for (int i = 0; i < msg->count; i++) {
+ fprintf(stderr, "%c", msg->value->elements[i + msg->offset]);
+ }
+}
+
+extern "C" void Java_org_j3_runtime_VM_sysWriteln__Ljava_lang_String_2 (MMTkString* msg) {
+ for (int i = 0; i < msg->count; i++) {
+ fprintf(stderr, "%c", msg->value->elements[i + msg->offset]);
+ }
+ fprintf(stderr, "\n");
+}
+
+extern "C" void Java_org_j3_runtime_VM_sysWriteln__ () {
+ fprintf(stderr, "\n");
+}
extern "C" void Java_org_j3_runtime_VM__1assert__ZLjava_lang_String_2 (bool cond, MMTkString* msg) {
ABORT();
Modified: vmkit/trunk/tools/j3/Main.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/tools/j3/Main.cpp?rev=138266&r1=138265&r2=138266&view=diff
==============================================================================
--- vmkit/trunk/tools/j3/Main.cpp (original)
+++ vmkit/trunk/tools/j3/Main.cpp Mon Aug 22 15:09:06 2011
@@ -37,7 +37,7 @@
// Initialize base components.
MvmModule::initialise();
- Collector::initialise();
+ Collector::initialise(argc, argv);
// Tell the compiler to run all optimizations.
StandardCompileOpts = true;
Modified: vmkit/trunk/tools/precompiler/Precompiler.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/tools/precompiler/Precompiler.cpp?rev=138266&r1=138265&r2=138266&view=diff
==============================================================================
--- vmkit/trunk/tools/precompiler/Precompiler.cpp (original)
+++ vmkit/trunk/tools/precompiler/Precompiler.cpp Mon Aug 22 15:09:06 2011
@@ -65,7 +65,7 @@
// Initialize base components.
MvmModule::initialise();
- Collector::initialise();
+ Collector::initialise(argc, argv);
// Tell the compiler to run all optimizations.
StandardCompileOpts = true;
Modified: vmkit/trunk/tools/vmjc/vmjc.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/tools/vmjc/vmjc.cpp?rev=138266&r1=138265&r2=138266&view=diff
==============================================================================
--- vmkit/trunk/tools/vmjc/vmjc.cpp (original)
+++ vmkit/trunk/tools/vmjc/vmjc.cpp Mon Aug 22 15:09:06 2011
@@ -122,11 +122,10 @@
}
mvm::MvmModule::initialise();
+ mvm::Collector::initialise(argc, argv);
JavaAOTCompiler* Comp = new JavaAOTCompiler("AOT");
- mvm::Collector::initialise();
-
mvm::BumpPtrAllocator allocator;
JnjvmBootstrapLoader* loader = new(allocator, "Bootstrap loader")
JnjvmBootstrapLoader(allocator, Comp, false);
More information about the vmkit-commits
mailing list