Merge branch 'master' into gnu

Conflicts:

	src/compile.cpp
This commit is contained in:
Joel Dice 2009-07-11 12:11:59 -06:00
commit e72ff8db0b
10 changed files with 106 additions and 28 deletions

View File

@ -7,7 +7,7 @@
There is NO WARRANTY for this software. See license.txt for
details. */
#include "math.h"
#include "stdlib.h"
#include "sys/time.h"
@ -32,11 +32,13 @@
# define SO_PREFIX ""
#else
# define SO_PREFIX "lib"
#include "sys/utsname.h"
#include "sys/wait.h"
#endif
#ifdef __APPLE__
# define SO_SUFFIX ".jnilib"
#include <CoreServices/CoreServices.h>
#elif defined WIN32
# define SO_SUFFIX ".dll"
#else
@ -349,6 +351,14 @@ Java_java_lang_System_getProperty(JNIEnv* e, jclass, jstring name,
r = e->NewStringUTF("\\");
} else if (strcmp(chars, "os.name") == 0) {
r = e->NewStringUTF("Windows");
} else if (strcmp(chars, "os.version") == 0) {
unsigned size = 32;
char buffer[size];
OSVERSIONINFO OSversion;
OSversion.dwOSVersionInfoSize=sizeof(OSVERSIONINFO);
::GetVersionEx(&OSversion);
snprintf(buffer, size, "%i.%i", (int)OSversion.dwMajorVersion, (int)OSversion.dwMinorVersion);
r = e->NewStringUTF(buffer);
} else if (strcmp(chars, "java.io.tmpdir") == 0) {
TCHAR buffer[MAX_PATH];
GetTempPath(MAX_PATH, buffer);
@ -367,11 +377,27 @@ Java_java_lang_System_getProperty(JNIEnv* e, jclass, jstring name,
r = e->NewStringUTF("Mac OS X");
#else
r = e->NewStringUTF("Linux");
#endif
} else if (strcmp(chars, "os.version") == 0) {
#ifdef __APPLE__
unsigned size = 32;
char buffer[size];
long minorVersion, majorVersion;
Gestalt(gestaltSystemVersionMajor, &majorVersion);
Gestalt(gestaltSystemVersionMinor, &minorVersion);
snprintf(buffer, size, "%ld.%ld", majorVersion, minorVersion);
r = e->NewStringUTF(buffer);
#else
struct utsname system_id;
uname(&system_id);
r = e->NewStringUTF(system_id.release);
#endif
} else if (strcmp(chars, "java.io.tmpdir") == 0) {
r = e->NewStringUTF("/tmp");
} else if (strcmp(chars, "user.home") == 0) {
r = e->NewStringUTF(getenv("HOME"));
r = e->NewStringUTF(getenv("HOME"));
}
#endif

View File

@ -97,10 +97,6 @@ public class LinkedList<T> implements List<T> {
return find(element) != null;
}
public void addAll(Collection<T> c) {
for (T t: c) add(t);
}
public boolean add(T element) {
addLast(element);
return true;

View File

@ -147,7 +147,7 @@ endif
ifeq ($(platform),darwin)
build-cflags = $(common-cflags) -fPIC -fvisibility=hidden -I$(src)
lflags = $(common-lflags) -ldl -framework CoreFoundation
lflags = $(common-lflags) -ldl -framework CoreFoundation -framework CoreServices
ifeq ($(bootimage),true)
bootimage-lflags = -Wl,-segprot,__BOOT,rwx,rwx
endif

View File

@ -27,6 +27,8 @@ search(Thread* t, object name, object (*op)(Thread*, object),
bool replaceDots)
{
if (LIKELY(name)) {
PROTECT(t, name);
object n = makeByteArray(t, stringLength(t, name) + 1);
char* s = reinterpret_cast<char*>(&byteArrayBody(t, n, 0));
stringChars(t, name, s);

View File

@ -271,7 +271,7 @@ class MyStackWalker: public Processor::StackWalker {
virtual void walk(Processor::StackVisitor* v) {
for (MyStackWalker it(this); it.valid();) {
MyStackWalker walker(it);
MyStackWalker walker(&it);
if (not v->visit(&walker)) {
break;
}
@ -618,6 +618,7 @@ enum Event {
IpEvent,
MarkEvent,
ClearEvent,
InitEvent,
TraceEvent,
PushSubroutineEvent,
PopSubroutineEvent
@ -4239,24 +4240,25 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip,
}
}
FILE* compileLog = 0;
void
logCompile(MyThread* t, const void* code, unsigned size, const char* class_,
const char* name, const char* spec)
{
static FILE* log = 0;
static bool open = false;
if (not open) {
open = true;
const char* path = findProperty(t, "avian.jit.log");
if (path) {
log = fopen(path, "wb");
compileLog = fopen(path, "wb");
} else if (DebugCompile) {
log = stderr;
compileLog = stderr;
}
}
if (log) {
fprintf(log, "%p %p %s.%s%s\n",
if (compileLog) {
fprintf(compileLog, "%p %p %s.%s%s\n",
code, static_cast<const uint8_t*>(code) + size,
class_, name, spec);
}
@ -4446,6 +4448,14 @@ calculateFrameMaps(MyThread* t, Context* context, uintptr_t* originalRoots,
clearBit(roots, i);
} break;
case InitEvent: {
unsigned reference = context->eventLog.get2(eventIndex);
eventIndex += 2;
uintptr_t* tableRoots = context->rootTable + (reference * mapSize);
memcpy(roots, tableRoots, mapSize * BytesPerWord);
} break;
case TraceEvent: {
TraceElement* te; context->eventLog.get(eventIndex, &te, BytesPerWord);
if (DebugFrameMaps) {
@ -4992,16 +5002,8 @@ compile(MyThread* t, Allocator* allocator, Context* context)
uint8_t stackMap[codeMaxStack(t, methodCode(t, context->method))];
Frame frame2(&frame, stackMap);
uintptr_t* roots = context->rootTable
+ (start * frameMapSizeInWords(t, context->method));
for (unsigned i = 0; i < localSize(t, context->method); ++ i) {
if (getBit(roots, i)) {
frame2.set(i, Frame::Object);
} else {
frame2.set(i, Frame::Integer);
}
}
context->eventLog.append(InitEvent);
context->eventLog.append2(start);
for (unsigned i = 1;
i < codeMaxStack(t, methodCode(t, context->method));
@ -6202,6 +6204,11 @@ class SegFaultHandler: public System::SignalHandler {
return true;
}
}
if (compileLog) {
fflush(compileLog);
}
return false;
}

View File

@ -2591,7 +2591,7 @@ unreachable(Event* event)
for (Link* p = event->predecessors; p; p = p->nextPredecessor) {
if (not p->predecessor->allExits()) return false;
}
return true;
return event->predecessors != 0;
}
class ReturnEvent: public Event {

View File

@ -34,6 +34,12 @@ const bool Verbose2 = false;
const bool Debug = false;
const bool DebugFixies = false;
#ifdef NDEBUG
const bool DebugAllocation = false;
#else
const bool DebugAllocation = true;
#endif
#define ACQUIRE(x) MutexLock MAKE_NAME(monitorLock_) (x)
class MutexLock {
@ -422,7 +428,9 @@ class Segment {
}
void dispose() {
free(context, data, (footprint(capacity())) * BytesPerWord);
if (data) {
free(context, data, (footprint(capacity())) * BytesPerWord);
}
data = 0;
map = 0;
}
@ -1673,11 +1681,22 @@ void* tryAllocate(Context* c, unsigned size)
{
ACQUIRE(c->lock);
if (DebugAllocation) {
size = pad(size) + 2 * BytesPerWord;
}
if (size + c->count < c->limit) {
void* p = c->system->tryAllocate(size);
if (p) {
c->count += size;
return p;
if (DebugAllocation) {
static_cast<uintptr_t*>(p)[0] = 0x22377322;
static_cast<uintptr_t*>(p)[(size / BytesPerWord) - 1] = 0x22377322;
return static_cast<uintptr_t*>(p) + 1;
} else {
return p;
}
}
}
return 0;
@ -1686,7 +1705,21 @@ void* tryAllocate(Context* c, unsigned size)
void free(Context* c, const void* p, unsigned size) {
ACQUIRE(c->lock);
if (DebugAllocation) {
size = pad(size) + 2 * BytesPerWord;
memset(const_cast<void*>(p), 0xFE, size - (2 * BytesPerWord));
p = static_cast<const uintptr_t*>(p) - 1;
expect(c->system, static_cast<const uintptr_t*>(p)[0] == 0x22377322);
expect(c->system, static_cast<const uintptr_t*>(p)
[(size / BytesPerWord) - 1] == 0x22377322);
}
expect(c->system, c->count >= size);
c->system->free(p);
c->count -= size;
}

View File

@ -97,6 +97,14 @@ GetEnv(Machine* m, Thread** t, jint version)
}
}
jsize JNICALL
GetVersion(Thread* t)
{
ENTER(t, Thread::ActiveState);
return JNI_VERSION_1_6;
}
jsize JNICALL
GetStringLength(Thread* t, jstring s)
{
@ -1914,6 +1922,7 @@ populateJNITables(JavaVMVTable* vmTable, JNIEnvVTable* envTable)
memset(envTable, 0, sizeof(JNIEnvVTable));
envTable->GetVersion = ::GetVersion;
envTable->GetStringLength = ::GetStringLength;
envTable->GetStringChars = ::GetStringChars;
envTable->ReleaseStringChars = ::ReleaseStringChars;

View File

@ -94,6 +94,10 @@ const unsigned CompiledFlag = 1 << 1;
const unsigned ConstructorFlag = 1 << 2;
const unsigned FastNative = 1 << 3;
#ifndef JNI_VERSION_1_6
#define JNI_VERSION_1_6 0x00010006
#endif
typedef Machine JavaVM;
typedef Thread JNIEnv;

View File

@ -772,7 +772,8 @@ struct MINIDUMP_USER_STREAM_INFORMATION;
struct MINIDUMP_CALLBACK_INFORMATION;
enum MINIDUMP_TYPE {
MiniDumpNormal = 0
MiniDumpNormal = 0,
MiniDumpWithFullMemory = 2
};
typedef BOOL (*MiniDumpWriteDumpType)
@ -812,7 +813,7 @@ dump(LPEXCEPTION_POINTERS e, const char* directory)
(GetCurrentProcess(),
GetCurrentProcessId(),
file,
MiniDumpNormal,
MiniDumpWithFullMemory,
&exception,
0,
0);