source: dev/trunk/ab5.0/abdev/BasicCompiler_Common/Diagnose.cpp@ 485

Last change on this file since 485 was 485, checked in by dai_9181, 16 years ago

プロジェクトのリネームが完了

File size: 4.4 KB
Line 
1#include "stdafx.h"
2
3#include <Compiler.h>
4#include <Program.h>
5
6#include "../BasicCompiler_Common/common.h"
7
8#ifdef _AMD64_
9#include "../compiler_x64/opcode.h"
10#else
11#include "../compiler_x86/opcode.h"
12#endif
13
14
15void Diagnose(){
16 char temporary[8192];
17
18 {
19 ///////////////////////////////////////////////////////////////////
20 // グローバル / ローカル コード領域のサイズを調べる
21 ///////////////////////////////////////////////////////////////////
22
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 compiler.GetObjectModule().meta.GetUserProcs().Iterator_Reset();
40 while( compiler.GetObjectModule().meta.GetUserProcs().Iterator_HasNext() )
41 {
42 UserProc *pUserProc = compiler.GetObjectModule().meta.GetUserProcs().Iterator_GetNext();
43 if( pUserProc->IsCompiled() ){
44 if( pUserProc->HasParentClass() ){
45 codeSizeOfClassMethod += pUserProc->GetCodeSize();
46 }
47 else{
48 codeSizeOfGlobalProc += pUserProc->GetCodeSize();
49 }
50 }
51 }
52
53 sprintf(temporary, "%d", codeSizeOfGlobalProc/1024 );
54 trace_for_size( (string)"グローバル関数のコードサイズ総量: " + temporary + "KB" );
55 sprintf(temporary, "%d", codeSizeOfClassMethod/1024 );
56 trace_for_size( (string)"クラスメソッドのコードサイズ総量: " + temporary + "KB" );
57 }
58
59 {
60 ///////////////////////////////////////////////////////////////////
61 // Enumに必要なのコードサイズを調べる
62 ///////////////////////////////////////////////////////////////////
63 int codeSizeOfEnum = 0;
64
65 // イテレータをリセット
66 compiler.GetObjectModule().meta.GetClasses().Iterator_Reset();
67
68 while( compiler.GetObjectModule().meta.GetClasses().Iterator_HasNext() ){
69 int codeSizeOfClass = 0;
70
71 CClass &objClass = *compiler.GetObjectModule().meta.GetClasses().Iterator_GetNext();
72
73 if( !objClass.IsEnum() ){
74 // 列挙型以外は無視
75 continue;
76 }
77
78 // 動的メソッド
79 BOOST_FOREACH( const CMethod *pMethod, objClass.GetDynamicMethods() ){
80 if( pMethod->GetUserProc().IsCompiled() ){
81 codeSizeOfClass += pMethod->GetUserProc().GetCodeSize();
82 }
83 }
84
85 // 静的メソッド
86 BOOST_FOREACH( const CMethod *pMethod, objClass.GetStaticMethods() ){
87 codeSizeOfClass += pMethod->GetUserProc().GetCodeSize();
88 }
89
90 codeSizeOfEnum += codeSizeOfClass;
91 }
92
93 sprintf(temporary, "%d", codeSizeOfEnum/1024 );
94 trace_for_size( (string)"Enumのコードサイズ総量: " + temporary + "KB" );
95 }
96
97 trace_for_size( "\n\n" );
98
99 {
100 ///////////////////////////////////////////////////////////////////
101 // クラスのサイズを調べる
102 ///////////////////////////////////////////////////////////////////
103
104 // イテレータをリセット
105 compiler.GetObjectModule().meta.GetClasses().Iterator_Reset();
106
107 while( compiler.GetObjectModule().meta.GetClasses().Iterator_HasNext() ){
108 int codeSizeOfClass = 0;
109
110 CClass &objClass = *compiler.GetObjectModule().meta.GetClasses().Iterator_GetNext();
111
112 // 動的メソッド
113 BOOST_FOREACH( const CMethod *pMethod, objClass.GetDynamicMethods() ){
114 if( pMethod->GetUserProc().IsCompiled() ){
115 codeSizeOfClass += pMethod->GetUserProc().GetCodeSize();
116 }
117 }
118
119 // 静的メソッド
120 BOOST_FOREACH( const CMethod *pMethod, objClass.GetStaticMethods() ){
121 codeSizeOfClass += pMethod->GetUserProc().GetCodeSize();
122 }
123
124 if( codeSizeOfClass ){
125 temporary[0]=0;
126 lstrcat( temporary, "------------------------------------------------------------------\n" );
127 sprintf( temporary + lstrlen(temporary), "【 %s クラスのコード情報】\n", objClass.GetName().c_str() );
128 sprintf( temporary + lstrlen(temporary), "class code size: %d bytes\n", codeSizeOfClass );
129 lstrcat( temporary, "------------------------------------------------------------------\n" );
130 lstrcat( temporary, "\n" );
131 trace_for_size( temporary );
132 }
133 }
134 }
135}
Note: See TracBrowser for help on using the repository browser.