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

Last change on this file since 220 was 206, checked in by dai_9181, 17 years ago

コード全体のリファクタリングを実施

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