source: dev/trunk/abdev/BasicCompiler_Common/Diagnose.cpp@ 342

Last change on this file since 342 was 342, checked in by dai_9181, 17 years ago

vtblの構造を変更。vtblMasterListをはさんでvtblを表現した。
その他メンバ名変更。
ClassPrototypeクラスを追加。

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