diff options
author | Benoit Germain <benoit.germain@ubisoft.com> | 2024-06-10 18:16:57 +0200 |
---|---|---|
committer | Benoit Germain <benoit.germain@ubisoft.com> | 2024-06-10 18:16:57 +0200 |
commit | 7d31e295dc782afc92f3215d1571e629a5407fbf (patch) | |
tree | 2be6f774be1b41f65dd4e8c015712dacee42c21b /src | |
parent | ae582acdb1bfb3fb4171682b884545d174e95aa9 (diff) | |
download | lanes-7d31e295dc782afc92f3215d1571e629a5407fbf.tar.gz lanes-7d31e295dc782afc92f3215d1571e629a5407fbf.tar.bz2 lanes-7d31e295dc782afc92f3215d1571e629a5407fbf.zip |
Removed .demote_full_userdata
Diffstat (limited to 'src')
-rw-r--r-- | src/intercopycontext.cpp | 19 | ||||
-rw-r--r-- | src/lanes.lua | 2 | ||||
-rw-r--r-- | src/universe.cpp | 4 | ||||
-rw-r--r-- | src/universe.h | 2 |
4 files changed, 4 insertions, 23 deletions
diff --git a/src/intercopycontext.cpp b/src/intercopycontext.cpp index a5fd400..5be4304 100644 --- a/src/intercopycontext.cpp +++ b/src/intercopycontext.cpp | |||
@@ -718,6 +718,8 @@ LuaType InterCopyContext::processConversion() const | |||
718 | return false; | 718 | return false; |
719 | } | 719 | } |
720 | 720 | ||
721 | DEBUGSPEW_CODE(DebugSpew(U) << "CLONABLE USERDATA" << std::endl); | ||
722 | |||
721 | // we need to copy over the uservalues of the userdata as well | 723 | // we need to copy over the uservalues of the userdata as well |
722 | { | 724 | { |
723 | int const _mt{ luaG_absindex(L1, -2) }; // L1: ... mt __lanesclone | 725 | int const _mt{ luaG_absindex(L1, -2) }; // L1: ... mt __lanesclone |
@@ -795,6 +797,7 @@ LuaType InterCopyContext::processConversion() const | |||
795 | return false; // not a deep userdata | 797 | return false; // not a deep userdata |
796 | } | 798 | } |
797 | 799 | ||
800 | DEBUGSPEW_CODE(DebugSpew(U) << "DEEP USERDATA" << std::endl); | ||
798 | STACK_CHECK_START_REL(L1, 0); | 801 | STACK_CHECK_START_REL(L1, 0); |
799 | STACK_CHECK_START_REL(L2, 0); | 802 | STACK_CHECK_START_REL(L2, 0); |
800 | 803 | ||
@@ -1085,27 +1088,13 @@ LuaType InterCopyContext::processConversion() const | |||
1085 | STACK_CHECK(L2, 0); | 1088 | STACK_CHECK(L2, 0); |
1086 | 1089 | ||
1087 | // Allow only deep userdata entities to be copied across | 1090 | // Allow only deep userdata entities to be copied across |
1088 | DEBUGSPEW_CODE(DebugSpew(nullptr) << "USERDATA" << std::endl); | ||
1089 | if (tryCopyDeep()) { | 1091 | if (tryCopyDeep()) { |
1090 | STACK_CHECK(L1, 0); | 1092 | STACK_CHECK(L1, 0); |
1091 | STACK_CHECK(L2, 1); | 1093 | STACK_CHECK(L2, 1); |
1092 | return true; | 1094 | return true; |
1093 | } | 1095 | } |
1094 | 1096 | ||
1095 | STACK_CHECK(L1, 0); | 1097 | raise_luaL_error(getErrL(), "can't copy non-deep full userdata across lanes"); |
1096 | STACK_CHECK(L2, 0); | ||
1097 | |||
1098 | // Not a deep or clonable full userdata | ||
1099 | if (U->demoteFullUserdata) { // attempt demotion to light userdata | ||
1100 | void* const _lud{ lua_touserdata(L1, L1_i) }; | ||
1101 | lua_pushlightuserdata(L2, _lud); | ||
1102 | } else { // raise an error | ||
1103 | raise_luaL_error(getErrL(), "can't copy non-deep full userdata across lanes"); | ||
1104 | } | ||
1105 | |||
1106 | STACK_CHECK(L2, 1); | ||
1107 | STACK_CHECK(L1, 0); | ||
1108 | return true; | ||
1109 | } | 1098 | } |
1110 | 1099 | ||
1111 | // ################################################################################################# | 1100 | // ################################################################################################# |
diff --git a/src/lanes.lua b/src/lanes.lua index 92e773a..1378412 100644 --- a/src/lanes.lua +++ b/src/lanes.lua | |||
@@ -92,7 +92,6 @@ local default_params = | |||
92 | { | 92 | { |
93 | -- LuaJIT provides a thread-unsafe allocator by default, so we need to protect it when used in parallel lanes | 93 | -- LuaJIT provides a thread-unsafe allocator by default, so we need to protect it when used in parallel lanes |
94 | allocator = isLuaJIT and "protected" or nil, | 94 | allocator = isLuaJIT and "protected" or nil, |
95 | demote_full_userdata = nil, | ||
96 | -- it looks also like LuaJIT allocator may not appreciate direct use of its allocator for other purposes than the VM operation | 95 | -- it looks also like LuaJIT allocator may not appreciate direct use of its allocator for other purposes than the VM operation |
97 | internal_allocator = isLuaJIT and "libc" or "allocator", | 96 | internal_allocator = isLuaJIT and "libc" or "allocator", |
98 | keepers_gc_threshold = -1, | 97 | keepers_gc_threshold = -1, |
@@ -119,7 +118,6 @@ local param_checkers = | |||
119 | -- can be nil, "protected", or a function | 118 | -- can be nil, "protected", or a function |
120 | return val_ and (type(val_) == "function" or val_ == "protected") or true | 119 | return val_ and (type(val_) == "function" or val_ == "protected") or true |
121 | end, | 120 | end, |
122 | demote_full_userdata = boolean_param_checker, | ||
123 | internal_allocator = function(val_) | 121 | internal_allocator = function(val_) |
124 | -- can be "libc" or "allocator" | 122 | -- can be "libc" or "allocator" |
125 | return val_ == "libc" or val_ == "allocator" | 123 | return val_ == "libc" or val_ == "allocator" |
diff --git a/src/universe.cpp b/src/universe.cpp index 9ab6019..82522f1 100644 --- a/src/universe.cpp +++ b/src/universe.cpp | |||
@@ -107,7 +107,6 @@ Universe::Universe() | |||
107 | lua_setmetatable(L_, -2); // L_: settings universe | 107 | lua_setmetatable(L_, -2); // L_: settings universe |
108 | lua_pop(L_, 1); // L_: settings | 108 | lua_pop(L_, 1); // L_: settings |
109 | 109 | ||
110 | // TODO: write some tests to see what happens when we trigger errors in stripped mode | ||
111 | std::ignore = luaG_getfield(L_, 1, "strip_functions"); // L_: settings strip_functions | 110 | std::ignore = luaG_getfield(L_, 1, "strip_functions"); // L_: settings strip_functions |
112 | _U->stripFunctions = lua_toboolean(L_, -1) ? true : false; | 111 | _U->stripFunctions = lua_toboolean(L_, -1) ? true : false; |
113 | lua_pop(L_, 1); // L_: settings | 112 | lua_pop(L_, 1); // L_: settings |
@@ -115,9 +114,6 @@ Universe::Universe() | |||
115 | std::ignore = luaG_getfield(L_, 1, "verbose_errors"); // L_: settings verbose_errors | 114 | std::ignore = luaG_getfield(L_, 1, "verbose_errors"); // L_: settings verbose_errors |
116 | _U->verboseErrors = lua_toboolean(L_, -1) ? true : false; | 115 | _U->verboseErrors = lua_toboolean(L_, -1) ? true : false; |
117 | lua_pop(L_, 1); // L_: settings | 116 | lua_pop(L_, 1); // L_: settings |
118 | std::ignore = luaG_getfield(L_, 1, "demote_full_userdata"); // L_: settings demote_full_userdata | ||
119 | _U->demoteFullUserdata = lua_toboolean(L_, -1) ? true : false; | ||
120 | lua_pop(L_, 1); // L_: settings | ||
121 | 117 | ||
122 | // tracking | 118 | // tracking |
123 | std::ignore = luaG_getfield(L_, 1, "track_lanes"); // L_: settings track_lanes | 119 | std::ignore = luaG_getfield(L_, 1, "track_lanes"); // L_: settings track_lanes |
diff --git a/src/universe.h b/src/universe.h index 2b8cdf2..f0975d8 100644 --- a/src/universe.h +++ b/src/universe.h | |||
@@ -128,8 +128,6 @@ class Universe | |||
128 | // for verbose errors | 128 | // for verbose errors |
129 | bool verboseErrors{ false }; | 129 | bool verboseErrors{ false }; |
130 | 130 | ||
131 | bool demoteFullUserdata{ false }; | ||
132 | |||
133 | bool stripFunctions{ true }; | 131 | bool stripFunctions{ true }; |
134 | 132 | ||
135 | // before a state is created, this function will be called to obtain the allocator | 133 | // before a state is created, this function will be called to obtain the allocator |