source: dev/branches/egtra/ab5.0/abdev/BasicCompiler_Common/Diagnose.cpp@ 818

Last change on this file since 818 was 803, checked in by イグトランス (egtra), 14 years ago

Hashmapの実装にunorderedを用いるよう変更

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