/[svn]/linuxsampler/trunk/src/scriptvm/ScriptVM.cpp
ViewVC logotype

Diff of /linuxsampler/trunk/src/scriptvm/ScriptVM.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 3076 by schoenebeck, Thu Jan 5 18:00:52 2017 UTC revision 3277 by schoenebeck, Mon Jun 5 18:40:18 2017 UTC
# Line 117  namespace LinuxSampler { Line 117  namespace LinuxSampler {
117                  else                  else
118                      return 1;                      return 1;
119              }              }
120    
121                case STMT_SYNC: {
122                    #if DEBUG_SCRIPTVM_CORE
123                    _printIndents(depth);
124                    printf("-> STMT_SYNC\n");
125                    #endif
126                    SyncBlock* syncStmt = (SyncBlock*) statement;
127                    if (syncStmt->statements())
128                        return _requiredMaxStackSizeFor( syncStmt->statements() ) + 1;
129                    else
130                        return 1;
131                }
132          }          }
133    
134          return 1; // actually just to avoid compiler warning          return 1; // actually just to avoid compiler warning
# Line 147  namespace LinuxSampler { Line 159  namespace LinuxSampler {
159          m_fnShRight = new CoreVMFunction_sh_right;          m_fnShRight = new CoreVMFunction_sh_right;
160          m_fnMin = new CoreVMFunction_min;          m_fnMin = new CoreVMFunction_min;
161          m_fnMax = new CoreVMFunction_max;          m_fnMax = new CoreVMFunction_max;
162            m_fnArrayEqual = new CoreVMFunction_array_equal;
163            m_fnSearch = new CoreVMFunction_search;
164            m_fnSort = new CoreVMFunction_sort;
165      }      }
166    
167      ScriptVM::~ScriptVM() {      ScriptVM::~ScriptVM() {
# Line 163  namespace LinuxSampler { Line 178  namespace LinuxSampler {
178          delete m_fnShRight;          delete m_fnShRight;
179          delete m_fnMin;          delete m_fnMin;
180          delete m_fnMax;          delete m_fnMax;
181            delete m_fnArrayEqual;
182            delete m_fnSearch;
183            delete m_fnSort;
184          delete m_varRealTimer;          delete m_varRealTimer;
185          delete m_varPerfTimer;          delete m_varPerfTimer;
186      }      }
# Line 269  namespace LinuxSampler { Line 287  namespace LinuxSampler {
287          else if (name == "sh_right") return m_fnShRight;          else if (name == "sh_right") return m_fnShRight;
288          else if (name == "min") return m_fnMin;          else if (name == "min") return m_fnMin;
289          else if (name == "max") return m_fnMax;          else if (name == "max") return m_fnMax;
290            else if (name == "array_equal") return m_fnArrayEqual;
291            else if (name == "search") return m_fnSearch;
292            else if (name == "sort") return m_fnSort;
293          return NULL;          return NULL;
294      }      }
295    
# Line 344  namespace LinuxSampler { Line 365  namespace LinuxSampler {
365          m_parserContext->execContext = ctx;          m_parserContext->execContext = ctx;
366    
367          ctx->status = VM_EXEC_RUNNING;          ctx->status = VM_EXEC_RUNNING;
368          StmtFlags_t flags = STMT_SUCCESS;          ctx->instructionsCount = 0;
369            StmtFlags_t& flags = ctx->flags;
370          int instructionsCounter = 0;          int instructionsCounter = 0;
371            int synced = m_autoSuspend ? 0 : 1;
372    
373          int& frameIdx = ctx->stackFrame;          int& frameIdx = ctx->stackFrame;
374          if (frameIdx < 0) { // start condition ...          if (frameIdx < 0) { // start condition ...
# Line 422  namespace LinuxSampler { Line 445  namespace LinuxSampler {
445                          ctx->pushStack(                          ctx->pushStack(
446                              whileStmt->statements()                              whileStmt->statements()
447                          );                          );
448                          if (flags == STMT_SUCCESS && m_autoSuspend &&                          if (flags == STMT_SUCCESS && !synced &&
449                              instructionsCounter > SCRIPTVM_MAX_INSTR_PER_CYCLE_SOFT)                              instructionsCounter > SCRIPTVM_MAX_INSTR_PER_CYCLE_SOFT)
450                          {                          {
451                              flags = StmtFlags_t(STMT_SUSPEND_SIGNALLED);                              flags = StmtFlags_t(STMT_SUSPEND_SIGNALLED);
# Line 431  namespace LinuxSampler { Line 454  namespace LinuxSampler {
454                      } else ctx->popStack();                      } else ctx->popStack();
455                      break;                      break;
456                  }                  }
457    
458                    case STMT_SYNC: {
459                        #if DEBUG_SCRIPTVM_CORE
460                        _printIndents(frameIdx);
461                        printf("-> STMT_SYNC\n");
462                        #endif
463                        SyncBlock* syncStmt = (SyncBlock*) frame.statement;
464                        if (!frame.subindex++ && syncStmt->statements()) {
465                            ++synced;
466                            ctx->pushStack(
467                                syncStmt->statements()
468                            );
469                        } else {
470                            ctx->popStack();
471                            --synced;
472                        }
473                        break;
474                    }
475              }              }
476    
477              if (flags == STMT_SUCCESS && m_autoSuspend &&              if (flags == STMT_SUCCESS && !synced &&
478                  instructionsCounter > SCRIPTVM_MAX_INSTR_PER_CYCLE_HARD)                  instructionsCounter > SCRIPTVM_MAX_INSTR_PER_CYCLE_HARD)
479              {              {
480                  flags = StmtFlags_t(STMT_SUSPEND_SIGNALLED);                  flags = StmtFlags_t(STMT_SUSPEND_SIGNALLED);
# Line 443  namespace LinuxSampler { Line 484  namespace LinuxSampler {
484              ++instructionsCounter;              ++instructionsCounter;
485          }          }
486    
487          if (flags & STMT_SUSPEND_SIGNALLED) {          if ((flags & STMT_SUSPEND_SIGNALLED) && !(flags & STMT_ABORT_SIGNALLED)) {
488              ctx->status = VM_EXEC_SUSPENDED;              ctx->status = VM_EXEC_SUSPENDED;
489                ctx->flags  = STMT_SUCCESS;
490          } else {          } else {
491              ctx->status = VM_EXEC_NOT_RUNNING;              ctx->status = VM_EXEC_NOT_RUNNING;
492              if (flags & STMT_ERROR_OCCURRED)              if (flags & STMT_ERROR_OCCURRED)
# Line 452  namespace LinuxSampler { Line 494  namespace LinuxSampler {
494              ctx->reset();              ctx->reset();
495          }          }
496    
497            ctx->instructionsCount = instructionsCounter;
498    
499          m_eventHandler = NULL;          m_eventHandler = NULL;
500          m_parserContext->execContext = NULL;          m_parserContext->execContext = NULL;
501          m_parserContext = NULL;          m_parserContext = NULL;

Legend:
Removed from v.3076  
changed lines
  Added in v.3277

  ViewVC Help
Powered by ViewVC