History

further code cleanup from memory system upgrade part 1

Ge Wang committed 3 years ago

Commit 927edfd1 parent beef6542 files · +10 −31Browse files

Unified · Split

2 files
  1. src/core/chuck_emit.cpp +8 −14
  2. src/core/chuck_instr.cpp +2 −17
src/core/chuck_emit.cpp+8−14
@@ -74,7 +74,7 @@ t_CKBOOL emit_engine_emit_exp_postfix( Chuck_Emitter * emit, a_Exp_Postfix postf · 73 unmodified lines
7474 t_CKBOOL emit_engine_emit_exp_dur( Chuck_Emitter * emit, a_Exp_Dur dur );
7575 t_CKBOOL emit_engine_emit_exp_array( Chuck_Emitter * emit, a_Exp_Array array );
7676 t_CKBOOL emit_engine_emit_exp_func_call( Chuck_Emitter * emit, Chuck_Func * func,
77− a_Exp args, Chuck_Type * type, int linepos, t_CKBOOL spork = FALSE );
77+ Chuck_Type * type, int linepos, t_CKBOOL spork = FALSE );
7878 t_CKBOOL emit_engine_emit_exp_func_call( Chuck_Emitter * emit, a_Exp_Func_Call func_call,
7979 t_CKBOOL spork = FALSE );
8080 t_CKBOOL emit_engine_emit_func_args( Chuck_Emitter * emit, a_Exp_Func_Call func_call );
@@ -2565,7 +2565,7 @@ t_CKBOOL emit_engine_emit_op_chuck( Chuck_Emitter * emit, a_Exp lhs, a_Exp rhs, · 2484 unmodified lines
25652565 assert( binary->ck_func != NULL );
25662566
25672567 // emit
2568− return emit_engine_emit_exp_func_call( emit, binary->ck_func, binary->lhs, binary->self->type, binary->linepos );
2568+ return emit_engine_emit_exp_func_call( emit, binary->ck_func, binary->self->type, binary->linepos );
25692569 }
25702570
25712571 // assignment or something else
@@ -3429,7 +3429,6 @@ t_CKBOOL emit_engine_emit_exp_array( Chuck_Emitter * emit, a_Exp_Array array ) · 857 unmodified lines
34293429 //-----------------------------------------------------------------------------
34303430 t_CKBOOL emit_engine_emit_exp_func_call( Chuck_Emitter * emit,
34313431 Chuck_Func * func,
3432− a_Exp args,
34333432 Chuck_Type * type,
34343433 int linepos,
34353434 t_CKBOOL spork )
@@ -3531,7 +3530,7 @@ t_CKBOOL emit_engine_emit_exp_func_call( Chuck_Emitter * emit, · 95 unmodified lines
35313530 }
35323531
35333532 // the rest
3534− return emit_engine_emit_exp_func_call( emit, func_call->ck_func, func_call->args,
3533+ return emit_engine_emit_exp_func_call( emit, func_call->ck_func,
35353534 func_call->ret_type, func_call->linepos, spork );
35363535 }
35373536
@@ -4819,7 +4818,6 @@ t_CKBOOL emit_engine_emit_spork( Chuck_Emitter * emit, a_Exp_Func_Call exp ) · 1281 unmodified lines
48194818 // call the func on sporkee shred
48204819 if( !emit_engine_emit_exp_func_call( emit,
48214820 exp->ck_func,
4822− exp->args,
48234821 exp->ret_type,
48244822 exp->linepos,
48254823 TRUE ) ) return FALSE;
@@ -5142,16 +5140,12 @@ void Chuck_Emitter::traverse_scope_on_jump( ) · 316 unmodified lines
51425140 // skip scope boundary (denoted by NULL)
51435141 if( !local ) continue;
51445142
5145− // CK_STDCERR << "local: " << local->offset << " " << local->is_obj << CK_STDENDL;
5146− // check to see if it's an object
5147− if( local->is_obj )
5143+ // check to see if it's an object (but not global)
5144+ // (REFACTOR-2017: don't release global objects)
5145+ if( local->is_obj && !local->is_global )
51485146 {
5149− // (REFACTOR-2017: don't release global objects)
5150− if( !local->is_global )
5151− {
5152− // emit instruction to release the object
5153− this->append( new Chuck_Instr_Release_Object2( local->offset ) );
5154− }
5147+ // emit instruction to release the object
5148+ this->append( new Chuck_Instr_Release_Object2( local->offset ) );
51555149 }
51565150 }
51575151
src/core/chuck_instr.cpp+2−17
@@ -4788,17 +4788,10 @@ void Chuck_Instr_Func_Call_Member::execute( Chuck_VM * vm, Chuck_VM_Shred * shre · 4787 unmodified lines
47884788 // 1.4.2.1 (ge) | added -- ensure ref count
47894789 if( m_func_ref && isobj(vm->env(), m_func_ref->def->ret_type) )
47904790 {
4791+ // get return value as object reference
47914792 Chuck_VM_Object * obj = (Chuck_VM_Object *) retval.v_uint;
47924793 if( obj )
47934794 {
4794− // check if refcount is 0
4795− if( obj->m_ref_count == 0 )
4796− {
4797− EM_log( CK_LOG_FINE, "%s(...) returned object with refcount==0", S_name(m_func_ref->def->name) );
4798− EM_pushlog();
4799− EM_log( CK_LOG_FINE, "auto-incrementing object refcount to 1..." );
4800− EM_poplog();
4801− }
48024795 // always add reference to returned objects (should release outside)
48034796 obj->add_ref();
48044797 }
@@ -4922,18 +4915,10 @@ void Chuck_Instr_Func_Call_Static::execute( Chuck_VM * vm, Chuck_VM_Shred * shre · 117 unmodified lines
49224915 // 1.4.2.1 (ge) | added -- ensure ref count
49234916 if( m_func_ref && isobj(vm->env(), m_func_ref->def->ret_type) )
49244917 {
4925− // get as object pointer
4918+ // get return value as object reference
49264919 Chuck_VM_Object * obj = (Chuck_VM_Object *) retval.v_uint;
49274920 if( obj )
49284921 {
4929− // check if refcount is 0
4930− if( obj->m_ref_count == 0 )
4931− {
4932− EM_log( CK_LOG_FINE, "%s(...) returned object with refcount==0", S_name(m_func_ref->def->name) );
4933− EM_pushlog();
4934− EM_log( CK_LOG_FINE, "auto-incrementing object refcount to 1..." );
4935− EM_poplog();
4936− }
49374922 // always add reference to returned objects (should release outside)
49384923 obj->add_ref();
49394924 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t