[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Dotgnu-pnet-commits] CVS: pnet/engine cvm.h,1.40,1.41 cvm_dasm.c,1.46,
From: |
Rhys Weatherley <address@hidden> |
Subject: |
[Dotgnu-pnet-commits] CVS: pnet/engine cvm.h,1.40,1.41 cvm_dasm.c,1.46,1.47 cvm_inline.c,1.10,1.11 cvm_lengths.c,1.9,1.10 cvmc_call.c,1.22,1.23 lib_defs.h,1.19,1.20 null_coder.c,1.16,1.17 verify_call.c,1.31,1.32 |
Date: |
Sat, 22 Feb 2003 23:24:14 -0500 |
Update of /cvsroot/dotgnu-pnet/pnet/engine
In directory subversions:/tmp/cvs-serv5103/engine
Modified Files:
cvm.h cvm_dasm.c cvm_inline.c cvm_lengths.c cvmc_call.c
lib_defs.h null_coder.c verify_call.c
Log Message:
Inline "StringBuilder.Append(char)" because it is heavily used
in stream and string code within pnetlib.
Index: cvm.h
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/engine/cvm.h,v
retrieving revision 1.40
retrieving revision 1.41
diff -C2 -r1.40 -r1.41
*** cvm.h 22 Feb 2003 12:02:57 -0000 1.40
--- cvm.h 23 Feb 2003 04:24:11 -0000 1.41
***************
*** 483,507 ****
#define COP_PREFIX_MONITOR_ENTER 0x4F
#define COP_PREFIX_MONITOR_EXIT 0x50
/*
* Binary value fixups.
*/
! #define COP_PREFIX_FIX_I4_I 0x51
! #define COP_PREFIX_FIX_I4_U 0x52
/*
* Trigger method unrolling.
*/
! #define COP_PREFIX_UNROLL_METHOD 0x53
/*
* Allocate local stack space.
*/
! #define COP_PREFIX_LOCAL_ALLOC 0x54
/*
* Method profiling.
*/
! #define COP_PREFIX_PROFILE_COUNT 0x55
/*
--- 483,508 ----
#define COP_PREFIX_MONITOR_ENTER 0x4F
#define COP_PREFIX_MONITOR_EXIT 0x50
+ #define COP_PREFIX_APPEND_CHAR 0x51
/*
* Binary value fixups.
*/
! #define COP_PREFIX_FIX_I4_I 0x52
! #define COP_PREFIX_FIX_I4_U 0x53
/*
* Trigger method unrolling.
*/
! #define COP_PREFIX_UNROLL_METHOD 0x54
/*
* Allocate local stack space.
*/
! #define COP_PREFIX_LOCAL_ALLOC 0x55
/*
* Method profiling.
*/
! #define COP_PREFIX_PROFILE_COUNT 0x56
/*
Index: cvm_dasm.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/engine/cvm_dasm.c,v
retrieving revision 1.46
retrieving revision 1.47
diff -C2 -r1.46 -r1.47
*** cvm_dasm.c 22 Feb 2003 12:02:57 -0000 1.46
--- cvm_dasm.c 23 Feb 2003 04:24:11 -0000 1.47
***************
*** 543,546 ****
--- 543,547 ----
{"monitor_enter", CVM_OPER_NONE},
{"monitor_exit", CVM_OPER_NONE},
+ {"append_char", CVM_OPER_METHOD},
/*
***************
*** 568,572 ****
* Reserved opcodes.
*/
- {"preserved_56", CVM_OPER_NONE},
{"preserved_57", CVM_OPER_NONE},
{"preserved_58", CVM_OPER_NONE},
--- 569,572 ----
Index: cvm_inline.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/engine/cvm_inline.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -r1.10 -r1.11
*** cvm_inline.c 16 Jun 2002 00:45:54 -0000 1.10
--- cvm_inline.c 23 Feb 2003 04:24:11 -0000 1.11
***************
*** 49,53 ****
#elif defined(IL_CVM_LOCALS)
! /* No locals required */
#elif defined(IL_CVM_MAIN)
--- 49,53 ----
#elif defined(IL_CVM_LOCALS)
! System_Text_StringBuilder *builder;
#elif defined(IL_CVM_MAIN)
***************
*** 383,386 ****
--- 383,450 ----
}
VMBREAK(COP_PREFIX_MONITOR_EXIT);
+
+ /**
+ * <opcode name="append_char" group="Inline methods">
+ * <operation>Append a character to a string builder</operation>
+ *
+ * <format>prefix<fsep/>append_char<fsep/>method</format>
+ * <dformat>{append_char}<fsep/>method</dformat>
+ *
+ * <form name="append_char" code="COP_PREFIX_APPEND_CHAR"/>
+ *
+ * <before>..., builder, ch</before>
+ * <after>..., builder</after>
+ *
+ * <description>The <i>builder</i> and <i>ch</i> are popped from the
+ * stack as the types <code>ptr</code> and <code>int32</code> respectively.
+ * The character <i>ch</i> is appended to the end of the string builder
+ * indicated by <i>builder</i>. The <i>builder</i> is then pushed
+ * back onto the stack.</description>
+ *
+ * <notes>This instruction is used to inline calls to the
+ * <code>StringBuilder.Append(char)</code> method. The <i>method</i>
+ * argument must be a pointer to this method, because the interpreter
+ * will "bail out" to the C# class library if the append is too
+ * difficult to perform (e.g. the string must be reallocated).</notes>
+ *
+ * <exceptions>
+ * <exception name="System.NullReferenceException">Raised if
+ * <i>builder</i> is <code>null</code>.</exception>
+ * </exceptions>
+ * </opcode>
+ */
+ VMCASE(COP_PREFIX_APPEND_CHAR):
+ {
+ /* Append a character to a string builder */
+ if(stacktop[-2].ptrValue)
+ {
+ builder = (System_Text_StringBuilder *)(stacktop[-2].ptrValue);
+ if(!(builder->needsCopy) &&
+ builder->buildString->length <
builder->buildString->capacity)
+ {
+ /* We can insert the character into the string directly
*/
+ (StringToBuffer(builder->buildString))
+ [(builder->buildString->length)++] =
+ (ILUInt16)(stacktop[-1].intValue);
+ MODIFY_PC_AND_STACK(CVMP_LEN_PTR, -1);
+ }
+ else
+ {
+ /* We need to reallocate the builder, so call the C#
library */
+ COPY_STATE_TO_THREAD();
+ ILExecThreadCallVirtual(thread, CVMP_ARG_PTR(ILMethod
*),
+
&(stacktop[-2].ptrValue),
+
stacktop[-2].ptrValue,
+
(ILVaInt)(stacktop[-1].intValue));
+ RESTORE_STATE_FROM_THREAD();
+ MODIFY_PC_AND_STACK(CVMP_LEN_PTR, -1);
+ }
+ }
+ else
+ {
+ NULL_POINTER_EXCEPTION();
+ }
+ }
+ VMBREAK(COP_PREFIX_APPEND_CHAR);
#endif /* IL_CVM_PREFIX */
Index: cvm_lengths.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/engine/cvm_lengths.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -r1.9 -r1.10
*** cvm_lengths.c 22 Feb 2003 12:02:57 -0000 1.9
--- cvm_lengths.c 23 Feb 2003 04:24:11 -0000 1.10
***************
*** 501,504 ****
--- 501,505 ----
/* monitor_enter */ CVMP_LEN_NONE,
/* monitor_exit */ CVMP_LEN_NONE,
+ /* append_char */ CVMP_LEN_PTR,
/*
***************
*** 526,530 ****
* Reserved opcodes.
*/
- /* preserved_56 */ CVMP_LEN_NONE,
/* preserved_57 */ CVMP_LEN_NONE,
/* preserved_58 */ CVMP_LEN_NONE,
--- 527,530 ----
Index: cvmc_call.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/engine/cvmc_call.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -C2 -r1.22 -r1.23
*** cvmc_call.c 27 Dec 2002 12:25:09 -0000 1.22
--- cvmc_call.c 23 Feb 2003 04:24:11 -0000 1.23
***************
*** 192,196 ****
}
! static int CVMCoder_CallInlineable(ILCoder *coder, int inlineType)
{
/* Inline methods cannot be tail calls */
--- 192,197 ----
}
! static int CVMCoder_CallInlineable(ILCoder *coder, int inlineType,
! ILMethod
*methodInfo)
{
/* Inline methods cannot be tail calls */
***************
*** 347,350 ****
--- 348,360 ----
CVMP_OUT_WORD(COP_PREFIX_SET2D,
CVM_WORDS_PER_NATIVE_FLOAT);
CVM_OUT_NONE(COP_DWRITE);
+ return 1;
+ }
+ /* Not reached */
+
+ case IL_INLINEMETHOD_BUILDER_APPEND_CHAR:
+ {
+ /* Concatenate four string objects */
+ CVMP_OUT_PTR(COP_PREFIX_APPEND_CHAR, methodInfo);
+ CVM_ADJUST(-1);
return 1;
}
Index: lib_defs.h
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/engine/lib_defs.h,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -r1.19 -r1.20
*** lib_defs.h 6 Feb 2003 03:26:13 -0000 1.19
--- lib_defs.h 23 Feb 2003 04:24:11 -0000 1.20
***************
*** 50,53 ****
--- 50,64 ----
/*
+ * Internal structure of a string builder.
+ */
+ typedef struct
+ {
+ System_String *buildString;
+ ILInt32 maxCapacity;
+ ILBool needsCopy;
+
+ } System_Text_StringBuilder;
+
+ /*
* Internal structure of an array header, padded to the best alignment.
*/
Index: null_coder.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/engine/null_coder.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -r1.16 -r1.17
*** null_coder.c 23 Feb 2003 03:53:50 -0000 1.16
--- null_coder.c 23 Feb 2003 04:24:11 -0000 1.17
***************
*** 297,301 ****
{
}
! static int Coder_CallInlineable(ILCoder *coder, int inlineType)
{
return 0;
--- 297,302 ----
{
}
! static int Coder_CallInlineable(ILCoder *coder, int inlineType,
! ILMethod
*methodInfo)
{
return 0;
Index: verify_call.c
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnet/engine/verify_call.c,v
retrieving revision 1.31
retrieving revision 1.32
diff -C2 -r1.31 -r1.32
*** verify_call.c 13 Jan 2003 09:55:41 -0000 1.31
--- verify_call.c 23 Feb 2003 04:24:11 -0000 1.32
***************
*** 948,951 ****
--- 948,976 ----
return -1;
}
+ else if(!strcmp(name, "StringBuilder"))
+ {
+ /* Make sure that this is really "System.Text.StringBuilder" */
+ name = ILClass_Namespace(owner);
+ if(!name || strcmp(name, "System.Text") != 0)
+ {
+ return -1;
+ }
+ image = ILClassToImage(owner);
+ systemImage = ILContextGetSystem(ILImageToContext(image));
+ if(systemImage && systemImage != image)
+ {
+ return -1;
+ }
+
+ /* Check for known inlineable methods */
+ name = ILMethod_Name(method);
+ signature = ILMethod_Signature(method);
+ if(!strcmp(name, "Append") &&
+ _ILLookupTypeMatch(signature,
"(Tc)oSystem.Text.StringBuilder;"))
+ {
+ return IL_INLINEMETHOD_BUILDER_APPEND_CHAR;
+ }
+ return -1;
+ }
else if(Is2DArrayClass(owner))
{
***************
*** 1067,1071 ****
inlineType = GetInlineMethodType(methodInfo);
if(inlineType == -1 ||
! !ILCoderCallInlineable(coder, inlineType))
{
ILCoderCallMethod(coder, stack +
stackSize - numParams,
--- 1092,1096 ----
inlineType = GetInlineMethodType(methodInfo);
if(inlineType == -1 ||
! !ILCoderCallInlineable(coder, inlineType,
methodInfo))
{
ILCoderCallMethod(coder, stack +
stackSize - numParams,
***************
*** 1250,1254 ****
inlineType =
GetInlineMethodType(methodInfo);
if(inlineType == -1 ||
! !ILCoderCallInlineable(coder,
inlineType))
{
if(numParams > 0 &&
!ILMethod_IsStatic(methodInfo) &&
--- 1275,1279 ----
inlineType =
GetInlineMethodType(methodInfo);
if(inlineType == -1 ||
! !ILCoderCallInlineable(coder,
inlineType, methodInfo))
{
if(numParams > 0 &&
!ILMethod_IsStatic(methodInfo) &&
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Dotgnu-pnet-commits] CVS: pnet/engine cvm.h,1.40,1.41 cvm_dasm.c,1.46,1.47 cvm_inline.c,1.10,1.11 cvm_lengths.c,1.9,1.10 cvmc_call.c,1.22,1.23 lib_defs.h,1.19,1.20 null_coder.c,1.16,1.17 verify_call.c,1.31,1.32,
Rhys Weatherley <address@hidden> <=