aboutsummaryrefslogtreecommitdiff
path: root/src/lanes.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/lanes.cpp')
-rw-r--r--src/lanes.cpp34
1 files changed, 17 insertions, 17 deletions
diff --git a/src/lanes.cpp b/src/lanes.cpp
index 6b3a9a1..1f938d4 100644
--- a/src/lanes.cpp
+++ b/src/lanes.cpp
@@ -317,7 +317,7 @@ static void push_stack_trace(lua_State* L, int rc_, int stk_base_)
317 317
318 // For cancellation the error message is CANCEL_ERROR, and a stack trace isn't placed 318 // For cancellation the error message is CANCEL_ERROR, and a stack trace isn't placed
319 // For other errors, the message can be whatever was thrown, and we should have a stack trace table 319 // For other errors, the message can be whatever was thrown, and we should have a stack trace table
320 ASSERT_L(lua_type(L, 1 + stk_base_) == (CANCEL_ERROR.equals(L, stk_base_) ? LUA_TNIL : LUA_TTABLE)); 320 LUA_ASSERT(L, lua_type(L, 1 + stk_base_) == (CANCEL_ERROR.equals(L, stk_base_) ? LUA_TNIL : LUA_TTABLE));
321 // Just leaving the stack trace table on the stack is enough to get it through to the master. 321 // Just leaving the stack trace table on the stack is enough to get it through to the master.
322 break; 322 break;
323 } 323 }
@@ -327,7 +327,7 @@ static void push_stack_trace(lua_State* L, int rc_, int stk_base_)
327 case LUA_ERRERR: // error while running the error handler (if any, for example an out-of-memory condition) 327 case LUA_ERRERR: // error while running the error handler (if any, for example an out-of-memory condition)
328 default: 328 default:
329 // we should have a single value which is either a string (the error message) or CANCEL_ERROR 329 // we should have a single value which is either a string (the error message) or CANCEL_ERROR
330 ASSERT_L((lua_gettop(L) == stk_base_) && ((lua_type(L, stk_base_) == LUA_TSTRING) || CANCEL_ERROR.equals(L, stk_base_))); 330 LUA_ASSERT(L, (lua_gettop(L) == stk_base_) && ((lua_type(L, stk_base_) == LUA_TSTRING) || CANCEL_ERROR.equals(L, stk_base_)));
331 break; 331 break;
332 } 332 }
333} 333}
@@ -367,10 +367,10 @@ static void push_stack_trace(lua_State* L, int rc_, int stk_base_)
367 int args = 0; 367 int args = 0;
368 lua_pushinteger(L, n); // ... finalizers lane_error n 368 lua_pushinteger(L, n); // ... finalizers lane_error n
369 lua_rawget(L, finalizers_index); // ... finalizers lane_error finalizer 369 lua_rawget(L, finalizers_index); // ... finalizers lane_error finalizer
370 ASSERT_L(lua_isfunction(L, -1)); 370 LUA_ASSERT(L, lua_isfunction(L, -1));
371 if (lua_rc_ != LUA_OK) // we have an error message and an optional stack trace at the bottom of the stack 371 if (lua_rc_ != LUA_OK) // we have an error message and an optional stack trace at the bottom of the stack
372 { 372 {
373 ASSERT_L( finalizers_index == 2 || finalizers_index == 3); 373 LUA_ASSERT(L, finalizers_index == 2 || finalizers_index == 3);
374 //char const* err_msg = lua_tostring(L, 1); 374 //char const* err_msg = lua_tostring(L, 1);
375 lua_pushvalue(L, 1); // ... finalizers lane_error finalizer err_msg 375 lua_pushvalue(L, 1); // ... finalizers lane_error finalizer err_msg
376 // note we don't always have a stack trace for example when CANCEL_ERROR, or when we got an error that doesn't call our handler, such as LUA_ERRMEM 376 // note we don't always have a stack trace for example when CANCEL_ERROR, or when we got an error that doesn't call our handler, such as LUA_ERRMEM
@@ -564,7 +564,7 @@ static void selfdestruct_add(Lane* lane_)
564 if (U->timer_deep != nullptr) // test ins case some early internal error prevented Lanes from creating the deep timer 564 if (U->timer_deep != nullptr) // test ins case some early internal error prevented Lanes from creating the deep timer
565 { 565 {
566 [[maybe_unused]] int const prev_ref_count{ U->timer_deep->m_refcount.fetch_sub(1, std::memory_order_relaxed) }; 566 [[maybe_unused]] int const prev_ref_count{ U->timer_deep->m_refcount.fetch_sub(1, std::memory_order_relaxed) };
567 ASSERT_L(prev_ref_count == 1); // this should be the last reference 567 LUA_ASSERT(L, prev_ref_count == 1); // this should be the last reference
568 DeepFactory::DeleteDeepObject(L, U->timer_deep); 568 DeepFactory::DeleteDeepObject(L, U->timer_deep);
569 U->timer_deep = nullptr; 569 U->timer_deep = nullptr;
570 } 570 }
@@ -987,7 +987,7 @@ LUAG_FUNC(lane_new)
987 static constexpr int FIXED_ARGS{ 7 }; 987 static constexpr int FIXED_ARGS{ 7 };
988 int const nargs{ lua_gettop(L) - FIXED_ARGS }; 988 int const nargs{ lua_gettop(L) - FIXED_ARGS };
989 Universe* const U{ universe_get(L) }; 989 Universe* const U{ universe_get(L) };
990 ASSERT_L( nargs >= 0); 990 LUA_ASSERT(L, nargs >= 0);
991 991
992 // public Lanes API accepts a generic range -3/+3 992 // public Lanes API accepts a generic range -3/+3
993 // that will be remapped into the platform-specific scheduler priority scheme 993 // that will be remapped into the platform-specific scheduler priority scheme
@@ -1104,7 +1104,7 @@ LUAG_FUNC(lane_new)
1104 // give a default "Lua" name to the thread to see VM name in Decoda debugger 1104 // give a default "Lua" name to the thread to see VM name in Decoda debugger
1105 lua_pushfstring( L2, "Lane #%p", L2); // "..." 1105 lua_pushfstring( L2, "Lane #%p", L2); // "..."
1106 lua_setglobal( L2, "decoda_name"); // 1106 lua_setglobal( L2, "decoda_name"); //
1107 ASSERT_L( lua_gettop( L2) == 0); 1107 LUA_ASSERT(L, lua_gettop( L2) == 0);
1108 1108
1109 // package 1109 // package
1110 if (package_idx != 0) 1110 if (package_idx != 0)
@@ -1113,7 +1113,7 @@ LUAG_FUNC(lane_new)
1113 // when copying with mode LookupMode::LaneBody, should raise an error in case of problem, not leave it one the stack 1113 // when copying with mode LookupMode::LaneBody, should raise an error in case of problem, not leave it one the stack
1114 InterCopyContext c{ U, Dest{ L2 }, Source{ L }, {}, SourceIndex{ package_idx }, {}, {}, {} }; 1114 InterCopyContext c{ U, Dest{ L2 }, Source{ L }, {}, SourceIndex{ package_idx }, {}, {}, {} };
1115 [[maybe_unused]] InterCopyResult const ret{ c.inter_copy_package() }; 1115 [[maybe_unused]] InterCopyResult const ret{ c.inter_copy_package() };
1116 ASSERT_L(ret == InterCopyResult::Success); // either all went well, or we should not even get here 1116 LUA_ASSERT(L, ret == InterCopyResult::Success); // either all went well, or we should not even get here
1117 } 1117 }
1118 1118
1119 // modules to require in the target lane *before* the function is transfered! 1119 // modules to require in the target lane *before* the function is transfered!
@@ -1228,7 +1228,7 @@ LUAG_FUNC(lane_new)
1228 } 1228 }
1229 STACK_CHECK(L, 0); 1229 STACK_CHECK(L, 0);
1230 STACK_CHECK(L2, 1); 1230 STACK_CHECK(L2, 1);
1231 ASSERT_L(lua_isfunction(L2, 1)); 1231 LUA_ASSERT(L, lua_isfunction(L2, 1));
1232 1232
1233 // revive arguments 1233 // revive arguments
1234 if (nargs > 0) 1234 if (nargs > 0)
@@ -1243,7 +1243,7 @@ LUAG_FUNC(lane_new)
1243 } 1243 }
1244 } 1244 }
1245 STACK_CHECK(L, -nargs); 1245 STACK_CHECK(L, -nargs);
1246 ASSERT_L(lua_gettop( L) == FIXED_ARGS); 1246 LUA_ASSERT(L, lua_gettop( L) == FIXED_ARGS);
1247 1247
1248 // Store 'lane' in the lane's registry, for 'cancel_test()' (we do cancel tests at pending send/receive). 1248 // Store 'lane' in the lane's registry, for 'cancel_test()' (we do cancel tests at pending send/receive).
1249 LANE_POINTER_REGKEY.setValue(L2, [lane](lua_State* L) { lua_pushlightuserdata(L, lane); }); // func [... args ...] 1249 LANE_POINTER_REGKEY.setValue(L2, [lane](lua_State* L) { lua_pushlightuserdata(L, lane); }); // func [... args ...]
@@ -1355,7 +1355,7 @@ LUAG_FUNC(lane_new)
1355void push_thread_status(lua_State* L, Lane* lane_) 1355void push_thread_status(lua_State* L, Lane* lane_)
1356{ 1356{
1357 char const* const str{ thread_status_string(lane_) }; 1357 char const* const str{ thread_status_string(lane_) };
1358 ASSERT_L(str); 1358 LUA_ASSERT(L, str);
1359 1359
1360 lua_pushstring(L, str); 1360 lua_pushstring(L, str);
1361} 1361}
@@ -1430,7 +1430,7 @@ LUAG_FUNC(thread_join)
1430 1430
1431 default: 1431 default:
1432 DEBUGSPEW_CODE(fprintf(stderr, "Status: %d\n", lane->m_status)); 1432 DEBUGSPEW_CODE(fprintf(stderr, "Status: %d\n", lane->m_status));
1433 ASSERT_L(false); 1433 LUA_ASSERT(L, false);
1434 ret = 0; 1434 ret = 0;
1435 } 1435 }
1436 lua_close(L2); 1436 lua_close(L2);
@@ -1454,7 +1454,7 @@ LUAG_FUNC(thread_index)
1454 static constexpr int KEY{ 2 }; 1454 static constexpr int KEY{ 2 };
1455 static constexpr int USR{ 3 }; 1455 static constexpr int USR{ 3 };
1456 Lane* const lane{ ToLane(L, UD) }; 1456 Lane* const lane{ ToLane(L, UD) };
1457 ASSERT_L(lua_gettop(L) == 2); 1457 LUA_ASSERT(L, lua_gettop(L) == 2);
1458 1458
1459 STACK_GROW(L, 8); // up to 8 positions are needed in case of error propagation 1459 STACK_GROW(L, 8); // up to 8 positions are needed in case of error propagation
1460 1460
@@ -1515,7 +1515,7 @@ LUAG_FUNC(thread_index)
1515 // me[-2] could carry the stack table, but even 1515 // me[-2] could carry the stack table, but even
1516 // me[-1] is rather unnecessary (and undocumented); 1516 // me[-1] is rather unnecessary (and undocumented);
1517 // use ':join()' instead. --AKa 22-Jan-2009 1517 // use ':join()' instead. --AKa 22-Jan-2009
1518 ASSERT_L(lua_isnil(L, 4) && !lua_isnil(L, 5) && lua_istable(L, 6)); 1518 LUA_ASSERT(L, lua_isnil(L, 4) && !lua_isnil(L, 5) && lua_istable(L, 6));
1519 // store errstring at key -1 1519 // store errstring at key -1
1520 lua_pushnumber(L, -1); 1520 lua_pushnumber(L, -1);
1521 lua_pushvalue(L, 5); 1521 lua_pushvalue(L, 5);
@@ -1741,7 +1741,7 @@ LUAG_FUNC(configure)
1741 Universe* U = universe_get(L); 1741 Universe* U = universe_get(L);
1742 bool const from_master_state{ U == nullptr }; 1742 bool const from_master_state{ U == nullptr };
1743 char const* name = luaL_checkstring(L, lua_upvalueindex(1)); 1743 char const* name = luaL_checkstring(L, lua_upvalueindex(1));
1744 ASSERT_L(lua_type(L, 1) == LUA_TTABLE); 1744 LUA_ASSERT(L, lua_type(L, 1) == LUA_TTABLE);
1745 1745
1746 STACK_GROW(L, 4); 1746 STACK_GROW(L, 4);
1747 STACK_CHECK_START_ABS(L, 1); // settings 1747 STACK_CHECK_START_ABS(L, 1); // settings
@@ -1832,10 +1832,10 @@ LUAG_FUNC(configure)
1832 lua_pushcfunction(L, LG_thread_index); // settings M mt LG_thread_index 1832 lua_pushcfunction(L, LG_thread_index); // settings M mt LG_thread_index
1833 lua_setfield(L, -2, "__index"); // settings M mt 1833 lua_setfield(L, -2, "__index"); // settings M mt
1834 lua_getglobal(L, "error"); // settings M mt error 1834 lua_getglobal(L, "error"); // settings M mt error
1835 ASSERT_L( lua_isfunction(L, -1)); 1835 LUA_ASSERT(L, lua_isfunction(L, -1));
1836 lua_setfield(L, -2, "cached_error"); // settings M mt 1836 lua_setfield(L, -2, "cached_error"); // settings M mt
1837 lua_getglobal(L, "tostring"); // settings M mt tostring 1837 lua_getglobal(L, "tostring"); // settings M mt tostring
1838 ASSERT_L( lua_isfunction(L, -1)); 1838 LUA_ASSERT(L, lua_isfunction(L, -1));
1839 lua_setfield(L, -2, "cached_tostring"); // settings M mt 1839 lua_setfield(L, -2, "cached_tostring"); // settings M mt
1840 lua_pushcfunction(L, LG_thread_join); // settings M mt LG_thread_join 1840 lua_pushcfunction(L, LG_thread_join); // settings M mt LG_thread_join
1841 lua_setfield(L, -2, "join"); // settings M mt 1841 lua_setfield(L, -2, "join"); // settings M mt