source: dev/BasicCompiler_Common/gc.cpp@ 32

Last change on this file since 32 was 11, checked in by dai_9181, 18 years ago

Const変数の書き込み規制を有効化(グローバル/ローカル変数のみ)
定数オブジェクトと定数メンバは未実装。

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