From 3106252c04353f584c78b319569a2a15e3ccad0c Mon Sep 17 00:00:00 2001 From: Boris Batkin Date: Wed, 10 Apr 2024 22:40:49 -0700 Subject: [PATCH] more string heap limits --- include/daScript/ast/ast.h | 1 + include/daScript/misc/string_writer.h | 6 +-- include/daScript/simulate/aot.h | 6 +-- .../daScript/simulate/aot_builtin_string.h | 4 +- include/daScript/simulate/heap.h | 38 ++++++++++++++--- include/daScript/simulate/simulate.h | 10 +---- .../dasClangBind/src/dasClangBind.main.cpp | 2 +- modules/dasImgui | 2 +- modules/dasSFML | 2 +- modules/dasStdDlg/src/dasStdDlg.cpp | 4 +- src/ast/ast_aot_cpp.cpp | 4 +- src/ast/ast_module.cpp | 5 +++ src/ast/ast_print.cpp | 2 +- src/ast/ast_simulate.cpp | 12 +++--- src/builtin/module_builtin_ast.cpp | 20 ++++----- src/builtin/module_builtin_fio.cpp | 24 +++++------ src/builtin/module_builtin_rtti.cpp | 14 +++---- src/builtin/module_builtin_runtime.cpp | 16 +++---- src/builtin/module_builtin_string.cpp | 42 +++++++++---------- src/builtin/module_builtin_uriparser.cpp | 30 ++++++------- src/builtin/module_file_access.cpp | 2 +- src/builtin/module_jit.cpp | 6 +-- src/misc/string_writer.cpp | 2 +- src/simulate/bin_serializer.cpp | 2 +- src/simulate/heap.cpp | 8 ++-- src/simulate/runtime_string.cpp | 8 ++-- src/simulate/simulate.cpp | 2 +- src/simulate/simulate_gc.cpp | 2 +- 28 files changed, 152 insertions(+), 124 deletions(-) diff --git a/include/daScript/ast/ast.h b/include/daScript/ast/ast.h index 8a1d9b4f8..228b9652d 100644 --- a/include/daScript/ast/ast.h +++ b/include/daScript/ast/ast.h @@ -113,6 +113,7 @@ namespace das const AnnotationArgument * find ( const string & name, Type type ) const; bool getBoolOption(const string & name, bool def = false) const; int32_t getIntOption(const string & name, int32_t def = false) const; + uint64_t getUInt64Option(const string & name, uint64_t def = false) const; void serialize ( AstSerializer & ser ); }; diff --git a/include/daScript/misc/string_writer.h b/include/daScript/misc/string_writer.h index 3a5ef5d2b..2b9a32a05 100644 --- a/include/daScript/misc/string_writer.h +++ b/include/daScript/misc/string_writer.h @@ -137,7 +137,7 @@ namespace das { public: virtual void output() override; protected: - int pos = 0; + uint64_t pos = 0; static mutex pmut; }; @@ -178,7 +178,7 @@ namespace das { public: LOG ( int level = LogLevel::debug ) : logLevel(level) {} virtual void output() override { - int newPos = tellp(); + auto newPos = tellp(); if (newPos != pos) { string st(data.data() + pos, newPos - pos); logger(logLevel, useMarker ? getLogMarker(logLevel) : "", st.c_str(), /*ctx*/nullptr, /*at*/nullptr); @@ -188,7 +188,7 @@ namespace das { } } protected: - int pos = 0; + uint64_t pos = 0; int logLevel = LogLevel::debug; bool useMarker = true; }; diff --git a/include/daScript/simulate/aot.h b/include/daScript/simulate/aot.h index ca3a9346c..beb3dc1c6 100644 --- a/include/daScript/simulate/aot.h +++ b/include/daScript/simulate/aot.h @@ -1815,7 +1815,7 @@ namespace das { template __forceinline char * das_lexical_cast ( TT x, Context * __context__ ) { - return __context__->stringHeap->allocateString(to_string(x)); + return __context__->stringHeap->allocateString(__context__,to_string(x)); } __forceinline char * das_string_builder ( Context * __context__, const SimNode_AotInteropBase & node ) { @@ -1826,7 +1826,7 @@ namespace das { } auto length = writer.tellp(); if ( length ) { - return __context__->stringHeap->allocateString(writer.c_str(), length); + return __context__->stringHeap->allocateString(__context__,writer.c_str(),uint32_t(length)); } else { return nullptr; } @@ -1840,7 +1840,7 @@ namespace das { } auto length = writer.tellp(); if ( length ) { - auto str = __context__->stringHeap->allocateString(writer.c_str(), length); + auto str = __context__->stringHeap->allocateString(__context__,writer.c_str(), uint32_t(length)); __context__->freeTempString(str); return str; } else { diff --git a/include/daScript/simulate/aot_builtin_string.h b/include/daScript/simulate/aot_builtin_string.h index a3cdd1d77..3b1bda9c3 100644 --- a/include/daScript/simulate/aot_builtin_string.h +++ b/include/daScript/simulate/aot_builtin_string.h @@ -78,7 +78,7 @@ namespace das { __forceinline char * format ( const char * fmt, TT value, Context * context ) { char buf[256]; snprintf(buf, 256, fmt ? fmt : "", value); - return context->stringHeap->allocateString(buf, uint32_t(strlen(buf))); + return context->stringHeap->allocateString(context, buf, uint32_t(strlen(buf))); } template @@ -95,7 +95,7 @@ namespace das { block(writer); auto length = writer.tellp(); if ( length ) { - return context->stringHeap->allocateString(writer.c_str(), length); + return context->stringHeap->allocateString(context,writer.c_str(), length); } else { return nullptr; } diff --git a/include/daScript/simulate/heap.h b/include/daScript/simulate/heap.h index 1a0440a2d..e6a5d68ac 100644 --- a/include/daScript/simulate/heap.h +++ b/include/daScript/simulate/heap.h @@ -182,6 +182,8 @@ namespace das { } }; + class Context; + typedef das_hash_set das_string_set; class StringHeapAllocator : public AnyHeapAllocator { @@ -189,8 +191,8 @@ namespace das { virtual void forEachString ( const callable & fn ) = 0; virtual void reset() override; public: - char * allocateString ( const char * text, uint32_t length ); - char * allocateString ( const string & str ); + char * allocateString ( Context * context, const char * text, uint32_t length ); + char * allocateString ( Context * context, const string & str ); void freeString ( char * text, uint32_t length ); void setIntern ( bool on ); bool isIntern() const { return needIntern; } @@ -326,9 +328,21 @@ namespace das { class PersistentStringAllocator final : public StringHeapAllocator { public: PersistentStringAllocator() { model.alignMask = 3; } - virtual char * allocate ( uint32_t size ) override { return model.allocate(size); } + virtual char * allocate ( uint32_t size ) override { + if ( limit==0 || model.bytesAllocated()+size<=limit ) { + return model.allocate(size); + } else { + return nullptr; + } + } virtual void free ( char * ptr, uint32_t size ) override { model.free(ptr,size); } - virtual char * reallocate ( char * ptr, uint32_t oldSize, uint32_t newSize ) override { return model.reallocate(ptr,oldSize,newSize); } + virtual char * reallocate ( char * ptr, uint32_t oldSize, uint32_t newSize ) override { + if ( limit==0 || model.bytesAllocated()+newSize-oldSize<=limit ) { + return model.reallocate(ptr,oldSize,newSize); + } else { + return nullptr; + } + } virtual int depth() const override { return model.depth(); } virtual uint64_t bytesAllocated() const override { return model.bytesAllocated(); } virtual uint64_t totalAlignedMemoryAllocated() const override { return model.totalAlignedMemoryAllocated(); } @@ -354,9 +368,21 @@ namespace das { class LinearStringAllocator final : public StringHeapAllocator { public: LinearStringAllocator() { model.alignMask = 3; } - virtual char * allocate ( uint32_t size ) override { return model.allocate(size); } + virtual char * allocate ( uint32_t size ) override { + if ( limit==0 || model.bytesAllocated()+size<=limit ) { + return model.allocate(size); + } else { + return nullptr; + } + } virtual void free ( char * ptr, uint32_t size ) override { model.free(ptr,size); } - virtual char * reallocate ( char * ptr, uint32_t oldSize, uint32_t newSize ) override { return model.reallocate(ptr,oldSize,newSize); } + virtual char * reallocate ( char * ptr, uint32_t oldSize, uint32_t newSize ) override { + if ( limit==0 || model.bytesAllocated()+newSize-oldSize<=limit ) { + return model.reallocate(ptr,oldSize,newSize); + } else { + return nullptr; + } + } virtual int depth() const override { return model.depth(); } virtual uint64_t bytesAllocated() const override { return model.bytesAllocated(); } virtual uint64_t totalAlignedMemoryAllocated() const override { return model.totalAlignedMemoryAllocated(); } diff --git a/include/daScript/simulate/simulate.h b/include/daScript/simulate/simulate.h index 9ba5a2966..86793b54a 100644 --- a/include/daScript/simulate/simulate.h +++ b/include/daScript/simulate/simulate.h @@ -274,14 +274,8 @@ namespace das void makeWorkerFor(const Context & ctx); - uint32_t getGlobalSize() const { - return globalsSize; - } - - uint32_t getSharedSize() const { - return sharedSize; - } - + uint64_t getGlobalSize() const { return globalsSize; } + uint64_t getSharedSize() const { return sharedSize; } uint64_t getInitSemanticHash(); __forceinline void * getVariable ( int index ) const { diff --git a/modules/dasClangBind/src/dasClangBind.main.cpp b/modules/dasClangBind/src/dasClangBind.main.cpp index c1db15bd5..ff3e657ab 100644 --- a/modules/dasClangBind/src/dasClangBind.main.cpp +++ b/modules/dasClangBind/src/dasClangBind.main.cpp @@ -12,7 +12,7 @@ namespace das { char * from_CXString_to_string ( const CXString & cxs, Context * context ) { auto cst = clang_getCString(cxs); - auto res = context->stringHeap->allocateString(cst); + auto res = context->stringHeap->allocateString(context,cst); clang_disposeString(cxs); return res; } diff --git a/modules/dasImgui b/modules/dasImgui index cea465d4d..4b7974593 160000 --- a/modules/dasImgui +++ b/modules/dasImgui @@ -1 +1 @@ -Subproject commit cea465d4d5f6597de62c655d36dbc5e6eaee1ae7 +Subproject commit 4b7974593a8549daaa4246074aaa6e8241f756c2 diff --git a/modules/dasSFML b/modules/dasSFML index f82cdf524..baacbe931 160000 --- a/modules/dasSFML +++ b/modules/dasSFML @@ -1 +1 @@ -Subproject commit f82cdf52466e0add33f76d862e25300240a79a72 +Subproject commit baacbe9312467a8c6153c5406ce76beedf184c5a diff --git a/modules/dasStdDlg/src/dasStdDlg.cpp b/modules/dasStdDlg/src/dasStdDlg.cpp index f62cb76e3..48ef1bb99 100644 --- a/modules/dasStdDlg/src/dasStdDlg.cpp +++ b/modules/dasStdDlg/src/dasStdDlg.cpp @@ -13,7 +13,7 @@ char * GetSaveFileDlg ( const char * initialFileName , const char * initialPath, initialPath ? initialPath : "", filter ? filter : "" ); - return ctx->stringHeap->allocateString(sf); + return ctx->stringHeap->allocateString(ctx,sf); } char * GetOpenFileDlg ( const char * initialPath, const char * filter, Context * ctx ) { @@ -21,7 +21,7 @@ char * GetOpenFileDlg ( const char * initialPath, const char * filter, Context * initialPath ? initialPath : "", filter ? filter : "" ); - return ctx->stringHeap->allocateString(sf); + return ctx->stringHeap->allocateString(ctx,sf); } class Module_StdDlg : public Module { diff --git a/src/ast/ast_aot_cpp.cpp b/src/ast/ast_aot_cpp.cpp index e8e038dec..aa5d9f8f4 100644 --- a/src/ast/ast_aot_cpp.cpp +++ b/src/ast/ast_aot_cpp.cpp @@ -955,7 +955,7 @@ namespace das { public: TextWriter ss, sti, stg; protected: - int lastNewLine = -1; + uint64_t lastNewLine = -1ul; int tab = 0; int debugInfoGlobal = 0; AotDebugInfoHelper helper; @@ -1081,7 +1081,7 @@ namespace das { return Visitor::visit(that); } // program body - virtual void preVisitProgramBody ( Program * prog, Module * that ) override { + virtual void preVisitProgramBody ( Program * prog, Module * ) override { // functions ss << "\n"; prog->thisModule->functions.foreach([&](auto fn){ diff --git a/src/ast/ast_module.cpp b/src/ast/ast_module.cpp index a39efb078..b89ec04d1 100644 --- a/src/ast/ast_module.cpp +++ b/src/ast/ast_module.cpp @@ -60,6 +60,11 @@ namespace das { return arg ? arg->iValue : def; } + uint64_t AnnotationArgumentList::getUInt64Option(const string & name, uint64_t def) const { + auto arg = find(name, Type::tInt); + return arg ? uint64_t(arg->iValue) : def; + } + // MODULE void Module::addDependency ( Module * mod, bool pub ) { diff --git a/src/ast/ast_print.cpp b/src/ast/ast_print.cpp index 84354b5ed..e016451cd 100644 --- a/src/ast/ast_print.cpp +++ b/src/ast/ast_print.cpp @@ -1219,7 +1219,7 @@ namespace das { } protected: TextWriter ss; - int lastNewLine = -1; + uint64_t lastNewLine = -1ul; int tab = 0; }; diff --git a/src/ast/ast_simulate.cpp b/src/ast/ast_simulate.cpp index 10695b836..5eea0c806 100644 --- a/src/ast/ast_simulate.cpp +++ b/src/ast/ast_simulate.cpp @@ -3017,9 +3017,9 @@ namespace das context.stringHeap = make_smart(); } context.heap->setInitialSize ( options.getIntOption("heap_size_hint", policies.heap_size_hint) ); - context.heap->setLimit ( options.getIntOption("heap_size_limit", policies.max_heap_allocated) ); + context.heap->setLimit ( options.getUInt64Option("heap_size_limit", policies.max_heap_allocated) ); context.stringHeap->setInitialSize ( options.getIntOption("string_heap_size_hint", policies.string_heap_size_hint) ); - context.stringHeap->setLimit ( options.getIntOption("string_heap_size_limit", policies.max_string_heap_allocated) ); + context.stringHeap->setLimit ( options.getUInt64Option("string_heap_size_limit", policies.max_string_heap_allocated) ); context.constStringHeap = make_shared(); if ( globalStringHeapSize ) { context.constStringHeap->setInitialSize(globalStringHeapSize); @@ -3046,11 +3046,11 @@ namespace das gvar.debugInfo = helper.makeVariableDebugInfo(*pvar); gvar.flags = 0; if ( pvar->global_shared ) { - gvar.offset = pvar->stackTop = context.sharedSize; + gvar.offset = pvar->stackTop = (uint32_t) context.sharedSize; gvar.shared = true; context.sharedSize = (context.sharedSize + uint64_t(gvar.size) + 0xful) & ~0xfull; } else { - gvar.offset = pvar->stackTop = context.globalsSize; + gvar.offset = pvar->stackTop = (uint32_t) context.globalsSize; context.globalsSize = (context.globalsSize + uint64_t(gvar.size) + 0xful) & ~0xfull; } gvar.mangledNameHash = pvar->getMangledNameHash(); @@ -3059,11 +3059,11 @@ namespace das } } bool canAllocateVariables = true; - if ( context.globalsSize >= policies.max_static_variables_size ) { + if ( context.globalsSize >= policies.max_static_variables_size || context.globalsSize >= 0x100000000ul ) { error("Global variables size exceeds " + to_string(policies.max_static_variables_size), "Global variables size is " + to_string(context.globalsSize) + " bytes", "", LineInfo()); canAllocateVariables = false; } - if ( context.sharedSize >= 0x100000000ul ) { + if ( context.sharedSize >= policies.max_static_variables_size || context.sharedSize >= 0x100000000ul ) { error("Shared variables size exceeds " + to_string(policies.max_static_variables_size), "Shared variables size is " + to_string(context.sharedSize) + " bytes", "", LineInfo()); canAllocateVariables = false; } diff --git a/src/builtin/module_builtin_ast.cpp b/src/builtin/module_builtin_ast.cpp index 9df0e0a6b..b2e5904cc 100644 --- a/src/builtin/module_builtin_ast.cpp +++ b/src/builtin/module_builtin_ast.cpp @@ -230,7 +230,7 @@ namespace das { char * ast_describe_typedecl ( smart_ptr_raw t, bool d_extra, bool d_contracts, bool d_module, Context * context, LineInfoArg * at ) { if ( !t ) context->throw_error_at(at, "expecting type, not null"); - return context->stringHeap->allocateString(t->describe( + return context->stringHeap->allocateString(context,t->describe( d_extra ? TypeDecl::DescribeExtra::yes : TypeDecl::DescribeExtra::no, d_contracts ? TypeDecl::DescribeContracts::yes : TypeDecl::DescribeContracts::no, d_module ? TypeDecl::DescribeModule::yes : TypeDecl::DescribeModule::no)); @@ -238,7 +238,7 @@ namespace das { char * ast_describe_typedecl_cpp ( smart_ptr_raw t, bool d_substitureRef, bool d_skipRef, bool d_skipConst, bool d_redundantConst, Context * context, LineInfoArg * at ) { if ( !t ) context->throw_error_at(at, "expecting type, not null"); - return context->stringHeap->allocateString(describeCppType(t, + return context->stringHeap->allocateString(context,describeCppType(t, d_substitureRef ? CpptSubstitureRef::yes : CpptSubstitureRef::no, d_skipRef ? CpptSkipRef::yes : CpptSkipRef::no, d_skipConst ? CpptSkipConst::yes : CpptSkipConst::no, @@ -249,23 +249,23 @@ namespace das { if ( !t ) context->throw_error_at(at, "expecting expression, not null"); TextWriter ss; ss << *t; - return context->stringHeap->allocateString(ss.str()); + return context->stringHeap->allocateString(context,ss.str()); } char * ast_describe_function ( smart_ptr_raw t, Context * context, LineInfoArg * at ) { if ( !t ) context->throw_error_at(at, "expecting function, not null"); TextWriter ss; ss << *t; - return context->stringHeap->allocateString(ss.str()); + return context->stringHeap->allocateString(context,ss.str()); } char * ast_das_to_string ( Type bt, Context * context ) { - return context->stringHeap->allocateString(das_to_string(bt)); + return context->stringHeap->allocateString(context,das_to_string(bt)); } char * ast_find_bitfield_name ( smart_ptr_raw bft, Bitfield value, Context * context, LineInfoArg * at ) { if ( !bft ) context->throw_error_at(at, "expecting bitfield type, not null"); - return context->stringHeap->allocateString(bft->findBitfieldName(value)); + return context->stringHeap->allocateString(context,bft->findBitfieldName(value)); } int64_t ast_find_enum_value ( EnumerationPtr enu, const char * value ) { @@ -408,22 +408,22 @@ namespace das { char * get_mangled_name ( smart_ptr_raw func, Context * context, LineInfoArg * at ) { if ( !func ) context->throw_error_at(at,"expecting function"); - return context->stringHeap->allocateString(func->getMangledName()); + return context->stringHeap->allocateString(context,func->getMangledName()); } char * get_mangled_name_t ( smart_ptr_raw typ, Context * context, LineInfoArg * at ) { if ( !typ ) context->throw_error_at(at,"expecting function"); - return context->stringHeap->allocateString(typ->getMangledName()); + return context->stringHeap->allocateString(context,typ->getMangledName()); } char * get_mangled_name_v ( smart_ptr_raw var, Context * context, LineInfoArg * at ) { if ( !var ) context->throw_error_at(at,"expecting function"); - return context->stringHeap->allocateString(var->getMangledName()); + return context->stringHeap->allocateString(context,var->getMangledName()); } char * get_mangled_name_b ( smart_ptr_raw expr, Context * context, LineInfoArg * at ) { if ( !expr ) context->throw_error_at(at,"expecting block"); - return context->stringHeap->allocateString(expr->getMangledName()); + return context->stringHeap->allocateString(context,expr->getMangledName()); } void get_use_global_variables ( smart_ptr_raw func, const TBlock & block, Context * context, LineInfoArg * at ) { diff --git a/src/builtin/module_builtin_fio.cpp b/src/builtin/module_builtin_fio.cpp index e53c798d4..ba73924d5 100644 --- a/src/builtin/module_builtin_fio.cpp +++ b/src/builtin/module_builtin_fio.cpp @@ -249,7 +249,7 @@ namespace das { struct stat st; int fd = fileno((FILE*)f); fstat(fd, &st); - char * res = context->stringHeap->allocateString(nullptr, st.st_size); + char * res = context->stringHeap->allocateString(context,nullptr, st.st_size); fseek((FILE*)f, 0, SEEK_SET); auto bytes = fread(res, 1, st.st_size, (FILE *)f); if ( uint64_t(bytes) != uint64_t(st.st_size) ) { @@ -263,7 +263,7 @@ namespace das { if ( !f ) context->throw_error_at(at, "can't fgets NULL"); vector buffer(16384); if (char* buf = fgets(buffer.data(), int(buffer.size()), (FILE *)f)) { - return context->stringHeap->allocateString(buf, uint32_t(strlen(buf))); + return context->stringHeap->allocateString(context,buf, uint32_t(strlen(buf))); } else { return nullptr; } @@ -352,11 +352,11 @@ namespace das { full_path[--len] = 0; } } - return context->stringHeap->allocateString(full_path, len); + return context->stringHeap->allocateString(context,full_path, len); #else char * tempName = strdup(name); char * dirName = dirname(tempName); - char * result = context->stringHeap->allocateString(dirName, strlen(dirName)); + char * result = context->stringHeap->allocateString(context,dirName, strlen(dirName)); free(tempName); return result; #endif @@ -374,11 +374,11 @@ namespace das { char ext[ _MAX_EXT ]; _splitpath(name, drive, dir, full_path, ext); strcat(full_path, ext); - return context->stringHeap->allocateString(full_path, uint32_t(strlen(full_path))); + return context->stringHeap->allocateString(context,full_path, uint32_t(strlen(full_path))); #else char * tempName = strdup(name); char * dirName = basename(tempName); - char * result = context->stringHeap->allocateString(dirName, strlen(dirName)); + char * result = context->stringHeap->allocateString(context,dirName, strlen(dirName)); free(tempName); return result; #endif @@ -407,7 +407,7 @@ namespace das { string findPath = string(path ? path : "") + "/*"; if ((hFile = _findfirst(findPath.c_str(), &c_file)) != -1L) { do { - char * fname = context->stringHeap->allocateString(c_file.name, uint32_t(strlen(c_file.name))); + char * fname = context->stringHeap->allocateString(context,c_file.name, uint32_t(strlen(c_file.name))); vec4f args[1] = { cast::from(fname) }; @@ -420,7 +420,7 @@ namespace das { struct dirent *ent; if ((dir = opendir (path ? path : "")) != NULL) { while ((ent = readdir (dir)) != NULL) { - char * fname = context->stringHeap->allocateString(ent->d_name,uint32_t(strlen(ent->d_name))); + char * fname = context->stringHeap->allocateString(context,ent->d_name,uint32_t(strlen(ent->d_name))); vec4f args[1] = { cast::from(fname) }; @@ -449,7 +449,7 @@ namespace das { #else char * buf = getcwd(nullptr, 0); if ( buf ) { - char * res = context->stringHeap->allocateString(buf, uint32_t(strlen(buf))); + char * res = context->stringHeap->allocateString(context,buf, uint32_t(strlen(buf))); free(buf); return res; } else { @@ -526,7 +526,7 @@ namespace das { if ( !path ) return nullptr; auto res = normalizeFileName(path); if ( res.length()==0 ) return nullptr; - return context->stringHeap->allocateString(res); + return context->stringHeap->allocateString(context,res); } bool builtin_remove_file ( const char * path ) { @@ -543,7 +543,7 @@ namespace das { if ( !var ) return nullptr; auto res = getenv(var); if ( !res ) return nullptr; - return context->stringHeap->allocateString(res); + return context->stringHeap->allocateString(context,res); } char * sanitize_command_line ( const char * cmd, Context * context, LineInfoArg * at ) { @@ -565,7 +565,7 @@ namespace das { } } if ( ss.str().size() > UINT_MAX ) context->throw_error_at(at, "string too long"); - return context->stringHeap->allocateString(ss.str().data(), uint32_t(ss.str().size())); + return context->stringHeap->allocateString(context,ss.str().data(), uint32_t(ss.str().size())); } class Module_FIO : public Module { diff --git a/src/builtin/module_builtin_rtti.cpp b/src/builtin/module_builtin_rtti.cpp index 44922fb5a..b61b03750 100644 --- a/src/builtin/module_builtin_rtti.cpp +++ b/src/builtin/module_builtin_rtti.cpp @@ -912,7 +912,7 @@ namespace das { break; case Type::tString: nada._variant = 7; - nada.sValue = context->stringHeap->allocateString(info.sValue); + nada.sValue = context->stringHeap->allocateString(context,info.sValue); break; default:; } @@ -1045,7 +1045,7 @@ namespace das { char * rtti_get_das_type_name(Type tt, Context * context) { string str = das_to_string(tt); - return context->stringHeap->allocateString(str); + return context->stringHeap->allocateString(context,str); } int rtti_add_annotation_argument(AnnotationArgumentList& list, const char* name) { @@ -1162,30 +1162,30 @@ namespace das { char * builtin_print_data ( void * data, const TypeInfo * typeInfo, Bitfield flags, Context * context ) { TextWriter ssw; ssw << debug_value(data, (TypeInfo *)typeInfo, PrintFlags(uint32_t(flags))); - return context->stringHeap->allocateString(ssw.str()); + return context->stringHeap->allocateString(context,ssw.str()); } char * builtin_print_data_v ( float4 data, const TypeInfo * typeInfo, Bitfield flags, Context * context ) { TextWriter ssw; ssw << debug_value(vec4f(data), (TypeInfo *)typeInfo, PrintFlags(uint32_t(flags))); - return context->stringHeap->allocateString(ssw.str()); + return context->stringHeap->allocateString(context,ssw.str()); } char * builtin_debug_type ( const TypeInfo * typeInfo, Context * context ) { if ( !typeInfo ) return nullptr; auto dt = debug_type(typeInfo); - return context->stringHeap->allocateString(dt); + return context->stringHeap->allocateString(context,dt); } char * builtin_debug_line ( const LineInfo & at, bool fully, Context * context ) { auto dt = at.describe(fully); - return context->stringHeap->allocateString(dt); + return context->stringHeap->allocateString(context,dt); } char * builtin_get_typeinfo_mangled_name ( const TypeInfo * typeInfo, Context * context ) { if ( !typeInfo ) return nullptr; auto dt = getTypeInfoMangledName((TypeInfo*)typeInfo); - return context->stringHeap->allocateString(dt); + return context->stringHeap->allocateString(context,dt); } const FuncInfo * builtin_get_function_info_by_mnh ( Context &, Func fun ) { diff --git a/src/builtin/module_builtin_runtime.cpp b/src/builtin/module_builtin_runtime.cpp index 068c2c2b2..6d5f6989f 100644 --- a/src/builtin/module_builtin_runtime.cpp +++ b/src/builtin/module_builtin_runtime.cpp @@ -1002,7 +1002,7 @@ namespace das char * collectProfileInfo( Context * context ) { TextWriter tout; context->collectProfileInfo(tout); - return context->stringHeap->allocateString(tout.str()); + return context->stringHeap->allocateString(context,tout.str()); } void builtin_array_free ( Array & dim, int szt, Context * __context__, LineInfoArg * at ) { @@ -1259,7 +1259,7 @@ namespace das auto res = args[0]; auto flags = cast::to(args[1]); ssw << debug_type(typeInfo) << " = " << debug_value(res, typeInfo, PrintFlags(flags)); - auto sres = context.stringHeap->allocateString(ssw.str()); + auto sres = context.stringHeap->allocateString(&context,ssw.str()); return cast::from(sres); } @@ -1268,7 +1268,7 @@ namespace das auto res = args[0]; auto humanReadable = cast::to(args[1]); auto ssw = debug_json_value(res, typeInfo, humanReadable); - auto sres = context.stringHeap->allocateString(ssw); + auto sres = context.stringHeap->allocateString(&context,ssw); return cast::from(sres); } @@ -1287,11 +1287,11 @@ namespace das } char * builtin_das_root ( Context * context ) { - return context->stringHeap->allocateString(getDasRoot()); + return context->stringHeap->allocateString(context,getDasRoot()); } char * to_das_string(const string & str, Context * ctx) { - return ctx->stringHeap->allocateString(str); + return ctx->stringHeap->allocateString(ctx,str); } char * pass_string(char * str) { @@ -1300,7 +1300,7 @@ namespace das char * clone_pass_string(char * str, Context * ctx ) { if ( !str ) return nullptr; - return ctx->stringHeap->allocateString(str); + return ctx->stringHeap->allocateString(ctx,str); } void set_das_string(string & str, const char * bs) { @@ -1308,7 +1308,7 @@ namespace das } void set_string_das(char * & bs, const string & str, Context * ctx ) { - bs = ctx->stringHeap->allocateString(str); + bs = ctx->stringHeap->allocateString(ctx,str); } void peek_das_string(const string & str, const TBlock> & block, Context * context, LineInfoArg * at) { @@ -1321,7 +1321,7 @@ namespace das const uint32_t strLen = stringLengthSafe ( *context, str ); if (!strLen) return nullptr; - return context->stringHeap->allocateString(str, strLen); + return context->stringHeap->allocateString(context,str, strLen); } void builtin_temp_array ( void * data, int size, const Block & block, Context * context, LineInfoArg * at ) { diff --git a/src/builtin/module_builtin_string.cpp b/src/builtin/module_builtin_string.cpp index 5291c2393..726551aef 100644 --- a/src/builtin/module_builtin_string.cpp +++ b/src/builtin/module_builtin_string.cpp @@ -87,7 +87,7 @@ namespace das return nullptr; const char *start = strip_l(str); const char *end = strip_r(str, strLen); - return end > start ? context->stringHeap->allocateString(start, uint32_t(end-start)) : nullptr; + return end > start ? context->stringHeap->allocateString(context,start, uint32_t(end-start)) : nullptr; } char* builtin_string_strip_left ( const char *str, Context * context ) { @@ -95,7 +95,7 @@ namespace das if (!strLen) return nullptr; const char *start = strip_l(str); - return uint32_t(start-str) < strLen ? context->stringHeap->allocateString(start, strLen-uint32_t(start-str)) : nullptr; + return uint32_t(start-str) < strLen ? context->stringHeap->allocateString(context,start, strLen-uint32_t(start-str)) : nullptr; } char* builtin_string_strip_right ( const char *str, Context * context ) { @@ -103,7 +103,7 @@ namespace das if (!strLen) return nullptr; const char *end = strip_r(str, strLen); - return end != str ? context->stringHeap->allocateString(str, uint32_t(end-str)) : nullptr; + return end != str ? context->stringHeap->allocateString(context,str, uint32_t(end-str)) : nullptr; } static inline int clamp_int(int v, int minv, int maxv) { @@ -133,7 +133,7 @@ namespace das char* builtin_string_chop(const char* str, int start, int length, Context* context) { if ( !str || length<=0 ) return nullptr; - return context->stringHeap->allocateString(str + start, length); + return context->stringHeap->allocateString(context,str + start, length); } char* builtin_string_slice1 ( const char *str, int start, int end, Context * context ) { @@ -142,7 +142,7 @@ namespace das return nullptr; start = clamp_int((start < 0) ? (strLen + start) : start, 0, strLen); end = clamp_int((end < 0) ? (strLen + end) : end, 0, strLen); - return end > start ? context->stringHeap->allocateString(str + start, uint32_t(end-start)) : nullptr; + return end > start ? context->stringHeap->allocateString(context,str + start, uint32_t(end-start)) : nullptr; } char* builtin_string_slice2 ( const char *str, int start, Context * context ) { @@ -150,14 +150,14 @@ namespace das if (!strLen) return nullptr; start = clamp_int((start < 0) ? (strLen + start) : start, 0, strLen); - return strLen > uint32_t(start) ? context->stringHeap->allocateString(str + start, uint32_t(strLen-start)) : nullptr; + return strLen > uint32_t(start) ? context->stringHeap->allocateString(context,str + start, uint32_t(strLen-start)) : nullptr; } char* builtin_string_reverse ( const char *str, Context * context ) { const uint32_t strLen = stringLengthSafe ( *context, str ); if (!strLen) return nullptr; - char * ret = context->stringHeap->allocateString(str, strLen); + char * ret = context->stringHeap->allocateString(context,str, strLen); str += strLen-1; for (char *d = ret, *end = ret + strLen; d != end; --str, ++d) *d = *str; @@ -172,7 +172,7 @@ namespace das const uint32_t strLen = stringLengthSafe ( *context, str ); if (!strLen) return nullptr; - char * ret = context->stringHeap->allocateString(str, strLen); + char * ret = context->stringHeap->allocateString(context,str, strLen); for (char *d = ret, *end = ret + strLen; d != end; ++str, ++d) *d = (char)to_lower(*str); return ret; @@ -198,7 +198,7 @@ namespace das const uint32_t strLen = stringLengthSafe ( *context, str ); if (!strLen) return nullptr; - char * ret = context->stringHeap->allocateString(str, strLen); + char * ret = context->stringHeap->allocateString(context,str, strLen); for (char *d = ret, *end = ret + strLen; d != end; ++str, ++d) *d = (char)to_upper(*str); return ret; @@ -349,7 +349,7 @@ namespace das context->invoke(block, args, nullptr, at); auto length = writer.tellp(); if ( length ) { - return context->stringHeap->allocateString(writer.c_str(), length); + return context->stringHeap->allocateString(context,writer.c_str(), uint32_t(length)); } else { return nullptr; } @@ -383,7 +383,7 @@ namespace das } char * to_string_char ( int ch, Context * context ) { - auto st = context->stringHeap->allocateString(nullptr, 1); + auto st = context->stringHeap->allocateString(context,nullptr, 1); *st = char(ch); return st; } @@ -391,7 +391,7 @@ namespace das char * string_repeat ( const char * str, int count, Context * context ) { uint32_t len = stringLengthSafe ( *context, str ); if ( !len || count<=0 ) return nullptr; - char * res = context->stringHeap->allocateString(nullptr, len * count); + char * res = context->stringHeap->allocateString(context,nullptr, len * count); for ( char * s = res; count; count--, s+=len ) { memcpy ( s, str, len ); } @@ -515,7 +515,7 @@ namespace das data.replace(pos, toSearchSize, repl); pos = data.find(toss, pos + replaceStrSize); } - return context->stringHeap->allocateString(data); + return context->stringHeap->allocateString(context,data); } class StrdupDataWalker : public DataWalker { @@ -532,7 +532,7 @@ namespace das char * builtin_string_escape ( const char *str, Context * context ) { if ( !str ) return nullptr; - return context->stringHeap->allocateString(escapeString(str,false)); + return context->stringHeap->allocateString(context,escapeString(str,false)); } char * builtin_string_unescape ( const char *str, Context * context, LineInfoArg * at ) { @@ -540,14 +540,14 @@ namespace das bool err = false; auto estr = unescapeString(str, &err, false); if ( err ) context->throw_error_at(at, "invalid escape sequence"); - return context->stringHeap->allocateString(estr); + return context->stringHeap->allocateString(context,estr); } char * builtin_string_safe_unescape ( const char *str, Context * context ) { if ( !str ) return nullptr; bool err = false; auto estr = unescapeString(str, &err, false); - return context->stringHeap->allocateString(estr); + return context->stringHeap->allocateString(context,estr); } int builtin_find_first_char_of ( const char * str, int Ch, Context * context ) { @@ -573,7 +573,7 @@ namespace das char * builtin_string_from_array ( const TArray & bytes, Context * context ) { if ( !bytes.size ) return nullptr; - return context->stringHeap->allocateString(bytes.data, bytes.size); + return context->stringHeap->allocateString(context,bytes.data, bytes.size); } void delete_string ( char * & str, Context * context ) { @@ -628,7 +628,7 @@ namespace das if ( !s ) return nullptr; while ( is_white_space(*s) ) s++; if ( *s ) { - return context->stringHeap->allocateString(s, uint32_t(strlen(s))); + return context->stringHeap->allocateString(context,s, uint32_t(strlen(s))); } else { return nullptr; } @@ -643,7 +643,7 @@ namespace das return nullptr; } else if ( str_end!=str_end_o ) { auto len = str_end - s; - char * res = context->stringHeap->allocateString(nullptr, int32_t(len)); + char * res = context->stringHeap->allocateString(context,nullptr, int32_t(len)); memcpy ( res, s, len ); res[len] = 0; return res; @@ -669,7 +669,7 @@ namespace das return nullptr; } else if ( str_end!=str_end_o ) { auto len = str_end - s; - char * res = context->stringHeap->allocateString(nullptr, int32_t(len)); + char * res = context->stringHeap->allocateString(context,nullptr, int32_t(len)); memcpy ( res, s, len ); res[len] = 0; return res; @@ -693,7 +693,7 @@ namespace das char * builtin_string_peek_and_modify ( const char * str, const TBlock>> & block, Context * context, LineInfoArg * at ) { if ( !str ) return nullptr; int32_t len = int32_t(strlen(str)); - char * cstr = context->stringHeap->allocateString(str, len); + char * cstr = context->stringHeap->allocateString(context,str, len); memcpy(cstr, str, len); Array arr; arr.data = cstr; diff --git a/src/builtin/module_builtin_uriparser.cpp b/src/builtin/module_builtin_uriparser.cpp index 92c60ee93..5a32af391 100644 --- a/src/builtin/module_builtin_uriparser.cpp +++ b/src/builtin/module_builtin_uriparser.cpp @@ -32,7 +32,7 @@ char * das::makeNewGuid( das::Context * context, LineInfoArg * at ) { if ( UuidCreate(&id)!=RPC_S_OK ) context->throw_error_at(at, "can't create UUID"); CHAR* uuidstr = NULL; if ( UuidToStringA(&id, (RPC_CSTR *)&uuidstr)!=RPC_S_OK ) context->throw_error_at(at, "can't convert UUID to string"); - char * res = context->stringHeap->allocateString(uuidstr); + char * res = context->stringHeap->allocateString(context,uuidstr); RpcStringFreeA((RPC_CSTR *)&uuidstr); return res; } @@ -49,7 +49,7 @@ char * das::makeNewGuid( das::Context * context, LineInfoArg * ) { uuid_generate(data.data); TextWriter tw; tw << HEX << data.data32[0] << "-" << data.data32[1] << "-" << data.data32[2] << "-" << data.data32[3] << DEC; - return context->stringHeap->allocateString(tw.str()); + return context->stringHeap->allocateString(context,tw.str()); } #elif defined(__APPLE__) @@ -64,7 +64,7 @@ char * das::makeNewGuid( das::Context * context, LineInfoArg * ) { uuid_generate(data.data); TextWriter tw; tw << HEX << data.data32[0] << "-" << data.data32[1] << "-" << data.data32[2] << "-" << data.data32[3] << DEC; - return context->stringHeap->allocateString(tw.str()); + return context->stringHeap->allocateString(context,tw.str()); } #else @@ -83,7 +83,7 @@ char * uri_to_unix_file_name ( char * uristr, Context * context ) { auto buf = new char[len + 1]; char * result = nullptr; if ( uriUriStringToUnixFilenameA(uristr, buf) == URI_SUCCESS ) { - result = context->stringHeap->allocateString(buf, uint32_t(strlen(buf))); + result = context->stringHeap->allocateString(context,buf, uint32_t(strlen(buf))); } delete [] buf; return result; @@ -95,7 +95,7 @@ char * uri_to_windows_file_name ( char * uristr, Context * context ) { auto buf = new char[len + 1]; char * result = nullptr; if ( uriUriStringToWindowsFilenameA(uristr, buf) == URI_SUCCESS ) { - result = context->stringHeap->allocateString(buf, uint32_t(strlen(buf))); + result = context->stringHeap->allocateString(context,buf, uint32_t(strlen(buf))); } delete [] buf; return result; @@ -107,7 +107,7 @@ char * unix_file_name_to_uri ( char * uristr, Context * context ) { auto buf = new char[3 * len + 1]; char * result = nullptr; if ( uriUnixFilenameToUriStringA(uristr, buf) == URI_SUCCESS ) { - result = context->stringHeap->allocateString(buf, uint32_t(strlen(buf))); + result = context->stringHeap->allocateString(context,buf, uint32_t(strlen(buf))); } delete [] buf; return result; @@ -119,7 +119,7 @@ char * windows_file_name_to_uri ( char * uristr, Context * context ) { auto buf = new char[8 + 3 * len + 1]; char * result = nullptr; if ( uriWindowsFilenameToUriStringA(uristr, buf) == URI_SUCCESS ) { - result = context->stringHeap->allocateString(buf, uint32_t(strlen(buf))); + result = context->stringHeap->allocateString(context,buf, uint32_t(strlen(buf))); } delete [] buf; return result; @@ -131,7 +131,7 @@ char * escape_uri ( char * uristr, bool spaceToPlus, bool normalizeBreaks, Conte auto buf = new char[len*6]; char * result = nullptr; if ( uriEscapeA(uristr, buf, spaceToPlus, normalizeBreaks) ) { - result = context->stringHeap->allocateString(buf, uint32_t(strlen(buf))); + result = context->stringHeap->allocateString(context,buf, uint32_t(strlen(buf))); } delete [] buf; return result; @@ -145,7 +145,7 @@ char * unescape_uri ( char * uristr,Context * context ) { buf[len] = 0; char * result = nullptr; if ( uriUnescapeInPlaceA(buf) ) { - result = context->stringHeap->allocateString(buf, uint32_t(strlen(buf))); + result = context->stringHeap->allocateString(context,buf, uint32_t(strlen(buf))); } delete [] buf; return result; @@ -171,7 +171,7 @@ char* normalize_uri(char* uristr, Context* context) { charsRequired++; char* buf = new char[charsRequired]; if (uriToStringA(buf, &uri, charsRequired, nullptr) == URI_SUCCESS) { - result = context->stringHeap->allocateString(buf, uint32_t(strlen(buf))); + result = context->stringHeap->allocateString(context,buf, uint32_t(strlen(buf))); } delete[] buf; uriFreeUriMembersA(&uri); @@ -253,27 +253,27 @@ void clone_uri ( Uri & uri, const Uri & uriS ) { } char * uri_to_string ( const Uri & uri, Context * context ) { - return context->stringHeap->allocateString(uri.str()); + return context->stringHeap->allocateString(context,uri.str()); } char * text_range_to_string ( const UriTextRangeA & trange, Context * context ) { if ( auto slen = trange.afterLast - trange.first ) { - return context->stringHeap->allocateString(trange.first, uint32_t(slen)); + return context->stringHeap->allocateString(context,trange.first, uint32_t(slen)); } else { return nullptr; } } char * to_unix_file_name ( const Uri & uri, Context * context ) { - return context->stringHeap->allocateString(uri.toUnixFileName()); + return context->stringHeap->allocateString(context,uri.toUnixFileName()); } char * to_windows_file_name ( const Uri & uri, Context * context ) { - return context->stringHeap->allocateString(uri.toWindowsFileName()); + return context->stringHeap->allocateString(context,uri.toWindowsFileName()); } char * to_file_name ( const Uri & uri, Context * context ) { - return context->stringHeap->allocateString(uri.toFileName()); + return context->stringHeap->allocateString(context,uri.toFileName()); } Uri from_file_name ( const char * str ) { diff --git a/src/builtin/module_file_access.cpp b/src/builtin/module_file_access.cpp index dec91230d..e63266ea1 100644 --- a/src/builtin/module_file_access.cpp +++ b/src/builtin/module_file_access.cpp @@ -56,7 +56,7 @@ namespace das { } // set it char ** gpr = (char **) context->getVariable(ipr); - *gpr = context->stringHeap->allocateString(pakRoot); + *gpr = context->stringHeap->allocateString(context,pakRoot); } // logs auto tostr = tout.str(); diff --git a/src/builtin/module_jit.cpp b/src/builtin/module_jit.cpp index 7e5bcd433..448b0ce67 100644 --- a/src/builtin/module_jit.cpp +++ b/src/builtin/module_jit.cpp @@ -95,7 +95,7 @@ extern "C" { } auto length = writer.tellp(); if ( length ) { - return context.stringHeap->allocateString(writer.c_str(), length); + return context.stringHeap->allocateString(&context,writer.c_str(), uint32_t(length)); } else { return nullptr; } @@ -109,7 +109,7 @@ extern "C" { } auto length = writer.tellp(); if ( length ) { - auto str = context.stringHeap->allocateString(writer.c_str(), length); + auto str = context.stringHeap->allocateString(&context,writer.c_str(), uint32_t(length)); context.freeTempString(str); return str; } else { @@ -164,7 +164,7 @@ extern "C" { uint32_t commonLength = la + lb; if ( !commonLength ) { return nullptr; - } else if ( char * sAB = (char * ) context->stringHeap->allocateString(nullptr, commonLength) ) { + } else if ( char * sAB = (char * ) context->stringHeap->allocateString(context,nullptr, commonLength) ) { memcpy ( sAB, sA, la ); memcpy ( sAB+la, sB, lb+1 ); context->stringHeap->recognize(sAB); diff --git a/src/misc/string_writer.cpp b/src/misc/string_writer.cpp index 9f5c243f4..6a7422ac2 100644 --- a/src/misc/string_writer.cpp +++ b/src/misc/string_writer.cpp @@ -12,7 +12,7 @@ namespace das { void TextPrinter::output() { lock_guard guard(pmut); - int newPos = tellp(); + uint64_t newPos = tellp(); if (newPos != pos) { string st(data.data() + pos, newPos - pos); printf("%s", st.c_str()); diff --git a/src/simulate/bin_serializer.cpp b/src/simulate/bin_serializer.cpp index 91fdd2d8b..524bb17ae 100644 --- a/src/simulate/bin_serializer.cpp +++ b/src/simulate/bin_serializer.cpp @@ -132,7 +132,7 @@ namespace das { load ( length ); char * temp = new char[length+1]; read ( temp, length ); - data = (char *) context->stringHeap->allocateString(temp,length); + data = (char *) context->stringHeap->allocateString(context,temp,length); delete [] temp; } else { uint32_t length = stringLengthSafe(*context, data); diff --git a/src/simulate/heap.cpp b/src/simulate/heap.cpp index 18f23c4a4..179f223b8 100644 --- a/src/simulate/heap.cpp +++ b/src/simulate/heap.cpp @@ -42,8 +42,8 @@ namespace das { return nullptr; } - char * StringHeapAllocator::allocateString ( const string & str ) { - return allocateString ( str.c_str(), uint32_t(str.length()) ); + char * StringHeapAllocator::allocateString ( Context * context, const string & str ) { + return allocateString ( context, str.c_str(), uint32_t(str.length()) ); } bool PersistentHeapAllocator::mark() { @@ -220,7 +220,7 @@ namespace das { return nullptr; } - char * StringHeapAllocator::allocateString ( const char * text, uint32_t length ) { + char * StringHeapAllocator::allocateString ( Context * context, const char * text, uint32_t length ) { if ( length ) { if ( needIntern && text ) { auto it = internMap.find(StrHashEntry(text,length)); @@ -236,6 +236,8 @@ namespace das { str[length] = 0; if ( needIntern && text ) internMap.insert(StrHashEntry(str,length)); return str; + } else if ( context ) { + context->throw_error("out of string heap"); } } return nullptr; diff --git a/src/simulate/runtime_string.cpp b/src/simulate/runtime_string.cpp index 9f5ff0bef..acd3b742c 100644 --- a/src/simulate/runtime_string.cpp +++ b/src/simulate/runtime_string.cpp @@ -20,7 +20,7 @@ namespace das uint32_t commonLength = la + lb; if ( !commonLength ) { return v_zero(); - } else if ( char * sAB = (char * ) context.stringHeap->allocateString(nullptr, commonLength) ) { + } else if ( char * sAB = (char * ) context.stringHeap->allocateString(&context,nullptr, commonLength) ) { memcpy ( sAB, sA, la ); memcpy ( sAB+la, sB, lb+1 ); context.stringHeap->recognize(sAB); @@ -41,7 +41,7 @@ namespace das if ( !commonLength ) { // *pA = nullptr; is unnecessary, because its already nullptr return; - } else if ( char * sAB = (char * ) context.stringHeap->allocateString(nullptr, commonLength) ) { + } else if ( char * sAB = (char * ) context.stringHeap->allocateString(&context,nullptr, commonLength) ) { memcpy ( sAB, sA, la ); memcpy ( sAB+la, sB, lb+1 ); *pA = sAB; @@ -351,9 +351,9 @@ namespace das for ( int i=0, is=nArguments; i!=is; ++i ) { walker.walk(argValues[i], types[i]); } - int length = writer.tellp(); + uint64_t length = writer.tellp(); if ( length ) { - auto pStr = context.stringHeap->allocateString(writer.c_str(), length); + auto pStr = context.stringHeap->allocateString(&context,writer.c_str(), uint32_t(length)); if ( !pStr ) { context.throw_error_at(debugInfo, "can't allocate string builder result, out of heap"); } diff --git a/src/simulate/simulate.cpp b/src/simulate/simulate.cpp index 473e9b645..78b6ba12e 100644 --- a/src/simulate/simulate.cpp +++ b/src/simulate/simulate.cpp @@ -1224,7 +1224,7 @@ namespace das if ( !str || !len ) return nullptr; char * ist = constStringHeap->intern(str,len); if ( !ist ) ist = stringHeap->intern(str,len); - return ist ? ist : stringHeap->allocateString(str,len); + return ist ? ist : stringHeap->allocateString(this,str,len); } class SharedDataWalker : public DataWalker { diff --git a/src/simulate/simulate_gc.cpp b/src/simulate/simulate_gc.cpp index d5a5ac1e7..6ed5d1469 100644 --- a/src/simulate/simulate_gc.cpp +++ b/src/simulate/simulate_gc.cpp @@ -1063,7 +1063,7 @@ namespace das for ( auto f : walker.failed ) { tw << " " << uint64_t(f); } - auto etext = stringHeap->allocateString(tw.str()); + auto etext = stringHeap->allocateString(this,tw.str()); throw_error_at(at, "%s", etext); } }