summaryrefslogtreecommitdiffstats
path: root/vm/Dvm.mk
blob: 7d8355cf254fc4230328b8e3e635e82541be1807 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
# Copyright (C) 2008 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

#
# Common definitions for host or target builds of libdvm.
#
# If you enable or disable optional features here, make sure you do
# a "clean" build -- not everything depends on Dalvik.h.  (See Android.mk
# for the exact command.)
#


#
# Compiler defines.
#

LOCAL_CFLAGS += -fstrict-aliasing -Wstrict-aliasing=2
LOCAL_CFLAGS += -Wall -Wextra -Wno-unused-parameter
LOCAL_CFLAGS += -DARCH_VARIANT=\"$(dvm_arch_variant)\"

ifneq ($(strip $(LOCAL_CLANG)),true)
LOCAL_CFLAGS += -fno-align-jumps
endif

#
# Optional features.  These may impact the size or performance of the VM.
#

# Make a debugging version when building the simulator (if not told
# otherwise) and when explicitly asked.
dvm_make_debug_vm := false
ifneq ($(strip $(DEBUG_DALVIK_VM)),)
  dvm_make_debug_vm := $(DEBUG_DALVIK_VM)
endif

ifeq ($(dvm_make_debug_vm),true)
  #
  # "Debug" profile:
  # - debugger enabled
  # - profiling enabled
  # - tracked-reference verification enabled
  # - allocation limits enabled
  # - GDB helpers enabled
  # - LOGV
  # - assert()
  #
  LOCAL_CFLAGS += -DWITH_INSTR_CHECKS
  LOCAL_CFLAGS += -DWITH_EXTRA_OBJECT_VALIDATION
  LOCAL_CFLAGS += -DWITH_TRACKREF_CHECKS
  LOCAL_CFLAGS += -DWITH_EXTRA_GC_CHECKS=1
  #LOCAL_CFLAGS += -DCHECK_MUTEX
  LOCAL_CFLAGS += -DDVM_SHOW_EXCEPTION=3
  # add some extra stuff to make it easier to examine with GDB
  LOCAL_CFLAGS += -DEASY_GDB
  # overall config may be for a "release" build, so reconfigure these
  LOCAL_CFLAGS += -UNDEBUG -DDEBUG=1 -DLOG_NDEBUG=1 -DWITH_DALVIK_ASSERT
else  # !dvm_make_debug_vm
  #
  # "Performance" profile:
  # - all development features disabled
  # - compiler optimizations enabled (redundant for "release" builds)
  # - (debugging and profiling still enabled)
  #
  #LOCAL_CFLAGS += -DNDEBUG -DLOG_NDEBUG=1
  # "-O2" is redundant for device (release) but useful for sim (debug)
  #LOCAL_CFLAGS += -O2 -Winline
  #LOCAL_CFLAGS += -DWITH_EXTRA_OBJECT_VALIDATION
  LOCAL_CFLAGS += -DDVM_SHOW_EXCEPTION=1
  # if you want to try with assertions on the device, add:
  #LOCAL_CFLAGS += -UNDEBUG -DDEBUG=1 -DLOG_NDEBUG=1 -DWITH_DALVIK_ASSERT
endif  # !dvm_make_debug_vm

# bug hunting: checksum and verify interpreted stack when making JNI calls
#LOCAL_CFLAGS += -DWITH_JNI_STACK_CHECK

