don't include embedded boot classpath in libvm.a, only the executable

This commit is contained in:
Joel Dice 2008-01-18 17:54:36 -07:00
parent bb701f309c
commit 35160e46d8
5 changed files with 71 additions and 59 deletions

View File

@ -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<uintptr_t>(SYMBOL(size));
return SYMBOL(start);
}
#endif
} // extern "C"

View File

@ -1,5 +1,7 @@
MAKEFLAGS = -s MAKEFLAGS = -s
name = vm
build-arch = $(shell uname -m) build-arch = $(shell uname -m)
ifeq ($(build-arch),i586) ifeq ($(build-arch),i586)
build-arch = i386 build-arch = i386
@ -135,7 +137,7 @@ generated-code = \
$(native-build)/type-initializations.cpp \ $(native-build)/type-initializations.cpp \
$(native-build)/type-java-initializations.cpp $(native-build)/type-java-initializations.cpp
interpreter-depends = \ vm-depends = \
$(generated-code) \ $(generated-code) \
$(src)/allocator.h \ $(src)/allocator.h \
$(src)/common.h \ $(src)/common.h \
@ -151,7 +153,7 @@ interpreter-depends = \
$(src)/util.h \ $(src)/util.h \
$(src)/zone.h $(src)/zone.h
interpreter-sources = \ vm-sources = \
$(src)/$(system).cpp \ $(src)/$(system).cpp \
$(src)/finder.cpp \ $(src)/finder.cpp \
$(src)/machine.cpp \ $(src)/machine.cpp \
@ -161,25 +163,21 @@ interpreter-sources = \
$(src)/builtin.cpp \ $(src)/builtin.cpp \
$(src)/jnienv.cpp $(src)/jnienv.cpp
interpreter-asm-sources = $(src)/$(asm).S vm-asm-sources = $(src)/$(asm).S
ifeq ($(process),compile) ifeq ($(process),compile)
interpreter-depends += \ vm-depends += \
$(src)/compiler.h \ $(src)/compiler.h \
$(src)/vector.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 endif
interpreter-cpp-objects = \ vm-cpp-objects = $(call cpp-objects,$(vm-sources),$(src),$(native-build))
$(call cpp-objects,$(interpreter-sources),$(src),$(native-build)) vm-asm-objects = $(call asm-objects,$(vm-asm-sources),$(src),$(native-build))
interpreter-asm-objects = \ vm-objects = $(vm-cpp-objects) $(vm-asm-objects)
$(call asm-objects,$(interpreter-asm-sources),$(src),$(native-build))
interpreter-objects = \
$(interpreter-cpp-objects) \
$(interpreter-asm-objects)
driver-sources = $(src)/main.cpp driver-sources = $(src)/main.cpp
@ -191,8 +189,8 @@ generator-objects = \
$(call cpp-objects,$(generator-sources),$(src),$(native-build)) $(call cpp-objects,$(generator-sources),$(src),$(native-build))
generator = $(native-build)/generator generator = $(native-build)/generator
archive = $(native-build)/libvm.a archive = $(native-build)/lib$(name).a
interpreter = $(native-build)/vm vm = $(native-build)/$(name)
classpath-sources = $(shell find $(classpath) -name '*.java') classpath-sources = $(shell find $(classpath) -name '*.java')
classpath-classes = \ classpath-classes = \
@ -220,26 +218,26 @@ endif
args = $(flags) $(input) args = $(flags) $(input)
.PHONY: build .PHONY: build
build: $(interpreter) $(archive) $(classpath-dep) $(test-dep) build: $(vm) $(archive) $(classpath-dep) $(test-dep)
$(test-classes): $(classpath-dep) $(test-classes): $(classpath-dep)
.PHONY: run .PHONY: run
run: build run: build
$(interpreter) $(args) $(vm) $(args)
.PHONY: debug .PHONY: debug
debug: build debug: build
gdb --args $(interpreter) $(args) gdb --args $(vm) $(args)
.PHONY: vg .PHONY: vg
vg: build vg: build
$(vg) $(interpreter) $(args) $(vg) $(vm) $(args)
.PHONY: test .PHONY: test
test: build test: build
/bin/bash $(test)/test.sh 2>/dev/null \ /bin/bash $(test)/test.sh 2>/dev/null \
$(interpreter) $(mode) "$(flags)" \ $(vm) $(mode) "$(flags)" \
$(call class-names,$(test-build),$(test-classes)) $(call class-names,$(test-build),$(test-classes))
.PHONY: clean .PHONY: clean
@ -287,11 +285,10 @@ define compile-object
$(cxx) $(cflags) -c $(<) -o $(@) $(cxx) $(cflags) -c $(<) -o $(@)
endef endef
$(interpreter-cpp-objects): \ $(vm-cpp-objects): $(native-build)/%.o: $(src)/%.cpp $(vm-depends)
$(native-build)/%.o: $(src)/%.cpp $(interpreter-depends)
$(compile-object) $(compile-object)
$(interpreter-asm-objects): $(native-build)/%-asm.o: $(src)/%.S $(vm-asm-objects): $(native-build)/%-asm.o: $(src)/%.S
$(compile-object) $(compile-object)
$(driver-object): $(native-build)/%.o: $(src)/%.cpp $(driver-object): $(native-build)/%.o: $(src)/%.cpp
@ -319,14 +316,13 @@ $(jni-objects): $(native-build)/%.o: $(classpath)/%.cpp
@mkdir -p $(dir $(@)) @mkdir -p $(dir $(@))
$(cxx) $(jni-cflags) -c $(<) -o $(@) $(cxx) $(jni-cflags) -c $(<) -o $(@)
$(archive): $(interpreter-objects) $(jni-objects) $(classpath-object) $(archive): $(vm-objects) $(jni-objects)
@echo "creating $(@)" @echo "creating $(@)"
rm -rf $(@) rm -rf $(@)
$(ar) cru $(@) $(^) $(ar) cru $(@) $(^)
$(ranlib) $(@) $(ranlib) $(@)
$(interpreter): \ $(vm): $(vm-objects) $(jni-objects) $(classpath-object) $(driver-object)
$(interpreter-objects) $(jni-objects) $(classpath-object) $(driver-object)
@echo "linking $(@)" @echo "linking $(@)"
ifeq ($(platform),windows) ifeq ($(platform),windows)
$(dlltool) -z $(@).def $(^) $(dlltool) -z $(@).def $(^)

