Permalink
Browse files

[X86] X86 trace JIT compiler support

This patch provides a fully functional x86 trace JIT compiler for Dalvik
VM. It is built on top of the existing x86 fast interpreter
with bug fixes and needed extension to support trace JIT interface. The
x86 trace JIT code generator was developed independent of the existing
template-based code generator and thus does not share exactly the same
infrastructure. Included in this patch are:

* Deprecated and removed the x86-atom fast interpreter that is no
  longer functional since ICS.
* Augmented x86 fast interpreter to provide interfaces for x86 trace JIT
  compiler.
* Added x86 trace JIT code generator with full JDWP debugging support.
* Method JIT and self-verification mode are not supported.

The x86 code generator uses the x86 instruction encoder/decoder library
from the Apache Harmony project. Additional wrapper extension and bug
fixes were added to support the x86 trace JIT code generator. The x86
instruction encoder/decoder is embedded inside the x86 code generator
under the libenc subdirectory.

Change-Id: I241113681963a16c13a3562390813cbaaa6eedf0
Signed-off-by: Dong-Yuan Chen <dong-yuan.chen@intel.com>
Signed-off-by: Yixin Shou <yixin.shou@intel.com>
Signed-off-by: Johnnie Birch <johnnie.l.birch.jr@intel.com>
Signed-off-by: Udayan <udayan.banerji@intel.com>
Signed-off-by: Sushma Kyasaralli Thimmappa <sushma.kyasaralli.thimmappa@intel.com>
Signed-off-by: Bijoy Jose <bijoy.a.jose@intel.com>
Signed-off-by: Razvan A Lupusoru <razvan.a.lupusoru@intel.com>
Signed-off-by: Tim Hartley <timothy.d.hartley@intel.com>
  • Loading branch information...
dychen95 authored and enh committed Jul 3, 2012
1 parent abede65 commit 0c2dc522d0e120f346cf0a40c8cf0c93346131c2
Showing 391 changed files with 36,721 additions and 33,624 deletions.
View
33 NOTICE
@@ -1,3 +1,8 @@
+ =========================================================================
+ == NOTICE file corresponding to the section 4 d of ==
+ == the Apache License, Version 2.0, ==
+ == in this case for the Android-specific code. ==
+ =========================================================================
Copyright (c) 2005-2008, The Android Open Source Project
@@ -188,3 +193,31 @@
END OF TERMS AND CONDITIONS
+ =========================================================================
+ == NOTICE file for the x86 JIT libenc subdirectory. ==
+ =========================================================================
+
+Apache Harmony
+Copyright 2006, 2010 The Apache Software Foundation.
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+
+Portions of Harmony were originally developed by
+Intel Corporation and are licensed to the Apache Software
+Foundation under the "Software Grant and Corporate Contribution
+License Agreement" and for which the following copyright notices
+apply
+ (C) Copyright 2005 Intel Corporation
+ (C) Copyright 2005-2006 Intel Corporation
+ (C) Copyright 2006 Intel Corporation
+
+Portions of the Apache Portable Runtime used by DRLVM were
+developed at the National Center for Supercomputing Applications
+(NCSA) at the University of Illinois at Urbana-Champaign.
+
+This software contains code derived from the RSA Data Security
+Inc. MD5 Message-Digest Algorithm.
+
+This software contains code derived from UNIX V7, Copyright(C)
+Caldera International Inc.
@@ -14,7 +14,7 @@ static public void main(String[] args) throws Exception {
static private void child() throws Exception {
System.out.println("spawning child");
- ProcessBuilder pb = new ProcessBuilder("/system/bin/sleep", "5");
+ ProcessBuilder pb = new ProcessBuilder("sleep", "5");
Process proc = pb.start();
Thread.sleep(1000);
checkManager();
@@ -78,8 +78,8 @@ while true; do
done
if [ "x$INTERP" = "x" ]; then
- INTERP="fast" # TODO: change this to "jit" when the x86 jit is merged.
- msg "Using fast interpreter by default"
+ INTERP="jit"
+ msg "Using jit by default"
fi
if [ "$OPTIMIZE" = "y" ]; then
View
@@ -92,6 +92,10 @@ ifeq ($(WITH_JIT),true)
LOCAL_MODULE := libdvm_interp
include $(BUILD_SHARED_LIBRARY)
+ ifeq ($(dvm_arch),x86) # For x86, we enable JIT on host too
+ # restore WITH_JIT = true for host dalvik build
+ WITH_JIT := true
+ endif # dvm_arch==x86
endif
#
@@ -108,7 +112,11 @@ ifeq ($(WITH_HOST_DALVIK),true)
# Note: HOST_ARCH_VARIANT isn't defined.
dvm_arch_variant := $(HOST_ARCH)
- WITH_JIT := false
+ # We always want the x86 JIT.
+ ifeq ($(dvm_arch),x86)
+ WITH_JIT := true
+ endif
+
include $(LOCAL_PATH)/Dvm.mk
LOCAL_SHARED_LIBRARIES += libcrypto libssl libicuuc libicui18n
View
@@ -284,19 +284,41 @@ endif
ifeq ($(dvm_arch),x86)
ifeq ($(dvm_os),linux)
MTERP_ARCH_KNOWN := true
- LOCAL_CFLAGS += -DDVM_JMP_TABLE_MTERP=1
+ 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/Assemble.cpp \
- compiler/codegen/x86/ArchUtility.cpp \
- compiler/codegen/x86/ia32/Codegen.cpp \
- compiler/codegen/x86/ia32/CallingConvention.S \
- compiler/template/out/CompilerTemplateAsm-ia32.S
+ 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
View
@@ -155,6 +155,9 @@ struct DvmGlobals {
ExecutionMode executionMode;
+ bool commonInit; /* whether common stubs are generated */
+ bool constInit; /* whether global constants are initialized */
+
/*
* VM init management.
*/
@@ -870,15 +873,28 @@ struct DvmJitGlobals {
/* true/false: compile/reject methods specified in the -Xjitmethod list */
bool includeSelectedMethod;
+ /* true/false: compile/reject traces with offset specified in the -Xjitoffset list */
+ bool includeSelectedOffset;
+
/* Disable JIT for selected opcodes - one bit for each opcode */
char opList[(kNumPackedOpcodes+7)/8];
/* Disable JIT for selected methods */
HashTable *methodTable;
+ /* Disable JIT for selected classes */
+ HashTable *classTable;
+
+ /* Disable JIT for selected offsets */
+ unsigned int pcTable[COMPILER_PC_OFFSET_SIZE];
+ int num_entries_pcTable;
+
/* Flag to dump all compiled code */
bool printMe;
+ /* Flag to dump compiled binary code in bytes */
+ bool printBinary;
+
/* Per-process debug flag toggled when receiving a SIGUSR2 */
bool receivedSIGUSR2;
@@ -948,6 +964,10 @@ struct DvmJitGlobals {
u8 maxCompilerThreadBlockGCTime;
#endif
+#if defined(ARCH_IA32)
+ JitOptLevel optLevel;
+#endif
+
/* Place arrays at the end to ease the display in gdb sessions */
/* Work order queue for compilations */
Oops, something went wrong.

0 comments on commit 0c2dc52

Please sign in to comment.