void bhvm::exec_instruction (const std::string& instruction) { if (instruction == "pop") { exec_pop(); } else if (instruction == "nop") { exec_nop(); } else if (instruction == "calle") { exec_calle(); } else if (instruction == "jump") { exec_jump(); } else if (instruction.substr(0, 5) == "push ") { exec_push(instruction.substr(5)); } else throw Alarm(MTK_HERE, "bhvm", MTK_SS("unknown command " << instruction), alPriorCritic); }
void stask_yield_to_executor(sched_task_t stask) { assert (stask->task->state >= TASK_TRANSITION_TO_WAITING); executor_t exec = stask->executor; bool found; sched_task_t next_stask; TRACE(QS_STASK_FIND_NEXT_START()); if (sync_data_try_dequeue_runnable (stask->sync_data, exec, &next_stask)) { goto yield; } TRACE(QS_STASK_FIND_NEXT_DEQUEUE_END()); found = exec_pop(exec, &next_stask); TRACE(QS_STASK_FIND_NEXT_POP_END()); if (found) { TRACE(QS_STASK_POP_SUCCESS()); goto yield; /* printf("%p stole %p\n", proc, next_proc); */ } next_stask = exec_get_work(exec, 8); TRACE(QS_STASK_FIND_NEXT_GET_WORK_END()); yield: TRACE(QS_STASK_FIND_NEXT_END()); stask_switch(stask, next_stask); }
void bhvm::exec_calle (void) { std::string command = get_top(); exec_pop(); std::map<std::string, CountPtr< Signal<bhvm*> > >::iterator it = map_signal_external_commands.find(command); if (it == map_signal_external_commands.end() || it->second.isValid()==false) throw Alarm(MTK_HERE, "bhvm", MTK_SS("command not registered " << command), alPriorCritic); it->second->emit(this); }
void bhvm::exec_jump (void) { std::string label2jump; if (stack.size() != 0) { label2jump = get_top(); exec_pop(); if (labels.find(label2jump) == labels.end()) { signal_error (Alarm(MTK_HERE, "bhvm", MTK_SS("inexistent label " << label2jump), alPriorCritic)); throw Alarm(MTK_HERE, "bhvm", MTK_SS("inexistent label " << label2jump), alPriorCritic); } else program_counter = labels[label2jump]; } else throw Alarm(MTK_HERE, "bhvm", MTK_SS("no label to jump (empty stack)"), alPriorCritic); }
void exec(Pystat stat){ Arg arg0 = stat->args[0]; Arg arg1 = stat->args[1]; switch(stat->op){ case Y_PUSH: { exec_push(arg0.ival, pc+1); // num_objects break; } case Y_GOTO: { exec_goto(arg0.ival); // absolute line break; } case Y_POP: { exec_pop(); break; } case Y_NEW: { exec_new(arg0.ival); // obj size break; } case Y_NEWS: { exec_news(arg0.ival); // obj size break; } case Y_LDC: { exec_ldc(arg0.ival); break; } case Y_LDI: { exec_ldi(arg0.ival); break; } case Y_LDR: { exec_ldr(arg0.rval); break; } case Y_LDS: { exec_lds(arg0.sval); break; } case Y_LOD: { exec_lod(arg0.ival); // oid break; } case Y_GLOD: { exec_glod(arg0.ival); // oid break; } case Y_CAT: { exec_cat(arg0.ival, arg1.ival); // num fields, record/array size break; } case Y_LDA: { exec_lda(arg0.ival); // oid break; } case Y_GLDA: { exec_glda(arg0.ival); // oid break; } case Y_FDA: { exec_fda(arg0.ival); // field offset break; } case Y_EIL: { exec_eil(arg0.ival); // field size, embedded break; } case Y_SIL: { exec_sil(arg0.ival); // field size, on stack break; } case Y_IXA: { exec_ixa(arg0.ival); // elem size break; } case Y_STO: { exec_sto(arg0.ival); // oid break; } case Y_GSTO: { exec_gsto(arg0.ival); // oid break; } case Y_IST: { exec_ist(); // indirect store break; } case Y_JMF: { exec_jmf(arg0.ival); // offset break; } case Y_JMP: { exec_jmp(arg0.ival); // offset break; } case Y_EQU: { exec_equ(); // for all types of objects break; } case Y_NEQ: { exec_neq(); // for all types of objects break; } case Y_IGT: { exec_igt(); break; } case Y_IGE: { exec_ige(); break; } case Y_ILT: { exec_ilt(); break; } case Y_ILE: { exec_ile(); break; } case Y_RGT: { exec_rgt(); break; } case Y_RGE: { exec_rge(); break; } case Y_RLT: { exec_rlt(); break; } case Y_RLE: { exec_rle(); break; } case Y_SGT: { exec_sgt(); break; } case Y_SGE: { exec_sge(); break; } case Y_SLT: { exec_slt(); break; } case Y_SLE: { exec_sle(); break; } case Y_IPLUS: { exec_iplus(); break; } case Y_IMINUS: { exec_iminus(); break; } case Y_ITIMES: { exec_itimes(); break; } case Y_IDIV: { exec_idiv(); break; } case Y_RPLUS: { exec_rplus(); break; } case Y_RMINUS: { exec_rminus(); break; } case Y_RTIMES: { exec_rtimes(); break; } case Y_RDIV: { exec_rdiv(); break; } case Y_IUMI: { exec_iumi(); break; } case Y_RUMI: { exec_rumi(); break; } case Y_NEG: { exec_neg(); break; } case Y_WR: { exec_wr(arg0.sval, 1, stdout); // schema break; } case Y_FWR: { exec_fwr(arg0.sval); // schema break; } case Y_RD: { exec_rd(arg0.sval, 1, stdin); // schema break; } case Y_FRD: { exec_frd(arg0.sval); // schema break; } case Y_TOINT: { exec_toint(); break; } case Y_TOINTUP: { exec_tointup(); break; } case Y_TOREAL: { exec_toreal(); break; } case Y_READ: { exec_read(arg0.ival, arg1.sval, 1, stdin); // oid, schema break; } case Y_GREAD: { exec_gread(arg0.ival, arg1.sval, 1, stdin); // oid, schema break; } case Y_FREAD: { exec_fread(arg0.ival, arg1.sval); // oid, schema break; } case Y_GFREAD: { exec_gfread(arg0.ival, arg1.sval); // oid, schema break; } case Y_WRITE: { exec_write(arg0.sval); // schema break; } case Y_FWRITE: { exec_fwrite(arg0.sval); // schema break; } case Y_TDUP: { exec_tdup(); break; } case Y_TPOP: { exec_tpop(arg0.ival); // num objects break; } case Y_MODULE: { // nothing to do here, the instruction is useless break; } case Y_RETURN: { exec_return(); break; } default: { machine_error("Unknown instruction."); break; } } }