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