LOCAL_SRC_FILES := \
	AllocTracker.cpp \
	Atomic.cpp.arm \
	AtomicCache.cpp \
	BitVector.cpp.arm \
	CheckJni.cpp \
	Ddm.cpp \
	Debugger.cpp \
	DvmDex.cpp \
	Exception.cpp \
	Hash.cpp \
	IndirectRefTable.cpp.arm \
	Init.cpp \
	InitRefs.cpp \
	InlineNative.cpp.arm \
	Inlines.cpp \
	Intern.cpp \
	Jni.cpp \
	JarFile.cpp \
	LinearAlloc.cpp \
	Misc.cpp \
	Native.cpp \
	PointerSet.cpp \
	Profile.cpp \
	RawDexFile.cpp \
	ReferenceTable.cpp \
	SignalCatcher.cpp \
	StdioConverter.cpp \
	Sync.cpp \
	Thread.cpp \
	UtfString.cpp \
	alloc/Alloc.cpp \
	alloc/CardTable.cpp \
	alloc/HeapBitmap.cpp.arm \
	alloc/HeapDebug.cpp \
	alloc/Heap.cpp.arm \
	alloc/DdmHeap.cpp \
	alloc/Verify.cpp \
	alloc/Visit.cpp \
	analysis/CodeVerify.cpp \
	analysis/DexPrepare.cpp \
	analysis/DexVerify.cpp \
	analysis/Liveness.cpp \
	analysis/Optimize.cpp \
	analysis/RegisterMap.cpp \
	analysis/VerifySubs.cpp \
	analysis/VfyBasicBlock.cpp \
	hprof/Hprof.cpp \
	hprof/HprofClass.cpp \
	hprof/HprofHeap.cpp \
	hprof/HprofOutput.cpp \
	hprof/HprofString.cpp \
	interp/Interp.cpp.arm \
	interp/Stack.cpp \
	jdwp/ExpandBuf.cpp \
	jdwp/JdwpAdb.cpp \
	jdwp/JdwpConstants.cpp \
	jdwp/JdwpEvent.cpp \
	jdwp/JdwpHandler.cpp \
	jdwp/JdwpMain.cpp \
	jdwp/JdwpSocket.cpp \
	mterp/Mterp.cpp.arm \
	mterp/out/InterpC-portable.cpp.arm \
	native/InternalNative.cpp \
	native/dalvik_bytecode_OpcodeInfo.cpp \
	native/dalvik_system_DexFile.cpp \
	native/dalvik_system_VMDebug.cpp \
	native/dalvik_system_VMRuntime.cpp \
	native/dalvik_system_VMStack.cpp \
	native/dalvik_system_Zygote.cpp \
	native/java_lang_Class.cpp \
	native/java_lang_Double.cpp \
	native/java_lang_Float.cpp \
	native/java_lang_Math.cpp \
	native/java_lang_Object.cpp \
	native/java_lang_Runtime.cpp \
	native/java_lang_String.cpp \
	native/java_lang_System.cpp \
	native/java_lang_Throwable.cpp \
	native/java_lang_VMClassLoader.cpp \
	native/java_lang_VMThread.cpp \
	native/java_lang_reflect_AccessibleObject.cpp \
	native/java_lang_reflect_Array.cpp \
	native/java_lang_reflect_Constructor.cpp \
	native/java_lang_reflect_Field.cpp \
	native/java_lang_reflect_Method.cpp \
	native/java_lang_reflect_Proxy.cpp \
	native/java_util_concurrent_atomic_AtomicLong.cpp \
	native/org_apache_harmony_dalvik_NativeTestTarget.cpp \
	native/org_apache_harmony_dalvik_ddmc_DdmServer.cpp \
	native/org_apache_harmony_dalvik_ddmc_DdmVmInternal.cpp \
	native/sun_misc_Unsafe.cpp \
	oo/AccessCheck.cpp \
	oo/Array.cpp \
	oo/Class.cpp \
	oo/Object.cpp \
	oo/Resolve.cpp \
	oo/TypeCheck.cpp \
	reflect/Annotation.cpp \
	reflect/Proxy.cpp \
	reflect/Reflect.cpp \
	test/AtomicTest.cpp.arm \
	test/TestHash.cpp \
	test/TestIndirectRefTable.cpp

