From c1c3d02bf09116948742870de1a22f35862ccd6c Mon Sep 17 00:00:00 2001 From: Mike Nolan Date: Tue, 1 Sep 2026 06:04:58 -0500 Subject: [PATCH] Replace time-based GC with allocation-count trigger, migrate all Create factories to GCList::Create(), fix VFSPath root path, reorder TObject variant --- include/CrossLang.hpp | 4 +-- src/program_lib/crosslangcompiler.cpp | 4 +-- src/runtime_methods/class.cpp | 4 +-- src/runtime_methods/env.cpp | 4 --- src/runtime_methods/net.cpp | 4 +-- src/runtime_methods/std.cpp | 38 ++++++++++----------------- src/vm/bc/executemethod2.cpp | 4 +-- src/vm/gc.cpp | 5 +--- 8 files changed, 25 insertions(+), 42 deletions(-) diff --git a/include/CrossLang.hpp b/include/CrossLang.hpp index 69fc3be..bb3dde1 100644 --- a/include/CrossLang.hpp +++ b/include/CrossLang.hpp @@ -1815,7 +1815,7 @@ class EnvironmentPermissions { bool canRegisterPath; bool canRegisterOGC; bool canRegisterEnv; - bool canRegisterClass; + bool canRegisterZeClass; bool sqlite3Scoped; bool locked; TDictionary *customConsole = nullptr; @@ -1903,7 +1903,7 @@ class TStd { static void RegisterOGC(std::shared_ptr gc, TRootEnvironment *env); static void RegisterEnv(std::shared_ptr gc, TRootEnvironment *env); static void RegisterProcess(std::shared_ptr gc, TRootEnvironment *env); - static void RegisterClass(std::shared_ptr gc, TRootEnvironment *env); + static void RegisterZeClass(std::shared_ptr gc, TRootEnvironment *env); }; class TSubEnvironment : public TEnvironment { diff --git a/src/program_lib/crosslangcompiler.cpp b/src/program_lib/crosslangcompiler.cpp index 49a055d..7a46799 100644 --- a/src/program_lib/crosslangcompiler.cpp +++ b/src/program_lib/crosslangcompiler.cpp @@ -192,7 +192,7 @@ void CrossLangCompiler(std::vector &argv) { if (comptime == "secure") { TStd::RegisterConsole(gc, env); - TStd::RegisterClass(gc, env); + TStd::RegisterZeClass(gc, env); TStd::RegisterCrypto(gc, env); TStd::RegisterDictionary(gc, env); TStd::RegisterJson(gc, env); @@ -201,7 +201,7 @@ void CrossLangCompiler(std::vector &argv) { env->permissions.locked = true; } else if (comptime == "secure_file") { TStd::RegisterConsole(gc, env); - TStd::RegisterClass(gc, env); + TStd::RegisterZeClass(gc, env); TStd::RegisterCrypto(gc, env); TStd::RegisterDictionary(gc, env); TStd::RegisterJson(gc, env); diff --git a/src/runtime_methods/class.cpp b/src/runtime_methods/class.cpp index 80dce4e..f72950a 100644 --- a/src/runtime_methods/class.cpp +++ b/src/runtime_methods/class.cpp @@ -190,9 +190,9 @@ static TObject Class_GetInfo(TRootEnvironment *env, GCList &ls, return nullptr; } -void TStd::RegisterClass(std::shared_ptr gc, TRootEnvironment *env) { +void TStd::RegisterZeClass(std::shared_ptr gc, TRootEnvironment *env) { GCList ls(gc); - env->permissions.canRegisterClass = true; + env->permissions.canRegisterZeClass = true; TDictionary *cls = env->EnsureDictionary(gc, "Class"); gc->BarrierBegin(); diff --git a/src/runtime_methods/env.cpp b/src/runtime_methods/env.cpp index da4cc9d..9e64c1c 100644 --- a/src/runtime_methods/env.cpp +++ b/src/runtime_methods/env.cpp @@ -1,10 +1,6 @@ #include "CrossLang.hpp" #include "TessesFramework/Serialization/BitConverter.hpp" -#if defined(_WIN32) -#include -#endif - namespace Tesses::CrossLang { using namespace Tesses::Framework::Platform::Environment; #if defined(_WIN32) diff --git a/src/runtime_methods/net.cpp b/src/runtime_methods/net.cpp index 8cc831e..316b6bf 100644 --- a/src/runtime_methods/net.cpp +++ b/src/runtime_methods/net.cpp @@ -823,8 +823,8 @@ static TObject Net_Http_ListenOnUnusedPort(GCList &ls, static TObject Net_Http_MimeType(GCList &ls, std::vector args) { Tesses::Framework::Filesystem::VFSPath p; if (GetArgumentAsPath(args, 0, p)) { - std::filesystem::path p2 = p.GetFileName(); - return HttpUtils::GetMimeType(p2); + + return HttpUtils::GetMimeTypePath(p); } return std::string("application/octet-stream"); } diff --git a/src/runtime_methods/std.cpp b/src/runtime_methods/std.cpp index 67d2444..a3a4f28 100644 --- a/src/runtime_methods/std.cpp +++ b/src/runtime_methods/std.cpp @@ -6,28 +6,17 @@ #include #include #include + #if !defined(CROSSLANG_STATIC) #if defined(CROSSLANG_ENABLE_FFI) #include #endif -#if defined(_WIN32) -#include - -#include -#undef min -#undef max -#else +#if !defined(_WIN32) #include #include #endif #else -#if defined(_WIN32) -#include - -#include -#undef min -#undef max -#else +#if !defined(_WIN32) #include #endif #endif @@ -70,15 +59,18 @@ class DL { Tesses::Framework::Filesystem::LocalFilesystem lfs; std::string str = lfs.VFSPathToSystem(p); #if defined(_WIN32) - handle = - LoadLibraryExA(str.c_str(), NULL, LOAD_WITH_ALTERED_SEARCH_PATH); + + throw std::runtime_error("I removed support on this platform"); + // handle =LoadLibraryExA(str.c_str(), NULL, + // LOAD_WITH_ALTERED_SEARCH_PATH); #else handle = dlopen(str.c_str(), RTLD_LAZY); #endif } template T Resolve(std::string name) { #if defined(_WIN32) - return (T)GetProcAddress((HMODULE)handle, name.c_str()); + throw std::runtime_error("I removed support on this platform"); + // return (T)GetProcAddress((HMODULE)handle, name.c_str()); #else return (T)dlsym(handle, name.c_str()); @@ -86,7 +78,9 @@ class DL { } ~DL() { #if defined(_WIN32) - FreeLibrary((HMODULE)handle); + + throw std::runtime_error("I removed support on this platform"); + // FreeLibrary((HMODULE)handle); #else dlclose(handle); #endif @@ -1004,11 +998,7 @@ static TObject YieldEnumerableFunc(GCList &ls, std::vector args) { static TObject DateTime_Sleep(GCList &ls, std::vector args) { int64_t msec; if (GetArgument(args, 0, msec)) { -#if defined(_WIN32) - Sleep((int)msec); -#else - usleep(1000 * msec); -#endif + Tesses::Framework::TF_Sleep(msec); } return nullptr; } @@ -1587,7 +1577,7 @@ void TStd::RegisterStd( RegisterCrypto(gc, env); RegisterOGC(gc, env); RegisterProcess(gc, env); - RegisterClass(gc, env); + RegisterZeClass(gc, env); gc->RegisterEverything(env); diff --git a/src/vm/bc/executemethod2.cpp b/src/vm/bc/executemethod2.cpp index 4f7ab9b..90798f5 100644 --- a/src/vm/bc/executemethod2.cpp +++ b/src/vm/bc/executemethod2.cpp @@ -2292,9 +2292,9 @@ bool InterperterThread::ExecuteMethod2(std::shared_ptr gc, TObject instance, } if (key == "RegisterClass") { if ((myEnv->permissions.canRegisterEverything || - myEnv->permissions.canRegisterClass) && + myEnv->permissions.canRegisterZeClass) && !rootEnv->permissions.locked) - TStd::RegisterClass(gc, rootEnv); + TStd::RegisterZeClass(gc, rootEnv); cse.back()->Push(gc, nullptr); return false; } diff --git a/src/vm/gc.cpp b/src/vm/gc.cpp index 8fcdd05..e4e6ebf 100644 --- a/src/vm/gc.cpp +++ b/src/vm/gc.cpp @@ -2,9 +2,7 @@ #include #include #include -#if defined(_WIN32) -#include -#else +#if !defined(_WIN32) #include #endif @@ -85,7 +83,6 @@ TDictionary *CreateThread(GCList &ls, TCallable *callable, bool detached) { TObject cb = th->callable->Call(ls, {}); gc->BarrierBegin(); th->returnValue = cb; - std::map mt; #if defined(GEKKO) || defined(_EE) current_funcs_mtx.Lock(); current_funcs.erase(pthread_self());