source: dev/trunk/ab5.0/abdev/BasicCompiler_Common/Diagnose.cpp@ 527

Last change on this file since 527 was 527, checked in by dai_9181, 16 years ago

ヘッダファイルを整理中

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