• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/DlMalloc.cpp \
203	alloc/HeapSource.cpp \
204	alloc/MarkSweep.cpp.arm
205endif
206
207WITH_JIT := $(strip $(WITH_JIT))
208
209ifeq ($(WITH_JIT),true)
210  LOCAL_CFLAGS += -DWITH_JIT
211  LOCAL_SRC_FILES += \
212	compiler/Compiler.cpp \
213	compiler/Frontend.cpp \
214	compiler/Utility.cpp \
215	compiler/InlineTransformation.cpp \
216	compiler/IntermediateRep.cpp \
217	compiler/Dataflow.cpp \
218	compiler/SSATransformation.cpp \
219	compiler/Loop.cpp \
220	compiler/Ralloc.cpp \
221	interp/Jit.cpp
222endif
223
224LOCAL_C_INCLUDES += \
225	$(JNI_H_INCLUDE) \
226	dalvik \
227	dalvik/vm \
228	external/zlib \
229	libcore/include \
230
231MTERP_ARCH_KNOWN := false
232
233ifeq ($(dvm_arch),arm)
234  #dvm_arch_variant := armv7-a
235  #LOCAL_CFLAGS += -march=armv7-a -mfloat-abi=softfp -mfpu=vfp
236  LOCAL_CFLAGS += -Werror
237  MTERP_ARCH_KNOWN := true
238  # Select architecture-specific sources (armv5te, armv7-a, etc.)
239  LOCAL_SRC_FILES += \
240		arch/arm/CallOldABI.S \
241		arch/arm/CallEABI.S \
242		arch/arm/HintsEABI.cpp \
243		mterp/out/InterpC-$(dvm_arch_variant).cpp.arm \
244		mterp/out/InterpAsm-$(dvm_arch_variant).S
245
246  ifeq ($(WITH_JIT),true)
247    LOCAL_SRC_FILES += \
248		compiler/codegen/RallocUtil.cpp \
249		compiler/codegen/arm/$(dvm_arch_variant)/Codegen.cpp \
250		compiler/codegen/arm/$(dvm_arch_variant)/CallingConvention.S \
251		compiler/codegen/arm/Assemble.cpp \
252		compiler/codegen/arm/ArchUtility.cpp \
253		compiler/codegen/arm/LocalOptimizations.cpp \
254		compiler/codegen/arm/GlobalOptimizations.cpp \
255		compiler/codegen/arm/ArmRallocUtil.cpp \
256		compiler/template/out/CompilerTemplateAsm-$(dvm_arch_variant).S
257  endif
258endif
259
260ifeq ($(dvm_arch),mips)
261  MTERP_ARCH_KNOWN := true
262  LOCAL_C_INCLUDES += external/libffi/$(TARGET_OS)-$(TARGET_ARCH)
263  LOCAL_SHARED_LIBRARIES += libffi
264  LOCAL_SRC_FILES += \
265		arch/mips/CallO32.S \
266		arch/mips/HintsO32.cpp \
267		arch/generic/Call.cpp \
268		mterp/out/InterpC-mips.cpp \
269		mterp/out/InterpAsm-mips.S
270
271  ifeq ($(WITH_JIT),true)
272    dvm_arch_variant := mips
273    LOCAL_SRC_FILES += \
274		compiler/codegen/mips/RallocUtil.cpp \
275		compiler/codegen/mips/$(dvm_arch_variant)/Codegen.cpp \
276		compiler/codegen/mips/$(dvm_arch_variant)/CallingConvention.S \
277		compiler/codegen/mips/Assemble.cpp \
278		compiler/codegen/mips/ArchUtility.cpp \
279		compiler/codegen/mips/LocalOptimizations.cpp \
280		compiler/codegen/mips/GlobalOptimizations.cpp \
281		compiler/template/out/CompilerTemplateAsm-$(dvm_arch_variant).S
282  endif
283endif
284
285ifeq ($(dvm_arch),x86)
286  ifeq ($(dvm_os),linux)
287    MTERP_ARCH_KNOWN := true
288    LOCAL_CFLAGS += -DDVM_JMP_TABLE_MTERP=1 \
289                    -DMTERP_STUB
290    LOCAL_SRC_FILES += \
291		arch/$(dvm_arch_variant)/Call386ABI.S \
292		arch/$(dvm_arch_variant)/Hints386ABI.cpp \
293		mterp/out/InterpC-$(dvm_arch_variant).cpp \
294		mterp/out/InterpAsm-$(dvm_arch_variant).S
295    ifeq ($(WITH_JIT),true)
296      LOCAL_CFLAGS += -DARCH_IA32
297      LOCAL_SRC_FILES += \
298                compiler/codegen/x86/LowerAlu.cpp \
299                compiler/codegen/x86/LowerConst.cpp \
300                compiler/codegen/x86/LowerMove.cpp \
301                compiler/codegen/x86/Lower.cpp \
302                compiler/codegen/x86/LowerHelper.cpp \
303                compiler/codegen/x86/LowerJump.cpp \
304                compiler/codegen/x86/LowerObject.cpp \
305                compiler/codegen/x86/AnalysisO1.cpp \
306                compiler/codegen/x86/BytecodeVisitor.cpp \
307                compiler/codegen/x86/NcgAot.cpp \
308                compiler/codegen/x86/CodegenInterface.cpp \
309                compiler/codegen/x86/LowerInvoke.cpp \
310                compiler/codegen/x86/LowerReturn.cpp \
311                compiler/codegen/x86/NcgHelper.cpp \
312                compiler/codegen/x86/LowerGetPut.cpp
313
314      # need apache harmony x86 encoder/decoder
315      LOCAL_C_INCLUDES += \
316                dalvik/vm/compiler/codegen/x86/libenc
317      LOCAL_SRC_FILES += \
318                compiler/codegen/x86/libenc/enc_base.cpp \
319                compiler/codegen/x86/libenc/dec_base.cpp \
320                compiler/codegen/x86/libenc/enc_wrapper.cpp \
321                compiler/codegen/x86/libenc/enc_tabl.cpp
322
323    endif
324  endif
325endif
326
327ifeq ($(MTERP_ARCH_KNOWN),false)
328  # unknown architecture, try to use FFI
329  LOCAL_C_INCLUDES += external/libffi/$(dvm_os)-$(dvm_arch)
330
331  ifeq ($(dvm_os)-$(dvm_arch),darwin-x86)
332      # OSX includes libffi, so just make the linker aware of it directly.
333      LOCAL_LDLIBS += -lffi
334  else
335      LOCAL_SHARED_LIBRARIES += libffi
336  endif
337
338  LOCAL_SRC_FILES += \
339		arch/generic/Call.cpp \
340		arch/generic/Hints.cpp \
341		mterp/out/InterpC-allstubs.cpp
342
343  # The following symbols are usually defined in the asm file, but
344  # since we don't have an asm file in this case, we instead just
345  # peg them at 0 here, and we add an #ifdef'able define for good
346  # measure, too.
347  LOCAL_CFLAGS += -DdvmAsmInstructionStart=0 -DdvmAsmInstructionEnd=0 \
348	-DdvmAsmSisterStart=0 -DdvmAsmSisterEnd=0 -DDVM_NO_ASM_INTERP=1
349endif
350