[4] | 1 | #include "common.h"
|
---|
| 2 |
|
---|
| 3 | #ifdef _AMD64_
|
---|
| 4 | #include "../BasicCompiler64/opcode.h"
|
---|
| 5 | #else
|
---|
[5] | 6 | #include "../BasicCompiler32/opcode.h"
|
---|
[4] | 7 | #endif
|
---|
| 8 |
|
---|
| 9 | int Schedule_GlobalRoot_StartPtr;
|
---|
| 10 | int Schedule_GlobalRoot_Size;
|
---|
| 11 |
|
---|
| 12 | void 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 | GetVarOffset(1,"_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 | GetVarOffset(1,"_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 | GetVarOffset(1,"_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 |
|
---|
| 80 | void 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 | }
|
---|