From 031852daec60100e741d06c918cce16f0d542468 Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Mon, 26 Mar 2012 18:02:43 -0600 Subject: [PATCH 1/6] add -march=i586 to lflags as well as cflags where appropriate When link time optimization is enabled, we need to remind the compiler that we're targeting i586 when linking so it can resolve atomic operations like __sync_bool_compare_and_swap. --- makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/makefile b/makefile index 53ca635f7f..635fb052c9 100755 --- a/makefile +++ b/makefile @@ -472,6 +472,7 @@ ifneq ($(platform),darwin) ifeq ($(arch),i386) # this is necessary to support __sync_bool_compare_and_swap: cflags += -march=i586 + lflags += -march=i586 endif endif From 2ee377112599facd0571e168660182331c486004 Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Mon, 26 Mar 2012 18:06:16 -0600 Subject: [PATCH 2/6] make find[Field|Method]InClass non-inline functions It seems that GCC 4.6.1 gets confused at LTO time when we take the address of inline functions, so I'm switching them to non-inline linkage to make it happy. --- src/machine.cpp | 68 +++++++++++++++++++++++++++++-------------------- src/machine.h | 19 +++----------- 2 files changed, 44 insertions(+), 43 deletions(-) diff --git a/src/machine.cpp b/src/machine.cpp index 182308f8d4..744d6d2a46 100644 --- a/src/machine.cpp +++ b/src/machine.cpp @@ -2416,6 +2416,38 @@ isInitializing(Thread* t, object c) return false; } +object +findInTable(Thread* t, object table, object name, object spec, + object& (*getName)(Thread*, object), + object& (*getSpec)(Thread*, object)) +{ + if (table) { + for (unsigned i = 0; i < arrayLength(t, table); ++i) { + object o = arrayBody(t, table, i); + if (vm::strcmp(&byteArrayBody(t, getName(t, o), 0), + &byteArrayBody(t, name, 0)) == 0 and + vm::strcmp(&byteArrayBody(t, getSpec(t, o), 0), + &byteArrayBody(t, spec, 0)) == 0) + { + return o; + } + } + +// fprintf(stderr, "%s %s not in\n", +// &byteArrayBody(t, name, 0), +// &byteArrayBody(t, spec, 0)); + +// for (unsigned i = 0; i < arrayLength(t, table); ++i) { +// object o = arrayBody(t, table, i); +// fprintf(stderr, "\t%s %s\n", +// &byteArrayBody(t, getName(t, o), 0), +// &byteArrayBody(t, getSpec(t, o), 0)); +// } + } + + return 0; +} + } // namespace namespace vm { @@ -3884,35 +3916,17 @@ makeObjectArray(Thread* t, object elementClass, unsigned count) } object -findInTable(Thread* t, object table, object name, object spec, - object& (*getName)(Thread*, object), - object& (*getSpec)(Thread*, object)) +findFieldInClass(Thread* t, object class_, object name, object spec) { - if (table) { - for (unsigned i = 0; i < arrayLength(t, table); ++i) { - object o = arrayBody(t, table, i); - if (vm::strcmp(&byteArrayBody(t, getName(t, o), 0), - &byteArrayBody(t, name, 0)) == 0 and - vm::strcmp(&byteArrayBody(t, getSpec(t, o), 0), - &byteArrayBody(t, spec, 0)) == 0) - { - return o; - } - } + return findInTable + (t, classFieldTable(t, class_), name, spec, fieldName, fieldSpec); +} -// fprintf(stderr, "%s %s not in\n", -// &byteArrayBody(t, name, 0), -// &byteArrayBody(t, spec, 0)); - -// for (unsigned i = 0; i < arrayLength(t, table); ++i) { -// object o = arrayBody(t, table, i); -// fprintf(stderr, "\t%s %s\n", -// &byteArrayBody(t, getName(t, o), 0), -// &byteArrayBody(t, getSpec(t, o), 0)); -// } - } - - return 0; +object +findMethodInClass(Thread* t, object class_, object name, object spec) +{ + return findInTable + (t, classMethodTable(t, class_), name, spec, methodName, methodSpec); } object diff --git a/src/machine.h b/src/machine.h index 08884e40d0..cdb3ecf039 100644 --- a/src/machine.h +++ b/src/machine.h @@ -2595,16 +2595,7 @@ makeObjectArray(Thread* t, unsigned count) } object -findInTable(Thread* t, object table, object name, object spec, - object& (*getName)(Thread*, object), - object& (*getSpec)(Thread*, object)); - -inline object -findFieldInClass(Thread* t, object class_, object name, object spec) -{ - return findInTable - (t, classFieldTable(t, class_), name, spec, fieldName, fieldSpec); -} +findFieldInClass(Thread* t, object class_, object name, object spec); inline object findFieldInClass2(Thread* t, object class_, const char* name, const char* spec) @@ -2616,12 +2607,8 @@ findFieldInClass2(Thread* t, object class_, const char* name, const char* spec) return findFieldInClass(t, class_, n, s); } -inline object -findMethodInClass(Thread* t, object class_, object name, object spec) -{ - return findInTable - (t, classMethodTable(t, class_), name, spec, methodName, methodSpec); -} +object +findMethodInClass(Thread* t, object class_, object name, object spec); inline object makeThrowable From 4800518a316613c9f8ec990b51e2b5c86594e29a Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Tue, 27 Mar 2012 08:22:35 -0600 Subject: [PATCH 3/6] fix bootimage.cpp build regression I forgot to update bootimage.cpp when I added a parameter to Machine's constructor in d78247a. --- src/bootimage.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bootimage.cpp b/src/bootimage.cpp index dd408705e2..6ece510972 100644 --- a/src/bootimage.cpp +++ b/src/bootimage.cpp @@ -1671,7 +1671,7 @@ main(int ac, const char** av) p->initialize(&image, code, CodeCapacity); Machine* m = new (h->allocate(sizeof(Machine))) Machine - (s, h, f, 0, p, c, 0, 0, 0, 0); + (s, h, f, 0, p, c, 0, 0, 0, 0, 128 * 1024); Thread* t = p->makeThread(m, 0, 0); enter(t, Thread::ActiveState); From a2e0151728e443f2b901f830092fbc68de702312 Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Tue, 27 Mar 2012 17:57:11 -0600 Subject: [PATCH 4/6] initialize Machine::OutOfMemoryError in writeBootImage2 If we don't initialize that at our first opportunity, it's possible we'll run out of memory later and exit silently instead of printing the error and returning a nonzero exit code. --- src/bootimage.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/bootimage.cpp b/src/bootimage.cpp index 6ece510972..834431f7b4 100644 --- a/src/bootimage.cpp +++ b/src/bootimage.cpp @@ -1287,6 +1287,9 @@ writeBootImage2(Thread* t, FILE* bootimageOutput, FILE* codeOutput, BootImage* image, uint8_t* code, const char* className, const char* methodName, const char* methodSpec) { + setRoot(t, Machine::OutOfMemoryError, + make(t, type(t, Machine::OutOfMemoryErrorType))); + Zone zone(t->m->system, t->m->heap, 64 * 1024); object classPoolMap; From 48bb1e4f41e976c61f2197421e025811af2d1d3e Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Tue, 27 Mar 2012 17:58:52 -0600 Subject: [PATCH 5/6] include charsets.jar in openjdk-src build The other JARs we were including refer to classes in this jar, so we need to include it as well. --- makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/makefile b/makefile index 635fb052c9..3c1f98bfb2 100755 --- a/makefile +++ b/makefile @@ -1087,6 +1087,7 @@ $(openjdk-jar-dep): $(jar) xf "$$($(native-path) "$(openjdk)/jre/lib/rt.jar")" && \ $(jar) xf "$$($(native-path) "$(openjdk)/jre/lib/jsse.jar")" && \ $(jar) xf "$$($(native-path) "$(openjdk)/jre/lib/jce.jar")" && \ + $(jar) xf "$$($(native-path) "$(openjdk)/jre/lib/charsets.jar")" && \ $(jar) xf "$$($(native-path) "$(openjdk)/jre/lib/ext/sunjce_provider.jar")" && \ $(jar) xf "$$($(native-path) "$(openjdk)/jre/lib/resources.jar")") @touch $(@) From ae2b58ee40424e84dd7d656d5a221c4feee88fcd Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Tue, 27 Mar 2012 18:14:29 -0600 Subject: [PATCH 6/6] increase bootimage.cpp heap and code size limits OpenJDK is huge, so building a bootimage out of the whole thing (as opposed to an app shrunk using ProGuard) requires a lot of space. Note that we still can't handle this on ARM or PowerPC due to a limitation in the compiler, but we don't expect people to ship binaries with the entire OpenJDK class library anyway, so it shouldn't be a problem in practice. --- src/bootimage.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/bootimage.cpp b/src/bootimage.cpp index 834431f7b4..3447dff69a 100644 --- a/src/bootimage.cpp +++ b/src/bootimage.cpp @@ -25,7 +25,7 @@ using namespace vm; namespace { -const unsigned HeapCapacity = 256 * 1024 * 1024; +const unsigned HeapCapacity = 512 * 1024 * 1024; const unsigned TargetFixieSizeInBytes = 8 + (TargetBytesPerWord * 2); const unsigned TargetFixieSizeInWords = ceiling @@ -1667,7 +1667,11 @@ main(int ac, const char** av) // in a branch instruction for the target architecture (~32MB on // PowerPC and ARM). When that limitation is removed, we'll be able // to specify a capacity as large as we like here: +#if (defined ARCH_x86_64) || (defined ARCH_x86_32) + const unsigned CodeCapacity = 128 * 1024 * 1024; +#else const unsigned CodeCapacity = 30 * 1024 * 1024; +#endif uint8_t* code = static_cast(h->allocate(CodeCapacity)); BootImage image;