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

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