[pypy-svn] r68662 - in pypy/branch/msvc-asmgcroot/pypy/translator: c c/gcc c/gcc/test c/gcc/test/msvc platform

afa at codespeak.net afa at codespeak.net
Tue Oct 20 17:22:40 CEST 2009


Author: afa
Date: Tue Oct 20 17:22:39 2009
New Revision: 68662

Added:
   pypy/branch/msvc-asmgcroot/pypy/translator/c/gcc/test/msvc/track8.s
Modified:
   pypy/branch/msvc-asmgcroot/pypy/translator/c/gcc/instruction.py
   pypy/branch/msvc-asmgcroot/pypy/translator/c/gcc/test/msvc/track0.s
   pypy/branch/msvc-asmgcroot/pypy/translator/c/gcc/test/test_asmgcroot.py
   pypy/branch/msvc-asmgcroot/pypy/translator/c/gcc/trackgcroot.py
   pypy/branch/msvc-asmgcroot/pypy/translator/c/genc.py
   pypy/branch/msvc-asmgcroot/pypy/translator/platform/windows.py
Log:
More progress, now gcroots are tracked, still does not work


Modified: pypy/branch/msvc-asmgcroot/pypy/translator/c/gcc/instruction.py
==============================================================================
--- pypy/branch/msvc-asmgcroot/pypy/translator/c/gcc/instruction.py	(original)
+++ pypy/branch/msvc-asmgcroot/pypy/translator/c/gcc/instruction.py	Tue Oct 20 17:22:39 2009
@@ -10,6 +10,7 @@
 REG2LOC = {}
 for _i, _reg in enumerate(CALLEE_SAVE_REGISTERS):
     REG2LOC[_reg] = LOC_REG | (_i<<2)
+    REG2LOC[_reg[1:]] = LOC_REG | (_i<<2)
 
 def frameloc(base, offset):
     assert base in (LOC_EBP_BASED, LOC_ESP_BASED)

