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

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