From e47c149fb1d429f6ca24af4e7dc4f4a3593458b8 Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Thu, 3 Sep 2009 17:57:32 -0600 Subject: [PATCH 1/7] fix misuse of FindFirstFile --- classpath/java-io.cpp | 11 +++++++++-- src/windows.cpp | 7 ++++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/classpath/java-io.cpp b/classpath/java-io.cpp index 035a6ecc1c..f9a7ce5c3a 100644 --- a/classpath/java-io.cpp +++ b/classpath/java-io.cpp @@ -405,14 +405,21 @@ Java_java_io_File_openDir(JNIEnv* e, jclass, jstring path) { const char* chars = e->GetStringUTFChars(path, 0); if (chars) { + unsigned length = strlen(chars); + + RUNTIME_ARRAY(char, buffer, length + 3); + memcpy(RUNTIME_ARRAY_BODY(buffer), chars, length); + memcpy(RUNTIME_ARRAY_BODY(buffer) + length, "\\*", 3); + + e->ReleaseStringUTFChars(path, chars); + Directory* d = new (malloc(sizeof(Directory))) Directory; - d->handle = FindFirstFile(chars, &(d->data)); + d->handle = FindFirstFile(buffer, &(d->data)); if (d->handle == INVALID_HANDLE_VALUE) { d->dispose(); d = 0; } - e->ReleaseStringUTFChars(path, chars); return reinterpret_cast(d); } else { return 0; diff --git a/src/windows.cpp b/src/windows.cpp index 74aa32b498..f15c2996d2 100644 --- a/src/windows.cpp +++ b/src/windows.cpp @@ -678,8 +678,13 @@ class MySystem: public System { virtual Status open(System::Directory** directory, const char* name) { Status status = 1; + unsigned length = strlen(name); + RUNTIME_ARRAY(char, buffer, length + 3); + memcpy(RUNTIME_ARRAY_BODY(buffer), name, length); + memcpy(RUNTIME_ARRAY_BODY(buffer) + length, "\\*", 3); + Directory* d = new (allocate(this, sizeof(Directory))) Directory(this); - d->handle = FindFirstFile(name, &(d->data)); + d->handle = FindFirstFile(RUNTIME_ARRAY_BODY(buffer), &(d->data)); if (d->handle == INVALID_HANDLE_VALUE) { d->dispose(); } else { From b0ba70866e2d7677fe86fd123c904478566c2859 Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Fri, 4 Sep 2009 15:09:40 -0600 Subject: [PATCH 2/7] fix incorrect line numbers in NPE traces --- src/compile.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/compile.cpp b/src/compile.cpp index a7e67b7e9a..d857d7ba51 100644 --- a/src/compile.cpp +++ b/src/compile.cpp @@ -6351,7 +6351,9 @@ class SegFaultHandler: public System::SignalHandler { void* oldBase = t->base; void* oldStack = t->stack; - t->ip = *ip; + // add one to the IP since findLineNumber will subract one + // when we make the trace: + t->ip = static_cast(*ip) + 1; t->base = *base; t->stack = static_cast(*stack) - t->arch->frameReturnAddressSize(); From bf2b17cfa6b55fd70d77be57d99d597dce1a647e Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Fri, 4 Sep 2009 17:08:45 -0600 Subject: [PATCH 3/7] fix misspelled comment --- src/compile.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compile.cpp b/src/compile.cpp index d857d7ba51..ac87bfa8d8 100644 --- a/src/compile.cpp +++ b/src/compile.cpp @@ -6351,7 +6351,7 @@ class SegFaultHandler: public System::SignalHandler { void* oldBase = t->base; void* oldStack = t->stack; - // add one to the IP since findLineNumber will subract one + // add one to the IP since findLineNumber will subtract one // when we make the trace: t->ip = static_cast(*ip) + 1; t->base = *base; From 8956b98604033e48bebc9417ae6612dce014fa0e Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Sat, 5 Sep 2009 15:21:45 -0600 Subject: [PATCH 4/7] speed up build (especially on Windows) by avoiding redundant shell command execution in makefile --- makefile | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/makefile b/makefile index f67e18fefb..6631091379 100644 --- a/makefile +++ b/makefile @@ -3,12 +3,12 @@ MAKEFLAGS = -s name = avian version = 0.2 -build-arch = $(shell uname -m | sed 's/^i.86$$/i386/') +build-arch := $(shell uname -m | sed 's/^i.86$$/i386/') ifeq (Power,$(filter Power,$(build-arch))) build-arch = powerpc endif -build-platform = \ +build-platform := \ $(shell uname -s | tr [:upper:] [:lower:] \ | sed 's/^mingw32.*$$/mingw32/' \ | sed 's/^cygwin.*$$/cygwin/') @@ -54,10 +54,10 @@ ifdef gnu gnu-object-dep = $(build)/gnu-object.dep gnu-cflags = -DBOOT_BUILTINS=\"javaio,javalang,javalangreflect,javamath,javanet,javanio,javautil\" -DAVIAN_GNU gnu-lflags = -lgmp - gnu-objects = $(shell find $(build)/gnu-objects -name "*.o") + gnu-objects := $(shell find $(build)/gnu-objects -name "*.o") endif -root = $(shell (cd .. && pwd)) +root := $(shell (cd .. && pwd)) build = build native-build = $(build)/$(platform)-$(arch)$(options) classpath-build = $(build)/classpath @@ -232,8 +232,8 @@ ld := $(cc) build-ld := $(build-cc) ifdef msvc - windows-java-home = $(shell cygpath -m "$(JAVA_HOME)") - zlib = $(shell cygpath -m "$(root)/win32/msvc") + windows-java-home := $(shell cygpath -m "$(JAVA_HOME)") + zlib := $(shell cygpath -m "$(root)/win32/msvc") cxx = "$(msvc)/BIN/cl.exe" cc = $(cxx) ld = "$(msvc)/BIN/link.exe" @@ -271,7 +271,7 @@ cpp-objects = $(foreach x,$(1),$(patsubst $(2)/%.cpp,$(3)/%.o,$(x))) asm-objects = $(foreach x,$(1),$(patsubst $(2)/%.S,$(3)/%-asm.o,$(x))) java-classes = $(foreach x,$(1),$(patsubst $(2)/%.java,$(3)/%.class,$(x))) -jni-sources = $(shell find $(classpath) -name '*.cpp') +jni-sources := $(shell find $(classpath) -name '*.cpp') jni-objects = $(call cpp-objects,$(jni-sources),$(classpath),$(native-build)) generated-code = \ @@ -390,7 +390,7 @@ executable = $(native-build)/$(name)${exe-suffix} dynamic-library = $(native-build)/$(so-prefix)$(name)$(so-suffix) executable-dynamic = $(native-build)/$(name)-dynamic${exe-suffix} -classpath-sources = $(shell find $(classpath) -name '*.java') +classpath-sources := $(shell find $(classpath) -name '*.java') classpath-classes = \ $(call java-classes,$(classpath-sources),$(classpath),$(classpath-build)) classpath-object = $(native-build)/classpath-jar.o From 3446ed0fcef3bb0d01792f98263c4dd55847687d Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Sat, 5 Sep 2009 15:35:00 -0600 Subject: [PATCH 5/7] fix MSVC build regression in java-io.cpp --- classpath/java-io.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classpath/java-io.cpp b/classpath/java-io.cpp index f9a7ce5c3a..22a480cc77 100644 --- a/classpath/java-io.cpp +++ b/classpath/java-io.cpp @@ -414,7 +414,7 @@ Java_java_io_File_openDir(JNIEnv* e, jclass, jstring path) e->ReleaseStringUTFChars(path, chars); Directory* d = new (malloc(sizeof(Directory))) Directory; - d->handle = FindFirstFile(buffer, &(d->data)); + d->handle = FindFirstFile(RUNTIME_ARRAY_BODY(buffer), &(d->data)); if (d->handle == INVALID_HANDLE_VALUE) { d->dispose(); d = 0; From 44ae6a02c244df4fe2cff7ffa91f52115fa45ed0 Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Sat, 5 Sep 2009 16:04:43 -0600 Subject: [PATCH 6/7] fix parallel (make -jN) build --- makefile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/makefile b/makefile index 6631091379..59e84596a7 100644 --- a/makefile +++ b/makefile @@ -449,7 +449,9 @@ args = $(flags) $(input) build: $(static-library) $(executable) $(dynamic-library) \ $(executable-dynamic) $(classpath-dep) $(test-dep) $(test-extra-dep) -$(test-classes): $(classpath-dep) +$(test-dep): $(classpath-dep) + +$(test-extra-dep): $(classpath-dep) .PHONY: run run: build From 49d113f43f1259ac668e5ecf63a60fff3a25e706 Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Sat, 5 Sep 2009 18:26:13 -0600 Subject: [PATCH 7/7] fix parallel bootimage build --- makefile | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/makefile b/makefile index 59e84596a7..5be4b75551 100644 --- a/makefile +++ b/makefile @@ -663,18 +663,13 @@ else endif $(strip) $(strip-all) $(@) -$(bootimage-generator): make-bootimage-generator - -make-bootimage-generator: - (unset MAKEFLAGS && \ - make mode=$(mode) \ +$(bootimage-generator): + $(MAKE) mode=$(mode) \ arch=$(build-arch) \ platform=$(bootimage-platform) \ - bootimage=$(bootimage) \ - heapdump=$(heapdump) \ bootimage-generator= \ build-bootimage-generator=$(bootimage-generator) \ - $(bootimage-generator)) + $(bootimage-generator) $(build-bootimage-generator): \ $(vm-objects) $(classpath-object) $(jni-objects) $(heapwalk-objects) \