Modified: pypy/branch/msvc-asmgcroot/pypy/translator/c/gcc/test/msvc/track0.s
==============================================================================
--- pypy/branch/msvc-asmgcroot/pypy/translator/c/gcc/test/msvc/track0.s	(original)
+++ pypy/branch/msvc-asmgcroot/pypy/translator/c/gcc/test/msvc/track0.s	Tue Oct 20 17:22:39 2009
@@ -1,3 +1,10 @@
+; Function compile flags: /Ogtpy
+;	COMDAT _pypy_g_ll_join_strs__Signed_arrayPtr
+_TEXT	SEGMENT
+_l_result_2$ = -8					; size = 4
+_l_v405$ = -4						; size = 4
+_l_num_items_0$ = 8					; size = 4
+_l_items_2$ = 12					; size = 4
 _pypy_g_ll_join_strs__Signed_arrayPtr PROC		; COMDAT
 
 ; 1457 : struct pypy_rpy_string0 *pypy_g_ll_join_strs__Signed_arrayPtr(long l_num_items_0, struct pypy_array0 *l_items_2) {
@@ -57,7 +64,7 @@
 	jl	SHORT $LN15 at pypy_g_ll_@139
 $LN14 at pypy_g_ll_@139:
 	call	_RPyAbort
-    ;; expected {24(%esp) | %ebx, %esi, %edi, %ebp | }
+    ;; expected {24(%esp) | %ebx, %esi, %edi, %ebp | 32(%esp)}
 $LN15 at pypy_g_ll_@139:
 
 ; 1529 : 	l_v420 = l_v419;
@@ -69,7 +76,7 @@
 	test	ebx, ebx
 	jne	SHORT $LN16 at pypy_g_ll_@139
 	call	_RPyAbort
-    ;; expected {24(%esp) | %ebx, %esi, %edi, %ebp | }
+    ;; expected {24(%esp) | %ebx, %esi, %edi, %ebp | 32(%esp)}
 $LN16 at pypy_g_ll_@139:
 
 ; 1531 : 	OP_INT_ADD(l_v402, l_v421, l_v422);
@@ -99,7 +106,7 @@
 
 	push	edi
 	call	_pypy_g_mallocstr__Signed
-    ;; expected {28(%esp) | %ebx, %esi, %edi, %ebp | }
+    ;; expected {28(%esp) | %ebx, %esi, %edi, %ebp | 36(%esp)}
 
 ; 1486 : 	l_v405 = (void*)l_items_2;
 

Added: pypy/branch/msvc-asmgcroot/pypy/translator/c/gcc/test/msvc/track8.s
==============================================================================
--- (empty file)
+++ pypy/branch/msvc-asmgcroot/pypy/translator/c/gcc/test/msvc/track8.s	Tue Oct 20 17:22:39 2009
@@ -0,0 +1,528 @@
+; Function compile flags: /Ogtpy
+;	COMDAT _pypy_g_foo
+_TEXT	SEGMENT
+tv419 = -8						; size = 4
+_l_v416$ = -4						; size = 4
+_l_v413$ = -4						; size = 4
+_l_v410$ = -4						; size = 4
+_l_v407$ = -4						; size = 4
+_l_v404$ = -4						; size = 4
+_l_v401$ = -4						; size = 4
+_l_v394$ = -4						; size = 4
+_l_v391$ = -4						; size = 4
+_l_v388$ = -4						; size = 4
+_l_v385$ = -4						; size = 4
+_l_v382$ = -4						; size = 4
+_l_v379$ = -4						; size = 4
+_l_v376$ = -4						; size = 4
+_l_v368$ = -4						; size = 4
+_l_v365$ = -4						; size = 4
+_l_v362$ = -4						; size = 4
+_l_v359$ = -4						; size = 4
+_l_v356$ = -4						; size = 4
+_l_v353$ = -4						; size = 4
+_local$40423 = 8					; size = 1
+_l_rec_1$ = 8						; size = 4
+_l_a1_1$ = 12						; size = 4
+_l_a2_1$ = 16						; size = 4
+_l_a3_1$ = 20						; size = 4
+_l_a4_1$ = 24						; size = 4
+_l_a5_1$ = 28						; size = 4
+_l_a6_1$ = 32						; size = 4
+_pypy_g_foo PROC					; COMDAT
+
+; 1026 : 	bool_t l_v337; bool_t l_v340; bool_t l_v345; bool_t l_v346;
+; 1027 : 	bool_t l_v371; bool_t l_v398; bool_t l_v420; bool_t l_v426;
+; 1028 : 	long l_v342; long l_v344; long l_v374; long l_v399; long l_v421;
+; 1029 : 	struct pypy_header0 *l_v347; struct pypy_object0 *l_v372;
+; 1030 : 	struct pypy_object_vtable0 *l_v339;
+; 1031 : 	struct pypy_object_vtable0 *l_v397;
+; 1032 : 	struct pypy_object_vtable0 *l_v419;
+; 1033 : 	struct pypy_object_vtable0 *l_v425; struct pypy_src8_A0 *l_v335;
+; 1034 : 	void* l_v336; void* l_v341; void* l_v343; void* l_v349; void* l_v351;
+; 1035 : 	void* l_v352; void* l_v353; void* l_v354; void* l_v356; void* l_v357;
+; 1036 : 	void* l_v359; void* l_v360; void* l_v362; void* l_v363; void* l_v365;
+; 1037 : 	void* l_v366; void* l_v368; void* l_v369; void* l_v376; void* l_v377;
+; 1038 : 	void* l_v379; void* l_v380; void* l_v382; void* l_v383; void* l_v385;
+; 1039 : 	void* l_v386; void* l_v388; void* l_v389; void* l_v391; void* l_v392;
+; 1040 : 	void* l_v394; void* l_v395; void* l_v401; void* l_v402; void* l_v404;
+; 1041 : 	void* l_v405; void* l_v407; void* l_v408; void* l_v410; void* l_v411;
+; 1042 : 	void* l_v413; void* l_v414; void* l_v416; void* l_v417; void* l_v424;
+; 1043 : 	void* l_v428;
+; 1044 : 
+; 1045 :     block0:
+; 1046 : 	OP_INT_GT(l_rec_1, 0L, l_v337);
+
+	mov	eax, DWORD PTR _l_rec_1$[esp-4]
+	sub	esp, 8
+	test	eax, eax
+$block0$34376:
+
+; 1047 : 	if (l_v337) {
+
+	jle	$block1$34379
+	push	ebx
+	mov	ebx, DWORD PTR _l_a2_1$[esp+8]
+	push	ebp
+	mov	ebp, DWORD PTR _l_a1_1$[esp+12]
+	push	edi
+	mov	edi, DWORD PTR _l_a3_1$[esp+16]
+	add	eax, -1
+	mov	DWORD PTR tv419[esp+20], eax
+	push	esi
+	npad	10
+$LL63 at pypy_g_foo:
+
+; 1048 : 		goto block2;
+; 1049 : 	}
+; 1050 : 	goto block1;
+; 1051 : 
+; 1052 :     block1:
+; 1053 : 	RPY_DEBUG_RETURN();
+; 1054 : 	return /* nothing */;
+; 1055 : 
+; 1056 :     block2:
+; 1057 : 	pypy_g_stack_check___();
+
+	lea	eax, DWORD PTR _local$40423[esp+20]
+	sub	eax, DWORD PTR __LLstacktoobig_stack_base_pointer
+$block0$40413:
+	cmp	eax, DWORD PTR __LLstacktoobig_stack_min
+$block2$34378:
+	jl	SHORT $LN16 at pypy_g_foo
+	cmp	eax, DWORD PTR __LLstacktoobig_stack_max
+	jle	SHORT $LN17 at pypy_g_foo
+$LN16 at pypy_g_foo:
+	call	_LL_stack_too_big_slowpath
+	;; expected {24(%esp) | %ebx, %esi, %edi, %ebp | %ebx, %edi, %ebp, 44(%esp), 48(%esp), 52(%esp)}
+	test	eax, eax
+	jne	$LN71 at pypy_g_foo
+$LN17 at pypy_g_foo:
+$block1$40416:
+
+; 1058 : 	l_v339 = RPyField((&pypy_g_ExcData), ed_exc_type);
+; 1059 : 	l_v340 = (l_v339 == NULL);
+
+	cmp	DWORD PTR _pypy_g_ExcData, 0
+
+; 1060 : 	if (!l_v340) {
+
+	jne	$LN75 at pypy_g_foo
+
+; 1061 : 		goto block1;
+; 1062 : 	}
+; 1063 : 	goto block3;
+; 1064 : 
+; 1065 :     block3:
+; 1066 : 	l_v341 = RPyField((&pypy_g_pypy_rpython_memory_gc_semispace_SemiSpaceGC), ssgc_inst_free);
+
+	mov	esi, DWORD PTR _pypy_g_pypy_rpython_memory_gc_semispace_SemiSpaceGC+12
+
+; 1067 : 	OP_RAW_MALLOC_USAGE((0 + ROUND_UP_FOR_ALLOCATION(sizeof(struct pypy_src8_A0), sizeof(struct pypy_forwarding_stub0))), l_v342);
+; 1068 : 	l_v343 = RPyField((&pypy_g_pypy_rpython_memory_gc_semispace_SemiSpaceGC), ssgc_inst_top_of_space);
+; 1069 : 	OP_ADR_DELTA(l_v343, l_v341, l_v344);
+
+	mov	eax, DWORD PTR _pypy_g_pypy_rpython_memory_gc_semispace_SemiSpaceGC+80
+	sub	eax, esi
+
+; 1070 : 	OP_INT_GT(l_v342, l_v344, l_v345);
+
+	cmp	eax, 8
+$block3$34382:
+
+; 1071 : 	if (l_v345) {
+
+	jge	SHORT $block4$34395
+
+; 1184 : 	goto block1;
+; 1185 : 
+; 1186 :     block10:
+; 1187 : 	abort();  /* debug_llinterpcall should be unreachable */
+; 1188 : 	goto block5;
+; 1189 : 
+; 1190 :     block11:
+; 1191 : 	l_v424 = pypy_g_SemiSpaceGC_obtain_free_space((&pypy_g_pypy_rpython_memory_gc_semispace_SemiSpaceGC), (0 + ROUND_UP_FOR_ALLOCATION(sizeof(struct pypy_src8_A0), sizeof(struct pypy_forwarding_stub0))));
+
+	push	8
+	push	OFFSET _pypy_g_pypy_rpython_memory_gc_semispace_SemiSpaceGC
+$block11$34394:
+	call	_pypy_g_SemiSpaceGC_obtain_free_space
+	;; expected {32(%esp) | %ebx, %esi, %edi, %ebp | %ebx, %edi, %ebp, 52(%esp), 56(%esp), 60(%esp)}
+	add	esp, 8
+
+; 1192 : 	l_v425 = RPyField((&pypy_g_ExcData), ed_exc_type);
+; 1193 : 	l_v426 = (l_v425 == NULL);
+
+	cmp	DWORD PTR _pypy_g_ExcData, 0
+
+; 1194 : 	if (!l_v426) {
+
+	je	SHORT $LN1 at pypy_g_foo
+
+; 1195 : 		l_v428 = NULL;
+
+	xor	esi, esi
+
+; 1196 : 		goto block6;
+
+	jmp	SHORT $block6$34416
+$LN1 at pypy_g_foo:
+
+; 1197 : 	}
+; 1198 : 	l_v336 = l_v424;
+
+	mov	esi, eax
+$block4$34395:
+
+; 1072 : 		goto block11;
+; 1073 : 	}
+; 1074 : 	l_v336 = l_v341;
+; 1075 : 	goto block4;
+; 1076 : 
+; 1077 :     block4:
+; 1078 : 	OP_INT_IS_TRUE(RUNNING_ON_LLINTERP, l_v346);
+; 1079 : 	if (l_v346) {
+; 1080 : 		goto block10;
+; 1081 : 	}
+; 1082 : 	goto block5;
+; 1083 : 
+; 1084 :     block5:
+; 1085 : 	l_v347 = (struct pypy_header0 *)l_v336;
+; 1086 : 	RPyField(l_v347, h_tid) = (GROUP_MEMBER_OFFSET(struct group_pypy_g_typeinfo_s, member1)|0L);
+; 1087 : 	OP_ADR_ADD(l_v336, (0 + ROUND_UP_FOR_ALLOCATION(sizeof(struct pypy_src8_A0), sizeof(struct pypy_forwarding_stub0))), l_v349);
+
+	lea	ecx, DWORD PTR [esi+8]
+	mov	DWORD PTR [esi], 1
+$block5$34398:
+
+; 1088 : 	RPyField((&pypy_g_pypy_rpython_memory_gc_semispace_SemiSpaceGC), ssgc_inst_free) = l_v349;
+
+	mov	DWORD PTR _pypy_g_pypy_rpython_memory_gc_semispace_SemiSpaceGC+12, ecx
+$block6$34416:
+
+; 1089 : 	OP_ADR_ADD(l_v336, 0, l_v351);
+; 1090 : 	l_v352 = (void*)l_v351;
+; 1091 : 	l_v428 = l_v352;
+; 1092 : 	goto block6;
+; 1093 : 
+; 1094 :     block6:
+; 1095 : 	l_v353 = (void*)l_a2_1;
+
+	mov	DWORD PTR _l_v353$[esp+24], ebx
+
+; 1096 : 	l_v354 = pypy_asm_gcroot(l_v353);
+
+	test	DWORD PTR _l_v353$[esp+24], 0
+
+; 1097 : 	l_a2_1 = l_v354; /* for moving GCs */
+; 1098 : 	l_v356 = (void*)l_a5_1;
+
+	mov	edx, DWORD PTR _l_a5_1$[esp+20]
+	mov	DWORD PTR _l_v356$[esp+24], edx
+
+; 1099 : 	l_v357 = pypy_asm_gcroot(l_v356);
+
+	test	DWORD PTR _l_v356$[esp+24], 0
+
+; 1100 : 	l_a5_1 = l_v357; /* for moving GCs */
+; 1101 : 	l_v359 = (void*)l_a6_1;
+
+	mov	eax, DWORD PTR _l_a6_1$[esp+20]
+	mov	DWORD PTR _l_v359$[esp+24], eax
+
+; 1102 : 	l_v360 = pypy_asm_gcroot(l_v359);
+
+	test	DWORD PTR _l_v359$[esp+24], 0
+
+; 1103 : 	l_a6_1 = l_v360; /* for moving GCs */
+; 1104 : 	l_v362 = (void*)l_a1_1;
+
+	mov	DWORD PTR _l_v362$[esp+24], ebp
+
+; 1105 : 	l_v363 = pypy_asm_gcroot(l_v362);
+
+	test	DWORD PTR _l_v362$[esp+24], 0
+
+; 1106 : 	l_a1_1 = l_v363; /* for moving GCs */
+; 1107 : 	l_v365 = (void*)l_a3_1;
+
+	mov	DWORD PTR _l_v365$[esp+24], edi
+
+; 1108 : 	l_v366 = pypy_asm_gcroot(l_v365);
+
+	test	DWORD PTR _l_v365$[esp+24], 0
+
+; 1109 : 	l_a3_1 = l_v366; /* for moving GCs */
+; 1110 : 	l_v368 = (void*)l_a4_1;
+
+	mov	ecx, DWORD PTR _l_a4_1$[esp+20]
+	mov	DWORD PTR _l_v368$[esp+24], ecx
+
+; 1111 : 	l_v369 = pypy_asm_gcroot(l_v368);
+
+	test	DWORD PTR _l_v368$[esp+24], 0
+
+; 1112 : 	l_a4_1 = l_v369; /* for moving GCs */
+; 1113 : 	l_v335 = (struct pypy_src8_A0 *)l_v428;
+; 1114 : 	l_v371 = (l_v335 != NULL);
+
+	test	esi, esi
+
+; 1115 : 	if (!l_v371) {
+
+	je	$LN75 at pypy_g_foo
+
+; 1116 : 		goto block1;
+; 1117 : 	}
+; 1118 : 	goto block7;
+; 1119 : 
+; 1120 :     block7:
+; 1121 : 	l_v372 = (struct pypy_object0 *)l_v335;
+; 1122 : 	RPyField(l_v372, o_typeptr) = (&pypy_g_src8_A_vtable.a_super);
+; 1123 : 	OP_INT_SUB(l_rec_1, 1L, l_v374);
+; 1124 : 	pypy_g_foo(l_v374, l_v335, l_v335, l_v335, l_v335, l_v335, l_v335);
+
+	mov	edx, DWORD PTR tv419[esp+24]
+	push	esi
+	push	esi
+	push	esi
+	push	esi
+	push	esi
+	push	esi
+	push	edx
+$block7$34426:
+	mov	DWORD PTR [esi+4], OFFSET _pypy_g_src8_A_vtable
+	call	_pypy_g_foo
+	;; expected {52(%esp) | %ebx, %esi, %edi, %ebp | %ebx, %esi, %edi, %ebp, 72(%esp), 76(%esp), 80(%esp)}
+	add	esp, 28					; 0000001cH
+
+; 1125 : 	l_v376 = (void*)l_a2_1;
+
+	mov	DWORD PTR _l_v376$[esp+24], ebx
+
+; 1126 : 	l_v377 = pypy_asm_gcroot(l_v376);
+
+	test	DWORD PTR _l_v376$[esp+24], 0
+
+; 1127 : 	l_a2_1 = l_v377; /* for moving GCs */
+; 1128 : 	l_v379 = (void*)l_a6_1;
+
+	mov	eax, DWORD PTR _l_a6_1$[esp+20]
+	mov	DWORD PTR _l_v379$[esp+24], eax
+
+; 1129 : 	l_v380 = pypy_asm_gcroot(l_v379);
+
+	test	DWORD PTR _l_v379$[esp+24], 0
+
+; 1130 : 	l_a6_1 = l_v380; /* for moving GCs */
+; 1131 : 	l_v382 = (void*)l_a1_1;
+
+	mov	DWORD PTR _l_v382$[esp+24], ebp
+
+; 1132 : 	l_v383 = pypy_asm_gcroot(l_v382);
+
+	test	DWORD PTR _l_v382$[esp+24], 0
+
+; 1133 : 	l_a1_1 = l_v383; /* for moving GCs */
+; 1134 : 	l_v385 = (void*)l_v335;
+
+	mov	DWORD PTR _l_v385$[esp+24], esi
+
+; 1135 : 	l_v386 = pypy_asm_gcroot(l_v385);
+
+	test	DWORD PTR _l_v385$[esp+24], 0
+
+; 1136 : 	l_v335 = l_v386; /* for moving GCs */
+; 1137 : 	l_v388 = (void*)l_a3_1;
+
+	mov	DWORD PTR _l_v388$[esp+24], edi
+
+; 1138 : 	l_v389 = pypy_asm_gcroot(l_v388);
+
+	test	DWORD PTR _l_v388$[esp+24], 0
+
+; 1139 : 	l_a3_1 = l_v389; /* for moving GCs */
+; 1140 : 	l_v391 = (void*)l_a5_1;
+
+	mov	ecx, DWORD PTR _l_a5_1$[esp+20]
+	mov	DWORD PTR _l_v391$[esp+24], ecx
+
+; 1141 : 	l_v392 = pypy_asm_gcroot(l_v391);
+
+	test	DWORD PTR _l_v391$[esp+24], 0
+
+; 1142 : 	l_a5_1 = l_v392; /* for moving GCs */
+; 1143 : 	l_v394 = (void*)l_a4_1;
+
+	mov	edx, DWORD PTR _l_a4_1$[esp+20]
+	mov	DWORD PTR _l_v394$[esp+24], edx
+
+; 1144 : 	l_v395 = pypy_asm_gcroot(l_v394);
+
+	test	DWORD PTR _l_v394$[esp+24], 0
+
+; 1145 : 	l_a4_1 = l_v395; /* for moving GCs */
+; 1146 : 	l_v397 = RPyField((&pypy_g_ExcData), ed_exc_type);
+; 1147 : 	l_v398 = (l_v397 == NULL);
+
+	cmp	DWORD PTR _pypy_g_ExcData, 0
+
+; 1148 : 	if (!l_v398) {
+
+	jne	$LN75 at pypy_g_foo
+
+; 1149 : 		goto block1;
+; 1150 : 	}
+; 1151 : 	goto block8;
+; 1152 : 
+; 1153 :     block8:
+; 1154 : 	OP_INT_SUB(l_rec_1, 1L, l_v399);
+; 1155 : 	pypy_g_foo(l_v399, l_v335, l_v335, l_v335, l_v335, l_v335, l_v335);
+
+	mov	eax, DWORD PTR tv419[esp+24]
+	push	esi
+	push	esi
+	push	esi
+	push	esi
+	push	esi
+	push	esi
+	push	eax
+$block8$34437:
+	call	_pypy_g_foo
+	;; expected {52(%esp) | %ebx, %esi, %edi, %ebp | %ebx, %edi, %ebp, 72(%esp), 76(%esp), 80(%esp)}
+	add	esp, 28					; 0000001cH
+
+; 1156 : 	l_v401 = (void*)l_a2_1;
+
+	mov	DWORD PTR _l_v401$[esp+24], ebx
+
+; 1157 : 	l_v402 = pypy_asm_gcroot(l_v401);
+
+	test	DWORD PTR _l_v401$[esp+24], 0
+
+; 1158 : 	l_a2_1 = l_v402; /* for moving GCs */
+; 1159 : 	l_v404 = (void*)l_a1_1;
+
+	mov	DWORD PTR _l_v404$[esp+24], ebp
+
+; 1160 : 	l_v405 = pypy_asm_gcroot(l_v404);
+
+	test	DWORD PTR _l_v404$[esp+24], 0
+
+; 1161 : 	l_a1_1 = l_v405; /* for moving GCs */
+; 1162 : 	l_v407 = (void*)l_a3_1;
+
+	mov	DWORD PTR _l_v407$[esp+24], edi
+
+; 1163 : 	l_v408 = pypy_asm_gcroot(l_v407);
+
+	test	DWORD PTR _l_v407$[esp+24], 0
+
+; 1164 : 	l_a3_1 = l_v408; /* for moving GCs */
+; 1165 : 	l_v410 = (void*)l_a6_1;
+
+	mov	ecx, DWORD PTR _l_a6_1$[esp+20]
+	mov	DWORD PTR _l_v410$[esp+24], ecx
+
+; 1166 : 	l_v411 = pypy_asm_gcroot(l_v410);
+
+	test	DWORD PTR _l_v410$[esp+24], 0
+
+; 1167 : 	l_a6_1 = l_v411; /* for moving GCs */
+; 1168 : 	l_v413 = (void*)l_a5_1;
+
+	mov	edx, DWORD PTR _l_a5_1$[esp+20]
+	mov	DWORD PTR _l_v413$[esp+24], edx
+
+; 1169 : 	l_v414 = pypy_asm_gcroot(l_v413);
+
+	test	DWORD PTR _l_v413$[esp+24], 0
+
+; 1170 : 	l_a5_1 = l_v414; /* for moving GCs */
+; 1171 : 	l_v416 = (void*)l_a4_1;
+
+	mov	esi, DWORD PTR _l_a4_1$[esp+20]
+	mov	DWORD PTR _l_v416$[esp+24], esi
+
+; 1172 : 	l_v417 = pypy_asm_gcroot(l_v416);
+
+	test	DWORD PTR _l_v416$[esp+24], 0
+
+; 1173 : 	l_a4_1 = l_v417; /* for moving GCs */
+; 1174 : 	l_v419 = RPyField((&pypy_g_ExcData), ed_exc_type);
+; 1175 : 	l_v420 = (l_v419 == NULL);
+
+	cmp	DWORD PTR _pypy_g_ExcData, 0
+
+; 1176 : 	if (!l_v420) {
+
+	jne	SHORT $LN75 at pypy_g_foo
+
+; 1177 : 		goto block1;
+; 1178 : 	}
+; 1179 : 	goto block9;
+; 1180 : 
+; 1181 :     block9:
+; 1182 : 	OP_INT_SUB(l_rec_1, 1L, l_v421);
+; 1183 : 	pypy_g_foo(l_v421, l_a6_1, l_a5_1, l_a4_1, l_a3_1, l_a2_1, l_a1_1);
+
+	sub	DWORD PTR _l_rec_1$[esp+20], 1
+	sub	DWORD PTR tv419[esp+24], 1
+	cmp	DWORD PTR _l_rec_1$[esp+20], 0
+	mov	eax, ebp
+	mov	ebp, DWORD PTR _l_a6_1$[esp+20]
+	mov	ecx, ebx
+	mov	ebx, DWORD PTR _l_a5_1$[esp+20]
+	mov	edx, edi
+$block9$34446:
+	mov	edi, esi
+	mov	DWORD PTR _l_a4_1$[esp+20], edx
+	mov	DWORD PTR _l_a5_1$[esp+20], ecx
+	mov	DWORD PTR _l_a6_1$[esp+20], eax
+$block0_1$34376:
+	jg	$LL63 at pypy_g_foo
+	pop	esi
+	pop	edi
+	pop	ebp
+	pop	ebx
+
+; 1199 : 	goto block4;
+; 1200 : }
+
+	add	esp, 8
+	ret	0
+$LN71 at pypy_g_foo:
+$block0$40426:
+$block0$40437:
+$block0$40434:
+$block2$40415:
+
+; 1048 : 		goto block2;
+; 1049 : 	}
+; 1050 : 	goto block1;
+; 1051 : 
+; 1052 :     block1:
+; 1053 : 	RPY_DEBUG_RETURN();
+; 1054 : 	return /* nothing */;
+; 1055 : 
+; 1056 :     block2:
+; 1057 : 	pypy_g_stack_check___();
+
+	mov	DWORD PTR _pypy_g_ExcData, OFFSET _pypy_g_exceptions_RuntimeError_vtable
+	mov	DWORD PTR _pypy_g_ExcData+4, OFFSET _pypy_g_exceptions_RuntimeError
+$block1$40435:
+$block1$40438:
+$block1$40427:
+$LN75 at pypy_g_foo:
+	pop	esi
+	pop	edi
+	pop	ebp
+	pop	ebx
+$block1$34379:
+
+; 1199 : 	goto block4;
+; 1200 : }
+
+	add	esp, 8
+	ret	0
+_pypy_g_foo ENDP

