diff options
Diffstat (limited to 'src/lanes.cpp')
-rw-r--r-- | src/lanes.cpp | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/src/lanes.cpp b/src/lanes.cpp index f549359..462de0f 100644 --- a/src/lanes.cpp +++ b/src/lanes.cpp | |||
@@ -540,7 +540,7 @@ static void selfdestruct_add(Lane* lane_) | |||
540 | if (lane != SELFDESTRUCT_END) | 540 | if (lane != SELFDESTRUCT_END) |
541 | { | 541 | { |
542 | // this causes a leak because we don't call U's destructor (which could be bad if the still running lanes are accessing it) | 542 | // this causes a leak because we don't call U's destructor (which could be bad if the still running lanes are accessing it) |
543 | std::ignore = luaL_error(L, "Zombie thread %s refuses to die!", lane->debug_name); // doesn't return | 543 | luaL_error(L, "Zombie thread %s refuses to die!", lane->debug_name); // doesn't return |
544 | } | 544 | } |
545 | } | 545 | } |
546 | 546 | ||
@@ -1134,7 +1134,8 @@ LUAG_FUNC(lane_new) | |||
1134 | { | 1134 | { |
1135 | DEBUGSPEW_CODE(fprintf(stderr, INDENT_BEGIN "lane_new: update 'package'\n" INDENT_END)); | 1135 | DEBUGSPEW_CODE(fprintf(stderr, INDENT_BEGIN "lane_new: update 'package'\n" INDENT_END)); |
1136 | // when copying with mode LookupMode::LaneBody, should raise an error in case of problem, not leave it one the stack | 1136 | // when copying with mode LookupMode::LaneBody, should raise an error in case of problem, not leave it one the stack |
1137 | std::ignore = luaG_inter_copy_package(U, Source{ L }, Dest{ L2 }, package_idx, LookupMode::LaneBody); | 1137 | [[maybe_unused]] InterCopyResult const ret{ luaG_inter_copy_package(U, Source{ L }, Dest{ L2 }, package_idx, LookupMode::LaneBody) }; |
1138 | ASSERT_L(ret == InterCopyResult::Success); // either all went well, or we should not even get here | ||
1138 | } | 1139 | } |
1139 | 1140 | ||
1140 | // modules to require in the target lane *before* the function is transfered! | 1141 | // modules to require in the target lane *before* the function is transfered! |
@@ -1146,7 +1147,7 @@ LUAG_FUNC(lane_new) | |||
1146 | // should not happen, was checked in lanes.lua before calling lane_new() | 1147 | // should not happen, was checked in lanes.lua before calling lane_new() |
1147 | if (lua_type(L, required_idx) != LUA_TTABLE) | 1148 | if (lua_type(L, required_idx) != LUA_TTABLE) |
1148 | { | 1149 | { |
1149 | return luaL_error(L, "expected required module list as a table, got %s", luaL_typename(L, required_idx)); | 1150 | luaL_error(L, "expected required module list as a table, got %s", luaL_typename(L, required_idx)); // doesn't return |
1150 | } | 1151 | } |
1151 | 1152 | ||
1152 | lua_pushnil(L); // func libs priority globals package required gc_cb [... args ...] nil | 1153 | lua_pushnil(L); // func libs priority globals package required gc_cb [... args ...] nil |
@@ -1154,7 +1155,7 @@ LUAG_FUNC(lane_new) | |||
1154 | { | 1155 | { |
1155 | if (lua_type(L, -1) != LUA_TSTRING || lua_type(L, -2) != LUA_TNUMBER || lua_tonumber(L, -2) != nbRequired) | 1156 | if (lua_type(L, -1) != LUA_TSTRING || lua_type(L, -2) != LUA_TNUMBER || lua_tonumber(L, -2) != nbRequired) |
1156 | { | 1157 | { |
1157 | return luaL_error(L, "required module list should be a list of strings"); | 1158 | luaL_error(L, "required module list should be a list of strings"); // doesn't return |
1158 | } | 1159 | } |
1159 | else | 1160 | else |
1160 | { | 1161 | { |
@@ -1168,7 +1169,7 @@ LUAG_FUNC(lane_new) | |||
1168 | if (lua_isnil( L2, -1)) | 1169 | if (lua_isnil( L2, -1)) |
1169 | { | 1170 | { |
1170 | lua_pop( L2, 1); // | 1171 | lua_pop( L2, 1); // |
1171 | return luaL_error(L, "cannot pre-require modules without loading 'package' library first"); | 1172 | luaL_error(L, "cannot pre-require modules without loading 'package' library first"); // doesn't return |
1172 | } | 1173 | } |
1173 | else | 1174 | else |
1174 | { | 1175 | { |
@@ -1203,7 +1204,7 @@ LUAG_FUNC(lane_new) | |||
1203 | DEBUGSPEW_CODE( fprintf( stderr, INDENT_BEGIN "lane_new: transfer globals\n" INDENT_END)); | 1204 | DEBUGSPEW_CODE( fprintf( stderr, INDENT_BEGIN "lane_new: transfer globals\n" INDENT_END)); |
1204 | if (!lua_istable(L, globals_idx)) | 1205 | if (!lua_istable(L, globals_idx)) |
1205 | { | 1206 | { |
1206 | return luaL_error(L, "Expected table, got %s", luaL_typename(L, globals_idx)); | 1207 | luaL_error(L, "Expected table, got %s", luaL_typename(L, globals_idx)); // doesn't return |
1207 | } | 1208 | } |
1208 | 1209 | ||
1209 | DEBUGSPEW_CODE(U->debugspew_indent_depth.fetch_add(1, std::memory_order_relaxed)); | 1210 | DEBUGSPEW_CODE(U->debugspew_indent_depth.fetch_add(1, std::memory_order_relaxed)); |
@@ -1230,11 +1231,11 @@ LUAG_FUNC(lane_new) | |||
1230 | DEBUGSPEW_CODE(fprintf( stderr, INDENT_BEGIN "lane_new: transfer lane body\n" INDENT_END)); | 1231 | DEBUGSPEW_CODE(fprintf( stderr, INDENT_BEGIN "lane_new: transfer lane body\n" INDENT_END)); |
1231 | DEBUGSPEW_CODE(U->debugspew_indent_depth.fetch_add(1, std::memory_order_relaxed)); | 1232 | DEBUGSPEW_CODE(U->debugspew_indent_depth.fetch_add(1, std::memory_order_relaxed)); |
1232 | lua_pushvalue(L, 1); // func libs priority globals package required gc_cb [... args ...] func | 1233 | lua_pushvalue(L, 1); // func libs priority globals package required gc_cb [... args ...] func |
1233 | int const res{ luaG_inter_move(U, Source{ L }, Dest{ L2 }, 1, LookupMode::LaneBody) }; // func libs priority globals package required gc_cb [... args ...] // func | 1234 | InterCopyResult const res{ luaG_inter_move(U, Source{ L }, Dest{ L2 }, 1, LookupMode::LaneBody) }; // func libs priority globals package required gc_cb [... args ...] // func |
1234 | DEBUGSPEW_CODE(U->debugspew_indent_depth.fetch_sub(1, std::memory_order_relaxed)); | 1235 | DEBUGSPEW_CODE(U->debugspew_indent_depth.fetch_sub(1, std::memory_order_relaxed)); |
1235 | if (res != 0) | 1236 | if (res != InterCopyResult::Success) |
1236 | { | 1237 | { |
1237 | return luaL_error(L, "tried to copy unsupported types"); | 1238 | luaL_error(L, "tried to copy unsupported types"); // doesn't return |
1238 | } | 1239 | } |
1239 | } | 1240 | } |
1240 | else if (lua_type(L, 1) == LUA_TSTRING) | 1241 | else if (lua_type(L, 1) == LUA_TSTRING) |
@@ -1243,7 +1244,7 @@ LUAG_FUNC(lane_new) | |||
1243 | // compile the string | 1244 | // compile the string |
1244 | if (luaL_loadstring(L2, lua_tostring(L, 1)) != 0) // func | 1245 | if (luaL_loadstring(L2, lua_tostring(L, 1)) != 0) // func |
1245 | { | 1246 | { |
1246 | return luaL_error(L, "error when parsing lane function code"); | 1247 | luaL_error(L, "error when parsing lane function code"); // doesn't return |
1247 | } | 1248 | } |
1248 | } | 1249 | } |
1249 | STACK_CHECK(L, 0); | 1250 | STACK_CHECK(L, 0); |
@@ -1253,14 +1254,13 @@ LUAG_FUNC(lane_new) | |||
1253 | // revive arguments | 1254 | // revive arguments |
1254 | if (nargs > 0) | 1255 | if (nargs > 0) |
1255 | { | 1256 | { |
1256 | int res; | ||
1257 | DEBUGSPEW_CODE(fprintf( stderr, INDENT_BEGIN "lane_new: transfer lane arguments\n" INDENT_END)); | 1257 | DEBUGSPEW_CODE(fprintf( stderr, INDENT_BEGIN "lane_new: transfer lane arguments\n" INDENT_END)); |
1258 | DEBUGSPEW_CODE(U->debugspew_indent_depth.fetch_add(1, std::memory_order_relaxed)); | 1258 | DEBUGSPEW_CODE(U->debugspew_indent_depth.fetch_add(1, std::memory_order_relaxed)); |
1259 | res = luaG_inter_move(U, Source{ L }, Dest{ L2 }, nargs, LookupMode::LaneBody); // func libs priority globals package required gc_cb // func [... args ...] | 1259 | InterCopyResult const res{ luaG_inter_move(U, Source{ L }, Dest{ L2 }, nargs, LookupMode::LaneBody) }; // func libs priority globals package required gc_cb // func [... args ...] |
1260 | DEBUGSPEW_CODE(U->debugspew_indent_depth.fetch_sub(1, std::memory_order_relaxed)); | 1260 | DEBUGSPEW_CODE(U->debugspew_indent_depth.fetch_sub(1, std::memory_order_relaxed)); |
1261 | if (res != 0) | 1261 | if (res != InterCopyResult::Success) |
1262 | { | 1262 | { |
1263 | return luaL_error(L, "tried to copy unsupported types"); | 1263 | luaL_error(L, "tried to copy unsupported types"); // doesn't return |
1264 | } | 1264 | } |
1265 | } | 1265 | } |
1266 | STACK_CHECK(L, -nargs); | 1266 | STACK_CHECK(L, -nargs); |
@@ -1420,9 +1420,9 @@ LUAG_FUNC(thread_join) | |||
1420 | case Lane::Done: | 1420 | case Lane::Done: |
1421 | { | 1421 | { |
1422 | int const n{ lua_gettop(L2) }; // whole L2 stack | 1422 | int const n{ lua_gettop(L2) }; // whole L2 stack |
1423 | if ((n > 0) && (luaG_inter_move(U, Source{ L2 }, Dest{ L }, n, LookupMode::LaneBody) != 0)) | 1423 | if ((n > 0) && (luaG_inter_move(U, Source{ L2 }, Dest{ L }, n, LookupMode::LaneBody) != InterCopyResult::Success)) |
1424 | { | 1424 | { |
1425 | return luaL_error(L, "tried to copy unsupported types"); | 1425 | luaL_error(L, "tried to copy unsupported types"); // doesn't return |
1426 | } | 1426 | } |
1427 | ret = n; | 1427 | ret = n; |
1428 | } | 1428 | } |
@@ -1434,9 +1434,9 @@ LUAG_FUNC(thread_join) | |||
1434 | STACK_GROW(L, 3); | 1434 | STACK_GROW(L, 3); |
1435 | lua_pushnil(L); | 1435 | lua_pushnil(L); |
1436 | // even when ERROR_FULL_STACK, if the error is not LUA_ERRRUN, the handler wasn't called, and we only have 1 error message on the stack ... | 1436 | // even when ERROR_FULL_STACK, if the error is not LUA_ERRRUN, the handler wasn't called, and we only have 1 error message on the stack ... |
1437 | if (luaG_inter_move(U, Source{ L2 }, Dest{ L }, n, LookupMode::LaneBody) != 0) // nil "err" [trace] | 1437 | if (luaG_inter_move(U, Source{ L2 }, Dest{ L }, n, LookupMode::LaneBody) != InterCopyResult::Success) // nil "err" [trace] |
1438 | { | 1438 | { |
1439 | return luaL_error(L, "tried to copy unsupported types: %s", lua_tostring(L, -n)); | 1439 | luaL_error(L, "tried to copy unsupported types: %s", lua_tostring(L, -n)); // doesn't return |
1440 | } | 1440 | } |
1441 | ret = 1 + n; | 1441 | ret = 1 + n; |
1442 | } | 1442 | } |