OSDN Git Service

Restructure the codegen to make architectural depedency explicit.
[android-x86/dalvik.git] / vm / Dvm.mk
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,
19 # rebuild the VM with "make clean-libdvm && make -j4 libdvm".
20 #
21
22
23 #
24 # Compiler defines.
25 #
26 LOCAL_CFLAGS += -fstrict-aliasing -Wstrict-aliasing=2 -fno-align-jumps
27 #LOCAL_CFLAGS += -DUSE_INDIRECT_REF
28
29 #
30 # Optional features.  These may impact the size or performance of the VM.
31 #
32 LOCAL_CFLAGS += -DWITH_PROFILER -DWITH_DEBUGGER
33
34 # 0=full cache, 1/2=reduced, 3=no cache
35 LOCAL_CFLAGS += -DDVM_RESOLVER_CACHE=0
36
37 ifeq ($(WITH_DEADLOCK_PREDICTION),true)
38   LOCAL_CFLAGS += -DWITH_DEADLOCK_PREDICTION
39   WITH_MONITOR_TRACKING := true
40 endif
41 ifeq ($(WITH_MONITOR_TRACKING),true)
42   LOCAL_CFLAGS += -DWITH_MONITOR_TRACKING
43 endif
44
45 # Make a debugging version when building the simulator (if not told
46 # otherwise) and when explicitly asked.
47 dvm_make_debug_vm := false
48 ifeq ($(strip $(DEBUG_DALVIK_VM)),)
49   ifeq ($(dvm_simulator),true)
50     dvm_make_debug_vm := true
51   endif
52 else
53   dvm_make_debug_vm := $(DEBUG_DALVIK_VM)
54 endif
55
56 ifeq ($(dvm_make_debug_vm),true)
57   #
58   # "Debug" profile:
59   # - debugger enabled
60   # - profiling enabled
61   # - tracked-reference verification enabled
62   # - allocation limits enabled
63   # - GDB helpers enabled
64   # - LOGV
65   # - assert()
66   #
67   LOCAL_CFLAGS += -DWITH_INSTR_CHECKS
68   LOCAL_CFLAGS += -DWITH_EXTRA_OBJECT_VALIDATION
69   LOCAL_CFLAGS += -DWITH_TRACKREF_CHECKS
70   LOCAL_CFLAGS += -DWITH_ALLOC_LIMITS
71   LOCAL_CFLAGS += -DWITH_EXTRA_GC_CHECKS=1
72   #LOCAL_CFLAGS += -DCHECK_MUTEX
73   #LOCAL_CFLAGS += -DPROFILE_FIELD_ACCESS
74   LOCAL_CFLAGS += -DDVM_SHOW_EXCEPTION=3
75   # add some extra stuff to make it easier to examine with GDB
76   LOCAL_CFLAGS += -DEASY_GDB
77   # overall config may be for a "release" build, so reconfigure these
78   LOCAL_CFLAGS += -UNDEBUG -DDEBUG=1 -DLOG_NDEBUG=1 -DWITH_DALVIK_ASSERT
79 else  # !dvm_make_debug_vm
80   #
81   # "Performance" profile:
82   # - all development features disabled
83   # - compiler optimizations enabled (redundant for "release" builds)
84   # - (debugging and profiling still enabled)
85   #
86   #LOCAL_CFLAGS += -DNDEBUG -DLOG_NDEBUG=1
87   # "-O2" is redundant for device (release) but useful for sim (debug)
88   #LOCAL_CFLAGS += -O2 -Winline
89   #LOCAL_CFLAGS += -DWITH_EXTRA_OBJECT_VALIDATION
90   LOCAL_CFLAGS += -DDVM_SHOW_EXCEPTION=1
91   # if you want to try with assertions on the device, add:
92   #LOCAL_CFLAGS += -UNDEBUG -DDEBUG=1 -DLOG_NDEBUG=1 -DWITH_DALVIK_ASSERT
93 endif  # !dvm_make_debug_vm
94
95 # bug hunting: checksum and verify interpreted stack when making JNI calls
96 #LOCAL_CFLAGS += -DWITH_JNI_STACK_CHECK
97
98 LOCAL_SRC_FILES := \
99         AllocTracker.c \
100         AtomicCache.c \
101         CheckJni.c \
102         Ddm.c \
103         Debugger.c \
104         DvmDex.c \
105         Exception.c \
106         Hash.c \
107         IndirectRefTable.c.arm \
108         Init.c \
109         InlineNative.c.arm \
110         Inlines.c \
111         Intern.c \
112         Jni.c \
113         JarFile.c \
114         LinearAlloc.c \
115         Misc.c.arm \
116         Native.c \
117         PointerSet.c \
118         Profile.c \
119         Properties.c \
120         RawDexFile.c \
121         ReferenceTable.c \
122         SignalCatcher.c \
123         StdioConverter.c \
124         Sync.c \
125         Thread.c \
126         UtfString.c \
127         alloc/clz.c.arm \
128         alloc/Alloc.c \
129         alloc/HeapBitmap.c.arm \
130         alloc/HeapDebug.c \
131         alloc/HeapSource.c \
132         alloc/HeapTable.c \
133         alloc/HeapWorker.c \
134         alloc/Heap.c.arm \
135         alloc/MarkSweep.c.arm \
136         alloc/DdmHeap.c \
137         analysis/CodeVerify.c \
138         analysis/DexOptimize.c \
139         analysis/DexVerify.c \
140         analysis/ReduceConstants.c \
141         analysis/RegisterMap.c \
142         analysis/VerifySubs.c \
143         interp/Interp.c.arm \
144         interp/Stack.c \
145         jdwp/ExpandBuf.c \
146         jdwp/JdwpAdb.c \
147         jdwp/JdwpConstants.c \
148         jdwp/JdwpEvent.c \
149         jdwp/JdwpHandler.c \
150         jdwp/JdwpMain.c \
151         jdwp/JdwpSocket.c \
152         mterp/Mterp.c.arm \
153         mterp/out/InterpC-portstd.c.arm \
154         mterp/out/InterpC-portdbg.c.arm \
155         native/InternalNative.c \
156         native/dalvik_system_DexFile.c \
157         native/dalvik_system_SamplingProfiler.c \
158         native/dalvik_system_VMDebug.c \
159         native/dalvik_system_VMRuntime.c \
160         native/dalvik_system_VMStack.c \
161         native/dalvik_system_Zygote.c \
162         native/java_lang_Class.c \
163         native/java_lang_Object.c \
164         native/java_lang_Runtime.c \
165         native/java_lang_String.c \
166         native/java_lang_System.c \
167         native/java_lang_SystemProperties.c \
168         native/java_lang_Throwable.c \
169         native/java_lang_VMClassLoader.c \
170         native/java_lang_VMThread.c \
171         native/java_lang_reflect_AccessibleObject.c \
172         native/java_lang_reflect_Array.c \
173         native/java_lang_reflect_Constructor.c \
174         native/java_lang_reflect_Field.c \
175         native/java_lang_reflect_Method.c \
176         native/java_lang_reflect_Proxy.c \
177         native/java_security_AccessController.c \
178         native/java_util_concurrent_atomic_AtomicLong.c \
179         native/org_apache_harmony_dalvik_NativeTestTarget.c \
180         native/org_apache_harmony_dalvik_ddmc_DdmServer.c \
181         native/org_apache_harmony_dalvik_ddmc_DdmVmInternal.c \
182         native/sun_misc_Unsafe.c \
183         native/SystemThread.c \
184         oo/AccessCheck.c \
185         oo/Array.c \
186         oo/Class.c \
187         oo/Object.c \
188         oo/Resolve.c \
189         oo/TypeCheck.c \
190         reflect/Annotation.c \
191         reflect/Proxy.c \
192         reflect/Reflect.c \
193         test/AtomicSpeed.c \
194         test/TestHash.c \
195         test/TestIndirectRefTable.c
196
197 WITH_JIT := $(strip $(WITH_JIT))
198
199 ifeq ($(WITH_JIT),true)
200   LOCAL_CFLAGS += -DWITH_JIT
201   LOCAL_SRC_FILES += \
202         ../dexdump/OpCodeNames.c \
203         compiler/Compiler.c \
204         compiler/Frontend.c \
205         compiler/Utility.c \
206         compiler/IntermediateRep.c \
207         compiler/Dataflow.c \
208         compiler/Loop.c \
209         compiler/Ralloc.c \
210         interp/Jit.c
211 endif
212
213 WITH_HPROF := $(strip $(WITH_HPROF))
214 ifeq ($(WITH_HPROF),)
215   WITH_HPROF := true
216 endif
217 ifeq ($(WITH_HPROF),true)
218   LOCAL_SRC_FILES += \
219         hprof/Hprof.c \
220         hprof/HprofClass.c \
221         hprof/HprofHeap.c \
222         hprof/HprofOutput.c \
223         hprof/HprofString.c
224   LOCAL_CFLAGS += -DWITH_HPROF=1
225
226   ifeq ($(strip $(WITH_HPROF_UNREACHABLE)),true)
227     LOCAL_CFLAGS += -DWITH_HPROF_UNREACHABLE=1
228   endif
229
230   ifeq ($(strip $(WITH_HPROF_STACK)),true)
231     LOCAL_SRC_FILES += \
232         hprof/HprofStack.c \
233         hprof/HprofStackFrame.c
234     LOCAL_CFLAGS += -DWITH_HPROF_STACK=1
235   endif # WITH_HPROF_STACK
236 endif   # WITH_HPROF
237
238 ifeq ($(strip $(DVM_TRACK_HEAP_MARKING)),true)
239   LOCAL_CFLAGS += -DDVM_TRACK_HEAP_MARKING=1
240 endif
241
242 LOCAL_C_INCLUDES += \
243         $(JNI_H_INCLUDE) \
244         dalvik \
245         dalvik/vm \
246         external/zlib \
247         $(KERNEL_HEADERS)
248
249
250 ifeq ($(dvm_simulator),true)
251   LOCAL_LDLIBS += -lpthread -ldl
252   ifeq ($(HOST_OS),linux)
253     # need this for clock_gettime() in profiling
254     LOCAL_LDLIBS += -lrt
255   endif
256 else
257   ifeq ($(dvm_os),linux)
258     LOCAL_SHARED_LIBRARIES += libdl
259   endif
260 endif
261
262 MTERP_ARCH_KNOWN := false
263
264 ifeq ($(dvm_arch),arm)
265   #dvm_arch_variant := armv7-a
266   #LOCAL_CFLAGS += -march=armv7-a -mfloat-abi=softfp -mfpu=vfp
267   MTERP_ARCH_KNOWN := true
268   # Select architecture-specific sources (armv4t, armv5te etc.)
269   LOCAL_SRC_FILES += \
270                 arch/arm/CallOldABI.S \
271                 arch/arm/CallEABI.S \
272                 arch/arm/HintsEABI.c \
273                 mterp/out/InterpC-$(dvm_arch_variant).c.arm \
274                 mterp/out/InterpAsm-$(dvm_arch_variant).S
275
276   ifeq ($(WITH_JIT),true)
277     LOCAL_SRC_FILES += \
278                 compiler/codegen/arm/RallocUtil.c \
279                 compiler/codegen/arm/$(dvm_arch_variant)/Codegen.c \
280                 compiler/codegen/arm/Assemble.c \
281                 compiler/codegen/arm/ArchUtility.c \
282                 compiler/codegen/arm/LocalOptimizations.c \
283                 compiler/codegen/arm/GlobalOptimizations.c \
284                 compiler/template/out/CompilerTemplateAsm-$(dvm_arch_variant).S
285   endif
286 endif
287
288 ifeq ($(dvm_arch),x86)
289   ifeq ($(dvm_os),linux)
290     MTERP_ARCH_KNOWN := true
291     LOCAL_SRC_FILES += \
292                 arch/x86/Call386ABI.S \
293                 arch/x86/Hints386ABI.c \
294                 mterp/out/InterpC-x86.c \
295                 mterp/out/InterpAsm-x86.S
296   endif
297 endif
298
299 ifeq ($(dvm_arch),sh)
300   MTERP_ARCH_KNOWN := true
301   LOCAL_SRC_FILES += \
302                 arch/sh/CallSH4ABI.S \
303                 arch/generic/Hints.c \
304                 mterp/out/InterpC-allstubs.c \
305                 mterp/out/InterpAsm-allstubs.S
306 endif
307
308 ifeq ($(MTERP_ARCH_KNOWN),false)
309   # unknown architecture, try to use FFI
310   LOCAL_C_INCLUDES += external/libffi/$(dvm_os)-$(dvm_arch)
311
312   ifeq ($(dvm_os)-$(dvm_arch),darwin-x86)
313       # OSX includes libffi, so just make the linker aware of it directly.
314       LOCAL_LDLIBS += -lffi
315   else
316       LOCAL_SHARED_LIBRARIES += libffi
317   endif
318
319   LOCAL_SRC_FILES += \
320                 arch/generic/Call.c \
321                 arch/generic/Hints.c \
322                 mterp/out/InterpC-allstubs.c
323
324   # The following symbols are usually defined in the asm file, but
325   # since we don't have an asm file in this case, we instead just
326   # peg them at 0 here, and we add an #ifdef'able define for good
327   # measure, too.
328   LOCAL_CFLAGS += -DdvmAsmInstructionStart=0 -DdvmAsmInstructionEnd=0 \
329         -DdvmAsmSisterStart=0 -DdvmAsmSisterEnd=0 -DDVM_NO_ASM_INTERP=1
330 endif