• R/O
  • HTTP
  • SSH
  • HTTPS

コミット

タグ
未設定

よく使われているワード(クリックで追加)

javaandroidc++linuxobjective-cc#cocoa誰得qtrubygamebathyscaphephpgui翻訳windowspythoncomegattwittertestframeworkbtronarduinovb.net計画中(planning stage)directxpreviewerゲームエンジンdom

BASIC compiler/interpreter for PIC32MX/MZ-80K


コミットメタ情報

リビジョンba72515e68910844bfb8a94d0a3e0d90e5eb1ac7 (tree)
日時2019-02-12 04:54:56
作者Katsumi <kmorimatsu@sour...>
コミッターKatsumi

ログメッセージ

Use 10 deleted pointers for new object if possible.

変更サマリ

差分

--- a/mips/megalopa/debug.c
+++ b/mips/megalopa/debug.c
@@ -228,9 +228,26 @@ static const char initext[]=
228228 static const char bastext[]=
229229 "USECLASS CLASS1\n"
230230 "CLS\n"
231-"print CLASS1::T3()\n"
232-"\n"
233-"\n"
231+"dim o(95),v(95)\n"
232+"for i=1 to 85\n"
233+" o(i)=new(CLASS1)\n"
234+"next\n"
235+"for i=1 to 100\n"
236+" for j=1 to 85\n"
237+" v(j)=rnd()\n"
238+" o(j).T1=v(j)\n"
239+" next\n"
240+" for j=86 to 95\n"
241+" o(j)=new(CLASS1)\n"
242+" next\n"
243+" for j=86 to 95\n"
244+" DELETE o(j)\n"
245+" next\n"
246+" for j=1 to 85\n"
247+" if v(j)!=o(j).T1 then print \"ERR\":end\n"
248+" next\n"
249+"next\n"
250+"print \"OK\"\n"
234251 "\n"
235252 "\n"
236253 "\n"
@@ -238,6 +255,7 @@ static const char bastext[]=
238255
239256
240257 static const char classtext[]=
258+"FIELD T1,T2\n"
241259 "METHOD T3\n"
242260 " return 123\n"
243261 "\n"
--- a/mips/megalopa/memory.c
+++ b/mips/megalopa/memory.c
@@ -26,22 +26,31 @@
2626 */
2727
2828 static int g_temp_var_num_candidate=ALLOC_PERM_BLOCK;
29-static int g_last_deleted_pointer;
30-static int g_last_deleted_size=0;
29+
30+#define DELETE_LIST_SIZE 10
31+static int g_deleted_num;
32+static int g_deleted_pointer[DELETE_LIST_SIZE];
33+static int g_deleted_size[DELETE_LIST_SIZE];
34+
3135
3236 #define register_deleted_block(x,y) \
3337 do {\
34- g_last_deleted_pointer=(x);\
35- g_last_deleted_size=(y);\
38+ if (g_deleted_num<DELETE_LIST_SIZE) {\
39+ g_deleted_pointer[g_deleted_num]=(x);\
40+ g_deleted_size[g_deleted_num]=(y);\
41+ g_deleted_num++;\
42+ }\
3643 } while(0)
3744
3845 void set_free_area(void* begin, void* end){
46+ // Initialize heap area
3947 int i;
4048 for(i=0;i<ALLOC_BLOCK_NUM;i++){
4149 g_var_size[i]=0;
4250 }
4351 g_heap_mem=(int*)begin;
4452 g_max_mem=(int)((end-begin)/4);
53+ g_deleted_num=0;
4554 }
4655
4756 void* calloc_memory(int size, int var_num){
@@ -98,13 +107,19 @@ void* _alloc_memory_main(int size, int var_num){
98107 g_var_pointer[var_num]=0;
99108 while(1){
100109 // Try the block previously deleted
101- if (size<=g_last_deleted_size) {
102- g_last_deleted_size=0;
103- candidate=g_last_deleted_pointer;
110+ candidate=0;
111+ while(g_deleted_num){
112+ // Check if the last deleted block fits
113+ // If not, these cannot be used anymore
114+ g_deleted_num--;
115+ if (size<=g_deleted_size[g_deleted_num]) {
116+ candidate=g_deleted_pointer[g_deleted_num];
117+ break;
118+ }
119+ }
120+ if (candidate || g_deleted_num) {
121+ // Candidate found
104122 break;
105- } else {
106- // Last deleted block is a candidate only once
107- g_last_deleted_size=0;
108123 }
109124 // Try the block after last block
110125 candidate=0;