Modified: pypy/branch/msvc-asmgcroot/pypy/translator/c/gcc/test/test_asmgcroot.py
==============================================================================
--- pypy/branch/msvc-asmgcroot/pypy/translator/c/gcc/test/test_asmgcroot.py	(original)
+++ pypy/branch/msvc-asmgcroot/pypy/translator/c/gcc/test/test_asmgcroot.py	Tue Oct 20 17:22:39 2009
@@ -51,7 +51,7 @@
 
         def run(arg0, arg1):
             lines = []
-            print >> sys.stderr, 'RUN: starting', exe_name
+            print >> sys.stderr, 'RUN: starting', exe_name, arg0, arg1
             g = os.popen('"%s" %d %d' % (exe_name, arg0, arg1), 'r')
             for line in g:
                 print >> sys.stderr, 'RUN:', line.rstrip()

Modified: pypy/branch/msvc-asmgcroot/pypy/translator/c/gcc/trackgcroot.py
==============================================================================
--- pypy/branch/msvc-asmgcroot/pypy/translator/c/gcc/trackgcroot.py	(original)
+++ pypy/branch/msvc-asmgcroot/pypy/translator/c/gcc/trackgcroot.py	Tue Oct 20 17:22:39 2009
@@ -34,16 +34,10 @@
 r_jmp_source    = re.compile(r"\d*[(](%[\w]+)[,)]")
 r_jmptable_item = re.compile(r"\t.long\t"+LABEL+"(-\"[A-Za-z0-9$]+\")?\s*$")
 r_jmptable_end  = re.compile(r"\t.text|\t.section\s+.text|\t\.align|"+LABEL)