# TODO: this is the wrong test, but what's the right one?
ifneq ($(filter arm mips,$(dvm_arch)),)
  LOCAL_SRC_FILES += os/android.cpp
else
  LOCAL_SRC_FILES += os/linux.cpp
endif

WITH_COPYING_GC := $(strip $(WITH_COPYING_GC))

ifeq ($(WITH_COPYING_GC),true)
  LOCAL_CFLAGS += -DWITH_COPYING_GC
  LOCAL_SRC_FILES += \
	alloc/Copying.cpp.arm
else
  LOCAL_SRC_FILES += \
	alloc/DlMalloc.cpp \
	alloc/HeapSource.cpp \
	alloc/MarkSweep.cpp.arm
endif

WITH_JIT := $(strip $(WITH_JIT))

ifeq ($(WITH_JIT),true)
  LOCAL_CFLAGS += -DWITH_JIT
  LOCAL_SRC_FILES += \
	compiler/Compiler.cpp \
	compiler/Frontend.cpp \
	compiler/Utility.cpp \
	compiler/InlineTransformation.cpp \
	compiler/IntermediateRep.cpp \
	compiler/Dataflow.cpp \
	compiler/SSATransformation.cpp \
	compiler/Loop.cpp \
	compiler/Ralloc.cpp \
	interp/Jit.cpp
endif

LOCAL_C_INCLUDES += \
	dalvik \
	dalvik/vm \
	external/zlib \
	libcore/include \

MTERP_ARCH_KNOWN := false

ifeq ($(dvm_arch),arm)
  #dvm_arch_variant := armv7-a
  #LOCAL_CFLAGS += -march=armv7-a -mfloat-abi=softfp -mfpu=vfp
  LOCAL_CFLAGS += -Werror
  MTERP_ARCH_KNOWN := true

  # Select architecture-specific sources (armv5te, armv7-a, etc.)
  LOCAL_SRC_FILES += \
		arch/arm/CallOldABI.S \
		arch/arm/CallEABI.S \
		arch/arm/HintsEABI.cpp \
		mterp/out/InterpC-$(dvm_arch_variant).cpp.arm \
		mterp/out/InterpAsm-$(dvm_arch_variant).S

  ifeq ($(WITH_JIT),true)
    # Debuggerd support
    LOCAL_SRC_FILES += DalvikCrashDump.cpp

    LOCAL_SRC_FILES += \
		compiler/codegen/RallocUtil.cpp \
		compiler/codegen/arm/$(dvm_arch_variant)/Codegen.cpp \
		compiler/codegen/arm/$(dvm_arch_variant)/CallingConvention.S \
		compiler/codegen/arm/Assemble.cpp \
		compiler/codegen/arm/ArchUtility.cpp \
		compiler/codegen/arm/LocalOptimizations.cpp \
		compiler/codegen/arm/GlobalOptimizations.cpp \
		compiler/codegen/arm/ArmRallocUtil.cpp \
		compiler/template/out/CompilerTemplateAsm-$(dvm_arch_variant).S
  endif

  ifeq ($(WITH_QC_PERF),true)
    LOCAL_WHOLE_STATIC_LIBRARIES += libqc-dalvik
    LOCAL_SHARED_LIBRARIES += libqc-opt
    LOCAL_CFLAGS += -DWITH_QC_PERF
  endif
endif

ifeq ($(dvm_arch),mips)
  MTERP_ARCH_KNOWN := true
  LOCAL_C_INCLUDES += external/libffi/$(TARGET_OS)-$(TARGET_ARCH)
  LOCAL_SHARED_LIBRARIES += libffi
  LOCAL_SRC_FILES += \
		arch/mips/CallO32.S \
		arch/mips/HintsO32.cpp \
		arch/generic/Call.cpp \
		mterp/out/InterpC-mips.cpp \
		mterp/out/InterpAsm-mips.S

  ifeq ($(WITH_JIT),true)
    dvm_arch_variant := mips
    LOCAL_SRC_FILES += \
		compiler/codegen/mips/RallocUtil.cpp \
		compiler/codegen/mips/$(dvm_arch_variant)/Codegen.cpp \
		compiler/codegen/mips/$(dvm_arch_variant)/CallingConvention.S \
		compiler/codegen/mips/Assemble.cpp \
		compiler/codegen/mips/ArchUtility.cpp \
		compiler/codegen/mips/LocalOptimizations.cpp \
		compiler/codegen/mips/GlobalOptimizations.cpp \
		compiler/template/out/CompilerTemplateAsm-$(dvm_arch_variant).S
  endif
