Dvm.mk revision 0c2dc522d0e120f346cf0a40c8cf0c93346131c2
1# Copyright (C) 2008 The Android Open Source Project
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#      http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15#
16# Common definitions for host or target builds of libdvm.
17#
18# If you enable or disable optional features here, make sure you do
19# a "clean" build -- not everything depends on Dalvik.h.  (See Android.mk
20# for the exact command.)
21#
22
23
24#
25# Compiler defines.
26#
27LOCAL_CFLAGS += -fstrict-aliasing -Wstrict-aliasing=2 -fno-align-jumps
28LOCAL_CFLAGS += -Wall -Wextra -Wno-unused-parameter
29LOCAL_CFLAGS += -DARCH_VARIANT=\"$(dvm_arch_variant)\"
30
31#
32# Optional features.  These may impact the size or performance of the VM.
33#
34
35# Make a debugging version when building the simulator (if not told
36# otherwise) and when explicitly asked.
37dvm_make_debug_vm := false
38ifneq ($(strip $(DEBUG_DALVIK_VM)),)
39  dvm_make_debug_vm := $(DEBUG_DALVIK_VM)
40endif
41
42ifeq ($(dvm_make_debug_vm),true)
43  #
44  # "Debug" profile:
45  # - debugger enabled
46  # - profiling enabled
47  # - tracked-reference verification enabled
48  # - allocation limits enabled
49  # - GDB helpers enabled
50  # - LOGV
51  # - assert()
52  #
53  LOCAL_CFLAGS += -DWITH_INSTR_CHECKS
54  LOCAL_CFLAGS += -DWITH_EXTRA_OBJECT_VALIDATION
55  LOCAL_CFLAGS += -DWITH_TRACKREF_CHECKS
56  LOCAL_CFLAGS += -DWITH_EXTRA_GC_CHECKS=1
57  #LOCAL_CFLAGS += -DCHECK_MUTEX
58  LOCAL_CFLAGS += -DDVM_SHOW_EXCEPTION=3
59  # add some extra stuff to make it easier to examine with GDB
60  LOCAL_CFLAGS += -DEASY_GDB
61  # overall config may be for a "release" build, so reconfigure these
62  LOCAL_CFLAGS += -UNDEBUG -DDEBUG=1 -DLOG_NDEBUG=1 -DWITH_DALVIK_ASSERT
63else  # !dvm_make_debug_vm
64  #
65  # "Performance" profile:
66  # - all development features disabled
67  # - compiler optimizations enabled (redundant for "release" builds)
68  # - (debugging and profiling still enabled)
69  #
70  #LOCAL_CFLAGS += -DNDEBUG -DLOG_NDEBUG=1
71  # "-O2" is redundant for device (release) but useful for sim (debug)
72  #LOCAL_CFLAGS += -O2 -Winline
73  #LOCAL_CFLAGS += -DWITH_EXTRA_OBJECT_VALIDATION
74  LOCAL_CFLAGS += -DDVM_SHOW_EXCEPTION=1
75  # if you want to try with assertions on the device, add:
76  #LOCAL_CFLAGS += -UNDEBUG -DDEBUG=1 -DLOG_NDEBUG=1 -DWITH_DALVIK_ASSERT
77endif  # !dvm_make_debug_vm
78
79# bug hunting: checksum and verify interpreted stack when making JNI calls
80#LOCAL_CFLAGS += -DWITH_JNI_STACK_CHECK
81
82LOCAL_SRC_FILES := \
83	AllocTracker.cpp \
84	Atomic.cpp.arm \
85	AtomicCache.cpp \
86	BitVector.cpp.arm \
87	CheckJni.cpp \
88	Ddm.cpp \
89	Debugger.cpp \
90	DvmDex.cpp \
91	Exception.cpp \
92	Hash.cpp \
93	IndirectRefTable.cpp.arm \
94	Init.cpp \
95	InitRefs.cpp \
96	InlineNative.cpp.arm \
97	Inlines.cpp \
98	Intern.cpp \
99	Jni.cpp \
100	JarFile.cpp \
101	LinearAlloc.cpp \
102	Misc.cpp \
103	Native.cpp \
104	PointerSet.cpp \
105	Profile.cpp \
106	RawDexFile.cpp \
107	ReferenceTable.cpp \
108	SignalCatcher.cpp \
109	StdioConverter.cpp \
110	Sync.cpp \
111	Thread.cpp \
112	UtfString.cpp \
113	alloc/Alloc.cpp \
114	alloc/CardTable.cpp \
115	alloc/HeapBitmap.cpp.arm \
116	alloc/HeapDebug.cpp \
117	alloc/Heap.cpp.arm \
118	alloc/DdmHeap.cpp \
119	alloc/Verify.cpp \
120	alloc/Visit.cpp \
121	analysis/CodeVerify.cpp \
122	analysis/DexPrepare.cpp \
123	analysis/DexVerify.cpp \
124	analysis/Liveness.cpp \
125	analysis/Optimize.cpp \
126	analysis/RegisterMap.cpp \
127	analysis/VerifySubs.cpp \
128	analysis/VfyBasicBlock.cpp \
129	hprof/Hprof.cpp \
130	hprof/HprofClass.cpp \
131	hprof/HprofHeap.cpp \
132	hprof/HprofOutput.cpp \
133	hprof/HprofString.cpp \
134	interp/Interp.cpp.arm \
135	interp/Stack.cpp \
136	jdwp/ExpandBuf.cpp \
137	jdwp/JdwpAdb.cpp \
138	jdwp/JdwpConstants.cpp \
139	jdwp/JdwpEvent.cpp \
140	jdwp/JdwpHandler.cpp \
141	jdwp/JdwpMain.cpp \
142	jdwp/JdwpSocket.cpp \
143	mterp/Mterp.cpp.arm \
144	mterp/out/InterpC-portable.cpp.arm \
145	native/InternalNative.cpp \
146	native/dalvik_bytecode_OpcodeInfo.cpp \
147	native/dalvik_system_DexFile.cpp \
148	native/dalvik_system_VMDebug.cpp \
149	native/dalvik_system_VMRuntime.cpp \
150	native/dalvik_system_VMStack.cpp \
151	native/dalvik_system_Zygote.cpp \
152	native/java_lang_Class.cpp \
153	native/java_lang_Double.cpp \
154	native/java_lang_Float.cpp \
155	native/java_lang_Math.cpp \
156	native/java_lang_Object.cpp \
157	native/java_lang_Runtime.cpp \
158	native/java_lang_String.cpp \
159	native/java_lang_System.cpp \
160	native/java_lang_Throwable.cpp \
161	native/java_lang_VMClassLoader.cpp \
162	native/java_lang_VMThread.cpp \
163	native/java_lang_reflect_AccessibleObject.cpp \
164	native/java_lang_reflect_Array.cpp \
165	native/java_lang_reflect_Constructor.cpp \
166	native/java_lang_reflect_Field.cpp \
167	native/java_lang_reflect_Method.cpp \
168	native/java_lang_reflect_Proxy.cpp \
169	native/java_util_concurrent_atomic_AtomicLong.cpp \
170	native/org_apache_harmony_dalvik_NativeTestTarget.cpp \
171	native/org_apache_harmony_dalvik_ddmc_DdmServer.cpp \
172	native/org_apache_harmony_dalvik_ddmc_DdmVmInternal.cpp \
173	native/sun_misc_Unsafe.cpp \
174	oo/AccessCheck.cpp \
175	oo/Array.cpp \
176	oo/Class.cpp \
177	oo/Object.cpp \
178	oo/Resolve.cpp \
179	oo/TypeCheck.cpp \
180	reflect/Annotation.cpp \
181	reflect/Proxy.cpp \
182	reflect/Reflect.cpp \
183	test/AtomicTest.cpp.arm \
184	test/TestHash.cpp \
185	test/TestIndirectRefTable.cpp
186
187# TODO: this is the wrong test, but what's the right one?
188ifneq ($(filter arm mips,$(dvm_arch)),)
189  LOCAL_SRC_FILES += os/android.cpp
190else
191  LOCAL_SRC_FILES += os/linux.cpp
192endif
193
194WITH_COPYING_GC := $(strip $(WITH_COPYING_GC))
195
196ifeq ($(WITH_COPYING_GC),true)
197  LOCAL_CFLAGS += -DWITH_COPYING_GC
198  LOCAL_SRC_FILES += \
199	alloc/Copying.cpp.arm
200else
201  LOCAL_SRC_FILES += \
202	alloc/HeapSource.cpp \
203	alloc/MarkSweep.cpp.arm
204endif
205
206WITH_JIT := $(strip $(WITH_JIT))
207
208ifeq ($(WITH_JIT),true)
209  LOCAL_CFLAGS += -DWITH_JIT
210  LOCAL_SRC_FILES += \
211	compiler/Compiler.cpp \
212	compiler/Frontend.cpp \
213	compiler/Utility.cpp \
214	compiler/InlineTransformation.cpp \
215	compiler/IntermediateRep.cpp \
216	compiler/Dataflow.cpp \
217	compiler/SSATransformation.cpp \
218	compiler/Loop.cpp \
219	compiler/Ralloc.cpp \
220	interp/Jit.cpp
221endif
222
223LOCAL_C_INCLUDES += \
224	$(JNI_H_INCLUDE) \
225	dalvik \
226	dalvik/vm \
227	external/zlib \
228	libcore/include \
229
230MTERP_ARCH_KNOWN := false
231
232ifeq ($(dvm_arch),arm)
233  #dvm_arch_variant := armv7-a
234  #LOCAL_CFLAGS += -march=armv7-a -mfloat-abi=softfp -mfpu=vfp
235  LOCAL_CFLAGS += -Werror
236  MTERP_ARCH_KNOWN := true
237  # Select architecture-specific sources (armv5te, armv7-a, etc.)
238  LOCAL_SRC_FILES += \
239		arch/arm/CallOldABI.S \
240		arch/arm/CallEABI.S \
241		arch/arm/HintsEABI.cpp \
242		mterp/out/InterpC-$(dvm_arch_variant).cpp.arm \
243		mterp/out/InterpAsm-$(dvm_arch_variant).S
244
245  ifeq ($(WITH_JIT),true)
246    LOCAL_SRC_FILES += \
247		compiler/codegen/RallocUtil.cpp \
248		compiler/codegen/arm/$(dvm_arch_variant)/Codegen.cpp \
249		compiler/codegen/arm/$(dvm_arch_variant)/CallingConvention.S \
250		compiler/codegen/arm/Assemble.cpp \
251		compiler/codegen/arm/ArchUtility.cpp \
252		compiler/codegen/arm/LocalOptimizations.cpp \
253		compiler/codegen/arm/GlobalOptimizations.cpp \
254		compiler/codegen/arm/ArmRallocUtil.cpp \
255		compiler/template/out/CompilerTemplateAsm-$(dvm_arch_variant).S
256  endif
257endif
258
259ifeq ($(dvm_arch),mips)
260  MTERP_ARCH_KNOWN := true
261  LOCAL_C_INCLUDES += external/libffi/$(TARGET_OS)-$(TARGET_ARCH)
262  LOCAL_SHARED_LIBRARIES += libffi
263  LOCAL_SRC_FILES += \
264		arch/mips/CallO32.S \
265		arch/mips/HintsO32.cpp \
266		arch/generic/Call.cpp \
267		mterp/out/InterpC-mips.cpp \
268		mterp/out/InterpAsm-mips.S
269
270  ifeq ($(WITH_JIT),true)
271    dvm_arch_variant := mips
272    LOCAL_SRC_FILES += \
273		compiler/codegen/mips/RallocUtil.cpp \
274		compiler/codegen/mips/$(dvm_arch_variant)/Codegen.cpp \
275		compiler/codegen/mips/$(dvm_arch_variant)/CallingConvention.S \
276		compiler/codegen/mips/Assemble.cpp \
277		compiler/codegen/mips/ArchUtility.cpp \
278		compiler/codegen/mips/LocalOptimizations.cpp \
279		compiler/codegen/mips/GlobalOptimizations.cpp \
280		compiler/template/out/CompilerTemplateAsm-$(dvm_arch_variant).S
281  endif
282endif
283
284ifeq ($(dvm_arch),x86)
285  ifeq ($(dvm_os),linux)
286    MTERP_ARCH_KNOWN := true
287    LOCAL_CFLAGS += -DDVM_JMP_TABLE_MTERP=1 \
288                    -DMTERP_STUB
289    LOCAL_SRC_FILES += \
290		arch/$(dvm_arch_variant)/Call386ABI.S \
291		arch/$(dvm_arch_variant)/Hints386ABI.cpp \
292		mterp/out/InterpC-$(dvm_arch_variant).cpp \
293		mterp/out/InterpAsm-$(dvm_arch_variant).S
294    ifeq ($(WITH_JIT),true)
295      LOCAL_CFLAGS += -DARCH_IA32
296      LOCAL_SRC_FILES += \
297                compiler/codegen/x86/LowerAlu.cpp \
298                compiler/codegen/x86/LowerConst.cpp \
299                compiler/codegen/x86/LowerMove.cpp \
300                compiler/codegen/x86/Lower.cpp \
301                compiler/codegen/x86/LowerHelper.cpp \
302                compiler/codegen/x86/LowerJump.cpp \
303                compiler/codegen/x86/LowerObject.cpp \
304                compiler/codegen/x86/AnalysisO1.cpp \
305                compiler/codegen/x86/BytecodeVisitor.cpp \
306                compiler/codegen/x86/NcgAot.cpp \
307                compiler/codegen/x86/CodegenInterface.cpp \
308                compiler/codegen/x86/LowerInvoke.cpp \
309                compiler/codegen/x86/LowerReturn.cpp \
310                compiler/codegen/x86/NcgHelper.cpp \
311                compiler/codegen/x86/LowerGetPut.cpp
312
313      # need apache harmony x86 encoder/decoder
314      LOCAL_C_INCLUDES += \
315                dalvik/vm/compiler/codegen/x86/libenc
316      LOCAL_SRC_FILES += \
317                compiler/codegen/x86/libenc/enc_base.cpp \
318                compiler/codegen/x86/libenc/dec_base.cpp \
319                compiler/codegen/x86/libenc/enc_wrapper.cpp \
320                compiler/codegen/x86/libenc/enc_tabl.cpp
321
322    endif
323  endif
324endif
325
326ifeq ($(MTERP_ARCH_KNOWN),false)
327  # unknown architecture, try to use FFI
328  LOCAL_C_INCLUDES += external/libffi/$(dvm_os)-$(dvm_arch)
329
330  ifeq ($(dvm_os)-$(dvm_arch),darwin-x86)
331      # OSX includes libffi, so just make the linker aware of it directly.
332      LOCAL_LDLIBS += -lffi
333  else
334      LOCAL_SHARED_LIBRARIES += libffi
335  endif
336
337  LOCAL_SRC_FILES += \
338		arch/generic/Call.cpp \
339		arch/generic/Hints.cpp \
340		mterp/out/InterpC-allstubs.cpp
341
342  # The following symbols are usually defined in the asm file, but
343  # since we don't have an asm file in this case, we instead just
344  # peg them at 0 here, and we add an #ifdef'able define for good
345  # measure, too.
346  LOCAL_CFLAGS += -DdvmAsmInstructionStart=0 -DdvmAsmInstructionEnd=0 \
347	-DdvmAsmSisterStart=0 -DdvmAsmSisterEnd=0 -DDVM_NO_ASM_INTERP=1
348endif
349