@@ -1399,17 +1399,64 @@ wasm_interp_call_func_import(WASMModuleInstance *module_inst,
1399
1399
#endif /* WASM_ENABLE_DEBUG_INTERP */
1400
1400
#endif /* WASM_ENABLE_THREAD_MGR */
1401
1401
1402
+ #if WASM_ENABLE_THREAD_MGR != 0 && WASM_ENABLE_DEBUG_INTERP != 0
1403
+ #if BH_ATOMIC_32_IS_ATOMIC != 0
1404
+ #define GET_SIGNAL_FLAG () \
1405
+ do { \
1406
+ signal_flag = \
1407
+ BH_ATOMIC_32_LOAD(exec_env->current_status->signal_flag); \
1408
+ } while (0)
1409
+ #else
1410
+ #define GET_SIGNAL_FLAG () \
1411
+ do { \
1412
+ os_mutex_lock(&exec_env->wait_lock); \
1413
+ signal_flag = exec_env->current_status->signal_flag; \
1414
+ os_mutex_unlock(&exec_env->wait_lock); \
1415
+ } while (0)
1416
+ #endif
1417
+ #endif
1418
+
1402
1419
#if WASM_ENABLE_LABELS_AS_VALUES != 0
1403
1420
1404
1421
#define HANDLE_OP (opcode ) HANDLE_##opcode:
1405
1422
#define FETCH_OPCODE_AND_DISPATCH () goto *handle_table[*frame_ip++]
1406
1423
1424
+ #if WASM_ENABLE_THREAD_MGR != 0 && WASM_ENABLE_DEBUG_INTERP != 0
1425
+ #define HANDLE_OP_END () \
1426
+ do { \
1427
+ /* Record the current frame_ip, so when exception occurs, \
1428
+ debugger can know the exact opcode who caused the exception */ \
1429
+ frame_ip_orig = frame_ip ; \
1430
+ /* Atomic load the exec_env's signal_flag first, and then handle \
1431
+ more with lock if it is WAMR_SIG_SINGSTEP */ \
1432
+ GET_SIGNAL_FLAG (); \
1433
+ if (signal_flag == WAMR_SIG_SINGSTEP ) { \
1434
+ os_mutex_lock (& exec_env -> wait_lock ); \
1435
+ while (exec_env -> current_status -> signal_flag == WAMR_SIG_SINGSTEP \
1436
+ && exec_env -> current_status -> step_count ++ == 1 ) { \
1437
+ exec_env -> current_status -> step_count = 0 ; \
1438
+ SYNC_ALL_TO_FRAME (); \
1439
+ wasm_cluster_thread_waiting_run (exec_env ); \
1440
+ } \
1441
+ os_mutex_unlock (& exec_env -> wait_lock ); \
1442
+ } \
1443
+ goto * handle_table [* frame_ip ++ ]; \
1444
+ } while (0 )
1445
+ #else
1446
+ #define HANDLE_OP_END () FETCH_OPCODE_AND_DISPATCH()
1447
+ #endif
1448
+
1449
+ #else /* else of WASM_ENABLE_LABELS_AS_VALUES */
1450
+ #define HANDLE_OP (opcode ) case opcode:
1407
1451
#if WASM_ENABLE_THREAD_MGR != 0 && WASM_ENABLE_DEBUG_INTERP != 0
1408
1452
#define HANDLE_OP_END () \
1409
- do { \
1410
- /* Record the current frame_ip, so when exception occurs, \
1411
- debugger can know the exact opcode who caused the exception */ \
1412
- frame_ip_orig = frame_ip ; \
1453
+ /* Record the current frame_ip, so when exception occurs, \
1454
+ debugger can know the exact opcode who caused the exception */ \
1455
+ frame_ip_orig = frame_ip; \
1456
+ /* Atomic load the exec_env's signal_flag first, and then handle \
1457
+ more with lock if it is WAMR_SIG_SINGSTEP */ \
1458
+ GET_SIGNAL_FLAG (); \
1459
+ if (signal_flag == WAMR_SIG_SINGSTEP ) { \
1413
1460
os_mutex_lock (& exec_env -> wait_lock ); \
1414
1461
while (exec_env -> current_status -> signal_flag == WAMR_SIG_SINGSTEP \
1415
1462
&& exec_env -> current_status -> step_count ++ == 1 ) { \
@@ -1418,25 +1465,8 @@ wasm_interp_call_func_import(WASMModuleInstance *module_inst,
1418
1465
wasm_cluster_thread_waiting_run (exec_env ); \
1419
1466
} \
1420
1467
os_mutex_unlock (& exec_env -> wait_lock ); \
1421
- goto * handle_table [* frame_ip ++ ]; \
1422
- } while (0 )
1423
- #else
1424
- #define HANDLE_OP_END () FETCH_OPCODE_AND_DISPATCH()
1425
- #endif
1426
-
1427
- #else /* else of WASM_ENABLE_LABELS_AS_VALUES */
1428
- #define HANDLE_OP (opcode ) case opcode:
1429
- #if WASM_ENABLE_THREAD_MGR != 0 && WASM_ENABLE_DEBUG_INTERP != 0
1430
- #define HANDLE_OP_END () \
1431
- os_mutex_lock(&exec_env->wait_lock); \
1432
- if (exec_env->current_status->signal_flag == WAMR_SIG_SINGSTEP \
1433
- && exec_env->current_status->step_count++ == 1) { \
1434
- exec_env->current_status->step_count = 0; \
1435
- SYNC_ALL_TO_FRAME(); \
1436
- wasm_cluster_thread_waiting_run(exec_env); \
1437
- } \
1438
- os_mutex_unlock(&exec_env->wait_lock); \
1439
- continue
1468
+ } \
1469
+ continue ;
1440
1470
#else
1441
1471
#define HANDLE_OP_END () continue
1442
1472
#endif
@@ -1545,6 +1575,9 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
1545
1575
debug_instance ? & debug_instance -> watch_point_list_read : NULL ;
1546
1576
bh_list * watch_point_list_write =
1547
1577
debug_instance ? & debug_instance -> watch_point_list_write : NULL ;
1578
+ #if WASM_ENABLE_THREAD_MGR != 0
1579
+ uint32 signal_flag ;
1580
+ #endif
1548
1581
#endif
1549
1582
1550
1583
#if WASM_ENABLE_LABELS_AS_VALUES != 0
0 commit comments