| 1 | #include "../BasicCompiler_Common/common.h"
 | 
|---|
| 2 | 
 | 
|---|
| 3 | #ifdef _AMD64_
 | 
|---|
| 4 | #include "../BasicCompiler64/opcode.h"
 | 
|---|
| 5 | #else
 | 
|---|
| 6 | #include "../BasicCompiler32/opcode.h"
 | 
|---|
| 7 | #endif
 | 
|---|
| 8 | 
 | 
|---|
| 9 | 
 | 
|---|
| 10 | void Diagnose(){
 | 
|---|
| 11 |     char temporary[8192];
 | 
|---|
| 12 | 
 | 
|---|
| 13 |     {
 | 
|---|
| 14 |         ///////////////////////////////////////////////////////////////////
 | 
|---|
| 15 |         // グローバル / ローカル コード領域のサイズを調べる
 | 
|---|
| 16 |         ///////////////////////////////////////////////////////////////////
 | 
|---|
| 17 | 
 | 
|---|
| 18 |         extern int obp;
 | 
|---|
| 19 |         extern int GlobalOpBufferSize;
 | 
|---|
| 20 |         sprintf(temporary, "%d", GlobalOpBufferSize/1024 );
 | 
|---|
| 21 |         Smoothie::Logger::Put( (string)"グローバル領域のコードサイズ: " + temporary + "KB" );
 | 
|---|
| 22 |         sprintf(temporary, "%d", (obp-GlobalOpBufferSize)/1024 );
 | 
|---|
| 23 |         Smoothie::Logger::Put( (string)"ローカル領域のコードサイズ: " + temporary + "KB" );
 | 
|---|
| 24 |         sprintf(temporary, "%d", obp/1024 );
 | 
|---|
| 25 |         Smoothie::Logger::Put( (string)"コードサイズ総量: " + temporary + "KB" );
 | 
|---|
| 26 |     }
 | 
|---|
| 27 | 
 | 
|---|
| 28 |     {
 | 
|---|
| 29 |         ///////////////////////////////////////////////////////////////////
 | 
|---|
| 30 |         // グローバル関数、クラスメソッドのサイズを調べる
 | 
|---|
| 31 |         ///////////////////////////////////////////////////////////////////
 | 
|---|
| 32 | 
 | 
|---|
| 33 |         int codeSizeOfGlobalProc = 0;
 | 
|---|
| 34 |         int codeSizeOfClassMethod = 0;
 | 
|---|
| 35 |         for(int i2=0;i2<MAX_HASH;i2++){
 | 
|---|
| 36 |             extern GlobalProc **ppSubHash;
 | 
|---|
| 37 |             GlobalProc *pUserProc = ppSubHash[i2];
 | 
|---|
| 38 |             while(pUserProc){
 | 
|---|
| 39 |                 if( pUserProc->IsCompiled() ){
 | 
|---|
| 40 |                     if( pUserProc->HasParentClass() ){
 | 
|---|
| 41 |                         codeSizeOfClassMethod += pUserProc->GetCodeSize();
 | 
|---|
| 42 |                     }
 | 
|---|
| 43 |                     else{
 | 
|---|
| 44 |                         codeSizeOfGlobalProc += pUserProc->GetCodeSize();
 | 
|---|
| 45 |                     }
 | 
|---|
| 46 |                 }
 | 
|---|
| 47 | 
 | 
|---|
| 48 |                 pUserProc=pUserProc->pNextData;
 | 
|---|
| 49 |             }
 | 
|---|
| 50 |         }
 | 
|---|
| 51 | 
 | 
|---|
| 52 |         sprintf(temporary, "%d", codeSizeOfGlobalProc/1024 );
 | 
|---|
| 53 |         Smoothie::Logger::Put( (string)"グローバル関数のコードサイズ総量: " + temporary + "KB" );
 | 
|---|
| 54 |         sprintf(temporary, "%d", codeSizeOfClassMethod/1024 );
 | 
|---|
| 55 |         Smoothie::Logger::Put( (string)"クラスメソッドのコードサイズ総量: " + temporary + "KB" );
 | 
|---|
| 56 |     }
 | 
|---|
| 57 | 
 | 
|---|
| 58 |     {
 | 
|---|
| 59 |         ///////////////////////////////////////////////////////////////////
 | 
|---|
| 60 |         // Enumに必要なのコードサイズを調べる
 | 
|---|
| 61 |         ///////////////////////////////////////////////////////////////////
 | 
|---|
| 62 |         int codeSizeOfEnum = 0;
 | 
|---|
| 63 | 
 | 
|---|
| 64 |         // イテレータをリセット
 | 
|---|
| 65 |         extern Classes *pobj_DBClass;
 | 
|---|
| 66 |         pobj_DBClass->Iterator_Reset();
 | 
|---|
| 67 | 
 | 
|---|
| 68 |         while( pobj_DBClass->Iterator_HasNext() ){
 | 
|---|
| 69 |             int codeSizeOfClass = 0;
 | 
|---|
| 70 | 
 | 
|---|
| 71 |             CClass &objClass = *pobj_DBClass->Iterator_GetNext();
 | 
|---|
| 72 | 
 | 
|---|
| 73 |             if( !objClass.IsEnum() ){
 | 
|---|
| 74 |                 // 列挙型以外は無視
 | 
|---|
| 75 |                 continue;
 | 
|---|
| 76 |             }
 | 
|---|
| 77 | 
 | 
|---|
| 78 |             // 動的メソッド
 | 
|---|
| 79 |             foreach( const CMethod *pMethod, objClass.GetMethods() ){
 | 
|---|
| 80 |                 if( pMethod->pUserProc->IsCompiled() ){
 | 
|---|
| 81 |                     codeSizeOfClass += pMethod->pUserProc->GetCodeSize();
 | 
|---|
| 82 |                 }
 | 
|---|
| 83 |             }
 | 
|---|
| 84 | 
 | 
|---|
| 85 |             // 静的メソッド
 | 
|---|
| 86 |             foreach( const CMethod *pMethod, objClass.GetStaticMethods() ){
 | 
|---|
| 87 |                     codeSizeOfClass += pMethod->pUserProc->GetCodeSize();
 | 
|---|
| 88 |             }
 | 
|---|
| 89 | 
 | 
|---|
| 90 |             codeSizeOfEnum += codeSizeOfClass;
 | 
|---|
| 91 |         }
 | 
|---|
| 92 | 
 | 
|---|
| 93 |         sprintf(temporary, "%d", codeSizeOfEnum/1024 );
 | 
|---|
| 94 |         Smoothie::Logger::Put( (string)"Enumのコードサイズ総量: " + temporary + "KB" );
 | 
|---|
| 95 |     }
 | 
|---|
| 96 | 
 | 
|---|
| 97 |     Smoothie::Logger::Put( "\n\n" );
 | 
|---|
| 98 | 
 | 
|---|
| 99 |     {
 | 
|---|
| 100 |         ///////////////////////////////////////////////////////////////////
 | 
|---|
| 101 |         // クラスのサイズを調べる
 | 
|---|
| 102 |         ///////////////////////////////////////////////////////////////////
 | 
|---|
| 103 | 
 | 
|---|
| 104 |         // イテレータをリセット
 | 
|---|
| 105 |         extern Classes *pobj_DBClass;
 | 
|---|
| 106 |         pobj_DBClass->Iterator_Reset();
 | 
|---|
| 107 | 
 | 
|---|
| 108 |         while( pobj_DBClass->Iterator_HasNext() ){
 | 
|---|
| 109 |             int codeSizeOfClass = 0;
 | 
|---|
| 110 | 
 | 
|---|
| 111 |             CClass &objClass = *pobj_DBClass->Iterator_GetNext();
 | 
|---|
| 112 | 
 | 
|---|
| 113 |             // 動的メソッド
 | 
|---|
| 114 |             foreach( const CMethod *pMethod, objClass.GetMethods() ){
 | 
|---|
| 115 |                 if( pMethod->pUserProc->IsCompiled() ){
 | 
|---|
| 116 |                     codeSizeOfClass += pMethod->pUserProc->GetCodeSize();
 | 
|---|
| 117 |                 }
 | 
|---|
| 118 |             }
 | 
|---|
| 119 | 
 | 
|---|
| 120 |             // 静的メソッド
 | 
|---|
| 121 |             foreach( const CMethod *pMethod, objClass.GetStaticMethods() ){
 | 
|---|
| 122 |                     codeSizeOfClass += pMethod->pUserProc->GetCodeSize();
 | 
|---|
| 123 |             }
 | 
|---|
| 124 | 
 | 
|---|
| 125 |             if( codeSizeOfClass ){
 | 
|---|
| 126 |                 temporary[0]=0;
 | 
|---|
| 127 |                 lstrcat( temporary, "------------------------------------------------------------------\n" );
 | 
|---|
| 128 |                 sprintf( temporary + lstrlen(temporary), "【 %s クラスのコード情報】\n", objClass.GetName().c_str() );
 | 
|---|
| 129 |                 sprintf( temporary + lstrlen(temporary), "class code size: %d bytes\n", codeSizeOfClass );
 | 
|---|
| 130 |                 lstrcat( temporary, "------------------------------------------------------------------\n" );
 | 
|---|
| 131 |                 lstrcat( temporary, "\n" );
 | 
|---|
| 132 |                 Smoothie::Logger::Put( temporary );
 | 
|---|
| 133 |             }
 | 
|---|
| 134 |         }
 | 
|---|
| 135 |     }
 | 
|---|
| 136 | }
 | 
|---|