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

Last change on this file since 265 was 265, checked in by dai_9181, 17 years ago
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 obp;
26 extern int GlobalOpBufferSize;
27 sprintf(temporary, "%d", GlobalOpBufferSize/1024 );
[167]28 trace_for_size( (string)"グローバル領域のコードサイズ: " + temporary + "KB" );
[92]29 sprintf(temporary, "%d", (obp-GlobalOpBufferSize)/1024 );
[167]30 trace_for_size( (string)"ローカル領域のコードサイズ: " + temporary + "KB" );
[92]31 sprintf(temporary, "%d", obp/1024 );
[167]32 trace_for_size( (string)"コードサイズ総量: " + temporary + "KB" );
[92]33 }
34
[91]35 {
[92]36 ///////////////////////////////////////////////////////////////////
[91]37 // グローバル関数、クラスメソッドのサイズを調べる
[92]38 ///////////////////////////////////////////////////////////////////
39
[91]40 int codeSizeOfGlobalProc = 0;
41 int codeSizeOfClassMethod = 0;
[265]42 compiler.GetObjectModule().meta.GetUserProcs().Iterator_Reset();
43 while( compiler.GetObjectModule().meta.GetUserProcs().Iterator_HasNext() )
[206]44 {
[265]45 UserProc *pUserProc = compiler.GetObjectModule().meta.GetUserProcs().Iterator_GetNext();
[206]46 if( pUserProc->IsCompiled() ){
47 if( pUserProc->HasParentClass() ){
48 codeSizeOfClassMethod += pUserProc->GetCodeSize();
[91]49 }
[206]50 else{
51 codeSizeOfGlobalProc += pUserProc->GetCodeSize();
52 }
[91]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 // イテレータをリセット
[265]69 compiler.GetObjectModule().meta.GetClasses().Iterator_Reset();
[92]70
[265]71 while( compiler.GetObjectModule().meta.GetClasses().Iterator_HasNext() ){
[92]72 int codeSizeOfClass = 0;
73
[265]74 CClass &objClass = *compiler.GetObjectModule().meta.GetClasses().Iterator_GetNext();
[92]75
76 if( !objClass.IsEnum() ){
77 // 列挙型以外は無視
78 continue;
79 }
80
81 // 動的メソッド
[182]82 BOOST_FOREACH( const CMethod *pMethod, objClass.GetMethods() ){
[206]83 if( pMethod->GetUserProc().IsCompiled() ){
84 codeSizeOfClass += pMethod->GetUserProc().GetCodeSize();
[92]85 }
86 }
87
88 // 静的メソッド
[182]89 BOOST_FOREACH( const CMethod *pMethod, objClass.GetStaticMethods() ){
[206]90 codeSizeOfClass += pMethod->GetUserProc().GetCodeSize();
[92]91 }
92
93 codeSizeOfEnum += codeSizeOfClass;
94 }
95
96 sprintf(temporary, "%d", codeSizeOfEnum/1024 );
[167]97 trace_for_size( (string)"Enumのコードサイズ総量: " + temporary + "KB" );
[91]98 }
99
[167]100 trace_for_size( "\n\n" );
[92]101
[91]102 {
[92]103 ///////////////////////////////////////////////////////////////////
[91]104 // クラスのサイズを調べる
[92]105 ///////////////////////////////////////////////////////////////////
[91]106
107 // イテレータをリセット
[265]108 compiler.GetObjectModule().meta.GetClasses().Iterator_Reset();
[91]109
[265]110 while( compiler.GetObjectModule().meta.GetClasses().Iterator_HasNext() ){
[91]111 int codeSizeOfClass = 0;
112
[265]113 CClass &objClass = *compiler.GetObjectModule().meta.GetClasses().Iterator_GetNext();
[91]114
115 // 動的メソッド
[182]116 BOOST_FOREACH( const CMethod *pMethod, objClass.GetMethods() ){
[206]117 if( pMethod->GetUserProc().IsCompiled() ){
118 codeSizeOfClass += pMethod->GetUserProc().GetCodeSize();
[91]119 }
120 }
121
122 // 静的メソッド
[182]123 BOOST_FOREACH( const CMethod *pMethod, objClass.GetStaticMethods() ){
[206]124 codeSizeOfClass += pMethod->GetUserProc().GetCodeSize();
[91]125 }
126
127 if( codeSizeOfClass ){
128 temporary[0]=0;
129 lstrcat( temporary, "------------------------------------------------------------------\n" );
[131]130 sprintf( temporary + lstrlen(temporary), "【 %s クラスのコード情報】\n", objClass.GetName().c_str() );
[91]131 sprintf( temporary + lstrlen(temporary), "class code size: %d bytes\n", codeSizeOfClass );
132 lstrcat( temporary, "------------------------------------------------------------------\n" );
133 lstrcat( temporary, "\n" );
[167]134 trace_for_size( temporary );
[91]135 }
136 }
137 }
138}
Note: See TracBrowser for help on using the repository browser.