|
@@ -114,6 +114,12 @@ bool SQVM::ARITH_OP(SQUnsignedInteger op,SQObjectPtr &trg,const SQObjectPtr &o1,
|
|
|
}
|
|
}
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+#ifdef PROFILE_SQVM
|
|
|
|
|
+//from sqstdsystem
|
|
|
|
|
+int GetMilliCount();
|
|
|
|
|
+int GetMilliSpan( int nTimeStart );
|
|
|
|
|
+#endif
|
|
|
|
|
|
|
|
SQVM::SQVM(SQSharedState *ss)
|
|
SQVM::SQVM(SQSharedState *ss)
|
|
|
{
|
|
{
|
|
@@ -135,11 +141,22 @@ SQVM::SQVM(SQSharedState *ss)
|
|
|
_openouters = NULL;
|
|
_openouters = NULL;
|
|
|
ci = NULL;
|
|
ci = NULL;
|
|
|
INIT_CHAIN();ADD_TO_CHAIN(&_ss(this)->_gc_chain,this);
|
|
INIT_CHAIN();ADD_TO_CHAIN(&_ss(this)->_gc_chain,this);
|
|
|
- _check_delayed_relase_hooks = true;
|
|
|
|
|
-}
|
|
|
|
|
|
|
+ _check_delayed_relase_hooks = true;
|
|
|
|
|
+#ifdef PROFILE_SQVM
|
|
|
|
|
+ printf("SQVM::SQVM : %p\n", this);
|
|
|
|
|
+ _last_op_profile_time = GetMilliCount();
|
|
|
|
|
+ _op_profile.resize(_OP__LAST__+1);
|
|
|
|
|
+ for(SQUnsignedInteger i=0; i <= _OP__LAST__; ++i){
|
|
|
|
|
+ OpProfile &opp = _op_profile[i];
|
|
|
|
|
+ opp.op = i;
|
|
|
|
|
+ opp.count = opp.total_time = 0;
|
|
|
|
|
+ }
|
|
|
|
|
+#endif
|
|
|
|
|
+}
|
|
|
|
|
|
|
|
void SQVM::Finalize()
|
|
void SQVM::Finalize()
|
|
|
{
|
|
{
|
|
|
|
|
+ if(!_alloccallsstacksize) return; //to prevent multiple calls
|
|
|
CallAtExitHandler();
|
|
CallAtExitHandler();
|
|
|
_sharedstate->CallDelayedReleaseHooks(this);
|
|
_sharedstate->CallDelayedReleaseHooks(this);
|
|
|
if(_openouters) CloseOuters(&_stack._vals[0]);
|
|
if(_openouters) CloseOuters(&_stack._vals[0]);
|
|
@@ -155,6 +172,16 @@ void SQVM::Finalize()
|
|
|
SQInteger size=_stack.size();
|
|
SQInteger size=_stack.size();
|
|
|
for(SQInteger i=0;i<size;i++)
|
|
for(SQInteger i=0;i<size;i++)
|
|
|
_stack[i].Null();
|
|
_stack[i].Null();
|
|
|
|
|
+#ifdef PROFILE_SQVM
|
|
|
|
|
+ printf("SQVM::Finalize : %p\n", this);
|
|
|
|
|
+#define ENUM_OP(a,b) {\
|
|
|
|
|
+ OpProfile &opp = _op_profile[a];\
|
|
|
|
|
+ if(opp.count) printf("%d\t%d\t%d\t%d\t%s\n", a, opp.op, opp.count, opp.total_time, _SC(#a));\
|
|
|
|
|
+ }
|
|
|
|
|
+ SQ_OP_CODE_LIST()
|
|
|
|
|
+#undef ENUM_OP
|
|
|
|
|
+#endif
|
|
|
|
|
+ _alloccallsstacksize = 0; //to prevent multiple calls
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
SQVM::~SQVM()
|
|
SQVM::~SQVM()
|
|
@@ -748,15 +775,24 @@ exception_restore:
|
|
|
#else
|
|
#else
|
|
|
|
|
|
|
|
//
|
|
//
|
|
|
- {
|
|
|
|
|
|
|
+ {
|
|
|
for(;;)
|
|
for(;;)
|
|
|
{
|
|
{
|
|
|
//if the last instruction was a call then check for release hooks
|
|
//if the last instruction was a call then check for release hooks
|
|
|
//obs.: changing the order of comparison bellow with gcc makes the code slower
|
|
//obs.: changing the order of comparison bellow with gcc makes the code slower
|
|
|
if((ci->_ip->op == _OP_CALL) && _check_delayed_relase_hooks) _sharedstate->CallDelayedReleaseHooks(this);
|
|
if((ci->_ip->op == _OP_CALL) && _check_delayed_relase_hooks) _sharedstate->CallDelayedReleaseHooks(this);
|
|
|
|
|
+#ifdef PROFILE_SQVM
|
|
|
|
|
+ OpProfile &opp_last = _op_profile[ci->_ip->op];
|
|
|
|
|
+ opp_last.total_time += GetMilliSpan(_last_op_profile_time);
|
|
|
|
|
+ _last_op_profile_time = GetMilliCount();
|
|
|
|
|
+#endif
|
|
|
const SQInstruction &_i_ = *ci->_ip++;
|
|
const SQInstruction &_i_ = *ci->_ip++;
|
|
|
//dumpstack(_stackbase);
|
|
//dumpstack(_stackbase);
|
|
|
//scprintf("\n[%d] %s %d %d %d %d\n",ci->_ip-ci->_iv->_vals,g_InstrDesc[_i_.op].name,arg0,arg1,arg2,arg3);
|
|
//scprintf("\n[%d] %s %d %d %d %d\n",ci->_ip-ci->_iv->_vals,g_InstrDesc[_i_.op].name,arg0,arg1,arg2,arg3);
|
|
|
|
|
+#ifdef PROFILE_SQVM
|
|
|
|
|
+ OpProfile &opp = _op_profile[_i_.op];
|
|
|
|
|
+ ++opp.count;
|
|
|
|
|
+#endif
|
|
|
switch(_i_.op)
|
|
switch(_i_.op)
|
|
|
{
|
|
{
|
|
|
case _OP_LINE: if (_debughook) CallDebugHook(_SC('l'),arg1); continue;
|
|
case _OP_LINE: if (_debughook) CallDebugHook(_SC('l'),arg1); continue;
|