Changeset 620
- Timestamp:
- 08/02/10 03:57:57 (18 months ago)
- Location:
- interpreter/trunk/backend
- Files:
-
- 2 edited
-
common/kite_compiler.c (modified) (4 diffs)
-
kite-vm-1.0/kite_compile_bytecode.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
interpreter/trunk/backend/common/kite_compiler.c
r619 r620 103 103 } 104 104 105 #ifdef WIN32 106 WaitForSingleObject(thd->vm->compile_mtx, INFINITE); 107 #else 108 pthread_mutex_lock(&thd->vm->compile_mtx); 109 #endif /* WIN32 */ 110 105 111 compiler->thd = thd; 106 112 compiler->currentLine = 1; … … 126 132 free(compiler); 127 133 #endif /* HAVE_GC_H */ 134 135 #ifdef WIN32 136 ReleaseMutex(thd->vm->compile_mtx); 137 #else 138 pthread_mutex_unlock(&thd->vm->compile_mtx); 139 #endif /* WIN32 */ 140 128 141 return ret; 129 142 } … … 164 177 } 165 178 179 #ifdef WIN32 180 WaitForSingleObject(thd->vm->compile_mtx, INFINITE); 181 #else 182 pthread_mutex_lock(&thd->vm->compile_mtx); 183 #endif /* WIN32 */ 184 166 185 compiler->thd = thd; 167 186 compiler->currentLine = ln; … … 187 206 free(compiler); 188 207 #endif /* HAVE_GC_H */ 189 return ret; 190 } 208 209 #ifdef WIN32 210 ReleaseMutex(thd->vm->compile_mtx); 211 #else 212 pthread_mutex_unlock(&thd->vm->compile_mtx); 213 #endif /* WIN32 */ 214 215 return ret; 216 } -
interpreter/trunk/backend/kite-vm-1.0/kite_compile_bytecode.c
r619 r620 26 26 static void kite_optimize_increment(kite_compiler_t *compiler, kite_opcode_t *o1, kite_opcode_t *o2) 27 27 { 28 /*kite_thread_t *thd = compiler->thd; 29 kite_opcode_push *p1 = (kite_opcode_push*)o1; 30 kite_opcode_push *p2 = (kite_opcode_push*)o2; 31 if (o1->opcode == PUSH && o2->opcode == PUSH) { 32 if (p1->obj->type == OBJ_IDENT && p2->obj->type == OBJ_IDENT) { 33 if (strcmp(p1->obj->builtin_data.stringvalue.string, 34 p2->obj->builtin_data.stringvalue.string) == 0) { 35 if (o1->next && o2->next) { 36 if (o1->next->opcode == DEREF_1 && o2->next->opcode == DEREF_1) { 37 if (o1->next->next == o2) { 38 kite_opcode_t *dupe = kite_compile_dupe_top(TRUE); 39 dupe->file = strdup(o2->file); 40 dupe->line = o2->line; 41 o1->next->next = dupe; 42 dupe->next = o2->next->next; 43 o2->next->next = NULL; 44 kite_free_instruction_list(thd, o2); 45 } 28 kite_thread_t *thd = compiler->thd; 29 kite_vm_t *vm = thd->vm; 30 kite_opcode_t *p1 = (void*)vm->text_segment + (long)o1; 31 kite_opcode_t *p2 = (void*)vm->text_segment + (long)o2; 32 if (p1->opcode == PUSH && p2->opcode == PUSH) { 33 if (p1->op_arg.obj->type == OBJ_IDENT && p2->op_arg.obj->type == OBJ_IDENT) { 34 if (strcmp(p1->op_arg.obj->builtin_data.stringvalue.string, 35 p2->op_arg.obj->builtin_data.stringvalue.string) == 0) { 36 if ((p1 + 1) < ((void*)vm->text_segment + vm->text_segment_length) && 37 (p1 + 2) < ((void*)vm->text_segment + vm->text_segment_length)) { 38 if ((p1 + 1)->opcode == DEREF_1 && (p2 + 1)->opcode == DEREF_1) { 39 p2->opcode = DUPE_TOP; 40 p2->op_arg.dupe_ref = TRUE; 41 (p2 + 1)->opcode = NOP; 46 42 } 47 43 } 48 44 } 49 45 } 50 } */46 } 51 47 } 52 48 … … 524 520 525 521 if (opc->opcode == ARITH_OP && ((kite_opcode_arithop*)opc)->op_arg.operation == OP_ARRAY_DEREF) 526 return opc -compiler->thd->vm->text_segment;522 return (void*)opc - (long)compiler->thd->vm->text_segment; 527 523 else 528 524 return NULL; … … 532 528 { 533 529 kite_opcode_t *op2; 534 535 /*if (op1 && op1->next && op1->next->next) 530 int has_possible_dupe = TRUE; 531 int i; 532 kite_vm_t *vm = compiler->thd->vm; 533 534 /* Ensure next two instructions are valid for dupe optimization. 535 Equivalent to op1 && op1->next && op1->next->next in old code. */ 536 op2 = (void*)vm->text_segment + (long)op1; 537 for (i = 0; i < 2; i++) 536 538 { 537 op2 = op1->next->next; 539 if (op2->opcode == RETURN_NOW || ((void*)op2 - (long)vm->text_segment) >= vm->text_segment_length) 540 { 541 has_possible_dupe = FALSE; 542 break; 543 } 544 op2++; 545 } 546 547 /* Perform dupe optimization. */ 548 if (has_possible_dupe) 549 { 550 op2 = (void*)op2 - (long)vm->text_segment; 538 551 kite_optimize_increment(compiler, op1, op2); 539 } */552 } 540 553 541 554 if (!orig_op2) … … 772 785 { 773 786 kite_thread_t *thd = compiler->thd; 787 kite_vm_t *vm = thd->vm; 774 788 kite_opcode_t *op = kite_compile_push(kite_new_ident(thd, name)); 775 789 COMPILE_INSTRUCTION(op, line); 790 op = vm->cur_text_segment - sizeof(kite_opcode_t); 776 791 COMPILE_INSTRUCTION(kite_compile_deref_1(TRUE), line); 777 return NULL;792 return op; 778 793 } 779 794
Note: See TracChangeset
for help on using the changeset viewer.
