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

Last change on this file since 206 was 206, checked in by dai_9181, 17 years ago

コード全体のリファクタリングを実施

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