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