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