endif

ifeq ($(dvm_arch),x86)
  ifeq ($(dvm_os),linux)
    MTERP_ARCH_KNOWN := true
    LOCAL_CFLAGS += -DDVM_JMP_TABLE_MTERP=1 \
                    -DMTERP_STUB
    LOCAL_SRC_FILES += \
		arch/$(dvm_arch_variant)/Call386ABI.S \
		arch/$(dvm_arch_variant)/Hints386ABI.cpp \
		mterp/out/InterpC-$(dvm_arch_variant).cpp \
		mterp/out/InterpAsm-$(dvm_arch_variant).S
    ifeq ($(WITH_JIT),true)
      LOCAL_CFLAGS += -DARCH_IA32
      LOCAL_SRC_FILES += \
                compiler/codegen/x86/LowerAlu.cpp \
                compiler/codegen/x86/LowerConst.cpp \
                compiler/codegen/x86/LowerMove.cpp \
                compiler/codegen/x86/Lower.cpp \
                compiler/codegen/x86/LowerHelper.cpp \
                compiler/codegen/x86/LowerJump.cpp \
                compiler/codegen/x86/LowerObject.cpp \
                compiler/codegen/x86/AnalysisO1.cpp \
                compiler/codegen/x86/BytecodeVisitor.cpp \
                compiler/codegen/x86/NcgAot.cpp \
                compiler/codegen/x86/CodegenInterface.cpp \
                compiler/codegen/x86/LowerInvoke.cpp \
                compiler/codegen/x86/LowerReturn.cpp \
                compiler/codegen/x86/NcgHelper.cpp \
                compiler/codegen/x86/LowerGetPut.cpp

      # need apache harmony x86 encoder/decoder
      LOCAL_C_INCLUDES += \
                dalvik/vm/compiler/codegen/x86/libenc
      LOCAL_SRC_FILES += \
                compiler/codegen/x86/libenc/enc_base.cpp \
                compiler/codegen/x86/libenc/dec_base.cpp \
                compiler/codegen/x86/libenc/enc_wrapper.cpp \
                compiler/codegen/x86/libenc/enc_tabl.cpp

    endif
  endif
endif

ifeq ($(MTERP_ARCH_KNOWN),false)
  # unknown architecture, try to use FFI
  LOCAL_C_INCLUDES += external/libffi/$(dvm_os)-$(dvm_arch)

  ifeq ($(dvm_os)-$(dvm_arch),darwin-x86)
      # OSX includes libffi, so just make the linker aware of it directly.
      LOCAL_LDLIBS += -lffi
  else
      LOCAL_SHARED_LIBRARIES += libffi
  endif

  LOCAL_SRC_FILES += \
		arch/generic/Call.cpp \
		arch/generic/Hints.cpp \
		mterp/out/InterpC-allstubs.cpp

  # The following symbols are usually defined in the asm file, but
  # since we don't have an asm file in this case, we instead just
  # peg them at 0 here, and we add an #ifdef'able define for good
  # measure, too.
  LOCAL_CFLAGS += -DdvmAsmInstructionStart=0 -DdvmAsmInstructionEnd=0 \
	-DdvmAsmSisterStart=0 -DdvmAsmSisterEnd=0 -DDVM_NO_ASM_INTERP=1
endif