View File

@ -1968,7 +1968,6 @@ JNI_GetDefaultJavaVMInitArgs(void* args)
} }
#define BUILTINS_PROPERTY "vm.builtins" #define BUILTINS_PROPERTY "vm.builtins"
#define BUILTIN_CLASSPATH "[vmClasspath]"
extern "C" JNIEXPORT jint JNICALL extern "C" JNIEXPORT jint JNICALL
JNI_CreateJavaVM(Machine** m, Thread** t, void* args) JNI_CreateJavaVM(Machine** m, Thread** t, void* args)
@ -1977,13 +1976,7 @@ JNI_CreateJavaVM(Machine** m, Thread** t, void* args)
System* s = makeSystem(); System* s = makeSystem();
Heap* h = makeHeap(s, a->maxHeapSize); Heap* h = makeHeap(s, a->maxHeapSize);
Finder* f = makeFinder(s, a->classpath);
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);
Processor* p = makeProcessor(s, h); Processor* p = makeProcessor(s, h);
*m = new (h->allocate(sizeof(Machine), false)) Machine(s, h, f, p); *m = new (h->allocate(sizeof(Machine), false)) Machine(s, h, f, p);

View File

@ -2657,6 +2657,17 @@ findInTable(Thread* t, object table, object name, object spec,
return o; 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; return 0;

View File

@ -1,6 +1,7 @@
#include "stdlib.h" #include "stdlib.h"
#include "stdio.h" #include "stdio.h"
#include "string.h" #include "string.h"
#include "stdint.h"
#include "jni.h" #include "jni.h"
// since we don't link against libstdc++, we must implement some dummy // since we don't link against libstdc++, we must implement some dummy
@ -8,6 +9,34 @@
extern "C" void __cxa_pure_virtual(void) { abort(); } extern "C" void __cxa_pure_virtual(void) { abort(); }
void operator delete(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<uintptr_t>(SYMBOL(size));
return SYMBOL(start);
}
#endif
}
#ifdef JNI_VERSION_1_6 #ifdef JNI_VERSION_1_6
// todo: use JavaVMInitArgs instead // todo: use JavaVMInitArgs instead
typedef struct JDK1_1InitArgs { 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]; const char* properties[propertyCount + 1];
properties[propertyCount] = 0; properties[propertyCount] = 0;
for (int i = 1; i < ac; ++i) { for (int i = 1; i < ac; ++i) {