Index: BasicCompiler64/Compile_ProcOp.cpp
===================================================================
--- BasicCompiler64/Compile_ProcOp.cpp	(revision 94)
+++ BasicCompiler64/Compile_ProcOp.cpp	(revision 95)
@@ -205,4 +205,10 @@
 
 			pobj_DBClass->Compile_System_InitializeUserTypes();
+	}
+	else if( userProc.GetName() == "RegisterGlobalRoots"
+		&& userProc.HasParentClass()
+		&& (string)userProc.GetParentClass().name == "_System_CGarbageCollection" ){
+
+			Compile_AddGlobalRootsForGc();
 	}
 	else{
Index: BasicCompiler64/Compile_Var.cpp
===================================================================
--- BasicCompiler64/Compile_Var.cpp	(revision 94)
+++ BasicCompiler64/Compile_Var.cpp	(revision 95)
@@ -1314,2 +1314,38 @@
 	}
 }
+
+bool Compile_AddGlobalRootsForGc(){
+	UserProc *pUserProc_AddGlobalRootPtr = GetClassMethod( "_System_CGarbageCollection", "AddGlobalRootPtr" );
+	if( !pUserProc_AddGlobalRootPtr ){
+		SetError(3, "_System_CGarbageCollection.AddGlobalRootPtr", -1 );
+		return false;
+	}
+
+	BOOST_FOREACH( const Variable *pVar, globalVars ){
+		if( pVar->IsObject() || pVar->IsPointer() || pVar->IsStruct() ){
+			// オブジェクトまたはポインタだったとき
+			// ※構造体も含む（暫定対応）
+
+			// 変数領域に要するLONG_PTR単位の個数を引き渡す
+			//mov r8,count
+			op_mov_RV(sizeof(_int64), REG_R8,pVar->GetMemorySize()/PTR_SIZE);
+
+			// ルートポインタを引き渡す
+			//mov rdx,offset
+			op_mov_RV(sizeof(_int64), REG_RDX,(int)pVar->offset);
+			obp-=sizeof(long);
+			pobj_GlobalVarSchedule->add();
+			obp+=sizeof(long);
+
+			// Thisポインタを引き渡す
+			SetThisPtrToReg(REG_RCX);
+
+			// call AddGlobalRootPtr
+			op_call( pUserProc_AddGlobalRootPtr );
+
+			ReallocNativeCodeBuffer();
+		}
+	}
+
+	return true;
+}
Index: BasicCompiler64/MakePeHdr.cpp
===================================================================
--- BasicCompiler64/MakePeHdr.cpp	(revision 94)
+++ BasicCompiler64/MakePeHdr.cpp	(revision 95)
@@ -6,4 +6,6 @@
 // 特殊関数の構造体ポインタ
 ////////////////////////////
+
+// グローバル関数、静的メソッド
 UserProc
 	*pSub_System_StartupProgram,
@@ -24,4 +26,8 @@
 	*pSub_System_GC_free_for_SweepingDelete,
 	*pSubStaticMethod_System_TypeBase_InitializeUserTypes;
+
+// 動的メソッド
+UserProc
+	*pUserProc_System_CGarbageCollection_RegisterGlobalRoots;
 
 
@@ -231,4 +237,9 @@
 		pSubStaticMethod_System_TypeBase_InitializeUserTypes->Using();
 		pSubStaticMethod_System_TypeBase_InitializeUserTypes->ThisIsAutoGenerationProc();
+	}
+
+	if( pUserProc_System_CGarbageCollection_RegisterGlobalRoots = GetClassMethod( "_System_CGarbageCollection", "RegisterGlobalRoots" ) ){
+		pUserProc_System_CGarbageCollection_RegisterGlobalRoots->Using();
+		pUserProc_System_CGarbageCollection_RegisterGlobalRoots->ThisIsAutoGenerationProc();
 	}
 
Index: BasicCompiler64/Opcode.h
===================================================================
--- BasicCompiler64/Opcode.h	(revision 94)
+++ BasicCompiler64/Opcode.h	(revision 95)
@@ -325,4 +325,5 @@
 void dim( char *VarName,int *SubScripts,Type &type,char *InitBuf,char *ConstractParameter,DWORD dwFlags);
 void SetVarPtrToReg(int reg,RELATIVE_VAR *pRelativeVar);
+bool Compile_AddGlobalRootsForGc();
 
 //ParamImpl.cpp
