Merge lp:~xranby/ubuntu/quantal/avian/lp1047395 into lp:ubuntu/quantal/avian

Proposed by Xerxes Rånby
Status: Merged
Merged at revision: 3
Proposed branch: lp:~xranby/ubuntu/quantal/avian/lp1047395
Merge into: lp:ubuntu/quantal/avian
Diff against target: 8268 lines (+40/-8135)
10 files modified
.pc/applied-patches (+0/-2)
.pc/dpkg-buildflags.diff/makefile (+3/-1)
.pc/soname.diff/makefile (+0/-1283)
.pc/version-info.diff/makefile (+0/-1287)
.pc/version-info.diff/src/classpath-openjdk.cpp (+0/-5544)
debian/changelog (+7/-0)
debian/patches/dpkg-buildflags.diff (+4/-4)
debian/patches/series (+0/-2)
makefile (+2/-1)
src/jnienv.cpp (+24/-11)
To merge this branch: bzr merge lp:~xranby/ubuntu/quantal/avian/lp1047395
Reviewer Review Type Date Requested Status
Matthias Klose Approve
Review via email: mp+123690@code.launchpad.net

Description of the change

Update using the latest Avian source .tar.gz from upstream 2012-09-10:
wget https://github.com/ReadyTalk/avian/tarball/master -O avian_0.6+20120910.orig.tar.gz

Removed patches that are now upsteam and close fixed lp1047395 bug.
https://bugs.launchpad.net/ubuntu/+source/avian/+bug/1047395
Tested on armhf:
java -avian -version
java version "1.7.0_07"
OpenJDK Runtime Environment (IcedTea7 2.3.2) (7u7-2.3.2-1ubuntu1)
Avian (build 0.6, package 0.6+20120910-0ubuntu2)

To post a comment you must log in.
Revision history for this message
Matthias Klose (doko) wrote :

