source: dev/trunk/abdev/BasicCompiler_Common/gc.cpp@ 163

Last change on this file since 163 was 75, checked in by dai_9181, 18 years ago

TYPEINFO→Typeへのリファクタリングを実施。64bitはほぼ完了。32bitが全般的に未完成。

File size: 2.3 KB
Line 
1#include "common.h"
2
3#ifdef _AMD64_
4#include "../BasicCompiler64/opcode.h"
5#else
6#include "../BasicCompiler32/opcode.h"
7#endif
8
9int Schedule_GlobalRoot_StartPtr;
10int Schedule_GlobalRoot_Size;
11
12void InitGCVariables(void){
13 char temporary[255];
14
15
16 ///////////////////////////////
17 // グローバル変数の開始位置
18 ///////////////////////////////
19
20 sprintf(temporary,"_System_gc_GlobalRoot_StartPtr%c%cVoidPtr",1,ESC_AS);
21 OpcodeDim(temporary,0);
22
23 Type type;
24 RELATIVE_VAR RelativeVar;
25 GetVarOffsetReadWrite("_System_gc_GlobalRoot_StartPtr",&RelativeVar,type);
26
27 //mov rax,ptr
28 op_mov_RV(PTR_SIZE,REG_RAX,0);
29 Schedule_GlobalRoot_StartPtr=obp-sizeof(long);
30
31 //mov ptr[offset],rax/eax
32 op_mov_MR(PTR_SIZE,REG_RAX,0,(int)RelativeVar.offset,MOD_DISP32);
33 obp-=sizeof(long);
34 pobj_GlobalVarSchedule->add();
35 obp+=sizeof(long);
36
37
38 ///////////////////////////////
39 // グローバル変数の大きさ
40 ///////////////////////////////
41
42 sprintf(temporary,"_System_gc_GlobalRoot_Size%c%cLong",1,ESC_AS);
43 OpcodeDim(temporary,0);
44
45 GetVarOffsetReadWrite("_System_gc_GlobalRoot_Size",&RelativeVar,type);
46
47 //mov rax,ptr
48 op_mov_RV(PTR_SIZE,REG_RAX,0);
49 Schedule_GlobalRoot_Size=obp-sizeof(long);
50
51 //mov ptr[offset],rax/eax
52 op_mov_MR(PTR_SIZE,REG_RAX,0,(int)RelativeVar.offset,MOD_DISP32);
53 obp-=sizeof(long);
54 pobj_GlobalVarSchedule->add();
55 obp+=sizeof(long);
56
57
58
59 ///////////////////////////////
60 // スタックフレームの開始位置
61 ///////////////////////////////
62
63 sprintf(temporary,"_System_gc_StackRoot_StartPtr%c%c*LONG_PTR",1,ESC_AS);
64 OpcodeDim(temporary,0);
65
66 GetVarOffsetReadWrite("_System_gc_StackRoot_StartPtr",&RelativeVar,type);
67
68 //mov rax,rsp
69 op_mov_RR(REG_RAX,REG_RSP);
70
71 //mov ptr[offset],rax/eax
72 op_mov_MR(PTR_SIZE,REG_RAX,0,(int)RelativeVar.offset,MOD_DISP32);
73 obp-=sizeof(long);
74 pobj_GlobalVarSchedule->add();
75 obp+=sizeof(long);
76
77}
78
79void PerformedGcVarSchedule(void){
80 //グローバル変数領域の開始位置
81 extern DWORD ImageBase;
82 extern int MemPos_RWSection;
83 *((long *)(OpBuffer+Schedule_GlobalRoot_StartPtr))=ImageBase+MemPos_RWSection;
84 pobj_Reloc->AddSchedule_CodeSection(Schedule_GlobalRoot_StartPtr);
85
86 //グローバル変数領域のサイズ
87 extern int AllInitGlobalVarSize;
88 extern int AllGlobalVarSize;
89 *((long *)(OpBuffer+Schedule_GlobalRoot_Size))=AllInitGlobalVarSize+AllGlobalVarSize;
90}
Note: See TracBrowser for help on using the repository browser.