-LOCALVAR        = r"%eax|%edx|%ecx|%ebx|%esi|%edi|%ebp|\d*[(]%esp[)]"
-LOCALVARFP      = LOCALVAR + r"|-?\d*[(]%ebp[)]"
-r_gcroot_marker = re.compile(r"\t/[*] GCROOT ("+LOCALVARFP+") [*]/")
 r_bottom_marker = re.compile(r"\t/[*] GC_STACK_BOTTOM [*]/")
-r_localvarnofp  = re.compile(LOCALVAR)
-r_localvarfp    = re.compile(LOCALVARFP)
-r_localvar_esp  = re.compile(r"(\d*)[(]%esp[)]")
-r_localvar_ebp  = re.compile(r"(-?\d*)[(]%ebp[)]")
 
 class FunctionGcRootTracker(object):
+    skip = 0
 
     @classmethod
     def init_regexp(cls):
@@ -57,7 +51,7 @@
         self.funcname = funcname
         self.lines = lines
         self.uses_frame_pointer = False
-        self.r_localvar = r_localvarnofp
+        self.r_localvar = self.r_localvarnofp
         self.filetag = filetag
         # a "stack bottom" function is either main() or a callback from C code
         self.is_stack_bottom = False
@@ -77,6 +71,9 @@
                 self.dump()
         return self.gettable()
 
