[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[dotgnu-pnet-commits] pnet ChangeLog engine/cvm.c engine/cvm.h engine...
From: |
Aleksey Demakov |
Subject: |
[dotgnu-pnet-commits] pnet ChangeLog engine/cvm.c engine/cvm.h engine... |
Date: |
Sat, 17 Mar 2007 19:11:37 +0000 |
CVSROOT: /sources/dotgnu-pnet
Module name: pnet
Changes by: Aleksey Demakov <avd> 07/03/17 19:11:37
Modified files:
. : ChangeLog
engine : cvm.c cvm.h cvm_config.h cvmc.c engine.h
md_x86.h mklabel.sh process.c unroll.c
unroll_branch.c
Log message:
in unroller add support for loading CVM interpreter variables from stack
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/pnet/ChangeLog?cvsroot=dotgnu-pnet&r1=1.3437&r2=1.3438
http://cvs.savannah.gnu.org/viewcvs/pnet/engine/cvm.c?cvsroot=dotgnu-pnet&r1=1.58&r2=1.59
http://cvs.savannah.gnu.org/viewcvs/pnet/engine/cvm.h?cvsroot=dotgnu-pnet&r1=1.54&r2=1.55
http://cvs.savannah.gnu.org/viewcvs/pnet/engine/cvm_config.h?cvsroot=dotgnu-pnet&r1=1.17&r2=1.18
http://cvs.savannah.gnu.org/viewcvs/pnet/engine/cvmc.c?cvsroot=dotgnu-pnet&r1=1.54&r2=1.55
http://cvs.savannah.gnu.org/viewcvs/pnet/engine/engine.h?cvsroot=dotgnu-pnet&r1=1.120&r2=1.121
http://cvs.savannah.gnu.org/viewcvs/pnet/engine/md_x86.h?cvsroot=dotgnu-pnet&r1=1.8&r2=1.9
http://cvs.savannah.gnu.org/viewcvs/pnet/engine/mklabel.sh?cvsroot=dotgnu-pnet&r1=1.10&r2=1.11
http://cvs.savannah.gnu.org/viewcvs/pnet/engine/process.c?cvsroot=dotgnu-pnet&r1=1.72&r2=1.73
http://cvs.savannah.gnu.org/viewcvs/pnet/engine/unroll.c?cvsroot=dotgnu-pnet&r1=1.18&r2=1.19
http://cvs.savannah.gnu.org/viewcvs/pnet/engine/unroll_branch.c?cvsroot=dotgnu-pnet&r1=1.3&r2=1.4
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/dotgnu-pnet/pnet/ChangeLog,v
retrieving revision 1.3437
retrieving revision 1.3438
diff -u -b -r1.3437 -r1.3438
--- ChangeLog 17 Mar 2007 16:10:14 -0000 1.3437
+++ ChangeLog 17 Mar 2007 19:11:37 -0000 1.3438
@@ -1,3 +1,31 @@
+2007-03-18 Aleksey Demakov <address@hidden>
+
+ * engine/cvm_config.h (IL_NO_REGISTERS_USED, IL_VMCASE_BARRIER): New
+ configuration options.
+
+ * engine/cvm.h, engine/cvm.c (COP_PREFIX_UNROLL_STACK)
+ (COP_PREFIX_UNROLL_STACK_RETURN): New opcodes for unroller stack
+ variables initialization.
+
+ * engine/mklabel.sh: Add VMBARRIER() macro. Use VMBARRIER() in
+ VMCASE() if IL_VMCASE_BARRIER is defined.
+
+ * engine/unroll.c (LoadMachineState): Load stack and frame variables.
+ (UnloadMachineState): Store stack and pc variables. Add pc address
+ argument.
+
+ * engine/md_x86.h: Support variable load and store configuration.
+
+ * engine/cvmc.c (_ILCVMUnrollInitStack): New function.
+ (_ILCVMGetPcOffset, _ILCVMSetPcOffset): New functions.
+ (_ILCVMGetStackOffset, _ILCVMSetStackOffset): New functions.
+ (_ILCVMGetFrameOffset, _ILCVMSetFrameOffset): New functions.
+ * engine/unroll.c (_ILCVMUnrollGetNativeStack): New function.
+ * engine/engine.h: New functions declarations.
+
+ * engine/process.c (ILExecProcessCreate): add _ILCVMUnrollInitStack
+ call.
+
2007-03-17 Klaus Treichel <address@hidden>
* cscc/csharp/cs_grammar.cs: Add the new 2.0 operators for Null
Coalescing
Index: engine/cvm.c
===================================================================
RCS file: /sources/dotgnu-pnet/pnet/engine/cvm.c,v
retrieving revision 1.58
retrieving revision 1.59
diff -u -b -r1.58 -r1.59
--- engine/cvm.c 17 Jun 2006 09:24:38 -0000 1.58
+++ engine/cvm.c 17 Mar 2007 19:11:37 -0000 1.59
@@ -46,6 +46,7 @@
* figure out that "pc", "stacktop", and "frame" are the
* best values to put into registers.
*/
+#if !defined(IL_NO_REGISTERS_USED)
#if defined(CVM_X86) && defined(__GNUC__) && !defined(IL_NO_ASM)
#define REGISTER_ASM_X86 1
@@ -135,6 +136,10 @@
#define IL_MEMCMP(dst,src,len) (ILMemCmp((dst), (src),
(len)))
#else
#define IL_NO_REGISTERS_USED 1
+#endif
+#endif
+
+#if defined(IL_NO_REGISTERS_USED)
#define REGISTER_ASM_PC(x) x
#define REGISTER_ASM_STACK(x) x
#define REGISTER_ASM_FRAME(x) x
@@ -149,7 +154,7 @@
* Defining macros to declare variables in the interpreter loop volatile.
* This is done to fix problems with gcc's optimized code.
*/
-#ifdef __GNUC__
+#if defined(__GNUC__) && !defined(IL_VMCASE_BARRIER)
#if (__GNUC__ == 4) && defined(CVM_X86)
#define IL_PC_VOLATILE volatile
#define IL_STACKTOP_VOLATILE volatile
@@ -863,6 +868,80 @@
}
VMBREAK(COP_PREFIX_UNROLL_METHOD);
+ /**
+ * <opcode name="unroll_stack"
+ * group="Miscellaneous
instructions">
+ *
+ * <operation>Start special stack
variable
+ * initialization for
unroller</operation>
+ *
+ * <dformat>{unroll_stack}</dformat>
+ *
+ * <form name="unroll_stack"
+ *
code="COP_PREFIX_UNROLL_STACK"/>
+ *
+ * <description>The
<i>unroll_stack</i> instruction
+ * is used only to bootstrap the
unroller.<p/>
+ *
+ * It generates the code that gets
the native stack
+ * pointer value and puts it on the
interpreter
+ * stack. This istruction must be
followed by
+ *
<i>unroll_stack_return</i>.</description>
+ * </opcode>
+ */
+ VMCASE(COP_PREFIX_UNROLL_STACK):
+ {
+ #if defined(IL_CVM_DIRECT_UNROLLED) &&
defined(IL_NO_REGISTERS_USED)
+
_ILCVMUnrollGetNativeStack(thread->process->coder, &pc, &stacktop);
+ #endif
+
MODIFY_PC_AND_STACK(CVMP_LEN_NONE, 0);
+ }
+ VMBREAK(COP_PREFIX_UNROLL_STACK);
+
+ /**
+ * <opcode name="unroll_stack_return"
+ * group="Miscellaneous
instructions">
+ *
+ * <operation>Finish special stack
variable
+ * initialization for
unroller</operation>
+ *
+ *
<dformat>{unroll_stack_return}</dformat>
+ *
+ * <form name="unroll_stack_return"
+ *
code="COP_PREFIX_UNROLL_STACK_RETURN"/>
+ *
+ * <description>The
<i>unroll_stack_return</i>
+ * instruction is used only to
bootstrap the
+ * unroller.<p/>
+ *
+ * It gets the native stack pointer
value obtained
+ * through the "unroll_stack"
instruction, computes
+ * the offset of the interpreter
variables against
+ * it, and stores the offsets for
internal use by
+ * the unroller.</description>
+ * </opcode>
+ */
+ VMCASE(COP_PREFIX_UNROLL_STACK_RETURN):
+ {
+ #ifdef IL_NO_REGISTERS_USED
+ char *native_stack =
stacktop[-1].ptrValue;
+ _ILCVMSetPcOffset(
+ thread->process->coder,
+ ((char *) &pc) -
native_stack);
+ _ILCVMSetStackOffset(
+ thread->process->coder,
+ ((char *) &stacktop) -
native_stack);
+ _ILCVMSetFrameOffset(
+ thread->process->coder,
+ ((char *) &frame) -
native_stack);
+
MODIFY_PC_AND_STACK(CVMP_LEN_NONE, -1);
+ #else
+
MODIFY_PC_AND_STACK(CVMP_LEN_NONE, 0);
+ #endif
+ return 0;
+ }
+ VMBREAK(COP_PREFIX_UNROLL_STACK_RETURN);
+
#ifndef IL_CVM_DIRECT
VMPREFIXDEFAULT:
{
Index: engine/cvm.h
===================================================================
RCS file: /sources/dotgnu-pnet/pnet/engine/cvm.h,v
retrieving revision 1.54
retrieving revision 1.55
diff -u -b -r1.54 -r1.55
--- engine/cvm.h 15 Oct 2005 15:13:47 -0000 1.54
+++ engine/cvm.h 17 Mar 2007 19:11:37 -0000 1.55
@@ -570,6 +570,11 @@
#define COP_PREFIX_TAN 0x89
#define COP_PREFIX_TANH 0x8A
+/*
+ * Initialize unroller special stack variables.
+ */
+#define COP_PREFIX_UNROLL_STACK 0x8B
+#define COP_PREFIX_UNROLL_STACK_RETURN 0x8C
/*
* Definition of a CVM stack word which can hold
Index: engine/cvm_config.h
===================================================================
RCS file: /sources/dotgnu-pnet/pnet/engine/cvm_config.h,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -b -r1.17 -r1.18
--- engine/cvm_config.h 17 Jun 2006 09:24:38 -0000 1.17
+++ engine/cvm_config.h 17 Mar 2007 19:11:37 -0000 1.18
@@ -35,6 +35,11 @@
/*#define IL_NO_ASM*/
/*
+ * Turn off explicit register declarations in the cvm loop if this is defined.
+ */
+/*#define IL_NO_REGISTERS_USED*/
+
+/*
* Enable or disable dumping of CVM instructions during execution.
*/
/*#define IL_DUMP_CVM*/
@@ -243,6 +248,16 @@
#define CVM_CTOR_OFFSET 6
#endif
+/*
+ * If the interpeter does not use explicit register declarations it might be
+ * necessary to flush the variables on each opcode.
+ */
+#if defined(IL_CVM_DIRECT_UNROLLED) && defined(IL_NO_REGISTERS_USED)
+#if defined(CVM_X86)
+#define IL_VMCASE_BARRIER
+#endif
+#endif
+
#ifdef __cplusplus
};
#endif
Index: engine/cvmc.c
===================================================================
RCS file: /sources/dotgnu-pnet/pnet/engine/cvmc.c,v
retrieving revision 1.54
retrieving revision 1.55
diff -u -b -r1.54 -r1.55
--- engine/cvmc.c 10 Mar 2007 21:54:57 -0000 1.54
+++ engine/cvmc.c 17 Mar 2007 19:11:37 -0000 1.55
@@ -93,6 +93,11 @@
ILExecProcess *process; /* Backpointer to the owning
process */
/* The manager for running the required cctors. */
ILCCtorMgr cctorMgr;
+#if defined(IL_CVM_DIRECT_UNROLLED) && defined(IL_NO_REGISTERS_USED)
+ int pcOffset;
+ int stackOffset;
+ int frameOffset;
+#endif
};
/*
@@ -189,6 +194,11 @@
coder->nativeArgPosn = 0;
coder->nativeArgHeight = 0;
coder->process = process;
+#if defined(IL_CVM_DIRECT_UNROLLED) && defined(IL_NO_REGISTERS_USED)
+ coder->pcOffset = 0;
+ coder->stackOffset = 0;
+ coder->frameOffset = 0;
+#endif
/* Call the interpreter to export the label tables for
use in code generation for direct threading */
@@ -321,6 +331,85 @@
return (ILCacheStartMethod(coder->cache, posn, align, 0) != 0);
}
+
+int _ILCVMGetPcOffset(ILCoder *_coder)
+{
+#if defined(IL_CVM_DIRECT_UNROLLED) && defined(IL_NO_REGISTERS_USED)
+ return _ILCoderToILCVMCoder(_coder)->pcOffset;
+#else
+ return 0;
+#endif
+}
+
+void _ILCVMSetPcOffset(ILCoder *_coder, int pcOffset)
+{
+#if defined(IL_CVM_DIRECT_UNROLLED) && defined(IL_NO_REGISTERS_USED)
+ _ILCoderToILCVMCoder(_coder)->pcOffset = pcOffset;
+#endif
+}
+
+int _ILCVMGetStackOffset(ILCoder *_coder)
+{
+#if defined(IL_CVM_DIRECT_UNROLLED) && defined(IL_NO_REGISTERS_USED)
+ return _ILCoderToILCVMCoder(_coder)->stackOffset;
+#else
+ return 0;
+#endif
+}
+
+void _ILCVMSetStackOffset(ILCoder *_coder, int stackOffset)
+{
+#if defined(IL_CVM_DIRECT_UNROLLED) && defined(IL_NO_REGISTERS_USED)
+ _ILCoderToILCVMCoder(_coder)->stackOffset = stackOffset;
+#endif
+}
+
+int _ILCVMGetFrameOffset(ILCoder *_coder)
+{
+#if defined(IL_CVM_DIRECT_UNROLLED) && defined(IL_NO_REGISTERS_USED)
+ return _ILCoderToILCVMCoder(_coder)->frameOffset;
+#else
+ return 0;
+#endif
+}
+
+void _ILCVMSetFrameOffset(ILCoder *_coder, int frameOffset)
+{
+#if defined(IL_CVM_DIRECT_UNROLLED) && defined(IL_NO_REGISTERS_USED)
+ _ILCoderToILCVMCoder(_coder)->frameOffset = frameOffset;
+#endif
+}
+
+int _ILCVMUnrollInitStack(ILExecProcess *process)
+{
+#if defined(IL_CVM_DIRECT_UNROLLED) && defined(IL_NO_REGISTERS_USED)
+ ILCVMCoder *coder;
+
+ coder = _ILCoderToILCVMCoder(process->coder);
+
+ /* Find some room in the cache */
+ coder->start = ILCacheStartMethod(coder->cache, &(coder->codePosn), 1,
0);
+ if(!(coder->start))
+ {
+ return 0;
+ }
+
+ /* Generate register initialization code */
+ CVMP_OUT_NONE(COP_PREFIX_UNROLL_STACK);
+ CVM_OUT_NONE(COP_POP);
+ CVMP_OUT_NONE(COP_PREFIX_UNROLL_STACK_RETURN);
+ ILCacheEndMethod(&coder->codePosn);
+
+ /* Execute register initialization code */
+ process->mainThread->pc = coder->start;
+ _ILCVMInterpreter(process->mainThread);
+
+ return 1;
+#else
+ return 1;
+#endif
+}
+
#if !defined(IL_CONFIG_REDUCE_CODE) && !defined(IL_WITHOUT_TOOLS)
/*
Index: engine/engine.h
===================================================================
RCS file: /sources/dotgnu-pnet/pnet/engine/engine.h,v
retrieving revision 1.120
retrieving revision 1.121
diff -u -b -r1.120 -r1.121
--- engine/engine.h 10 Mar 2007 21:54:57 -0000 1.120
+++ engine/engine.h 17 Mar 2007 19:11:37 -0000 1.121
@@ -948,6 +948,46 @@
unsigned char *pc, ILMethod *method);
/*
+ * Initialize the CVM interpreter stack variables.
+ */
+int _ILCVMUnrollInitStack(ILExecProcess *process);
+
+/*
+ * Generate code that gets the native stack pointer value.
+ */
+int _ILCVMUnrollGetNativeStack(ILCoder *coder, unsigned char **pcPtr, CVMWord
**stackPtr);
+
+/*
+ * Get offset of the interpreter "pc" variable.
+ */
+int _ILCVMGetPcOffset(ILCoder *coder);
+
+/*
+ * Set offset of the interpreter "pc" variable.
+ */
+void _ILCVMSetPcOffset(ILCoder *coder, int pcOffset);
+
+/*
+ * Get offset of the interpreter "stacktop" variable.
+ */
+int _ILCVMGetStackOffset(ILCoder *coder);
+
+/*
+ * Set offset of the interpreter "stacktop" variable.
+ */
+void _ILCVMSetStackOffset(ILCoder *coder, int stackOffset);
+
+/*
+ * Get offset of the interpreter "frame" variable.
+ */
+int _ILCVMGetFrameOffset(ILCoder *coder);
+
+/*
+ * Set offset of the interpreter "frame" variable.
+ */
+void _ILCVMSetFrameOffset(ILCoder *coder, int frameOffset);
+
+/*
* Determine the size of a type's values in bytes. This assumes
* that the caller has obtained the metadata write lock.
*/
Index: engine/md_x86.h
===================================================================
RCS file: /sources/dotgnu-pnet/pnet/engine/md_x86.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- engine/md_x86.h 10 Aug 2003 06:20:09 -0000 1.8
+++ engine/md_x86.h 17 Mar 2007 19:11:37 -0000 1.9
@@ -101,13 +101,30 @@
#define MD_REG_FRAME X86_EBX
/*
+ * The registers to be used to save pc before jumping to cvm. These
+ * can be set to -1 if MD_STATE_ALREADY_IN_REGS is not 0.
+ */
+#define MD_REG_TEMP_PC X86_EAX
+#define MD_REG_TEMP_PC_PTR X86_ECX
+
+/*
+ * The register that contains native stack pointer. This can be set to
+ * -1 if MD_STATE_ALREADY_IN_REGS is not 0.
+ */
+#define MD_REG_NATIVE_STACK X86_ESP
+
+/*
* Set this to 1 if "pc", "stacktop", and "frame" are already in
* the above registers when unrolled code is entered. i.e. the
* CVM interpreter has manual assignments of registers to variables
* in the file "cvm.c". If the state is not already in registers,
* then set this value to zero.
*/
+#ifdef IL_NO_REGISTERS_USED
+#define MD_STATE_ALREADY_IN_REGS 0
+#else
#define MD_STATE_ALREADY_IN_REGS 1
+#endif
/*
* Registers that must be saved on the system stack prior to their use
@@ -119,7 +136,21 @@
* Registers with special meanings (pc, stacktop, frame) that must
* be saved if MD_STATE_ALREADY_IN_REGS is 0.
*/
+#ifdef IL_VMCASE_BARRIER
#define MD_SPECIAL_REGS_TO_BE_SAVED 0
+#else
+#define MD_SPECIAL_REGS_TO_BE_SAVED \
+ ((1 << MD_REG_PC) | (1 << MD_REG_STACK) | (1 << MD_REG_FRAME))
+#endif
+
+/*
+ * The number of bytes the special registers occupy on the stack.
+ */
+#ifdef IL_VMCASE_BARRIER
+#define MD_SPECIAL_REGS_STACK_OFFSET 0
+#else
+#define MD_SPECIAL_REGS_STACK_OFFSET (3 * 4)
+#endif
/*
* Floating-point register numbers that must be saved.
@@ -484,6 +515,8 @@
* Jump back into the CVM interpreter to execute the instruction
* at "pc". If "label" is non-NULL, then it indicates the address
* of the CVM instruction handler to jump directly to.
+ *
+ * This is used if MD_STATE_ALREADY_IN_REGS is 0.
*/
#define md_jump_to_cvm(inst,pc,label) \
do { \
@@ -499,6 +532,43 @@
} while (0)
/*
+ * Jump back into the CVM interpreter to execute the instruction
+ * at "pc". If "label" is non-NULL, then it indicates the address
+ * of the CVM instruction handler to jump directly to.
+ *
+ * This is used if MD_STATE_ALREADY_IN_REGS is not 0.
+ */
+#define md_jump_to_cvm_with_pc_offset(inst,pc,pc_offset,label)
\
+ do { \
+ int __offset = (pc_offset) -
MD_SPECIAL_REGS_STACK_OFFSET; \
+ x86_mov_reg_imm((inst), MD_REG_TEMP_PC,
(int)pc); \
+ x86_mov_membase_reg((inst),
MD_REG_NATIVE_STACK, __offset, MD_REG_TEMP_PC, 4); \
+ if((label)) \
+ { \
+ x86_jump_code((inst), label); \
+ } \
+ else \
+ { \
+ x86_jump_membase((inst),
MD_REG_TEMP_PC, 0); \
+ } \
+ } while (0)
+
+/*
+ * Jump back into the CVM interpreter to execute the instruction
+ * at "pc".
+ *
+ * This is used if MD_STATE_ALREADY_IN_REGS is not 0 to bootstrap
+ * the unroller.
+ */
+#define md_jump_to_cvm_with_pc_ptr(inst,pc,pc_ptr) \
+ do { \
+ x86_mov_reg_imm((inst), MD_REG_TEMP_PC,
(int)pc); \
+ x86_mov_reg_imm((inst), MD_REG_TEMP_PC_PTR,
(int)pc_ptr); \
+ x86_mov_membase_reg((inst), MD_REG_TEMP_PC_PTR,
0, MD_REG_TEMP_PC, 4); \
+ x86_jump_membase((inst), MD_REG_TEMP_PC, 0); \
+ } while (0)
+
+/*
* Jump to a program counter that is defined by a switch table.
*/
#define md_switch(inst,reg,table) \
Index: engine/mklabel.sh
===================================================================
RCS file: /sources/dotgnu-pnet/pnet/engine/mklabel.sh,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -b -r1.10 -r1.11
--- engine/mklabel.sh 20 Jun 2005 10:59:08 -0000 1.10
+++ engine/mklabel.sh 17 Mar 2007 19:11:37 -0000 1.11
@@ -43,6 +43,16 @@
echo '#endif'
echo ''
+echo '/*'
+echo ' * Force compiler to flush all variables from registers to memory.'
+echo ' */'
+echo '#ifdef __GNUC__'
+echo '#define VMBARRIER() __asm__ __volatile__ ("" : : : "memory")'
+echo '#else'
+echo '#define VMBARRIER()'
+echo '#endif'
+echo ''
+
# Allow specific platforms to override Computed GOTO realizations
echo '#ifndef VM_CGOTO_SWITCH'
echo '#define VM_CGOTO_SWITCH(val) goto **(void**)pc;'
@@ -143,9 +153,15 @@
echo '#ifdef IL_CVM_DIRECT'
echo '#define VMSWITCH(val) VM_CGOTO_SWITCH(val);'
echo '#define VMPREFIXSWITCH(val) VM_CGOTO_PREFIXSWITCH(val);'
+echo '#ifdef IL_VMCASE_BARRIER'
+echo '#define VMCASE(val) val##_label: VMBARRIER(); val##_dummy'
+echo '#define VMDEFAULT _DEFAULT_MAIN_label: VMBARRIER();
_DEFAULT_MAIN_dummy'
+echo '#define VMPREFIXDEFAULT _DEFAULT_PREFIX_label: VMBARRIER();
_DEFAULT_PREFIX_dummy'
+echo '#else /* !IL_VMCASE_BARRIER */'
echo '#define VMCASE(val) val##_label'
echo '#define VMDEFAULT _DEFAULT_MAIN_label'
echo '#define VMPREFIXDEFAULT _DEFAULT_PREFIX_label'
+echo '#endif /* !IL_VMCASE_BARRIER */'
echo '#define VMBREAK(val) \
CVM_DUMP(); \
VM_CGOTO_BREAK(val)'
@@ -255,9 +271,15 @@
echo '#ifdef IL_CVM_DIRECT'
echo '#define VMSWITCH(val) VM_CGOTO_SWITCH(val);'
echo '#define VMPREFIXSWITCH(val) VM_CGOTO_PREFIXSWITCH(val);'
+echo '#ifdef IL_VMCASE_BARRIER'
+echo '#define VMCASE(val) val##_label: VMBARRIER(); val##_dummy'
+echo '#define VMDEFAULT _DEFAULT_MAIN_label: VMBARRIER();
_DEFAULT_MAIN_dummy'
+echo '#define VMPREFIXDEFAULT _DEFAULT_PREFIX_label: VMBARRIER();
_DEFAULT_PREFIX_dummy'
+echo '#else /* !IL_VMCASE_BARRIER */'
echo '#define VMCASE(val) val##_label'
echo '#define VMDEFAULT _DEFAULT_MAIN_label'
echo '#define VMPREFIXDEFAULT _DEFAULT_PREFIX_label'
+echo '#endif /* !IL_VMCASE_BARRIER */'
echo '#define VMBREAK(val) \
CVM_DUMP(); \
VM_CGOTO_BREAK(val)'
Index: engine/process.c
===================================================================
RCS file: /sources/dotgnu-pnet/pnet/engine/process.c,v
retrieving revision 1.72
retrieving revision 1.73
diff -u -b -r1.72 -r1.73
--- engine/process.c 10 Mar 2007 21:54:57 -0000 1.72
+++ engine/process.c 17 Mar 2007 19:11:37 -0000 1.73
@@ -223,6 +223,14 @@
return 0;
}
+#ifdef IL_USE_CVM
+ if(!_ILCVMUnrollInitStack(process))
+ {
+ ILExecProcessDestroy(process);
+ return 0;
+ }
+#endif
+
/* If threading isn't supported, then the main thread is the finalizer
thread */
if (!ILHasThreads())
{
Index: engine/unroll.c
===================================================================
RCS file: /sources/dotgnu-pnet/pnet/engine/unroll.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -b -r1.18 -r1.19
--- engine/unroll.c 17 Jun 2006 09:24:38 -0000 1.18
+++ engine/unroll.c 17 Mar 2007 19:11:37 -0000 1.19
@@ -67,7 +67,11 @@
long cachedLocal; /* Local variable that was just stored
*/
int cachedReg; /* Register for
variable that was stored */
int thisValidated; /* "this" has been checked for
NULL */
-
+#if !MD_STATE_ALREADY_IN_REGS
+ int pcOffset; /* interpreter's pc variable
offset */
+ int stackOffset; /* interpreter's stack variable
offset */
+ int frameOffset; /* interpreter's frame variable
offset */
+#endif
} MDUnroll;
/*
@@ -252,7 +256,14 @@
}
/* Load stack and frame from the local variables in "_ILCVMInterpreter"
*/
- /* TODO */
+ if(unroll->stackOffset)
+ {
+ md_load_membase_word_native(unroll->out, MD_REG_STACK,
MD_REG_NATIVE_STACK, unroll->stackOffset);
+ }
+ if(unroll->frameOffset)
+ {
+ md_load_membase_word_native(unroll->out, MD_REG_FRAME,
MD_REG_NATIVE_STACK, unroll->frameOffset);
+ }
}
#else /* MD_STATE_ALREADY_IN_REGS */
@@ -264,12 +275,15 @@
/*
* Unload the machine state and jump back into the CVM interpreter.
*/
-static void UnloadMachineState(MDUnroll *unroll, unsigned char *pc,
+static void UnloadMachineState(MDUnroll *unroll, unsigned char *pc, unsigned
char **pcPtr,
unsigned char *label)
{
#if !MD_STATE_ALREADY_IN_REGS
/* Store the stack and pc to the local variables in "_ILCVMInterpreter"
*/
- /* TODO */
+ if(unroll->stackOffset)
+ {
+ md_store_membase_word_native(unroll->out, MD_REG_STACK,
MD_REG_NATIVE_STACK, unroll->stackOffset);
+ }
/* Restore the previous values of the special registers */
if((MD_SPECIAL_REGS_TO_BE_SAVED & (1 << MD_REG_FRAME)) != 0)
@@ -284,10 +298,24 @@
{
md_pop_reg(unroll->out, MD_REG_PC);
}
-#endif
/* Jump back into the CVM interpreter */
+ if(unroll->pcOffset)
+ {
+ md_jump_to_cvm_with_pc_offset(unroll->out, pc,
unroll->pcOffset, label);
+ }
+ else if(pcPtr)
+ {
+ md_jump_to_cvm_with_pc_ptr(unroll->out, pc, pcPtr);
+ }
+ else
+ {
+ md_jump_to_cvm(unroll->out, pc, label);
+ }
+#else
+ /* Jump back into the CVM interpreter */
md_jump_to_cvm(unroll->out, pc, label);
+#endif
}
/*
@@ -309,7 +337,7 @@
unroll->regsSaved = 0;
/* Unload the machine state and jump back into the CVM interpreter */
- UnloadMachineState(unroll, pc, 0);
+ UnloadMachineState(unroll, pc, 0, 0);
}
/*
@@ -339,7 +367,7 @@
RestoreSpecialRegisters(unroll);
/* Jump into the CVM interpreter to re-execute the instruction */
- UnloadMachineState(unroll, pc, label);
+ UnloadMachineState(unroll, pc, 0, label);
}
/*
@@ -1546,6 +1574,11 @@
unroll.cachedLocal = -1;
unroll.cachedReg = -1;
unroll.thisValidated = 0;
+#if !MD_STATE_ALREADY_IN_REGS
+ unroll.pcOffset = _ILCVMGetPcOffset(coder);
+ unroll.stackOffset = _ILCVMGetStackOffset(coder);
+ unroll.frameOffset = _ILCVMGetFrameOffset(coder);
+#endif
inUnrollBlock = 0;
overwritePC = 0;
unrollStart = 0;
@@ -1655,6 +1688,75 @@
return 1;
}
+int _ILCVMUnrollGetNativeStack(ILCoder *coder, unsigned char **pcPtr, CVMWord
**stackPtr)
+{
+#if !MD_STATE_ALREADY_IN_REGS
+ unsigned char *pc;
+ unsigned char *stack;
+ MDUnroll unroll;
+ md_inst_ptr unrollStart;
+ ILCachePosn posn;
+
+ pc = *pcPtr;
+ stack = (unsigned char *) *stackPtr;
+
+ /* Find some room in the cache */
+ if(!_ILCVMStartUnrollBlock(coder, 32, &posn))
+ {
+ return 0;
+ }
+ if((posn.limit - posn.ptr) < UNROLL_BUFMIN)
+ {
+ /* Insufficient space to unroll the method */
+ ILCacheEndMethod(&posn);
+ return 0;
+ }
+
+ /* Initialize the local unroll state */
+ unroll.out = (md_inst_ptr)(posn.ptr);
+ unroll.regsUsed = 0;
+ unroll.regsSaved = 0;
+ unroll.pseudoStackSize = 0;
+ unroll.fpStackSize = 0;
+ unroll.stackHeight = 0;
+ unroll.cachedLocal = -1;
+ unroll.cachedReg = -1;
+ unroll.thisValidated = 0;
+ unroll.pcOffset = 0;
+ unroll.stackOffset = 0;
+ unroll.frameOffset = 0;
+
+ /* The start position of the code */
+ unrollStart = unroll.out;
+
+ /* Load the machine state */
+ LoadMachineState(&unroll);
+
+ /* Store native stack pointer value on the interpreter stack */
+ md_load_const_native(unroll.out, MD_REG_TEMP_PC, stack);
+ md_load_const_native(unroll.out, MD_REG_TEMP_PC_PTR, stackPtr);
+ md_store_membase_word_native(unroll.out, MD_REG_NATIVE_STACK,
MD_REG_TEMP_PC, 0);
+ md_add_reg_imm(unroll.out, MD_REG_TEMP_PC, sizeof(CVMWord));
+ md_store_membase_word_native(unroll.out, MD_REG_TEMP_PC,
MD_REG_TEMP_PC_PTR, 0);
+
+ /* Store the start position next to the current op */
+ pc += CVM_LEN_NONE;
+ *((void **)pc) = unrollStart;
+ pc += CVM_LEN_NONE;
+
+ /* Unload the machine state and jump back into the CVM interpreter */
+ UnloadMachineState(&unroll, pc, pcPtr, 0);
+
+ /* Update the method cache to reflect the final position */
+ ILCacheFlush(posn.ptr, (long)(((unsigned char *)(unroll.out)) -
posn.ptr));
+ posn.ptr = (unsigned char *)(unroll.out);
+ ILCacheEndMethod(&posn);
+ return 1;
+#else
+ return 0;
+#endif
+}
+
#else /* !IL_CVM_DIRECT_UNROLLED */
/*
Index: engine/unroll_branch.c
===================================================================
RCS file: /sources/dotgnu-pnet/pnet/engine/unroll_branch.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- engine/unroll_branch.c 10 Aug 2003 06:20:09 -0000 1.3
+++ engine/unroll_branch.c 17 Mar 2007 19:11:37 -0000 1.4
@@ -43,7 +43,7 @@
/* Output the jump to the true PC */
FixStackHeight(unroll);
- UnloadMachineState(unroll, truePC, 0);
+ UnloadMachineState(unroll, truePC, 0, 0);
/* Back-patch the branch instruction to point here */
md_patch(patch, unroll->out);
@@ -51,7 +51,7 @@
/* Output the jump to the false PC */
FixStackHeight(unroll);
unroll->stackHeight = 0;
- UnloadMachineState(unroll, falsePC, 0);
+ UnloadMachineState(unroll, falsePC, 0, 0);
}
#elif defined(IL_UNROLL_CASES)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [dotgnu-pnet-commits] pnet ChangeLog engine/cvm.c engine/cvm.h engine...,
Aleksey Demakov <=