From 35160e46d89437f775600e7639c5a3448b5b3cf6 Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Fri, 18 Jan 2008 17:54:36 -0700 Subject: [PATCH] don't include embedded boot classpath in libvm.a, only the executable --- classpath/classpath.cpp | 25 --------------------- makefile | 48 +++++++++++++++++++---------------------- src/jnienv.cpp | 9 +------- src/machine.cpp | 11 ++++++++++ src/main.cpp | 37 +++++++++++++++++++++++++++++++ 5 files changed, 71 insertions(+), 59 deletions(-) delete mode 100644 classpath/classpath.cpp diff --git a/classpath/classpath.cpp b/classpath/classpath.cpp deleted file mode 100644 index f75d3333a7..0000000000 --- a/classpath/classpath.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#include "stdint.h" - -#ifdef __MINGW32__ -# define EXPORT __declspec(dllexport) -# define SYMBOL(x) binary_classpath_jar_##x -#else -# define EXPORT __attribute__ ((visibility("default"))) -# define SYMBOL(x) _binary_classpath_jar_##x -#endif - -extern "C" { - -#ifndef __APPLE__ - extern const uint8_t SYMBOL(start)[]; - extern const uint8_t SYMBOL(size)[]; - - EXPORT const uint8_t* - vmClasspath(unsigned* size) - { - *size = reinterpret_cast(SYMBOL(size)); - return SYMBOL(start); - } -#endif - -} // extern "C" diff --git a/makefile b/makefile index 88cfb9ba82..5db7e2b519 100644 --- a/makefile +++ b/makefile @@ -1,5 +1,7 @@ MAKEFLAGS = -s +name = vm + build-arch = $(shell uname -m) ifeq ($(build-arch),i586) build-arch = i386 @@ -135,7 +137,7 @@ generated-code = \ $(native-build)/type-initializations.cpp \ $(native-build)/type-java-initializations.cpp -interpreter-depends = \ +vm-depends = \ $(generated-code) \ $(src)/allocator.h \ $(src)/common.h \ @@ -151,7 +153,7 @@ interpreter-depends = \ $(src)/util.h \ $(src)/zone.h -interpreter-sources = \ +vm-sources = \ $(src)/$(system).cpp \ $(src)/finder.cpp \ $(src)/machine.cpp \ @@ -161,25 +163,21 @@ interpreter-sources = \ $(src)/builtin.cpp \ $(src)/jnienv.cpp -interpreter-asm-sources = $(src)/$(asm).S +vm-asm-sources = $(src)/$(asm).S ifeq ($(process),compile) - interpreter-depends += \ + vm-depends += \ $(src)/compiler.h \ $(src)/vector.h - interpreter-sources += $(src)/compiler.cpp + vm-sources += $(src)/compiler.cpp - interpreter-asm-sources += $(src)/compile.S + vm-asm-sources += $(src)/compile.S endif -interpreter-cpp-objects = \ - $(call cpp-objects,$(interpreter-sources),$(src),$(native-build)) -interpreter-asm-objects = \ - $(call asm-objects,$(interpreter-asm-sources),$(src),$(native-build)) -interpreter-objects = \ - $(interpreter-cpp-objects) \ - $(interpreter-asm-objects) +vm-cpp-objects = $(call cpp-objects,$(vm-sources),$(src),$(native-build)) +vm-asm-objects = $(call asm-objects,$(vm-asm-sources),$(src),$(native-build)) +vm-objects = $(vm-cpp-objects) $(vm-asm-objects) driver-sources = $(src)/main.cpp @@ -191,8 +189,8 @@ generator-objects = \ $(call cpp-objects,$(generator-sources),$(src),$(native-build)) generator = $(native-build)/generator -archive = $(native-build)/libvm.a -interpreter = $(native-build)/vm +archive = $(native-build)/lib$(name).a +vm = $(native-build)/$(name) classpath-sources = $(shell find $(classpath) -name '*.java') classpath-classes = \ @@ -220,26 +218,26 @@ endif args = $(flags) $(input) .PHONY: build -build: $(interpreter) $(archive) $(classpath-dep) $(test-dep) +build: $(vm) $(archive) $(classpath-dep) $(test-dep) $(test-classes): $(classpath-dep) .PHONY: run run: build - $(interpreter) $(args) + $(vm) $(args) .PHONY: debug debug: build - gdb --args $(interpreter) $(args) + gdb --args $(vm) $(args) .PHONY: vg vg: build - $(vg) $(interpreter) $(args) + $(vg) $(vm) $(args) .PHONY: test test: build /bin/bash $(test)/test.sh 2>/dev/null \ - $(interpreter) $(mode) "$(flags)" \ + $(vm) $(mode) "$(flags)" \ $(call class-names,$(test-build),$(test-classes)) .PHONY: clean @@ -287,11 +285,10 @@ define compile-object $(cxx) $(cflags) -c $(<) -o $(@) endef -$(interpreter-cpp-objects): \ - $(native-build)/%.o: $(src)/%.cpp $(interpreter-depends) +$(vm-cpp-objects): $(native-build)/%.o: $(src)/%.cpp $(vm-depends) $(compile-object) -$(interpreter-asm-objects): $(native-build)/%-asm.o: $(src)/%.S +$(vm-asm-objects): $(native-build)/%-asm.o: $(src)/%.S $(compile-object) $(driver-object): $(native-build)/%.o: $(src)/%.cpp @@ -319,14 +316,13 @@ $(jni-objects): $(native-build)/%.o: $(classpath)/%.cpp @mkdir -p $(dir $(@)) $(cxx) $(jni-cflags) -c $(<) -o $(@) -$(archive): $(interpreter-objects) $(jni-objects) $(classpath-object) +$(archive): $(vm-objects) $(jni-objects) @echo "creating $(@)" rm -rf $(@) $(ar) cru $(@) $(^) $(ranlib) $(@) -$(interpreter): \ - $(interpreter-objects) $(jni-objects) $(classpath-object) $(driver-object) +$(vm): $(vm-objects) $(jni-objects) $(classpath-object) $(driver-object) @echo "linking $(@)" ifeq ($(platform),windows) $(dlltool) -z $(@).def $(^) diff --git a/src/jnienv.cpp b/src/jnienv.cpp index 9ebc7a70f9..72c53bb642 100644 --- a/src/jnienv.cpp +++ b/src/jnienv.cpp @@ -1968,7 +1968,6 @@ JNI_GetDefaultJavaVMInitArgs(void* args) } #define BUILTINS_PROPERTY "vm.builtins" -#define BUILTIN_CLASSPATH "[vmClasspath]" extern "C" JNIEXPORT jint JNICALL JNI_CreateJavaVM(Machine** m, Thread** t, void* args) @@ -1977,13 +1976,7 @@ JNI_CreateJavaVM(Machine** m, Thread** t, void* args) System* s = makeSystem(); Heap* h = makeHeap(s, a->maxHeapSize); - - unsigned size = sizeof(BUILTIN_CLASSPATH) + 1 + strlen(a->classpath); - char classpath[size]; - snprintf(classpath, size, "%s%c%s", - BUILTIN_CLASSPATH, s->pathSeparator(), a->classpath); - - Finder* f = makeFinder(s, classpath); + Finder* f = makeFinder(s, a->classpath); Processor* p = makeProcessor(s, h); *m = new (h->allocate(sizeof(Machine), false)) Machine(s, h, f, p); diff --git a/src/machine.cpp b/src/machine.cpp index b7d2592ef9..f47509a420 100644 --- a/src/machine.cpp +++ b/src/machine.cpp @@ -2657,6 +2657,17 @@ findInTable(Thread* t, object table, object name, object spec, 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; diff --git a/src/main.cpp b/src/main.cpp index 3ea3efa99c..ffba794a31 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,6 +1,7 @@ #include "stdlib.h" #include "stdio.h" #include "string.h" +#include "stdint.h" #include "jni.h" // since we don't link against libstdc++, we must implement some dummy @@ -8,6 +9,34 @@ extern "C" void __cxa_pure_virtual(void) { abort(); } void operator delete(void*) { abort(); } +#ifdef __MINGW32__ +# define PATH_SEPARATOR ';' +# define EXPORT __declspec(dllexport) +# define SYMBOL(x) binary_classpath_jar_##x +#else +# define PATH_SEPARATOR ':' +# define EXPORT __attribute__ ((visibility("default"))) +# define SYMBOL(x) _binary_classpath_jar_##x +#endif + +extern "C" { + +#ifndef __APPLE__ +# define BOOT_CLASSPATH "[classpathJar]" + + extern const uint8_t SYMBOL(start)[]; + extern const uint8_t SYMBOL(size)[]; + + EXPORT const uint8_t* + classpathJar(unsigned* size) + { + *size = reinterpret_cast(SYMBOL(size)); + return SYMBOL(start); + } +#endif + +} + #ifdef JNI_VERSION_1_6 // todo: use JavaVMInitArgs instead typedef struct JDK1_1InitArgs { @@ -76,6 +105,14 @@ main(int ac, const char** av) } } +#ifdef BOOT_CLASSPATH + unsigned size = sizeof(BOOT_CLASSPATH) + 1 + strlen(vmArgs.classpath); + char classpath[size]; + snprintf(classpath, size, "%s%c%s", + BOOT_CLASSPATH, PATH_SEPARATOR, vmArgs.classpath); + vmArgs.classpath = classpath; +#endif + const char* properties[propertyCount + 1]; properties[propertyCount] = 0; for (int i = 1; i < ac; ++i) {