+    def replace_symbols(self, operand):
+        return operand
+
     def gettable(self):
         """Returns a list [(label_after_call, callshape_tuple)]
         See format_callshape() for more details about callshape_tuple.
@@ -145,6 +142,8 @@
         self.insns = [InsnFunctionStart()]
         ignore_insns = False
         for lineno, line in enumerate(self.lines):
+            if lineno < self.skip:
+                continue
             self.currentlineno = lineno
             insn = []
             match = r_insn.match(line)
@@ -158,7 +157,7 @@
                         meth = getattr(self, 'visit_' + opname)
                     line = line.rsplit(';', 1)[0]
                     insn = meth(line)
-            elif r_gcroot_marker.match(line):
+            elif self.r_gcroot_marker.match(line):
                 insn = self._visit_gcroot_marker(line)
             elif r_bottom_marker.match(line):
                 self.is_stack_bottom = True
@@ -235,18 +234,20 @@
             elif isinstance(localvar, (list, tuple)):
                 return [fixvar(var) for var in localvar]
 
-            match = r_localvar_esp.match(localvar)
+            match = self.r_localvar_esp.match(localvar)
             if match:
-                if localvar == '0(%esp)': # for pushl and popl, by
-                    hint = None           # default ebp addressing is
-                else:                     # a bit nicer
+                if localvar == self.TOP_OF_STACK: # for pushl and popl, by
+                    hint = None                   # default ebp addressing is
+                else:                             # a bit nicer
                     hint = 'esp'
                 ofs_from_esp = int(match.group(1) or '0')
+                if self.format == 'msvc':
+                    ofs_from_esp += int(match.group(2) or '0')
                 localvar = ofs_from_esp - insn.framesize
                 assert localvar != 0    # that's the return address
                 return LocalVar(localvar, hint=hint)
             elif self.uses_frame_pointer:
-                match = r_localvar_ebp.match(localvar)
+                match = self.r_localvar_ebp.match(localvar)
                 if match:
                     ofs_from_ebp = int(match.group(1) or '0')
                     localvar = ofs_from_ebp - 4
@@ -341,9 +342,9 @@
     # ____________________________________________________________
 
     def _visit_gcroot_marker(self, line):
-        match = r_gcroot_marker.match(line)
+        match = self.r_gcroot_marker.match(line)
         loc = match.group(1)
-        return InsnGCROOT(loc)
+        return InsnGCROOT(self.replace_symbols(loc))
 
     def visit_nop(self, line):
         return []
@@ -449,7 +450,7 @@
         if target == self.ESP:
             # only for  leal -12(%ebp), %esp  in function epilogues
             source = match.group("source")
-            match = r_localvar_ebp.match(source)
+            match = self.r_localvar_ebp.match(source)
             if match:
                 if not self.uses_frame_pointer:
                     raise UnrecognizedOperation('epilogue without prologue')
@@ -457,7 +458,7 @@
                 assert ofs_from_ebp <= 0
                 framesize = 4 - ofs_from_ebp
             else:
-                match = r_localvar_esp.match(source)
+                match = self.r_localvar_esp.match(source)
                 # leal 12(%esp), %esp
                 if match:
                     return InsnStackAdjust(int(match.group(1)))
@@ -468,6 +469,8 @@
             return self.binary_insn(line)
 
     def insns_for_copy(self, source, target):
+        source = self.replace_symbols(source)
+        target = self.replace_symbols(target)
         if source == self.ESP or target == self.ESP:
             raise UnrecognizedOperation('%s -> %s' % (source, target))
         elif self.r_localvar.match(target):
@@ -482,22 +485,22 @@
         match = self.r_binaryinsn.match(line)
         source = match.group("source")
         target = match.group("target")
-        if source == self.ESP and target == '%ebp':
+        if source == self.ESP and target == self.EBP:
             return self._visit_prologue()
-        elif source == '%ebp' and target == self.ESP:
+        elif source == self.EBP and target == self.ESP:
             return self._visit_epilogue()
         return self.insns_for_copy(source, target)
 
     def visit_pushl(self, line):
         match = self.r_unaryinsn.match(line)
         source = match.group(1)
-        return [InsnStackAdjust(-4)] + self.insns_for_copy(source, '0(%esp)')
+        return [InsnStackAdjust(-4)] + self.insns_for_copy(source, self.TOP_OF_STACK)
 
     def visit_pushw(self, line):
         return [InsnStackAdjust(-2)]   # rare but not impossible
 
     def _visit_pop(self, target):
-        return self.insns_for_copy('0(%esp)', target) + [InsnStackAdjust(+4)]
+        return self.insns_for_copy(self.TOP_OF_STACK, target) + [InsnStackAdjust(+4)]
 
     def visit_popl(self, line):
         match = self.r_unaryinsn.match(line)
@@ -507,7 +510,7 @@
     def _visit_prologue(self):
         # for the prologue of functions that use %ebp as frame pointer
         self.uses_frame_pointer = True
-        self.r_localvar = r_localvarfp
+        self.r_localvar = self.r_localvarfp
         return [InsnPrologue()]
 
     def _visit_epilogue(self):
@@ -516,7 +519,7 @@
         return [InsnEpilogue(4)]
 
     def visit_leave(self, line):
-        return self._visit_epilogue() + self._visit_pop('%ebp')
+        return self._visit_epilogue() + self._visit_pop(self.EBP)
 
     def visit_ret(self, line):
         return InsnRet()
@@ -542,7 +545,7 @@
                         # if the source looks like 8(%eax,%edx,4)
                         # %eax is the real source, %edx is an offset.
                         match = r_jmp_source.match(s)
-                        if match and not r_localvar_esp.match(s):
+                        if match and not self.r_localvar_esp.match(s):
                             sources.append(match.group(1))
                         else:
                             sources.append(s)
@@ -648,13 +651,13 @@
                     assert  lineoffset in (1,2)
                     return [InsnStackAdjust(-4)]
         insns = [InsnCall(self.currentlineno),
-                 InsnSetLocal('%eax')]      # the result is there
+                 InsnSetLocal(self.EAX)]      # the result is there
         if sys.platform == 'win32':
             # handle __stdcall calling convention:
             # Stack cleanup is performed by the called function,
             # Function name is decorated with "@N" where N is the stack size
             if match and '@' in target:
-                insns.append(InsnStackAdjust(int(target.split('@')[1])))
+                insns.append(InsnStackAdjust(int(target.rsplit('@', 1)[1])))
         return insns
 
 
@@ -662,11 +665,21 @@
     format = 'elf'
 
     ESP     = '%esp'
+    EBP     = '%ebp'
+    EAX     = '%eax'
     OPERAND = r'(?:[-\w$%+.:@"]+(?:[(][\w%,]+[)])?|[(][\w%,]+[)])'
     LABEL   = r'([a-zA-Z_$.][a-zA-Z0-9_$@.]*)'
+    TOP_OF_STACK = '0(%esp)'
 
     r_functionstart = re.compile(r"\t.type\s+"+LABEL+",\s*[@]function\s*$")
     r_functionend   = re.compile(r"\t.size\s+"+LABEL+",\s*[.]-"+LABEL+"\s*$")
+    LOCALVAR        = r"%eax|%edx|%ecx|%ebx|%esi|%edi|%ebp|\d*[(]%esp[)]"
+    LOCALVARFP      = LOCALVAR + r"|-?\d*[(]%ebp[)]"
+    r_localvarnofp  = re.compile(LOCALVAR)
+    r_localvarfp    = re.compile(LOCALVARFP)
+    r_gcroot_marker = re.compile(r"\t/[*] GCROOT ("+LOCALVARFP+") [*]/")
+    r_localvar_esp  = re.compile(r"(\d*)[(]%esp[)]")
+    r_localvar_ebp  = re.compile(r"(-?\d*)[(]%ebp[)]")
 
     def __init__(self, lines, filetag=0):
         match = self.r_functionstart.match(lines[0])
@@ -700,14 +713,27 @@
 class MsvcFunctionGcRootTracker(FunctionGcRootTracker):
     format = 'msvc'
 
-    r_functionstart = re.compile(LABEL+r"\s+PROC\s*(:?;.+)\n$")
-    r_functionend   = re.compile(LABEL+r"\s+ENDP\s*$")
-
     ESP = 'esp'
+    EBP = 'ebp'
+    EAX = 'eax'
+    TOP_OF_STACK = 'DWORD PTR [esp]'
 
-    OPERAND = r'(?:(:?WORD|DWORD|BYTE) PTR |OFFSET )?[_\w?@$]*(?:[-+0-9]+)?(:?\[[-+*\w0-9]+\])?'
+    OPERAND = r'(?:(:?WORD|DWORD|BYTE) PTR |OFFSET )?[_\w?:@$]*(?:[-+0-9]+)?(:?\[[-+*\w0-9]+\])?'
     LABEL   = r'([a-zA-Z_$.][a-zA-Z0-9_$@.]*)'
 
+    r_functionstart = re.compile(r"; Function compile flags: ")
+    r_codestart     = re.compile(LABEL+r"\s+PROC\s*(:?;.+)?\n$")
+    r_functionend   = re.compile(LABEL+r"\s+ENDP\s*$")
+    r_symboldefine =  re.compile(r"([_a-z0-9]+\$) = ([-0-9]+)\s*;.+\n")
+
+    LOCALVAR        = r"eax|edx|ecx|ebx|esi|edi|ebp|DWORD PTR [-+]?\d*\[esp[-+]\d+\]"
+    LOCALVARFP      = LOCALVAR + r"|-?\d*\[ebp\]"
+    r_localvarnofp  = re.compile(LOCALVAR)
+    r_localvarfp    = re.compile(LOCALVARFP)
+    r_gcroot_marker = re.compile(r";.+ = pypy_asm_gcroot\(")
+    r_localvar_esp  = re.compile(r"DWORD PTR ([-+]?\d+)?\[esp([-+]?\d+)?\]")
+    r_localvar_ebp  = re.compile(r"DWORD PTR ([-+]?\d+)?\[ebp([-+]?\d+)?\]")
+
     @classmethod
     def init_regexp(cls):
         super(MsvcFunctionGcRootTracker, cls).init_regexp()
@@ -715,11 +741,29 @@
         cls.r_jump = re.compile(r"\tj\w+\s+(?:SHORT |DWORD PTR )?"+LABEL+"\s*$")
 
     def __init__(self, lines, filetag=0):
-        match = self.r_functionstart.match(lines[0])
+        self.defines = {}
+        for i, line in enumerate(lines):
+            if self.r_symboldefine.match(line):
+                match = self.r_symboldefine.match(line)
+                name = match.group(1)
+                value = int(match.group(2))
+                self.defines[name] = value
+                continue
+
+            match = self.r_codestart.match(line)
+            if match:
+                self.skip = i
+                break
+
         funcname = match.group(1)
         super(MsvcFunctionGcRootTracker, self).__init__(
             funcname, lines, filetag)
 
+    def replace_symbols(self, operand):
+        for name, value in self.defines.items():
+            operand = operand.replace(name, str(value))
+        return operand
+
     for name in '''
         push pop mov lea
         xor sub add
@@ -737,6 +781,13 @@
         except ValueError:
             return None
 
+    def _visit_gcroot_marker(self, line):
+        assert self.lines[self.currentlineno + 1] == "\n"
+        assert self.lines[self.currentlineno + 2].startswith("\ttest\tDWORD PTR")
+        match = self.r_binaryinsn.match(self.lines[self.currentlineno + 2])
+        loc = match.group("target")
+        return InsnGCROOT(self.replace_symbols(loc))
+
 MsvcFunctionGcRootTracker.init_regexp()
 
 class AssemblerParser(object):
@@ -909,6 +960,9 @@
 
             newlines.append(line)
 
+            if line == "\t.model\tflat\n":
+                newlines.append("\tassume fs:nothing\n")
+
         newfile.writelines(newlines)
 
 PARSERS = {
@@ -982,13 +1036,13 @@
             if self.format == 'msvc':
                 print >> output, "\tpush\t%s\t\t; %s" % (source, comment)
             else:
-                print >> output, "\tpushl\t%s\t\t/* %s */ " % (target, comment)
+                print >> output, "\tpushl\t%s\t\t/* %s */ " % (source, comment)
 
         def _popl(source, comment):
             if self.format == 'msvc':
                 print >> output, "\tpop\t%s\t\t; %s" % (source, comment)
             else:
-                print >> output, "\tpopl\t%s\t\t/* %s */ " % (target, comment)
+                print >> output, "\tpopl\t%s\t\t/* %s */ " % (source, comment)
 
 
         def _register(name, disp=""):
@@ -1332,6 +1386,12 @@
     verbose = 1
     shuffle = False
     output_raw_table = False
+    if sys.platform == 'darwin':
+        format = 'darwin'
+    elif sys.platform == 'win32':
+        format = 'mingw32'
+    else:
+        format = 'elf'
     while len(sys.argv) > 1:
         if sys.argv[1] == '-v':
             del sys.argv[1]
@@ -1342,14 +1402,11 @@
         elif sys.argv[1] == '-t':
             del sys.argv[1]
             output_raw_table = True
+        elif sys.argv[1].startswith('-f'):
+            format = sys.argv[1][2:]
+            del sys.argv[1]
         else:
             break
-    if sys.platform == 'darwin':
-        format = 'darwin'
-    elif sys.platform == 'win32':
-        format = 'msvc'
-    else:
-        format = 'elf'
     tracker = GcRootTracker(verbose=verbose, shuffle=shuffle, format=format)
     for fn in sys.argv[1:]:
         f = open(fn, 'r')

Modified: pypy/branch/msvc-asmgcroot/pypy/translator/c/genc.py
==============================================================================
--- pypy/branch/msvc-asmgcroot/pypy/translator/c/genc.py	(original)
+++ pypy/branch/msvc-asmgcroot/pypy/translator/c/genc.py	Tue Oct 20 17:22:39 2009
@@ -505,13 +505,13 @@
                 mk.definition('OBJECTS', 'gcmaptable.obj $(ASMLBLOBJFILES)')
                 mk.rule('.SUFFIXES', '.s', [])
                 mk.rule('.s.obj', '',
-                        'cmd /c $(MASM) /nologo /Cx /Zm /coff /Fo$@ /c $< $(INCLUDEDIRS)')
+                        'cmd /c $(MASM) /nologo /Cx /Cp /Zm /coff /Fo$@ /c $< $(INCLUDEDIRS)')
                 mk.rule('.c.gcmap', '',
                         ['$(CC) /nologo $(CFLAGS) /c /FAs /Fa$*.s $< $(INCLUDEDIRS)',
-                         'cmd /c ' + python + '$(PYPYDIR)/translator/c/gcc/trackgcroot.py -t $*.s > $@']
+                         'cmd /c ' + python + '$(PYPYDIR)/translator/c/gcc/trackgcroot.py -fmsvc -t $*.s > $@']
                         )
                 mk.rule('gcmaptable.s', '$(GCMAPFILES)',
-                        'cmd /c ' + python + '$(PYPYDIR)/translator/c/gcc/trackgcroot.py $(GCMAPFILES) > $@')
+                        'cmd /c ' + python + '$(PYPYDIR)/translator/c/gcc/trackgcroot.py -fmsvc $(GCMAPFILES) > $@')
             else:
                 mk.definition('OBJECTS', '$(ASMLBLFILES) gcmaptable.s')
                 mk.rule('%.s', '%.c', '$(CC) $(CFLAGS) -frandom-seed=$< -o $@ -S $< $(INCLUDEDIRS)')

Modified: pypy/branch/msvc-asmgcroot/pypy/translator/platform/windows.py
==============================================================================
--- pypy/branch/msvc-asmgcroot/pypy/translator/platform/windows.py	(original)
+++ pypy/branch/msvc-asmgcroot/pypy/translator/platform/windows.py	Tue Oct 20 17:22:39 2009
@@ -241,13 +241,21 @@
 
         rules = [
             ('all', '$(DEFAULT_TARGET)', []),
-            ('$(TARGET)', '$(OBJECTS)', '$(CC_LINK) /nologo $(LDFLAGS) $(OBJECTS) /out:$@ $(LIBDIRS) $(LIBS)'),
             ('.c.o', '', '$(CC) $(CFLAGS) /Fo$@ /c $< $(INCLUDEDIRS)'),
             ]
 
         for rule in rules:
             m.rule(*rule)
 
+        if self.version < 80:
+            m.rule('$(TARGET)', '$(OBJECTS)',
+                   '$(CC_LINK) /nologo $(LDFLAGS) $(OBJECTS) /out:$@ $(LIBDIRS) $(LIBS)')
+        else:
+            m.rule('$(TARGET)', '$(OBJECTS)',
+                   ['$(CC_LINK) /nologo $(LDFLAGS) $(OBJECTS) /out:$@ $(LIBDIRS) $(LIBS) /MANIFESTFILE:$*.manifest',
+                    'mt.exe -nologo -manifest $*.manifest -outputresource:$@;1',
+                    ])
+
         return m
 
     def execute_makefile(self, path_to_makefile):



More information about the Pypy-commit mailing list