Skip to content

Commit 501bed9

Browse files
committed
Remove duplicate interpret (dead code)
1 parent b82d8a0 commit 501bed9

File tree

1 file changed

+0
-273
lines changed

1 file changed

+0
-273
lines changed

src/Interpreter/instructions.cpp

Lines changed: 0 additions & 273 deletions
Original file line numberDiff line numberDiff line change
@@ -1265,276 +1265,3 @@ bool i_instr_callback(Module *m, uint8_t opcode) {
12651265
// TODO
12661266
return true;
12671267
}
1268-
1269-
bool interpret(Module *m, bool waiting) {
1270-
uint8_t *block_ptr;
1271-
uint8_t opcode;
1272-
1273-
// keep track of occurring errors
1274-
bool success = true;
1275-
1276-
// set to true when finishes successfully
1277-
bool program_done = false;
1278-
1279-
while ((!program_done && success) || waiting) {
1280-
if (m->warduino->program_state == WARDUINOstep) {
1281-
m->warduino->debugger->pauseRuntime(m);
1282-
}
1283-
1284-
while (m->warduino->program_state != WARDUINOinit &&
1285-
m->warduino->debugger->checkDebugMessages(
1286-
m, &m->warduino->program_state)) {
1287-
}
1288-
fflush(stdout);
1289-
// esp_task_wdt_reset();
1290-
1291-
// Resolve 1 callback event if queue is not empty and VM not paused, and
1292-
// no event currently resolving
1293-
CallbackHandler::resolve_event();
1294-
1295-
// Sleep interpret loop if 'paused' or 'waiting drone'
1296-
if (m->warduino->program_state == WARDUINOpause ||
1297-
m->warduino->program_state == PROXYhalt) {
1298-
// wait until new debug messages arrive
1299-
if (m->warduino->program_state == WARDUINOpause) {
1300-
warduino::unique_lock lock(
1301-
m->warduino->debugger->messageQueueMutex);
1302-
m->warduino->debugger->messageQueueConditionVariable.wait(
1303-
lock, [m] { return m->warduino->debugger->freshMessages; });
1304-
}
1305-
continue;
1306-
}
1307-
1308-
// Program state is not paused
1309-
1310-
// If BP and not the one we just unpaused
1311-
if (m->warduino->debugger->isBreakpoint(m->pc_ptr) &&
1312-
m->warduino->debugger->skipBreakpoint != m->pc_ptr &&
1313-
m->warduino->program_state != PROXYrun) {
1314-
m->warduino->debugger->pauseRuntime(m);
1315-
m->warduino->debugger->notifyBreakpoint(m, m->pc_ptr);
1316-
continue;
1317-
}
1318-
m->warduino->debugger->skipBreakpoint = nullptr;
1319-
1320-
// Take snapshot before executing an instruction
1321-
m->warduino->debugger->sendAsyncSnapshots(m);
1322-
1323-
opcode = *m->pc_ptr;
1324-
block_ptr = m->pc_ptr;
1325-
m->pc_ptr += 1;
1326-
1327-
dbg_dump_stack(m);
1328-
dbg_trace(" PC: %p OPCODE: <%s> in %s\n", block_ptr,
1329-
opcode_repr(opcode),
1330-
m->pc_ptr > m->bytes && m->pc_ptr < m->bytes + m->byte_count
1331-
? "module"
1332-
: "patch");
1333-
1334-
switch (opcode) {
1335-
//
1336-
// Control flow operators
1337-
//
1338-
case 0x00: // unreachable
1339-
sprintf(exception, "%s", "unreachable");
1340-
success &= false;
1341-
case 0x01: // nop
1342-
continue;
1343-
case 0x02: // block
1344-
success &= i_instr_block(m, block_ptr);
1345-
continue;
1346-
case 0x03: // loop
1347-
success &= i_instr_loop(m, block_ptr);
1348-
continue;
1349-
case 0x04: // if
1350-
success &= i_instr_if(m, block_ptr);
1351-
continue;
1352-
case 0x05: // else
1353-
success &= i_instr_else(m);
1354-
continue;
1355-
case 0x0b: // end
1356-
success &= i_instr_end(m, &program_done);
1357-
continue;
1358-
case 0x0c: // br
1359-
success &= i_instr_br(m);
1360-
continue;
1361-
case 0x0d: // br_if
1362-
success &= i_instr_br_if(m);
1363-
continue;
1364-
case 0x0e: // br_table
1365-
success &= i_instr_br_table(m);
1366-
continue;
1367-
case 0x0f: // return
1368-
success &= i_instr_return(m);
1369-
continue;
1370-
1371-
//
1372-
// Call operators
1373-
//
1374-
case 0x10: { // call
1375-
success &= i_instr_call(m);
1376-
continue;
1377-
}
1378-
case 0x11: { // call_indirect
1379-
success &= i_instr_call_indirect(m);
1380-
continue;
1381-
}
1382-
//
1383-
// Parametric operators
1384-
//
1385-
case 0x1a: // drop
1386-
success &= i_instr_drop(m);
1387-
continue;
1388-
case 0x1b: // select
1389-
success &= i_instr_select(m);
1390-
continue;
1391-
1392-
//
1393-
// Variable access
1394-
//
1395-
case 0x20: // get_local
1396-
success &= i_instr_get_local(m);
1397-
continue;
1398-
case 0x21: // set_local
1399-
success &= i_instr_set_local(m);
1400-
continue;
1401-
case 0x22: // tee_local
1402-
success &= i_instr_tee_local(m);
1403-
continue;
1404-
case 0x23: // get_global
1405-
success &= i_instr_get_global(m);
1406-
continue;
1407-
case 0x24: // set_global
1408-
success &= i_instr_set_global(m);
1409-
continue;
1410-
1411-
//
1412-
// Memory-related operators
1413-
//
1414-
case 0x3f: // current_memory
1415-
success &= i_instr_current_memory(m);
1416-
continue;
1417-
case 0x40: // grow_memory
1418-
success &= i_instr_grow_memory(m);
1419-
continue;
1420-
// Memory load operators
1421-
case 0x28 ... 0x35:
1422-
success &= i_instr_mem_load(m, opcode);
1423-
continue;
1424-
// Memory store operators
1425-
case 0x36 ... 0x3e:
1426-
success &= i_instr_mem_store(m, opcode);
1427-
continue;
1428-
1429-
//
1430-
// Constants
1431-
//
1432-
case 0x41 ... 0x44: // i32.const
1433-
success &= i_instr_const(m, opcode);
1434-
continue;
1435-
1436-
//
1437-
// Comparison operators
1438-
//
1439-
1440-
// unary
1441-
case 0x45: // i32.eqz
1442-
case 0x50: // i64.eqz
1443-
success &= i_instr_unary_u32(m, opcode);
1444-
continue;
1445-
1446-
// i32 binary
1447-
case 0x46 ... 0x4f:
1448-
success &= i_instr_math_u32(m, opcode);
1449-
continue;
1450-
case 0x51 ... 0x5a:
1451-
success &= i_instr_math_u64(m, opcode);
1452-
continue;
1453-
case 0x5b ... 0x60:
1454-
success &= i_instr_math_f32(m, opcode);
1455-
continue;
1456-
case 0x61 ... 0x66:
1457-
success &= i_instr_math_f64(m, opcode);
1458-
continue;
1459-
1460-
//
1461-
// Numeric operators
1462-
//
1463-
1464-
// unary i32
1465-
case 0x67 ... 0x69:
1466-
success &= i_instr_unary_i32(m, opcode);
1467-
continue;
1468-
1469-
// unary i64
1470-
case 0x79 ... 0x7b:
1471-
success &= i_instr_unary_i64(m, opcode);
1472-
continue;
1473-
1474-
case 0x8b ... 0x91: // unary f32
1475-
case 0x99 ... 0x9f: // unary f64
1476-
success &= i_instr_unary_floating(m, opcode);
1477-
continue;
1478-
1479-
// i32 binary
1480-
case 0x6a ... 0x78:
1481-
success &= i_instr_binary_i32(m, opcode);
1482-
continue;
1483-
1484-
// i64 binary
1485-
case 0x7c ... 0x8a:
1486-
success &= i_instr_binary_i64(m, opcode);
1487-
continue;
1488-
1489-
// f32 binary
1490-
case 0x92 ... 0x98:
1491-
success &= i_instr_binary_f32(m, opcode);
1492-
continue;
1493-
1494-
// f64 binary
1495-
case 0xa0 ... 0xa6:
1496-
success &= i_instr_binary_f64(m, opcode);
1497-
continue;
1498-
1499-
// conversion operations
1500-
case 0xa7 ... 0xbb:
1501-
success &= i_instr_conversion(m, opcode);
1502-
continue;
1503-
1504-
// callback operations
1505-
case 0xe0 ... 0xe3:
1506-
success &= i_instr_callback(m, opcode);
1507-
continue;
1508-
default:
1509-
sprintf(exception, "unrecognized opcode 0x%x", opcode);
1510-
if (m->options.return_exception) {
1511-
m->exception = strdup(exception);
1512-
}
1513-
return false;
1514-
}
1515-
}
1516-
1517-
if (m->warduino->program_state == PROXYrun) {
1518-
dbg_info("Trap was thrown during proxy call.\n");
1519-
RFC *rfc = m->warduino->debugger->topProxyCall();
1520-
rfc->success = false;
1521-
rfc->exception = strdup(exception);
1522-
rfc->exception_size = strlen(exception);
1523-
m->warduino->debugger->sendProxyCallResult(m);
1524-
}
1525-
1526-
// Resolve all unhandled callback events
1527-
while (CallbackHandler::resolving_event && CallbackHandler::resolve_event())
1528-
;
1529-
1530-
dbg_trace("Interpretation ended %s with status %s\n",
1531-
program_done ? "expectedly" : "unexpectedly",
1532-
success ? "ok" : "error");
1533-
if (!success && m->options.return_exception) {
1534-
m->exception = strdup(exception);
1535-
} else if (!success) {
1536-
FATAL("%s\n", exception);
1537-
}
1538-
1539-
return success;
1540-
}

0 commit comments

Comments
 (0)