├── .gitignore ├── Makefile ├── Makefile.common ├── Makefile.libretro ├── README.md ├── jni ├── Android.mk └── Application.mk ├── link.T └── src ├── jamvm ├── Makefile.am ├── Makefile.in ├── access.c ├── alloc.c ├── alloc.h ├── annotations.h ├── arch │ ├── Makefile.am │ ├── Makefile.in │ ├── arch.h │ ├── arm.h │ ├── i386.h │ ├── mips.h │ ├── parisc.h │ ├── powerpc.h │ ├── sparc.h │ └── x86_64.h ├── cast.c ├── class.c ├── class.h ├── classlib │ ├── Makefile.am │ ├── Makefile.in │ ├── gnuclasspath │ │ ├── Makefile.am │ │ ├── Makefile.in │ │ ├── alloc.c │ │ ├── annotations.c │ │ ├── class.c │ │ ├── classlib-defs.h │ │ ├── classlib-excep.h │ │ ├── classlib-symbol.h │ │ ├── classlib.h │ │ ├── dll.c │ │ ├── excep.c │ │ ├── frame.c │ │ ├── gnuclasspath.h │ │ ├── jni.c │ │ ├── lib │ │ │ ├── Makefile.am │ │ │ ├── Makefile.in │ │ │ ├── README │ │ │ ├── classes.zip │ │ │ ├── gnu │ │ │ │ ├── Makefile.am │ │ │ │ ├── Makefile.in │ │ │ │ └── classpath │ │ │ │ │ ├── Makefile.am │ │ │ │ │ ├── Makefile.in │ │ │ │ │ ├── VMStackWalker.java │ │ │ │ │ └── VMSystemProperties.java │ │ │ ├── jamvm │ │ │ │ ├── Makefile.am │ │ │ │ ├── Makefile.in │ │ │ │ ├── ThreadInfoHelper.java │ │ │ │ └── java │ │ │ │ │ ├── Makefile.am │ │ │ │ │ ├── Makefile.in │ │ │ │ │ └── lang │ │ │ │ │ ├── JarLauncher.java │ │ │ │ │ ├── Makefile.am │ │ │ │ │ ├── Makefile.in │ │ │ │ │ └── VMClassLoaderData.java │ │ │ ├── java │ │ │ │ ├── Makefile.am │ │ │ │ ├── Makefile.in │ │ │ │ ├── lang │ │ │ │ │ ├── Makefile.am │ │ │ │ │ ├── Makefile.in │ │ │ │ │ ├── VMClass.java │ │ │ │ │ ├── VMClassLoader.java │ │ │ │ │ ├── VMRuntime.java │ │ │ │ │ ├── VMString.java │ │ │ │ │ ├── VMThread.java │ │ │ │ │ ├── VMThrowable.java │ │ │ │ │ └── reflect │ │ │ │ │ │ ├── Makefile.am │ │ │ │ │ │ ├── Makefile.in │ │ │ │ │ │ ├── VMConstructor.java │ │ │ │ │ │ ├── VMField.java │ │ │ │ │ │ └── VMMethod.java │ │ │ │ └── security │ │ │ │ │ ├── Makefile.am │ │ │ │ │ ├── Makefile.in │ │ │ │ │ └── VMAccessController.java │ │ │ └── sun │ │ │ │ ├── Makefile.am │ │ │ │ ├── Makefile.in │ │ │ │ └── reflect │ │ │ │ ├── Makefile.am │ │ │ │ ├── Makefile.in │ │ │ │ └── annotation │ │ │ │ ├── AnnotationInvocationHandler.java │ │ │ │ ├── Makefile.am │ │ │ │ └── Makefile.in │ │ ├── natives.c │ │ ├── properties.c │ │ ├── reflect.c │ │ └── thread.c │ ├── openjdk │ │ ├── Makefile.am │ │ ├── Makefile.in │ │ ├── access.c │ │ ├── alloc.c │ │ ├── class.c │ │ ├── classlib-defs.h │ │ ├── classlib-excep.h │ │ ├── classlib-symbol.h │ │ ├── classlib.h │ │ ├── dll.c │ │ ├── excep.c │ │ ├── frame.c │ │ ├── jmm.h │ │ ├── jni.c │ │ ├── jvm.c │ │ ├── management.c │ │ ├── mh.c │ │ ├── natives.c │ │ ├── openjdk.h │ │ ├── perf.c │ │ ├── properties.c │ │ ├── reflect.c │ │ ├── shutdown.c │ │ ├── thread.c │ │ └── trace.h │ └── squirreljme │ │ └── nativemethods.c ├── config.h ├── config.h.in ├── dll.c ├── dll_ffi.c ├── excep.c ├── excep.h ├── execute.c ├── frame.c ├── frame.h ├── hash.c ├── hash.h ├── hooks.c ├── init.c ├── interp │ ├── Makefile.am │ ├── Makefile.in │ ├── direct.c │ ├── engine │ │ ├── Makefile.am │ │ ├── Makefile.in │ │ ├── interp-direct-common.h │ │ ├── interp-direct.h │ │ ├── interp-indirect.h │ │ ├── interp-inlining.h │ │ ├── interp-threading.h │ │ ├── interp.c │ │ ├── interp.h │ │ ├── interp2.c │ │ ├── relocatability.c │ │ └── tool_source │ │ │ └── compute_relocatability.c │ ├── inlining.c │ ├── inlining.h │ └── shared.h ├── jam.c ├── jam.h ├── jni-internal.h ├── jni-stubs.c ├── jni.c ├── jni.h ├── lock.c ├── lock.h ├── natives.c ├── natives.h ├── os │ ├── Makefile.am │ ├── Makefile.in │ ├── bsd │ │ ├── Makefile.am │ │ ├── Makefile.in │ │ ├── arm │ │ │ ├── Makefile.am │ │ │ ├── Makefile.in │ │ │ ├── callNative.S │ │ │ ├── callNativeEABI.S │ │ │ ├── callNativeOABI.S │ │ │ ├── dll_md.c │ │ │ └── init.c │ │ ├── i386 │ │ │ ├── Makefile.am │ │ │ ├── Makefile.in │ │ │ ├── dll_md.c │ │ │ └── init.c │ │ ├── os.c │ │ ├── powerpc │ │ │ ├── Makefile.am │ │ │ ├── Makefile.in │ │ │ ├── callNative.S │ │ │ ├── dll_md.c │ │ │ └── init.c │ │ ├── sparc │ │ │ ├── Makefile.am │ │ │ ├── Makefile.in │ │ │ └── init.c │ │ └── x86_64 │ │ │ ├── Makefile.am │ │ │ ├── Makefile.in │ │ │ ├── callNative.S │ │ │ ├── dll_md.c │ │ │ └── init.c │ ├── darwin │ │ ├── Makefile.am │ │ ├── Makefile.in │ │ ├── arm │ │ │ ├── Makefile.am │ │ │ ├── Makefile.in │ │ │ ├── callNative.S │ │ │ ├── callNativeEABI.S │ │ │ ├── callNativeOABI.S │ │ │ ├── dll_md.c │ │ │ └── init.c │ │ ├── i386 │ │ │ ├── Makefile.am │ │ │ ├── Makefile.in │ │ │ ├── dll_md.c │ │ │ └── init.c │ │ ├── os.c │ │ └── powerpc │ │ │ ├── Makefile.am │ │ │ ├── Makefile.in │ │ │ ├── callNative.S │ │ │ ├── callNative32.S │ │ │ ├── callNative64.S │ │ │ ├── dll_md.c │ │ │ └── init.c │ ├── libretro │ │ ├── Makefile.am │ │ ├── Makefile.in │ │ ├── arm │ │ │ ├── Makefile.am │ │ │ ├── Makefile.in │ │ │ ├── callNative.S │ │ │ ├── callNativeEABI.S │ │ │ ├── callNativeEABIHard.S │ │ │ ├── callNativeEABIHardARM.S │ │ │ ├── callNativeOABI.S │ │ │ ├── dll_md.c │ │ │ └── init.c │ │ ├── i386 │ │ │ ├── Makefile.am │ │ │ ├── Makefile.in │ │ │ ├── dll_md.c │ │ │ ├── init.c │ │ │ ├── jni-stubs.c │ │ │ └── stubs_md.c │ │ ├── mips │ │ │ ├── Makefile.am │ │ │ ├── Makefile.in │ │ │ ├── callNative.S │ │ │ ├── dll_md.c │ │ │ └── init.c │ │ ├── os.c │ │ ├── parisc │ │ │ ├── Makefile.am │ │ │ ├── Makefile.in │ │ │ └── init.c │ │ ├── powerpc │ │ │ ├── Makefile.am │ │ │ ├── Makefile.in │ │ │ ├── callNative.S │ │ │ ├── dll_md.c │ │ │ └── init.c │ │ └── x86_64 │ │ │ ├── Makefile.am │ │ │ ├── Makefile.in │ │ │ ├── callNative.S │ │ │ ├── dll_md.c │ │ │ └── init.c │ ├── linux │ │ ├── Makefile.am │ │ ├── Makefile.in │ │ ├── arm │ │ │ ├── Makefile.am │ │ │ ├── Makefile.in │ │ │ ├── callNative.S │ │ │ ├── callNativeEABI.S │ │ │ ├── callNativeEABIHard.S │ │ │ ├── callNativeEABIHardARM.S │ │ │ ├── callNativeOABI.S │ │ │ ├── dll_md.c │ │ │ └── init.c │ │ ├── i386 │ │ │ ├── Makefile.am │ │ │ ├── Makefile.in │ │ │ ├── dll_md.c │ │ │ ├── init.c │ │ │ ├── jni-stubs.c │ │ │ └── stubs_md.c │ │ ├── mips │ │ │ ├── Makefile.am │ │ │ ├── Makefile.in │ │ │ ├── callNative.S │ │ │ ├── dll_md.c │ │ │ └── init.c │ │ ├── os.c │ │ ├── parisc │ │ │ ├── Makefile.am │ │ │ ├── Makefile.in │ │ │ └── init.c │ │ ├── powerpc │ │ │ ├── Makefile.am │ │ │ ├── Makefile.in │ │ │ ├── callNative.S │ │ │ ├── dll_md.c │ │ │ └── init.c │ │ └── x86_64 │ │ │ ├── Makefile.am │ │ │ ├── Makefile.in │ │ │ ├── callNative.S │ │ │ ├── dll_md.c │ │ │ └── init.c │ └── solaris │ │ ├── Makefile.am │ │ ├── Makefile.in │ │ ├── os.c │ │ └── x86 │ │ ├── Makefile.am │ │ ├── Makefile.in │ │ ├── callNative64.S │ │ ├── dll_md.c │ │ └── init.c ├── properties.c ├── properties.h ├── reflect.c ├── reflect.h ├── resolve.c ├── shutdown.c ├── sig.c ├── sig.h ├── string.c ├── stubs.c ├── stubs.h ├── symbol.c ├── symbol.h ├── thread.c ├── thread.h ├── time.c ├── utf8.c ├── zip.c └── zip.h └── libretro ├── libretro-common ├── include │ ├── boolean.h │ ├── compat │ │ └── msvc.h │ ├── retro_common_api.h │ ├── retro_inline.h │ ├── retro_miscellaneous.h │ └── rthreads │ │ └── rthreads.h └── rthreads │ ├── gx_pthread.h │ ├── psp_pthread.h │ ├── rthreads.c │ └── xenon_sdl_threads.c ├── libretro.c ├── libretro.h ├── libretro_exports.h └── libretro_params.h /.gitignore: -------------------------------------------------------------------------------- 1 | *.so 2 | *.o 3 | *.dylib 4 | *.dll 5 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | include Makefile.libretro 2 | -------------------------------------------------------------------------------- /Makefile.common: -------------------------------------------------------------------------------- 1 | 2 | INCFLAGS := -I$(CORE_DIR)/src/libretro \ 3 | -I$(CORE_DIR)/src/libretro/libretro-common/include \ 4 | -I$(CORE_DIR)/src/jamvm \ 5 | -I$(CORE_DIR)/src/jamvm/arch \ 6 | -I$(CORE_DIR)/src/jamvm/classlib/squirreljme \ 7 | -I$(CORE_DIR)/src/jamvm/interp \ 8 | -I$(CORE_DIR)/src/jamvm/interp/engine \ 9 | -I$(CORE_DIR)/src/jamvm/os/libretro 10 | 11 | SOURCES_C := $(CORE_DIR)/src/libretro/libretro.c \ 12 | $(CORE_DIR)/src/libretro/libretro-common/rthreads/rthreads.c \ 13 | $(wildcard $(CORE_DIR)/src/jamvm/*.c) \ 14 | $(wildcard $(CORE_DIR)/src/jamvm/arch/*.c) \ 15 | $(wildcard $(CORE_DIR)/src/jamvm/classlib/squirreljme/*.c) \ 16 | $(wildcard $(CORE_DIR)/src/jamvm/interp/*.c) \ 17 | $(wildcard $(CORE_DIR)/src/jamvm/interp/engine/*.c) \ 18 | $(wildcard $(CORE_DIR)/src/jamvm/os/libretro/*.c) 19 | 20 | SOURCES_CXX := 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # libretro-JamVM 2 | A full java virtual machine port for libretro, to be used with freej2me and SquirrelJME. 3 | -------------------------------------------------------------------------------- /jni/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH := $(call my-dir) 2 | GIT_VERSION := " $(shell git rev-parse --short HEAD)" 3 | 4 | include $(CLEAR_VARS) 5 | 6 | LOCAL_MODULE := retro 7 | 8 | ifeq ($(TARGET_ARCH_ABI), armeabi) 9 | LOCAL_CFLAGS += -DANDROID_ARM 10 | endif 11 | 12 | ifeq ($(TARGET_ARCH_ABI), armeabi-v7a) 13 | LOCAL_CFLAGS += -DANDROID_ARM 14 | endif 15 | 16 | ifeq ($(TARGET_ARCH_ABI), arm64-v8a) 17 | LOCAL_CFLAGS += -DANDROID_ARM 18 | endif 19 | 20 | ifeq ($(TARGET_ARCH_ABI), x86) 21 | LOCAL_CFLAGS += -DANDROID_X86 22 | endif 23 | 24 | ifeq ($(TARGET_ARCH_ABI), x86_64) 25 | LOCAL_CFLAGS += -DANDROID_X86 26 | endif 27 | 28 | ifeq ($(TARGET_ARCH_ABI), mips) 29 | LOCAL_CFLAGS += -DANDROID_MIPS -D__mips__ -D__MIPSEL__ 30 | endif 31 | 32 | ifeq ($(TARGET_ARCH_ABI), mips64) 33 | LOCAL_CFLAGS += -DANDROID_MIPS -D__mips__ -D__MIPSEL__ 34 | endif 35 | 36 | CORE_DIR := .. 37 | 38 | SOURCES_C := 39 | SOURCES_ASM := 40 | INCFLAGS := 41 | COMMONFLAGS := 42 | 43 | include $(CORE_DIR)/Makefile.common 44 | 45 | LOCAL_SRC_FILES := $(SOURCES_C) $(SOURCES_CXX) $(SOURCES_ASM) 46 | LOCAL_CFLAGS += -O3 $(COMMONFLAGS) -D__LIBRETRO__ -DFRONTEND_SUPPORTS_RGB565 $(INCFLAGS) -DGIT_VERSION=\"$(GIT_VERSION)\" 47 | 48 | include $(BUILD_SHARED_LIBRARY) 49 | -------------------------------------------------------------------------------- /jni/Application.mk: -------------------------------------------------------------------------------- 1 | APP_ABI := all 2 | -------------------------------------------------------------------------------- /link.T: -------------------------------------------------------------------------------- 1 | { 2 | global: retro_*; 3 | local: *; 4 | }; 5 | 6 | -------------------------------------------------------------------------------- /src/jamvm/Makefile.am: -------------------------------------------------------------------------------- 1 | ## 2 | ## Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2010, 2011, 2012, 2013 3 | ## Robert Lougher . 4 | ## 5 | ## This file is part of JamVM. 6 | ## 7 | ## This program is free software; you can redistribute it and/or 8 | ## modify it under the terms of the GNU General Public License 9 | ## as published by the Free Software Foundation; either version 2, 10 | ## or (at your option) any later version. 11 | ## 12 | ## This program is distributed in the hope that it will be useful, 13 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | ## GNU General Public License for more details. 16 | ## 17 | ## You should have received a copy of the GNU General Public License 18 | ## along with this program; if not, write to the Free Software 19 | ## Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | ## 21 | 22 | SUBDIRS = os interp classlib 23 | DIST_SUBDIRS = os arch interp classlib 24 | 25 | bin_PROGRAMS = jamvm 26 | include_HEADERS = jni.h 27 | 28 | lib_LTLIBRARIES = libjvm.la 29 | noinst_LTLIBRARIES = libcore.la 30 | 31 | libcore_la_SOURCES = alloc.c alloc.h cast.c class.c dll.c excep.c execute.c \ 32 | frame.h hash.c hash.h jam.h jni.c lock.c lock.h \ 33 | natives.c reflect.c resolve.c sig.h string.c thread.c \ 34 | thread.h utf8.c zip.c zip.h properties.c natives.h \ 35 | dll_ffi.c access.c frame.c init.c hooks.c class.h \ 36 | symbol.c symbol.h excep.h shutdown.c time.c reflect.h \ 37 | jni-internal.h properties.h sig.c stubs.h stubs.c \ 38 | jni-stubs.c annotations.h 39 | 40 | jamvm_SOURCES = jam.c 41 | libjvm_la_SOURCES = 42 | 43 | jamvm_LDADD = libcore.la 44 | libjvm_la_LIBADD = libcore.la 45 | libjvm_la_LDFLAGS = -avoid-version 46 | libcore_la_LIBADD = interp/libinterp.la os/@os@/@arch@/libnative.la \ 47 | os/@os@/libos.la classlib/@classlib@/libclasslib.la 48 | 49 | AM_CPPFLAGS = -I$(top_srcdir)/src/interp/engine 50 | 51 | DISTCLEANFILES = arch.h classlib.h classlib-defs.h classlib-symbol.h \ 52 | classlib-excep.h 53 | -------------------------------------------------------------------------------- /src/jamvm/alloc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2009 3 | * Robert Lougher . 4 | * 5 | * This file is part of JamVM. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2, 10 | * or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | #define HEADER_SIZE sizeof(uintptr_t) 23 | #define LOG_OBJECT_GRAIN 3 24 | #define FLC_BIT 2 25 | 26 | #define HDR_ADDRESS(obj) (uintptr_t*)(((char*)obj)-HEADER_SIZE) 27 | 28 | #define clearFlcBit(obj) { \ 29 | uintptr_t *hdr_addr = HDR_ADDRESS(obj); \ 30 | *hdr_addr &= ~FLC_BIT; \ 31 | MBARRIER(); \ 32 | } 33 | 34 | #define setFlcBit(obj) { \ 35 | uintptr_t *hdr_addr = HDR_ADDRESS(obj); \ 36 | *hdr_addr |= FLC_BIT; \ 37 | MBARRIER(); \ 38 | } 39 | 40 | #define testFlcBit(obj) (*HDR_ADDRESS(obj) & FLC_BIT) 41 | 42 | #define isPlaceholderObj(obj) (obj->class == NULL) 43 | -------------------------------------------------------------------------------- /src/jamvm/annotations.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 Robert Lougher . 3 | * 4 | * This file is part of JamVM. 5 | * 6 | * This program is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License 8 | * as published by the Free Software Foundation; either version 2, 9 | * or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 19 | */ 20 | 21 | #define getClassAnnotationData(class) \ 22 | CLASS_EXTRA_ATTRIBUTES(class, class_annos) 23 | 24 | #define getClassTypeAnnotationData(class) \ 25 | CLASS_EXTRA_ATTRIBUTES(class, class_type_annos) 26 | 27 | #define getMethodAnnotationData(mb) \ 28 | METHOD_EXTRA_ATTRIBUTES(mb, method_annos) 29 | 30 | #define getMethodTypeAnnotationData(mb) \ 31 | METHOD_EXTRA_ATTRIBUTES(mb, method_type_annos) 32 | 33 | #define getMethodParameterAnnotationData(mb) \ 34 | METHOD_EXTRA_ATTRIBUTES(mb, method_parameter_annos) 35 | 36 | #define getMethodDefaultValueAnnotationData(mb) \ 37 | METHOD_EXTRA_ATTRIBUTES(mb, method_anno_default_val) 38 | 39 | #define getFieldAnnotationData(fb) \ 40 | FIELD_EXTRA_ATTRIBUTES(fb, field_annos) 41 | 42 | #define getFieldTypeAnnotationData(fb) \ 43 | FIELD_EXTRA_ATTRIBUTES(fb, field_type_annos) 44 | -------------------------------------------------------------------------------- /src/jamvm/arch/Makefile.am: -------------------------------------------------------------------------------- 1 | ## 2 | ## Copyright (C) 2003, 2004, 2005, 2006, 2007 3 | ## Robert Lougher . 4 | ## 5 | ## This file is part of JamVM. 6 | ## 7 | ## This program is free software; you can redistribute it and/or 8 | ## modify it under the terms of the GNU General Public License 9 | ## as published by the Free Software Foundation; either version 2, 10 | ## or (at your option) any later version. 11 | ## 12 | ## This program is distributed in the hope that it will be useful, 13 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | ## GNU General Public License for more details. 16 | ## 17 | ## You should have received a copy of the GNU General Public License 18 | ## along with this program; if not, write to the Free Software 19 | ## Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | ## 21 | 22 | EXTRA_DIST = powerpc.h arm.h i386.h x86_64.h parisc.h mips.h sparc.h 23 | -------------------------------------------------------------------------------- /src/jamvm/arch/arch.h: -------------------------------------------------------------------------------- 1 | #if defined(__arm__) 2 | #include "arm.h" 3 | #elif defined(__x86_64__) 4 | #include "x86_64.h" 5 | #elif defined(__i386__) 6 | #include "i386.h" 7 | #elif defined(__mips__) 8 | #include "mips.h" 9 | #elif defined(__powerpc__) 10 | #include "powerpc.h" 11 | #elif defined(__sparc__) 12 | #include "sparc.h" 13 | #else 14 | #error "Your CPU architecture is not defined, please check arch.h" 15 | #endif 16 | -------------------------------------------------------------------------------- /src/jamvm/arch/sparc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009 Robert Lougher . 3 | * 4 | * This file is part of JamVM. 5 | * 6 | * This program is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License 8 | * as published by the Free Software Foundation; either version 2, 9 | * or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 19 | */ 20 | 21 | #define OS_ARCH "sparc" 22 | 23 | #define HANDLER_TABLE_T static const void 24 | #define DOUBLE_1_BITS 0x3ff0000000000000LL 25 | 26 | #define READ_DBL(v,p,l) v = ((u8)p[0]<<56)|((u8)p[1]<<48)|((u8)p[2]<<40) \ 27 | |((u8)p[3]<<32)|((u8)p[4]<<24)|((u8)p[5]<<16) \ 28 | |((u8)p[6]<<8)|(u8)p[7]; p+=8; 29 | 30 | #define FPU_HACK 31 | 32 | #define FULL_MBAR() __asm__ __volatile__ ("membar #LoadLoad | #LoadStore"\ 33 | " | #StoreLoad | #StoreStore" : : : "memory") 34 | 35 | static inline uint32_t 36 | compare_and_swap_32(volatile uint32_t *addr, uint32_t oldval, uint32_t newval) 37 | { 38 | uint32_t result; 39 | FULL_MBAR(); 40 | __asm__ __volatile__ ("cas [%4], %2, %0" 41 | : "=r" (result), "=m" (*addr) 42 | : "r" (oldval), "m" (*addr), "r" (addr), 43 | "0" (newval)); 44 | return result == oldval; 45 | } 46 | 47 | #define COMPARE_AND_SWAP32 compare_and_swap_32 48 | 49 | static inline uint64_t 50 | compare_and_swap_64(volatile uint64_t *addr, uint64_t oldval, uint64_t newval) 51 | { 52 | uint64_t result; 53 | FULL_MBAR(); 54 | __asm__ __volatile__ ("casx [%4], %2, %0" 55 | : "=r" (result), "=m" (*addr) 56 | : "r" (oldval), "m" (*addr), "r" (addr), 57 | "0" (newval)); 58 | return result == oldval; 59 | } 60 | 61 | #define COMPARE_AND_SWAP64 compare_and_swap_64 62 | #ifdef __arch64__ 63 | # define COMPARE_AND_SWAP COMPARE_AND_SWAP64 64 | #else 65 | # define COMPARE_AND_SWAP COMPARE_AND_SWAP32 66 | #endif 67 | 68 | #define LOCKWORD_READ(addr) *addr 69 | #define LOCKWORD_WRITE(addr, value) *addr = value 70 | #define LOCKWORD_COMPARE_AND_SWAP COMPARE_AND_SWAP 71 | 72 | #define MBARRIER() FULL_MBAR() 73 | #define JMM_LOCK_MBARRIER() MBARRIER() 74 | #define JMM_UNLOCK_MBARRIER() MBARRIER() 75 | -------------------------------------------------------------------------------- /src/jamvm/cast.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2003, 2004, 2005, 2006, 2007 3 | * Robert Lougher . 4 | * 5 | * This file is part of JamVM. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2, 10 | * or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | #include "jam.h" 23 | 24 | char implements(Class *class, Class *test) { 25 | ClassBlock *test_cb = CLASS_CB(test); 26 | int i; 27 | 28 | for(i = 0; i < test_cb->interfaces_count; i++) 29 | if((class == test_cb->interfaces[i]) || 30 | implements(class, test_cb->interfaces[i])) 31 | return TRUE; 32 | 33 | if(test_cb->super) 34 | return implements(class, test_cb->super); 35 | 36 | return FALSE; 37 | } 38 | 39 | char isSubClassOf(Class *class, Class *test) { 40 | for(; test != NULL && test != class; test = CLASS_CB(test)->super); 41 | return test != NULL; 42 | } 43 | 44 | char isInstOfArray0(Class *array_class, Class *test_elem, int test_dim) { 45 | ClassBlock *array_cb = CLASS_CB(array_class); 46 | Class *array_elem = array_cb->element_class; 47 | 48 | if(test_dim == array_cb->dim) 49 | return isInstanceOf(array_elem, test_elem); 50 | 51 | if(test_dim > array_cb->dim) 52 | return IS_INTERFACE(CLASS_CB(array_elem)) ? 53 | implements(array_elem, array_class) : 54 | (array_elem == array_cb->super); 55 | 56 | return FALSE; 57 | } 58 | 59 | char isInstOfArray(Class *class, Class *test) { 60 | ClassBlock *test_cb = CLASS_CB(test); 61 | 62 | if(!IS_ARRAY(CLASS_CB(class))) 63 | return class == test_cb->super; 64 | 65 | return isInstOfArray0(class, test_cb->element_class, test_cb->dim); 66 | } 67 | 68 | char isInstanceOf(Class *class, Class *test) { 69 | if(class == test) 70 | return TRUE; 71 | 72 | if(IS_INTERFACE(CLASS_CB(class))) 73 | return implements(class, test); 74 | else 75 | if(IS_ARRAY(CLASS_CB(test))) 76 | return isInstOfArray(class, test); 77 | else 78 | return isSubClassOf(class, test); 79 | } 80 | 81 | char arrayStoreCheck(Class *array_class, Class *test) { 82 | ClassBlock *test_cb = CLASS_CB(test); 83 | 84 | if(!IS_ARRAY(test_cb)) 85 | return isInstOfArray0(array_class, test, 1); 86 | 87 | return isInstOfArray0(array_class, test_cb->element_class, test_cb->dim + 1); 88 | } 89 | -------------------------------------------------------------------------------- /src/jamvm/classlib/Makefile.am: -------------------------------------------------------------------------------- 1 | ## 2 | ## Copyright (C) 2010 Robert Lougher . 3 | ## 4 | ## This file is part of JamVM. 5 | ## 6 | ## This program is free software; you can redistribute it and/or 7 | ## modify it under the terms of the GNU General Public License 8 | ## as published by the Free Software Foundation; either version 2, 9 | ## or (at your option) any later version. 10 | ## 11 | ## This program is distributed in the hope that it will be useful, 12 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | ## GNU General Public License for more details. 15 | ## 16 | ## You should have received a copy of the GNU General Public License 17 | ## along with this program; if not, write to the Free Software 18 | ## Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 19 | ## 20 | 21 | SUBDIRS = @classlib@ 22 | DIST_SUBDIRS = gnuclasspath openjdk 23 | 24 | -------------------------------------------------------------------------------- /src/jamvm/classlib/gnuclasspath/Makefile.am: -------------------------------------------------------------------------------- 1 | ## 2 | ## Copyright (C) 2010, 2011, 2013 Robert Lougher . 3 | ## 4 | ## This file is part of JamVM. 5 | ## 6 | ## This program is free software; you can redistribute it and/or 7 | ## modify it under the terms of the GNU General Public License 8 | ## as published by the Free Software Foundation; either version 2, 9 | ## or (at your option) any later version. 10 | ## 11 | ## This program is distributed in the hope that it will be useful, 12 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | ## GNU General Public License for more details. 15 | ## 16 | ## You should have received a copy of the GNU General Public License 17 | ## along with this program; if not, write to the Free Software 18 | ## Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 19 | ## 20 | 21 | SUBDIRS = lib 22 | 23 | noinst_LTLIBRARIES = libclasslib.la 24 | libclasslib_la_SOURCES = thread.c class.c natives.c excep.c reflect.c \ 25 | dll.c jni.c properties.c annotations.c frame.c \ 26 | classlib.h classlib-symbol.h classlib-defs.h \ 27 | alloc.c gnuclasspath.h classlib-excep.h 28 | 29 | AM_CPPFLAGS = -I$(top_builddir)/src -I$(top_srcdir)/src 30 | -------------------------------------------------------------------------------- /src/jamvm/classlib/gnuclasspath/alloc.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Robert Lougher . 3 | * 4 | * This file is part of JamVM. 5 | * 6 | * This program is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License 8 | * as published by the Free Software Foundation; either version 2, 9 | * or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 19 | */ 20 | 21 | #include "jam.h" 22 | #include "thread.h" 23 | #include "gnuclasspath.h" 24 | 25 | #ifdef TRACEGC 26 | #define TRACE(fmt, ...) jam_printf(fmt, ## __VA_ARGS__) 27 | #else 28 | #define TRACE(fmt, ...) 29 | #endif 30 | 31 | void classlibMarkSpecial(Object *ob, int mark) { 32 | if(IS_VMTHROWABLE(CLASS_CB(ob->class))) { 33 | TRACE("Mark found VMThrowable object @%p\n", ob); 34 | markVMThrowable(ob, mark); 35 | } 36 | } 37 | 38 | void classlibHandleUnmarkedSpecial(Object *ob) { 39 | if(IS_VMTHREAD(CLASS_CB(ob->class))) { 40 | /* Free the native thread structure (see comment 41 | in detachThread (thread.c) */ 42 | TRACE("FREE: Freeing native thread for VMThread object %p\n", ob); 43 | gcPendingFree(vmThread2Thread(ob)); 44 | } 45 | } 46 | 47 | -------------------------------------------------------------------------------- /src/jamvm/classlib/gnuclasspath/classlib-defs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011, 2014 Robert Lougher . 3 | * 4 | * This file is part of JamVM. 5 | * 6 | * This program is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License 8 | * as published by the Free Software Foundation; either version 2, 9 | * or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 19 | */ 20 | 21 | #define VMTHREAD 512 22 | #define VMTHROWABLE 1024 23 | 24 | #define CLASSLIB_CLASS_SPECIAL (VMTHREAD | VMTHROWABLE) 25 | 26 | #define CLASSLIB_CLASS_PAD_SIZE 4*sizeof(Object*) 27 | 28 | #define CLASSLIB_CLASS_EXTRA_FIELDS \ 29 | /* NONE */ 30 | 31 | #define CLASSLIB_THREAD_EXTRA_FIELDS \ 32 | unsigned short state; 33 | 34 | #define CLASSLIB_CLASSBLOCK_REFS_DO(action, cb, ...) \ 35 | /* NONE */ 36 | -------------------------------------------------------------------------------- /src/jamvm/classlib/gnuclasspath/classlib-excep.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 Robert Lougher . 3 | * 4 | * This file is part of JamVM. 5 | * 6 | * This program is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License 8 | * as published by the Free Software Foundation; either version 2, 9 | * or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 19 | */ 20 | 21 | #define CLASSLIB_EXCEPTIONS_DO(action) 22 | -------------------------------------------------------------------------------- /src/jamvm/classlib/gnuclasspath/dll.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 Robert Lougher . 3 | * 4 | * This file is part of JamVM. 5 | * 6 | * This program is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License 8 | * as published by the Free Software Foundation; either version 2, 9 | * or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 19 | */ 20 | 21 | #include "jam.h" 22 | 23 | char *classlibDefaultBootDllPath() { 24 | return CLASSPATH_INSTALL_DIR"/lib/classpath"; 25 | } 26 | 27 | void *classlibLookupLoadedDlls(char *name, Object *loader) { 28 | return lookupLoadedDlls0(name, loader); 29 | } 30 | 31 | -------------------------------------------------------------------------------- /src/jamvm/classlib/gnuclasspath/excep.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010, 2011 Robert Lougher . 3 | * 4 | * This file is part of JamVM. 5 | * 6 | * This program is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License 8 | * as published by the Free Software Foundation; either version 2, 9 | * or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 19 | */ 20 | 21 | #include "jam.h" 22 | #include "symbol.h" 23 | 24 | static Class *vmthrow_class; 25 | static int backtrace_offset; 26 | 27 | int classlibInitialiseException(Class *throw_class) { 28 | FieldBlock *backtrace = NULL; 29 | 30 | vmthrow_class = findSystemClass0(SYMBOL(java_lang_VMThrowable)); 31 | if(vmthrow_class != NULL) 32 | backtrace = findField(vmthrow_class, SYMBOL(backtrace), 33 | SYMBOL(sig_java_lang_Object)); 34 | 35 | if(backtrace == NULL) { 36 | jam_fprintf(stderr, "Expected \"backtrace\" field missing in " 37 | "java.lang.VMThrowable\n"); 38 | return FALSE; 39 | } 40 | 41 | CLASS_CB(vmthrow_class)->flags |= VMTHROWABLE; 42 | backtrace_offset = backtrace->u.offset; 43 | 44 | registerStaticClassRef(&vmthrow_class); 45 | return TRUE; 46 | } 47 | 48 | Object *setStackTrace0(ExecEnv *ee, int max_depth) { 49 | Object *array = stackTrace(ee, max_depth); 50 | Object *vmthrwble = allocObject(vmthrow_class); 51 | 52 | if(vmthrwble != NULL) 53 | INST_DATA(vmthrwble, Object*, backtrace_offset) = array; 54 | 55 | return vmthrwble; 56 | } 57 | 58 | Object *convertStackTrace(Object *vmthrwble) { 59 | Object *array = INST_DATA(vmthrwble, Object*, backtrace_offset); 60 | 61 | if(array == NULL) 62 | return NULL; 63 | 64 | return stackTraceElements(array); 65 | } 66 | 67 | /* GC support for marking classes referenced by a VMThrowable. 68 | In rare circumstances a stack backtrace may hold the only 69 | reference to a class */ 70 | 71 | void markVMThrowable(Object *vmthrwble, int mark) { 72 | Object *array; 73 | 74 | if((array = INST_DATA(vmthrwble, Object*, backtrace_offset)) != NULL) { 75 | uintptr_t *src = ARRAY_DATA(array, uintptr_t); 76 | int i, depth = ARRAY_LEN(array); 77 | 78 | for(i = 0; i < depth; i += 2) { 79 | MethodBlock *mb = (MethodBlock*)src[i]; 80 | markObject(mb->class, mark); 81 | } 82 | } 83 | } 84 | 85 | -------------------------------------------------------------------------------- /src/jamvm/classlib/gnuclasspath/frame.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Robert Lougher . 3 | * 4 | * This file is part of JamVM. 5 | * 6 | * This program is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License 8 | * as published by the Free Software Foundation; either version 2, 9 | * or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 19 | */ 20 | 21 | #include "jam.h" 22 | #include "thread.h" 23 | #include "reflect.h" 24 | #include "gnuclasspath.h" 25 | 26 | /* The function classlibGetCallerFrame() is used in code that does 27 | security related stack-walking. It guards against invocation 28 | via reflection. These frames must be skipped, else it will 29 | appear that the caller was loaded by the boot loader. */ 30 | 31 | Frame *classlibGetCallerFrame(Frame *last, int depth) { 32 | for(;;) { 33 | /* Loop until the required number of frames have been skipped 34 | or we hit a dummy frame (top of this invocation) */ 35 | for(; last->mb != NULL; last = last->prev) 36 | if(depth-- <= 0) 37 | return last; 38 | 39 | /* Skip the dummy frame, and check if we're 40 | at the top of the stack */ 41 | if((last = last->prev)->prev == NULL) 42 | return NULL; 43 | 44 | /* Check if we were invoked via reflection */ 45 | if(last->mb->class == getReflectMethodClass()) { 46 | /* There will be two frames for invoke */ 47 | last = last->prev->prev; 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/jamvm/classlib/gnuclasspath/gnuclasspath.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Robert Lougher . 3 | * 4 | * This file is part of JamVM. 5 | * 6 | * This program is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License 8 | * as published by the Free Software Foundation; either version 2, 9 | * or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 19 | */ 20 | 21 | #define IS_VMTHREAD(cb) (cb->flags & VMTHREAD) 22 | #define IS_VMTHROWABLE(cb) (cb->flags & VMTHROWABLE) 23 | 24 | extern Object *getVMConsParamTypes(Object *vm_cons_obj); 25 | extern Object *getVMMethodParamTypes(Object *vm_method_obj); 26 | extern Class *getVMMethodReturnType(Object *vm_method_obj); 27 | extern Class *getVMFieldType(Object *vm_field_obj); 28 | 29 | extern MethodBlock *getVMConsMethodBlock(Object *cons_ref_obj); 30 | extern int getVMConsAccessFlag(Object *cons_ref_obj); 31 | extern MethodBlock *getVMMethodMethodBlock(Object *mthd_ref_obj); 32 | extern int getVMMethodAccessFlag(Object *mthd_ref_obj); 33 | extern FieldBlock *getVMFieldFieldBlock(Object *fld_ref_obj); 34 | extern int getVMFieldAccessFlag(Object *fld_ref_obj); 35 | 36 | extern Object *getClassAnnotations(Class *class); 37 | extern Object *getFieldAnnotations(FieldBlock *fb); 38 | extern Object *getMethodAnnotations(MethodBlock *mb); 39 | extern Object *getMethodParameterAnnotations(MethodBlock *mb); 40 | extern Object *getMethodDefaultValue(MethodBlock *mb); 41 | 42 | extern Class *getReflectMethodClass(); 43 | 44 | extern Thread *vmThread2Thread(Object *vmThread); 45 | extern void markVMThrowable(Object *vmthrwble, int mark); 46 | -------------------------------------------------------------------------------- /src/jamvm/classlib/gnuclasspath/lib/Makefile.am: -------------------------------------------------------------------------------- 1 | ## 2 | ## Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 3 | ## Robert Lougher . 4 | ## 5 | ## This file is part of JamVM. 6 | ## 7 | ## This program is free software; you can redistribute it and/or 8 | ## modify it under the terms of the GNU General Public License 9 | ## as published by the Free Software Foundation; either version 2, 10 | ## or (at your option) any later version. 11 | ## 12 | ## This program is distributed in the hope that it will be useful, 13 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | ## GNU General Public License for more details. 16 | ## 17 | ## You should have received a copy of the GNU General Public License 18 | ## along with this program; if not, write to the Free Software 19 | ## Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | ## 21 | 22 | CP_LIB_DIR = ${with_classpath_install_dir}/share/classpath 23 | GLIBJ_ZIP = ${CP_LIB_DIR}/glibj.zip 24 | 25 | SUBDIRS = jamvm java gnu sun 26 | EXTRA_DIST = classes.zip README 27 | 28 | noinst_DATA = inst_classes.zip 29 | 30 | JAVA_FILES = $(srcdir)/jamvm/java/lang/JarLauncher.java \ 31 | $(srcdir)/jamvm/java/lang/VMClassLoaderData.java \ 32 | $(srcdir)/jamvm/ThreadInfoHelper.java \ 33 | $(srcdir)/java/lang/VMRuntime.java \ 34 | $(srcdir)/java/lang/VMClass.java \ 35 | $(srcdir)/java/lang/VMClassLoader.java \ 36 | $(srcdir)/java/lang/VMString.java \ 37 | $(srcdir)/java/lang/VMThread.java \ 38 | $(srcdir)/java/lang/VMThrowable.java \ 39 | $(srcdir)/java/lang/reflect/VMConstructor.java \ 40 | $(srcdir)/java/lang/reflect/VMField.java \ 41 | $(srcdir)/java/lang/reflect/VMMethod.java \ 42 | $(srcdir)/java/security/VMAccessController.java \ 43 | $(srcdir)/gnu/classpath/VMSystemProperties.java \ 44 | $(srcdir)/sun/reflect/annotation/AnnotationInvocationHandler.java \ 45 | $(srcdir)/gnu/classpath/VMStackWalker.java 46 | 47 | 48 | inst_classes.zip: classes.zip 49 | ln -fs $< $@ 50 | 51 | classes.zip: $(JAVA_FILES) 52 | -mkdir classes 53 | $(JAVAC) -bootclasspath ${GLIBJ_ZIP} -d classes $(JAVA_FILES) 54 | cd classes && zip -r ../classes.zip . 55 | rm -rf classes 56 | 57 | install-data-local: 58 | $(mkinstalldirs) $(DESTDIR)$(pkgdatadir) 59 | @use_zip_yes@ cp -p inst_classes.zip $(DESTDIR)$(pkgdatadir)/classes.zip 60 | @use_zip_no@ unzip -o inst_classes.zip -d $(DESTDIR)$(pkgdatadir)/classes 61 | @use_zip_yes@ $(mkinstalldirs) $(DESTDIR)$(libdir) 62 | @use_zip_yes@ ln -fs $(GLIBJ_ZIP) $(DESTDIR)$(libdir)/rt.jar 63 | 64 | uninstall-local: 65 | rm -rf $(DESTDIR)$(pkgdatadir) 66 | rm $(DESTDIR)$(libdir)/rt.jar 67 | 68 | DISTCLEANFILES = inst_classes.zip 69 | -------------------------------------------------------------------------------- /src/jamvm/classlib/gnuclasspath/lib/README: -------------------------------------------------------------------------------- 1 | This directory contains JamVM's Jar launcher wrapper 2 | (jamvm.java.lang.JarLauncher) and the JamVM versions 3 | of the VM-specific classes required to work with GNU 4 | Classpath. Most of these are derived from the 5 | reference classes from GNU Classpath. 6 | 7 | The classes are distributed pre-built in classes.zip 8 | in order to simplify installation. The classes.zip 9 | archive will be automatically rebuilt if any Java 10 | sources are changed. Note, `jikes' must be present 11 | within your path, and Classpath must have already been 12 | built and installed as it requires glibj.zip. 13 | -------------------------------------------------------------------------------- /src/jamvm/classlib/gnuclasspath/lib/classes.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/libretro/libretro-JamVM/e767ea15478bfca8e193c7737b6f9d418700d1a5/src/jamvm/classlib/gnuclasspath/lib/classes.zip -------------------------------------------------------------------------------- /src/jamvm/classlib/gnuclasspath/lib/gnu/Makefile.am: -------------------------------------------------------------------------------- 1 | ## 2 | ## Copyright (C) 2003, 2004, 2005, 2006, 2007 3 | ## Robert Lougher . 4 | ## 5 | ## This file is part of JamVM. 6 | ## 7 | ## This program is free software; you can redistribute it and/or 8 | ## modify it under the terms of the GNU General Public License 9 | ## as published by the Free Software Foundation; either version 2, 10 | ## or (at your option) any later version. 11 | ## 12 | ## This program is distributed in the hope that it will be useful, 13 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | ## GNU General Public License for more details. 16 | ## 17 | ## You should have received a copy of the GNU General Public License 18 | ## along with this program; if not, write to the Free Software 19 | ## Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | ## 21 | 22 | SUBDIRS = classpath 23 | 24 | -------------------------------------------------------------------------------- /src/jamvm/classlib/gnuclasspath/lib/gnu/classpath/Makefile.am: -------------------------------------------------------------------------------- 1 | ## 2 | ## Copyright (C) 2003, 2004, 2005, 2006, 2007 3 | ## Robert Lougher . 4 | ## 5 | ## This file is part of JamVM. 6 | ## 7 | ## This program is free software; you can redistribute it and/or 8 | ## modify it under the terms of the GNU General Public License 9 | ## as published by the Free Software Foundation; either version 2, 10 | ## or (at your option) any later version. 11 | ## 12 | ## This program is distributed in the hope that it will be useful, 13 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | ## GNU General Public License for more details. 16 | ## 17 | ## You should have received a copy of the GNU General Public License 18 | ## along with this program; if not, write to the Free Software 19 | ## Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | ## 21 | 22 | EXTRA_DIST = \ 23 | VMSystemProperties.java \ 24 | VMStackWalker.java 25 | -------------------------------------------------------------------------------- /src/jamvm/classlib/gnuclasspath/lib/jamvm/Makefile.am: -------------------------------------------------------------------------------- 1 | ## 2 | ## Copyright (C) 2003, 2004, 2005, 2006, 2007, 2009 3 | ## Robert Lougher . 4 | ## 5 | ## This file is part of JamVM. 6 | ## 7 | ## This program is free software; you can redistribute it and/or 8 | ## modify it under the terms of the GNU General Public License 9 | ## as published by the Free Software Foundation; either version 2, 10 | ## or (at your option) any later version. 11 | ## 12 | ## This program is distributed in the hope that it will be useful, 13 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | ## GNU General Public License for more details. 16 | ## 17 | ## You should have received a copy of the GNU General Public License 18 | ## along with this program; if not, write to the Free Software 19 | ## Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | ## 21 | 22 | SUBDIRS = java 23 | 24 | EXTRA_DIST = \ 25 | ThreadInfoHelper.java 26 | -------------------------------------------------------------------------------- /src/jamvm/classlib/gnuclasspath/lib/jamvm/ThreadInfoHelper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009 Robert Lougher . 3 | * 4 | * This file is part of JamVM. 5 | * 6 | * This program is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License 8 | * as published by the Free Software Foundation; either version 2, 9 | * or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 19 | */ 20 | 21 | package jamvm; 22 | 23 | class ThreadInfoHelper { 24 | static Object[] createThreadInfo(Thread thread, Object lock, 25 | Thread lockOwner) { 26 | 27 | String lockName = null; 28 | String lockOwnerName = null; 29 | 30 | if(lock != null) { 31 | lockName = lock.getClass().getName() + "@" + 32 | Integer.toHexString(System.identityHashCode(lock)); 33 | if(lockOwner != null) 34 | lockOwnerName = lockOwner.getName(); 35 | } 36 | 37 | return new Object[] {thread.getName(), thread.getState(), 38 | lockName, lockOwnerName}; 39 | } 40 | } 41 | 42 | -------------------------------------------------------------------------------- /src/jamvm/classlib/gnuclasspath/lib/jamvm/java/Makefile.am: -------------------------------------------------------------------------------- 1 | ## 2 | ## Copyright (C) 2003, 2004, 2005, 2006, 2007 3 | ## Robert Lougher . 4 | ## 5 | ## This file is part of JamVM. 6 | ## 7 | ## This program is free software; you can redistribute it and/or 8 | ## modify it under the terms of the GNU General Public License 9 | ## as published by the Free Software Foundation; either version 2, 10 | ## or (at your option) any later version. 11 | ## 12 | ## This program is distributed in the hope that it will be useful, 13 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | ## GNU General Public License for more details. 16 | ## 17 | ## You should have received a copy of the GNU General Public License 18 | ## along with this program; if not, write to the Free Software 19 | ## Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | ## 21 | 22 | SUBDIRS = lang 23 | -------------------------------------------------------------------------------- /src/jamvm/classlib/gnuclasspath/lib/jamvm/java/lang/JarLauncher.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2003, 2004, 2006, 2008 Robert Lougher . 3 | * 4 | * This file is part of JamVM. 5 | * 6 | * This program is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License 8 | * as published by the Free Software Foundation; either version 2, 9 | * or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 19 | */ 20 | 21 | package jamvm.java.lang; 22 | 23 | import java.util.jar.JarFile; 24 | import java.util.jar.Manifest; 25 | import java.util.jar.Attributes.Name; 26 | import java.lang.reflect.Method; 27 | 28 | public class JarLauncher { 29 | public static void main(String[] args) { 30 | String jarFile = System.getProperty("java.class.path", null); 31 | 32 | try { 33 | JarFile jar = new JarFile(jarFile); 34 | Manifest manifest = jar.getManifest(); 35 | 36 | if(manifest == null) 37 | System.err.println("Couldn't read manifest from " + jar.getName() + " (invalid jar file?)."); 38 | else { 39 | String mainAttr = manifest.getMainAttributes().getValue(Name.MAIN_CLASS); 40 | 41 | if(mainAttr == null) 42 | System.err.println("Couldn't find Main-Class attribute in " + 43 | jar.getName() + " Manifest."); 44 | else { 45 | ClassLoader sysLoader = ClassLoader.getSystemClassLoader(); 46 | Class mainClass = Class.forName(mainAttr, true, sysLoader); 47 | Method meth = mainClass.getMethod("main", new Class[] {args.getClass()}); 48 | 49 | meth.setAccessible(true); 50 | meth.invoke(null, new Object[] {args}); 51 | } 52 | } 53 | } catch(Exception e) { 54 | e.printStackTrace(); 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/jamvm/classlib/gnuclasspath/lib/jamvm/java/lang/Makefile.am: -------------------------------------------------------------------------------- 1 | ## 2 | ## Copyright (C) 2003, 2004, 2005, 2006, 2007 3 | ## Robert Lougher . 4 | ## 5 | ## This file is part of JamVM. 6 | ## 7 | ## This program is free software; you can redistribute it and/or 8 | ## modify it under the terms of the GNU General Public License 9 | ## as published by the Free Software Foundation; either version 2, 10 | ## or (at your option) any later version. 11 | ## 12 | ## This program is distributed in the hope that it will be useful, 13 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | ## GNU General Public License for more details. 16 | ## 17 | ## You should have received a copy of the GNU General Public License 18 | ## along with this program; if not, write to the Free Software 19 | ## Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | ## 21 | 22 | EXTRA_DIST = \ 23 | JarLauncher.java \ 24 | VMClassLoaderData.java 25 | -------------------------------------------------------------------------------- /src/jamvm/classlib/gnuclasspath/lib/jamvm/java/lang/VMClassLoaderData.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 Robert Lougher . 3 | * 4 | * This file is part of JamVM. 5 | * 6 | * This program is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License 8 | * as published by the Free Software Foundation; either version 2, 9 | * or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 19 | */ 20 | 21 | package jamvm.java.lang; 22 | import java.util.ArrayList; 23 | 24 | public class VMClassLoaderData { 25 | ArrayList unloaders; 26 | long hashtable; 27 | 28 | synchronized void newLibraryUnloader(long dllEntry) { 29 | if(unloaders == null) 30 | unloaders = new ArrayList(4); 31 | 32 | unloaders.add(new Unloader(dllEntry)); 33 | } 34 | 35 | private static class Unloader { 36 | long dllEntry; 37 | 38 | Unloader(long entry) { 39 | dllEntry = entry; 40 | } 41 | 42 | public void finalize() { 43 | nativeUnloadDll(dllEntry); 44 | } 45 | 46 | native void nativeUnloadDll(long dllEntry); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/jamvm/classlib/gnuclasspath/lib/java/Makefile.am: -------------------------------------------------------------------------------- 1 | ## 2 | ## Copyright (C) 2003, 2004, 2005, 2006, 2007 3 | ## Robert Lougher . 4 | ## 5 | ## This file is part of JamVM. 6 | ## 7 | ## This program is free software; you can redistribute it and/or 8 | ## modify it under the terms of the GNU General Public License 9 | ## as published by the Free Software Foundation; either version 2, 10 | ## or (at your option) any later version. 11 | ## 12 | ## This program is distributed in the hope that it will be useful, 13 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | ## GNU General Public License for more details. 16 | ## 17 | ## You should have received a copy of the GNU General Public License 18 | ## along with this program; if not, write to the Free Software 19 | ## Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | ## 21 | 22 | SUBDIRS = lang security 23 | 24 | -------------------------------------------------------------------------------- /src/jamvm/classlib/gnuclasspath/lib/java/lang/Makefile.am: -------------------------------------------------------------------------------- 1 | ## 2 | ## Copyright (C) 2003, 2004, 2005, 2006, 2007 3 | ## Robert Lougher . 4 | ## 5 | ## This file is part of JamVM. 6 | ## 7 | ## This program is free software; you can redistribute it and/or 8 | ## modify it under the terms of the GNU General Public License 9 | ## as published by the Free Software Foundation; either version 2, 10 | ## or (at your option) any later version. 11 | ## 12 | ## This program is distributed in the hope that it will be useful, 13 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | ## GNU General Public License for more details. 16 | ## 17 | ## You should have received a copy of the GNU General Public License 18 | ## along with this program; if not, write to the Free Software 19 | ## Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | ## 21 | 22 | SUBDIRS = reflect 23 | 24 | EXTRA_DIST = \ 25 | VMRuntime.java \ 26 | VMClass.java \ 27 | VMClassLoader.java \ 28 | VMString.java \ 29 | VMThread.java \ 30 | VMThrowable.java 31 | -------------------------------------------------------------------------------- /src/jamvm/classlib/gnuclasspath/lib/java/lang/VMString.java: -------------------------------------------------------------------------------- 1 | package java.lang; 2 | 3 | /** 4 | * Helper class for String, to abstract VM-specifics. 5 | * 6 | * @author Robert Lougher 7 | */ 8 | final class VMString 9 | { 10 | /** 11 | * JamVM uses its own internal String hashtable which is much 12 | * faster than the reference Classpath implementation. 13 | * 14 | * @param s the String to intern 15 | * @return existing interned string or s 16 | */ 17 | static native String intern(String s); 18 | } 19 | -------------------------------------------------------------------------------- /src/jamvm/classlib/gnuclasspath/lib/java/lang/reflect/Makefile.am: -------------------------------------------------------------------------------- 1 | ## 2 | ## Copyright (C) 2003, 2004, 2005, 2006, 2007 3 | ## Robert Lougher . 4 | ## 5 | ## This file is part of JamVM. 6 | ## 7 | ## This program is free software; you can redistribute it and/or 8 | ## modify it under the terms of the GNU General Public License 9 | ## as published by the Free Software Foundation; either version 2, 10 | ## or (at your option) any later version. 11 | ## 12 | ## This program is distributed in the hope that it will be useful, 13 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | ## GNU General Public License for more details. 16 | ## 17 | ## You should have received a copy of the GNU General Public License 18 | ## along with this program; if not, write to the Free Software 19 | ## Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | ## 21 | 22 | EXTRA_DIST = \ 23 | VMConstructor.java \ 24 | VMMethod.java \ 25 | VMField.java 26 | -------------------------------------------------------------------------------- /src/jamvm/classlib/gnuclasspath/lib/java/security/Makefile.am: -------------------------------------------------------------------------------- 1 | ## 2 | ## Copyright (C) 2003, 2004, 2005, 2006, 2007 3 | ## Robert Lougher . 4 | ## 5 | ## This file is part of JamVM. 6 | ## 7 | ## This program is free software; you can redistribute it and/or 8 | ## modify it under the terms of the GNU General Public License 9 | ## as published by the Free Software Foundation; either version 2, 10 | ## or (at your option) any later version. 11 | ## 12 | ## This program is distributed in the hope that it will be useful, 13 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | ## GNU General Public License for more details. 16 | ## 17 | ## You should have received a copy of the GNU General Public License 18 | ## along with this program; if not, write to the Free Software 19 | ## Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | ## 21 | 22 | EXTRA_DIST = \ 23 | VMAccessController.java 24 | -------------------------------------------------------------------------------- /src/jamvm/classlib/gnuclasspath/lib/sun/Makefile.am: -------------------------------------------------------------------------------- 1 | ## 2 | ## Copyright (C) 2003, 2004, 2005, 2006, 2007 3 | ## Robert Lougher . 4 | ## 5 | ## This file is part of JamVM. 6 | ## 7 | ## This program is free software; you can redistribute it and/or 8 | ## modify it under the terms of the GNU General Public License 9 | ## as published by the Free Software Foundation; either version 2, 10 | ## or (at your option) any later version. 11 | ## 12 | ## This program is distributed in the hope that it will be useful, 13 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | ## GNU General Public License for more details. 16 | ## 17 | ## You should have received a copy of the GNU General Public License 18 | ## along with this program; if not, write to the Free Software 19 | ## Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | ## 21 | 22 | SUBDIRS = reflect 23 | -------------------------------------------------------------------------------- /src/jamvm/classlib/gnuclasspath/lib/sun/reflect/Makefile.am: -------------------------------------------------------------------------------- 1 | ## 2 | ## Copyright (C) 2003, 2004, 2005, 2006, 2007 3 | ## Robert Lougher . 4 | ## 5 | ## This file is part of JamVM. 6 | ## 7 | ## This program is free software; you can redistribute it and/or 8 | ## modify it under the terms of the GNU General Public License 9 | ## as published by the Free Software Foundation; either version 2, 10 | ## or (at your option) any later version. 11 | ## 12 | ## This program is distributed in the hope that it will be useful, 13 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | ## GNU General Public License for more details. 16 | ## 17 | ## You should have received a copy of the GNU General Public License 18 | ## along with this program; if not, write to the Free Software 19 | ## Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | ## 21 | 22 | SUBDIRS = annotation 23 | -------------------------------------------------------------------------------- /src/jamvm/classlib/gnuclasspath/lib/sun/reflect/annotation/Makefile.am: -------------------------------------------------------------------------------- 1 | ## 2 | ## Copyright (C) 2003, 2004, 2005, 2006, 2007 3 | ## Robert Lougher . 4 | ## 5 | ## This file is part of JamVM. 6 | ## 7 | ## This program is free software; you can redistribute it and/or 8 | ## modify it under the terms of the GNU General Public License 9 | ## as published by the Free Software Foundation; either version 2, 10 | ## or (at your option) any later version. 11 | ## 12 | ## This program is distributed in the hope that it will be useful, 13 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | ## GNU General Public License for more details. 16 | ## 17 | ## You should have received a copy of the GNU General Public License 18 | ## along with this program; if not, write to the Free Software 19 | ## Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | ## 21 | 22 | EXTRA_DIST = \ 23 | AnnotationInvocationHandler.java 24 | -------------------------------------------------------------------------------- /src/jamvm/classlib/gnuclasspath/properties.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010, 2011 Robert Lougher . 3 | * 4 | * This file is part of JamVM. 5 | * 6 | * This program is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License 8 | * as published by the Free Software Foundation; either version 2, 9 | * or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 19 | */ 20 | 21 | #include "jam.h" 22 | #include "properties.h" 23 | 24 | char *classlibDefaultJavaHome() { 25 | return INSTALL_DIR; 26 | } 27 | 28 | void classlibAddDefaultProperties(Object *properties) { 29 | setProperty(properties, "java.runtime.version", VERSION); 30 | setProperty(properties, "java.version", JAVA_COMPAT_VERSION); 31 | setProperty(properties, "java.vendor", "GNU Classpath"); 32 | setProperty(properties, "java.vendor.url", "http://www.classpath.org"); 33 | setProperty(properties, "java.specification.version", "1.5"); 34 | setProperty(properties, "java.specification.vendor", 35 | "Sun Microsystems Inc."); 36 | setProperty(properties, "java.specification.name", 37 | "Java Platform API Specification"); 38 | setProperty(properties, "java.class.version", "48.0"); 39 | setProperty(properties, "java.boot.class.path", getBootClassPath()); 40 | setProperty(properties, "gnu.classpath.boot.library.path", 41 | getBootDllPath()); 42 | setProperty(properties, "gnu.cpu.endian", 43 | IS_BIG_ENDIAN ? "big" : "little"); 44 | } 45 | 46 | -------------------------------------------------------------------------------- /src/jamvm/classlib/openjdk/Makefile.am: -------------------------------------------------------------------------------- 1 | ## 2 | ## Copyright (C) 2010, 2011, 2012, 2013 Robert Lougher . 3 | ## 4 | ## This file is part of JamVM. 5 | ## 6 | ## This program is free software; you can redistribute it and/or 7 | ## modify it under the terms of the GNU General Public License 8 | ## as published by the Free Software Foundation; either version 2, 9 | ## or (at your option) any later version. 10 | ## 11 | ## This program is distributed in the hope that it will be useful, 12 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | ## GNU General Public License for more details. 15 | ## 16 | ## You should have received a copy of the GNU General Public License 17 | ## along with this program; if not, write to the Free Software 18 | ## Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 19 | ## 20 | 21 | noinst_LTLIBRARIES = libclasslib.la 22 | libclasslib_la_SOURCES = thread.c class.c natives.c excep.c reflect.c \ 23 | dll.c jni.c jvm.c properties.c openjdk.h \ 24 | trace.h management.c jmm.h access.c frame.c \ 25 | classlib.h classlib-symbol.h classlib-defs.h \ 26 | shutdown.c alloc.c perf.c mh.c classlib-excep.h 27 | 28 | AM_CPPFLAGS = -I$(top_builddir)/src -I$(top_srcdir)/src 29 | -------------------------------------------------------------------------------- /src/jamvm/classlib/openjdk/access.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010, 2012, 2013, 2014 Robert Lougher . 3 | * 4 | * This file is part of JamVM. 5 | * 6 | * This program is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License 8 | * as published by the Free Software Foundation; either version 2, 9 | * or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 19 | */ 20 | 21 | #include "jam.h" 22 | #include "symbol.h" 23 | 24 | static Class *magic_accessor; 25 | 26 | int classlibInitialiseAccess() { 27 | magic_accessor = findSystemClass0(SYMBOL(sun_reflect_MagicAccessorImpl)); 28 | if(magic_accessor == NULL) 29 | return FALSE; 30 | 31 | registerStaticClassRef(&magic_accessor); 32 | return TRUE; 33 | } 34 | 35 | int classlibAccessCheck(Class *class, Class *referrer) { 36 | Class *host_class = CLASS_CB(referrer)->host_class; 37 | 38 | if(host_class != NULL) { 39 | while(CLASS_CB(host_class)->host_class != NULL) 40 | host_class = CLASS_CB(host_class)->host_class; 41 | 42 | if(host_class == class) 43 | return TRUE; 44 | } 45 | 46 | return isSubClassOf(magic_accessor, referrer); 47 | } 48 | 49 | -------------------------------------------------------------------------------- /src/jamvm/classlib/openjdk/alloc.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Robert Lougher . 3 | * 4 | * This file is part of JamVM. 5 | * 6 | * This program is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License 8 | * as published by the Free Software Foundation; either version 2, 9 | * or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 19 | */ 20 | 21 | #include "jam.h" 22 | #include "thread.h" 23 | #include "openjdk.h" 24 | 25 | #ifdef TRACEGC 26 | #define TRACE(fmt, ...) jam_printf(fmt, ## __VA_ARGS__) 27 | #else 28 | #define TRACE(fmt, ...) 29 | #endif 30 | 31 | void classlibHandleUnmarkedSpecial(Object *ob) { 32 | if(IS_JTHREAD(CLASS_CB(ob->class))) { 33 | /* Free the native thread structure (see comment 34 | in detachThread (thread.c) */ 35 | TRACE("FREE: Freeing native thread for java thread object %p\n", ob); 36 | gcPendingFree(jThread2Thread(ob)); 37 | } 38 | } 39 | 40 | -------------------------------------------------------------------------------- /src/jamvm/classlib/openjdk/classlib-defs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011, 2013, 2014 Robert Lougher . 3 | * 4 | * This file is part of JamVM. 5 | * 6 | * This program is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License 8 | * as published by the Free Software Foundation; either version 2, 9 | * or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 19 | */ 20 | 21 | #define JTHREAD 512 22 | #define CLASSLIB_CLASS_SPECIAL JTHREAD 23 | 24 | #if OPENJDK_VERSION == 8 25 | #define CLASSLIB_CLASS_PAD_SIZE 10*sizeof(Object*)+1*sizeof(int) 26 | #elif OPENJDK_VERSION == 7 27 | #define CLASSLIB_CLASS_PAD_SIZE 18*sizeof(Object*)+2*sizeof(int) 28 | #else 29 | #define CLASSLIB_CLASS_PAD_SIZE 17*sizeof(Object*)+2*sizeof(int) 30 | #endif 31 | 32 | #define CLASSLIB_CLASS_EXTRA_FIELDS \ 33 | Object *protection_domain; \ 34 | Object *host_class; \ 35 | Object *signers; 36 | 37 | #define CLASSLIB_THREAD_EXTRA_FIELDS \ 38 | /* NONE */ 39 | 40 | #define CLASSLIB_CLASSBLOCK_REFS_DO(action, cb, ...) \ 41 | action(cb, protection_domain, ## __VA_ARGS__); \ 42 | action(cb, host_class, ## __VA_ARGS__); \ 43 | action(cb, signers, ## __VA_ARGS__) 44 | 45 | #ifdef JSR292 46 | #define ID_invokeGeneric (MB_PREPARED + 1) 47 | #define ID_invokeBasic (MB_PREPARED + 2) 48 | #define ID_linkToStatic (MB_PREPARED + 3) 49 | #define ID_linkToSpecial (MB_PREPARED + 4) 50 | #define ID_linkToVirtual (MB_PREPARED + 5) 51 | #define ID_linkToInterface (MB_PREPARED + 6) 52 | 53 | #define mbPolymorphicNameID(mb) mb->state 54 | 55 | typedef struct cached_poly_offsets { 56 | int mem_name_vmtarget; 57 | int lmda_form_vmentry; 58 | int mthd_hndl_form; 59 | } CachedPolyOffsets; 60 | 61 | #define CLASSLIB_METHOD_ANNOTATIONS(mb, type_name) { \ 62 | if(type_name == SYMBOL(sig_sun_reflect_CallerSensitive)) \ 63 | mb->flags |= MB_CALLER_SENSITIVE; \ 64 | else if(type_name == SYMBOL(sig_java_lang_invoke_LambdaForm_Hidden)) \ 65 | mb->flags |= MB_LAMBDA_HIDDEN; \ 66 | else if(type_name == SYMBOL(sig_java_lang_invoke_LambdaForm_Compiled)) \ 67 | mb->flags |= MB_LAMBDA_COMPILED; \ 68 | } 69 | #endif 70 | -------------------------------------------------------------------------------- /src/jamvm/classlib/openjdk/classlib-excep.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2013 Robert Lougher . 3 | * 4 | * This file is part of JamVM. 5 | * 6 | * This program is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License 8 | * as published by the Free Software Foundation; either version 2, 9 | * or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 19 | */ 20 | 21 | #ifdef JSR292 22 | #define CLASSLIB_EXCEPTIONS_DO(action) \ 23 | action(java_lang_BootstrapMethodError), 24 | #else 25 | #define CLASSLIB_EXCEPTIONS_DO(action) 26 | #endif 27 | 28 | -------------------------------------------------------------------------------- /src/jamvm/classlib/openjdk/dll.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010, 2011 Robert Lougher . 3 | * 4 | * This file is part of JamVM. 5 | * 6 | * This program is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License 8 | * as published by the Free Software Foundation; either version 2, 9 | * or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 19 | */ 20 | 21 | #include 22 | 23 | #include "jam.h" 24 | #include "symbol.h" 25 | 26 | static MethodBlock *findNative_mb; 27 | 28 | int classlibInitialiseDll() { 29 | Class *ldr_class = findSystemClass0(SYMBOL(java_lang_ClassLoader)); 30 | 31 | if(ldr_class != NULL) 32 | findNative_mb = findMethod(ldr_class, SYMBOL(findNative), 33 | SYMBOL(_java_lang_ClassLoader_java_lang_String__J)); 34 | 35 | if(findNative_mb == NULL) { 36 | jam_fprintf(stderr, "Expected \"findNative\" method missing " 37 | "in java.lang.ClassLoader\n"); 38 | return FALSE; 39 | } 40 | 41 | return TRUE; 42 | } 43 | 44 | char *classlibDefaultBootDllPath() { 45 | char *java_home = getJavaHome(); 46 | char *dll_path = sysMalloc(strlen(java_home) + sizeof("/lib/"OS_ARCH)); 47 | 48 | return strcat(strcpy(dll_path, java_home), "/lib/"OS_ARCH); 49 | } 50 | 51 | void *classlibLookupLoadedDlls(char *name, Object *loader) { 52 | Object *name_string; 53 | 54 | if(loader == NULL) { 55 | void *address = lookupLoadedDlls0(name, NULL); 56 | 57 | if(address != NULL) 58 | return address; 59 | } 60 | 61 | if((name_string = createString(name)) != NULL) { 62 | int64_t ret = *(int64_t*)executeStaticMethod(findNative_mb->class, 63 | findNative_mb, 64 | loader, 65 | name_string); 66 | 67 | return (void *)(uintptr_t)ret; 68 | } 69 | 70 | return NULL; 71 | } 72 | 73 | -------------------------------------------------------------------------------- /src/jamvm/classlib/openjdk/excep.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010, 2011 Robert Lougher . 3 | * 4 | * This file is part of JamVM. 5 | * 6 | * This program is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License 8 | * as published by the Free Software Foundation; either version 2, 9 | * or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 19 | */ 20 | 21 | #include "jam.h" 22 | #include "symbol.h" 23 | 24 | static int backtrace_offset; 25 | 26 | int classlibInitialiseException(Class *throw_class) { 27 | 28 | FieldBlock *backtrace = findField(throw_class, SYMBOL(backtrace), 29 | SYMBOL(sig_java_lang_Object)); 30 | 31 | if(backtrace == NULL) { 32 | jam_fprintf(stderr, "Expected \"backtrace\" field missing in " 33 | "java.lang.Throwable\n"); 34 | return FALSE; 35 | } 36 | 37 | backtrace_offset = backtrace->u.offset; 38 | return TRUE; 39 | } 40 | 41 | void fillInStackTrace(Object *thrwble) { 42 | Object *array = stackTrace(getExecEnv(), INT_MAX); 43 | INST_DATA(thrwble, Object*, backtrace_offset) = array; 44 | } 45 | 46 | int stackTraceDepth(Object *thrwble) { 47 | Object *array; 48 | 49 | if((array = INST_DATA(thrwble, Object*, backtrace_offset)) == NULL) 50 | return 0; 51 | 52 | return ARRAY_LEN(array)/2; 53 | } 54 | 55 | Object *stackTraceElementAtIndex(Object *thrwble, int index) { 56 | CodePntr pc; 57 | Object *array; 58 | MethodBlock *mb; 59 | 60 | if((array = INST_DATA(thrwble, Object*, backtrace_offset)) == NULL) 61 | return NULL; 62 | 63 | mb = ARRAY_DATA(array, MethodBlock*)[index * 2]; 64 | pc = ARRAY_DATA(array, CodePntr)[index * 2 + 1]; 65 | 66 | return stackTraceElement(mb, pc); 67 | } 68 | -------------------------------------------------------------------------------- /src/jamvm/classlib/openjdk/frame.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011, 2012, 2013 Robert Lougher . 3 | * 4 | * This file is part of JamVM. 5 | * 6 | * This program is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License 8 | * as published by the Free Software Foundation; either version 2, 9 | * or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 19 | */ 20 | 21 | #include "jam.h" 22 | #include "symbol.h" 23 | 24 | static Class *cons_accessor; 25 | static Class *method_accessor; 26 | 27 | /* Defined in reflect.c */ 28 | extern MethodBlock *mthd_invoke_mb; 29 | 30 | int classlibInitialiseFrame() { 31 | method_accessor = findSystemClass0(SYMBOL(sun_reflect_MethodAccessorImpl)); 32 | cons_accessor = findSystemClass0(SYMBOL(sun_reflect_ConstructorAccessorImpl)); 33 | 34 | if(method_accessor == NULL || cons_accessor == NULL) 35 | return FALSE; 36 | 37 | registerStaticClassRef(&cons_accessor); 38 | registerStaticClassRef(&method_accessor); 39 | 40 | return TRUE; 41 | } 42 | 43 | int classlibIsSkippedReflectFrame(Frame *frame) { 44 | 45 | return isSubClassOf(cons_accessor, frame->mb->class) || 46 | isSubClassOf(method_accessor, frame->mb->class); 47 | } 48 | 49 | /* The function classlibGetCallerFrame() is used in code that does 50 | security related stack-walking. It guards against invocation 51 | via reflection. These frames must be skipped, else it will 52 | appear that the caller was loaded by the boot loader. */ 53 | 54 | Frame *classlibGetCallerFrame(Frame *last, int depth) { 55 | do { 56 | for(; last->mb != NULL; last = last->prev) 57 | if(!isSubClassOf(method_accessor, last->mb->class) 58 | && !(last->mb->flags & MB_LAMBDA_COMPILED) 59 | && last->mb != mthd_invoke_mb 60 | && depth-- <= 0) 61 | return last; 62 | } while((last = last->prev)->prev != NULL); 63 | 64 | return NULL; 65 | } 66 | 67 | -------------------------------------------------------------------------------- /src/jamvm/classlib/openjdk/openjdk.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010, 2011, 2013 Robert Lougher . 3 | * 4 | * This file is part of JamVM. 5 | * 6 | * This program is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License 8 | * as published by the Free Software Foundation; either version 2, 9 | * or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 19 | */ 20 | 21 | #define IS_JTHREAD(cb) (cb->flags & JTHREAD) 22 | 23 | extern void fillInStackTrace(Object *); 24 | extern Object *consNewInstance(Object *reflect_ob, Object *args_array); 25 | extern Object *invokeMethod(Object *reflect_ob, Object *ob, Object *args_array); 26 | 27 | extern int stackTraceDepth(Object *thrwble); 28 | extern Object *stackTraceElementAtIndex(Object *thrwble, int index); 29 | 30 | extern int initialiseJVMInterface(); 31 | extern Object *enclosingMethodInfo(Class *class); 32 | extern Object *getAnnotationsAsArray(AttributeData *annotations); 33 | 34 | extern int typeNo2PrimTypeIndex(int type_no); 35 | extern int primTypeIndex2Size(int prim_idx); 36 | extern char primClass2TypeChar(Class *prim); 37 | extern int widenPrimitiveElement(int src_idx, int dst_idx, 38 | void *src_addr, void *dst_addr); 39 | 40 | extern int jThreadIsAlive(Object *jthread); 41 | extern void *getJMMInterface(int version); 42 | 43 | extern void initialiseMethodHandles(); 44 | extern void expandMemberName(Object *mname); 45 | extern void initMemberName(Object *mname, Object *target); 46 | extern long long memNameFieldOffset(Object *mname); 47 | extern long long memNameStaticFieldOffset(Object *mname); 48 | extern void setCallSiteTargetNormal(Object *call_site, Object *target); 49 | extern void setCallSiteTargetVolatile(Object *call_site, Object *target); 50 | extern int getMembers(Class *clazz, Object *match_name, Object *match_sig, 51 | int match_flags, Class *caller, int skip, 52 | Object *results); 53 | extern Object *resolveMemberName(Class *mh_class, Object *mname); 54 | 55 | extern Object *getMethodParameters(Object *method); 56 | -------------------------------------------------------------------------------- /src/jamvm/classlib/openjdk/perf.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012 Robert Lougher . 3 | * 4 | * This file is part of JamVM. 5 | * 6 | * This program is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License 8 | * as published by the Free Software Foundation; either version 2, 9 | * or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 19 | */ 20 | 21 | #include "jam.h" 22 | #include "hash.h" 23 | #include "class.h" 24 | #include "thread.h" 25 | #include "natives.h" 26 | #include "classlib.h" 27 | 28 | uintptr_t *registerNatives(Class *class, MethodBlock *mb, uintptr_t *ostack) { 29 | return ostack; 30 | } 31 | 32 | uintptr_t *highResFrequency(Class *class, MethodBlock *mb, uintptr_t *ostack) { 33 | *(long long*)ostack = 0; 34 | return ostack + 2; 35 | } 36 | 37 | uintptr_t *highResCounter(Class *class, MethodBlock *mb, uintptr_t *ostack) { 38 | *(long long*)ostack = 0; 39 | return ostack + 2; 40 | } 41 | 42 | uintptr_t *createByteArray(Class *class, MethodBlock *mb, uintptr_t *ostack) { 43 | *ostack++ = (uintptr_t)NULL; 44 | return ostack; 45 | } 46 | 47 | uintptr_t *createLong(Class *class, MethodBlock *mb, uintptr_t *ostack) { 48 | *ostack++ = (uintptr_t)classlibNewDirectByteBuffer(sysMalloc(8), 8); 49 | return ostack; 50 | } 51 | 52 | uintptr_t *attach(Class *class, MethodBlock *mb, uintptr_t *ostack) { 53 | *ostack++ = (uintptr_t)NULL; 54 | return ostack; 55 | } 56 | 57 | uintptr_t *detach(Class *class, MethodBlock *mb, uintptr_t *ostack) { 58 | return ostack; 59 | } 60 | 61 | VMMethod sun_misc_perf[] = { 62 | {"registerNatives", "()V", registerNatives}, 63 | {"highResFrequency", "()J", highResFrequency}, 64 | {"highResCounter", "()J", highResCounter}, 65 | {"createByteArray", "(Ljava/lang/String;II[BI)Ljava/nio/ByteBuffer;", 66 | createByteArray}, 67 | {"createLong", "(Ljava/lang/String;IIJ)Ljava/nio/ByteBuffer;", 68 | createLong}, 69 | {"attach", "(Ljava/lang/String;II)Ljava/nio/ByteBuffer;", 70 | attach}, 71 | {"detach", "(Ljava/nio/ByteBuffer;)V", detach}, 72 | {NULL, NULL, NULL} 73 | }; 74 | 75 | -------------------------------------------------------------------------------- /src/jamvm/classlib/openjdk/properties.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 Robert Lougher . 3 | * 4 | * This file is part of JamVM. 5 | * 6 | * This program is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License 8 | * as published by the Free Software Foundation; either version 2, 9 | * or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 19 | */ 20 | 21 | #include 22 | #include "jam.h" 23 | 24 | char *classlibDefaultJavaHome() { 25 | char *path = nativeJVMPath(); 26 | char *pntr = path + strlen(path); 27 | int count = 0; 28 | char *home; 29 | 30 | while(pntr > path && count < 4) 31 | count += *--pntr == '/'; 32 | 33 | if(count != 4) { 34 | printf("Error: JVM path malformed. Aborting VM.\n"); 35 | exitVM(1); 36 | } 37 | 38 | home = sysMalloc(pntr - path + 1); 39 | memcpy(home, path, pntr - path); 40 | home[pntr - path] = '\0'; 41 | sysFree(path); 42 | 43 | return home; 44 | } 45 | 46 | -------------------------------------------------------------------------------- /src/jamvm/classlib/openjdk/shutdown.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Robert Lougher . 3 | * 4 | * This file is part of JamVM. 5 | * 6 | * This program is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License 8 | * as published by the Free Software Foundation; either version 2, 9 | * or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 19 | */ 20 | 21 | #include "jam.h" 22 | #include "symbol.h" 23 | 24 | void classlibVMShutdown() { 25 | /* Execute Shutdown.shutdown() to run any registered shutdown hooks. 26 | Unlike System.exit() it does not exit the VM after shutdown */ 27 | 28 | if(!VMInitialising()) { 29 | Class *class = findSystemClass(SYMBOL(java_lang_Shutdown)); 30 | if(class != NULL) { 31 | MethodBlock *mb = findMethod(class, SYMBOL(shutdown), 32 | SYMBOL(___V)); 33 | if(mb != NULL) 34 | executeStaticMethod(class, mb); 35 | } 36 | 37 | shutdownVM(); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/jamvm/classlib/openjdk/trace.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 Robert Lougher . 3 | * 4 | * This file is part of JamVM. 5 | * 6 | * This program is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License 8 | * as published by the Free Software Foundation; either version 2, 9 | * or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 19 | */ 20 | 21 | #if 1 22 | #define TRACE(fmt, ...) 23 | #else 24 | #define TRACE(fmt, ...) { printf(fmt "\n", ## __VA_ARGS__); fflush(stdout); } 25 | #endif 26 | 27 | #if 0 28 | #define TBD(fmt, ...) 29 | #define UNUSED(fmt, ...) 30 | #define DEPRECATED(fmt, ...) 31 | #define UNIMPLEMENTED(fmt, ...) 32 | #else 33 | #define TBD(fmt, ...) { printf(fmt "\n", ## __VA_ARGS__); fflush(stdout); } 34 | #define UNUSED(fmt, ...) { printf(fmt "\n", ## __VA_ARGS__); fflush(stdout); } 35 | #define DEPRECATED(fmt, ...) { printf(fmt "\n", ## __VA_ARGS__); fflush(stdout); } 36 | #define UNIMPLEMENTED(fmt, ...) { printf(fmt "\n", ## __VA_ARGS__); fflush(stdout); } 37 | #endif 38 | 39 | #define IGNORED(fmt, ...) 40 | -------------------------------------------------------------------------------- /src/jamvm/classlib/squirreljme/nativemethods.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include "jam.h" 7 | #include "excep.h" 8 | #include "reflect.h" 9 | #include "natives.h" 10 | 11 | uintptr_t *is_squirrel_jme_jvm(Class *class, MethodBlock *mb, uintptr_t *ostack){ 12 | *ostack++ = 0;//false 13 | return ostack; 14 | } 15 | 16 | uintptr_t *map_service(Class *class, MethodBlock *mb, uintptr_t *ostack){ 17 | Object *string = (Object *)ostack[1]; 18 | 19 | char *service_name = string ? String2Utf8(string) : NULL; 20 | char service_class[100]; 21 | bool return_null = false; 22 | 23 | if(strcmp(service_name, "net.multiphasicapps.squirreljme.lcdui.DisplayManager") == 0){ 24 | strcpy(service_class, "libretro.DisplayManager"); 25 | } 26 | else if(strcmp(service_name, "net.multiphasicapps.squirreljme.rms.RecordClusterManager") == 0){ 27 | strcpy(service_class, "libretro.FileRecordClusterManager"); 28 | } 29 | else{ 30 | return_null = true; 31 | } 32 | 33 | sysFree(service_name); 34 | 35 | if(!return_null){ 36 | *ostack++ = (uintptr_t)createString(service_class); 37 | } 38 | else{ 39 | *ostack++ = (uintptr_t)NULL; 40 | } 41 | return ostack; 42 | } 43 | 44 | VMMethod ext_systemvm_methods[] = { 45 | {"isSquirrelJMEJVM", "()Z", is_squirrel_jme_jvm}, 46 | {NULL, NULL, NULL} 47 | }; 48 | 49 | VMMethod ext_systemenvironment_methods[] = { 50 | {"mapService", "(Ljava/lang/String;)Ljava/lang/String;", map_service}, 51 | {NULL, NULL, NULL} 52 | }; 53 | 54 | VMClass native_methods[] = { 55 | {"net/multiphasicapps/squirreljme/unsafe/__Ext_systemvm__", ext_systemvm_methods}, 56 | {"net/multiphasicapps/squirreljme/unsafe/__Ext_systemenvironment__", ext_systemenvironment_methods}, 57 | {NULL, NULL} 58 | }; 59 | -------------------------------------------------------------------------------- /src/jamvm/excep.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 Robert Lougher . 3 | * 4 | * This file is part of JamVM. 5 | * 6 | * This program is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License 8 | * as published by the Free Software Foundation; either version 2, 9 | * or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 19 | */ 20 | 21 | #include "classlib-excep.h" 22 | 23 | #define EXCEPTIONS_DO(action) \ 24 | action(java_lang_LinkageError), \ 25 | action(java_lang_InternalError), \ 26 | action(java_lang_ClassFormatError), \ 27 | action(java_lang_NoSuchFieldError), \ 28 | action(java_lang_OutOfMemoryError), \ 29 | action(java_lang_NoSuchMethodError), \ 30 | action(java_lang_InstantiationError), \ 31 | action(java_lang_IllegalAccessError), \ 32 | action(java_lang_ClassCastException), \ 33 | action(java_lang_StackOverflowError), \ 34 | action(java_lang_ArithmeticException), \ 35 | action(java_lang_AbstractMethodError), \ 36 | action(java_lang_ArrayStoreException), \ 37 | action(java_lang_NullPointerException), \ 38 | action(java_lang_NoClassDefFoundError), \ 39 | action(java_lang_UnsatisfiedLinkError), \ 40 | action(java_lang_InterruptedException), \ 41 | action(java_lang_InstantiationException), \ 42 | action(java_lang_ClassNotFoundException), \ 43 | action(java_lang_IllegalAccessException), \ 44 | action(java_lang_IllegalArgumentException), \ 45 | action(java_lang_NegativeArraySizeException), \ 46 | action(java_lang_IllegalThreadStateException), \ 47 | action(java_lang_IllegalMonitorStateException), \ 48 | action(java_lang_IncompatibleClassChangeError), \ 49 | action(java_lang_ArrayIndexOutOfBoundsException), \ 50 | action(java_lang_StringIndexOutOfBoundsException) 51 | 52 | #define EXCEPTION_ENUM(name) exception_##name 53 | 54 | enum { 55 | CLASSLIB_EXCEPTIONS_DO(EXCEPTION_ENUM) 56 | EXCEPTIONS_DO(EXCEPTION_ENUM), 57 | MAX_EXCEPTION_ENUM 58 | }; 59 | -------------------------------------------------------------------------------- /src/jamvm/frame.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2011 3 | * Robert Lougher . 4 | * 5 | * This file is part of JamVM. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2, 10 | * or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | #include "jam.h" 23 | #include "hash.h" 24 | #include "class.h" 25 | #include "thread.h" 26 | #include "classlib.h" 27 | 28 | int initialiseFrame() { 29 | if(!classlibInitialiseFrame()) { 30 | jam_fprintf(stderr, "Error initialising VM (initialiseFrame)\n"); 31 | return FALSE; 32 | } 33 | 34 | return TRUE; 35 | } 36 | 37 | Class *getCallerClass(int depth) { 38 | Frame *last = getExecEnv()->last_frame; 39 | 40 | if(last->prev == NULL) 41 | return NULL; 42 | 43 | if((last = classlibGetCallerFrame(last, depth)) == NULL) 44 | return NULL; 45 | 46 | return last->mb->class; 47 | } 48 | 49 | Object *getClassContext() { 50 | Class *class_class = findArrayClass("[Ljava/lang/Class;"); 51 | Frame *last = getExecEnv()->last_frame; 52 | Frame *bottom = last; 53 | Object *array; 54 | int depth = 0; 55 | 56 | if(class_class == NULL) 57 | return NULL; 58 | 59 | if(last->prev == NULL) 60 | return allocArray(class_class, 0, sizeof(Class*)); 61 | 62 | for(; last != NULL; last = classlibGetCallerFrame(last, 1)) 63 | if(!(last->mb->access_flags & ACC_NATIVE)) 64 | depth++; 65 | 66 | array = allocArray(class_class, depth, sizeof(Class*)); 67 | 68 | if(array != NULL) { 69 | Class **data = ARRAY_DATA(array, Class*); 70 | 71 | for(; bottom != NULL; bottom = classlibGetCallerFrame(bottom, 1)) 72 | if(!(bottom->mb->access_flags & ACC_NATIVE)) 73 | *data++ = bottom->mb->class; 74 | } 75 | 76 | return array; 77 | } 78 | 79 | Object *firstNonNullClassLoader() { 80 | Frame *last = getExecEnv()->last_frame; 81 | 82 | if(last->prev != NULL) 83 | do { 84 | for(; last->mb != NULL; last = last->prev) 85 | if(!classlibIsSkippedReflectFrame(last)) { 86 | Object *loader = CLASS_CB(last->mb->class)->class_loader; 87 | if(loader != NULL) 88 | return loader; 89 | } 90 | } while((last = last->prev)->prev != NULL); 91 | 92 | return NULL; 93 | } 94 | 95 | -------------------------------------------------------------------------------- /src/jamvm/hash.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2003, 2004, 2005, 2006, 2007 3 | * Robert Lougher . 4 | * 5 | * This file is part of JamVM. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2, 10 | * or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | #include 23 | #include 24 | 25 | #include "jam.h" 26 | #include "hash.h" 27 | #include "class.h" 28 | #include "classlib.h" 29 | 30 | void lockHashTable0(HashTable *table, Thread *self) { 31 | if(!tryLockVMLock(table->lock, self)) { 32 | disableSuspend(self); 33 | lockVMLock(table->lock, self); 34 | enableSuspend(self); 35 | } 36 | fastDisableSuspend(self); 37 | } 38 | 39 | void unlockHashTable0(HashTable *table, Thread *self) { 40 | fastEnableSuspend(self); 41 | unlockVMLock(table->lock, self); 42 | } 43 | 44 | void resizeHash(HashTable *table, int new_size) { 45 | HashEntry *new_table = gcMemMalloc(sizeof(HashEntry)*new_size); 46 | int i; 47 | 48 | memset(new_table, 0, sizeof(HashEntry)*new_size); 49 | 50 | for(i = table->hash_size-1; i >= 0; i--) { 51 | void *ptr = table->hash_table[i].data; 52 | if(ptr != NULL) { 53 | int hash = table->hash_table[i].hash; 54 | int new_index = hash & (new_size - 1); 55 | 56 | while(new_table[new_index].data != NULL) 57 | new_index = (new_index+1) & (new_size - 1); 58 | 59 | new_table[new_index].hash = hash; 60 | new_table[new_index].data = ptr; 61 | } 62 | } 63 | 64 | gcMemFree(table->hash_table); 65 | table->hash_table = new_table; 66 | table->hash_size = new_size; 67 | } 68 | -------------------------------------------------------------------------------- /src/jamvm/hooks.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2003, 2004, 2005, 2006, 2007 3 | * Robert Lougher . 4 | * 5 | * This file is part of JamVM. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2, 10 | * or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | #include "jam.h" 23 | 24 | static int (*vfprintf_hook)(FILE *stream, const char *fmt, va_list ap); 25 | static void (*exit_hook)(int status); 26 | 27 | void jam_fprintf(FILE *stream, const char *fmt, ...) { 28 | va_list ap; 29 | 30 | va_start(ap, fmt); 31 | (*vfprintf_hook)(stream, fmt, ap); 32 | 33 | va_end(ap); 34 | } 35 | 36 | void jamvm_exit(int status) { 37 | (*exit_hook)(status); 38 | } 39 | 40 | int initialiseHooks(InitArgs *args) { 41 | vfprintf_hook = args->vfprintf; 42 | exit_hook = args->exit; 43 | return TRUE; 44 | } 45 | 46 | -------------------------------------------------------------------------------- /src/jamvm/interp/Makefile.am: -------------------------------------------------------------------------------- 1 | ## 2 | ## Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 3 | ## Robert Lougher . 4 | ## 5 | ## This file is part of JamVM. 6 | ## 7 | ## This program is free software; you can redistribute it and/or 8 | ## modify it under the terms of the GNU General Public License 9 | ## as published by the Free Software Foundation; either version 2, 10 | ## or (at your option) any later version. 11 | ## 12 | ## This program is distributed in the hope that it will be useful, 13 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | ## GNU General Public License for more details. 16 | ## 17 | ## You should have received a copy of the GNU General Public License 18 | ## along with this program; if not, write to the Free Software 19 | ## Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | ## 21 | 22 | SUBDIRS = engine 23 | 24 | noinst_LTLIBRARIES = libinterp.la 25 | libinterp_la_SOURCES = direct.c inlining.c inlining.h shared.h 26 | 27 | libinterp_la_LIBADD = engine/libengine.la 28 | 29 | if COMPILE_TIME_RELOC_CHECKS 30 | inlining.lo: relocatability.inc 31 | endif 32 | 33 | relocatability.inc: engine/compute_relocatability 34 | engine/compute_relocatability 35 | 36 | AM_CPPFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/src/interp/engine -I$(top_builddir)/src 37 | 38 | CLEANFILES = relocatability.inc 39 | 40 | -------------------------------------------------------------------------------- /src/jamvm/interp/engine/Makefile.am: -------------------------------------------------------------------------------- 1 | ## 2 | ## Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2013 3 | ## Robert Lougher . 4 | ## 5 | ## This file is part of JamVM. 6 | ## 7 | ## This program is free software; you can redistribute it and/or 8 | ## modify it under the terms of the GNU General Public License 9 | ## as published by the Free Software Foundation; either version 2, 10 | ## or (at your option) any later version. 11 | ## 12 | ## This program is distributed in the hope that it will be useful, 13 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | ## GNU General Public License for more details. 16 | ## 17 | ## You should have received a copy of the GNU General Public License 18 | ## along with this program; if not, write to the Free Software 19 | ## Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | ## 21 | 22 | noinst_LTLIBRARIES = libengine.la 23 | libengine_la_SOURCES = interp.c interp2.c relocatability.c interp.h \ 24 | interp-threading.h interp-indirect.h \ 25 | interp-direct.h interp-inlining.h \ 26 | interp-direct-common.h 27 | 28 | if COMPILE_TIME_RELOC_CHECKS 29 | noinst_PROGRAMS = compute_relocatability 30 | compute_relocatability_LDADD = libengine.la 31 | endif 32 | 33 | AM_CFLAGS = @interp_cflags@ 34 | AM_CPPFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/src/interp -I$(top_builddir)/src 35 | 36 | -------------------------------------------------------------------------------- /src/jamvm/interp/engine/interp2.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2003, 2004, 2005, 2006, 2007 3 | * Robert Lougher . 4 | * 5 | * This file is part of JamVM. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2, 10 | * or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | #include "config.h" 23 | 24 | #ifdef INLINING 25 | #define executeJava() executeJava2() 26 | #define PAD __asm__(".space 4; .space 4; .space 4; .space 4"); 27 | 28 | #include "interp.c" 29 | #endif 30 | -------------------------------------------------------------------------------- /src/jamvm/interp/inlining.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 3 | * Robert Lougher . 4 | * 5 | * This file is part of JamVM. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2, 10 | * or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | #define LABELS_SIZE 256 23 | #define GOTO_START 230 24 | #define GOTO_END 255 25 | 26 | #ifdef USE_CACHE 27 | #define HANDLERS 3 28 | #define ENTRY_LABELS 0 29 | #define START_LABELS 3 30 | #define END_LABELS 6 31 | #define BRANCH_LABELS 9 32 | #else 33 | #define HANDLERS 1 34 | #define ENTRY_LABELS 0 35 | #define START_LABELS 1 36 | #define END_LABELS 2 37 | #define BRANCH_LABELS 3 38 | #endif 39 | 40 | /* Number of entries in the branch patch table */ 41 | #define BRANCH_NUM 16 42 | 43 | #define MEMCMP_FAILED -1 44 | #define END_REORDERED -2 45 | #define END_BEFORE_ENTRY -3 46 | 47 | #define FALLTHROUGH 1 48 | #define HANDLER 2 49 | #define TARGET 4 50 | #define END 8 51 | 52 | #ifdef INLINING 53 | extern uintptr_t *executeJava2(); 54 | extern int calculateRelocatability(int handler_sizes[HANDLERS][LABELS_SIZE]); 55 | #endif 56 | -------------------------------------------------------------------------------- /src/jamvm/jni-internal.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009 Robert Lougher . 3 | * 4 | * This file is part of JamVM. 5 | * 6 | * This program is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License 8 | * as published by the Free Software Foundation; either version 2, 9 | * or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 19 | */ 20 | 21 | #define REF_MASK 0x3 22 | #define GLOBAL_REF 0x2 23 | #define WEAK_GLOBAL_REF 0x1 24 | #define LOCAL_REF 0x0 25 | 26 | /* The tag is also used as the index into the list of 27 | global ref tables. As local refs are instead stored 28 | in the JNI frame, we use idx 0 for cleared weak refs, 29 | even though no object is ever tagged as such */ 30 | #define CLEARED_WEAK_REF 0x0 31 | 32 | #define REF_TO_OBJ_WEAK_NULL_CHECK(ref) ({ \ 33 | Object *_obj = REF_TO_OBJ(ref); \ 34 | if(REF_TYPE(ref) == WEAK_GLOBAL_REF) \ 35 | _obj = isPlaceholderObj(_obj) ? NULL : _obj; \ 36 | _obj; \ 37 | }) 38 | 39 | #define REF_TYPE(ref) (((uintptr_t)(ref))&REF_MASK) 40 | #define REF_TO_OBJ(ref) ((Object*)(((uintptr_t)(ref))&~REF_MASK)) 41 | #define OBJ_TO_REF(ref, ref_type) ((jobject)(((uintptr_t)(ref))|ref_type)) 42 | -------------------------------------------------------------------------------- /src/jamvm/lock.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2011 3 | * Robert Lougher . 4 | * 5 | * This file is part of JamVM. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2, 10 | * or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | #include "thread.h" 23 | 24 | extern void monitorInit(Monitor *mon); 25 | extern void monitorLock(Monitor *mon, Thread *self); 26 | extern void monitorUnlock(Monitor *mon, Thread *self); 27 | extern int monitorWait(Monitor *mon, Thread *self, long long ms, int ns, 28 | int is_wait, int interruptible); 29 | extern int monitorNotify(Monitor *mon, Thread *self); 30 | extern int monitorNotifyAll(Monitor *mon, Thread *self); 31 | 32 | extern void objectLock(Object *ob); 33 | extern void objectUnlock(Object *ob); 34 | extern void objectNotify(Object *ob); 35 | extern void objectNotifyAll(Object *ob); 36 | extern void objectWait(Object *ob, long long ms, int ns, int interruptible); 37 | extern int objectLockedByCurrent(Object *ob); 38 | extern Thread *objectLockedBy(Object *ob); 39 | extern void threadMonitorCache(); 40 | -------------------------------------------------------------------------------- /src/jamvm/natives.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2009 3 | * Robert Lougher . 4 | * 5 | * This file is part of JamVM. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2, 10 | * or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | typedef struct vm_method { 23 | char *methodname; 24 | char *methodtype; 25 | NativeMethod method; 26 | } VMMethod; 27 | 28 | typedef struct vm_class { 29 | char *classname; 30 | VMMethod *methods; 31 | } VMClass; 32 | 33 | extern VMClass native_methods[]; 34 | -------------------------------------------------------------------------------- /src/jamvm/os/Makefile.am: -------------------------------------------------------------------------------- 1 | ## 2 | ## Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 3 | ## Robert Lougher . 4 | ## 5 | ## This file is part of JamVM. 6 | ## 7 | ## This program is free software; you can redistribute it and/or 8 | ## modify it under the terms of the GNU General Public License 9 | ## as published by the Free Software Foundation; either version 2, 10 | ## or (at your option) any later version. 11 | ## 12 | ## This program is distributed in the hope that it will be useful, 13 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | ## GNU General Public License for more details. 16 | ## 17 | ## You should have received a copy of the GNU General Public License 18 | ## along with this program; if not, write to the Free Software 19 | ## Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | ## 21 | 22 | SUBDIRS = @os@ 23 | DIST_SUBDIRS = linux darwin bsd solaris 24 | 25 | -------------------------------------------------------------------------------- /src/jamvm/os/bsd/Makefile.am: -------------------------------------------------------------------------------- 1 | ## 2 | ## Copyright (C) 2003, 2004, 2005, 2006, 2007, 2009 3 | ## Robert Lougher . 4 | ## 5 | ## This file is part of JamVM. 6 | ## 7 | ## This program is free software; you can redistribute it and/or 8 | ## modify it under the terms of the GNU General Public License 9 | ## as published by the Free Software Foundation; either version 2, 10 | ## or (at your option) any later version. 11 | ## 12 | ## This program is distributed in the hope that it will be useful, 13 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | ## GNU General Public License for more details. 16 | ## 17 | ## You should have received a copy of the GNU General Public License 18 | ## along with this program; if not, write to the Free Software 19 | ## Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | ## 21 | 22 | SUBDIRS = @arch@ 23 | DIST_SUBDIRS = powerpc arm i386 x86_64 sparc 24 | 25 | noinst_LTLIBRARIES = libos.la 26 | libos_la_SOURCES = os.c 27 | 28 | AM_CPPFLAGS = -I$(top_builddir)/src 29 | -------------------------------------------------------------------------------- /src/jamvm/os/bsd/arm/Makefile.am: -------------------------------------------------------------------------------- 1 | ## 2 | ## Copyright (C) 2003, 2004, 2005, 2006, 2007 3 | ## Robert Lougher . 4 | ## 5 | ## This file is part of JamVM. 6 | ## 7 | ## This program is free software; you can redistribute it and/or 8 | ## modify it under the terms of the GNU General Public License 9 | ## as published by the Free Software Foundation; either version 2, 10 | ## or (at your option) any later version. 11 | ## 12 | ## This program is distributed in the hope that it will be useful, 13 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | ## GNU General Public License for more details. 16 | ## 17 | ## You should have received a copy of the GNU General Public License 18 | ## along with this program; if not, write to the Free Software 19 | ## Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | ## 21 | 22 | EXTRA_DIST = callNativeOABI.S callNativeEABI.S 23 | 24 | noinst_LTLIBRARIES = libnative.la 25 | libnative_la_SOURCES = init.c dll_md.c callNative.S 26 | 27 | AM_CPPFLAGS = -I$(top_builddir)/src 28 | AM_CCASFLAGS = -I$(top_builddir)/src 29 | -------------------------------------------------------------------------------- /src/jamvm/os/bsd/arm/callNative.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2003, 2004, 2005, 2006, 2007 3 | * Robert Lougher . 4 | * 5 | * This file is part of JamVM. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2, 10 | * or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | #include "config.h" 23 | 24 | #ifndef USE_FFI 25 | #ifdef __ARM_EABI__ 26 | #include "callNativeEABI.S" 27 | #else 28 | #include "callNativeOABI.S" 29 | #endif 30 | #endif 31 | -------------------------------------------------------------------------------- /src/jamvm/os/bsd/arm/init.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2003, 2004, 2006, 2007 3 | * Robert Lougher . 4 | * 5 | * This file is part of JamVM. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2, 10 | * or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | void initialisePlatform() { 23 | /* Nothing to do for ARM */ 24 | } 25 | -------------------------------------------------------------------------------- /src/jamvm/os/bsd/i386/Makefile.am: -------------------------------------------------------------------------------- 1 | ## 2 | ## Copyright (C) 2003, 2004, 2005, 2006, 2007 3 | ## Robert Lougher . 4 | ## 5 | ## This file is part of JamVM. 6 | ## 7 | ## This program is free software; you can redistribute it and/or 8 | ## modify it under the terms of the GNU General Public License 9 | ## as published by the Free Software Foundation; either version 2, 10 | ## or (at your option) any later version. 11 | ## 12 | ## This program is distributed in the hope that it will be useful, 13 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | ## GNU General Public License for more details. 16 | ## 17 | ## You should have received a copy of the GNU General Public License 18 | ## along with this program; if not, write to the Free Software 19 | ## Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | ## 21 | 22 | noinst_LTLIBRARIES = libnative.la 23 | libnative_la_SOURCES = init.c dll_md.c 24 | 25 | AM_CPPFLAGS = -I$(top_builddir)/src 26 | -------------------------------------------------------------------------------- /src/jamvm/os/bsd/i386/init.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2003, 2004, 2006, 2007 3 | * Robert Lougher . 4 | * 5 | * This file is part of JamVM. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2, 10 | * or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | void setDoublePrecision() { 23 | } 24 | 25 | void initialisePlatform() { 26 | } 27 | -------------------------------------------------------------------------------- /src/jamvm/os/bsd/os.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2009, 2014 3 | * Robert Lougher . 4 | * 5 | * This file is part of JamVM. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2, 10 | * or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | #ifndef __NetBSD__ 31 | #include 32 | #endif 33 | 34 | #include "../../jam.h" 35 | 36 | #ifdef __OpenBSD__ 37 | void *nativeStackBase() { 38 | stack_t sinfo; 39 | 40 | pthread_stackseg_np(pthread_self(), &sinfo); 41 | return sinfo.ss_sp; 42 | } 43 | #else 44 | void *nativeStackBase() { 45 | pthread_attr_t attr; 46 | size_t size; 47 | void *addr; 48 | 49 | pthread_attr_init(&attr); 50 | pthread_attr_get_np(pthread_self(), &attr); 51 | pthread_attr_getstack(&attr, &addr, &size); 52 | 53 | return addr+size; 54 | } 55 | #endif 56 | 57 | int nativeAvailableProcessors() { 58 | int processors, mib[2]; 59 | size_t len = sizeof(processors); 60 | 61 | mib[0] = CTL_HW; 62 | mib[1] = HW_NCPU; 63 | 64 | if(sysctl(mib, 2, &processors, &len, NULL, 0) == -1) 65 | return 1; 66 | else 67 | return processors; 68 | } 69 | 70 | char *nativeLibError() { 71 | return dlerror(); 72 | } 73 | 74 | char *nativeLibPath() { 75 | return getenv("LD_LIBRARY_PATH"); 76 | } 77 | 78 | void *nativeLibOpen(char *path) { 79 | return dlopen(path, RTLD_LAZY); 80 | } 81 | 82 | void nativeLibClose(void *handle) { 83 | dlclose(handle); 84 | } 85 | 86 | void *nativeLibSym(void *handle, char *symbol) { 87 | return dlsym(handle, symbol); 88 | } 89 | 90 | char *nativeLibMapName(char *name) { 91 | char *buff = sysMalloc(strlen(name) + sizeof("lib.so") + 1); 92 | 93 | sprintf(buff, "lib%s.so", name); 94 | return buff; 95 | } 96 | 97 | long long nativePhysicalMemory() { 98 | return 0; /* TBD */ 99 | } 100 | -------------------------------------------------------------------------------- /src/jamvm/os/bsd/powerpc/Makefile.am: -------------------------------------------------------------------------------- 1 | ## 2 | ## Copyright (C) 2003, 2004, 2005, 2006, 2007 3 | ## Robert Lougher . 4 | ## 5 | ## This file is part of JamVM. 6 | ## 7 | ## This program is free software; you can redistribute it and/or 8 | ## modify it under the terms of the GNU General Public License 9 | ## as published by the Free Software Foundation; either version 2, 10 | ## or (at your option) any later version. 11 | ## 12 | ## This program is distributed in the hope that it will be useful, 13 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | ## GNU General Public License for more details. 16 | ## 17 | ## You should have received a copy of the GNU General Public License 18 | ## along with this program; if not, write to the Free Software 19 | ## Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | ## 21 | 22 | noinst_LTLIBRARIES = libnative.la 23 | libnative_la_SOURCES = init.c dll_md.c callNative.S 24 | 25 | AM_CPPFLAGS = -I$(top_builddir)/src 26 | AM_CCASFLAGS = -I$(top_builddir)/src 27 | -------------------------------------------------------------------------------- /src/jamvm/os/bsd/powerpc/dll_md.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2003, 2004, 2005, 2006, 2007 3 | * Robert Lougher . 4 | * 5 | * This file is part of JamVM. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2, 10 | * or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | #include "../../../jam.h" 23 | 24 | #ifndef USE_FFI 25 | #include 26 | 27 | /* The PowerPC calling convention passes the first 8 integer 28 | and fp args in registers. After this, the arguments spill 29 | onto the stack. Because of long/double alignment, and arg 30 | ordering, we must scan the signature to calculate the extra 31 | stack requirements. This is done the first time the native 32 | method is called, and stored in the opaque "extra argument". 33 | */ 34 | 35 | int nativeExtraArg(MethodBlock *mb) { 36 | char *sig = mb->type; 37 | int iargs = 2; /* take into account the 2 extra arguments 38 | passed (JNIEnv and class/this). */ 39 | int fargs = 0; 40 | int margs = 0; 41 | 42 | while(*++sig != ')') 43 | switch(*sig) { 44 | case 'J': 45 | iargs = (iargs + 3) & ~1; 46 | if(iargs > 8) 47 | margs = (margs + 3) & ~1; 48 | break; 49 | 50 | case 'D': 51 | if(++fargs > 8) 52 | margs = (margs + 3) & ~1; 53 | break; 54 | 55 | case 'F': 56 | if(++fargs > 8) 57 | margs++; 58 | break; 59 | 60 | default: 61 | if(++iargs > 8) 62 | margs++; 63 | 64 | if(*sig == '[') 65 | while(*++sig == '['); 66 | if(*sig == 'L') 67 | while(*++sig != ';'); 68 | break; 69 | } 70 | 71 | #ifdef DEBUG_DLL 72 | jam_printf(" int args: %d fp args: %d stack: %d>\n", 73 | CLASS_CB(mb->class)->name, mb->name, mb->type, iargs, fargs, margs); 74 | #endif 75 | 76 | return margs; 77 | } 78 | #endif 79 | -------------------------------------------------------------------------------- /src/jamvm/os/bsd/powerpc/init.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2003, 2004, 2006, 2007 3 | * Robert Lougher . 4 | * 5 | * This file is part of JamVM. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2, 10 | * or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | void initialisePlatform() { 23 | /* Nothing to do for powerpc */ 24 | } 25 | -------------------------------------------------------------------------------- /src/jamvm/os/bsd/sparc/Makefile.am: -------------------------------------------------------------------------------- 1 | ## 2 | ## Copyright (C) 2009 Robert Lougher . 3 | ## 4 | ## This file is part of JamVM. 5 | ## 6 | ## This program is free software; you can redistribute it and/or 7 | ## modify it under the terms of the GNU General Public License 8 | ## as published by the Free Software Foundation; either version 2, 9 | ## or (at your option) any later version. 10 | ## 11 | ## This program is distributed in the hope that it will be useful, 12 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | ## GNU General Public License for more details. 15 | ## 16 | ## You should have received a copy of the GNU General Public License 17 | ## along with this program; if not, write to the Free Software 18 | ## Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 19 | ## 20 | 21 | noinst_LTLIBRARIES = libnative.la 22 | libnative_la_SOURCES = init.c 23 | 24 | AM_CPPFLAGS = -I$(top_builddir)/src 25 | -------------------------------------------------------------------------------- /src/jamvm/os/bsd/sparc/init.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009 Robert Lougher . 3 | * 4 | * This file is part of JamVM. 5 | * 6 | * This program is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License 8 | * as published by the Free Software Foundation; either version 2, 9 | * or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 19 | */ 20 | 21 | void initialisePlatform() { 22 | /* Nothing to do for sparc */ 23 | } 24 | -------------------------------------------------------------------------------- /src/jamvm/os/bsd/x86_64/Makefile.am: -------------------------------------------------------------------------------- 1 | ## 2 | ## Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 3 | ## Robert Lougher . 4 | ## 5 | ## This file is part of JamVM. 6 | ## 7 | ## This program is free software; you can redistribute it and/or 8 | ## modify it under the terms of the GNU General Public License 9 | ## as published by the Free Software Foundation; either version 2, 10 | ## or (at your option) any later version. 11 | ## 12 | ## This program is distributed in the hope that it will be useful, 13 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | ## GNU General Public License for more details. 16 | ## 17 | ## You should have received a copy of the GNU General Public License 18 | ## along with this program; if not, write to the Free Software 19 | ## Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | ## 21 | 22 | noinst_LTLIBRARIES = libnative.la 23 | libnative_la_SOURCES = init.c dll_md.c callNative.S 24 | 25 | AM_CPPFLAGS = -I$(top_builddir)/src 26 | AM_CCASFLAGS = -I$(top_builddir)/src 27 | -------------------------------------------------------------------------------- /src/jamvm/os/bsd/x86_64/dll_md.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 Robert Lougher . 3 | * 4 | * This file is part of JamVM. 5 | * 6 | * This program is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License 8 | * as published by the Free Software Foundation; either version 2, 9 | * or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 19 | */ 20 | 21 | #include "../../../jam.h" 22 | 23 | #ifndef USE_FFI 24 | #include 25 | 26 | int nativeExtraArg(MethodBlock *mb) { 27 | char *sig = mb->type; 28 | int stack_space; 29 | int iargs = 0; 30 | int fargs = 0; 31 | 32 | while(*++sig != ')') 33 | switch(*sig) { 34 | case 'D': 35 | case 'F': 36 | fargs++; 37 | break; 38 | 39 | default: 40 | iargs++; 41 | 42 | if(*sig == '[') 43 | while(*++sig == '['); 44 | if(*sig == 'L') 45 | while(*++sig != ';'); 46 | break; 47 | } 48 | 49 | stack_space = ((iargs > 4 ? iargs - 4 : 0) + 50 | (fargs > 8 ? fargs - 8 : 0)) << 3; 51 | 52 | /* Ensure the stack remains 16 byte aligned. As 53 | callJNIMethod pushes an even number of registers 54 | the extra space must also be even. */ 55 | return (stack_space + 15) & ~15; 56 | } 57 | #endif 58 | -------------------------------------------------------------------------------- /src/jamvm/os/bsd/x86_64/init.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2003, 2004, 2005, 2006, 2007 3 | * Robert Lougher . 4 | * 5 | * This file is part of JamVM. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2, 10 | * or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | void setDoublePrecision() { 23 | } 24 | 25 | void initialisePlatform() { 26 | } 27 | -------------------------------------------------------------------------------- /src/jamvm/os/darwin/Makefile.am: -------------------------------------------------------------------------------- 1 | ## 2 | ## Copyright (C) 2003, 2004, 2005, 2006, 2007 3 | ## Robert Lougher . 4 | ## 5 | ## This file is part of JamVM. 6 | ## 7 | ## This program is free software; you can redistribute it and/or 8 | ## modify it under the terms of the GNU General Public License 9 | ## as published by the Free Software Foundation; either version 2, 10 | ## or (at your option) any later version. 11 | ## 12 | ## This program is distributed in the hope that it will be useful, 13 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | ## GNU General Public License for more details. 16 | ## 17 | ## You should have received a copy of the GNU General Public License 18 | ## along with this program; if not, write to the Free Software 19 | ## Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | ## 21 | 22 | SUBDIRS = @arch@ 23 | DIST_SUBDIRS = powerpc i386 arm 24 | 25 | noinst_LTLIBRARIES = libos.la 26 | libos_la_SOURCES = os.c 27 | 28 | AM_CPPFLAGS = -I$(top_builddir)/src 29 | -------------------------------------------------------------------------------- /src/jamvm/os/darwin/arm/Makefile.am: -------------------------------------------------------------------------------- 1 | ## 2 | ## Copyright (C) 2003, 2004, 2005, 2006, 2007 3 | ## Robert Lougher . 4 | ## 5 | ## This file is part of JamVM. 6 | ## 7 | ## This program is free software; you can redistribute it and/or 8 | ## modify it under the terms of the GNU General Public License 9 | ## as published by the Free Software Foundation; either version 2, 10 | ## or (at your option) any later version. 11 | ## 12 | ## This program is distributed in the hope that it will be useful, 13 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | ## GNU General Public License for more details. 16 | ## 17 | ## You should have received a copy of the GNU General Public License 18 | ## along with this program; if not, write to the Free Software 19 | ## Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | ## 21 | 22 | EXTRA_DIST = callNativeOABI.S callNativeEABI.S 23 | 24 | noinst_LTLIBRARIES = libnative.la 25 | libnative_la_SOURCES = init.c dll_md.c callNative.S 26 | 27 | AM_CPPFLAGS = -I$(top_builddir)/src 28 | AM_CCASFLAGS = -I$(top_builddir)/src 29 | -------------------------------------------------------------------------------- /src/jamvm/os/darwin/arm/callNative.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2003, 2004, 2005, 2006, 2007 3 | * Robert Lougher . 4 | * 5 | * This file is part of JamVM. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2, 10 | * or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | #include "config.h" 23 | 24 | /* The iPhone currently appears to use a slightly modified 25 | OABI convention, where r7 is used as a frame pointer. 26 | CallNativeOABI.S does not modify or use r7. 27 | 28 | EABI support is included in case iPhone moves to EABI. 29 | Most ARM Linux distributions have made this move. 30 | */ 31 | 32 | #ifndef USE_FFI 33 | #ifdef __ARM_EABI__ 34 | #include "callNativeEABI.S" 35 | #else 36 | #include "callNativeOABI.S" 37 | #endif 38 | #endif 39 | -------------------------------------------------------------------------------- /src/jamvm/os/darwin/arm/init.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2003, 2004, 2006, 2007 3 | * Robert Lougher . 4 | * 5 | * This file is part of JamVM. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2, 10 | * or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | void initialisePlatform() { 23 | /* Nothing to do for ARM */ 24 | } 25 | -------------------------------------------------------------------------------- /src/jamvm/os/darwin/i386/Makefile.am: -------------------------------------------------------------------------------- 1 | ## 2 | ## Copyright (C) 2003, 2004, 2005, 2006, 2007 3 | ## Robert Lougher . 4 | ## 5 | ## This file is part of JamVM. 6 | ## 7 | ## This program is free software; you can redistribute it and/or 8 | ## modify it under the terms of the GNU General Public License 9 | ## as published by the Free Software Foundation; either version 2, 10 | ## or (at your option) any later version. 11 | ## 12 | ## This program is distributed in the hope that it will be useful, 13 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | ## GNU General Public License for more details. 16 | ## 17 | ## You should have received a copy of the GNU General Public License 18 | ## along with this program; if not, write to the Free Software 19 | ## Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | ## 21 | 22 | noinst_LTLIBRARIES = libnative.la 23 | libnative_la_SOURCES = init.c dll_md.c 24 | 25 | AM_CPPFLAGS = -I$(top_builddir)/src 26 | -------------------------------------------------------------------------------- /src/jamvm/os/darwin/i386/init.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2003, 2004, 2006, 2007 3 | * Robert Lougher . 4 | * 5 | * This file is part of JamVM. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2, 10 | * or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | /* This is needed on Linux/i386. Find out if it's 23 | needed on Darwin/i386, and how to set it. */ 24 | void setDoublePrecision() { 25 | } 26 | 27 | void initialisePlatform() { 28 | } 29 | -------------------------------------------------------------------------------- /src/jamvm/os/darwin/powerpc/Makefile.am: -------------------------------------------------------------------------------- 1 | ## 2 | ## Copyright (C) 2003, 2004, 2005, 2006, 2007 3 | ## Robert Lougher . 4 | ## 5 | ## This file is part of JamVM. 6 | ## 7 | ## This program is free software; you can redistribute it and/or 8 | ## modify it under the terms of the GNU General Public License 9 | ## as published by the Free Software Foundation; either version 2, 10 | ## or (at your option) any later version. 11 | ## 12 | ## This program is distributed in the hope that it will be useful, 13 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | ## GNU General Public License for more details. 16 | ## 17 | ## You should have received a copy of the GNU General Public License 18 | ## along with this program; if not, write to the Free Software 19 | ## Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | ## 21 | 22 | noinst_LTLIBRARIES = libnative.la 23 | libnative_la_SOURCES = init.c dll_md.c callNative.S 24 | 25 | AM_CPPFLAGS = -I$(top_builddir)/src 26 | AM_CCASFLAGS = -I$(top_builddir)/src 27 | 28 | EXTRA_DIST = callNative32.S callNative64.S 29 | -------------------------------------------------------------------------------- /src/jamvm/os/darwin/powerpc/callNative.S: -------------------------------------------------------------------------------- 1 | ; 2 | ; Copyright (C) 2003, 2004, 2005, 2006, 2007 3 | ; Robert Lougher . 4 | ; 5 | ; This file is part of JamVM. 6 | ; 7 | ; This program is free software; you can redistribute it and/or 8 | ; modify it under the terms of the GNU General Public License 9 | ; as published by the Free Software Foundation; either version 2, 10 | ; or (at your option) any later version. 11 | ; 12 | ; This program is distributed in the hope that it will be useful, 13 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | ; GNU General Public License for more details. 16 | ; 17 | ; You should have received a copy of the GNU General Public License 18 | ; along with this program; if not, write to the Free Software 19 | ; Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | ; 21 | 22 | #include "config.h" 23 | 24 | #ifndef USE_FFI 25 | #ifdef __ppc64__ 26 | #include "callNative64.S" 27 | #else 28 | #include "callNative32.S" 29 | #endif 30 | #endif 31 | -------------------------------------------------------------------------------- /src/jamvm/os/darwin/powerpc/dll_md.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2003, 2004, 2005, 2006, 2007 3 | * Robert Lougher . 4 | * 5 | * This file is part of JamVM. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2, 10 | * or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | #include "../../../jam.h" 23 | 24 | #ifndef USE_FFI 25 | #include 26 | 27 | /* 28 | This function calculates the size of the params area needed 29 | in the caller frame for the JNI native method. This is: 30 | JNIEnv + class (if static) + method arguments + saved regs + 31 | linkage area. It's negative because the stack grows downwards. 32 | */ 33 | 34 | int nativeExtraArg(MethodBlock *mb) { 35 | int params = (mb->args_count + 1 + 36 | ((mb->access_flags & ACC_STATIC) ? 1 : 0) + 7 + 6) * -sizeof(uintptr_t); 37 | 38 | #ifdef DEBUG_DLL 39 | jam_printf("\n", mb->name, mb->type, params); 40 | #endif 41 | 42 | return params; 43 | } 44 | #endif 45 | -------------------------------------------------------------------------------- /src/jamvm/os/darwin/powerpc/init.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2003, 2004, 2006, 2007 3 | * Robert Lougher . 4 | * 5 | * This file is part of JamVM. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2, 10 | * or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | void initialisePlatform() { 23 | /* Nothing to do for powerpc */ 24 | } 25 | -------------------------------------------------------------------------------- /src/jamvm/os/libretro/Makefile.am: -------------------------------------------------------------------------------- 1 | ## 2 | ## Copyright (C) 2003, 2004, 2005, 2006, 2007 3 | ## Robert Lougher . 4 | ## 5 | ## This file is part of JamVM. 6 | ## 7 | ## This program is free software; you can redistribute it and/or 8 | ## modify it under the terms of the GNU General Public License 9 | ## as published by the Free Software Foundation; either version 2, 10 | ## or (at your option) any later version. 11 | ## 12 | ## This program is distributed in the hope that it will be useful, 13 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | ## GNU General Public License for more details. 16 | ## 17 | ## You should have received a copy of the GNU General Public License 18 | ## along with this program; if not, write to the Free Software 19 | ## Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | ## 21 | 22 | SUBDIRS = @arch@ 23 | DIST_SUBDIRS = powerpc arm i386 x86_64 parisc mips 24 | 25 | noinst_LTLIBRARIES = libos.la 26 | libos_la_SOURCES = os.c 27 | 28 | AM_CPPFLAGS = -I$(top_builddir)/src 29 | -------------------------------------------------------------------------------- /src/jamvm/os/libretro/arm/Makefile.am: -------------------------------------------------------------------------------- 1 | ## 2 | ## Copyright (C) 2003, 2004, 2005, 2006, 2007, 2010, 2011, 2012 3 | ## Robert Lougher . 4 | ## 5 | ## This file is part of JamVM. 6 | ## 7 | ## This program is free software; you can redistribute it and/or 8 | ## modify it under the terms of the GNU General Public License 9 | ## as published by the Free Software Foundation; either version 2, 10 | ## or (at your option) any later version. 11 | ## 12 | ## This program is distributed in the hope that it will be useful, 13 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | ## GNU General Public License for more details. 16 | ## 17 | ## You should have received a copy of the GNU General Public License 18 | ## along with this program; if not, write to the Free Software 19 | ## Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | ## 21 | 22 | EXTRA_DIST = callNativeOABI.S callNativeEABI.S callNativeEABIHard.S \ 23 | callNativeEABIHardARM.S 24 | 25 | noinst_LTLIBRARIES = libnative.la 26 | libnative_la_SOURCES = init.c dll_md.c callNative.S 27 | 28 | AM_CPPFLAGS = -I$(top_builddir)/src -I$(top_srcdir)/src 29 | AM_CCASFLAGS = -I$(top_builddir)/src 30 | -------------------------------------------------------------------------------- /src/jamvm/os/libretro/arm/callNative.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2011, 2012 3 | * Robert Lougher . 4 | * 5 | * This file is part of JamVM. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2, 10 | * or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | #include "config.h" 23 | 24 | #ifndef USE_FFI 25 | #ifdef __ARM_EABI__ 26 | #ifdef __ARM_PCS_VFP 27 | #ifdef __ARM_ARCH_7A__ 28 | #include "callNativeEABIHard.S" 29 | #else 30 | #include "callNativeEABIHardARM.S" 31 | #endif 32 | #else 33 | #include "callNativeEABI.S" 34 | #endif 35 | #else 36 | #include "callNativeOABI.S" 37 | #endif 38 | #endif 39 | -------------------------------------------------------------------------------- /src/jamvm/os/libretro/arm/init.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2003, 2004, 2006, 2007 3 | * Robert Lougher . 4 | * 5 | * This file is part of JamVM. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2, 10 | * or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | void initialisePlatform() { 23 | /* Nothing to do for ARM */ 24 | } 25 | -------------------------------------------------------------------------------- /src/jamvm/os/libretro/i386/Makefile.am: -------------------------------------------------------------------------------- 1 | ## 2 | ## Copyright (C) 2003, 2004, 2005, 2006, 2007, 2010 3 | ## Robert Lougher . 4 | ## 5 | ## This file is part of JamVM. 6 | ## 7 | ## This program is free software; you can redistribute it and/or 8 | ## modify it under the terms of the GNU General Public License 9 | ## as published by the Free Software Foundation; either version 2, 10 | ## or (at your option) any later version. 11 | ## 12 | ## This program is distributed in the hope that it will be useful, 13 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | ## GNU General Public License for more details. 16 | ## 17 | ## You should have received a copy of the GNU General Public License 18 | ## along with this program; if not, write to the Free Software 19 | ## Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | ## 21 | 22 | noinst_LTLIBRARIES = libnative.la 23 | libnative_la_SOURCES = init.c dll_md.c stubs_md.c jni-stubs.c 24 | 25 | AM_CPPFLAGS = -I$(top_builddir)/src -I$(top_srcdir)/src 26 | -------------------------------------------------------------------------------- /src/jamvm/os/libretro/i386/init.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2003, 2004, 2006, 2007 3 | * Robert Lougher . 4 | * 5 | * This file is part of JamVM. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2, 10 | * or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | #include 23 | 24 | /* Change floating point precision to double (64-bit) from 25 | * the extended (80-bit) Linux default. */ 26 | 27 | void setDoublePrecision() { 28 | fpu_control_t cw; 29 | 30 | _FPU_GETCW(cw); 31 | cw &= ~_FPU_EXTENDED; 32 | cw |= _FPU_DOUBLE; 33 | _FPU_SETCW(cw); 34 | } 35 | 36 | void initialisePlatform() { 37 | setDoublePrecision(); 38 | } 39 | -------------------------------------------------------------------------------- /src/jamvm/os/libretro/i386/stubs_md.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010, 2012 Robert Lougher . 3 | * 4 | * This file is part of JamVM. 5 | * 6 | * This program is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License 8 | * as published by the Free Software Foundation; either version 2, 9 | * or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 19 | */ 20 | 21 | #ifndef GEN_STUBS_INC 22 | #include "jam.h" 23 | #endif 24 | 25 | #if defined(GEN_STUBS_INC) || defined(USE_MD_STUBS) 26 | #include 27 | #include "sig.h" 28 | 29 | char *convertSig2Simple(char *sig) { 30 | char *simple_sig, *simple_pntr; 31 | int count = 0; 32 | int i; 33 | 34 | SCAN_SIG(sig, count+=2, count++); 35 | simple_sig = simple_pntr = sysMalloc((count + 1)/2 + 4); 36 | 37 | *simple_pntr++ = '('; 38 | for(i = 0; i < count/2; i++) 39 | *simple_pntr++ = 'J'; 40 | 41 | if(count&0x1) 42 | *simple_pntr++ = 'I'; 43 | *simple_pntr++ = ')'; 44 | 45 | switch(*sig) { 46 | case 'Z': 47 | *simple_pntr++ = 'B'; 48 | break; 49 | 50 | case '[': 51 | *simple_pntr++ = 'L'; 52 | break; 53 | 54 | default: 55 | *simple_pntr++ = *sig; 56 | break; 57 | } 58 | 59 | *simple_pntr = '\0'; 60 | return simple_sig; 61 | } 62 | #endif 63 | 64 | -------------------------------------------------------------------------------- /src/jamvm/os/libretro/mips/Makefile.am: -------------------------------------------------------------------------------- 1 | ## 2 | ## Copyright (C) 2003, 2004, 2005, 2006, 2007, 2011 3 | ## Robert Lougher . 4 | ## 5 | ## This file is part of JamVM. 6 | ## 7 | ## This program is free software; you can redistribute it and/or 8 | ## modify it under the terms of the GNU General Public License 9 | ## as published by the Free Software Foundation; either version 2, 10 | ## or (at your option) any later version. 11 | ## 12 | ## This program is distributed in the hope that it will be useful, 13 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | ## GNU General Public License for more details. 16 | ## 17 | ## You should have received a copy of the GNU General Public License 18 | ## along with this program; if not, write to the Free Software 19 | ## Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | ## 21 | 22 | noinst_LTLIBRARIES = libnative.la 23 | libnative_la_SOURCES = init.c dll_md.c callNative.S 24 | 25 | AM_CPPFLAGS = -I$(top_builddir)/src 26 | AM_CCASFLAGS = -I$(top_builddir)/src 27 | -------------------------------------------------------------------------------- /src/jamvm/os/libretro/mips/dll_md.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2003, 2004, 2005, 2006, 2007 3 | * Robert Lougher . 4 | * 5 | * This file is part of JamVM. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2, 10 | * or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | #include "../../../jam.h" 23 | 24 | #ifndef USE_FFI 25 | int nativeExtraArg(MethodBlock *mb) { 26 | char *sig = mb->type; 27 | int args = 8; 28 | 29 | while(*++sig != ')') 30 | switch(*sig) { 31 | case 'J': 32 | case 'D': 33 | args = (args + 15) & ~7; 34 | break; 35 | 36 | default: 37 | args += 4; 38 | 39 | if(*sig == '[') 40 | while(*++sig == '['); 41 | if(*sig == 'L') 42 | while(*++sig != ';'); 43 | break; 44 | } 45 | 46 | return (args + 7) & ~7; 47 | } 48 | #endif 49 | -------------------------------------------------------------------------------- /src/jamvm/os/libretro/mips/init.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2003, 2004, 2006, 2007 3 | * Robert Lougher . 4 | * 5 | * This file is part of JamVM. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2, 10 | * or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | void initialisePlatform() { 23 | } 24 | -------------------------------------------------------------------------------- /src/jamvm/os/libretro/os.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2014 3 | * Robert Lougher . 4 | * 5 | * This file is part of JamVM. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2, 10 | * or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | #include "../../jam.h" 23 | #include "../../../libretro/libretro_exports.h" 24 | 25 | long long nativePhysicalMemory() { 26 | return system_memory_size; 27 | } 28 | 29 | void *nativeStackBase() { 30 | return NULL; 31 | } 32 | 33 | int nativeAvailableProcessors() { 34 | return 1; 35 | } 36 | 37 | char *nativeLibError() { 38 | //return dlerror(); 39 | return "Dynamic librarys are not supported with the libretro port.\n"; 40 | } 41 | 42 | char *nativeLibPath() { 43 | //return getenv("LD_LIBRARY_PATH"); 44 | return system_path; 45 | } 46 | 47 | void *nativeLibOpen(char *path) { 48 | //return dlopen(path, RTLD_LAZY); 49 | return NULL; 50 | } 51 | 52 | void nativeLibClose(void *handle) { 53 | //dlclose(handle); 54 | } 55 | 56 | void *nativeLibSym(void *handle, char *symbol) { 57 | return dlsym(handle, symbol); 58 | } 59 | 60 | char *nativeLibMapName(char *name) { 61 | char *buff = sysMalloc(strlen(name) + sizeof("lib.so") + 1); 62 | 63 | sprintf(buff, "lib%s.so", name); 64 | return buff; 65 | } 66 | 67 | char *nativeJVMPath() { 68 | //Should return $(retroarchsysdir)/javame 69 | /* 70 | Dl_info info; 71 | char *path; 72 | 73 | if(dladdr(nativeJVMPath, &info) == 0) { 74 | printf("Error: dladdr failed. Aborting VM\n"); 75 | exitVM(1); 76 | } 77 | 78 | path = sysMalloc(strlen(info.dli_fname) + 1); 79 | strcpy(path, info.dli_fname); 80 | 81 | return path; 82 | */ 83 | return system_path; 84 | } 85 | 86 | -------------------------------------------------------------------------------- /src/jamvm/os/libretro/parisc/Makefile.am: -------------------------------------------------------------------------------- 1 | ## 2 | ## Copyright (C) 2003, 2004, 2005, 2006, 2007 3 | ## Robert Lougher . 4 | ## 5 | ## This file is part of JamVM. 6 | ## 7 | ## This program is free software; you can redistribute it and/or 8 | ## modify it under the terms of the GNU General Public License 9 | ## as published by the Free Software Foundation; either version 2, 10 | ## or (at your option) any later version. 11 | ## 12 | ## This program is distributed in the hope that it will be useful, 13 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | ## GNU General Public License for more details. 16 | ## 17 | ## You should have received a copy of the GNU General Public License 18 | ## along with this program; if not, write to the Free Software 19 | ## Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | ## 21 | 22 | noinst_LTLIBRARIES = libnative.la 23 | libnative_la_SOURCES = init.c 24 | 25 | AM_CPPFLAGS = -I$(top_builddir)/src 26 | -------------------------------------------------------------------------------- /src/jamvm/os/libretro/parisc/init.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2003, 2004, 2005, 2006, 2007 3 | * Robert Lougher . 4 | * 5 | * This file is part of JamVM. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2, 10 | * or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | #include "arch/parisc.h" 23 | 24 | CasLock cas_lock; 25 | 26 | void initialisePlatform() { 27 | /* Initialise lock for compare_and_swap implementation */ 28 | cas_lock.lock = 1; 29 | } 30 | -------------------------------------------------------------------------------- /src/jamvm/os/libretro/powerpc/Makefile.am: -------------------------------------------------------------------------------- 1 | ## 2 | ## Copyright (C) 2003, 2004, 2005, 2006, 2007 3 | ## Robert Lougher . 4 | ## 5 | ## This file is part of JamVM. 6 | ## 7 | ## This program is free software; you can redistribute it and/or 8 | ## modify it under the terms of the GNU General Public License 9 | ## as published by the Free Software Foundation; either version 2, 10 | ## or (at your option) any later version. 11 | ## 12 | ## This program is distributed in the hope that it will be useful, 13 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | ## GNU General Public License for more details. 16 | ## 17 | ## You should have received a copy of the GNU General Public License 18 | ## along with this program; if not, write to the Free Software 19 | ## Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | ## 21 | 22 | noinst_LTLIBRARIES = libnative.la 23 | libnative_la_SOURCES = init.c dll_md.c callNative.S 24 | 25 | AM_CPPFLAGS = -I$(top_builddir)/src 26 | AM_CCASFLAGS = -I$(top_builddir)/src 27 | -------------------------------------------------------------------------------- /src/jamvm/os/libretro/powerpc/dll_md.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2003, 2004, 2005, 2006, 2007 3 | * Robert Lougher . 4 | * 5 | * This file is part of JamVM. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2, 10 | * or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | #include "../../../jam.h" 23 | 24 | #ifndef USE_FFI 25 | #include 26 | 27 | /* The PowerPC calling convention passes the first 8 integer 28 | and fp args in registers. After this, the arguments spill 29 | onto the stack. Because of long/double alignment, and arg 30 | ordering, we must scan the signature to calculate the extra 31 | stack requirements. This is done the first time the native 32 | method is called, and stored in the opaque "extra argument". 33 | */ 34 | 35 | int nativeExtraArg(MethodBlock *mb) { 36 | char *sig = mb->type; 37 | int iargs = 2; /* take into account the 2 extra arguments 38 | passed (JNIEnv and class/this). */ 39 | int fargs = 0; 40 | int margs = 0; 41 | 42 | while(*++sig != ')') 43 | switch(*sig) { 44 | case 'J': 45 | iargs = (iargs + 3) & ~1; 46 | if(iargs > 8) 47 | margs = (margs + 3) & ~1; 48 | break; 49 | 50 | case 'D': 51 | if(++fargs > 8) 52 | margs = (margs + 3) & ~1; 53 | break; 54 | 55 | case 'F': 56 | if(++fargs > 8) 57 | margs++; 58 | break; 59 | 60 | default: 61 | if(++iargs > 8) 62 | margs++; 63 | 64 | if(*sig == '[') 65 | while(*++sig == '['); 66 | if(*sig == 'L') 67 | while(*++sig != ';'); 68 | break; 69 | } 70 | 71 | #ifdef DEBUG_DLL 72 | jam_printf(" int args: %d fp args: %d stack: %d>\n", 73 | CLASS_CB(mb->class)->name, mb->name, mb->type, iargs, fargs, margs); 74 | #endif 75 | 76 | return margs; 77 | } 78 | #endif 79 | -------------------------------------------------------------------------------- /src/jamvm/os/libretro/powerpc/init.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2003, 2004, 2005, 2006, 2007 3 | * Robert Lougher . 4 | * 5 | * This file is part of JamVM. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2, 10 | * or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | void initialisePlatform() { 23 | /* Nothing to do for powerpc */ 24 | } 25 | -------------------------------------------------------------------------------- /src/jamvm/os/libretro/x86_64/Makefile.am: -------------------------------------------------------------------------------- 1 | ## 2 | ## Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2010 3 | ## Robert Lougher . 4 | ## 5 | ## This file is part of JamVM. 6 | ## 7 | ## This program is free software; you can redistribute it and/or 8 | ## modify it under the terms of the GNU General Public License 9 | ## as published by the Free Software Foundation; either version 2, 10 | ## or (at your option) any later version. 11 | ## 12 | ## This program is distributed in the hope that it will be useful, 13 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | ## GNU General Public License for more details. 16 | ## 17 | ## You should have received a copy of the GNU General Public License 18 | ## along with this program; if not, write to the Free Software 19 | ## Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | ## 21 | 22 | noinst_LTLIBRARIES = libnative.la 23 | libnative_la_SOURCES = init.c dll_md.c callNative.S 24 | 25 | AM_CPPFLAGS = -I$(top_builddir)/src -I$(top_srcdir)/src 26 | AM_CCASFLAGS = -I$(top_builddir)/src -I$(top_srcdir)/src 27 | -------------------------------------------------------------------------------- /src/jamvm/os/libretro/x86_64/dll_md.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008, 2010 Robert Lougher . 3 | * 4 | * This file is part of JamVM. 5 | * 6 | * This program is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License 8 | * as published by the Free Software Foundation; either version 2, 9 | * or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 19 | */ 20 | 21 | #include "jam.h" 22 | 23 | #ifndef USE_FFI 24 | #include 25 | 26 | int nativeExtraArg(MethodBlock *mb) { 27 | char *sig = mb->type; 28 | int stack_space; 29 | int iargs = 0; 30 | int fargs = 0; 31 | 32 | while(*++sig != ')') 33 | switch(*sig) { 34 | case 'D': 35 | case 'F': 36 | fargs++; 37 | break; 38 | 39 | default: 40 | iargs++; 41 | 42 | if(*sig == '[') 43 | while(*++sig == '['); 44 | if(*sig == 'L') 45 | while(*++sig != ';'); 46 | break; 47 | } 48 | 49 | stack_space = ((iargs > 4 ? iargs - 4 : 0) + 50 | (fargs > 8 ? fargs - 8 : 0)) << 3; 51 | 52 | /* Ensure the stack remains 16 byte aligned. As 53 | callJNIMethod pushes an even number of registers 54 | the extra space must also be even. */ 55 | return (stack_space + 15) & ~15; 56 | } 57 | #endif 58 | -------------------------------------------------------------------------------- /src/jamvm/os/libretro/x86_64/init.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2003, 2004, 2005, 2006, 2007 3 | * Robert Lougher . 4 | * 5 | * This file is part of JamVM. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2, 10 | * or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | #ifdef __linux__ 23 | #include 24 | #endif 25 | 26 | /* Change the x87 FPU precision to double (64-bit) from the extended 27 | (80-bit) Linux default. Note, unlike on i386, my testcases pass 28 | without this. This is probably because gcc assumes and uses SSE 29 | by default, not the x87 FPU. However, keep it in to be safe. 30 | */ 31 | 32 | void setDoublePrecision() { 33 | #ifdef __linux__ 34 | fpu_control_t cw; 35 | 36 | _FPU_GETCW(cw); 37 | cw &= ~_FPU_EXTENDED; 38 | cw |= _FPU_DOUBLE; 39 | _FPU_SETCW(cw); 40 | #endif 41 | } 42 | 43 | void initialisePlatform() { 44 | setDoublePrecision(); 45 | } 46 | -------------------------------------------------------------------------------- /src/jamvm/os/linux/Makefile.am: -------------------------------------------------------------------------------- 1 | ## 2 | ## Copyright (C) 2003, 2004, 2005, 2006, 2007 3 | ## Robert Lougher . 4 | ## 5 | ## This file is part of JamVM. 6 | ## 7 | ## This program is free software; you can redistribute it and/or 8 | ## modify it under the terms of the GNU General Public License 9 | ## as published by the Free Software Foundation; either version 2, 10 | ## or (at your option) any later version. 11 | ## 12 | ## This program is distributed in the hope that it will be useful, 13 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | ## GNU General Public License for more details. 16 | ## 17 | ## You should have received a copy of the GNU General Public License 18 | ## along with this program; if not, write to the Free Software 19 | ## Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | ## 21 | 22 | SUBDIRS = @arch@ 23 | DIST_SUBDIRS = powerpc arm i386 x86_64 parisc mips 24 | 25 | noinst_LTLIBRARIES = libos.la 26 | libos_la_SOURCES = os.c 27 | 28 | AM_CPPFLAGS = -I$(top_builddir)/src 29 | -------------------------------------------------------------------------------- /src/jamvm/os/linux/arm/Makefile.am: -------------------------------------------------------------------------------- 1 | ## 2 | ## Copyright (C) 2003, 2004, 2005, 2006, 2007, 2010, 2011, 2012 3 | ## Robert Lougher . 4 | ## 5 | ## This file is part of JamVM. 6 | ## 7 | ## This program is free software; you can redistribute it and/or 8 | ## modify it under the terms of the GNU General Public License 9 | ## as published by the Free Software Foundation; either version 2, 10 | ## or (at your option) any later version. 11 | ## 12 | ## This program is distributed in the hope that it will be useful, 13 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | ## GNU General Public License for more details. 16 | ## 17 | ## You should have received a copy of the GNU General Public License 18 | ## along with this program; if not, write to the Free Software 19 | ## Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | ## 21 | 22 | EXTRA_DIST = callNativeOABI.S callNativeEABI.S callNativeEABIHard.S \ 23 | callNativeEABIHardARM.S 24 | 25 | noinst_LTLIBRARIES = libnative.la 26 | libnative_la_SOURCES = init.c dll_md.c callNative.S 27 | 28 | AM_CPPFLAGS = -I$(top_builddir)/src -I$(top_srcdir)/src 29 | AM_CCASFLAGS = -I$(top_builddir)/src 30 | -------------------------------------------------------------------------------- /src/jamvm/os/linux/arm/callNative.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2011, 2012 3 | * Robert Lougher . 4 | * 5 | * This file is part of JamVM. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2, 10 | * or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | #include "config.h" 23 | 24 | #ifndef USE_FFI 25 | #ifdef __ARM_EABI__ 26 | #ifdef __ARM_PCS_VFP 27 | #ifdef __ARM_ARCH_7A__ 28 | #include "callNativeEABIHard.S" 29 | #else 30 | #include "callNativeEABIHardARM.S" 31 | #endif 32 | #else 33 | #include "callNativeEABI.S" 34 | #endif 35 | #else 36 | #include "callNativeOABI.S" 37 | #endif 38 | #endif 39 | -------------------------------------------------------------------------------- /src/jamvm/os/linux/arm/init.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2003, 2004, 2006, 2007 3 | * Robert Lougher . 4 | * 5 | * This file is part of JamVM. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2, 10 | * or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | void initialisePlatform() { 23 | /* Nothing to do for ARM */ 24 | } 25 | -------------------------------------------------------------------------------- /src/jamvm/os/linux/i386/Makefile.am: -------------------------------------------------------------------------------- 1 | ## 2 | ## Copyright (C) 2003, 2004, 2005, 2006, 2007, 2010 3 | ## Robert Lougher . 4 | ## 5 | ## This file is part of JamVM. 6 | ## 7 | ## This program is free software; you can redistribute it and/or 8 | ## modify it under the terms of the GNU General Public License 9 | ## as published by the Free Software Foundation; either version 2, 10 | ## or (at your option) any later version. 11 | ## 12 | ## This program is distributed in the hope that it will be useful, 13 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | ## GNU General Public License for more details. 16 | ## 17 | ## You should have received a copy of the GNU General Public License 18 | ## along with this program; if not, write to the Free Software 19 | ## Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | ## 21 | 22 | noinst_LTLIBRARIES = libnative.la 23 | libnative_la_SOURCES = init.c dll_md.c stubs_md.c jni-stubs.c 24 | 25 | AM_CPPFLAGS = -I$(top_builddir)/src -I$(top_srcdir)/src 26 | -------------------------------------------------------------------------------- /src/jamvm/os/linux/i386/init.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2003, 2004, 2006, 2007 3 | * Robert Lougher . 4 | * 5 | * This file is part of JamVM. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2, 10 | * or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | #include 23 | 24 | /* Change floating point precision to double (64-bit) from 25 | * the extended (80-bit) Linux default. */ 26 | 27 | void setDoublePrecision() { 28 | fpu_control_t cw; 29 | 30 | _FPU_GETCW(cw); 31 | cw &= ~_FPU_EXTENDED; 32 | cw |= _FPU_DOUBLE; 33 | _FPU_SETCW(cw); 34 | } 35 | 36 | void initialisePlatform() { 37 | setDoublePrecision(); 38 | } 39 | -------------------------------------------------------------------------------- /src/jamvm/os/linux/i386/stubs_md.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010, 2012 Robert Lougher . 3 | * 4 | * This file is part of JamVM. 5 | * 6 | * This program is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License 8 | * as published by the Free Software Foundation; either version 2, 9 | * or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 19 | */ 20 | 21 | #ifndef GEN_STUBS_INC 22 | #include "jam.h" 23 | #endif 24 | 25 | #if defined(GEN_STUBS_INC) || defined(USE_MD_STUBS) 26 | #include 27 | #include "sig.h" 28 | 29 | char *convertSig2Simple(char *sig) { 30 | char *simple_sig, *simple_pntr; 31 | int count = 0; 32 | int i; 33 | 34 | SCAN_SIG(sig, count+=2, count++); 35 | simple_sig = simple_pntr = sysMalloc((count + 1)/2 + 4); 36 | 37 | *simple_pntr++ = '('; 38 | for(i = 0; i < count/2; i++) 39 | *simple_pntr++ = 'J'; 40 | 41 | if(count&0x1) 42 | *simple_pntr++ = 'I'; 43 | *simple_pntr++ = ')'; 44 | 45 | switch(*sig) { 46 | case 'Z': 47 | *simple_pntr++ = 'B'; 48 | break; 49 | 50 | case '[': 51 | *simple_pntr++ = 'L'; 52 | break; 53 | 54 | default: 55 | *simple_pntr++ = *sig; 56 | break; 57 | } 58 | 59 | *simple_pntr = '\0'; 60 | return simple_sig; 61 | } 62 | #endif 63 | 64 | -------------------------------------------------------------------------------- /src/jamvm/os/linux/mips/Makefile.am: -------------------------------------------------------------------------------- 1 | ## 2 | ## Copyright (C) 2003, 2004, 2005, 2006, 2007, 2011 3 | ## Robert Lougher . 4 | ## 5 | ## This file is part of JamVM. 6 | ## 7 | ## This program is free software; you can redistribute it and/or 8 | ## modify it under the terms of the GNU General Public License 9 | ## as published by the Free Software Foundation; either version 2, 10 | ## or (at your option) any later version. 11 | ## 12 | ## This program is distributed in the hope that it will be useful, 13 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | ## GNU General Public License for more details. 16 | ## 17 | ## You should have received a copy of the GNU General Public License 18 | ## along with this program; if not, write to the Free Software 19 | ## Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | ## 21 | 22 | noinst_LTLIBRARIES = libnative.la 23 | libnative_la_SOURCES = init.c dll_md.c callNative.S 24 | 25 | AM_CPPFLAGS = -I$(top_builddir)/src 26 | AM_CCASFLAGS = -I$(top_builddir)/src 27 | -------------------------------------------------------------------------------- /src/jamvm/os/linux/mips/dll_md.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2003, 2004, 2005, 2006, 2007 3 | * Robert Lougher . 4 | * 5 | * This file is part of JamVM. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2, 10 | * or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | #include "../../../jam.h" 23 | 24 | #ifndef USE_FFI 25 | int nativeExtraArg(MethodBlock *mb) { 26 | char *sig = mb->type; 27 | int args = 8; 28 | 29 | while(*++sig != ')') 30 | switch(*sig) { 31 | case 'J': 32 | case 'D': 33 | args = (args + 15) & ~7; 34 | break; 35 | 36 | default: 37 | args += 4; 38 | 39 | if(*sig == '[') 40 | while(*++sig == '['); 41 | if(*sig == 'L') 42 | while(*++sig != ';'); 43 | break; 44 | } 45 | 46 | return (args + 7) & ~7; 47 | } 48 | #endif 49 | -------------------------------------------------------------------------------- /src/jamvm/os/linux/mips/init.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2003, 2004, 2006, 2007 3 | * Robert Lougher . 4 | * 5 | * This file is part of JamVM. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2, 10 | * or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | void initialisePlatform() { 23 | } 24 | -------------------------------------------------------------------------------- /src/jamvm/os/linux/os.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2014 3 | * Robert Lougher . 4 | * 5 | * This file is part of JamVM. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2, 10 | * or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | #define __USE_GNU 29 | #include 30 | #include 31 | 32 | #include "../../jam.h" 33 | 34 | long long nativePhysicalMemory() { 35 | /* Long longs are used here because with PAE, a 32-bit 36 | machine can have more than 4GB of physical memory */ 37 | 38 | long long num_pages = sysconf(_SC_PHYS_PAGES); 39 | long long page_size = sysconf(_SC_PAGESIZE); 40 | 41 | return num_pages * page_size; 42 | } 43 | 44 | void *nativeStackBase() { 45 | #ifdef __UCLIBC__ 46 | return NULL; 47 | #else 48 | pthread_attr_t attr; 49 | void *addr; 50 | size_t size; 51 | 52 | pthread_getattr_np(pthread_self(), &attr); 53 | pthread_attr_getstack(&attr, &addr, &size); 54 | 55 | return addr+size; 56 | #endif 57 | } 58 | 59 | int nativeAvailableProcessors() { 60 | #ifdef __UCLIBC__ 61 | return 1; 62 | #else 63 | return get_nprocs(); 64 | #endif 65 | } 66 | 67 | char *nativeLibError() { 68 | return dlerror(); 69 | } 70 | 71 | char *nativeLibPath() { 72 | return getenv("LD_LIBRARY_PATH"); 73 | } 74 | 75 | void *nativeLibOpen(char *path) { 76 | return dlopen(path, RTLD_LAZY); 77 | } 78 | 79 | void nativeLibClose(void *handle) { 80 | dlclose(handle); 81 | } 82 | 83 | void *nativeLibSym(void *handle, char *symbol) { 84 | return dlsym(handle, symbol); 85 | } 86 | 87 | char *nativeLibMapName(char *name) { 88 | char *buff = sysMalloc(strlen(name) + sizeof("lib.so") + 1); 89 | 90 | sprintf(buff, "lib%s.so", name); 91 | return buff; 92 | } 93 | 94 | char *nativeJVMPath() { 95 | Dl_info info; 96 | char *path; 97 | 98 | if(dladdr(nativeJVMPath, &info) == 0) { 99 | printf("Error: dladdr failed. Aborting VM\n"); 100 | exitVM(1); 101 | } 102 | 103 | path = sysMalloc(strlen(info.dli_fname) + 1); 104 | strcpy(path, info.dli_fname); 105 | 106 | return path; 107 | } 108 | 109 | -------------------------------------------------------------------------------- /src/jamvm/os/linux/parisc/Makefile.am: -------------------------------------------------------------------------------- 1 | ## 2 | ## Copyright (C) 2003, 2004, 2005, 2006, 2007 3 | ## Robert Lougher . 4 | ## 5 | ## This file is part of JamVM. 6 | ## 7 | ## This program is free software; you can redistribute it and/or 8 | ## modify it under the terms of the GNU General Public License 9 | ## as published by the Free Software Foundation; either version 2, 10 | ## or (at your option) any later version. 11 | ## 12 | ## This program is distributed in the hope that it will be useful, 13 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | ## GNU General Public License for more details. 16 | ## 17 | ## You should have received a copy of the GNU General Public License 18 | ## along with this program; if not, write to the Free Software 19 | ## Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | ## 21 | 22 | noinst_LTLIBRARIES = libnative.la 23 | libnative_la_SOURCES = init.c 24 | 25 | AM_CPPFLAGS = -I$(top_builddir)/src 26 | -------------------------------------------------------------------------------- /src/jamvm/os/linux/parisc/init.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2003, 2004, 2005, 2006, 2007 3 | * Robert Lougher . 4 | * 5 | * This file is part of JamVM. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2, 10 | * or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | #include "arch/parisc.h" 23 | 24 | CasLock cas_lock; 25 | 26 | void initialisePlatform() { 27 | /* Initialise lock for compare_and_swap implementation */ 28 | cas_lock.lock = 1; 29 | } 30 | -------------------------------------------------------------------------------- /src/jamvm/os/linux/powerpc/Makefile.am: -------------------------------------------------------------------------------- 1 | ## 2 | ## Copyright (C) 2003, 2004, 2005, 2006, 2007 3 | ## Robert Lougher . 4 | ## 5 | ## This file is part of JamVM. 6 | ## 7 | ## This program is free software; you can redistribute it and/or 8 | ## modify it under the terms of the GNU General Public License 9 | ## as published by the Free Software Foundation; either version 2, 10 | ## or (at your option) any later version. 11 | ## 12 | ## This program is distributed in the hope that it will be useful, 13 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | ## GNU General Public License for more details. 16 | ## 17 | ## You should have received a copy of the GNU General Public License 18 | ## along with this program; if not, write to the Free Software 19 | ## Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | ## 21 | 22 | noinst_LTLIBRARIES = libnative.la 23 | libnative_la_SOURCES = init.c dll_md.c callNative.S 24 | 25 | AM_CPPFLAGS = -I$(top_builddir)/src 26 | AM_CCASFLAGS = -I$(top_builddir)/src 27 | -------------------------------------------------------------------------------- /src/jamvm/os/linux/powerpc/dll_md.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2003, 2004, 2005, 2006, 2007 3 | * Robert Lougher . 4 | * 5 | * This file is part of JamVM. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2, 10 | * or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | #include "../../../jam.h" 23 | 24 | #ifndef USE_FFI 25 | #include 26 | 27 | /* The PowerPC calling convention passes the first 8 integer 28 | and fp args in registers. After this, the arguments spill 29 | onto the stack. Because of long/double alignment, and arg 30 | ordering, we must scan the signature to calculate the extra 31 | stack requirements. This is done the first time the native 32 | method is called, and stored in the opaque "extra argument". 33 | */ 34 | 35 | int nativeExtraArg(MethodBlock *mb) { 36 | char *sig = mb->type; 37 | int iargs = 2; /* take into account the 2 extra arguments 38 | passed (JNIEnv and class/this). */ 39 | int fargs = 0; 40 | int margs = 0; 41 | 42 | while(*++sig != ')') 43 | switch(*sig) { 44 | case 'J': 45 | iargs = (iargs + 3) & ~1; 46 | if(iargs > 8) 47 | margs = (margs + 3) & ~1; 48 | break; 49 | 50 | case 'D': 51 | if(++fargs > 8) 52 | margs = (margs + 3) & ~1; 53 | break; 54 | 55 | case 'F': 56 | if(++fargs > 8) 57 | margs++; 58 | break; 59 | 60 | default: 61 | if(++iargs > 8) 62 | margs++; 63 | 64 | if(*sig == '[') 65 | while(*++sig == '['); 66 | if(*sig == 'L') 67 | while(*++sig != ';'); 68 | break; 69 | } 70 | 71 | #ifdef DEBUG_DLL 72 | jam_printf(" int args: %d fp args: %d stack: %d>\n", 73 | CLASS_CB(mb->class)->name, mb->name, mb->type, iargs, fargs, margs); 74 | #endif 75 | 76 | return margs; 77 | } 78 | #endif 79 | -------------------------------------------------------------------------------- /src/jamvm/os/linux/powerpc/init.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2003, 2004, 2005, 2006, 2007 3 | * Robert Lougher . 4 | * 5 | * This file is part of JamVM. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2, 10 | * or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | void initialisePlatform() { 23 | /* Nothing to do for powerpc */ 24 | } 25 | -------------------------------------------------------------------------------- /src/jamvm/os/linux/x86_64/Makefile.am: -------------------------------------------------------------------------------- 1 | ## 2 | ## Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2010 3 | ## Robert Lougher . 4 | ## 5 | ## This file is part of JamVM. 6 | ## 7 | ## This program is free software; you can redistribute it and/or 8 | ## modify it under the terms of the GNU General Public License 9 | ## as published by the Free Software Foundation; either version 2, 10 | ## or (at your option) any later version. 11 | ## 12 | ## This program is distributed in the hope that it will be useful, 13 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | ## GNU General Public License for more details. 16 | ## 17 | ## You should have received a copy of the GNU General Public License 18 | ## along with this program; if not, write to the Free Software 19 | ## Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | ## 21 | 22 | noinst_LTLIBRARIES = libnative.la 23 | libnative_la_SOURCES = init.c dll_md.c callNative.S 24 | 25 | AM_CPPFLAGS = -I$(top_builddir)/src -I$(top_srcdir)/src 26 | AM_CCASFLAGS = -I$(top_builddir)/src -I$(top_srcdir)/src 27 | -------------------------------------------------------------------------------- /src/jamvm/os/linux/x86_64/dll_md.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008, 2010 Robert Lougher . 3 | * 4 | * This file is part of JamVM. 5 | * 6 | * This program is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License 8 | * as published by the Free Software Foundation; either version 2, 9 | * or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 19 | */ 20 | 21 | #include "jam.h" 22 | 23 | #ifndef USE_FFI 24 | #include 25 | 26 | int nativeExtraArg(MethodBlock *mb) { 27 | char *sig = mb->type; 28 | int stack_space; 29 | int iargs = 0; 30 | int fargs = 0; 31 | 32 | while(*++sig != ')') 33 | switch(*sig) { 34 | case 'D': 35 | case 'F': 36 | fargs++; 37 | break; 38 | 39 | default: 40 | iargs++; 41 | 42 | if(*sig == '[') 43 | while(*++sig == '['); 44 | if(*sig == 'L') 45 | while(*++sig != ';'); 46 | break; 47 | } 48 | 49 | stack_space = ((iargs > 4 ? iargs - 4 : 0) + 50 | (fargs > 8 ? fargs - 8 : 0)) << 3; 51 | 52 | /* Ensure the stack remains 16 byte aligned. As 53 | callJNIMethod pushes an even number of registers 54 | the extra space must also be even. */ 55 | return (stack_space + 15) & ~15; 56 | } 57 | #endif 58 | -------------------------------------------------------------------------------- /src/jamvm/os/linux/x86_64/init.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2003, 2004, 2005, 2006, 2007 3 | * Robert Lougher . 4 | * 5 | * This file is part of JamVM. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2, 10 | * or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | #ifdef __linux__ 23 | #include 24 | #endif 25 | 26 | /* Change the x87 FPU precision to double (64-bit) from the extended 27 | (80-bit) Linux default. Note, unlike on i386, my testcases pass 28 | without this. This is probably because gcc assumes and uses SSE 29 | by default, not the x87 FPU. However, keep it in to be safe. 30 | */ 31 | 32 | void setDoublePrecision() { 33 | #ifdef __linux__ 34 | fpu_control_t cw; 35 | 36 | _FPU_GETCW(cw); 37 | cw &= ~_FPU_EXTENDED; 38 | cw |= _FPU_DOUBLE; 39 | _FPU_SETCW(cw); 40 | #endif 41 | } 42 | 43 | void initialisePlatform() { 44 | setDoublePrecision(); 45 | } 46 | -------------------------------------------------------------------------------- /src/jamvm/os/solaris/Makefile.am: -------------------------------------------------------------------------------- 1 | ## 2 | ## Copyright (C) 2008 Robert Lougher . 3 | ## 4 | ## This file is part of JamVM. 5 | ## 6 | ## This program is free software; you can redistribute it and/or 7 | ## modify it under the terms of the GNU General Public License 8 | ## as published by the Free Software Foundation; either version 2, 9 | ## or (at your option) any later version. 10 | ## 11 | ## This program is distributed in the hope that it will be useful, 12 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | ## GNU General Public License for more details. 15 | ## 16 | ## You should have received a copy of the GNU General Public License 17 | ## along with this program; if not, write to the Free Software 18 | ## Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 19 | ## 20 | 21 | SUBDIRS = @arch@ 22 | DIST_SUBDIRS = x86 23 | 24 | noinst_LTLIBRARIES = libos.la 25 | libos_la_SOURCES = os.c 26 | 27 | AM_CPPFLAGS = -I$(top_builddir)/src 28 | -------------------------------------------------------------------------------- /src/jamvm/os/solaris/os.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008, 2009, 2014 Robert Lougher . 3 | * 4 | * This file is part of JamVM. 5 | * 6 | * This program is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License 8 | * as published by the Free Software Foundation; either version 2, 9 | * or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 19 | */ 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | #include "../../jam.h" 30 | 31 | void *nativeStackBase() { 32 | stack_t ss; 33 | 34 | thr_stksegment(&ss); 35 | return ss.ss_sp; 36 | } 37 | 38 | int nativeAvailableProcessors() { 39 | return sysconf(_SC_NPROCESSORS_ONLN); 40 | } 41 | 42 | char *nativeLibError() { 43 | return dlerror(); 44 | } 45 | 46 | char *nativeLibPath() { 47 | return getenv("LD_LIBRARY_PATH"); 48 | } 49 | 50 | void *nativeLibOpen(char *path) { 51 | return dlopen(path, RTLD_LAZY); 52 | } 53 | 54 | void nativeLibClose(void *handle) { 55 | dlclose(handle); 56 | } 57 | 58 | void *nativeLibSym(void *handle, char *symbol) { 59 | return dlsym(handle, symbol); 60 | } 61 | 62 | char *nativeLibMapName(char *name) { 63 | char *buff = sysMalloc(strlen(name) + sizeof("lib.so") + 1); 64 | 65 | sprintf(buff, "lib%s.so", name); 66 | return buff; 67 | } 68 | 69 | long long nativePhysicalMemory() { 70 | return 0; /* TBD */ 71 | } 72 | -------------------------------------------------------------------------------- /src/jamvm/os/solaris/x86/Makefile.am: -------------------------------------------------------------------------------- 1 | ## 2 | ## Copyright (C) 2008 Robert Lougher . 3 | ## 4 | ## This file is part of JamVM. 5 | ## 6 | ## This program is free software; you can redistribute it and/or 7 | ## modify it under the terms of the GNU General Public License 8 | ## as published by the Free Software Foundation; either version 2, 9 | ## or (at your option) any later version. 10 | ## 11 | ## This program is distributed in the hope that it will be useful, 12 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | ## GNU General Public License for more details. 15 | ## 16 | ## You should have received a copy of the GNU General Public License 17 | ## along with this program; if not, write to the Free Software 18 | ## Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 19 | ## 20 | 21 | noinst_LTLIBRARIES = libnative.la 22 | libnative_la_SOURCES = init.c dll_md.c callNative64.S 23 | 24 | AM_CPPFLAGS = -I$(top_builddir)/src 25 | AM_CCASFLAGS = -I$(top_builddir)/src 26 | -------------------------------------------------------------------------------- /src/jamvm/os/solaris/x86/init.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 Robert Lougher . 3 | * 4 | * This file is part of JamVM. 5 | * 6 | * This program is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License 8 | * as published by the Free Software Foundation; either version 2, 9 | * or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 19 | */ 20 | 21 | void setDoublePrecision() { 22 | unsigned short cw; 23 | 24 | asm("fnstcw %0" : "=m" (cw)); 25 | 26 | cw &= ~0x300; 27 | cw |= 0x200; 28 | 29 | asm("fldcw %0" :: "m" (cw)); 30 | } 31 | 32 | void initialisePlatform() { 33 | setDoublePrecision(); 34 | } 35 | -------------------------------------------------------------------------------- /src/jamvm/properties.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009 Robert Lougher . 3 | * 4 | * This file is part of JamVM. 5 | * 6 | * This program is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License 8 | * as published by the Free Software Foundation; either version 2, 9 | * or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 19 | */ 20 | 21 | /* If we have endian.h include it. Otherwise, include sys/param.h 22 | if we have it. If the BYTE_ORDER macro is still undefined, we 23 | fall-back, and work out the endianness ourselves at runtime -- 24 | this always works. 25 | */ 26 | #ifdef HAVE_ENDIAN_H 27 | #include 28 | #elif HAVE_SYS_PARAM_H 29 | #include 30 | #endif 31 | 32 | #if defined BYTE_ORDER 33 | #if BYTE_ORDER == BIG_ENDIAN 34 | #define IS_BIG_ENDIAN TRUE 35 | #else 36 | #define IS_BIG_ENDIAN FALSE 37 | #endif 38 | #elif defined _BIG_ENDIAN 39 | #define IS_BIG_ENDIAN TRUE 40 | #elif defined _LITTLE_ENDIAN 41 | #define IS_BIG_ENDIAN FALSE 42 | #else 43 | #define IS_BIG_ENDIAN ({ \ 44 | /* No byte-order macro -- work it out ourselves at runtime */ \ 45 | union { \ 46 | int i; \ 47 | char c[sizeof(int)]; \ 48 | } u; \ 49 | u.i = 1; \ 50 | u.c[sizeof(int)-1] == 1; \ 51 | }) 52 | #endif 53 | 54 | #define IS_BE64 (sizeof(uintptr_t) == 8 && IS_BIG_ENDIAN) 55 | -------------------------------------------------------------------------------- /src/jamvm/shutdown.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008, 2010 Robert Lougher . 3 | * 4 | * This file is part of JamVM. 5 | * 6 | * This program is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License 8 | * as published by the Free Software Foundation; either version 2, 9 | * or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 19 | */ 20 | 21 | #include "jam.h" 22 | 23 | void shutdownVM() { 24 | shutdownInterpreter(); 25 | shutdownDll(); 26 | } 27 | 28 | -------------------------------------------------------------------------------- /src/jamvm/sig.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009, 2012 Robert Lougher . 3 | * 4 | * This file is part of JamVM. 5 | * 6 | * This program is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License 8 | * as published by the Free Software Foundation; either version 2, 9 | * or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 19 | */ 20 | 21 | #include "jam.h" 22 | #include "sig.h" 23 | 24 | int sigElement2Size(char element) { 25 | switch(element) { 26 | case 'B': 27 | case 'Z': 28 | return 1; 29 | 30 | case 'C': 31 | case 'S': 32 | return 2; 33 | 34 | case 'I': 35 | case 'F': 36 | return 4; 37 | 38 | case 'L': 39 | case '[': 40 | return sizeof(Object*); 41 | 42 | default: 43 | return 8; 44 | } 45 | } 46 | 47 | int sigArgsCount(char *sig) { 48 | int count = 0; 49 | 50 | SCAN_SIG(sig, count+=2, count++); 51 | 52 | return count; 53 | } 54 | -------------------------------------------------------------------------------- /src/jamvm/sig.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2003, 2004, 2005, 2006, 2007 3 | * Robert Lougher . 4 | * 5 | * This file is part of JamVM. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2, 10 | * or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | #define SCAN_SIG(p, D, S) \ 23 | p++; /* skip start ( */ \ 24 | while(*p != ')') { \ 25 | if((*p == 'J') || (*p == 'D')) { \ 26 | D; \ 27 | p++; \ 28 | } else { \ 29 | S; \ 30 | if(*p == '[') \ 31 | for(p++; *p == '['; p++); \ 32 | if(*p == 'L') \ 33 | while(*p++ != ';'); \ 34 | else \ 35 | p++; \ 36 | } \ 37 | } \ 38 | p++; /* skip end ) */ 39 | -------------------------------------------------------------------------------- /src/jamvm/stubs.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011, 2012 Robert Lougher . 3 | * 4 | * This file is part of JamVM. 5 | * 6 | * This program is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License 8 | * as published by the Free Software Foundation; either version 2, 9 | * or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 19 | */ 20 | 21 | #ifndef GEN_STUBS_INC 22 | #include "jam.h" 23 | #endif 24 | 25 | #if defined(GEN_STUBS_INC) || !defined(USE_MD_STUBS) 26 | #include 27 | 28 | static char mapSigElement2Simple(char element) { 29 | switch(element) { 30 | case 'J': 31 | case 'D': 32 | case 'F': 33 | return element; 34 | 35 | default: 36 | return 'I'; 37 | } 38 | } 39 | 40 | static char mapRet2Simple(char element) { 41 | switch(element) { 42 | case 'Z': 43 | return 'B'; 44 | 45 | case '[': 46 | return 'L'; 47 | 48 | default: 49 | return element; 50 | } 51 | } 52 | 53 | char *convertSig2Simple(char *sig) { 54 | char *simple_sig = sysMalloc(strlen(sig) + 1); 55 | char *simple_pntr = simple_sig; 56 | char *sig_pntr = sig; 57 | 58 | *simple_pntr++ = '('; 59 | while(*++sig_pntr != ')') { 60 | *simple_pntr++ = mapSigElement2Simple(*sig_pntr); 61 | 62 | if(*sig_pntr == '[') 63 | while(*++sig_pntr == '['); 64 | if(*sig_pntr == 'L') 65 | while(*++sig_pntr != ';'); 66 | } 67 | 68 | *simple_pntr++ = ')'; 69 | *simple_pntr++ = mapRet2Simple(*++sig_pntr); 70 | *simple_pntr++ = '\0'; 71 | 72 | return sysRealloc(simple_sig, simple_pntr - simple_sig); 73 | } 74 | #endif 75 | 76 | -------------------------------------------------------------------------------- /src/jamvm/stubs.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 Robert Lougher . 3 | * 4 | * This file is part of JamVM. 5 | * 6 | * This program is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License 8 | * as published by the Free Software Foundation; either version 2, 9 | * or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 19 | */ 20 | 21 | typedef struct jni_stub { 22 | char *signature; 23 | NativeMethod func; 24 | #ifdef HAVE_PROFILE_STUBS 25 | unsigned int profile_count; 26 | #endif 27 | } JNIStub; 28 | 29 | extern JNIStub jni_stubs[]; 30 | extern JNIStub jni_static_stubs[]; 31 | -------------------------------------------------------------------------------- /src/jamvm/symbol.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008, 2010 Robert Lougher . 3 | * 4 | * This file is part of JamVM. 5 | * 6 | * This program is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License 8 | * as published by the Free Software Foundation; either version 2, 9 | * or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 19 | */ 20 | 21 | #include 22 | 23 | #include "jam.h" 24 | #include "symbol.h" 25 | 26 | #define SYMBOL_VALUE(name, value) value 27 | char *symbol_values[] = { 28 | CLASSLIB_SYMBOLS_DO(SYMBOL_VALUE), 29 | SYMBOLS_DO(SYMBOL_VALUE) 30 | }; 31 | 32 | int initialiseSymbol() { 33 | int i; 34 | 35 | for(i = 0; i < MAX_SYMBOL_ENUM; i++) 36 | if(symbol_values[i] != newUtf8(symbol_values[i])) { 37 | jam_fprintf(stderr, "Error when initialising VM symbols." 38 | " Aborting VM.\n"); 39 | return FALSE; 40 | } 41 | 42 | return TRUE; 43 | } 44 | -------------------------------------------------------------------------------- /src/jamvm/time.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 Robert Lougher . 3 | * 4 | * This file is part of JamVM. 5 | * 6 | * This program is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU General Public License 8 | * as published by the Free Software Foundation; either version 2, 9 | * or (at your option) any later version. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 19 | */ 20 | 21 | #include 22 | #include 23 | #include 24 | 25 | void getTimeoutAbsolute(struct timespec *ts, long long millis, 26 | long long nanos) { 27 | 28 | /* Calculate seconds (long long prevents overflow) */ 29 | long long seconds = millis / 1000 + nanos / 1000000000; 30 | 31 | /* Calculate nanoseconds */ 32 | nanos %= 1000000000; 33 | nanos += (millis % 1000) * 1000000; 34 | 35 | /* Adjust values so that nanos is less than 1 second */ 36 | if(nanos > 999999999) { 37 | seconds++; 38 | nanos -= 1000000000; 39 | } 40 | 41 | /* If seconds is too big to fit into the timespec use the 42 | maximum value (year 2038) */ 43 | ts->tv_sec = seconds > LONG_MAX ? LONG_MAX : seconds; 44 | ts->tv_nsec = nanos; 45 | } 46 | 47 | void getTimeoutRelative(struct timespec *ts, long long millis, 48 | long long nanos) { 49 | struct timeval tv; 50 | long long seconds; 51 | 52 | /* Get the current time */ 53 | gettimeofday(&tv, NULL); 54 | 55 | /* Calculate seconds (long long prevents overflow) */ 56 | seconds = tv.tv_sec + millis / 1000 + nanos / 1000000000; 57 | 58 | /* Calculate nanoseconds */ 59 | nanos %= 1000000000; 60 | nanos += (tv.tv_usec + ((millis % 1000) * 1000)) * 1000; 61 | 62 | /* Adjust values so that nanos is less than 1 second. 63 | This also prevents overflowing the timespec, as the 64 | value may be larger than tv_nsec (signed int) */ 65 | seconds += nanos / 1000000000; 66 | nanos %= 1000000000; 67 | 68 | /* If seconds is too big to fit into the timespec use the 69 | maximum value (year 2038) */ 70 | ts->tv_sec = seconds > LONG_MAX ? LONG_MAX : seconds; 71 | ts->tv_nsec = nanos; 72 | } 73 | 74 | -------------------------------------------------------------------------------- /src/jamvm/zip.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2003, 2004, 2005, 2006, 2007 3 | * Robert Lougher . 4 | * 5 | * This file is part of JamVM. 6 | * 7 | * This program is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU General Public License 9 | * as published by the Free Software Foundation; either version 2, 10 | * or (at your option) any later version. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software 19 | * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | 23 | typedef struct zip_file { 24 | int length; 25 | unsigned char *data; 26 | HashTable *dir_hash; 27 | } ZipFile; 28 | 29 | extern ZipFile *processArchive(char *path); 30 | extern char *findArchiveDirEntry(char *pathname, ZipFile *zip); 31 | extern char *findArchiveEntry(char *pathname, ZipFile *zip, int *entry_len); 32 | -------------------------------------------------------------------------------- /src/libretro/libretro-common/include/boolean.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2010-2017 The RetroArch team 2 | * 3 | * --------------------------------------------------------------------------------------- 4 | * The following license statement only applies to this file (boolean.h). 5 | * --------------------------------------------------------------------------------------- 6 | * 7 | * Permission is hereby granted, free of charge, 8 | * to any person obtaining a copy of this software and associated documentation files (the "Software"), 9 | * to deal in the Software without restriction, including without limitation the rights to 10 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, 11 | * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 16 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 18 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 19 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | #ifndef __LIBRETRO_SDK_BOOLEAN_H 24 | #define __LIBRETRO_SDK_BOOLEAN_H 25 | 26 | #ifndef __cplusplus 27 | 28 | #if defined(_MSC_VER) && !defined(SN_TARGET_PS3) 29 | /* Hack applied for MSVC when compiling in C89 mode as it isn't C99 compliant. */ 30 | #define bool unsigned char 31 | #define true 1 32 | #define false 0 33 | #else 34 | #include 35 | #endif 36 | 37 | #endif 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /src/libretro/libretro-common/include/retro_inline.h: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2010-2017 The RetroArch team 2 | * 3 | * --------------------------------------------------------------------------------------- 4 | * The following license statement only applies to this file (retro_inline.h). 5 | * --------------------------------------------------------------------------------------- 6 | * 7 | * Permission is hereby granted, free of charge, 8 | * to any person obtaining a copy of this software and associated documentation files (the "Software"), 9 | * to deal in the Software without restriction, including without limitation the rights to 10 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, 11 | * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 16 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 18 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 19 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | #ifndef __LIBRETRO_SDK_INLINE_H 24 | #define __LIBRETRO_SDK_INLINE_H 25 | 26 | #ifndef INLINE 27 | 28 | #if defined(_WIN32) || defined(__INTEL_COMPILER) 29 | #define INLINE __inline 30 | #elif defined(__STDC_VERSION__) && __STDC_VERSION__>=199901L 31 | #define INLINE inline 32 | #elif defined(__GNUC__) 33 | #define INLINE __inline__ 34 | #else 35 | #define INLINE 36 | #endif 37 | 38 | #endif 39 | #endif 40 | -------------------------------------------------------------------------------- /src/libretro/libretro-common/rthreads/xenon_sdl_threads.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2010-2017 The RetroArch team 2 | * 3 | * --------------------------------------------------------------------------------------- 4 | * The following license statement only applies to this file (xenon_sdl_threads.c). 5 | * --------------------------------------------------------------------------------------- 6 | * 7 | * Permission is hereby granted, free of charge, 8 | * to any person obtaining a copy of this software and associated documentation files (the "Software"), 9 | * to deal in the Software without restriction, including without limitation the rights to 10 | * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, 11 | * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 14 | * 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 16 | * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 18 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 19 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | */ 22 | 23 | /* libSDLxenon doesn't implement this yet :[. Implement it very stupidly for now. ;) */ 24 | 25 | #include "SDL_thread.h" 26 | #include "SDL_mutex.h" 27 | #include 28 | #include 29 | 30 | SDL_cond *SDL_CreateCond(void) 31 | { 32 | bool *sleeping = calloc(1, sizeof(*sleeping)); 33 | return (SDL_cond*)sleeping; 34 | } 35 | 36 | void SDL_DestroyCond(SDL_cond *sleeping) 37 | { 38 | free(sleeping); 39 | } 40 | 41 | int SDL_CondWait(SDL_cond *cond, SDL_mutex *lock) 42 | { 43 | (void)lock; 44 | volatile bool *sleeping = (volatile bool*)cond; 45 | 46 | SDL_mutexV(lock); 47 | *sleeping = true; 48 | while (*sleeping); /* Yeah, we all love busyloops don't we? ._. */ 49 | SDL_mutexP(lock); 50 | 51 | return 0; 52 | } 53 | 54 | int SDL_CondSignal(SDL_cond *cond) 55 | { 56 | *(volatile bool*)cond = false; 57 | return 0; 58 | } 59 | 60 | -------------------------------------------------------------------------------- /src/libretro/libretro_exports.h: -------------------------------------------------------------------------------- 1 | #ifndef LREXPORTS_ 2 | #define LREXPORTS_ 3 | 4 | extern long long system_memory_size; 5 | extern char system_path[]; 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /src/libretro/libretro_params.h: -------------------------------------------------------------------------------- 1 | #ifndef LREXPORTS_ 2 | #define LREXPORTS_ 3 | 4 | #define LR_SCREENWIDTH 320 5 | #define LR_SCREENHEIGHT 240 6 | #define LR_SCREENASPECT 16.0 / 10.0 7 | #define LR_SCREENFPS 60.0 8 | 9 | #define LR_SOUNDRATE 44100.0 10 | 11 | #define LR_CORENAME "JamVM" 12 | #define LR_LIBVERSION "2.0.0" 13 | #define LR_VALIDFILEEXT "jar|jad" 14 | #define LR_NEEDFILEPATH true 15 | #define LR_BLOCKARCEXTRACT false 16 | #define LR_REQUIRESROM false 17 | 18 | #define LR_KEYSONDEVICE 15 //Up, Down, Left, Right, Select and 0-9 on a phone pad 19 | 20 | #endif 21 | --------------------------------------------------------------------------------