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