merged

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '.pc/applied-patches'
2--- .pc/applied-patches 2012-09-05 12:24:24 +0000
3+++ .pc/applied-patches 2012-09-11 08:19:21 +0000
4@@ -1,3 +1,1 @@
5-soname.diff
6 dpkg-buildflags.diff
7-version-info.diff
8
9=== modified file '.pc/dpkg-buildflags.diff/makefile'
10--- .pc/dpkg-buildflags.diff/makefile 2012-09-05 12:24:24 +0000
11+++ .pc/dpkg-buildflags.diff/makefile 2012-09-11 08:19:21 +0000
12@@ -194,6 +194,7 @@
13 common-cflags = $(warnings) -fno-rtti -fno-exceptions -I$(classpath-src) \
14 "-I$(JAVA_HOME)/include" -idirafter $(src) -I$(build) $(classpath-cflags) \
15 -D__STDC_LIMIT_MACROS -D_JNI_IMPLEMENTATION_ -DAVIAN_VERSION=\"$(version)\" \
16+ -DAVIAN_INFO="\"$(info)\"" \
17 -DUSE_ATOMIC_OPERATIONS -DAVIAN_JAVA_HOME=\"$(javahome)\" \
18 -DAVIAN_EMBED_PREFIX=\"$(embed-prefix)\" $(target-cflags)
19
20@@ -1161,7 +1162,8 @@
21 -IMPLIB:$(build)/$(name).lib -MANIFESTFILE:$(@).manifest
22 $(mt) -manifest $(@).manifest -outputresource:"$(@);2"
23 else
24- $(ld) $(^) $(version-script-flag) $(soname-flag) $(shared) $(lflags) $(bootimage-lflags) \
25+ $(ld) $(^) $(version-script-flag) $(soname-flag) \
26+ $(shared) $(lflags) $(bootimage-lflags) \
27 -o $(@)
28 endif
29 $(strip) $(strip-all) $(@)
30
31=== removed directory '.pc/soname.diff'
32=== removed file '.pc/soname.diff/makefile'
33--- .pc/soname.diff/makefile 2012-09-05 12:24:24 +0000
34+++ .pc/soname.diff/makefile 1970-01-01 00:00:00 +0000
35@@ -1,1283 +0,0 @@
36-MAKEFLAGS = -s
37-
38-name = avian
39-version = 0.6
40-
41-build-arch := $(shell uname -m \
42- | sed 's/^i.86$$/i386/' \
43- | sed 's/^x86pc$$/i386/' \
44- | sed 's/amd64/x86_64/' \
45- | sed 's/^arm.*$$/arm/' \
46- | sed 's/ppc/powerpc/')
47-
48-ifeq (Power,$(filter Power,$(build-arch)))
49- build-arch = powerpc
50-endif
51-
52-build-platform := \
53- $(shell uname -s | tr [:upper:] [:lower:] \
54- | sed 's/^mingw32.*$$/mingw32/' \
55- | sed 's/^cygwin.*$$/cygwin/')
56-
57-arch = $(build-arch)
58-target-arch = $(arch)
59-bootimage-platform = \
60- $(subst cygwin,windows,$(subst mingw32,windows,$(build-platform)))
61-platform = $(bootimage-platform)
62-
63-mode = fast
64-process = compile
65-
66-ifneq ($(process),compile)
67- options := -$(process)
68-endif
69-ifneq ($(mode),fast)
70- options := $(options)-$(mode)
71-endif
72-ifneq ($(lzma),)
73- options := $(options)-lzma
74-endif
75-ifeq ($(bootimage),true)
76- options := $(options)-bootimage
77-endif
78-ifeq ($(heapdump),true)
79- options := $(options)-heapdump
80-endif
81-ifeq ($(tails),true)
82- options := $(options)-tails
83-endif
84-ifeq ($(continuations),true)
85- options := $(options)-continuations
86-endif
87-
88-root := $(shell (cd .. && pwd))
89-build = build/$(platform)-$(arch)$(options)
90-classpath-build = $(build)/classpath
91-test-build = $(build)/test
92-src = src
93-classpath-src = classpath
94-test = test
95-win32 ?= $(root)/win32
96-win64 ?= $(root)/win64
97-
98-classpath = avian
99-
100-test-executable = $(shell pwd)/$(executable)
101-boot-classpath = $(classpath-build)
102-embed-prefix = /avian-embedded
103-
104-native-path = echo
105-
106-ifeq ($(build-platform),cygwin)
107- native-path = cygpath -m
108-endif
109-
110-windows-path = echo
111-
112-path-separator = :
113-
114-ifneq (,$(filter mingw32 cygwin,$(build-platform)))
115- path-separator = ;
116-endif
117-
118-library-path-variable = LD_LIBRARY_PATH
119-
120-ifeq ($(build-platform),darwin)
121- library-path-variable = DYLD_LIBRARY_PATH
122-endif
123-
124-library-path = $(library-path-variable)=$(build)
125-
126-ifneq ($(openjdk),)
127- openjdk-arch = $(arch)
128- ifeq ($(arch),x86_64)
129- openjdk-arch = amd64
130- endif
131-
132- ifneq ($(openjdk-src),)
133- include openjdk-src.mk
134- options := $(options)-openjdk-src
135- classpath-objects = $(openjdk-objects) $(openjdk-local-objects)
136- classpath-cflags = -DAVIAN_OPENJDK_SRC -DBOOT_JAVAHOME
137- openjdk-jar-dep = $(build)/openjdk-jar.dep
138- classpath-jar-dep = $(openjdk-jar-dep)
139- javahome = $(embed-prefix)/javahomeJar
140- javahome-files = lib/zi lib/currency.data lib/security/java.security \
141- lib/security/java.policy lib/security/cacerts
142-
143- local-policy = lib/security/local_policy.jar
144- ifeq ($(shell test -e "$(openjdk)/$(local-policy)" && echo found),found)
145- javahome-files += $(local-policy)
146- endif
147-
148- export-policy = lib/security/US_export_policy.jar
149- ifeq ($(shell test -e "$(openjdk)/$(export-policy)" && echo found),found)
150- javahome-files += $(export-policy)
151- endif
152-
153- ifeq ($(platform),windows)
154- javahome-files += lib/tzmappings
155- endif
156- javahome-object = $(build)/javahome-jar.o
157- boot-javahome-object = $(build)/boot-javahome.o
158- else
159- options := $(options)-openjdk
160- test-executable = $(shell pwd)/$(executable-dynamic)
161- ifeq ($(build-platform),darwin)
162- library-path = \
163- $(library-path-variable)=$(build):$(openjdk)/jre/lib
164- else
165- library-path = \
166- $(library-path-variable)=$(build):$(openjdk)/jre/lib/$(openjdk-arch)
167- endif
168- javahome = "$$($(native-path) "$(openjdk)/jre")"
169- endif
170-
171- classpath = openjdk
172- boot-classpath := "$(boot-classpath)$(path-separator)$$($(native-path) "$(openjdk)/jre/lib/rt.jar")"
173- build-javahome = $(openjdk)/jre
174-endif
175-
176-ifeq ($(classpath),avian)
177- jni-sources := $(shell find $(classpath-src) -name '*.cpp')
178- jni-objects = $(call cpp-objects,$(jni-sources),$(classpath-src),$(build))
179- classpath-objects = $(jni-objects)
180-endif
181-
182-input = List
183-
184-ifeq ($(use-clang),true)
185- build-cxx = clang -std=c++11
186- build-cc = clang
187-else
188- build-cxx = g++
189- build-cc = gcc
190-endif
191-
192-mflag =
193-ifneq ($(platform),darwin)
194- ifeq ($(arch),i386)
195- mflag = -m32
196- endif
197- ifeq ($(arch),x86_64)
198- mflag = -m64
199- endif
200-endif
201-
202-target-format = elf
203-
204-cxx = $(build-cxx) $(mflag)
205-cc = $(build-cc) $(mflag)
206-
207-ar = ar
208-ranlib = ranlib
209-dlltool = dlltool
210-vg = nice valgrind --num-callers=32 --db-attach=yes --freelist-vol=100000000
211-vg += --leak-check=full --suppressions=valgrind.supp
212-db = gdb --args
213-javac = "$(JAVA_HOME)/bin/javac"
214-javah = "$(JAVA_HOME)/bin/javah"
215-jar = "$(JAVA_HOME)/bin/jar"
216-strip = strip
217-strip-all = --strip-all
218-
219-rdynamic = -rdynamic
220-
221-# note that we suppress the non-virtual-dtor warning because we never
222-# use the delete operator, which means we don't need virtual
223-# destructors:
224-warnings = -Wall -Wextra -Werror -Wunused-parameter -Winit-self \
225- -Wno-non-virtual-dtor
226-
227-target-cflags = -DTARGET_BYTES_PER_WORD=$(pointer-size)
228-
229-common-cflags = $(warnings) -fno-rtti -fno-exceptions -I$(classpath-src) \
230- "-I$(JAVA_HOME)/include" -idirafter $(src) -I$(build) $(classpath-cflags) \
231- -D__STDC_LIMIT_MACROS -D_JNI_IMPLEMENTATION_ -DAVIAN_VERSION=\"$(version)\" \
232- -DUSE_ATOMIC_OPERATIONS -DAVIAN_JAVA_HOME=\"$(javahome)\" \
233- -DAVIAN_EMBED_PREFIX=\"$(embed-prefix)\" $(target-cflags)
234-
235-asmflags = $(target-cflags)
236-
237-ifneq (,$(filter i386 x86_64,$(arch)))
238- ifeq ($(use-frame-pointer),true)
239- common-cflags += -fno-omit-frame-pointer -DAVIAN_USE_FRAME_POINTER
240- asmflags += -DAVIAN_USE_FRAME_POINTER
241- endif
242-endif
243-
244-build-cflags = $(common-cflags) -fPIC -fvisibility=hidden \
245- "-I$(JAVA_HOME)/include/linux" -I$(src) -pthread
246-
247-converter-cflags = -D__STDC_CONSTANT_MACROS -Isrc/binaryToObject -Isrc/ \
248- -fno-rtti -fno-exceptions \
249- -DAVIAN_TARGET_ARCH=AVIAN_ARCH_UNKNOWN \
250- -DAVIAN_TARGET_FORMAT=AVIAN_FORMAT_UNKNOWN \
251- -Wall -Wextra -Werror -Wunused-parameter -Winit-self -Wno-non-virtual-dtor
252-
253-cflags = $(build-cflags)
254-
255-common-lflags = -lm -lz $(classpath-lflags)
256-
257-build-lflags = -lz -lpthread -ldl
258-
259-lflags = $(common-lflags) -lpthread -ldl
260-
261-version-script-flag = -Wl,--version-script=openjdk.ld
262-
263-build-system = posix
264-
265-system = posix
266-asm = x86
267-
268-pointer-size = 8
269-
270-so-prefix = lib
271-so-suffix = .so
272-
273-shared = -shared
274-
275-no-error = -Wno-error
276-
277-openjdk-extra-cflags = -fvisibility=hidden
278-
279-bootimage-cflags = -DTARGET_BYTES_PER_WORD=$(pointer-size)
280-
281-developer-dir := $(shell if test -d /Developer; then echo /Developer; \
282- else echo /Applications/Xcode.app/Contents/Developer; fi)
283-
284-ifeq ($(build-arch),powerpc)
285- ifneq ($(arch),$(build-arch))
286- bootimage-cflags += -DTARGET_OPPOSITE_ENDIAN
287- endif
288-endif
289-
290-ifeq ($(arch),i386)
291- pointer-size = 4
292-endif
293-
294-ifeq ($(arch),powerpc)
295- asm = powerpc
296- pointer-size = 4
297-
298- ifneq ($(arch),$(build-arch))
299- bootimage-cflags += -DTARGET_OPPOSITE_ENDIAN
300- endif
301-
302- ifneq ($(platform),darwin)
303- ifneq ($(arch),$(build-arch))
304- cxx = powerpc-linux-gnu-g++
305- cc = powerpc-linux-gnu-gcc
306- ar = powerpc-linux-gnu-ar
307- ranlib = powerpc-linux-gnu-ranlib
308- strip = powerpc-linux-gnu-strip
309- endif
310- endif
311-endif
312-
313-ifeq ($(arch),arm)
314- asm = arm
315- pointer-size = 4
316-
317- ifeq ($(build-platform),darwin)
318- ios = true
319- else
320- no-psabi = -Wno-psabi
321- cflags += -marm $(no-psabi)
322- endif
323-
324- ifneq ($(arch),$(build-arch))
325- ifeq ($(platform),darwin)
326- ios-bin = $(developer-dir)/Platforms/iPhoneOS.platform/Developer/usr/bin
327- cxx = $(ios-bin)/g++
328- cc = $(ios-bin)/gcc
329- ar = $(ios-bin)/ar
330- ranlib = $(ios-bin)/ranlib
331- strip = $(ios-bin)/strip
332- else
333- cxx = arm-linux-gnueabi-g++
334- cc = arm-linux-gnueabi-gcc
335- ar = arm-linux-gnueabi-ar
336- ranlib = arm-linux-gnueabi-ranlib
337- strip = arm-linux-gnueabi-strip
338- endif
339- endif
340-endif
341-
342-ifeq ($(ios),true)
343- cflags += -DAVIAN_IOS
344-endif
345-
346-ifeq ($(build-platform),darwin)
347- build-cflags = $(common-cflags) -fPIC -fvisibility=hidden -I$(src)
348- cflags += -I/System/Library/Frameworks/JavaVM.framework/Headers/
349- build-lflags += -framework CoreFoundation
350-endif
351-
352-ifeq ($(platform),qnx)
353- cflags = $(common-cflags) -fPIC -fvisibility=hidden -I$(src)
354- lflags = $(common-lflags) -lsocket
355- ifeq ($(build-platform),qnx)
356- build-cflags = $(common-cflags) -fPIC -fvisibility=hidden -I$(src)
357- build-lflags = $(common-lflags)
358- else
359- ifeq ($(arch),i386)
360- prefix = i486-pc-nto-qnx6.5.0-
361- else
362- prefix = arm-unknown-nto-qnx6.5.0-
363- endif
364- endif
365- cxx = $(prefix)g++
366- cc = $(prefix)gcc
367- ar = $(prefix)ar
368- ranlib = $(prefix)ranlib
369- strip = $(prefix)strip
370- rdynamic = -Wl,--export-dynamic
371-endif
372-
373-ifeq ($(platform),freebsd)
374-# There is no -ldl on FreeBSD
375- build-lflags = $(common-lflags) -lz -lpthread
376- lflags = $(common-lflags) -lpthread
377-# include/freebsd instead of include/linux
378- build-cflags = $(common-cflags) -fPIC -fvisibility=hidden \
379- "-I$(JAVA_HOME)/include/freebsd" -I$(src) -pthread
380- cflags = $(build-cflags)
381-endif
382-
383-ifeq ($(platform),darwin)
384- target-format = macho
385- ifeq (${OSX_SDK_SYSROOT},)
386- OSX_SDK_SYSROOT = 10.4u
387- endif
388- ifeq (${OSX_SDK_VERSION},)
389- OSX_SDK_VERSION = 10.4
390- endif
391- ifneq ($(build-platform),darwin)
392- cxx = i686-apple-darwin8-g++ $(mflag)
393- cc = i686-apple-darwin8-gcc $(mflag)
394- ar = i686-apple-darwin8-ar
395- ranlib = i686-apple-darwin8-ranlib
396- strip = i686-apple-darwin8-strip
397- sysroot = /opt/mac/SDKs/MacOSX${OSX_SDK_SYSROOT}.sdk
398- cflags = -I$(sysroot)/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Headers/ \
399- $(common-cflags) -fPIC -fvisibility=hidden -I$(src)
400- endif
401-
402- version-script-flag =
403- lflags = $(common-lflags) -ldl -framework CoreFoundation
404-
405- ifeq (,$(shell ld -v 2>&1 | grep cctools))
406- lflags += -Wl,-compatibility_version,1.0.0
407- endif
408-
409- ifneq ($(arch),arm)
410- lflags += -framework CoreServices -framework SystemConfiguration \
411- -framework Security
412- endif
413- ifeq ($(bootimage),true)
414- bootimage-lflags = -Wl,-segprot,__RWX,rwx,rwx
415- endif
416- rdynamic =
417- strip-all = -S -x
418- so-suffix = .dylib
419- shared = -dynamiclib
420-
421- sdk-dir = $(developer-dir)/Platforms/iPhoneOS.platform/Developer/SDKs
422-
423- ifeq ($(arch),arm)
424- ios-version := \
425- $(shell if test -d $(sdk-dir)/iPhoneOS5.1.sdk; then echo 5.1; \
426- elif test -d $(sdk-dir)/iPhoneOS5.0.sdk; then echo 5.0; \
427- elif test -d $(sdk-dir)/iPhoneOS4.3.sdk; then echo 4.3; \
428- elif test -d $(sdk-dir)/iPhoneOS4.2.sdk; then echo 4.2; \
429- else echo; fi)
430-
431- ifeq ($(ios-version),)
432- x := $(error "couldn't find SDK for iOS version")
433- endif
434-
435- flags = -arch armv7 -isysroot \
436- $(sdk-dir)/iPhoneOS$(ios-version).sdk/
437- openjdk-extra-cflags += $(flags)
438- cflags += $(flags)
439- asmflags += $(flags)
440- lflags += $(flags)
441- endif
442-
443- ifeq ($(arch),powerpc)
444- openjdk-extra-cflags += -arch ppc -mmacosx-version-min=${OSX_SDK_VERSION}
445- cflags += -arch ppc -mmacosx-version-min=${OSX_SDK_VERSION}
446- asmflags += -arch ppc -mmacosx-version-min=${OSX_SDK_VERSION}
447- lflags += -arch ppc -mmacosx-version-min=${OSX_SDK_VERSION}
448- endif
449-
450- ifeq ($(arch),i386)
451- openjdk-extra-cflags += -arch i386 -mmacosx-version-min=${OSX_SDK_VERSION}
452- cflags += -arch i386 -mmacosx-version-min=${OSX_SDK_VERSION}
453- asmflags += -arch i386 -mmacosx-version-min=${OSX_SDK_VERSION}
454- lflags += -arch i386 -mmacosx-version-min=${OSX_SDK_VERSION}
455- endif
456-
457- ifeq ($(arch),x86_64)
458- openjdk-extra-cflags += -arch x86_64
459- cflags += -arch x86_64
460- asmflags += -arch x86_64
461- lflags += -arch x86_64
462- endif
463-endif
464-
465-ifeq ($(platform),windows)
466- target-format = pe
467-
468- inc = "$(win32)/include"
469- lib = "$(win32)/lib"
470-
471- embed-prefix = c:/avian-embedded
472-
473- system = windows
474-
475- so-prefix =
476- so-suffix = .dll
477- exe-suffix = .exe
478-
479- lflags = -L$(lib) $(common-lflags) -lws2_32 -liphlpapi -mwindows -mconsole
480- cflags = -I$(inc) $(common-cflags) -DWINVER=0x0500
481-
482- ifeq (,$(filter mingw32 cygwin,$(build-platform)))
483- openjdk-extra-cflags += -I$(src)/openjdk/caseSensitive
484- prefix := $(shell i686-w64-mingw32-gcc --version >/dev/null 2>&1 \
485- && echo i686-w64-mingw32- || echo x86_64-w64-mingw32-)
486- cxx = $(prefix)g++ -m32
487- cc = $(prefix)gcc -m32
488- dlltool = $(prefix)dlltool -mi386 --as-flags=--32
489- ar = $(prefix)ar
490- ranlib = $(prefix)ranlib
491- strip = $(prefix)strip --strip-all
492- else
493- build-system = windows
494- common-cflags += "-I$(JAVA_HOME)/include/win32"
495- build-cflags = $(common-cflags) -I$(src) -I$(inc) -mthreads
496- openjdk-extra-cflags =
497- build-lflags = -L$(lib) $(common-lflags)
498- ifeq ($(build-platform),cygwin)
499- build-cxx = i686-w64-mingw32-g++
500- build-cc = i686-w64-mingw32-gcc
501- dlltool = i686-w64-mingw32-dlltool
502- ar = i686-w64-mingw32-ar
503- ranlib = i686-w64-mingw32-ranlib
504- strip = i686-w64-mingw32-strip
505- endif
506- endif
507-
508- ifeq ($(arch),x86_64)
509- ifeq ($(build-platform),cygwin)
510- build-cxx = x86_64-w64-mingw32-g++
511- build-cc = x86_64-w64-mingw32-gcc
512- endif
513- cxx = x86_64-w64-mingw32-g++ $(mflag)
514- cc = x86_64-w64-mingw32-gcc $(mflag)
515- dlltool = x86_64-w64-mingw32-dlltool
516- ar = x86_64-w64-mingw32-ar
517- ranlib = x86_64-w64-mingw32-ranlib
518- strip = x86_64-w64-mingw32-strip
519- inc = "$(win64)/include"
520- lib = "$(win64)/lib"
521- else
522- shared += -Wl,--add-stdcall-alias
523- endif
524-endif
525-
526-ifeq ($(mode),debug)
527- optimization-cflags = -O0 -g3
528- converter-cflags += -O0 -g3
529- strip = :
530-endif
531-ifeq ($(mode),debug-fast)
532- optimization-cflags = -O0 -g3 -DNDEBUG
533- strip = :
534-endif
535-ifeq ($(mode),stress)
536- optimization-cflags = -O0 -g3 -DVM_STRESS
537- strip = :
538-endif
539-ifeq ($(mode),stress-major)
540- optimization-cflags = -O0 -g3 -DVM_STRESS -DVM_STRESS_MAJOR
541- strip = :
542-endif
543-ifeq ($(mode),fast)
544- ifeq ($(use-clang),true)
545- optimization-cflags = -O4 -g3 -DNDEBUG
546- else
547- optimization-cflags = -O3 -g3 -DNDEBUG
548- endif
549- use-lto = true
550-endif
551-ifeq ($(mode),small)
552- ifeq ($(use-clang),true)
553- optimization-cflags = -Oz -g3 -DNDEBUG
554- else
555- optimization-cflags = -Os -g3 -DNDEBUG
556- endif
557- use-lto = true
558-endif
559-
560-ifeq ($(use-lto),true)
561- ifeq ($(use-clang),true)
562- optimization-cflags += -flto
563- lflags += $(optimization-cflags)
564- else
565-# only try to use LTO when GCC 4.6.0 or greater is available
566- gcc-major := $(shell $(cc) -dumpversion | cut -f1 -d.)
567- gcc-minor := $(shell $(cc) -dumpversion | cut -f2 -d.)
568- ifeq ($(shell expr 4 \< $(gcc-major) \
569- \| \( 4 \<= $(gcc-major) \& 6 \<= $(gcc-minor) \)),1)
570- optimization-cflags += -flto
571- no-lto = -fno-lto
572- lflags += $(optimization-cflags)
573- endif
574- endif
575-endif
576-
577-cflags += $(optimization-cflags)
578-
579-ifneq ($(platform),darwin)
580-ifeq ($(arch),i386)
581-# this is necessary to support __sync_bool_compare_and_swap:
582- cflags += -march=i586
583- lflags += -march=i586
584-endif
585-endif
586-
587-output = -o $(1)
588-as := $(cc)
589-ld := $(cc)
590-build-ld := $(build-cc)
591-
592-ifdef msvc
593- no-error =
594- windows-path = $(native-path)
595- windows-java-home := $(shell $(windows-path) "$(JAVA_HOME)")
596- zlib := $(shell $(windows-path) "$(win32)/msvc")
597- cxx = "$(msvc)/BIN/cl.exe"
598- cc = $(cxx)
599- ld = "$(msvc)/BIN/link.exe"
600- mt = "mt.exe"
601- cflags = -nologo -DAVIAN_VERSION=\"$(version)\" -D_JNI_IMPLEMENTATION_ \
602- -DUSE_ATOMIC_OPERATIONS -DAVIAN_JAVA_HOME=\"$(javahome)\" \
603- -DAVIAN_EMBED_PREFIX=\"$(embed-prefix)\" \
604- -Fd$(build)/$(name).pdb -I"$(zlib)/include" -I$(src) -I$(classpath-src) \
605- -I"$(build)" \
606- -I"$(windows-java-home)/include" -I"$(windows-java-home)/include/win32" \
607- -DTARGET_BYTES_PER_WORD=$(pointer-size)
608-
609- ifneq ($(lzma),)
610- cflags += -I$(shell $(windows-path) "$(lzma)")
611- endif
612-
613- shared = -dll
614- lflags = -nologo -LIBPATH:"$(zlib)/lib" -DEFAULTLIB:ws2_32 \
615- -DEFAULTLIB:zlib -MANIFEST -debug
616- output = -Fo$(1)
617-
618- ifeq ($(mode),debug)
619- cflags += -Od -Zi -MDd
620- endif
621- ifeq ($(mode),debug-fast)
622- cflags += -Od -Zi -DNDEBUG
623- endif
624- ifeq ($(mode),fast)
625- cflags += -O2 -GL -Zi -DNDEBUG
626- lflags += -LTCG
627- endif
628- ifeq ($(mode),small)
629- cflags += -O1s -Zi -GL -DNDEBUG
630- lflags += -LTCG
631- endif
632-
633- strip = :
634-endif
635-
636-c-objects = $(foreach x,$(1),$(patsubst $(2)/%.c,$(3)/%.o,$(x)))
637-cpp-objects = $(foreach x,$(1),$(patsubst $(2)/%.cpp,$(3)/%.o,$(x)))
638-asm-objects = $(foreach x,$(1),$(patsubst $(2)/%.S,$(3)/%-asm.o,$(x)))
639-java-classes = $(foreach x,$(1),$(patsubst $(2)/%.java,$(3)/%.class,$(x)))
640-
641-generated-code = \
642- $(build)/type-enums.cpp \
643- $(build)/type-declarations.cpp \
644- $(build)/type-constructors.cpp \
645- $(build)/type-initializations.cpp \
646- $(build)/type-java-initializations.cpp \
647- $(build)/type-name-initializations.cpp \
648- $(build)/type-maps.cpp
649-
650-vm-depends := $(generated-code) $(wildcard $(src)/*.h)
651-
652-vm-sources = \
653- $(src)/$(system).cpp \
654- $(src)/finder.cpp \
655- $(src)/machine.cpp \
656- $(src)/util.cpp \
657- $(src)/heap.cpp \
658- $(src)/$(process).cpp \
659- $(src)/classpath-$(classpath).cpp \
660- $(src)/builtin.cpp \
661- $(src)/jnienv.cpp \
662- $(src)/process.cpp
663-
664-vm-asm-sources = $(src)/$(asm).S
665-
666-target-asm = $(asm)
667-
668-ifeq ($(process),compile)
669- vm-sources += \
670- $(src)/compiler.cpp \
671- $(src)/$(target-asm).cpp
672-
673- vm-asm-sources += $(src)/compile-$(asm).S
674-endif
675-
676-vm-cpp-objects = $(call cpp-objects,$(vm-sources),$(src),$(build))
677-vm-asm-objects = $(call asm-objects,$(vm-asm-sources),$(src),$(build))
678-vm-objects = $(vm-cpp-objects) $(vm-asm-objects)
679-
680-heapwalk-sources = $(src)/heapwalk.cpp
681-heapwalk-objects = \
682- $(call cpp-objects,$(heapwalk-sources),$(src),$(build))
683-
684-ifeq ($(heapdump),true)
685- vm-sources += $(src)/heapdump.cpp
686- vm-heapwalk-objects = $(heapwalk-objects)
687- cflags += -DAVIAN_HEAPDUMP
688-endif
689-
690-ifeq ($(tails),true)
691- cflags += -DAVIAN_TAILS
692-endif
693-
694-ifeq ($(continuations),true)
695- cflags += -DAVIAN_CONTINUATIONS
696- asmflags += -DAVIAN_CONTINUATIONS
697-endif
698-
699-bootimage-generator-sources = $(src)/bootimage.cpp
700-ifneq ($(lzma),)
701- bootimage-generator-sources += $(src)/lzma-encode.cpp
702-endif
703-bootimage-generator-objects = \
704- $(call cpp-objects,$(bootimage-generator-sources),$(src),$(build))
705-bootimage-generator = $(build)/bootimage-generator
706-
707-bootimage-object = $(build)/bootimage-bin.o
708-codeimage-object = $(build)/codeimage-bin.o
709-
710-ifeq ($(bootimage),true)
711- vm-classpath-objects = $(bootimage-object) $(codeimage-object)
712- cflags += -DBOOT_IMAGE -DAVIAN_CLASSPATH=\"\"
713-else
714- vm-classpath-objects = $(classpath-object)
715- cflags += -DBOOT_CLASSPATH=\"[classpathJar]\" \
716- -DAVIAN_CLASSPATH=\"[classpathJar]\"
717-endif
718-
719-cflags += $(extra-cflags)
720-lflags += $(extra-lflags)
721-
722-openjdk-cflags += $(extra-cflags)
723-
724-driver-source = $(src)/main.cpp
725-driver-object = $(build)/main.o
726-driver-dynamic-objects = \
727- $(build)/main-dynamic.o
728-
729-boot-source = $(src)/boot.cpp
730-boot-object = $(build)/boot.o
731-
732-generator-depends := $(wildcard $(src)/*.h)
733-generator-sources = \
734- $(src)/type-generator.cpp \
735- $(src)/$(build-system).cpp \
736- $(src)/finder.cpp
737-
738-ifneq ($(lzma),)
739- common-cflags += -I$(lzma) -DAVIAN_USE_LZMA -D_7ZIP_ST
740-
741- vm-sources += \
742- $(src)/lzma-decode.cpp
743-
744- generator-sources += \
745- $(src)/lzma-decode.cpp
746-
747- lzma-decode-sources = \
748- $(lzma)/C/LzmaDec.c
749-
750- lzma-decode-objects = \
751- $(call c-objects,$(lzma-decode-sources),$(lzma)/C,$(build))
752-
753- lzma-encode-sources = \
754- $(lzma)/C/LzmaEnc.c \
755- $(lzma)/C/LzFind.c
756-
757- lzma-encode-objects = \
758- $(call c-objects,$(lzma-encode-sources),$(lzma)/C,$(build))
759-
760- lzma-encoder = $(build)/lzma/lzma
761-
762- lzma-encoder-cflags = -D__STDC_CONSTANT_MACROS -fno-rtti -fno-exceptions \
763- -I$(lzma)/C
764-
765- lzma-encoder-sources = \
766- $(src)/lzma/main.cpp
767-
768- lzma-encoder-objects = \
769- $(call cpp-objects,$(lzma-encoder-sources),$(src),$(build))
770-
771- lzma-encoder-lzma-sources = $(lzma-encode-sources) $(lzma-decode-sources)
772-
773- lzma-encoder-lzma-objects = \
774- $(call generator-c-objects,$(lzma-encoder-lzma-sources),$(lzma)/C,$(build))
775-
776- lzma-loader = $(build)/lzma/load.o
777-endif
778-
779-generator-cpp-objects = \
780- $(foreach x,$(1),$(patsubst $(2)/%.cpp,$(3)/%-build.o,$(x)))
781-generator-c-objects = \
782- $(foreach x,$(1),$(patsubst $(2)/%.c,$(3)/%-build.o,$(x)))
783-generator-objects = \
784- $(call generator-cpp-objects,$(generator-sources),$(src),$(build))
785-generator-lzma-objects = \
786- $(call generator-c-objects,$(lzma-decode-sources),$(lzma)/C,$(build))
787-generator = $(build)/generator
788-
789-converter-depends = \
790- $(src)/binaryToObject/tools.h \
791- $(src)/binaryToObject/endianness.h
792-
793-converter-sources = \
794- $(src)/binaryToObject/tools.cpp \
795- $(src)/binaryToObject/elf.cpp \
796- $(src)/binaryToObject/mach-o.cpp \
797- $(src)/binaryToObject/pe.cpp
798-
799-converter-tool-sources = \
800- $(src)/binaryToObject/main.cpp
801-
802-converter-objects = $(call cpp-objects,$(converter-sources),$(src),$(build))
803-converter-tool-objects = $(call cpp-objects,$(converter-tool-sources),$(src),$(build))
804-converter = $(build)/binaryToObject/binaryToObject
805-
806-static-library = $(build)/lib$(name).a
807-executable = $(build)/$(name)${exe-suffix}
808-dynamic-library = $(build)/$(so-prefix)jvm$(so-suffix)
809-executable-dynamic = $(build)/$(name)-dynamic${exe-suffix}
810-
811-ifneq ($(classpath),avian)
812-# Assembler, ConstantPool, and Stream are not technically needed for a
813-# working build, but we include them since our Subroutine test uses
814-# them to synthesize a class:
815- classpath-sources := \
816- $(classpath-src)/avian/Addendum.java \
817- $(classpath-src)/avian/Assembler.java \
818- $(classpath-src)/avian/Callback.java \
819- $(classpath-src)/avian/CallbackReceiver.java \
820- $(classpath-src)/avian/ClassAddendum.java \
821- $(classpath-src)/avian/Classes.java \
822- $(classpath-src)/avian/ConstantPool.java \
823- $(classpath-src)/avian/Continuations.java \
824- $(classpath-src)/avian/FieldAddendum.java \
825- $(classpath-src)/avian/IncompatibleContinuationException.java \
826- $(classpath-src)/avian/Machine.java \
827- $(classpath-src)/avian/MethodAddendum.java \
828- $(classpath-src)/avian/Singleton.java \
829- $(classpath-src)/avian/Stream.java \
830- $(classpath-src)/avian/SystemClassLoader.java \
831- $(classpath-src)/avian/VMClass.java \
832- $(classpath-src)/avian/VMField.java \
833- $(classpath-src)/avian/VMMethod.java \
834- $(classpath-src)/avian/avian_vm_resource/Handler.java
835-
836- ifneq ($(openjdk),)
837- classpath-sources := $(classpath-sources) \
838- $(classpath-src)/avian/OpenJDK.java
839- endif
840-else
841- classpath-sources := $(shell find $(classpath-src) -name '*.java')
842-endif
843-
844-classpath-classes = \
845- $(call java-classes,$(classpath-sources),$(classpath-src),$(classpath-build))
846-classpath-object = $(build)/classpath-jar.o
847-classpath-dep = $(classpath-build).dep
848-
849-vm-classes = \
850- avian/*.class \
851- avian/resource/*.class
852-
853-test-support-sources = $(shell find $(test)/avian/ -name '*.java')
854-test-sources = $(wildcard $(test)/*.java)
855-test-cpp-sources = $(wildcard $(test)/*.cpp)
856-test-sources += $(test-support-sources)
857-test-support-classes = $(call java-classes, $(test-support-sources),$(test),$(test-build))
858-test-classes = $(call java-classes,$(test-sources),$(test),$(test-build))
859-test-cpp-objects = $(call cpp-objects,$(test-cpp-sources),$(test),$(test-build))
860-test-library = $(build)/$(so-prefix)test$(so-suffix)
861-test-dep = $(test-build).dep
862-
863-test-extra-sources = $(wildcard $(test)/extra/*.java)
864-test-extra-classes = \
865- $(call java-classes,$(test-extra-sources),$(test),$(test-build))
866-test-extra-dep = $(test-build)-extra.dep
867-
868-ifeq ($(continuations),true)
869- continuation-tests = \
870- extra.Continuations \
871- extra.Coroutines \
872- extra.DynamicWind
873-endif
874-
875-ifeq ($(tails),true)
876- tail-tests = \
877- extra.Tails
878-endif
879-
880-ifeq ($(target-arch),i386)
881- cflags += -DAVIAN_TARGET_ARCH=AVIAN_ARCH_X86
882-endif
883-
884-ifeq ($(target-arch),x86_64)
885- cflags += -DAVIAN_TARGET_ARCH=AVIAN_ARCH_X86_64
886-endif
887-
888-ifeq ($(target-arch),powerpc)
889- cflags += -DAVIAN_TARGET_ARCH=AVIAN_ARCH_POWERPC
890-endif
891-
892-ifeq ($(target-arch),arm)
893- cflags += -DAVIAN_TARGET_ARCH=AVIAN_ARCH_ARM
894-endif
895-
896-ifeq ($(target-format),elf)
897- cflags += -DAVIAN_TARGET_FORMAT=AVIAN_FORMAT_ELF
898-endif
899-
900-ifeq ($(target-format),pe)
901- cflags += -DAVIAN_TARGET_FORMAT=AVIAN_FORMAT_PE
902-endif
903-
904-ifeq ($(target-format),macho)
905- cflags += -DAVIAN_TARGET_FORMAT=AVIAN_FORMAT_MACHO
906-endif
907-
908-class-name = $(patsubst $(1)/%.class,%,$(2))
909-class-names = $(foreach x,$(2),$(call class-name,$(1),$(x)))
910-
911-test-flags = -Djava.library.path=$(build) -cp $(build)/test
912-
913-test-args = $(test-flags) $(input)
914-
915-.PHONY: build
916-build: $(static-library) $(executable) $(dynamic-library) $(lzma-loader) \
917- $(lzma-encoder) $(executable-dynamic) $(classpath-dep) $(test-dep) \
918- $(test-extra-dep)
919-
920-$(test-dep): $(classpath-dep)
921-
922-$(test-extra-dep): $(classpath-dep)
923-
924-.PHONY: run
925-run: build
926- $(library-path) $(test-executable) $(test-args)
927-
928-.PHONY: debug
929-debug: build
930- $(library-path) gdb --args $(test-executable) $(test-args)
931-
932-.PHONY: vg
933-vg: build
934- $(library-path) $(vg) $(test-executable) $(test-args)
935-
936-.PHONY: test
937-test: build
938- $(library-path) /bin/sh $(test)/test.sh 2>/dev/null \
939- $(test-executable) $(mode) "$(test-flags)" \
940- $(call class-names,$(test-build),$(filter-out $(test-support-classes), $(test-classes))) \
941- $(continuation-tests) $(tail-tests)
942-
943-.PHONY: tarball
944-tarball:
945- @echo "creating build/avian-$(version).tar.bz2"
946- @mkdir -p build
947- (cd .. && tar --exclude=build --exclude='.*' --exclude='*~' -cjf \
948- avian/build/avian-$(version).tar.bz2 avian)
949-
950-.PHONY: javadoc
951-javadoc:
952- javadoc -sourcepath classpath -d build/javadoc -subpackages avian:java \
953- -windowtitle "Avian v$(version) Class Library API" \
954- -doctitle "Avian v$(version) Class Library API" \
955- -header "Avian v$(version)" \
956- -bottom "<a href=\"http://oss.readytalk.com/avian/\">http://oss.readytalk.com/avian</a>"
957-
958-.PHONY: clean
959-clean:
960- @echo "removing build"
961- rm -rf build
962-
963-$(build)/compile-x86-asm.o: $(src)/continuations-x86.S
964-
965-gen-arg = $(shell echo $(1) | sed -e 's:$(build)/type-\(.*\)\.cpp:\1:')
966-$(generated-code): %.cpp: $(src)/types.def $(generator) $(classpath-dep)
967- @echo "generating $(@)"
968- @mkdir -p $(dir $(@))
969- $(generator) $(boot-classpath) $(<) $(@) $(call gen-arg,$(@))
970-
971-$(classpath-build)/%.class: $(classpath-src)/%.java
972- @echo $(<)
973-
974-$(classpath-dep): $(classpath-sources)
975- @echo "compiling classpath classes"
976- @mkdir -p $(classpath-build)
977- $(javac) -d $(classpath-build) -bootclasspath $(boot-classpath) \
978- $(shell $(MAKE) -s --no-print-directory build=$(build) \
979- $(classpath-classes))
980- @touch $(@)
981-
982-$(test-build)/%.class: $(test)/%.java
983- @echo $(<)
984-
985-$(test-dep): $(test-sources) $(test-library)
986- @echo "compiling test classes"
987- @mkdir -p $(test-build)
988- files="$(shell $(MAKE) -s --no-print-directory build=$(build) $(test-classes))"; \
989- if test -n "$${files}"; then \
990- $(javac) -d $(test-build) -bootclasspath $(boot-classpath) $${files}; \
991- fi
992- $(javac) -source 1.2 -target 1.1 -XDjsrlimit=0 -d $(test-build) \
993- -bootclasspath $(boot-classpath) test/Subroutine.java
994- @touch $(@)
995-
996-$(test-extra-dep): $(test-extra-sources)
997- @echo "compiling extra test classes"
998- @mkdir -p $(test-build)
999- files="$(shell $(MAKE) -s --no-print-directory build=$(build) $(test-extra-classes))"; \
1000- if test -n "$${files}"; then \
1001- $(javac) -d $(test-build) -bootclasspath $(boot-classpath) $${files}; \
1002- fi
1003- @touch $(@)
1004-
1005-define compile-object
1006- @echo "compiling $(@)"
1007- @mkdir -p $(dir $(@))
1008- $(cxx) $(cflags) -c $$($(windows-path) $(<)) $(call output,$(@))
1009-endef
1010-
1011-define compile-asm-object
1012- @echo "compiling $(@)"
1013- @mkdir -p $(dir $(@))
1014- $(as) -I$(src) $(asmflags) -c $(<) -o $(@)
1015-endef
1016-
1017-$(vm-cpp-objects): $(build)/%.o: $(src)/%.cpp $(vm-depends)
1018- $(compile-object)
1019-
1020-$(test-cpp-objects): $(test-build)/%.o: $(test)/%.cpp $(vm-depends)
1021- $(compile-object)
1022-
1023-$(test-library): $(test-cpp-objects)
1024- @echo "linking $(@)"
1025-ifdef msvc
1026- $(ld) $(shared) $(lflags) $(^) -out:$(@) -PDB:$(@).pdb \
1027- -IMPLIB:$(test-build)/$(name).lib -MANIFESTFILE:$(@).manifest
1028- $(mt) -manifest $(@).manifest -outputresource:"$(@);2"
1029-else
1030- $(ld) $(^) $(shared) $(lflags) -o $(@)
1031-endif
1032-
1033-$(build)/%.o: $(lzma)/C/%.c
1034- @echo "compiling $(@)"
1035- @mkdir -p $(dir $(@))
1036- $(cxx) $(cflags) $(no-error) -c $$($(windows-path) $(<)) $(call output,$(@))
1037-
1038-$(vm-asm-objects): $(build)/%-asm.o: $(src)/%.S
1039- $(compile-asm-object)
1040-
1041-$(bootimage-generator-objects): $(build)/%.o: $(src)/%.cpp $(vm-depends)
1042- $(compile-object)
1043-
1044-$(heapwalk-objects): $(build)/%.o: $(src)/%.cpp $(vm-depends)
1045- $(compile-object)
1046-
1047-$(driver-object): $(driver-source)
1048- $(compile-object)
1049-
1050-$(build)/main-dynamic.o: $(driver-source)
1051- @echo "compiling $(@)"
1052- @mkdir -p $(dir $(@))
1053- $(cxx) $(cflags) -DBOOT_LIBRARY=\"$(so-prefix)jvm$(so-suffix)\" \
1054- -c $(<) $(call output,$(@))
1055-
1056-$(boot-object): $(boot-source)
1057- $(compile-object)
1058-
1059-$(boot-javahome-object): $(src)/boot-javahome.cpp
1060- $(compile-object)
1061-
1062-$(converter-objects) $(converter-tool-objects): $(build)/binaryToObject/%.o: $(src)/binaryToObject/%.cpp $(converter-depends)
1063- @mkdir -p $(dir $(@))
1064- $(build-cxx) $(converter-cflags) -c $(<) -o $(@)
1065-
1066-$(converter): $(converter-objects) $(converter-tool-objects)
1067- $(build-cc) $(^) -g -o $(@)
1068-
1069-$(lzma-encoder-objects): $(build)/lzma/%.o: $(src)/lzma/%.cpp
1070- @mkdir -p $(dir $(@))
1071- $(build-cxx) $(lzma-encoder-cflags) -c $(<) -o $(@)
1072-
1073-$(lzma-encoder): $(lzma-encoder-objects) $(lzma-encoder-lzma-objects)
1074- $(build-cc) $(^) -g -o $(@)
1075-
1076-$(lzma-loader): $(src)/lzma/load.cpp
1077- $(compile-object)
1078-
1079-$(build)/classpath.jar: $(classpath-dep) $(classpath-jar-dep)
1080- @echo "creating $(@)"
1081- (wd=$$(pwd) && \
1082- cd $(classpath-build) && \
1083- $(jar) c0f "$$($(native-path) "$${wd}/$(@)")" .)
1084-
1085-$(classpath-object): $(build)/classpath.jar $(converter)
1086- @echo "creating $(@)"
1087- $(converter) $(<) $(@) _binary_classpath_jar_start \
1088- _binary_classpath_jar_end $(target-format) $(arch)
1089-
1090-$(build)/javahome.jar:
1091- @echo "creating $(@)"
1092- (wd=$$(pwd) && \
1093- cd "$(build-javahome)" && \
1094- $(jar) c0f "$$($(native-path) "$${wd}/$(@)")" $(javahome-files))
1095-
1096-$(javahome-object): $(build)/javahome.jar $(converter)
1097- @echo "creating $(@)"
1098- $(converter) $(<) $(@) _binary_javahome_jar_start \
1099- _binary_javahome_jar_end $(target-format) $(arch)
1100-
1101-define compile-generator-object
1102- @echo "compiling $(@)"
1103- @mkdir -p $(dir $(@))
1104- $(build-cxx) -DPOINTER_SIZE=$(pointer-size) -O0 -g3 $(build-cflags) \
1105- -c $(<) -o $(@)
1106-endef
1107-
1108-$(generator-objects): $(generator-depends)
1109-$(generator-objects): $(build)/%-build.o: $(src)/%.cpp
1110- $(compile-generator-object)
1111-
1112-$(build)/%-build.o: $(lzma)/C/%.c
1113- @echo "compiling $(@)"
1114- @mkdir -p $(dir $(@))
1115- $(build-cxx) -DPOINTER_SIZE=$(pointer-size) -O0 -g3 $(build-cflags) \
1116- $(no-error) -c $(<) -o $(@)
1117-
1118-$(jni-objects): $(build)/%.o: $(classpath-src)/%.cpp
1119- $(compile-object)
1120-
1121-$(static-library): $(vm-objects) $(classpath-objects) $(vm-heapwalk-objects) \
1122- $(javahome-object) $(boot-javahome-object) $(lzma-decode-objects)
1123- @echo "creating $(@)"
1124- rm -rf $(@)
1125- $(ar) cru $(@) $(^)
1126- $(ranlib) $(@)
1127-
1128-$(bootimage-object) $(codeimage-object): $(bootimage-generator)
1129- $(<) -cp $(classpath-build) -bootimage $(bootimage-object) -codeimage $(codeimage-object) \
1130- -bootimage-symbols _binary_bootimage_bin_start:_binary_bootimage_bin_end \
1131- -codeimage-symbols _binary_codeimage_bin_start:_binary_codeimage_bin_end
1132-
1133-executable-objects = $(vm-objects) $(classpath-objects) $(driver-object) \
1134- $(vm-heapwalk-objects) $(boot-object) $(vm-classpath-objects) \
1135- $(javahome-object) $(boot-javahome-object) $(lzma-decode-objects)
1136-
1137-$(executable): $(executable-objects)
1138- @echo "linking $(@)"
1139-ifeq ($(platform),windows)
1140-ifdef msvc
1141- $(ld) $(lflags) $(executable-objects) -out:$(@) -PDB:$(@).pdb \
1142- -IMPLIB:$(@).lib -MANIFESTFILE:$(@).manifest
1143- $(mt) -manifest $(@).manifest -outputresource:"$(@);1"
1144-else
1145- $(dlltool) -z $(@).def $(executable-objects)
1146- $(dlltool) -d $(@).def -e $(@).exp
1147- $(ld) $(@).exp $(executable-objects) $(lflags) -o $(@)
1148-endif
1149-else
1150- $(ld) $(executable-objects) $(rdynamic) $(lflags) $(bootimage-lflags) -o $(@)
1151-endif
1152- $(strip) $(strip-all) $(@)
1153-
1154-$(bootimage-generator): $(bootimage-generator-objects)
1155- echo arch=$(arch) platform=$(platform)
1156- $(MAKE) mode=$(mode) \
1157- arch=$(build-arch) \
1158- target-arch=$(arch) \
1159- platform=$(bootimage-platform) \
1160- target-format=$(target-format) \
1161- openjdk=$(openjdk) \
1162- openjdk-src=$(openjdk-src) \
1163- bootimage-generator= \
1164- build-bootimage-generator=$(bootimage-generator) \
1165- target-cflags="$(bootimage-cflags)" \
1166- target-asm=$(asm) \
1167- $(bootimage-generator)
1168-
1169-$(build-bootimage-generator): \
1170- $(vm-objects) $(classpath-object) $(classpath-objects) \
1171- $(heapwalk-objects) $(bootimage-generator-objects) $(converter-objects) \
1172- $(lzma-decode-objects) $(lzma-encode-objects)
1173- @echo "linking $(@)"
1174-ifeq ($(platform),windows)
1175-ifdef msvc
1176- $(ld) $(lflags) $(^) -out:$(@) -PDB:$(@).pdb -IMPLIB:$(@).lib \
1177- -MANIFESTFILE:$(@).manifest
1178- $(mt) -manifest $(@).manifest -outputresource:"$(@);1"
1179-else
1180- $(dlltool) -z $(@).def $(^)
1181- $(dlltool) -d $(@).def -e $(@).exp
1182- $(ld) $(@).exp $(^) $(lflags) -o $(@)
1183-endif
1184-else
1185- $(ld) $(^) $(rdynamic) $(lflags) -o $(@)
1186-endif
1187-
1188-$(dynamic-library): $(vm-objects) $(dynamic-object) $(classpath-objects) \
1189- $(vm-heapwalk-objects) $(boot-object) $(vm-classpath-objects) \
1190- $(classpath-libraries) $(javahome-object) $(boot-javahome-object) \
1191- $(lzma-decode-objects)
1192- @echo "linking $(@)"
1193-ifdef msvc
1194- $(ld) $(shared) $(lflags) $(^) -out:$(@) -PDB:$(@).pdb \
1195- -IMPLIB:$(build)/$(name).lib -MANIFESTFILE:$(@).manifest
1196- $(mt) -manifest $(@).manifest -outputresource:"$(@);2"
1197-else
1198- $(ld) $(^) $(version-script-flag) $(shared) $(lflags) $(bootimage-lflags) \
1199- -o $(@)
1200-endif
1201- $(strip) $(strip-all) $(@)
1202-
1203-# todo: the $(no-lto) flag below is due to odd undefined reference errors on
1204-# Ubuntu 11.10 which may be fixable without disabling LTO.
1205-$(executable-dynamic): $(driver-dynamic-objects) $(dynamic-library)
1206- @echo "linking $(@)"
1207-ifdef msvc
1208- $(ld) $(lflags) -LIBPATH:$(build) -DEFAULTLIB:$(name) \
1209- -PDB:$(@).pdb -IMPLIB:$(@).lib $(driver-dynamic-objects) -out:$(@) \
1210- -MANIFESTFILE:$(@).manifest
1211- $(mt) -manifest $(@).manifest -outputresource:"$(@);1"
1212-else
1213- $(ld) $(driver-dynamic-objects) -L$(build) -ljvm $(lflags) $(no-lto) -o $(@)
1214-endif
1215- $(strip) $(strip-all) $(@)
1216-
1217-$(generator): $(generator-objects) $(generator-lzma-objects)
1218- @echo "linking $(@)"
1219- $(build-ld) $(^) $(build-lflags) -o $(@)
1220-
1221-$(openjdk-objects): $(build)/openjdk/%-openjdk.o: $(openjdk-src)/%.c \
1222- $(openjdk-headers-dep)
1223- @echo "compiling $(@)"
1224- @mkdir -p $(dir $(@))
1225- sed 's/^static jclass ia_class;//' < $(<) > $(build)/openjdk/$(notdir $(<))
1226-ifeq ($(ios),true)
1227- sed \
1228- -e 's/^#ifndef __APPLE__/#if 1/' \
1229- -e 's/^#ifdef __APPLE__/#if 0/' \
1230- < "$(openjdk-src)/solaris/native/java/lang/ProcessEnvironment_md.c" \
1231- > $(build)/openjdk/ProcessEnvironment_md.c
1232- sed \
1233- -e 's/^#ifndef __APPLE__/#if 1/' \
1234- -e 's/^#ifdef __APPLE__/#if 0/' \
1235- < "$(openjdk-src)/solaris/native/java/lang/UNIXProcess_md.c" \
1236- > $(build)/openjdk/UNIXProcess_md.c
1237-endif
1238- $(cc) -fPIC $(openjdk-extra-cflags) $(openjdk-cflags) \
1239- $(optimization-cflags) -w -c $(build)/openjdk/$(notdir $(<)) \
1240- $(call output,$(@))
1241-
1242-$(openjdk-local-objects): $(build)/openjdk/%-openjdk.o: $(src)/openjdk/%.c \
1243- $(openjdk-headers-dep)
1244- @echo "compiling $(@)"
1245- @mkdir -p $(dir $(@))
1246- $(cc) -fPIC $(openjdk-extra-cflags) $(openjdk-cflags) \
1247- $(optimization-cflags) -w -c $(<) $(call output,$(@))
1248-
1249-$(openjdk-headers-dep):
1250- @echo "generating openjdk headers"
1251- @mkdir -p $(dir $(@))
1252- $(javah) -d $(build)/openjdk -bootclasspath $(boot-classpath) \
1253- $(openjdk-headers-classes)
1254-ifeq ($(platform),windows)
1255- sed 's/^#ifdef _WIN64/#if 1/' \
1256- < "$(openjdk-src)/windows/native/java/net/net_util_md.h" \
1257- > $(build)/openjdk/net_util_md.h
1258- sed \
1259- -e 's/\(^#include "net_util.h"\)/\1\n#if (defined _INC_NLDEF) || (defined _WS2DEF_)\n#define HIDE(x) hide_##x\n#else\n#define HIDE(x) x\n#define _WINSOCK2API_\n#endif/' \
1260- -e 's/\(IpPrefix[a-zA-Z_]*\)/HIDE(\1)/' \
1261- -e 's/\(IpSuffix[a-zA-Z_]*\)/HIDE(\1)/' \
1262- -e 's/\(IpDad[a-zA-Z_]*\)/HIDE(\1)/' \
1263- -e 's/\(ScopeLevel[a-zA-Z_]*\)/HIDE(\1)/' \
1264- -e 's/\(SCOPE_LEVEL[a-zA-Z_]*\)/HIDE(\1)/' \
1265- < "$(openjdk-src)/windows/native/java/net/NetworkInterface.h" \
1266- > $(build)/openjdk/NetworkInterface.h
1267- echo 'static int getAddrsFromAdapter(IP_ADAPTER_ADDRESSES *ptr, netaddr **netaddrPP);' >> $(build)/openjdk/NetworkInterface.h
1268-endif
1269-ifeq ($(platform),darwin)
1270- mkdir -p $(build)/openjdk/netinet
1271- for file in \
1272- /usr/include/netinet/ip.h \
1273- /usr/include/netinet/in_systm.h \
1274- /usr/include/netinet/ip_icmp.h \
1275- /usr/include/netinet/in_var.h \
1276- /usr/include/netinet/icmp6.h \
1277- /usr/include/netinet/ip_var.h; do \
1278- if [ ! -f "$(build)/openjdk/netinet/$$(basename $${file})" ]; then \
1279- ln "$${file}" "$(build)/openjdk/netinet/$$(basename $${file})"; \
1280- fi; \
1281- done
1282- mkdir -p $(build)/openjdk/netinet6
1283- for file in \
1284- /usr/include/netinet6/in6_var.h; do \
1285- if [ ! -f "$(build)/openjdk/netinet6/$$(basename $${file})" ]; then \
1286- ln "$${file}" "$(build)/openjdk/netinet6/$$(basename $${file})"; \
1287- fi; \
1288- done
1289- mkdir -p $(build)/openjdk/net
1290- for file in \
1291- /usr/include/net/if_arp.h; do \
1292- if [ ! -f "$(build)/openjdk/net/$$(basename $${file})" ]; then \
1293- ln "$${file}" "$(build)/openjdk/net/$$(basename $${file})"; \
1294- fi; \
1295- done
1296- mkdir -p $(build)/openjdk/sys
1297- for file in \
1298- /usr/include/sys/kern_event.h \
1299- /usr/include/sys/sys_domain.h; do \
1300- if [ ! -f "$(build)/openjdk/sys/$$(basename $${file})" ]; then \
1301- ln "$${file}" "$(build)/openjdk/sys/$$(basename $${file})"; \
1302- fi; \
1303- done
1304-endif
1305- @touch $(@)
1306-
1307-$(openjdk-jar-dep):
1308- @echo "extracting openjdk classes"
1309- @mkdir -p $(dir $(@))
1310- @mkdir -p $(classpath-build)
1311- (cd $(classpath-build) && \
1312- $(jar) xf "$$($(native-path) "$(openjdk)/jre/lib/rt.jar")" && \
1313- $(jar) xf "$$($(native-path) "$(openjdk)/jre/lib/jsse.jar")" && \
1314- $(jar) xf "$$($(native-path) "$(openjdk)/jre/lib/jce.jar")" && \
1315- $(jar) xf "$$($(native-path) "$(openjdk)/jre/lib/charsets.jar")" && \
1316- $(jar) xf "$$($(native-path) "$(openjdk)/jre/lib/ext/sunjce_provider.jar")" && \
1317- $(jar) xf "$$($(native-path) "$(openjdk)/jre/lib/resources.jar")")
1318- @touch $(@)
1319
1320=== removed directory '.pc/version-info.diff'
1321=== removed file '.pc/version-info.diff/makefile'
1322--- .pc/version-info.diff/makefile 2012-09-05 12:24:24 +0000
1323+++ .pc/version-info.diff/makefile 1970-01-01 00:00:00 +0000
1324@@ -1,1287 +0,0 @@
1325-MAKEFLAGS = -s
1326-
1327-name = avian
1328-version = 0.6
1329-
1330-build-arch := $(shell uname -m \
1331- | sed 's/^i.86$$/i386/' \
1332- | sed 's/^x86pc$$/i386/' \
1333- | sed 's/amd64/x86_64/' \
1334- | sed 's/^arm.*$$/arm/' \
1335- | sed 's/ppc/powerpc/')
1336-
1337-ifeq (Power,$(filter Power,$(build-arch)))
1338- build-arch = powerpc
1339-endif
1340-
1341-build-platform := \
1342- $(shell uname -s | tr [:upper:] [:lower:] \
1343- | sed 's/^mingw32.*$$/mingw32/' \
1344- | sed 's/^cygwin.*$$/cygwin/')
1345-
1346-arch = $(build-arch)
1347-target-arch = $(arch)
1348-bootimage-platform = \
1349- $(subst cygwin,windows,$(subst mingw32,windows,$(build-platform)))
1350-platform = $(bootimage-platform)
1351-
1352-mode = fast
1353-process = compile
1354-
1355-ifneq ($(process),compile)
1356- options := -$(process)
1357-endif
1358-ifneq ($(mode),fast)
1359- options := $(options)-$(mode)
1360-endif
1361-ifneq ($(lzma),)
1362- options := $(options)-lzma
1363-endif
1364-ifeq ($(bootimage),true)
1365- options := $(options)-bootimage
1366-endif
1367-ifeq ($(heapdump),true)
1368- options := $(options)-heapdump
1369-endif
1370-ifeq ($(tails),true)
1371- options := $(options)-tails
1372-endif
1373-ifeq ($(continuations),true)
1374- options := $(options)-continuations
1375-endif
1376-
1377-root := $(shell (cd .. && pwd))
1378-build = build/$(platform)-$(arch)$(options)
1379-classpath-build = $(build)/classpath
1380-test-build = $(build)/test
1381-src = src
1382-classpath-src = classpath
1383-test = test
1384-win32 ?= $(root)/win32
1385-win64 ?= $(root)/win64
1386-
1387-classpath = avian
1388-
1389-test-executable = $(shell pwd)/$(executable)
1390-boot-classpath = $(classpath-build)
1391-embed-prefix = /avian-embedded
1392-
1393-native-path = echo
1394-
1395-ifeq ($(build-platform),cygwin)
1396- native-path = cygpath -m
1397-endif
1398-
1399-windows-path = echo
1400-
1401-path-separator = :
1402-
1403-ifneq (,$(filter mingw32 cygwin,$(build-platform)))
1404- path-separator = ;
1405-endif
1406-
1407-library-path-variable = LD_LIBRARY_PATH
1408-
1409-ifeq ($(build-platform),darwin)
1410- library-path-variable = DYLD_LIBRARY_PATH
1411-endif
1412-
1413-library-path = $(library-path-variable)=$(build)
1414-
1415-ifneq ($(openjdk),)
1416- openjdk-arch = $(arch)
1417- ifeq ($(arch),x86_64)
1418- openjdk-arch = amd64
1419- endif
1420-
1421- ifneq ($(openjdk-src),)
1422- include openjdk-src.mk
1423- options := $(options)-openjdk-src
1424- classpath-objects = $(openjdk-objects) $(openjdk-local-objects)
1425- classpath-cflags = -DAVIAN_OPENJDK_SRC -DBOOT_JAVAHOME
1426- openjdk-jar-dep = $(build)/openjdk-jar.dep
1427- classpath-jar-dep = $(openjdk-jar-dep)
1428- javahome = $(embed-prefix)/javahomeJar
1429- javahome-files = lib/zi lib/currency.data lib/security/java.security \
1430- lib/security/java.policy lib/security/cacerts
1431-
1432- local-policy = lib/security/local_policy.jar
1433- ifeq ($(shell test -e "$(openjdk)/$(local-policy)" && echo found),found)
1434- javahome-files += $(local-policy)
1435- endif
1436-
1437- export-policy = lib/security/US_export_policy.jar
1438- ifeq ($(shell test -e "$(openjdk)/$(export-policy)" && echo found),found)
1439- javahome-files += $(export-policy)
1440- endif
1441-
1442- ifeq ($(platform),windows)
1443- javahome-files += lib/tzmappings
1444- endif
1445- javahome-object = $(build)/javahome-jar.o
1446- boot-javahome-object = $(build)/boot-javahome.o
1447- else
1448- options := $(options)-openjdk
1449- test-executable = $(shell pwd)/$(executable-dynamic)
1450- ifeq ($(build-platform),darwin)
1451- library-path = \
1452- $(library-path-variable)=$(build):$(openjdk)/jre/lib
1453- else
1454- library-path = \
1455- $(library-path-variable)=$(build):$(openjdk)/jre/lib/$(openjdk-arch)
1456- endif
1457- javahome = "$$($(native-path) "$(openjdk)/jre")"
1458- endif
1459-
1460- classpath = openjdk
1461- boot-classpath := "$(boot-classpath)$(path-separator)$$($(native-path) "$(openjdk)/jre/lib/rt.jar")"
1462- build-javahome = $(openjdk)/jre
1463-endif
1464-
1465-ifeq ($(classpath),avian)
1466- jni-sources := $(shell find $(classpath-src) -name '*.cpp')
1467- jni-objects = $(call cpp-objects,$(jni-sources),$(classpath-src),$(build))
1468- classpath-objects = $(jni-objects)
1469-endif
1470-
1471-input = List
1472-
1473-ifeq ($(use-clang),true)
1474- build-cxx = clang -std=c++11
1475- build-cc = clang
1476-else
1477- build-cxx = g++
1478- build-cc = gcc
1479-endif
1480-
1481-mflag =
1482-ifneq ($(platform),darwin)
1483- ifeq ($(arch),i386)
1484- mflag = -m32
1485- endif
1486- ifeq ($(arch),x86_64)
1487- mflag = -m64
1488- endif
1489-endif
1490-
1491-target-format = elf
1492-
1493-cxx = $(build-cxx) $(mflag)
1494-cc = $(build-cc) $(mflag)
1495-
1496-ar = ar
1497-ranlib = ranlib
1498-dlltool = dlltool
1499-vg = nice valgrind --num-callers=32 --db-attach=yes --freelist-vol=100000000
1500-vg += --leak-check=full --suppressions=valgrind.supp
1501-db = gdb --args
1502-javac = "$(JAVA_HOME)/bin/javac"
1503-javah = "$(JAVA_HOME)/bin/javah"
1504-jar = "$(JAVA_HOME)/bin/jar"
1505-strip = strip
1506-strip-all = --strip-all
1507-
1508-rdynamic = -rdynamic
1509-
1510-# note that we suppress the non-virtual-dtor warning because we never
1511-# use the delete operator, which means we don't need virtual
1512-# destructors:
1513-warnings = -Wall -Wextra -Werror -Wunused-parameter -Winit-self \
1514- -Wno-non-virtual-dtor
1515-
1516-target-cflags = -DTARGET_BYTES_PER_WORD=$(pointer-size)
1517-
1518-common-cflags = $(warnings) -fno-rtti -fno-exceptions -I$(classpath-src) \
1519- "-I$(JAVA_HOME)/include" -idirafter $(src) -I$(build) $(classpath-cflags) \
1520- -D__STDC_LIMIT_MACROS -D_JNI_IMPLEMENTATION_ -DAVIAN_VERSION=\"$(version)\" \
1521- -DUSE_ATOMIC_OPERATIONS -DAVIAN_JAVA_HOME=\"$(javahome)\" \
1522- -DAVIAN_EMBED_PREFIX=\"$(embed-prefix)\" $(target-cflags)
1523-
1524-asmflags = $(target-cflags)
1525-
1526-ifneq (,$(filter i386 x86_64,$(arch)))
1527- ifeq ($(use-frame-pointer),true)
1528- common-cflags += -fno-omit-frame-pointer -DAVIAN_USE_FRAME_POINTER
1529- asmflags += -DAVIAN_USE_FRAME_POINTER
1530- endif
1531-endif
1532-
1533-build-cflags = $(common-cflags) -fPIC -fvisibility=hidden \
1534- "-I$(JAVA_HOME)/include/linux" -I$(src) -pthread
1535-
1536-converter-cflags = -D__STDC_CONSTANT_MACROS -Isrc/binaryToObject -Isrc/ \
1537- -fno-rtti -fno-exceptions \
1538- -DAVIAN_TARGET_ARCH=AVIAN_ARCH_UNKNOWN \
1539- -DAVIAN_TARGET_FORMAT=AVIAN_FORMAT_UNKNOWN \
1540- -Wall -Wextra -Werror -Wunused-parameter -Winit-self -Wno-non-virtual-dtor
1541-
1542-cflags = $(build-cflags)
1543-
1544-common-lflags = -lm -lz $(classpath-lflags)
1545-
1546-build-lflags = -lz -lpthread -ldl
1547-
1548-lflags = $(common-lflags) -lpthread -ldl
1549-
1550-soname-flag = -Wl,-soname -Wl,$(so-prefix)jvm$(so-suffix)
1551-version-script-flag = -Wl,--version-script=openjdk.ld
1552-
1553-cflags += $(DPKG_CFLAGS)
1554-lflags += $(DPKG_LFLAGS)
1555-
1556-build-system = posix
1557-
1558-system = posix
1559-asm = x86
1560-
1561-pointer-size = 8
1562-
1563-so-prefix = lib
1564-so-suffix = .so
1565-
1566-shared = -shared
1567-
1568-no-error = -Wno-error
1569-
1570-openjdk-extra-cflags = -fvisibility=hidden
1571-
1572-bootimage-cflags = -DTARGET_BYTES_PER_WORD=$(pointer-size)
1573-
1574-developer-dir := $(shell if test -d /Developer; then echo /Developer; \
1575- else echo /Applications/Xcode.app/Contents/Developer; fi)
1576-
1577-ifeq ($(build-arch),powerpc)
1578- ifneq ($(arch),$(build-arch))
1579- bootimage-cflags += -DTARGET_OPPOSITE_ENDIAN
1580- endif
1581-endif
1582-
1583-ifeq ($(arch),i386)
1584- pointer-size = 4
1585-endif
1586-
1587-ifeq ($(arch),powerpc)
1588- asm = powerpc
1589- pointer-size = 4
1590-
1591- ifneq ($(arch),$(build-arch))
1592- bootimage-cflags += -DTARGET_OPPOSITE_ENDIAN
1593- endif
1594-
1595- ifneq ($(platform),darwin)
1596- ifneq ($(arch),$(build-arch))
1597- cxx = powerpc-linux-gnu-g++
1598- cc = powerpc-linux-gnu-gcc
1599- ar = powerpc-linux-gnu-ar
1600- ranlib = powerpc-linux-gnu-ranlib
1601- strip = powerpc-linux-gnu-strip
1602- endif
1603- endif
1604-endif
1605-
1606-ifeq ($(arch),arm)
1607- asm = arm
1608- pointer-size = 4
1609-
1610- ifeq ($(build-platform),darwin)
1611- ios = true
1612- else
1613- no-psabi = -Wno-psabi
1614- cflags += -marm $(no-psabi)
1615- endif
1616-
1617- ifneq ($(arch),$(build-arch))
1618- ifeq ($(platform),darwin)
1619- ios-bin = $(developer-dir)/Platforms/iPhoneOS.platform/Developer/usr/bin
1620- cxx = $(ios-bin)/g++
1621- cc = $(ios-bin)/gcc
1622- ar = $(ios-bin)/ar
1623- ranlib = $(ios-bin)/ranlib
1624- strip = $(ios-bin)/strip
1625- else
1626- cxx = arm-linux-gnueabi-g++
1627- cc = arm-linux-gnueabi-gcc
1628- ar = arm-linux-gnueabi-ar
1629- ranlib = arm-linux-gnueabi-ranlib
1630- strip = arm-linux-gnueabi-strip
1631- endif
1632- endif
1633-endif
1634-
1635-ifeq ($(ios),true)
1636- cflags += -DAVIAN_IOS
1637-endif
1638-
1639-ifeq ($(build-platform),darwin)
1640- build-cflags = $(common-cflags) -fPIC -fvisibility=hidden -I$(src)
1641- cflags += -I/System/Library/Frameworks/JavaVM.framework/Headers/
1642- build-lflags += -framework CoreFoundation
1643-endif
1644-
1645-ifeq ($(platform),qnx)
1646- cflags = $(common-cflags) -fPIC -fvisibility=hidden -I$(src)
1647- lflags = $(common-lflags) -lsocket
1648- ifeq ($(build-platform),qnx)
1649- build-cflags = $(common-cflags) -fPIC -fvisibility=hidden -I$(src)
1650- build-lflags = $(common-lflags)
1651- else
1652- ifeq ($(arch),i386)
1653- prefix = i486-pc-nto-qnx6.5.0-
1654- else
1655- prefix = arm-unknown-nto-qnx6.5.0-
1656- endif
1657- endif
1658- cxx = $(prefix)g++
1659- cc = $(prefix)gcc
1660- ar = $(prefix)ar
1661- ranlib = $(prefix)ranlib
1662- strip = $(prefix)strip
1663- rdynamic = -Wl,--export-dynamic
1664-endif
1665-
1666-ifeq ($(platform),freebsd)
1667-# There is no -ldl on FreeBSD
1668- build-lflags = $(common-lflags) -lz -lpthread
1669- lflags = $(common-lflags) -lpthread
1670-# include/freebsd instead of include/linux
1671- build-cflags = $(common-cflags) -fPIC -fvisibility=hidden \
1672- "-I$(JAVA_HOME)/include/freebsd" -I$(src) -pthread
1673- cflags = $(build-cflags)
1674-endif
1675-
1676-ifeq ($(platform),darwin)
1677- target-format = macho
1678- ifeq (${OSX_SDK_SYSROOT},)
1679- OSX_SDK_SYSROOT = 10.4u
1680- endif
1681- ifeq (${OSX_SDK_VERSION},)
1682- OSX_SDK_VERSION = 10.4
1683- endif
1684- ifneq ($(build-platform),darwin)
1685- cxx = i686-apple-darwin8-g++ $(mflag)
1686- cc = i686-apple-darwin8-gcc $(mflag)
1687- ar = i686-apple-darwin8-ar
1688- ranlib = i686-apple-darwin8-ranlib
1689- strip = i686-apple-darwin8-strip
1690- sysroot = /opt/mac/SDKs/MacOSX${OSX_SDK_SYSROOT}.sdk
1691- cflags = -I$(sysroot)/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Headers/ \
1692- $(common-cflags) -fPIC -fvisibility=hidden -I$(src)
1693- endif
1694-
1695- version-script-flag =
1696- lflags = $(common-lflags) -ldl -framework CoreFoundation
1697-
1698- ifeq (,$(shell ld -v 2>&1 | grep cctools))
1699- lflags += -Wl,-compatibility_version,1.0.0
1700- endif
1701-
1702- ifneq ($(arch),arm)
1703- lflags += -framework CoreServices -framework SystemConfiguration \
1704- -framework Security
1705- endif
1706- ifeq ($(bootimage),true)
1707- bootimage-lflags = -Wl,-segprot,__RWX,rwx,rwx
1708- endif
1709- rdynamic =
1710- strip-all = -S -x
1711- so-suffix = .dylib
1712- shared = -dynamiclib
1713-
1714- sdk-dir = $(developer-dir)/Platforms/iPhoneOS.platform/Developer/SDKs
1715-
1716- ifeq ($(arch),arm)
1717- ios-version := \
1718- $(shell if test -d $(sdk-dir)/iPhoneOS5.1.sdk; then echo 5.1; \
1719- elif test -d $(sdk-dir)/iPhoneOS5.0.sdk; then echo 5.0; \
1720- elif test -d $(sdk-dir)/iPhoneOS4.3.sdk; then echo 4.3; \
1721- elif test -d $(sdk-dir)/iPhoneOS4.2.sdk; then echo 4.2; \
1722- else echo; fi)
1723-
1724- ifeq ($(ios-version),)
1725- x := $(error "couldn't find SDK for iOS version")
1726- endif
1727-
1728- flags = -arch armv7 -isysroot \
1729- $(sdk-dir)/iPhoneOS$(ios-version).sdk/
1730- openjdk-extra-cflags += $(flags)
1731- cflags += $(flags)
1732- asmflags += $(flags)
1733- lflags += $(flags)
1734- endif
1735-
1736- ifeq ($(arch),powerpc)
1737- openjdk-extra-cflags += -arch ppc -mmacosx-version-min=${OSX_SDK_VERSION}
1738- cflags += -arch ppc -mmacosx-version-min=${OSX_SDK_VERSION}
1739- asmflags += -arch ppc -mmacosx-version-min=${OSX_SDK_VERSION}
1740- lflags += -arch ppc -mmacosx-version-min=${OSX_SDK_VERSION}
1741- endif
1742-
1743- ifeq ($(arch),i386)
1744- openjdk-extra-cflags += -arch i386 -mmacosx-version-min=${OSX_SDK_VERSION}
1745- cflags += -arch i386 -mmacosx-version-min=${OSX_SDK_VERSION}
1746- asmflags += -arch i386 -mmacosx-version-min=${OSX_SDK_VERSION}
1747- lflags += -arch i386 -mmacosx-version-min=${OSX_SDK_VERSION}
1748- endif
1749-
1750- ifeq ($(arch),x86_64)
1751- openjdk-extra-cflags += -arch x86_64
1752- cflags += -arch x86_64
1753- asmflags += -arch x86_64
1754- lflags += -arch x86_64
1755- endif
1756-endif
1757-
1758-ifeq ($(platform),windows)
1759- target-format = pe
1760-
1761- inc = "$(win32)/include"
1762- lib = "$(win32)/lib"
1763-
1764- embed-prefix = c:/avian-embedded
1765-
1766- system = windows
1767-
1768- so-prefix =
1769- so-suffix = .dll
1770- exe-suffix = .exe
1771-
1772- lflags = -L$(lib) $(common-lflags) -lws2_32 -liphlpapi -mwindows -mconsole
1773- cflags = -I$(inc) $(common-cflags) -DWINVER=0x0500
1774-
1775- ifeq (,$(filter mingw32 cygwin,$(build-platform)))
1776- openjdk-extra-cflags += -I$(src)/openjdk/caseSensitive
1777- prefix := $(shell i686-w64-mingw32-gcc --version >/dev/null 2>&1 \
1778- && echo i686-w64-mingw32- || echo x86_64-w64-mingw32-)
1779- cxx = $(prefix)g++ -m32
1780- cc = $(prefix)gcc -m32
1781- dlltool = $(prefix)dlltool -mi386 --as-flags=--32
1782- ar = $(prefix)ar
1783- ranlib = $(prefix)ranlib
1784- strip = $(prefix)strip --strip-all
1785- else
1786- build-system = windows
1787- common-cflags += "-I$(JAVA_HOME)/include/win32"
1788- build-cflags = $(common-cflags) -I$(src) -I$(inc) -mthreads
1789- openjdk-extra-cflags =
1790- build-lflags = -L$(lib) $(common-lflags)
1791- ifeq ($(build-platform),cygwin)
1792- build-cxx = i686-w64-mingw32-g++
1793- build-cc = i686-w64-mingw32-gcc
1794- dlltool = i686-w64-mingw32-dlltool
1795- ar = i686-w64-mingw32-ar
1796- ranlib = i686-w64-mingw32-ranlib
1797- strip = i686-w64-mingw32-strip
1798- endif
1799- endif
1800-
1801- ifeq ($(arch),x86_64)
1802- ifeq ($(build-platform),cygwin)
1803- build-cxx = x86_64-w64-mingw32-g++
1804- build-cc = x86_64-w64-mingw32-gcc
1805- endif
1806- cxx = x86_64-w64-mingw32-g++ $(mflag)
1807- cc = x86_64-w64-mingw32-gcc $(mflag)
1808- dlltool = x86_64-w64-mingw32-dlltool
1809- ar = x86_64-w64-mingw32-ar
1810- ranlib = x86_64-w64-mingw32-ranlib
1811- strip = x86_64-w64-mingw32-strip
1812- inc = "$(win64)/include"
1813- lib = "$(win64)/lib"
1814- else
1815- shared += -Wl,--add-stdcall-alias
1816- endif
1817-endif
1818-
1819-ifeq ($(mode),debug)
1820- optimization-cflags = -O0 -g3
1821- converter-cflags += -O0 -g3
1822- strip = :
1823-endif
1824-ifeq ($(mode),debug-fast)
1825- optimization-cflags = -O0 -g3 -DNDEBUG
1826- strip = :
1827-endif
1828-ifeq ($(mode),stress)
1829- optimization-cflags = -O0 -g3 -DVM_STRESS
1830- strip = :
1831-endif
1832-ifeq ($(mode),stress-major)
1833- optimization-cflags = -O0 -g3 -DVM_STRESS -DVM_STRESS_MAJOR
1834- strip = :
1835-endif
1836-ifeq ($(mode),fast)
1837- ifeq ($(use-clang),true)
1838- optimization-cflags = -O4 -g3 -DNDEBUG
1839- else
1840- optimization-cflags = -O3 -g3 -DNDEBUG
1841- endif
1842- use-lto = true
1843-endif
1844-ifeq ($(mode),small)
1845- ifeq ($(use-clang),true)
1846- optimization-cflags = -Oz -g3 -DNDEBUG
1847- else
1848- optimization-cflags = -Os -g3 -DNDEBUG
1849- endif
1850- use-lto = true
1851-endif
1852-
1853-ifeq ($(use-lto),true)
1854- ifeq ($(use-clang),true)
1855- optimization-cflags += -flto
1856- lflags += $(optimization-cflags)
1857- else
1858-# only try to use LTO when GCC 4.6.0 or greater is available
1859- gcc-major := $(shell $(cc) -dumpversion | cut -f1 -d.)
1860- gcc-minor := $(shell $(cc) -dumpversion | cut -f2 -d.)
1861- ifeq ($(shell expr 4 \< $(gcc-major) \
1862- \| \( 4 \<= $(gcc-major) \& 6 \<= $(gcc-minor) \)),1)
1863- optimization-cflags += -flto
1864- no-lto = -fno-lto
1865- lflags += $(optimization-cflags)
1866- endif
1867- endif
1868-endif
1869-
1870-cflags += $(optimization-cflags)
1871-
1872-ifneq ($(platform),darwin)
1873-ifeq ($(arch),i386)
1874-# this is necessary to support __sync_bool_compare_and_swap:
1875- cflags += -march=i586
1876- lflags += -march=i586
1877-endif
1878-endif
1879-
1880-output = -o $(1)
1881-as := $(cc)
1882-ld := $(cc)
1883-build-ld := $(build-cc)
1884-
1885-ifdef msvc
1886- no-error =
1887- windows-path = $(native-path)
1888- windows-java-home := $(shell $(windows-path) "$(JAVA_HOME)")
1889- zlib := $(shell $(windows-path) "$(win32)/msvc")
1890- cxx = "$(msvc)/BIN/cl.exe"
1891- cc = $(cxx)
1892- ld = "$(msvc)/BIN/link.exe"
1893- mt = "mt.exe"
1894- cflags = -nologo -DAVIAN_VERSION=\"$(version)\" -D_JNI_IMPLEMENTATION_ \
1895- -DUSE_ATOMIC_OPERATIONS -DAVIAN_JAVA_HOME=\"$(javahome)\" \
1896- -DAVIAN_EMBED_PREFIX=\"$(embed-prefix)\" \
1897- -Fd$(build)/$(name).pdb -I"$(zlib)/include" -I$(src) -I$(classpath-src) \
1898- -I"$(build)" \
1899- -I"$(windows-java-home)/include" -I"$(windows-java-home)/include/win32" \
1900- -DTARGET_BYTES_PER_WORD=$(pointer-size)
1901-
1902- ifneq ($(lzma),)
1903- cflags += -I$(shell $(windows-path) "$(lzma)")
1904- endif
1905-
1906- shared = -dll
1907- lflags = -nologo -LIBPATH:"$(zlib)/lib" -DEFAULTLIB:ws2_32 \
1908- -DEFAULTLIB:zlib -MANIFEST -debug
1909- output = -Fo$(1)
1910-
1911- ifeq ($(mode),debug)
1912- cflags += -Od -Zi -MDd
1913- endif
1914- ifeq ($(mode),debug-fast)
1915- cflags += -Od -Zi -DNDEBUG
1916- endif
1917- ifeq ($(mode),fast)
1918- cflags += -O2 -GL -Zi -DNDEBUG
1919- lflags += -LTCG
1920- endif
1921- ifeq ($(mode),small)
1922- cflags += -O1s -Zi -GL -DNDEBUG
1923- lflags += -LTCG
1924- endif
1925-
1926- strip = :
1927-endif
1928-
1929-c-objects = $(foreach x,$(1),$(patsubst $(2)/%.c,$(3)/%.o,$(x)))
1930-cpp-objects = $(foreach x,$(1),$(patsubst $(2)/%.cpp,$(3)/%.o,$(x)))
1931-asm-objects = $(foreach x,$(1),$(patsubst $(2)/%.S,$(3)/%-asm.o,$(x)))
1932-java-classes = $(foreach x,$(1),$(patsubst $(2)/%.java,$(3)/%.class,$(x)))
1933-
1934-generated-code = \
1935- $(build)/type-enums.cpp \
1936- $(build)/type-declarations.cpp \
1937- $(build)/type-constructors.cpp \
1938- $(build)/type-initializations.cpp \
1939- $(build)/type-java-initializations.cpp \
1940- $(build)/type-name-initializations.cpp \
1941- $(build)/type-maps.cpp
1942-
1943-vm-depends := $(generated-code) $(wildcard $(src)/*.h)
1944-
1945-vm-sources = \
1946- $(src)/$(system).cpp \
1947- $(src)/finder.cpp \
1948- $(src)/machine.cpp \
1949- $(src)/util.cpp \
1950- $(src)/heap.cpp \
1951- $(src)/$(process).cpp \
1952- $(src)/classpath-$(classpath).cpp \
1953- $(src)/builtin.cpp \
1954- $(src)/jnienv.cpp \
1955- $(src)/process.cpp
1956-
1957-vm-asm-sources = $(src)/$(asm).S
1958-
1959-target-asm = $(asm)
1960-
1961-ifeq ($(process),compile)
1962- vm-sources += \
1963- $(src)/compiler.cpp \
1964- $(src)/$(target-asm).cpp
1965-
1966- vm-asm-sources += $(src)/compile-$(asm).S
1967-endif
1968-
1969-vm-cpp-objects = $(call cpp-objects,$(vm-sources),$(src),$(build))
1970-vm-asm-objects = $(call asm-objects,$(vm-asm-sources),$(src),$(build))
1971-vm-objects = $(vm-cpp-objects) $(vm-asm-objects)
1972-
1973-heapwalk-sources = $(src)/heapwalk.cpp
1974-heapwalk-objects = \
1975- $(call cpp-objects,$(heapwalk-sources),$(src),$(build))
1976-
1977-ifeq ($(heapdump),true)
1978- vm-sources += $(src)/heapdump.cpp
1979- vm-heapwalk-objects = $(heapwalk-objects)
1980- cflags += -DAVIAN_HEAPDUMP
1981-endif
1982-
1983-ifeq ($(tails),true)
1984- cflags += -DAVIAN_TAILS
1985-endif
1986-
1987-ifeq ($(continuations),true)
1988- cflags += -DAVIAN_CONTINUATIONS
1989- asmflags += -DAVIAN_CONTINUATIONS
1990-endif
1991-
1992-bootimage-generator-sources = $(src)/bootimage.cpp
1993-ifneq ($(lzma),)
1994- bootimage-generator-sources += $(src)/lzma-encode.cpp
1995-endif
1996-bootimage-generator-objects = \
1997- $(call cpp-objects,$(bootimage-generator-sources),$(src),$(build))
1998-bootimage-generator = $(build)/bootimage-generator
1999-
2000-bootimage-object = $(build)/bootimage-bin.o
2001-codeimage-object = $(build)/codeimage-bin.o
2002-
2003-ifeq ($(bootimage),true)
2004- vm-classpath-objects = $(bootimage-object) $(codeimage-object)
2005- cflags += -DBOOT_IMAGE -DAVIAN_CLASSPATH=\"\"
2006-else
2007- vm-classpath-objects = $(classpath-object)
2008- cflags += -DBOOT_CLASSPATH=\"[classpathJar]\" \
2009- -DAVIAN_CLASSPATH=\"[classpathJar]\"
2010-endif
2011-
2012-cflags += $(extra-cflags)
2013-lflags += $(extra-lflags)
2014-
2015-openjdk-cflags += $(extra-cflags)
2016-
2017-driver-source = $(src)/main.cpp
2018-driver-object = $(build)/main.o
2019-driver-dynamic-objects = \
2020- $(build)/main-dynamic.o
2021-
2022-boot-source = $(src)/boot.cpp
2023-boot-object = $(build)/boot.o
2024-
2025-generator-depends := $(wildcard $(src)/*.h)
2026-generator-sources = \
2027- $(src)/type-generator.cpp \
2028- $(src)/$(build-system).cpp \
2029- $(src)/finder.cpp
2030-
2031-ifneq ($(lzma),)
2032- common-cflags += -I$(lzma) -DAVIAN_USE_LZMA -D_7ZIP_ST
2033-
2034- vm-sources += \
2035- $(src)/lzma-decode.cpp
2036-
2037- generator-sources += \
2038- $(src)/lzma-decode.cpp
2039-
2040- lzma-decode-sources = \
2041- $(lzma)/C/LzmaDec.c
2042-
2043- lzma-decode-objects = \
2044- $(call c-objects,$(lzma-decode-sources),$(lzma)/C,$(build))
2045-
2046- lzma-encode-sources = \
2047- $(lzma)/C/LzmaEnc.c \
2048- $(lzma)/C/LzFind.c
2049-
2050- lzma-encode-objects = \
2051- $(call c-objects,$(lzma-encode-sources),$(lzma)/C,$(build))
2052-
2053- lzma-encoder = $(build)/lzma/lzma
2054-
2055- lzma-encoder-cflags = -D__STDC_CONSTANT_MACROS -fno-rtti -fno-exceptions \
2056- -I$(lzma)/C
2057-
2058- lzma-encoder-sources = \
2059- $(src)/lzma/main.cpp
2060-
2061- lzma-encoder-objects = \
2062- $(call cpp-objects,$(lzma-encoder-sources),$(src),$(build))
2063-
2064- lzma-encoder-lzma-sources = $(lzma-encode-sources) $(lzma-decode-sources)
2065-
2066- lzma-encoder-lzma-objects = \
2067- $(call generator-c-objects,$(lzma-encoder-lzma-sources),$(lzma)/C,$(build))
2068-
2069- lzma-loader = $(build)/lzma/load.o
2070-endif
2071-
2072-generator-cpp-objects = \
2073- $(foreach x,$(1),$(patsubst $(2)/%.cpp,$(3)/%-build.o,$(x)))
2074-generator-c-objects = \
2075- $(foreach x,$(1),$(patsubst $(2)/%.c,$(3)/%-build.o,$(x)))
2076-generator-objects = \
2077- $(call generator-cpp-objects,$(generator-sources),$(src),$(build))
2078-generator-lzma-objects = \
2079- $(call generator-c-objects,$(lzma-decode-sources),$(lzma)/C,$(build))
2080-generator = $(build)/generator
2081-
2082-converter-depends = \
2083- $(src)/binaryToObject/tools.h \
2084- $(src)/binaryToObject/endianness.h
2085-
2086-converter-sources = \
2087- $(src)/binaryToObject/tools.cpp \
2088- $(src)/binaryToObject/elf.cpp \
2089- $(src)/binaryToObject/mach-o.cpp \
2090- $(src)/binaryToObject/pe.cpp
2091-
2092-converter-tool-sources = \
2093- $(src)/binaryToObject/main.cpp
2094-
2095-converter-objects = $(call cpp-objects,$(converter-sources),$(src),$(build))
2096-converter-tool-objects = $(call cpp-objects,$(converter-tool-sources),$(src),$(build))
2097-converter = $(build)/binaryToObject/binaryToObject
2098-
2099-static-library = $(build)/lib$(name).a
2100-executable = $(build)/$(name)${exe-suffix}
2101-dynamic-library = $(build)/$(so-prefix)jvm$(so-suffix)
2102-executable-dynamic = $(build)/$(name)-dynamic${exe-suffix}
2103-
2104-ifneq ($(classpath),avian)
2105-# Assembler, ConstantPool, and Stream are not technically needed for a
2106-# working build, but we include them since our Subroutine test uses
2107-# them to synthesize a class:
2108- classpath-sources := \
2109- $(classpath-src)/avian/Addendum.java \
2110- $(classpath-src)/avian/Assembler.java \
2111- $(classpath-src)/avian/Callback.java \
2112- $(classpath-src)/avian/CallbackReceiver.java \
2113- $(classpath-src)/avian/ClassAddendum.java \
2114- $(classpath-src)/avian/Classes.java \
2115- $(classpath-src)/avian/ConstantPool.java \
2116- $(classpath-src)/avian/Continuations.java \
2117- $(classpath-src)/avian/FieldAddendum.java \
2118- $(classpath-src)/avian/IncompatibleContinuationException.java \
2119- $(classpath-src)/avian/Machine.java \
2120- $(classpath-src)/avian/MethodAddendum.java \
2121- $(classpath-src)/avian/Singleton.java \
2122- $(classpath-src)/avian/Stream.java \
2123- $(classpath-src)/avian/SystemClassLoader.java \
2124- $(classpath-src)/avian/VMClass.java \
2125- $(classpath-src)/avian/VMField.java \
2126- $(classpath-src)/avian/VMMethod.java \
2127- $(classpath-src)/avian/avian_vm_resource/Handler.java
2128-
2129- ifneq ($(openjdk),)
2130- classpath-sources := $(classpath-sources) \
2131- $(classpath-src)/avian/OpenJDK.java
2132- endif
2133-else
2134- classpath-sources := $(shell find $(classpath-src) -name '*.java')
2135-endif
2136-
2137-classpath-classes = \
2138- $(call java-classes,$(classpath-sources),$(classpath-src),$(classpath-build))
2139-classpath-object = $(build)/classpath-jar.o
2140-classpath-dep = $(classpath-build).dep
2141-
2142-vm-classes = \
2143- avian/*.class \
2144- avian/resource/*.class
2145-
2146-test-support-sources = $(shell find $(test)/avian/ -name '*.java')
2147-test-sources = $(wildcard $(test)/*.java)
2148-test-cpp-sources = $(wildcard $(test)/*.cpp)
2149-test-sources += $(test-support-sources)
2150-test-support-classes = $(call java-classes, $(test-support-sources),$(test),$(test-build))
2151-test-classes = $(call java-classes,$(test-sources),$(test),$(test-build))
2152-test-cpp-objects = $(call cpp-objects,$(test-cpp-sources),$(test),$(test-build))
2153-test-library = $(build)/$(so-prefix)test$(so-suffix)
2154-test-dep = $(test-build).dep
2155-
2156-test-extra-sources = $(wildcard $(test)/extra/*.java)
2157-test-extra-classes = \
2158- $(call java-classes,$(test-extra-sources),$(test),$(test-build))
2159-test-extra-dep = $(test-build)-extra.dep
2160-
2161-ifeq ($(continuations),true)
2162- continuation-tests = \
2163- extra.Continuations \
2164- extra.Coroutines \
2165- extra.DynamicWind
2166-endif
2167-
2168-ifeq ($(tails),true)
2169- tail-tests = \
2170- extra.Tails
2171-endif
2172-
2173-ifeq ($(target-arch),i386)
2174- cflags += -DAVIAN_TARGET_ARCH=AVIAN_ARCH_X86
2175-endif
2176-
2177-ifeq ($(target-arch),x86_64)
2178- cflags += -DAVIAN_TARGET_ARCH=AVIAN_ARCH_X86_64
2179-endif
2180-
2181-ifeq ($(target-arch),powerpc)
2182- cflags += -DAVIAN_TARGET_ARCH=AVIAN_ARCH_POWERPC
2183-endif
2184-
2185-ifeq ($(target-arch),arm)
2186- cflags += -DAVIAN_TARGET_ARCH=AVIAN_ARCH_ARM
2187-endif
2188-
2189-ifeq ($(target-format),elf)
2190- cflags += -DAVIAN_TARGET_FORMAT=AVIAN_FORMAT_ELF
2191-endif
2192-
2193-ifeq ($(target-format),pe)
2194- cflags += -DAVIAN_TARGET_FORMAT=AVIAN_FORMAT_PE
2195-endif
2196-
2197-ifeq ($(target-format),macho)
2198- cflags += -DAVIAN_TARGET_FORMAT=AVIAN_FORMAT_MACHO
2199-endif
2200-
2201-class-name = $(patsubst $(1)/%.class,%,$(2))
2202-class-names = $(foreach x,$(2),$(call class-name,$(1),$(x)))
2203-
2204-test-flags = -Djava.library.path=$(build) -cp $(build)/test
2205-
2206-test-args = $(test-flags) $(input)
2207-
2208-.PHONY: build
2209-build: $(static-library) $(executable) $(dynamic-library) $(lzma-loader) \
2210- $(lzma-encoder) $(executable-dynamic) $(classpath-dep) $(test-dep) \
2211- $(test-extra-dep)
2212-
2213-$(test-dep): $(classpath-dep)
2214-
2215-$(test-extra-dep): $(classpath-dep)
2216-
2217-.PHONY: run
2218-run: build
2219- $(library-path) $(test-executable) $(test-args)
2220-
2221-.PHONY: debug
2222-debug: build
2223- $(library-path) gdb --args $(test-executable) $(test-args)
2224-
2225-.PHONY: vg
2226-vg: build
2227- $(library-path) $(vg) $(test-executable) $(test-args)
2228-
2229-.PHONY: test
2230-test: build
2231- $(library-path) /bin/sh $(test)/test.sh 2>/dev/null \
2232- $(test-executable) $(mode) "$(test-flags)" \
2233- $(call class-names,$(test-build),$(filter-out $(test-support-classes), $(test-classes))) \
2234- $(continuation-tests) $(tail-tests)
2235-
2236-.PHONY: tarball
2237-tarball:
2238- @echo "creating build/avian-$(version).tar.bz2"
2239- @mkdir -p build
2240- (cd .. && tar --exclude=build --exclude='.*' --exclude='*~' -cjf \
2241- avian/build/avian-$(version).tar.bz2 avian)
2242-
2243-.PHONY: javadoc
2244-javadoc:
2245- javadoc -sourcepath classpath -d build/javadoc -subpackages avian:java \
2246- -windowtitle "Avian v$(version) Class Library API" \
2247- -doctitle "Avian v$(version) Class Library API" \
2248- -header "Avian v$(version)" \
2249- -bottom "<a href=\"http://oss.readytalk.com/avian/\">http://oss.readytalk.com/avian</a>"
2250-
2251-.PHONY: clean
2252-clean:
2253- @echo "removing build"
2254- rm -rf build
2255-
2256-$(build)/compile-x86-asm.o: $(src)/continuations-x86.S
2257-
2258-gen-arg = $(shell echo $(1) | sed -e 's:$(build)/type-\(.*\)\.cpp:\1:')
2259-$(generated-code): %.cpp: $(src)/types.def $(generator) $(classpath-dep)
2260- @echo "generating $(@)"
2261- @mkdir -p $(dir $(@))
2262- $(generator) $(boot-classpath) $(<) $(@) $(call gen-arg,$(@))
2263-
2264-$(classpath-build)/%.class: $(classpath-src)/%.java
2265- @echo $(<)
2266-
2267-$(classpath-dep): $(classpath-sources)
2268- @echo "compiling classpath classes"
2269- @mkdir -p $(classpath-build)
2270- $(javac) -d $(classpath-build) -bootclasspath $(boot-classpath) \
2271- $(shell $(MAKE) -s --no-print-directory build=$(build) \
2272- $(classpath-classes))
2273- @touch $(@)
2274-
2275-$(test-build)/%.class: $(test)/%.java
2276- @echo $(<)
2277-
2278-$(test-dep): $(test-sources) $(test-library)
2279- @echo "compiling test classes"
2280- @mkdir -p $(test-build)
2281- files="$(shell $(MAKE) -s --no-print-directory build=$(build) $(test-classes))"; \
2282- if test -n "$${files}"; then \
2283- $(javac) -d $(test-build) -bootclasspath $(boot-classpath) $${files}; \
2284- fi
2285- $(javac) -source 1.2 -target 1.1 -XDjsrlimit=0 -d $(test-build) \
2286- -bootclasspath $(boot-classpath) test/Subroutine.java
2287- @touch $(@)
2288-
2289-$(test-extra-dep): $(test-extra-sources)
2290- @echo "compiling extra test classes"
2291- @mkdir -p $(test-build)
2292- files="$(shell $(MAKE) -s --no-print-directory build=$(build) $(test-extra-classes))"; \
2293- if test -n "$${files}"; then \
2294- $(javac) -d $(test-build) -bootclasspath $(boot-classpath) $${files}; \
2295- fi
2296- @touch $(@)
2297-
2298-define compile-object
2299- @echo "compiling $(@)"
2300- @mkdir -p $(dir $(@))
2301- $(cxx) $(cflags) -c $$($(windows-path) $(<)) $(call output,$(@))
2302-endef
2303-
2304-define compile-asm-object
2305- @echo "compiling $(@)"
2306- @mkdir -p $(dir $(@))
2307- $(as) -I$(src) $(asmflags) -c $(<) -o $(@)
2308-endef
2309-
2310-$(vm-cpp-objects): $(build)/%.o: $(src)/%.cpp $(vm-depends)
2311- $(compile-object)
2312-
2313-$(test-cpp-objects): $(test-build)/%.o: $(test)/%.cpp $(vm-depends)
2314- $(compile-object)
2315-
2316-$(test-library): $(test-cpp-objects)
2317- @echo "linking $(@)"
2318-ifdef msvc
2319- $(ld) $(shared) $(lflags) $(^) -out:$(@) -PDB:$(@).pdb \
2320- -IMPLIB:$(test-build)/$(name).lib -MANIFESTFILE:$(@).manifest
2321- $(mt) -manifest $(@).manifest -outputresource:"$(@);2"
2322-else
2323- $(ld) $(^) $(shared) $(lflags) -o $(@)
2324-endif
2325-
2326-$(build)/%.o: $(lzma)/C/%.c
2327- @echo "compiling $(@)"
2328- @mkdir -p $(dir $(@))
2329- $(cxx) $(cflags) $(no-error) -c $$($(windows-path) $(<)) $(call output,$(@))
2330-
2331-$(vm-asm-objects): $(build)/%-asm.o: $(src)/%.S
2332- $(compile-asm-object)
2333-
2334-$(bootimage-generator-objects): $(build)/%.o: $(src)/%.cpp $(vm-depends)
2335- $(compile-object)
2336-
2337-$(heapwalk-objects): $(build)/%.o: $(src)/%.cpp $(vm-depends)
2338- $(compile-object)
2339-
2340-$(driver-object): $(driver-source)
2341- $(compile-object)
2342-
2343-$(build)/main-dynamic.o: $(driver-source)
2344- @echo "compiling $(@)"
2345- @mkdir -p $(dir $(@))
2346- $(cxx) $(cflags) -DBOOT_LIBRARY=\"$(so-prefix)jvm$(so-suffix)\" \
2347- -c $(<) $(call output,$(@))
2348-
2349-$(boot-object): $(boot-source)
2350- $(compile-object)
2351-
2352-$(boot-javahome-object): $(src)/boot-javahome.cpp
2353- $(compile-object)
2354-
2355-$(converter-objects) $(converter-tool-objects): $(build)/binaryToObject/%.o: $(src)/binaryToObject/%.cpp $(converter-depends)
2356- @mkdir -p $(dir $(@))
2357- $(build-cxx) $(converter-cflags) -c $(<) -o $(@)
2358-
2359-$(converter): $(converter-objects) $(converter-tool-objects)
2360- $(build-cc) $(^) -g -o $(@)
2361-
2362-$(lzma-encoder-objects): $(build)/lzma/%.o: $(src)/lzma/%.cpp
2363- @mkdir -p $(dir $(@))
2364- $(build-cxx) $(lzma-encoder-cflags) -c $(<) -o $(@)
2365-
2366-$(lzma-encoder): $(lzma-encoder-objects) $(lzma-encoder-lzma-objects)
2367- $(build-cc) $(^) -g -o $(@)
2368-
2369-$(lzma-loader): $(src)/lzma/load.cpp
2370- $(compile-object)
2371-
2372-$(build)/classpath.jar: $(classpath-dep) $(classpath-jar-dep)
2373- @echo "creating $(@)"
2374- (wd=$$(pwd) && \
2375- cd $(classpath-build) && \
2376- $(jar) c0f "$$($(native-path) "$${wd}/$(@)")" .)
2377-
2378-$(classpath-object): $(build)/classpath.jar $(converter)
2379- @echo "creating $(@)"
2380- $(converter) $(<) $(@) _binary_classpath_jar_start \
2381- _binary_classpath_jar_end $(target-format) $(arch)
2382-
2383-$(build)/javahome.jar:
2384- @echo "creating $(@)"
2385- (wd=$$(pwd) && \
2386- cd "$(build-javahome)" && \
2387- $(jar) c0f "$$($(native-path) "$${wd}/$(@)")" $(javahome-files))
2388-
2389-$(javahome-object): $(build)/javahome.jar $(converter)
2390- @echo "creating $(@)"
2391- $(converter) $(<) $(@) _binary_javahome_jar_start \
2392- _binary_javahome_jar_end $(target-format) $(arch)
2393-
2394-define compile-generator-object
2395- @echo "compiling $(@)"
2396- @mkdir -p $(dir $(@))
2397- $(build-cxx) -DPOINTER_SIZE=$(pointer-size) -O0 -g3 $(build-cflags) \
2398- -c $(<) -o $(@)
2399-endef
2400-
2401-$(generator-objects): $(generator-depends)
2402-$(generator-objects): $(build)/%-build.o: $(src)/%.cpp
2403- $(compile-generator-object)
2404-
2405-$(build)/%-build.o: $(lzma)/C/%.c
2406- @echo "compiling $(@)"
2407- @mkdir -p $(dir $(@))
2408- $(build-cxx) -DPOINTER_SIZE=$(pointer-size) -O0 -g3 $(build-cflags) \
2409- $(no-error) -c $(<) -o $(@)
2410-
2411-$(jni-objects): $(build)/%.o: $(classpath-src)/%.cpp
2412- $(compile-object)
2413-
2414-$(static-library): $(vm-objects) $(classpath-objects) $(vm-heapwalk-objects) \
2415- $(javahome-object) $(boot-javahome-object) $(lzma-decode-objects)
2416- @echo "creating $(@)"
2417- rm -rf $(@)
2418- $(ar) cru $(@) $(^)
2419- $(ranlib) $(@)
2420-
2421-$(bootimage-object) $(codeimage-object): $(bootimage-generator)
2422- $(<) -cp $(classpath-build) -bootimage $(bootimage-object) -codeimage $(codeimage-object) \
2423- -bootimage-symbols _binary_bootimage_bin_start:_binary_bootimage_bin_end \
2424- -codeimage-symbols _binary_codeimage_bin_start:_binary_codeimage_bin_end
2425-
2426-executable-objects = $(vm-objects) $(classpath-objects) $(driver-object) \
2427- $(vm-heapwalk-objects) $(boot-object) $(vm-classpath-objects) \
2428- $(javahome-object) $(boot-javahome-object) $(lzma-decode-objects)
2429-
2430-$(executable): $(executable-objects)
2431- @echo "linking $(@)"
2432-ifeq ($(platform),windows)
2433-ifdef msvc
2434- $(ld) $(lflags) $(executable-objects) -out:$(@) -PDB:$(@).pdb \
2435- -IMPLIB:$(@).lib -MANIFESTFILE:$(@).manifest
2436- $(mt) -manifest $(@).manifest -outputresource:"$(@);1"
2437-else
2438- $(dlltool) -z $(@).def $(executable-objects)
2439- $(dlltool) -d $(@).def -e $(@).exp
2440- $(ld) $(@).exp $(executable-objects) $(lflags) -o $(@)
2441-endif
2442-else
2443- $(ld) $(executable-objects) $(rdynamic) $(lflags) $(bootimage-lflags) -o $(@)
2444-endif
2445- $(strip) $(strip-all) $(@)
2446-
2447-$(bootimage-generator): $(bootimage-generator-objects)
2448- echo arch=$(arch) platform=$(platform)
2449- $(MAKE) mode=$(mode) \
2450- arch=$(build-arch) \
2451- target-arch=$(arch) \
2452- platform=$(bootimage-platform) \
2453- target-format=$(target-format) \
2454- openjdk=$(openjdk) \
2455- openjdk-src=$(openjdk-src) \
2456- bootimage-generator= \
2457- build-bootimage-generator=$(bootimage-generator) \
2458- target-cflags="$(bootimage-cflags)" \
2459- target-asm=$(asm) \
2460- $(bootimage-generator)
2461-
2462-$(build-bootimage-generator): \
2463- $(vm-objects) $(classpath-object) $(classpath-objects) \
2464- $(heapwalk-objects) $(bootimage-generator-objects) $(converter-objects) \
2465- $(lzma-decode-objects) $(lzma-encode-objects)
2466- @echo "linking $(@)"
2467-ifeq ($(platform),windows)
2468-ifdef msvc
2469- $(ld) $(lflags) $(^) -out:$(@) -PDB:$(@).pdb -IMPLIB:$(@).lib \
2470- -MANIFESTFILE:$(@).manifest
2471- $(mt) -manifest $(@).manifest -outputresource:"$(@);1"
2472-else
2473- $(dlltool) -z $(@).def $(^)
2474- $(dlltool) -d $(@).def -e $(@).exp
2475- $(ld) $(@).exp $(^) $(lflags) -o $(@)
2476-endif
2477-else
2478- $(ld) $(^) $(rdynamic) $(lflags) -o $(@)
2479-endif
2480-
2481-$(dynamic-library): $(vm-objects) $(dynamic-object) $(classpath-objects) \
2482- $(vm-heapwalk-objects) $(boot-object) $(vm-classpath-objects) \
2483- $(classpath-libraries) $(javahome-object) $(boot-javahome-object) \
2484- $(lzma-decode-objects)
2485- @echo "linking $(@)"
2486-ifdef msvc
2487- $(ld) $(shared) $(lflags) $(^) -out:$(@) -PDB:$(@).pdb \
2488- -IMPLIB:$(build)/$(name).lib -MANIFESTFILE:$(@).manifest
2489- $(mt) -manifest $(@).manifest -outputresource:"$(@);2"
2490-else
2491- $(ld) $(^) $(version-script-flag) $(soname-flag) $(shared) $(lflags) $(bootimage-lflags) \
2492- -o $(@)
2493-endif
2494- $(strip) $(strip-all) $(@)
2495-
2496-# todo: the $(no-lto) flag below is due to odd undefined reference errors on
2497-# Ubuntu 11.10 which may be fixable without disabling LTO.
2498-$(executable-dynamic): $(driver-dynamic-objects) $(dynamic-library)
2499- @echo "linking $(@)"
2500-ifdef msvc
2501- $(ld) $(lflags) -LIBPATH:$(build) -DEFAULTLIB:$(name) \
2502- -PDB:$(@).pdb -IMPLIB:$(@).lib $(driver-dynamic-objects) -out:$(@) \
2503- -MANIFESTFILE:$(@).manifest
2504- $(mt) -manifest $(@).manifest -outputresource:"$(@);1"
2505-else
2506- $(ld) $(driver-dynamic-objects) -L$(build) -ljvm $(lflags) $(no-lto) -o $(@)
2507-endif
2508- $(strip) $(strip-all) $(@)
2509-
2510-$(generator): $(generator-objects) $(generator-lzma-objects)
2511- @echo "linking $(@)"
2512- $(build-ld) $(^) $(build-lflags) -o $(@)
2513-
2514-$(openjdk-objects): $(build)/openjdk/%-openjdk.o: $(openjdk-src)/%.c \
2515- $(openjdk-headers-dep)
2516- @echo "compiling $(@)"
2517- @mkdir -p $(dir $(@))
2518- sed 's/^static jclass ia_class;//' < $(<) > $(build)/openjdk/$(notdir $(<))
2519-ifeq ($(ios),true)
2520- sed \
2521- -e 's/^#ifndef __APPLE__/#if 1/' \
2522- -e 's/^#ifdef __APPLE__/#if 0/' \
2523- < "$(openjdk-src)/solaris/native/java/lang/ProcessEnvironment_md.c" \
2524- > $(build)/openjdk/ProcessEnvironment_md.c
2525- sed \
2526- -e 's/^#ifndef __APPLE__/#if 1/' \
2527- -e 's/^#ifdef __APPLE__/#if 0/' \
2528- < "$(openjdk-src)/solaris/native/java/lang/UNIXProcess_md.c" \
2529- > $(build)/openjdk/UNIXProcess_md.c
2530-endif
2531- $(cc) -fPIC $(openjdk-extra-cflags) $(openjdk-cflags) \
2532- $(optimization-cflags) -w -c $(build)/openjdk/$(notdir $(<)) \
2533- $(call output,$(@))
2534-
2535-$(openjdk-local-objects): $(build)/openjdk/%-openjdk.o: $(src)/openjdk/%.c \
2536- $(openjdk-headers-dep)
2537- @echo "compiling $(@)"
2538- @mkdir -p $(dir $(@))
2539- $(cc) -fPIC $(openjdk-extra-cflags) $(openjdk-cflags) \
2540- $(optimization-cflags) -w -c $(<) $(call output,$(@))
2541-
2542-$(openjdk-headers-dep):
2543- @echo "generating openjdk headers"
2544- @mkdir -p $(dir $(@))
2545- $(javah) -d $(build)/openjdk -bootclasspath $(boot-classpath) \
2546- $(openjdk-headers-classes)
2547-ifeq ($(platform),windows)
2548- sed 's/^#ifdef _WIN64/#if 1/' \
2549- < "$(openjdk-src)/windows/native/java/net/net_util_md.h" \
2550- > $(build)/openjdk/net_util_md.h
2551- sed \
2552- -e 's/\(^#include "net_util.h"\)/\1\n#if (defined _INC_NLDEF) || (defined _WS2DEF_)\n#define HIDE(x) hide_##x\n#else\n#define HIDE(x) x\n#define _WINSOCK2API_\n#endif/' \
2553- -e 's/\(IpPrefix[a-zA-Z_]*\)/HIDE(\1)/' \
2554- -e 's/\(IpSuffix[a-zA-Z_]*\)/HIDE(\1)/' \
2555- -e 's/\(IpDad[a-zA-Z_]*\)/HIDE(\1)/' \
2556- -e 's/\(ScopeLevel[a-zA-Z_]*\)/HIDE(\1)/' \
2557- -e 's/\(SCOPE_LEVEL[a-zA-Z_]*\)/HIDE(\1)/' \
2558- < "$(openjdk-src)/windows/native/java/net/NetworkInterface.h" \
2559- > $(build)/openjdk/NetworkInterface.h
2560- echo 'static int getAddrsFromAdapter(IP_ADAPTER_ADDRESSES *ptr, netaddr **netaddrPP);' >> $(build)/openjdk/NetworkInterface.h
2561-endif
2562-ifeq ($(platform),darwin)
2563- mkdir -p $(build)/openjdk/netinet
2564- for file in \
2565- /usr/include/netinet/ip.h \
2566- /usr/include/netinet/in_systm.h \
2567- /usr/include/netinet/ip_icmp.h \
2568- /usr/include/netinet/in_var.h \
2569- /usr/include/netinet/icmp6.h \
2570- /usr/include/netinet/ip_var.h; do \
2571- if [ ! -f "$(build)/openjdk/netinet/$$(basename $${file})" ]; then \
2572- ln "$${file}" "$(build)/openjdk/netinet/$$(basename $${file})"; \
2573- fi; \
2574- done
2575- mkdir -p $(build)/openjdk/netinet6
2576- for file in \
2577- /usr/include/netinet6/in6_var.h; do \
2578- if [ ! -f "$(build)/openjdk/netinet6/$$(basename $${file})" ]; then \
2579- ln "$${file}" "$(build)/openjdk/netinet6/$$(basename $${file})"; \
2580- fi; \
2581- done
2582- mkdir -p $(build)/openjdk/net
2583- for file in \
2584- /usr/include/net/if_arp.h; do \
2585- if [ ! -f "$(build)/openjdk/net/$$(basename $${file})" ]; then \
2586- ln "$${file}" "$(build)/openjdk/net/$$(basename $${file})"; \
2587- fi; \
2588- done
2589- mkdir -p $(build)/openjdk/sys
2590- for file in \
2591- /usr/include/sys/kern_event.h \
2592- /usr/include/sys/sys_domain.h; do \
2593- if [ ! -f "$(build)/openjdk/sys/$$(basename $${file})" ]; then \
2594- ln "$${file}" "$(build)/openjdk/sys/$$(basename $${file})"; \
2595- fi; \
2596- done
2597-endif
2598- @touch $(@)
2599-
2600-$(openjdk-jar-dep):
2601- @echo "extracting openjdk classes"
2602- @mkdir -p $(dir $(@))
2603- @mkdir -p $(classpath-build)
2604- (cd $(classpath-build) && \
2605- $(jar) xf "$$($(native-path) "$(openjdk)/jre/lib/rt.jar")" && \
2606- $(jar) xf "$$($(native-path) "$(openjdk)/jre/lib/jsse.jar")" && \
2607- $(jar) xf "$$($(native-path) "$(openjdk)/jre/lib/jce.jar")" && \
2608- $(jar) xf "$$($(native-path) "$(openjdk)/jre/lib/charsets.jar")" && \
2609- $(jar) xf "$$($(native-path) "$(openjdk)/jre/lib/ext/sunjce_provider.jar")" && \
2610- $(jar) xf "$$($(native-path) "$(openjdk)/jre/lib/resources.jar")")
2611- @touch $(@)
2612
2613=== removed directory '.pc/version-info.diff/src'
2614=== removed file '.pc/version-info.diff/src/classpath-openjdk.cpp'
2615--- .pc/version-info.diff/src/classpath-openjdk.cpp 2012-09-05 12:24:24 +0000
2616+++ .pc/version-info.diff/src/classpath-openjdk.cpp 1970-01-01 00:00:00 +0000
2617@@ -1,5544 +0,0 @@
2618-/* Copyright (c) 2010-2012, Avian Contributors
2619-
2620- Permission to use, copy, modify, and/or distribute this software
2621- for any purpose with or without fee is hereby granted, provided
2622- that the above copyright notice and this permission notice appear
2623- in all copies.
2624-
2625- There is NO WARRANTY for this software. See license.txt for
2626- details. */
2627-
2628-#include "machine.h"
2629-#include "classpath-common.h"
2630-#include "util.h"
2631-#include "process.h"
2632-
2633-#ifdef PLATFORM_WINDOWS
2634-
2635-# include <windows.h>
2636-# include <io.h>
2637-# include <direct.h>
2638-# include <share.h>
2639-# include <errno.h>
2640-# include <fcntl.h>
2641-# include <sys/stat.h>
2642-# include <sys/types.h>
2643-
2644-# undef interface
2645-
2646-# define CLOSE _close
2647-# define READ _read
2648-# define WRITE _write
2649-# define FSTAT _fstat
2650-# define STAT _stat
2651-# define LSEEK _lseek
2652-
2653-# define S_ISSOCK(x) false
2654-
2655-# ifdef _MSC_VER
2656-# define S_ISREG(x) ((x) | _S_IFREG)
2657-# define S_ISDIR(x) ((x) | _S_IFDIR)
2658-# define S_IRUSR _S_IREAD
2659-# define S_IWUSR _S_IWRITE
2660-# else
2661-# define OPEN _open
2662-# endif
2663-
2664-# define O_RDONLY _O_RDONLY
2665-
2666-# ifdef AVIAN_OPENJDK_SRC
2667-# define EXPORT(x) x
2668-# else
2669-# define EXPORT(x) _##x
2670-# endif
2671-
2672-typedef int socklen_t;
2673-
2674-# define RTLD_DEFAULT 0
2675-
2676-#else // not PLATFORM_WINDOWS
2677-
2678-# include <unistd.h>
2679-# include <limits.h>
2680-# include <sys/types.h>
2681-# include <sys/stat.h>
2682-# include <sys/socket.h>
2683-# include <sys/ioctl.h>
2684-# include <fcntl.h>
2685-# include <errno.h>
2686-# include <sched.h>
2687-# include <dlfcn.h>
2688-
2689-# define OPEN open
2690-# define CLOSE close
2691-# define READ read
2692-# define WRITE write
2693-# define STAT stat
2694-# define FSTAT fstat
2695-# define LSEEK lseek
2696-
2697-# define EXPORT(x) x
2698-
2699-#endif // not PLATFORM_WINDOWS
2700-
2701-#define JVM_EEXIST -100
2702-
2703-using namespace vm;
2704-
2705-namespace {
2706-
2707-#ifdef _MSC_VER
2708-inline int
2709-OPEN(string_t path, int mask, int mode)
2710-{
2711- int fd;
2712- if (_wsopen_s(&fd, path, mask, _SH_DENYNO, mode) == 0) {
2713- return fd;
2714- } else {
2715- return -1;
2716- }
2717-}
2718-#endif
2719-
2720-namespace local {
2721-
2722-const int JMM_VERSION_1_0 = 0x20010000;
2723-
2724-struct jmmOptionalSupport {
2725- unsigned isLowMemoryDetectionSupported : 1;
2726- unsigned isCompilationTimeMonitoringSupported : 1;
2727- unsigned isThreadContentionMonitoringSupported : 1;
2728- unsigned isCurrentThreadCpuTimeSupported : 1;
2729- unsigned isOtherThreadCpuTimeSupported : 1;
2730- unsigned isBootClassPathSupported : 1;
2731- unsigned isObjectMonitorUsageSupported : 1;
2732- unsigned isSynchronizerUsageSupported : 1;
2733-};
2734-
2735-typedef unsigned jmmLongAttribute;
2736-typedef unsigned jmmBoolAttribute;
2737-typedef unsigned jmmStatisticType;
2738-typedef unsigned jmmThresholdType;
2739-typedef unsigned jmmVMGlobalType;
2740-typedef unsigned jmmVMGlobalOrigin;
2741-
2742-struct jmmVMGlobal {
2743- jstring name;
2744- jvalue value;
2745- jmmVMGlobalType type;
2746- jmmVMGlobalOrigin origin;
2747- unsigned writeable : 1;
2748- unsigned external : 1;
2749- unsigned reserved : 30;
2750- void* reserved1;
2751- void* reserved2;
2752-};
2753-
2754-struct jmmExtAttributeInfo {
2755- const char* name;
2756- char type;
2757- const char* description;
2758-};
2759-
2760-struct jmmGCStat {
2761- jlong gc_index;
2762- jlong start_time;
2763- jlong end_time;
2764- jobjectArray usage_before_gc;
2765- jobjectArray usage_after_gc;
2766- jint gc_ext_attribute_values_size;
2767- jvalue* gc_ext_attribute_values;
2768- jint num_gc_ext_attributes;
2769-};
2770-
2771-struct JmmInterface {
2772- void* reserved1;
2773- void* reserved2;
2774-
2775- jint
2776- (JNICALL *GetVersion)
2777- (JNIEnv*);
2778-
2779- jint
2780- (JNICALL *GetOptionalSupport)
2781- (JNIEnv*, jmmOptionalSupport*);
2782-
2783- jobject
2784- (JNICALL *GetInputArguments)
2785- (JNIEnv*);
2786-
2787- jint
2788- (JNICALL *GetThreadInfo)
2789- (JNIEnv*, jlongArray, jint, jobjectArray);
2790-
2791- jobjectArray
2792- (JNICALL *GetInputArgumentArray)
2793- (JNIEnv*);
2794-
2795- jobjectArray
2796- (JNICALL *GetMemoryPools)
2797- (JNIEnv*, jobject);
2798-
2799- jobjectArray
2800- (JNICALL *GetMemoryManagers)
2801- (JNIEnv*, jobject);
2802-
2803- jobject
2804- (JNICALL *GetMemoryPoolUsage)
2805- (JNIEnv*, jobject);
2806-
2807- jobject
2808- (JNICALL *GetPeakMemoryPoolUsage)
2809- (JNIEnv*, jobject);
2810-
2811- void* reserved4;
2812-
2813- jobject
2814- (JNICALL *GetMemoryUsage)
2815- (JNIEnv*, jboolean);
2816-
2817- jlong
2818- (JNICALL *GetLongAttribute)
2819- (JNIEnv*, jobject, jmmLongAttribute);
2820-
2821- jboolean (JNICALL *GetBoolAttribute)
2822- (JNIEnv*, jmmBoolAttribute);
2823-
2824- jboolean
2825- (JNICALL *SetBoolAttribute)
2826- (JNIEnv*, jmmBoolAttribute, jboolean);
2827-
2828- jint
2829- (JNICALL *GetLongAttributes)
2830- (JNIEnv*, jobject, jmmLongAttribute*, jint, jlong*);
2831-
2832- jobjectArray
2833- (JNICALL *FindCircularBlockedThreads)
2834- (JNIEnv*);
2835-
2836- jlong
2837- (JNICALL *GetThreadCpuTime)
2838- (JNIEnv*, jlong);
2839-
2840- jobjectArray
2841- (JNICALL *GetVMGlobalNames)
2842- (JNIEnv*);
2843-
2844- jint
2845- (JNICALL *GetVMGlobals)
2846- (JNIEnv*, jobjectArray, jmmVMGlobal*, jint);
2847-
2848- jint
2849- (JNICALL *GetInternalThreadTimes)
2850- (JNIEnv*, jobjectArray, jlongArray);
2851-
2852- jboolean
2853- (JNICALL *ResetStatistic)
2854- (JNIEnv*, jvalue, jmmStatisticType);
2855-
2856- void
2857- (JNICALL *SetPoolSensor)
2858- (JNIEnv*, jobject, jmmThresholdType, jobject);
2859-
2860- jlong
2861- (JNICALL *SetPoolThreshold)
2862- (JNIEnv*, jobject, jmmThresholdType, jlong);
2863-
2864- jobject
2865- (JNICALL *GetPoolCollectionUsage)
2866- (JNIEnv*, jobject);
2867-
2868- jint
2869- (JNICALL *GetGCExtAttributeInfo)
2870- (JNIEnv*, jobject, jmmExtAttributeInfo*, jint);
2871-
2872- void
2873- (JNICALL *GetLastGCStat)
2874- (JNIEnv*, jobject, jmmGCStat*);
2875-
2876- jlong
2877- (JNICALL *GetThreadCpuTimeWithKind)
2878- (JNIEnv*, jlong, jboolean);
2879-
2880- void* reserved5;
2881-
2882- jint
2883- (JNICALL *DumpHeap0)
2884- (JNIEnv*, jstring, jboolean);
2885-
2886- jobjectArray
2887- (JNICALL *FindDeadlocks)
2888- (JNIEnv*, jboolean);
2889-
2890- void
2891- (JNICALL *SetVMGlobal)
2892- (JNIEnv*, jstring, jvalue );
2893-
2894- void* reserved6;
2895-
2896- jobjectArray
2897- (JNICALL *DumpThreads)
2898- (JNIEnv*, jlongArray, jboolean, jboolean);
2899-};
2900-
2901-const unsigned InterfaceVersion = 4;
2902-const unsigned PageSize = 4 * 1024;
2903-const int VirtualFileBase = 1000000000;
2904-
2905-Machine* globalMachine;
2906-
2907-const char*
2908-primitiveName(Thread* t, object c)
2909-{
2910- if (c == primitiveClass(t, 'V')) {
2911- return "void";
2912- } else if (c == primitiveClass(t, 'Z')) {
2913- return "boolean";
2914- } else if (c == primitiveClass(t, 'B')) {
2915- return "byte";
2916- } else if (c == primitiveClass(t, 'C')) {
2917- return "char";
2918- } else if (c == primitiveClass(t, 'S')) {
2919- return "short";
2920- } else if (c == primitiveClass(t, 'I')) {
2921- return "int";
2922- } else if (c == primitiveClass(t, 'F')) {
2923- return "float";
2924- } else if (c == primitiveClass(t, 'J')) {
2925- return "long";
2926- } else if (c == primitiveClass(t, 'D')) {
2927- return "double";
2928- } else {
2929- abort(t);
2930- }
2931-}
2932-
2933-object
2934-getClassName(Thread* t, object c)
2935-{
2936- if (className(t, c) == 0) {
2937- if (classVmFlags(t, c) & PrimitiveFlag) {
2938- PROTECT(t, c);
2939-
2940- object name = makeByteArray(t, primitiveName(t, c));
2941-
2942- set(t, c, ClassName, name);
2943- } else {
2944- abort(t);
2945- }
2946- }
2947-
2948- return className(t, c);
2949-}
2950-
2951-object
2952-makeClassNameString(Thread* t, object name)
2953-{
2954- THREAD_RUNTIME_ARRAY(t, char, s, byteArrayLength(t, name));
2955- replace('/', '.', RUNTIME_ARRAY_BODY(s),
2956- reinterpret_cast<char*>(&byteArrayBody(t, name, 0)));
2957-
2958- return makeString(t, "%s", s);
2959-}
2960-
2961-void
2962-interceptFileOperations(Thread*);
2963-
2964-void
2965-clearInterrupted(Thread*);
2966-
2967-class MyClasspath : public Classpath {
2968- public:
2969- static const unsigned BufferSize = 1024;
2970-
2971- MyClasspath(System* s, Allocator* allocator, const char* javaHome,
2972- const char* embedPrefix):
2973- allocator(allocator), ranNetOnLoad(0), ranManagementOnLoad(0)
2974- {
2975- class StringBuilder {
2976- public:
2977- StringBuilder(System* s, char* pointer, unsigned remaining):
2978- s(s), pointer(pointer), remaining(remaining)
2979- { }
2980-
2981- void append(const char* append) {
2982- unsigned length = strlen(append);
2983- expect(s, remaining > length);
2984-
2985- strncpy(pointer, append, remaining);
2986-
2987- remaining -= length;
2988- pointer += length;
2989- }
2990-
2991- void append(char c) {
2992- assert(s, remaining > 1);
2993-
2994- pointer[0] = c;
2995- pointer[1] = 0;
2996-
2997- -- remaining;
2998- ++ pointer;
2999- }
3000-
3001- System* s;
3002- char* pointer;
3003- unsigned remaining;
3004- } sb(s, buffer, BufferSize);
3005-
3006- this->javaHome = sb.pointer;
3007- sb.append(javaHome);
3008- sb.append('\0');
3009-
3010- this->classpath = sb.pointer;
3011- sb.append(AVIAN_CLASSPATH);
3012- sb.append(s->pathSeparator());
3013- sb.append(javaHome);
3014- sb.append("/lib/rt.jar");
3015- sb.append(s->pathSeparator());
3016- sb.append(javaHome);
3017- sb.append("/lib/jsse.jar");
3018- sb.append(s->pathSeparator());
3019- sb.append(javaHome);
3020- sb.append("/lib/jce.jar");
3021- sb.append(s->pathSeparator());
3022- sb.append(javaHome);
3023- sb.append("/lib/ext/sunjce_provider.jar");
3024- sb.append(s->pathSeparator());
3025- sb.append(javaHome);
3026- sb.append("/lib/resources.jar");
3027- sb.append('\0');
3028-
3029- this->libraryPath = sb.pointer;
3030- sb.append(javaHome);
3031-#ifdef PLATFORM_WINDOWS
3032- sb.append("/bin");
3033-#elif defined __APPLE__
3034- sb.append("/lib");
3035-#elif defined ARCH_x86_64
3036- sb.append("/lib/amd64");
3037-#elif defined ARCH_arm
3038- sb.append("/lib/arm");
3039-#else
3040- // todo: handle other architectures
3041- sb.append("/lib/i386");
3042-#endif
3043- sb.append('\0');
3044-
3045- this->tzMappings = sb.pointer;
3046- sb.append(javaHome);
3047- sb.append("/lib/tzmappings");
3048- this->tzMappingsLength = sb.pointer - tzMappings;
3049- sb.append('\0');
3050-
3051- this->embedPrefix = sb.pointer;
3052- sb.append(embedPrefix);
3053- this->embedPrefixLength = sb.pointer - this->embedPrefix;
3054- }
3055-
3056- virtual object
3057- makeJclass(Thread* t, object class_)
3058- {
3059- PROTECT(t, class_);
3060-
3061- object name = makeClassNameString(t, getClassName(t, class_));
3062- PROTECT(t, name);
3063-
3064- object c = allocate(t, FixedSizeOfJclass, true);
3065- setObjectClass(t, c, type(t, Machine::JclassType));
3066- set(t, c, JclassName, name);
3067- set(t, c, JclassVmClass, class_);
3068-
3069- return c;
3070- }
3071-
3072- virtual object
3073- makeString(Thread* t, object array, int32_t offset, int32_t length)
3074- {
3075- if (objectClass(t, array) == type(t, Machine::ByteArrayType)) {
3076- PROTECT(t, array);
3077-
3078- object charArray = makeCharArray(t, length);
3079- for (int i = 0; i < length; ++i) {
3080- charArrayBody(t, charArray, i) = byteArrayBody(t, array, offset + i);
3081- }
3082-
3083- array = charArray;
3084- } else {
3085- expect(t, objectClass(t, array) == type(t, Machine::CharArrayType));
3086- }
3087-
3088- return vm::makeString(t, array, offset, length, 0);
3089- }
3090-
3091- virtual object
3092- makeThread(Thread* t, Thread* parent)
3093- {
3094- const unsigned MaxPriority = 10;
3095- const unsigned NormalPriority = 5;
3096-
3097- object group;
3098- if (parent) {
3099- group = threadGroup(t, parent->javaThread);
3100- } else {
3101- group = allocate(t, FixedSizeOfThreadGroup, true);
3102- setObjectClass(t, group, type(t, Machine::ThreadGroupType));
3103- threadGroupMaxPriority(t, group) = MaxPriority;
3104- }
3105-
3106- PROTECT(t, group);
3107-
3108- object thread = allocate(t, FixedSizeOfThread, true);
3109- setObjectClass(t, thread, type(t, Machine::ThreadType));
3110- threadPriority(t, thread) = NormalPriority;
3111- threadGroup(t, thread) = group;
3112- threadContextClassLoader(t, thread) = root(t, Machine::AppLoader);
3113-
3114- PROTECT(t, thread);
3115-
3116- object blockerLock = makeJobject(t);
3117- set(t, thread, ThreadBlockerLock, blockerLock);
3118-
3119- const unsigned BufferSize = 256;
3120- char buffer[BufferSize];
3121- unsigned length = vm::snprintf(buffer, BufferSize, "Thread-%p", thread);
3122- object name = makeCharArray(t, length);
3123- for (unsigned i = 0; i < length; ++i) {
3124- charArrayBody(t, name, i) = buffer[i];
3125- }
3126- set(t, thread, ThreadName, name);
3127-
3128- return thread;
3129- }
3130-
3131- virtual void
3132- clearInterrupted(Thread* t)
3133- {
3134- local::clearInterrupted(t);
3135- }
3136-
3137- virtual void
3138- runThread(Thread* t)
3139- {
3140- object method = resolveMethod
3141- (t, root(t, Machine::BootLoader), "java/lang/Thread", "run", "()V");
3142-
3143- t->m->processor->invoke(t, method, t->javaThread);
3144-
3145- acquire(t, t->javaThread);
3146- t->flags &= ~Thread::ActiveFlag;
3147- notifyAll(t, t->javaThread);
3148- release(t, t->javaThread);
3149- }
3150-
3151- virtual void
3152- resolveNative(Thread* t, object method)
3153- {
3154- if (strcmp(reinterpret_cast<const int8_t*>("sun/font/SunFontManager"),
3155- &byteArrayBody(t, className(t, methodClass(t, method)), 0)) == 0
3156- and strcmp(reinterpret_cast<const int8_t*>("initIDs"),
3157- &byteArrayBody(t, methodName(t, method), 0)) == 0
3158- and strcmp(reinterpret_cast<const int8_t*>("()V"),
3159- &byteArrayBody(t, methodSpec(t, method), 0)) == 0)
3160- {
3161- PROTECT(t, method);
3162-
3163- expect(t, loadLibrary(t, libraryPath, "fontmanager", true, true));
3164- }
3165-
3166- vm::resolveNative(t, method);
3167- }
3168-
3169- virtual void
3170- boot(Thread* t)
3171- {
3172- globalMachine = t->m;
3173-
3174- resolveSystemClass(t, root(t, Machine::BootLoader),
3175- className(t, type(t, Machine::ClassLoaderType)));
3176-
3177-#ifdef AVIAN_OPENJDK_SRC
3178- interceptFileOperations(t);
3179-#else // not AVIAN_OPENJDK_SRC
3180- expect(t, loadLibrary(t, libraryPath, "verify", true, true));
3181- expect(t, loadLibrary(t, libraryPath, "java", true, true));
3182-#endif // not AVIAN_OPENJDK_SRC
3183-
3184- { object assertionLock = resolveField
3185- (t, type(t, Machine::ClassLoaderType), "assertionLock",
3186- "Ljava/lang/Object;");
3187-
3188- set(t, root(t, Machine::BootLoader), fieldOffset(t, assertionLock),
3189- root(t, Machine::BootLoader));
3190- }
3191-
3192- { object class_ = resolveClass
3193- (t, root(t, Machine::BootLoader), "java/util/Properties", true,
3194- Machine::NoClassDefFoundErrorType);
3195-
3196- PROTECT(t, class_);
3197-
3198- object instance = makeNew(t, class_);
3199-
3200- PROTECT(t, instance);
3201-
3202- object constructor = resolveMethod(t, class_, "<init>", "()V");
3203-
3204- t->m->processor->invoke(t, constructor, instance);
3205-
3206- t->m->processor->invoke
3207- (t, root(t, Machine::BootLoader), "java/lang/System",
3208- "setProperties", "(Ljava/util/Properties;)V", 0, instance);
3209- }
3210-
3211- { object constructor = resolveMethod
3212- (t, type(t, Machine::ClassLoaderType), "<init>",
3213- "(Ljava/lang/ClassLoader;)V");
3214-
3215- PROTECT(t, constructor);
3216-
3217- t->m->processor->invoke(t, constructor, root(t, Machine::BootLoader), 0);
3218-
3219- t->m->processor->invoke
3220- (t, constructor, root(t, Machine::AppLoader),
3221- root(t, Machine::BootLoader));
3222- }
3223-
3224- { object scl = resolveField
3225- (t, type(t, Machine::ClassLoaderType), "scl",
3226- "Ljava/lang/ClassLoader;");
3227-
3228- PROTECT(t, scl);
3229-
3230- object sclSet = resolveField
3231- (t, type(t, Machine::ClassLoaderType), "sclSet", "Z");
3232-
3233- set(t, classStaticTable(t, type(t, Machine::ClassLoaderType)),
3234- fieldOffset(t, scl), root(t, Machine::AppLoader));
3235-
3236- cast<uint8_t>(classStaticTable(t, type(t, Machine::ClassLoaderType)),
3237- fieldOffset(t, sclSet)) = true;
3238- }
3239-
3240- t->m->processor->invoke
3241- (t, root(t, Machine::BootLoader), "java/lang/System",
3242- "initializeSystemClass", "()V", 0);
3243-
3244- t->m->processor->invoke
3245- (t, root(t, Machine::BootLoader), "sun/misc/Launcher",
3246- "getLauncher", "()Lsun/misc/Launcher;", 0);
3247-
3248- set(t, t->javaThread, ThreadContextClassLoader,
3249- root(t, Machine::AppLoader));
3250- }
3251-
3252- virtual const char*
3253- bootClasspath()
3254- {
3255- return classpath;
3256- }
3257-
3258- virtual void
3259- dispose()
3260- {
3261- allocator->free(this, sizeof(*this));
3262- }
3263-
3264- Allocator* allocator;
3265- const char* javaHome;
3266- const char* classpath;
3267- const char* libraryPath;
3268- const char* tzMappings;
3269- const char* embedPrefix;
3270- unsigned tzMappingsLength;
3271- unsigned embedPrefixLength;
3272- unsigned filePathField;
3273- unsigned fileDescriptorFdField;
3274- unsigned fileInputStreamFdField;
3275- unsigned zipFileJzfileField;
3276- unsigned zipEntryNameField;
3277- unsigned zipEntryTimeField;
3278- unsigned zipEntryCrcField;
3279- unsigned zipEntrySizeField;
3280- unsigned zipEntryCsizeField;
3281- unsigned zipEntryMethodField;
3282- bool ranNetOnLoad;
3283- bool ranManagementOnLoad;
3284- char buffer[BufferSize];
3285- JmmInterface jmmInterface;
3286-};
3287-
3288-struct JVM_ExceptionTableEntryType {
3289- jint start_pc;
3290- jint end_pc;
3291- jint handler_pc;
3292- jint catchType;
3293-};
3294-
3295-struct jvm_version_info {
3296- unsigned jvm_version;
3297- unsigned update_version: 8;
3298- unsigned special_update_version: 8;
3299- unsigned reserved1: 16;
3300- unsigned reserved2;
3301- unsigned is_attach_supported: 1;
3302- unsigned is_kernel_jvm: 1;
3303- unsigned: 30;
3304- unsigned: 32;
3305- unsigned: 32;
3306-};
3307-
3308-Finder*
3309-getFinder(Thread* t, const char* name, unsigned nameLength)
3310-{
3311- ACQUIRE(t, t->m->referenceLock);
3312-
3313- for (object p = root(t, Machine::VirtualFileFinders);
3314- p; p = finderNext(t, p))
3315- {
3316- if (byteArrayLength(t, finderName(t, p)) == nameLength
3317- and strncmp(reinterpret_cast<const char*>
3318- (&byteArrayBody(t, finderName(t, p), 0)),
3319- name, nameLength))
3320- {
3321- return static_cast<Finder*>(finderFinder(t, p));
3322- }
3323- }
3324-
3325- object n = makeByteArray(t, nameLength + 1);
3326- memcpy(&byteArrayBody(t, n, 0), name, nameLength);
3327-
3328- void* p = t->m->libraries->resolve
3329- (reinterpret_cast<const char*>(&byteArrayBody(t, n, 0)));
3330-
3331- if (p) {
3332- uint8_t* (*function)(unsigned*);
3333- memcpy(&function, &p, BytesPerWord);
3334-
3335- unsigned size;
3336- uint8_t* data = function(&size);
3337- if (data) {
3338- Finder* f = makeFinder(t->m->system, t->m->heap, data, size);
3339- object finder = makeFinder
3340- (t, f, n, root(t, Machine::VirtualFileFinders));
3341-
3342- setRoot(t, Machine::VirtualFileFinders, finder);
3343-
3344- return f;
3345- }
3346- }
3347-
3348- return 0;
3349-}
3350-
3351-bool
3352-pathEqual(const char* a, const char* b, unsigned length)
3353-{
3354-#ifdef PLATFORM_WINDOWS
3355- return strncasecmp(a, b, length) == 0;
3356-#else
3357- return strncmp(a, b, length) == 0;
3358-#endif
3359-}
3360-
3361-bool
3362-pathEqual(const char* a, const char* b)
3363-{
3364-#ifdef PLATFORM_WINDOWS
3365- return strcasecmp(a, b) == 0;
3366-#else
3367- return strcmp(a, b) == 0;
3368-#endif
3369-}
3370-
3371-class EmbeddedFile {
3372- public:
3373- EmbeddedFile(MyClasspath* cp, const char* path, unsigned pathLength) {
3374- if (pathEqual(cp->embedPrefix, path, cp->embedPrefixLength)) {
3375- const char* p = path + cp->embedPrefixLength;
3376- while (*p == '/') ++ p;
3377-
3378- this->jar = p;
3379-
3380- if (*p == 0) {
3381- this->jarLength = 0;
3382- this->path = 0;
3383- this->pathLength = 0;
3384- return;
3385- }
3386-
3387- while (*p and *p != '/') ++p;
3388-
3389- this->jarLength = p - this->jar;
3390-
3391- while (*p == '/') ++p;
3392-
3393- this->path = p;
3394- this->pathLength = pathLength - (p - path);
3395- } else {
3396- this->jar = 0;
3397- this->jarLength =0;
3398- this->path = 0;
3399- this->pathLength = 0;
3400- }
3401- }
3402-
3403- const char* jar;
3404- const char* path;
3405- unsigned jarLength;
3406- unsigned pathLength;
3407-};
3408-
3409-int64_t JNICALL
3410-getFileAttributes
3411-(Thread* t, object method, uintptr_t* arguments)
3412-{
3413- const unsigned Exists = 1;
3414- const unsigned Regular = 2;
3415- const unsigned Directory = 4;
3416-
3417- MyClasspath* cp = static_cast<MyClasspath*>(t->m->classpath);
3418-
3419- object file = reinterpret_cast<object>(arguments[1]);
3420- object path = cast<object>(file, cp->filePathField);
3421-
3422- THREAD_RUNTIME_ARRAY(t, char, p, stringLength(t, path) + 1);
3423- stringChars(t, path, RUNTIME_ARRAY_BODY(p));
3424- replace('\\', '/', RUNTIME_ARRAY_BODY(p));
3425-
3426- EmbeddedFile ef(cp, RUNTIME_ARRAY_BODY(p), stringLength(t, path));
3427- if (ef.jar) {
3428- if (ef.jarLength == 0) {
3429- return Exists | Directory;
3430- }
3431-
3432- Finder* finder = getFinder(t, ef.jar, ef.jarLength);
3433- if (finder) {
3434- if (ef.pathLength == 0) {
3435- return Exists | Directory;
3436- }
3437-
3438- unsigned length;
3439- System::FileType type = finder->stat(ef.path, &length, true);
3440- switch (type) {
3441- case System::TypeUnknown: return Exists;
3442- case System::TypeDoesNotExist: return 0;
3443- case System::TypeFile: return Exists | Regular;
3444- case System::TypeDirectory: return Exists | Directory;
3445- default: abort(t);
3446- }
3447- } else {
3448- return 0;
3449- }
3450- } else {
3451- return intValue
3452- (t, t->m->processor->invoke
3453- (t, nativeInterceptOriginal
3454- (t, methodRuntimeDataNative(t, getMethodRuntimeData(t, method))),
3455- reinterpret_cast<object>(arguments[0]), file));
3456- }
3457-}
3458-
3459-int64_t JNICALL
3460-checkFileAccess
3461-(Thread* t, object method, uintptr_t* arguments)
3462-{
3463- const unsigned Read = 4;
3464-
3465- MyClasspath* cp = static_cast<MyClasspath*>(t->m->classpath);
3466-
3467- object file = reinterpret_cast<object>(arguments[1]);
3468- unsigned mask = arguments[2];
3469- object path = cast<object>(file, cp->filePathField);
3470-
3471- THREAD_RUNTIME_ARRAY(t, char, p, stringLength(t, path) + 1);
3472- stringChars(t, path, RUNTIME_ARRAY_BODY(p));
3473- replace('\\', '/', RUNTIME_ARRAY_BODY(p));
3474-
3475- EmbeddedFile ef(cp, RUNTIME_ARRAY_BODY(p), stringLength(t, path));
3476- if (ef.jar) {
3477- if (ef.jarLength == 0) {
3478- return mask == Read;
3479- }
3480-
3481- Finder* finder = getFinder(t, ef.jar, ef.jarLength);
3482- if (finder) {
3483- if (ef.pathLength == 0) {
3484- return mask == Read;
3485- }
3486-
3487- unsigned length;
3488- System::FileType type = finder->stat(ef.path, &length, true);
3489- switch (type) {
3490- case System::TypeDoesNotExist: return false;
3491- case System::TypeUnknown:
3492- case System::TypeFile:
3493- case System::TypeDirectory: return mask == Read;
3494- default: abort(t);
3495- }
3496- } else {
3497- return 0;
3498- }
3499- } else {
3500- return intValue
3501- (t, t->m->processor->invoke
3502- (t, nativeInterceptOriginal
3503- (t, methodRuntimeDataNative(t, getMethodRuntimeData(t, method))),
3504- reinterpret_cast<object>(arguments[0]), file, mask)) != 0;
3505- }
3506-}
3507-
3508-int64_t JNICALL
3509-getFileLength
3510-(Thread* t, object method, uintptr_t* arguments)
3511-{
3512- MyClasspath* cp = static_cast<MyClasspath*>(t->m->classpath);
3513-
3514- object file = reinterpret_cast<object>(arguments[1]);
3515- object path = cast<object>(file, cp->filePathField);
3516-
3517- THREAD_RUNTIME_ARRAY(t, char, p, stringLength(t, path) + 1);
3518- stringChars(t, path, RUNTIME_ARRAY_BODY(p));
3519- replace('\\', '/', RUNTIME_ARRAY_BODY(p));
3520-
3521- EmbeddedFile ef(cp, RUNTIME_ARRAY_BODY(p), stringLength(t, path));
3522- if (ef.jar) {
3523- if (ef.jarLength == 0) {
3524- return 0;
3525- }
3526-
3527- Finder* finder = getFinder(t, ef.jar, ef.jarLength);
3528- if (finder) {
3529- if (ef.pathLength == 0) {
3530- return 0;
3531- }
3532-
3533- unsigned fileLength;
3534- finder->stat(ef.path, &fileLength);
3535- return fileLength;
3536- }
3537-
3538- return 0;
3539- } else {
3540- return longValue
3541- (t, t->m->processor->invoke
3542- (t, nativeInterceptOriginal
3543- (t, methodRuntimeDataNative(t, getMethodRuntimeData(t, method))),
3544- reinterpret_cast<object>(arguments[0]), file));
3545- }
3546-}
3547-
3548-void JNICALL
3549-openFile(Thread* t, object method, uintptr_t* arguments)
3550-{
3551- object this_ = reinterpret_cast<object>(arguments[0]);
3552- object path = reinterpret_cast<object>(arguments[1]);
3553-
3554- MyClasspath* cp = static_cast<MyClasspath*>(t->m->classpath);
3555-
3556- THREAD_RUNTIME_ARRAY(t, char, p, stringLength(t, path) + 1);
3557- stringChars(t, path, RUNTIME_ARRAY_BODY(p));
3558- replace('\\', '/', RUNTIME_ARRAY_BODY(p));
3559-
3560- EmbeddedFile ef(cp, RUNTIME_ARRAY_BODY(p), stringLength(t, path));
3561- if (ef.jar) {
3562- if (ef.jarLength == 0 or ef.pathLength == 0) {
3563- throwNew(t, Machine::FileNotFoundExceptionType);
3564- }
3565-
3566- Finder* finder = getFinder(t, ef.jar, ef.jarLength);
3567- if (finder == 0) {
3568- throwNew(t, Machine::FileNotFoundExceptionType);
3569- }
3570-
3571- System::Region* r = finder->find(ef.path);
3572- if (r == 0) {
3573- throwNew(t, Machine::FileNotFoundExceptionType);
3574- }
3575-
3576- PROTECT(t, this_);
3577-
3578- ACQUIRE(t, t->m->referenceLock);
3579-
3580- int index = -1;
3581- unsigned oldLength = root(t, Machine::VirtualFiles)
3582- ? arrayLength(t, root(t, Machine::VirtualFiles)) : 0;
3583-
3584- for (unsigned i = 0; i < oldLength; ++i) {
3585- if (arrayBody(t, root(t, Machine::VirtualFiles), i) == 0) {
3586- index = i;
3587- break;
3588- }
3589- }
3590-
3591- if (index == -1) {
3592- object newArray = growArray(t, root(t, Machine::VirtualFiles));
3593- setRoot(t, Machine::VirtualFiles, newArray);
3594- index = oldLength;
3595- }
3596-
3597- object region = makeRegion(t, r, 0);
3598- set(t, root(t, Machine::VirtualFiles), ArrayBody + (index * BytesPerWord),
3599- region);
3600-
3601- cast<int32_t>
3602- (cast<object>
3603- (this_, cp->fileInputStreamFdField), cp->fileDescriptorFdField)
3604- = index + VirtualFileBase;
3605- } else {
3606- t->m->processor->invoke
3607- (t, nativeInterceptOriginal
3608- (t, methodRuntimeDataNative(t, getMethodRuntimeData(t, method))),
3609- this_, path);
3610- }
3611-}
3612-
3613-int64_t JNICALL
3614-readByteFromFile(Thread* t, object method, uintptr_t* arguments)
3615-{
3616- object this_ = reinterpret_cast<object>(arguments[0]);
3617-
3618- MyClasspath* cp = static_cast<MyClasspath*>(t->m->classpath);
3619-
3620- int fd = cast<int32_t>
3621- (cast<object>
3622- (this_, cp->fileInputStreamFdField), cp->fileDescriptorFdField);
3623-
3624- if (fd >= VirtualFileBase) {
3625- ACQUIRE(t, t->m->referenceLock);
3626-
3627- object region = arrayBody
3628- (t, root(t, Machine::VirtualFiles), fd - VirtualFileBase);
3629-
3630- if (region) {
3631- System::Region* r = static_cast<System::Region*>
3632- (regionRegion(t, region));
3633-
3634- if (r->length() > regionPosition(t, region)) {
3635- return r->start()[regionPosition(t, region)++];
3636- } else {
3637- return -1;
3638- }
3639- } else {
3640- throwNew(t, Machine::IoExceptionType);
3641- }
3642- } else {
3643- return intValue
3644- (t, t->m->processor->invoke
3645- (t, nativeInterceptOriginal
3646- (t, methodRuntimeDataNative(t, getMethodRuntimeData(t, method))),
3647- this_));
3648- }
3649-}
3650-
3651-int64_t JNICALL
3652-readBytesFromFile(Thread* t, object method, uintptr_t* arguments)
3653-{
3654- object this_ = reinterpret_cast<object>(arguments[0]);
3655- object dst = reinterpret_cast<object>(arguments[1]);
3656- int32_t offset = arguments[2];
3657- int32_t length = arguments[3];
3658-
3659- MyClasspath* cp = static_cast<MyClasspath*>(t->m->classpath);
3660-
3661- int fd = cast<int32_t>
3662- (cast<object>
3663- (this_, cp->fileInputStreamFdField), cp->fileDescriptorFdField);
3664-
3665- if (fd >= VirtualFileBase) {
3666- PROTECT(t, dst);
3667-
3668- ACQUIRE(t, t->m->referenceLock);
3669-
3670- object region = arrayBody
3671- (t, root(t, Machine::VirtualFiles), fd - VirtualFileBase);
3672-
3673- if (region) {
3674- System::Region* r = static_cast<System::Region*>
3675- (regionRegion(t, region));
3676-
3677- int available = r->length() - regionPosition(t, region);
3678- if (available == 0) {
3679- return -1;
3680- }
3681-
3682- if (length > available) {
3683- length = available;
3684- }
3685-
3686- memcpy(&byteArrayBody(t, dst, offset),
3687- r->start() + regionPosition(t, region),
3688- length);
3689-
3690- regionPosition(t, region) += length;
3691-
3692- return length;
3693- } else {
3694- throwNew(t, Machine::IoExceptionType);
3695- }
3696- } else {
3697- return intValue
3698- (t, t->m->processor->invoke
3699- (t, nativeInterceptOriginal
3700- (t, methodRuntimeDataNative(t, getMethodRuntimeData(t, method))),
3701- this_, dst, offset, length));
3702- }
3703-}
3704-
3705-int64_t JNICALL
3706-skipBytesInFile(Thread* t, object method, uintptr_t* arguments)
3707-{
3708- object this_ = reinterpret_cast<object>(arguments[0]);
3709- int64_t count; memcpy(&count, arguments + 1, 8);
3710-
3711- MyClasspath* cp = static_cast<MyClasspath*>(t->m->classpath);
3712-
3713- int fd = cast<int32_t>
3714- (cast<object>
3715- (this_, cp->fileInputStreamFdField), cp->fileDescriptorFdField);
3716-
3717- if (fd >= VirtualFileBase) {
3718- ACQUIRE(t, t->m->referenceLock);
3719-
3720- object region = arrayBody
3721- (t, root(t, Machine::VirtualFiles), fd - VirtualFileBase);
3722-
3723- if (region) {
3724- System::Region* r = static_cast<System::Region*>
3725- (regionRegion(t, region));
3726-
3727- int available = r->length() - regionPosition(t, region);
3728- if (count > available) {
3729- count = available;
3730- }
3731-
3732- regionPosition(t, region) += count;
3733-
3734- return count;
3735- } else {
3736- throwNew(t, Machine::IoExceptionType);
3737- }
3738- } else {
3739- return longValue
3740- (t, t->m->processor->invoke
3741- (t, nativeInterceptOriginal
3742- (t, methodRuntimeDataNative(t, getMethodRuntimeData(t, method))),
3743- this_, count));
3744- }
3745-}
3746-
3747-int64_t JNICALL
3748-availableBytesInFile(Thread* t, object method, uintptr_t* arguments)
3749-{
3750- object this_ = reinterpret_cast<object>(arguments[0]);
3751-
3752- MyClasspath* cp = static_cast<MyClasspath*>(t->m->classpath);
3753-
3754- int fd = cast<int32_t>
3755- (cast<object>
3756- (this_, cp->fileInputStreamFdField), cp->fileDescriptorFdField);
3757-
3758- if (fd >= VirtualFileBase) {
3759- ACQUIRE(t, t->m->referenceLock);
3760-
3761- object region = arrayBody
3762- (t, root(t, Machine::VirtualFiles), fd - VirtualFileBase);
3763-
3764- if (region) {
3765- return static_cast<System::Region*>(regionRegion(t, region))->length()
3766- - regionPosition(t, region);
3767- } else {
3768- throwNew(t, Machine::IoExceptionType);
3769- }
3770- } else {
3771- object r = t->m->processor->invoke
3772- (t, nativeInterceptOriginal
3773- (t, methodRuntimeDataNative(t, getMethodRuntimeData(t, method))),
3774- this_);
3775-
3776- return r ? intValue(t, r) : 0;
3777- }
3778-}
3779-
3780-void JNICALL
3781-closeFile(Thread* t, object method, uintptr_t* arguments)
3782-{
3783- object this_ = reinterpret_cast<object>(arguments[0]);
3784-
3785- MyClasspath* cp = static_cast<MyClasspath*>(t->m->classpath);
3786-
3787- int fd = cast<int32_t>
3788- (cast<object>
3789- (this_, cp->fileInputStreamFdField), cp->fileDescriptorFdField);
3790-
3791- if (fd >= VirtualFileBase) {
3792- ACQUIRE(t, t->m->referenceLock);
3793-
3794- int index = fd - VirtualFileBase;
3795- object region = arrayBody(t, root(t, Machine::VirtualFiles), index);
3796-
3797- if (region) {
3798- static_cast<System::Region*>(regionRegion(t, region))->dispose();
3799- }
3800-
3801- set(t, root(t, Machine::VirtualFiles), ArrayBody + (index * BytesPerWord),
3802- 0);
3803- } else {
3804- t->m->processor->invoke
3805- (t, nativeInterceptOriginal
3806- (t, methodRuntimeDataNative(t, getMethodRuntimeData(t, method))),
3807- this_);
3808- }
3809-}
3810-
3811-class ZipFile {
3812- public:
3813- class Entry {
3814- public:
3815- Entry(unsigned hash, const uint8_t* start, Entry* next):
3816- hash(hash), start(start), next(next), entry(0)
3817- { }
3818-
3819- Entry(int64_t entry):
3820- hash(0), start(0), next(0), entry(entry)
3821- { }
3822-
3823- Entry():
3824- hash(0), start(0), next(0), entry(0)
3825- { }
3826-
3827- unsigned hash;
3828- const uint8_t* start;
3829- Entry* next;
3830- int64_t entry;
3831- };
3832-
3833- ZipFile(Thread* t, System::Region* region, unsigned entryCount):
3834- region(region),
3835- entryCount(entryCount),
3836- indexSize(nextPowerOfTwo(entryCount)),
3837- index(reinterpret_cast<ZipFile::Entry**>
3838- (t->m->heap->allocate(sizeof(ZipFile::Entry*) * indexSize))),
3839- file(0)
3840- {
3841- memset(index, 0, sizeof(ZipFile::Entry*) * indexSize);
3842- }
3843-
3844- ZipFile(int64_t file):
3845- region(0), entryCount(0), indexSize(0), index(0), file(file)
3846- { }
3847-
3848- System::Region* region;
3849- unsigned entryCount;
3850- unsigned indexSize;
3851- Entry** index;
3852- int64_t file;
3853- Entry entries[0];
3854-};
3855-
3856-int64_t JNICALL
3857-openZipFile(Thread* t, object method, uintptr_t* arguments)
3858-{
3859- object path = reinterpret_cast<object>(arguments[0]);
3860- int mode = arguments[1];
3861- int64_t lastModified; memcpy(&lastModified, arguments + 2, 8);
3862-
3863- MyClasspath* cp = static_cast<MyClasspath*>(t->m->classpath);
3864-
3865- THREAD_RUNTIME_ARRAY(t, char, p, stringLength(t, path) + 1);
3866- stringChars(t, path, RUNTIME_ARRAY_BODY(p));
3867- replace('\\', '/', RUNTIME_ARRAY_BODY(p));
3868-
3869- EmbeddedFile ef(cp, RUNTIME_ARRAY_BODY(p), stringLength(t, path));
3870- if (ef.jar) {
3871- if (ef.jarLength == 0 or ef.pathLength == 0) {
3872- throwNew(t, Machine::FileNotFoundExceptionType);
3873- }
3874-
3875- Finder* finder = getFinder(t, ef.jar, ef.jarLength);
3876- if (finder == 0) {
3877- throwNew(t, Machine::FileNotFoundExceptionType);
3878- }
3879-
3880- System::Region* r = finder->find(ef.path);
3881- if (r == 0) {
3882- throwNew(t, Machine::FileNotFoundExceptionType);
3883- }
3884-
3885- const uint8_t* start = r->start();
3886- const uint8_t* end = start + r->length();
3887- unsigned entryCount = 0;
3888- for (const uint8_t* p = end - CentralDirectorySearchStart; p > start;) {
3889- if (get4(p) == CentralDirectorySignature) {
3890- p = start + centralDirectoryOffset(p);
3891-
3892- while (p < end) {
3893- if (get4(p) == EntrySignature) {
3894- ++ entryCount;
3895-
3896- p = endOfEntry(p);
3897- } else {
3898- goto make;
3899- }
3900- }
3901- } else {
3902- -- p;
3903- }
3904- }
3905-
3906- make:
3907- ZipFile* file = new
3908- (t->m->heap->allocate
3909- (sizeof(ZipFile) + (sizeof(ZipFile::Entry) * entryCount)))
3910- ZipFile(t, r, entryCount);
3911-
3912- { unsigned position = 0;
3913- for (const uint8_t* p = end - CentralDirectorySearchStart; p > start;) {
3914- if (get4(p) == CentralDirectorySignature) {
3915- p = start + centralDirectoryOffset(p);
3916-
3917- while (p < end) {
3918- if (get4(p) == EntrySignature) {
3919- unsigned h = hash(fileName(p), fileNameLength(p));
3920- unsigned i = h & (file->indexSize - 1);
3921-
3922- file->index[i] = new (file->entries + (position++))
3923- ZipFile::Entry(h, p, file->index[i]);
3924-
3925- p = endOfEntry(p);
3926- } else {
3927- goto exit;
3928- }
3929- }
3930- } else {
3931- -- p;
3932- }
3933- }
3934- }
3935-
3936- exit:
3937- return reinterpret_cast<int64_t>(file);
3938- } else {
3939- return reinterpret_cast<int64_t>
3940- (new (t->m->heap->allocate(sizeof(ZipFile))) ZipFile
3941- (longValue
3942- (t, t->m->processor->invoke
3943- (t, nativeInterceptOriginal
3944- (t, methodRuntimeDataNative(t, getMethodRuntimeData(t, method))),
3945- 0, path, mode, lastModified))));
3946- }
3947-}
3948-
3949-int64_t JNICALL
3950-getZipFileEntryCount(Thread* t, object method, uintptr_t* arguments)
3951-{
3952- int64_t peer; memcpy(&peer, arguments, 8);
3953-
3954- ZipFile* file = reinterpret_cast<ZipFile*>(peer);
3955- if (file->region) {
3956- return file->entryCount;
3957- } else {
3958- return intValue
3959- (t, t->m->processor->invoke
3960- (t, nativeInterceptOriginal
3961- (t, methodRuntimeDataNative(t, getMethodRuntimeData(t, method))),
3962- 0, file->file));
3963- }
3964-}
3965-
3966-ZipFile::Entry*
3967-find(ZipFile* file, const char* path, unsigned pathLength)
3968-{
3969- unsigned i = hash(path) & (file->indexSize - 1);
3970- for (ZipFile::Entry* e = file->index[i]; e; e = e->next) {
3971- const uint8_t* p = e->start;
3972- if (equal(path, pathLength, fileName(p), fileNameLength(p))) {
3973- return e;
3974- }
3975- }
3976- return 0;
3977-}
3978-
3979-int64_t JNICALL
3980-getZipFileEntry(Thread* t, object method, uintptr_t* arguments)
3981-{
3982- int64_t peer; memcpy(&peer, arguments, 8);
3983- object path = reinterpret_cast<object>(arguments[2]);
3984- bool addSlash = arguments[3];
3985-
3986- ZipFile* file = reinterpret_cast<ZipFile*>(peer);
3987- if (file->region) {
3988- THREAD_RUNTIME_ARRAY(t, char, p, byteArrayLength(t, path) + 2);
3989- memcpy(RUNTIME_ARRAY_BODY(p), &byteArrayBody(t, path, 0),
3990- byteArrayLength(t, path));
3991- RUNTIME_ARRAY_BODY(p)[byteArrayLength(t, path)] = 0;
3992- replace('\\', '/', RUNTIME_ARRAY_BODY(p));
3993- if (addSlash) {
3994- RUNTIME_ARRAY_BODY(p)[byteArrayLength(t, path)] = '/';
3995- RUNTIME_ARRAY_BODY(p)[byteArrayLength(t, path) + 1] = 0;
3996- }
3997-
3998- return reinterpret_cast<int64_t>(find(file, p, byteArrayLength(t, path)));
3999- } else {
4000- int64_t entry = longValue
4001- (t, t->m->processor->invoke
4002- (t, nativeInterceptOriginal
4003- (t, methodRuntimeDataNative(t, getMethodRuntimeData(t, method))),
4004- 0, file->file, path, addSlash));
4005-
4006- return entry ? reinterpret_cast<int64_t>
4007- (new (t->m->heap->allocate(sizeof(ZipFile::Entry)))
4008- ZipFile::Entry(entry)) : 0;
4009- }
4010-}
4011-
4012-int64_t JNICALL
4013-getZipFileEntryBytes(Thread* t, object method, uintptr_t* arguments)
4014-{
4015- int64_t peer; memcpy(&peer, arguments, 8);
4016- int type = arguments[2];
4017-
4018- ZipFile::Entry* entry = reinterpret_cast<ZipFile::Entry*>(peer);
4019- if (entry->start) {
4020- switch (type) {
4021- case 0: { // name
4022- unsigned nameLength = fileNameLength(entry->start);
4023- object array = makeByteArray(t, nameLength + 1);
4024- memcpy(&byteArrayBody(t, array, 0), fileName(entry->start), nameLength);
4025- byteArrayBody(t, array, nameLength) = 0;
4026- return reinterpret_cast<int64_t>(array);
4027- } break;
4028-
4029- case 1: { // extra
4030- return 0;
4031- } break;
4032-
4033- case 2: { // comment
4034- return 0;
4035- } break;
4036-
4037- default: abort(t);
4038- }
4039- return compressedSize(entry->start);
4040- } else {
4041- return reinterpret_cast<int64_t>
4042- (t->m->processor->invoke
4043- (t, nativeInterceptOriginal
4044- (t, methodRuntimeDataNative(t, getMethodRuntimeData(t, method))),
4045- 0, entry->entry, type));
4046- }
4047-}
4048-
4049-int64_t JNICALL
4050-getNextZipFileEntry(Thread* t, object method, uintptr_t* arguments)
4051-{
4052- int64_t peer; memcpy(&peer, arguments, 8);
4053- int index = arguments[2];
4054-
4055- ZipFile* file = reinterpret_cast<ZipFile*>(peer);
4056- if (file->region) {
4057- return reinterpret_cast<int64_t>(file->entries + index);
4058- } else {
4059- int64_t entry = longValue
4060- (t, t->m->processor->invoke
4061- (t, nativeInterceptOriginal
4062- (t, methodRuntimeDataNative(t, getMethodRuntimeData(t, method))),
4063- 0, file->file, index));
4064-
4065- return entry ? reinterpret_cast<int64_t>
4066- (new (t->m->heap->allocate(sizeof(ZipFile::Entry)))
4067- ZipFile::Entry(entry)) : 0;
4068- }
4069-}
4070-
4071-void JNICALL
4072-initializeZipEntryFields(Thread* t, object method, uintptr_t* arguments)
4073-{
4074- object this_ = reinterpret_cast<object>(arguments[0]);
4075- int64_t peer; memcpy(&peer, arguments + 1, 8);
4076-
4077- ZipFile::Entry* entry = reinterpret_cast<ZipFile::Entry*>(peer);
4078- if (entry->start) {
4079- PROTECT(t, this_);
4080-
4081- MyClasspath* cp = static_cast<MyClasspath*>(t->m->classpath);
4082-
4083- unsigned nameLength = fileNameLength(entry->start);
4084- object array = makeByteArray(t, nameLength + 1);
4085- memcpy(&byteArrayBody(t, array, 0), fileName(entry->start), nameLength);
4086- byteArrayBody(t, array, nameLength) = 0;
4087-
4088- object name = t->m->classpath->makeString
4089- (t, array, 0, byteArrayLength(t, array) - 1);
4090-
4091- set(t, this_, cp->zipEntryNameField, name);
4092-
4093- cast<int64_t>(this_, cp->zipEntryTimeField)
4094- = fileTime(entry->start);
4095- cast<int64_t>(this_, cp->zipEntryCrcField)
4096- = fileCRC(entry->start);
4097- cast<int64_t>(this_, cp->zipEntrySizeField)
4098- = uncompressedSize(entry->start);
4099- cast<int64_t>(this_, cp->zipEntryCsizeField)
4100- = compressedSize(entry->start);
4101- cast<int64_t>(this_, cp->zipEntryMethodField)
4102- = compressionMethod(entry->start);
4103- } else {
4104- t->m->processor->invoke
4105- (t, nativeInterceptOriginal
4106- (t, methodRuntimeDataNative(t, getMethodRuntimeData(t, method))),
4107- this_, entry->entry);
4108- }
4109-}
4110-
4111-int64_t JNICALL
4112-getZipFileEntryMethod(Thread* t, object method, uintptr_t* arguments)
4113-{
4114- int64_t peer; memcpy(&peer, arguments, 8);
4115-
4116- ZipFile::Entry* entry = reinterpret_cast<ZipFile::Entry*>(peer);
4117- if (entry->start) {
4118- return compressionMethod(entry->start);
4119- } else {
4120- return intValue
4121- (t, t->m->processor->invoke
4122- (t, nativeInterceptOriginal
4123- (t, methodRuntimeDataNative(t, getMethodRuntimeData(t, method))),
4124- 0, entry->entry));
4125- }
4126-}
4127-
4128-int64_t JNICALL
4129-getZipFileEntryCompressedSize(Thread* t, object method, uintptr_t* arguments)
4130-{
4131- int64_t peer; memcpy(&peer, arguments, 8);
4132-
4133- ZipFile::Entry* entry = reinterpret_cast<ZipFile::Entry*>(peer);
4134- if (entry->start) {
4135- return compressedSize(entry->start);
4136- } else {
4137- return longValue
4138- (t, t->m->processor->invoke
4139- (t, nativeInterceptOriginal
4140- (t, methodRuntimeDataNative(t, getMethodRuntimeData(t, method))),
4141- 0, entry->entry));
4142- }
4143-}
4144-
4145-int64_t JNICALL
4146-getZipFileEntryUncompressedSize(Thread* t, object method, uintptr_t* arguments)
4147-{
4148- int64_t peer; memcpy(&peer, arguments, 8);
4149-
4150- ZipFile::Entry* entry = reinterpret_cast<ZipFile::Entry*>(peer);
4151- if (entry->start) {
4152- return uncompressedSize(entry->start);
4153- } else {
4154- return longValue
4155- (t, t->m->processor->invoke
4156- (t, nativeInterceptOriginal
4157- (t, methodRuntimeDataNative(t, getMethodRuntimeData(t, method))),
4158- 0, entry->entry));
4159- }
4160-}
4161-
4162-void JNICALL
4163-freeZipFileEntry(Thread* t, object method, uintptr_t* arguments)
4164-{
4165- int64_t filePeer; memcpy(&filePeer, arguments, 8);
4166- int64_t entryPeer; memcpy(&entryPeer, arguments + 2, 8);
4167-
4168- ZipFile* file = reinterpret_cast<ZipFile*>(filePeer);
4169- ZipFile::Entry* entry = reinterpret_cast<ZipFile::Entry*>(entryPeer);
4170- if (file->region == 0) {
4171- t->m->processor->invoke
4172- (t, nativeInterceptOriginal
4173- (t, methodRuntimeDataNative(t, getMethodRuntimeData(t, method))),
4174- 0, file->file, entry->entry);
4175- }
4176-
4177- t->m->heap->free(entry, sizeof(ZipFile::Entry));
4178-}
4179-
4180-int64_t JNICALL
4181-readZipFileEntry(Thread* t, object method, uintptr_t* arguments)
4182-{
4183- int64_t filePeer; memcpy(&filePeer, arguments, 8);
4184- int64_t entryPeer; memcpy(&entryPeer, arguments + 2, 8);
4185- int64_t position; memcpy(&position, arguments + 4, 8);
4186- object buffer = reinterpret_cast<object>(arguments[6]);
4187- int offset = arguments[7];
4188- int length = arguments[8];
4189-
4190- ZipFile* file = reinterpret_cast<ZipFile*>(filePeer);
4191- ZipFile::Entry* entry = reinterpret_cast<ZipFile::Entry*>(entryPeer);
4192- if (file->region) {
4193- unsigned size = uncompressedSize(entry->start);
4194- if (position >= size) {
4195- return -1;
4196- }
4197-
4198- if (position + length > size) {
4199- length = size - position;
4200- }
4201-
4202- memcpy(&byteArrayBody(t, buffer, offset),
4203- fileData(file->region->start() + localHeaderOffset(entry->start))
4204- + position,
4205- length);
4206-
4207- return length;
4208- } else {
4209- return intValue
4210- (t, t->m->processor->invoke
4211- (t, nativeInterceptOriginal
4212- (t, methodRuntimeDataNative(t, getMethodRuntimeData(t, method))),
4213- 0, file->file, entry->entry, position, buffer, offset, length));
4214- }
4215-}
4216-
4217-int64_t JNICALL
4218-getZipMessage(Thread* t, object method, uintptr_t* arguments)
4219-{
4220- int64_t peer; memcpy(&peer, arguments, 8);
4221-
4222- ZipFile* file = reinterpret_cast<ZipFile*>(peer);
4223- if (file->region) {
4224- return 0;
4225- } else {
4226- return reinterpret_cast<int64_t>
4227- (t->m->processor->invoke
4228- (t, nativeInterceptOriginal
4229- (t, methodRuntimeDataNative(t, getMethodRuntimeData(t, method))),
4230- 0, file->file));
4231- }
4232-}
4233-
4234-int64_t JNICALL
4235-getJarFileMetaInfEntryNames(Thread* t, object method, uintptr_t* arguments)
4236-{
4237- object this_ = reinterpret_cast<object>(arguments[0]);
4238-
4239- MyClasspath* cp = static_cast<MyClasspath*>(t->m->classpath);
4240-
4241- int64_t peer = cast<int64_t>(this_, cp->zipFileJzfileField);
4242- ZipFile* file = reinterpret_cast<ZipFile*>(peer);
4243- if (file->region) {
4244- return 0;
4245- } else {
4246- PROTECT(t, method);
4247-
4248- // OpenJDK's Java_java_util_jar_JarFile_getMetaInfEntryNames
4249- // implementation expects to find a pointer to an instance of its
4250- // jzfile structure in the ZipFile.jzfile field of the object we
4251- // pass in. However, we can't pass this_ in, because its
4252- // ZipFile.jzfile field points to a ZipFile instance, not a
4253- // jzfile. So we pass in a temporary object instead which has the
4254- // desired pointer at the same offset. We assume here that
4255- // ZipFile.jzfile is the first field in that class and that
4256- // Java_java_util_jar_JarFile_getMetaInfEntryNames will not look
4257- // for any other fields in the object.
4258- object pseudoThis = makeLong(t, file->file);
4259-
4260- return reinterpret_cast<int64_t>
4261- (t->m->processor->invoke
4262- (t, nativeInterceptOriginal
4263- (t, methodRuntimeDataNative(t, getMethodRuntimeData(t, method))),
4264- pseudoThis));
4265- }
4266-}
4267-
4268-void JNICALL
4269-closeZipFile(Thread* t, object method, uintptr_t* arguments)
4270-{
4271- int64_t peer; memcpy(&peer, arguments, 8);
4272-
4273- ZipFile* file = reinterpret_cast<ZipFile*>(peer);
4274- if (file->region) {
4275- file->region->dispose();
4276- t->m->heap->free(file, sizeof(ZipFile)
4277- + (sizeof(ZipFile::Entry) * file->entryCount));
4278- } else {
4279- t->m->processor->invoke
4280- (t, nativeInterceptOriginal
4281- (t, methodRuntimeDataNative(t, getMethodRuntimeData(t, method))),
4282- 0, file->file);
4283-
4284- t->m->heap->free(file, sizeof(ZipFile));
4285- }
4286-}
4287-
4288-int64_t JNICALL
4289-getBootstrapResource(Thread* t, object, uintptr_t* arguments)
4290-{
4291- object name = reinterpret_cast<object>(arguments[0]);
4292- PROTECT(t, name);
4293-
4294- object m = findMethodOrNull
4295- (t, type(t, Machine::SystemClassLoaderType),
4296- "findResource", "(Ljava/lang/String;)Ljava/net/URL;");
4297-
4298- if (m) {
4299- return reinterpret_cast<int64_t>
4300- (t->m->processor->invoke(t, m, root(t, Machine::BootLoader), name));
4301- } else {
4302- return 0;
4303- }
4304-}
4305-
4306-int64_t JNICALL
4307-getBootstrapResources(Thread* t, object, uintptr_t* arguments)
4308-{
4309- object name = reinterpret_cast<object>(arguments[0]);
4310- PROTECT(t, name);
4311-
4312- object m = findMethodOrNull
4313- (t, type(t, Machine::SystemClassLoaderType),
4314- "findResources", "(Ljava/lang/String;)Ljava/util/Enumeration;");
4315-
4316- if (m) {
4317- return reinterpret_cast<int64_t>
4318- (t->m->processor->invoke(t, m, root(t, Machine::BootLoader), name));
4319- } else {
4320- return 0;
4321- }
4322-}
4323-
4324-extern "C" JNIEXPORT jint JNICALL
4325-net_JNI_OnLoad(JavaVM*, void*);
4326-
4327-extern "C" JNIEXPORT jint JNICALL
4328-management_JNI_OnLoad(JavaVM*, void*);
4329-
4330-void JNICALL
4331-loadLibrary(Thread* t, object, uintptr_t* arguments)
4332-{
4333- object name = reinterpret_cast<object>(arguments[1]);
4334- THREAD_RUNTIME_ARRAY(t, char, n, stringLength(t, name) + 1);
4335- stringChars(t, name, RUNTIME_ARRAY_BODY(n));
4336-
4337- bool absolute = arguments[2];
4338-
4339-#ifdef AVIAN_OPENJDK_SRC
4340- if (not absolute) {
4341- if (strcmp(n, "net") == 0) {
4342- bool ran;
4343-
4344- { ACQUIRE(t, t->m->classLock);
4345-
4346- local::MyClasspath* c = static_cast<local::MyClasspath*>
4347- (t->m->classpath);
4348-
4349- ran = c->ranNetOnLoad;
4350- c->ranNetOnLoad = true;
4351- }
4352-
4353- if (not ran) {
4354- net_JNI_OnLoad(t->m, 0);
4355- }
4356-
4357- return;
4358- } else if (strcmp(n, "management") == 0) {
4359- bool ran;
4360-
4361- { ACQUIRE(t, t->m->classLock);
4362-
4363- local::MyClasspath* c = static_cast<local::MyClasspath*>
4364- (t->m->classpath);
4365-
4366- ran = c->ranManagementOnLoad;
4367- c->ranManagementOnLoad = true;
4368- }
4369-
4370- if (not ran) {
4371- management_JNI_OnLoad(t->m, 0);
4372- }
4373-
4374- return;
4375- } else if (strcmp(n, "zip") == 0
4376- or strcmp(n, "nio") == 0)
4377- {
4378- return;
4379- }
4380- }
4381-#endif // AVIAN_OPENJDK_SRC
4382-
4383- loadLibrary
4384- (t, static_cast<local::MyClasspath*>(t->m->classpath)->libraryPath,
4385- RUNTIME_ARRAY_BODY(n), not absolute, true);
4386-}
4387-
4388-// only safe to call during bootstrap when there's only one thread
4389-// running:
4390-void
4391-intercept(Thread* t, object c, const char* name, const char* spec,
4392- void* function)
4393-{
4394- object m = findMethodOrNull(t, c, name, spec);
4395- if (m) {
4396- PROTECT(t, m);
4397-
4398- object clone = methodClone(t, m);
4399-
4400- // make clone private to prevent vtable updates at compilation
4401- // time. Otherwise, our interception might be bypassed by calls
4402- // through the vtable.
4403- methodFlags(t, clone) |= ACC_PRIVATE;
4404-
4405- methodFlags(t, m) |= ACC_NATIVE;
4406-
4407- object native = makeNativeIntercept(t, function, true, clone);
4408-
4409- PROTECT(t, native);
4410-
4411- object runtimeData = getMethodRuntimeData(t, m);
4412-
4413- set(t, runtimeData, MethodRuntimeDataNative, native);
4414- } else {
4415- // If we can't find the method, just ignore it, since ProGuard may
4416- // have stripped it out as unused. Otherwise, the code below can
4417- // be uncommented for debugging purposes.
4418-
4419- // fprintf(stderr, "unable to find %s%s in %s\n",
4420- // name, spec, &byteArrayBody(t, className(t, c), 0));
4421-
4422- // abort(t);
4423- }
4424-}
4425-
4426-void
4427-interceptFileOperations(Thread* t)
4428-{
4429- MyClasspath* cp = static_cast<MyClasspath*>(t->m->classpath);
4430-
4431- { object fileClass = resolveClass
4432- (t, root(t, Machine::BootLoader), "java/io/File", false);
4433-
4434- if (fileClass) {
4435- object filePathField = findFieldInClass2
4436- (t, fileClass, "path", "Ljava/lang/String;");
4437-
4438- if (filePathField) {
4439- cp->filePathField = fieldOffset(t, filePathField);
4440- }
4441- }
4442- }
4443-
4444- { object fileDescriptorClass = resolveClass
4445- (t, root(t, Machine::BootLoader), "java/io/FileDescriptor", false);
4446-
4447- if (fileDescriptorClass) {
4448- object fileDescriptorFdField = findFieldInClass2
4449- (t, fileDescriptorClass, "fd", "I");
4450-
4451- if (fileDescriptorFdField) {
4452- cp->fileDescriptorFdField = fieldOffset(t, fileDescriptorFdField);
4453- }
4454- }
4455- }
4456-
4457- { object fileInputStreamClass = resolveClass
4458- (t, root(t, Machine::BootLoader), "java/io/FileInputStream", false);
4459-
4460- if (fileInputStreamClass) {
4461- PROTECT(t, fileInputStreamClass);
4462-
4463- object fileInputStreamFdField = findFieldInClass2
4464- (t, fileInputStreamClass, "fd", "Ljava/io/FileDescriptor;");
4465-
4466- if (fileInputStreamFdField) {
4467- cp->fileInputStreamFdField = fieldOffset(t, fileInputStreamFdField);
4468-
4469- intercept(t, fileInputStreamClass, "open", "(Ljava/lang/String;)V",
4470- voidPointer(openFile));
4471-
4472- intercept(t, fileInputStreamClass, "read", "()I",
4473- voidPointer(readByteFromFile));
4474-
4475- intercept(t, fileInputStreamClass, "readBytes", "([BII)I",
4476- voidPointer(readBytesFromFile));
4477-
4478- intercept(t, fileInputStreamClass, "skip", "(J)J",
4479- voidPointer(skipBytesInFile));
4480-
4481- intercept(t, fileInputStreamClass, "available", "()I",
4482- voidPointer(availableBytesInFile));
4483-
4484- intercept(t, fileInputStreamClass, "close0", "()V",
4485- voidPointer(closeFile));
4486- }
4487- }
4488- }
4489-
4490- { object zipFileClass = resolveClass
4491- (t, root(t, Machine::BootLoader), "java/util/zip/ZipFile", false);
4492-
4493- if (zipFileClass) {
4494- PROTECT(t, zipFileClass);
4495-
4496- object zipFileJzfileField = findFieldInClass2
4497- (t, zipFileClass, "jzfile", "J");
4498-
4499- if (zipFileJzfileField) {
4500- cp->zipFileJzfileField = fieldOffset(t, zipFileJzfileField);
4501-
4502- intercept(t, zipFileClass, "open", "(Ljava/lang/String;IJZ)J",
4503- voidPointer(openZipFile));
4504-
4505- intercept(t, zipFileClass, "getTotal", "(J)I",
4506- voidPointer(getZipFileEntryCount));
4507-
4508- intercept(t, zipFileClass, "getEntry", "(J[BZ)J",
4509- voidPointer(getZipFileEntry));
4510-
4511- intercept(t, zipFileClass, "getEntryBytes", "(JI)[B",
4512- voidPointer(getZipFileEntryBytes));
4513-
4514- intercept(t, zipFileClass, "getNextEntry", "(JI)J",
4515- voidPointer(getNextZipFileEntry));
4516-
4517- intercept(t, zipFileClass, "getEntryMethod", "(J)I",
4518- voidPointer(getZipFileEntryMethod));
4519-
4520- intercept(t, zipFileClass, "freeEntry", "(JJ)V",
4521- voidPointer(freeZipFileEntry));
4522-
4523- intercept(t, zipFileClass, "read", "(JJJ[BII)I",
4524- voidPointer(readZipFileEntry));
4525-
4526- intercept(t, zipFileClass, "getEntryCSize", "(J)J",
4527- voidPointer(getZipFileEntryCompressedSize));
4528-
4529- intercept(t, zipFileClass, "getEntrySize", "(J)J",
4530- voidPointer(getZipFileEntryUncompressedSize));
4531-
4532- intercept(t, zipFileClass, "getZipMessage", "(J)Ljava/lang/String;",
4533- voidPointer(getZipMessage));
4534-
4535- intercept(t, zipFileClass, "close", "(J)V",
4536- voidPointer(closeZipFile));
4537- }
4538- }
4539- }
4540-
4541- { object jarFileClass = resolveClass
4542- (t, root(t, Machine::BootLoader), "java/util/jar/JarFile", false);
4543-
4544- if (jarFileClass) {
4545- intercept(t, jarFileClass, "getMetaInfEntryNames",
4546- "()[Ljava/lang/String;",
4547- voidPointer(getJarFileMetaInfEntryNames));
4548- }
4549- }
4550-
4551- {
4552-#ifdef PLATFORM_WINDOWS
4553- const char* const fsClassName = "java/io/WinNTFileSystem";
4554- const char* const gbaMethodName = "getBooleanAttributes";
4555-#else
4556- const char* const fsClassName = "java/io/UnixFileSystem";
4557- const char* const gbaMethodName = "getBooleanAttributes0";
4558-#endif
4559-
4560- object fsClass = resolveClass
4561- (t, root(t, Machine::BootLoader), fsClassName, false);
4562-
4563- if (fsClass) {
4564- PROTECT(t, fsClass);
4565-
4566- intercept(t, fsClass, gbaMethodName, "(Ljava/io/File;)I",
4567- voidPointer(getFileAttributes));
4568-
4569- intercept(t, fsClass, "checkAccess", "(Ljava/io/File;I)Z",
4570- voidPointer(checkFileAccess));
4571-
4572- intercept(t, fsClass, "getLength", "(Ljava/io/File;)J",
4573- voidPointer(getFileLength));
4574- }
4575- }
4576-
4577- intercept(t, type(t, Machine::ClassLoaderType), "loadLibrary",
4578- "(Ljava/lang/Class;Ljava/lang/String;Z)V",
4579- voidPointer(loadLibrary));
4580-
4581- intercept(t, type(t, Machine::ClassLoaderType), "getBootstrapResource",
4582- "(Ljava/lang/String;)Ljava/net/URL;",
4583- voidPointer(getBootstrapResource));
4584-
4585- intercept(t, type(t, Machine::ClassLoaderType), "getBootstrapResources",
4586- "(Ljava/lang/String;)Ljava/util/Enumeration;",
4587- voidPointer(getBootstrapResources));
4588-}
4589-
4590-object
4591-getClassMethodTable(Thread* t, object c)
4592-{
4593- object addendum = classAddendum(t, c);
4594- if (addendum) {
4595- object table = classAddendumMethodTable(t, addendum);
4596- if (table) {
4597- return table;
4598- }
4599- }
4600- return classMethodTable(t, c);
4601-}
4602-
4603-unsigned
4604-countMethods(Thread* t, object c, bool publicOnly)
4605-{
4606- object table = getClassMethodTable(t, c);
4607- unsigned count = 0;
4608- for (unsigned i = 0; i < arrayLength(t, table); ++i) {
4609- object vmMethod = arrayBody(t, table, i);
4610- if (((not publicOnly) or (methodFlags(t, vmMethod) & ACC_PUBLIC))
4611- and byteArrayBody(t, methodName(t, vmMethod), 0) != '<')
4612- {
4613- ++ count;
4614- }
4615- }
4616- return count;
4617-}
4618-
4619-unsigned
4620-countFields(Thread* t, object c, bool publicOnly)
4621-{
4622- object table = classFieldTable(t, c);
4623- if (publicOnly) {
4624- unsigned count = 0;
4625- for (unsigned i = 0; i < arrayLength(t, table); ++i) {
4626- object vmField = arrayBody(t, table, i);
4627- if (fieldFlags(t, vmField) & ACC_PUBLIC) {
4628- ++ count;
4629- }
4630- }
4631- return count;
4632- } else {
4633- return objectArrayLength(t, table);
4634- }
4635-}
4636-
4637-unsigned
4638-countConstructors(Thread* t, object c, bool publicOnly)
4639-{
4640- object table = getClassMethodTable(t, c);
4641- unsigned count = 0;
4642- for (unsigned i = 0; i < arrayLength(t, table); ++i) {
4643- object vmMethod = arrayBody(t, table, i);
4644- if (((not publicOnly) or (methodFlags(t, vmMethod) & ACC_PUBLIC))
4645- and strcmp(reinterpret_cast<char*>
4646- (&byteArrayBody(t, methodName(t, vmMethod), 0)),
4647- "<init>") == 0)
4648- {
4649- ++ count;
4650- }
4651- }
4652- return count;
4653-}
4654-
4655-object
4656-resolveClassBySpec(Thread* t, object loader, const char* spec,
4657- unsigned specLength)
4658-{
4659- switch (*spec) {
4660- case 'L': {
4661- THREAD_RUNTIME_ARRAY(t, char, s, specLength - 1);
4662- memcpy(RUNTIME_ARRAY_BODY(s), spec + 1, specLength - 2);
4663- RUNTIME_ARRAY_BODY(s)[specLength - 2] = 0;
4664- return resolveClass(t, loader, s);
4665- }
4666-
4667- case '[': {
4668- THREAD_RUNTIME_ARRAY(t, char, s, specLength + 1);
4669- memcpy(RUNTIME_ARRAY_BODY(s), spec, specLength);
4670- RUNTIME_ARRAY_BODY(s)[specLength] = 0;
4671- return resolveClass(t, loader, s);
4672- }
4673-
4674- default:
4675- return primitiveClass(t, *spec);
4676- }
4677-}
4678-
4679-object
4680-resolveJType(Thread* t, object loader, const char* spec, unsigned specLength)
4681-{
4682- return getJClass(t, resolveClassBySpec(t, loader, spec, specLength));
4683-}
4684-
4685-object
4686-resolveParameterTypes(Thread* t, object loader, object spec,
4687- unsigned* parameterCount, unsigned* returnTypeSpec)
4688-{
4689- PROTECT(t, loader);
4690- PROTECT(t, spec);
4691-
4692- object list = 0;
4693- PROTECT(t, list);
4694-
4695- unsigned offset = 1;
4696- unsigned count = 0;
4697- while (byteArrayBody(t, spec, offset) != ')') {
4698- switch (byteArrayBody(t, spec, offset)) {
4699- case 'L': {
4700- unsigned start = offset;
4701- ++ offset;
4702- while (byteArrayBody(t, spec, offset) != ';') ++ offset;
4703- ++ offset;
4704-
4705- object type = resolveClassBySpec
4706- (t, loader, reinterpret_cast<char*>(&byteArrayBody(t, spec, start)),
4707- offset - start);
4708-
4709- list = makePair(t, type, list);
4710-
4711- ++ count;
4712- } break;
4713-
4714- case '[': {
4715- unsigned start = offset;
4716- while (byteArrayBody(t, spec, offset) == '[') ++ offset;
4717- switch (byteArrayBody(t, spec, offset)) {
4718- case 'L':
4719- ++ offset;
4720- while (byteArrayBody(t, spec, offset) != ';') ++ offset;
4721- ++ offset;
4722- break;
4723-
4724- default:
4725- ++ offset;
4726- break;
4727- }
4728-
4729- object type = resolveClassBySpec
4730- (t, loader, reinterpret_cast<char*>(&byteArrayBody(t, spec, start)),
4731- offset - start);
4732-
4733- list = makePair(t, type, list);
4734- ++ count;
4735- } break;
4736-
4737- default:
4738- list = makePair
4739- (t, primitiveClass(t, byteArrayBody(t, spec, offset)), list);
4740- ++ offset;
4741- ++ count;
4742- break;
4743- }
4744- }
4745-
4746- *parameterCount = count;
4747- *returnTypeSpec = offset + 1;
4748- return list;
4749-}
4750-
4751-object
4752-resolveParameterJTypes(Thread* t, object loader, object spec,
4753- unsigned* parameterCount, unsigned* returnTypeSpec)
4754-{
4755- object list = resolveParameterTypes
4756- (t, loader, spec, parameterCount, returnTypeSpec);
4757-
4758- PROTECT(t, list);
4759-
4760- object array = makeObjectArray
4761- (t, type(t, Machine::JclassType), *parameterCount);
4762- PROTECT(t, array);
4763-
4764- for (int i = *parameterCount - 1; i >= 0; --i) {
4765- object c = getJClass(t, pairFirst(t, list));
4766- set(t, array, ArrayBody + (i * BytesPerWord), c);
4767- list = pairSecond(t, list);
4768- }
4769-
4770- return array;
4771-}
4772-
4773-object
4774-resolveExceptionJTypes(Thread* t, object loader, object addendum)
4775-{
4776- if (addendum == 0 or methodAddendumExceptionTable(t, addendum) == 0) {
4777- return makeObjectArray(t, type(t, Machine::JclassType), 0);
4778- }
4779-
4780- PROTECT(t, loader);
4781- PROTECT(t, addendum);
4782-
4783- object array = makeObjectArray
4784- (t, type(t, Machine::JclassType),
4785- shortArrayLength(t, methodAddendumExceptionTable(t, addendum)));
4786- PROTECT(t, array);
4787-
4788- for (unsigned i = 0; i < shortArrayLength
4789- (t, methodAddendumExceptionTable(t, addendum)); ++i)
4790- {
4791- uint16_t index = shortArrayBody
4792- (t, methodAddendumExceptionTable(t, addendum), i) - 1;
4793-
4794- object o = singletonObject(t, addendumPool(t, addendum), index);
4795-
4796- if (objectClass(t, o) == type(t, Machine::ReferenceType)) {
4797- o = resolveClass(t, loader, referenceName(t, o));
4798-
4799- set(t, addendumPool(t, addendum), SingletonBody + (index * BytesPerWord),
4800- o);
4801- }
4802-
4803- o = getJClass(t, o);
4804-
4805- set(t, array, ArrayBody + (i * BytesPerWord), o);
4806- }
4807-
4808- return array;
4809-}
4810-
4811-void
4812-setProperty(Thread* t, object method, object properties,
4813- const char* name, const void* value, const char* format = "%s")
4814-{
4815- PROTECT(t, method);
4816- PROTECT(t, properties);
4817-
4818- object n = makeString(t, "%s", name);
4819- PROTECT(t, n);
4820-
4821- object v = makeString(t, format, value);
4822-
4823- t->m->processor->invoke(t, method, properties, n, v);
4824-}
4825-
4826-object
4827-interruptLock(Thread* t, object thread)
4828-{
4829- object lock = threadInterruptLock(t, thread);
4830-
4831- loadMemoryBarrier();
4832-
4833- if (lock == 0) {
4834- PROTECT(t, thread);
4835- ACQUIRE(t, t->m->referenceLock);
4836-
4837- if (threadInterruptLock(t, thread) == 0) {
4838- object head = makeMonitorNode(t, 0, 0);
4839- object lock = makeMonitor(t, 0, 0, 0, head, head, 0);
4840-
4841- storeStoreMemoryBarrier();
4842-
4843- set(t, thread, ThreadInterruptLock, lock);
4844- }
4845- }
4846-
4847- return threadInterruptLock(t, thread);
4848-}
4849-
4850-void
4851-clearInterrupted(Thread* t)
4852-{
4853- monitorAcquire(t, local::interruptLock(t, t->javaThread));
4854- threadInterrupted(t, t->javaThread) = false;
4855- monitorRelease(t, local::interruptLock(t, t->javaThread));
4856-}
4857-
4858-bool
4859-pipeAvailable(int fd, int* available)
4860-{
4861-#ifdef PLATFORM_WINDOWS
4862- HANDLE h = reinterpret_cast<HANDLE>(_get_osfhandle(fd));
4863- if (h == INVALID_HANDLE_VALUE) {
4864- return false;
4865- }
4866-
4867- DWORD n;
4868- if (PeekNamedPipe(h, 0,0, 0, &n, 0)) {
4869- *available = n;
4870- } else {
4871- if (GetLastError() != ERROR_BROKEN_PIPE) {
4872- return false;
4873- }
4874- *available = 0;
4875- }
4876-
4877- return true;
4878-#else
4879- return ioctl(fd, FIONREAD, available) >= 0;
4880-#endif
4881-}
4882-
4883-object
4884-fieldForOffsetInClass(Thread* t, object c, unsigned offset)
4885-{
4886- object super = classSuper(t, c);
4887- if (super) {
4888- object field = fieldForOffsetInClass(t, super, offset);
4889- if (field) {
4890- return field;
4891- }
4892- }
4893-
4894- object table = classFieldTable(t, c);
4895- if (table) {
4896- for (unsigned i = 0; i < objectArrayLength(t, table); ++i) {
4897- object field = objectArrayBody(t, table, i);
4898- if ((fieldFlags(t, field) & ACC_STATIC) == 0
4899- and fieldOffset(t, field) == offset)
4900- {
4901- return field;
4902- }
4903- }
4904- }
4905-
4906- return 0;
4907-}
4908-
4909-object
4910-fieldForOffset(Thread* t, object o, unsigned offset)
4911-{
4912- object field = fieldForOffsetInClass(t, objectClass(t, o), offset);
4913- if (field) {
4914- return field;
4915- } else {
4916- abort(t);
4917- }
4918-}
4919-
4920-} // namespace local
4921-
4922-} // namespace
4923-
4924-namespace vm {
4925-
4926-Classpath*
4927-makeClasspath(System* s, Allocator* allocator, const char* javaHome,
4928- const char* embedPrefix)
4929-{
4930- return new (allocator->allocate(sizeof(local::MyClasspath)))
4931- local::MyClasspath(s, allocator, javaHome, embedPrefix);
4932-}
4933-
4934-} // namespace vm
4935-
4936-extern "C" JNIEXPORT int64_t JNICALL
4937-Avian_java_lang_Class_getSuperclass
4938-(Thread* t, object, uintptr_t* arguments)
4939-{
4940- object super = classSuper
4941- (t, jclassVmClass(t, reinterpret_cast<object>(arguments[0])));
4942-
4943- return super ? reinterpret_cast<int64_t>(getJClass(t, super)) : 0;
4944-}
4945-
4946-extern "C" JNIEXPORT void
4947-Avian_sun_misc_Unsafe_registerNatives
4948-(Thread*, object, uintptr_t*)
4949-{
4950- // ignore
4951-}
4952-
4953-extern "C" JNIEXPORT void
4954-Avian_sun_misc_Perf_registerNatives
4955-(Thread*, object, uintptr_t*)
4956-{
4957- // ignore
4958-}
4959-
4960-extern "C" JNIEXPORT int64_t
4961-Avian_sun_misc_Perf_createLong
4962-(Thread* t, object, uintptr_t*)
4963-{
4964- return reinterpret_cast<int64_t>
4965- (t->m->processor->invoke
4966- (t, resolveMethod
4967- (t, root(t, Machine::BootLoader), "java/nio/ByteBuffer", "allocate",
4968- "(I)Ljava/nio/ByteBuffer;"), 0, 8));
4969-}
4970-
4971-extern "C" JNIEXPORT int64_t
4972-Avian_sun_misc_Unsafe_addressSize
4973-(Thread*, object, uintptr_t*)
4974-{
4975- return BytesPerWord;
4976-}
4977-
4978-extern "C" JNIEXPORT int64_t
4979-Avian_sun_misc_Unsafe_defineClass__Ljava_lang_String_2_3BIILjava_lang_ClassLoader_2Ljava_security_ProtectionDomain_2
4980-(Thread* t, object, uintptr_t* arguments)
4981-{
4982- //object name = reinterpret_cast<object>(arguments[1]);
4983- object data = reinterpret_cast<object>(arguments[2]);
4984- int32_t offset = arguments[3];
4985- int32_t length = arguments[4];
4986- object loader = reinterpret_cast<object>(arguments[5]);
4987- //object domain = reinterpret_cast<object>(arguments[6]);
4988-
4989- uint8_t* buffer = static_cast<uint8_t*>(t->m->heap->allocate(length));
4990-
4991- THREAD_RESOURCE2(t, uint8_t*, buffer, int, length,
4992- t->m->heap->free(buffer, length));
4993-
4994- memcpy(buffer, &byteArrayBody(t, data, offset), length);
4995-
4996- return reinterpret_cast<int64_t>
4997- (getJClass(t, defineClass(t, loader, buffer, length)));
4998-}
4999-
5000-extern "C" JNIEXPORT int64_t
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches

to all changes: