diff --git a/include/clasp/asttooling/clangTooling.h b/include/clasp/asttooling/clangTooling.h index 97766e31f6..22194fad5d 100644 --- a/include/clasp/asttooling/clangTooling.h +++ b/include/clasp/asttooling/clangTooling.h @@ -110,7 +110,7 @@ class DerivableSyntaxOnlyAction : public clbind::DerivablegetCompilerInstance(); CI.getFrontendOpts().DisableFree = true; - this->ExecuteAction(); + this->Base::ExecuteAction(); } }; diff --git a/include/clasp/clbind/constructor.h b/include/clasp/clbind/constructor.h index df93f4eceb..df5b0cd56f 100644 --- a/include/clasp/clbind/constructor.h +++ b/include/clasp/clbind/constructor.h @@ -201,8 +201,7 @@ class WRAPPER_Constructor_O < constructor, Policies, Pointer, Construct static inline LCC_RETURN wrapper_entry_point_n(const BytecodeWrapper& dummy, core::T_O* lcc_closure, size_t lcc_nargs, core::T_O** lcc_args ) { - MyType* closure = gctools::untag_general((MyType*)lcc_closure); - INCREMENT_FUNCTION_CALL_COUNTER(closure); + INCREMENT_FUNCTION_CALL_COUNTER(gctools::untag_general((MyType*)lcc_closure)); DO_DRAG_CXX_CALLS(); if (lcc_nargs!=NumParams) cc_wrong_number_of_arguments(lcc_closure,lcc_nargs,NumParams,NumParams); std::tuple...> all_args = arg_tuple<0,policies<>,ARGS...>::goFrame(lcc_args); diff --git a/include/clasp/clbind/function.h b/include/clasp/clbind/function.h index 38f3c53e07..71fe8ca3be 100644 --- a/include/clasp/clbind/function.h +++ b/include/clasp/clbind/function.h @@ -107,7 +107,7 @@ class WRAPPER_VariadicFunction(), code) { + : GlobalSimpleFunBase_O(fdesc, core::ClaspXepFunction::make(), code), fptr(ptr) { this->validateCodePointer((void **)&this->fptr, sizeof(this->fptr)); }; diff --git a/include/clasp/clbind/getterTop.h b/include/clasp/clbind/getterTop.h index e8800900ed..7c6606921b 100644 --- a/include/clasp/clbind/getterTop.h +++ b/include/clasp/clbind/getterTop.h @@ -12,7 +12,7 @@ class WRAPPER_Getter public: WRAPPER_Getter(VariablePtrType ptr, core::FunctionDescription_sp fdesc, core::T_sp code) - : mptr(ptr), GlobalSimpleFunBase_O(fdesc,core::ClaspXepFunction::make(),code) { + : GlobalSimpleFunBase_O(fdesc,core::ClaspXepFunction::make(),code), mptr(ptr) { trapGetterMethoid(); }; diff --git a/include/clasp/clbind/memberFunction.h b/include/clasp/clbind/memberFunction.h index eb19cbb21d..bc56a68176 100644 --- a/include/clasp/clbind/memberFunction.h +++ b/include/clasp/clbind/memberFunction.h @@ -50,7 +50,7 @@ class WRAPPER_AlienVariadicMethod < RT(OT::*)(ARGS...), Policies, ArgumentWrappe enum { NumParams = sizeof...(ARGS)+1 }; WRAPPER_AlienVariadicMethod(MethodType ptr, core::FunctionDescription_sp fdesc, core::T_sp code) - : mptr(ptr), GlobalSimpleFunBase_O(fdesc,core::ClaspXepFunction::make(),code) { + : GlobalSimpleFunBase_O(fdesc,core::ClaspXepFunction::make(),code), mptr(ptr) { this->validateCodePointer((void**)&this->mptr,sizeof(this->mptr)); }; @@ -120,7 +120,7 @@ class WRAPPER_AlienVariadicMethod < RT(OT::*)(ARGS...) const, Policies, Argument enum { NumParams = sizeof...(ARGS)+1 }; WRAPPER_AlienVariadicMethod(MethodType ptr, core::FunctionDescription_sp fdesc, core::T_sp code) - : mptr(ptr), GlobalSimpleFunBase_O(fdesc,core::ClaspXepFunction::make(),code) { + : GlobalSimpleFunBase_O(fdesc,core::ClaspXepFunction::make(),code), mptr(ptr) { this->validateCodePointer((void**)&this->mptr,sizeof(this->mptr)); }; diff --git a/include/clasp/core/backtrace.h b/include/clasp/core/backtrace.h index 71f6d7c6c2..5e8a39d821 100644 --- a/include/clasp/core/backtrace.h +++ b/include/clasp/core/backtrace.h @@ -32,10 +32,10 @@ DebuggerFrame_O : public General_O { DebuggerFrame_O(T_sp a_fname, T_sp a_return_address, T_sp a_sp, T_sp a_fd, T_sp a_closure, T_sp a_args, bool a_av, T_sp a_lang, bool a_is_xep) - : fname(a_fname), return_address(a_return_address), + : fname(a_fname), return_address(a_return_address), source_position(a_sp), function_description(a_fd), - closure(a_closure), args(a_args), args_available(a_av), is_xep(a_is_xep), - lang(a_lang), up(nil()), down(nil()) + closure(a_closure), args(a_args), args_available(a_av), + lang(a_lang), up(nil()), down(nil()), is_xep(a_is_xep) {} static DebuggerFrame_sp make(T_sp fname, T_sp ra, T_sp sp, T_sp fd, diff --git a/include/clasp/core/debugger.h b/include/clasp/core/debugger.h index 679b6307e2..7113ba803f 100644 --- a/include/clasp/core/debugger.h +++ b/include/clasp/core/debugger.h @@ -70,19 +70,17 @@ struct OpenDynamicLibraryInfo { bool _IsExecutable; std::string _Filename; void* _Handle; - SymbolTable _SymbolTable; gctools::clasp_ptr_t _LibraryStart; gctools::clasp_ptr_t _TextStart; gctools::clasp_ptr_t _TextEnd; bool _HasVtableSection; gctools::clasp_ptr_t _VtableSectionStart; gctools::clasp_ptr_t _VtableSectionEnd; - OpenDynamicLibraryInfo(bool is_executable, const std::string& f, void* h, const SymbolTable& symbol_table, gctools::clasp_ptr_t libstart, gctools::clasp_ptr_t textStart, gctools::clasp_ptr_t textEnd, + OpenDynamicLibraryInfo(bool is_executable, const std::string& f, void* h, gctools::clasp_ptr_t libstart, gctools::clasp_ptr_t textStart, gctools::clasp_ptr_t textEnd, bool hasVtableSection, gctools::clasp_ptr_t vtableSectionStart, gctools::clasp_ptr_t vtableSectionEnd ) : _IsExecutable(is_executable), _Filename(f), _Handle(h), - _SymbolTable(symbol_table), _LibraryStart(libstart), _TextStart(textStart), _TextEnd(textEnd), diff --git a/include/clasp/core/exceptions.h b/include/clasp/core/exceptions.h index 8e3ca895e9..9294612398 100644 --- a/include/clasp/core/exceptions.h +++ b/include/clasp/core/exceptions.h @@ -293,7 +293,6 @@ struct CxxFunctionInvocationLogger { #define IMPLEMENT_MEF(msg) SIMPLE_ERROR("Implement function %s:%d %s %s", __FILE__ , __LINE__ , __FUNCTION__ , msg) #define WARN_IMPLEMENT_ME() printf("%s:%d:%s Implement function\n", __FILE__, __LINE__, __FUNCTION__ ); -#define WARN_IMPLEMENT_MEF(msg) printf("%s\n", (BF("Implement function %s:%d %s %s") % __FILE__ % __LINE__ % __FUNCTION__ % (msg).str().c_str()).str().c_str()); #define NOT_SUPPORTED() SIMPLE_ERROR("Subclass(%s) does not support the function(%s) file(%s) lineNumber(%d)", this->className() , __FUNCTION__ , __FILE__ , __LINE__); @@ -305,9 +304,6 @@ struct CxxFunctionInvocationLogger { #define DEPRECATED() SIMPLE_ERROR(("Depreciated!!! function(%s) file(%s) lineNumber(%d)") , __FUNCTION__ , __FILE__ , __LINE__); #define STUB() printf("%s:%d>%s stub\n", __FILE__, __LINE__, __FUNCTION__ ) -#define MAY_BE_DEPRECATED() printf("%s\n", (BF("May be depreciated!!! function(%s) file(%s) lineNumber(%d)") % __FUNCTION__ % __FILE__ % __LINE__).str().c_str()); -#define DEPRECATEDP(s) SIMPLE_ERROR(("Depreciated!!! function(%s) file(%s) lineNumber(%d) %s") , __FUNCTION__ , __FILE__ , __LINE__ , (s)); - FORWARD(Cons); #ifdef DEBUG_ASSERT @@ -495,10 +491,6 @@ void assert_failure_bounds_error_lt(const char* file, size_t line, const char* f SIMPLE_ERROR(("Assertion [%s>%s] failed values are (%s) and (%s)") , #x , #y , (x) , (y)); \ } #define ASSERT_gt(x, y) ASSERT_greaterThan(x, y) -#define FATAL_ASSERTP(x, e) \ - if (!(x)) { \ - SIMPLE_ERROR(_lisp, core::LispError_O::create(BF("Assertion [%s] failed - %s") % #x % (e), _lisp)); \ - }; #if DEBUG_TRAP_NULLS == 1 #define ASSERTNOTNULLP(x, e) \ @@ -535,8 +527,6 @@ void assert_failure_bounds_error_lt(const char* file, size_t line, const char* f {} #define ASSERT_gt(x, y) \ {} -#define FATAL_ASSERTP(x, e) \ - {} #define ASSERTNOTNULLP(x, e) \ {} #define ASSERTNOTNULL(x) \ diff --git a/include/clasp/core/external_wrappers.h b/include/clasp/core/external_wrappers.h index e5283ca987..93b17ce64e 100644 --- a/include/clasp/core/external_wrappers.h +++ b/include/clasp/core/external_wrappers.h @@ -54,7 +54,7 @@ class WRAPPER_IndirectMethod < RT(OT::ExternalType::*)(ARGS...), Policies, OT, A enum { NumParams = sizeof...(ARGS)+1 }; WRAPPER_IndirectMethod(MethodType ptr, core::FunctionDescription_sp fdesc, core::T_sp code) - : mptr(ptr), GlobalSimpleFunBase_O(fdesc,core::ClaspXepFunction::make(),code) { + : GlobalSimpleFunBase_O(fdesc,core::ClaspXepFunction::make(),code), mptr(ptr) { this->validateCodePointer((void**)&this->mptr,sizeof(this->mptr)); }; @@ -118,7 +118,7 @@ class WRAPPER_IndirectMethod < RT(OT::ExternalType::*)(ARGS...) const, Policies, enum { NumParams = sizeof...(ARGS)+1 }; WRAPPER_IndirectMethod(MethodType ptr, core::FunctionDescription_sp fdesc, core::T_sp code) - : mptr(ptr), GlobalSimpleFunBase_O(fdesc,core::ClaspXepFunction::make(),code) { + : GlobalSimpleFunBase_O(fdesc,core::ClaspXepFunction::make(),code), mptr(ptr) { this->validateCodePointer((void**)&this->mptr,sizeof(this->mptr)); }; @@ -185,7 +185,7 @@ class WRAPPER_Getter : public GlobalSimpleFunBase_O { public: WRAPPER_Getter(MemPtr ptr, core::FunctionDescription_sp fdesc, core::T_sp code) - : mptr(ptr), GlobalSimpleFunBase_O(fdesc,core::ClaspXepFunction::make(),code) { + : GlobalSimpleFunBase_O(fdesc,core::ClaspXepFunction::make(),code), mptr(ptr) { this->validateCodePointer((void**)&this->mptr,sizeof(this->mptr)); } diff --git a/include/clasp/core/funcallableInstance.h b/include/clasp/core/funcallableInstance.h index 245b5d31ff..74c244a62b 100644 --- a/include/clasp/core/funcallableInstance.h +++ b/include/clasp/core/funcallableInstance.h @@ -63,7 +63,7 @@ class FuncallableInstance_O : public Function_O { explicit FuncallableInstance_O(GlobalSimpleFun_sp fdesc, Instance_sp metaClass, size_t slots) : Base(fdesc), _Class(metaClass), _RealFunction(nil()){}; FuncallableInstance_O(GlobalSimpleFun_sp fdesc, Instance_sp cl, Rack_sp rack) - : Base(fdesc), _Class(cl), _Rack(rack), _RealFunction(nil()){}; + : Base(fdesc), _Rack(rack), _Class(cl), _RealFunction(nil()){}; virtual ~FuncallableInstance_O(){}; public: diff --git a/include/clasp/core/lisp.h b/include/clasp/core/lisp.h index e4dba40b8a..0bce2dccc3 100644 --- a/include/clasp/core/lisp.h +++ b/include/clasp/core/lisp.h @@ -257,21 +257,18 @@ struct globals_t { // ------------------------------------------------------------ // ------------------------------------------------------------ // ------------------------------------------------------------ - globals_t() : _MakePackageCallback(NULL), - _ExportSymbolCallback(NULL), - _PathMax(CLASP_MAXPATHLEN), - _ActiveThreadsMutex(ACTVTHRD_NAMEWORD), + globals_t() : _ActiveThreadsMutex(ACTVTHRD_NAMEWORD), _DefaultSpecialBindingsMutex(SPCLBIND_NAMEWORD), _FinalizersMutex(MPSMESSG_NAMEWORD), _SourceFilesMutex(SRCFILES_NAMEWORD), _PackagesMutex(PKGSMUTX_NAMEWORD), -#ifdef DEBUG_MONITOR_SUPPORT - _MonitorMutex(LOGMUTEX_NAMEWORD), -#endif _ThePathnameTranslationsMutex(PNTRANSL_NAMEWORD), _JITLogMutex(JITLOG___NAMEWORD), _UnixSignalHandlersMutex(UNIXSIGN_NAMEWORD), - _CodeBlocksMutex(CODEBLOK_NAMEWORD), + _CodeBlocksMutex(CODEBLOK_NAMEWORD), +#ifdef DEBUG_MONITOR_SUPPORT + _MonitorMutex(LOGMUTEX_NAMEWORD), +#endif _StackWarnSize(gctools::_global_stack_max_size * 0.9), // 6MB default stack size before warnings _StackSampleCount(0), _StackSampleSize(0), @@ -279,7 +276,10 @@ struct globals_t { _ReplCounter(1), _Bundle(NULL), _DebugStream(NULL), - _SingleStepLevel(UndefinedUnsignedInt) + _SingleStepLevel(UndefinedUnsignedInt), + _MakePackageCallback(NULL), + _ExportSymbolCallback(NULL), + _PathMax(CLASP_MAXPATHLEN) { this->_GlobalInitializationCallbacks.clear(); this->_TraceLevel = 0; @@ -385,8 +385,6 @@ class Lisp { public: static void initializeGlobals(LispPtr lisp); -public: - static void lisp_initSymbols(LispPtr lisp); public: static const int MaxFunctionArguments; //()), shared_locks_array(*shared_locks_array_ptr), want_x_lock(false), recursive_xlock_count(0), + want_x_lock(false), shared_locks_array_ptr(std::make_shared()), shared_locks_array(*shared_locks_array_ptr), recursive_xlock_count(0), owner_thread_id(thread_id_t()) {} ~contention_free_shared_mutex() { diff --git a/include/clasp/core/mpPackage.h b/include/clasp/core/mpPackage.h index 5b06188d66..73354df0e5 100644 --- a/include/clasp/core/mpPackage.h +++ b/include/clasp/core/mpPackage.h @@ -149,9 +149,12 @@ class Process_O : public core::CxxObject_O { public: Process_O(core::T_sp name, core::T_sp function, core::List_sp arguments, core::List_sp initialSpecialBindings = nil(), size_t stack_size = 8 * 1024 * 1024) - : _Parent(nil()), _UniqueID(global_process_UniqueID++), _Name(name), _Function(function), _Arguments(arguments), - _InitialSpecialBindings(initialSpecialBindings), _ThreadInfo(NULL), _ReturnValuesList(nil()), _Aborted(false), - _AbortCondition(nil()), _StackSize(stack_size), _Phase(Nascent), _SuspensionMutex(SUSPBARR_NAMEWORD) { + : _UniqueID(global_process_UniqueID++), _Parent(nil()), _Name(name), _Function(function), _Arguments(arguments), + _InitialSpecialBindings(initialSpecialBindings), + _ReturnValuesList(nil()), _Aborted(false), + _AbortCondition(nil()), _ThreadInfo(NULL), + _Phase(Nascent), _SuspensionMutex(SUSPBARR_NAMEWORD), + _StackSize(stack_size) { if (!function) { printf("%s:%d Trying to create a process and the function is NULL\n", __FILE__, __LINE__); } diff --git a/include/clasp/core/newhash.h b/include/clasp/core/newhash.h index 76b382f479..73c976f838 100644 --- a/include/clasp/core/newhash.h +++ b/include/clasp/core/newhash.h @@ -103,52 +103,51 @@ hash_string(int initval, const unsigned char *k, int length) { /*------------------------------------- handle the last 11 bytes */ c += length; switch (len) { - /* all the case statements fall through */ case 23: - c += ((uintptr_t)k[22] << 52); + c += ((uintptr_t)k[22] << 52); [[fallthrough]]; case 22: - c += ((uintptr_t)k[21] << 48); + c += ((uintptr_t)k[21] << 48); [[fallthrough]]; case 21: - c += ((uintptr_t)k[20] << 40); + c += ((uintptr_t)k[20] << 40); [[fallthrough]]; case 20: - c += ((uintptr_t)k[19] << 32); + c += ((uintptr_t)k[19] << 32); [[fallthrough]]; case 19: - c += ((uintptr_t)k[18] << 24); + c += ((uintptr_t)k[18] << 24); [[fallthrough]]; case 18: - c += ((uintptr_t)k[17] << 16); + c += ((uintptr_t)k[17] << 16); [[fallthrough]]; case 17: - c += ((uintptr_t)k[16] << 8); + c += ((uintptr_t)k[16] << 8); [[fallthrough]]; /* the first byte of c is reserved for the length */ case 16: - b += ((uintptr_t)k[15] << 52); + b += ((uintptr_t)k[15] << 52); [[fallthrough]]; case 15: - b += ((uintptr_t)k[14] << 48); + b += ((uintptr_t)k[14] << 48); [[fallthrough]]; case 14: - b += ((uintptr_t)k[13] << 40); + b += ((uintptr_t)k[13] << 40); [[fallthrough]]; case 13: - b += ((uintptr_t)k[12] << 32); + b += ((uintptr_t)k[12] << 32); [[fallthrough]]; case 12: - b += ((uintptr_t)k[11] << 24); + b += ((uintptr_t)k[11] << 24); [[fallthrough]]; case 11: - b += ((uintptr_t)k[10] << 16); + b += ((uintptr_t)k[10] << 16); [[fallthrough]]; case 10: - b += ((uintptr_t)k[9] << 8); + b += ((uintptr_t)k[9] << 8); [[fallthrough]]; case 9: - b += k[8]; + b += k[8]; [[fallthrough]]; case 8: - a += ((uintptr_t)k[7] << 52); + a += ((uintptr_t)k[7] << 52); [[fallthrough]]; case 7: - a += ((uintptr_t)k[6] << 48); + a += ((uintptr_t)k[6] << 48); [[fallthrough]]; case 6: - a += ((uintptr_t)k[5] << 40); + a += ((uintptr_t)k[5] << 40); [[fallthrough]]; case 5: - a += ((uintptr_t)k[4] << 32); + a += ((uintptr_t)k[4] << 32); [[fallthrough]]; case 4: - a += ((uintptr_t)k[3] << 24); + a += ((uintptr_t)k[3] << 24); [[fallthrough]]; case 3: - a += ((uintptr_t)k[2] << 16); + a += ((uintptr_t)k[2] << 16); [[fallthrough]]; case 2: - a += ((uintptr_t)k[1] << 8); + a += ((uintptr_t)k[1] << 8); [[fallthrough]]; case 1: a += k[0]; /* case 0: nothing left to add */ diff --git a/include/clasp/core/numbers.h b/include/clasp/core/numbers.h index ad673e478f..f6eab092c9 100644 --- a/include/clasp/core/numbers.h +++ b/include/clasp/core/numbers.h @@ -150,7 +150,7 @@ namespace core SingleFloat_sp clasp_make_single_float(float d); DoubleFloat_sp clasp_make_double_float(double d); Number_sp clasp_log1_complex_inner(Number_sp r, Number_sp i); - void clasp_report_divide_by_zero(Number_sp x); + [[noreturn]] void clasp_report_divide_by_zero(Number_sp x); }; namespace core { diff --git a/include/clasp/core/package.h b/include/clasp/core/package.h index fed3435f77..2e2c23dc6a 100644 --- a/include/clasp/core/package.h +++ b/include/clasp/core/package.h @@ -224,8 +224,9 @@ class Package_O : public General_O { public: // Not default constructable - Package_O() : _Nicknames(nil()), _LocalNicknames(nil()), - _Documentation(nil()), _Lock(PACKAGE__NAMEWORD), _ActsLikeKeywordPackage(false) + Package_O() : _ActsLikeKeywordPackage(false), + _Nicknames(nil()), _LocalNicknames(nil()), + _Documentation(nil()), _Lock(PACKAGE__NAMEWORD) {}; virtual void fixupInternalsForSnapshotSaveLoad( snapshotSaveLoad::Fixup* fixup ) { diff --git a/include/clasp/core/record.h b/include/clasp/core/record.h index 38c51cc11d..4e3b108941 100644 --- a/include/clasp/core/record.h +++ b/include/clasp/core/record.h @@ -493,14 +493,14 @@ class Record_O : public General_O { template void field(Symbol_sp name, gctools::SmallMultimap_uncopyable,gctools::smart_ptr,CMP>& value ) { - RECORD_LOG(BF("field(Symbol_sp name, gctools::SmallMultimap,gctools::smart_ptr> ) name: %s") % _rep_(name)); + RECORD_LOG(("field(Symbol_sp name, gctools::SmallMultimap,gctools::smart_ptr> ) name: %s") , _rep_(name)); switch (this->stage()) { case saving: { Vector_sp vec_value = core__make_vector(cl::_sym_T_O, value.size()); size_t idx(0); for (auto it : value) vec_value->rowMajorAset(idx++,Cons_O::create(it.first, it.second)); - RECORD_LOG(BF("saving entry: %s") % _rep_(vec_value)); + RECORD_LOG(("saving entry: %s") , _rep_(vec_value)); Cons_sp apair = core::Cons_O::create(name, vec_value); this->_alist = core::Cons_O::create(apair, this->_alist); } break; @@ -512,13 +512,13 @@ class Record_O : public General_O { if (!find.consp()) SIMPLE_ERROR_SPRINTF("Could not find field %s", _rep_(name).c_str()); Cons_sp apair = gc::As_unsafe(find); - RECORD_LOG(BF("loading find: %s") % _rep_(apair)); + RECORD_LOG(("loading find: %s") , _rep_(apair)); Vector_sp vec_value = gc::As(CONS_CDR(apair)); - RECORD_LOG(BF("vec_value: %s") % _rep_(vec_value)); + RECORD_LOG(("vec_value: %s") , _rep_(vec_value)); value.clear(); for (size_t i(0), iEnd(cl__length(vec_value)); i < iEnd; ++i) { T_sp val = vec_value->rowMajorAref(i); - RECORD_LOG(BF("Loading vec0[%d] new@%p: %s\n") % i % (void *)(val.raw_()) % _rep_(val)); + RECORD_LOG(("Loading vec0[%d] new@%p: %s\n") , i , (void *)(val.raw_()) , _rep_(val)); value.push_back(std::make_pair, gctools::smart_ptr>(gc::As_unsafe>(oCar(val)), gc::As_unsafe>(oCdr(val)))); @@ -527,7 +527,7 @@ class Record_O : public General_O { this->flagSeen(apair); } break; case patching: { - RECORD_LOG(BF("Patching")); + RECORD_LOG(("Patching")); for ( auto&& pairi : value ) { gc::smart_ptr orig_key = pairi.first; gc::smart_ptr orig_value = pairi.second; diff --git a/include/clasp/core/sort.h b/include/clasp/core/sort.h index 0ae7729cb3..a8f975beed 100644 --- a/include/clasp/core/sort.h +++ b/include/clasp/core/sort.h @@ -205,77 +205,6 @@ void quickSortFirstCheckOrder(_RandomAccessIterator m, _RandomAccessIterator en, } } -#if 0 -template -__attribute__((optnone)) -void quickSortDebugDepth(_RandomAccessIterator m, _RandomAccessIterator en, Ocomp comparer, size_t depth) { - printf("%s:%d:%s number of entries: %lu\n", __FILE__, __LINE__, __FUNCTION__, (en - m) ); - if (depth==0) { - printf("%s:%d:%s Hit max depth - figure out why\n", __FILE__, __LINE__, __FUNCTION__ ); - abort(); - } - _RandomAccessIterator k; - _RandomAccessIterator n = en - 1; - if ((en-m) <= 1) return; - // typedef typename std::iterator_traits<_RandomAccessIterator>::value_type _ValueType; - typedef typename _RandomAccessIterator::value_type _ValueType; - if (m < n) { -#ifdef DEBUG_SORT - LOG(("Sorting list at start")); - for (_RandomAccessIterator ii = m; ii <= n; ii++) { - LOG(("element %d = %s") , (ii - m) , (*ii)->__repr__()); - } -#endif - ssize_t half = (n - m); - half = half / 2; - k = m + half; // pivot - swap<_ValueType>(*m, *k); -#ifdef DEBUG_SORT - LOG(("Sorting list pivot is now first element: ")); - for (_RandomAccessIterator ii = m; ii <= n; ii++) { - LOG(("element %d = %s") , (ii - m) , (*ii)->__repr__()); - } -#endif - _RandomAccessIterator i = m + 1; - _RandomAccessIterator j = n; - while (i <= j) { - _BLOCK_TRACEF(BF("Top of while i(%d) <= j(%d)") % (i - m) % (j - m)); - while ((i <= n) && (comparer(*i, *m))) { - LOG(("skipping lower bin index: %d value: %s") , (i - m) , _rep_((*i))); - i++; - } - while ((j >= i) && (!comparer(*j, *m))) { - LOG(("skipping upper bin index: %d value: %s") , (j - m) , _rep_((*j))); - j--; - } - if (i < j) { - LOG(("swapping value lower index: %d value: %s") , (i - m) , _rep_((*i))); - LOG(("swapping value upper index: %d value: %s") , (j - m) , _rep_((*j))); - swap<_ValueType>(*i, *j); - } - } - swap<_ValueType>(*m, *j); -#ifdef DEBUG_SORT - LOG(("After pivot list is now: ")); - for (_RandomAccessIterator ii = m; ii <= n; ii++) { - LOG(("element %d = %s") , (ii - m) , (*ii)->__repr__()); - } -#endif - LOG(("element at j -- index: %d value: %s") , (j - m) , _rep_((*j))); - quickSortDebugDepth(m, j, comparer,depth-1); - quickSortDebugDepth(j + 1, n + 1, comparer,depth-1); -#ifdef DEBUG_SORT - LOG(("After sort list is now: ")); - for (_RandomAccessIterator ii = m; ii <= n; ii++) { - LOG(("element %d = %s") , (ii - m) , (*ii)->__repr__()); - } -#endif - } -} -#endif - - - template void quickSort(_RandomAccessIterator m, _RandomAccessIterator en) { std::vector> work; diff --git a/include/clasp/core/string.h b/include/clasp/core/string.h index 5cdfa8a846..67742b8cf6 100644 --- a/include/clasp/core/string.h +++ b/include/clasp/core/string.h @@ -102,7 +102,6 @@ namespace core { virtual void ranged_sxhash(HashGenerator& hg, size_t start, size_t end) const final { if (hg.isFilling()) { Fixnum hash = 5381; - Fixnum c; for ( size_t i(start); isetf_name(snm); n->fmakunbound(); n->fmakunbound_setf(); -// ASSERTF(nm != "", BF("You cannot create a symbol without a name")); return n; }; public: diff --git a/include/clasp/core/translators.h b/include/clasp/core/translators.h index 7afde50f7c..ad18966209 100644 --- a/include/clasp/core/translators.h +++ b/include/clasp/core/translators.h @@ -283,8 +283,8 @@ template <> { typedef bool *DeclareType; - DeclareType _v; bool _val; + DeclareType _v; from_object( T_P o ) : _val( false ), _v( &_val ){}; }; @@ -293,8 +293,8 @@ template <> { typedef bool *DeclareType; - DeclareType _v; bool _val; + DeclareType _v; from_object( T_P o ) : _val( false ), _v( &_val ){}; ~from_object() {/*non trivial*/}; }; @@ -304,8 +304,8 @@ template <> { typedef bool *DeclareType; - DeclareType _v; bool _val; + DeclareType _v; from_object( T_P o ) : _val( true ), _v( &_val ){}; }; diff --git a/include/clasp/core/wrappers.h b/include/clasp/core/wrappers.h index 69e4599b7a..8542943d34 100644 --- a/include/clasp/core/wrappers.h +++ b/include/clasp/core/wrappers.h @@ -118,7 +118,7 @@ class WRAPPER_VariadicMethod : enum { NumParams = sizeof...(ARGS)+1 }; WRAPPER_VariadicMethod(MethodType ptr, core::FunctionDescription_sp fdesc, core::T_sp code) - : mptr(ptr), core::GlobalSimpleFunBase_O(fdesc,core::ClaspXepFunction::make(),code) { + : core::GlobalSimpleFunBase_O(fdesc,core::ClaspXepFunction::make(),code), mptr(ptr) { this->validateCodePointer((void**)&this->mptr,sizeof(this->mptr)); }; @@ -190,7 +190,7 @@ class WRAPPER_VariadicMethod < RT(OT::*)(ARGS...) const, Policies, ArgumentWrapp enum { NumParams = sizeof...(ARGS)+1 }; WRAPPER_VariadicMethod(MethodType ptr, core::FunctionDescription_sp fdesc, core::T_sp code) - : mptr(ptr), core::GlobalSimpleFunBase_O(fdesc,core::ClaspXepFunction::make(),code) { + : core::GlobalSimpleFunBase_O(fdesc,core::ClaspXepFunction::make(),code), mptr(ptr) { this->validateCodePointer((void**)&this->mptr,sizeof(this->mptr)); }; @@ -250,7 +250,6 @@ namespace core { inline void wrap_translator(const string &packageName, const string &name, core::T_O* (*fp)(core::T_O*), const string& filename, const string &arguments = "", const string &declares = "", const string &docstring = "", const string &sourceFile = "", int sourceLine = 0) { Symbol_sp symbol = lispify_intern(name, packageName); using VariadicType = WRAPPER_Translator_O; - FunctionDescription_sp fdesc = makeFunctionDescription(symbol,nil()); auto entry = gctools::GC::allocate(fp); lisp_bytecode_defun( symbol_function, clbind::DefaultWrapper::BytecodeP, symbol, packageName, entry, arguments, declares, docstring, sourceFile, sourceLine, 1 ); } diff --git a/include/clasp/gctools/gcalloc_boehm.h b/include/clasp/gctools/gcalloc_boehm.h index 669512588c..11a0850cb7 100644 --- a/include/clasp/gctools/gcalloc_boehm.h +++ b/include/clasp/gctools/gcalloc_boehm.h @@ -103,7 +103,6 @@ inline Header_s* do_boehm_general_allocation(const Header_s::BadgeStampWtagMtag& #endif #ifdef USE_PRECISE_GC auto stamp = the_header.stamp(); - auto kind_defined = global_stamp_layout[stamp].boehm._kind_defined; auto& kind = global_stamp_layout[stamp].boehm._kind; GCTOOLS_ASSERT(kind!=KIND_UNDEFINED); Header_s* header = reinterpret_cast(ALIGNED_GC_MALLOC_KIND( stamp, true_size, kind, &kind)); diff --git a/include/clasp/gctools/gcweak.h b/include/clasp/gctools/gcweak.h index 07d2b3570e..c5e19c0bab 100644 --- a/include/clasp/gctools/gcweak.h +++ b/include/clasp/gctools/gcweak.h @@ -302,7 +302,7 @@ class WeakKeyHashTable { mutable mp::SharedMutex_sp _Mutex; #endif public: - WeakKeyHashTable(size_t length, core::Number_sp rehashSize, double rehashThreshold) : _Length(length), _RehashSize(rehashSize), _RehashThreshold(rehashThreshold) {}; + WeakKeyHashTable(size_t length, core::Number_sp rehashSize, double rehashThreshold) : _RehashSize(rehashSize), _RehashThreshold(rehashThreshold), _Length(length) {}; void initialize(); public: static uint sxhashKey(const value_type &key); diff --git a/include/clasp/gctools/memoryManagement.h b/include/clasp/gctools/memoryManagement.h index 3cda621d7e..5c2b72dc05 100644 --- a/include/clasp/gctools/memoryManagement.h +++ b/include/clasp/gctools/memoryManagement.h @@ -63,7 +63,7 @@ struct ClaspInfo { core::LispHolder *_lispHolder; ClaspInfo(int argc, const char **argv, size_t stackMax) - : _argc(argc), _argv(argv), _stackMax(stackMax), _lispHolder(NULL), _mpiEnabled(false), _mpiRank(0), _mpiSize(1){}; + : _argc(argc), _argv(argv), _stackMax(stackMax), _mpiEnabled(false), _mpiRank(0), _mpiSize(1), _lispHolder(NULL){}; }; }; // namespace gctools @@ -746,7 +746,7 @@ class Header_s : public BaseHeader_s { #define GUARD2 0xC0FFEEE0 Header_s(const BadgeStampWtagMtag &k, size_t tstart = 0, size_t tsize = 0, size_t total_size = sizeof(Header_s)) - : BaseHeader_s(k), _guard(GUARD1), _tail_start(tstart), _tail_size(tsize), _source((uintptr_t)this), _guard2(GUARD2), + : BaseHeader_s(k), _tail_start(tstart), _tail_size(tsize), _guard(GUARD1), _source((uintptr_t)this), _guard2(GUARD2), _dup_badge_stamp_wtag_mtag(k) { #ifdef DEBUG_GUARD_BACKTRACE this->maybe_fill_backtrace(k._value); @@ -755,7 +755,7 @@ class Header_s : public BaseHeader_s { }; Header_s(Header_s *headerptr) - : BaseHeader_s(headerptr->_badge_stamp_wtag_mtag), _guard(GUARD1), _tail_start(0), _tail_size(0), _source(headerptr->_source), + : BaseHeader_s(headerptr->_badge_stamp_wtag_mtag), _tail_start(0), _tail_size(0), _guard(GUARD1), _source(headerptr->_source), _guard2(GUARD2), _dup_badge_stamp_wtag_mtag(headerptr->_badge_stamp_wtag_mtag){}; #endif diff --git a/include/clasp/gctools/snapshotSaveLoad.h b/include/clasp/gctools/snapshotSaveLoad.h index 5c436ac480..a98f838a5d 100644 --- a/include/clasp/gctools/snapshotSaveLoad.h +++ b/include/clasp/gctools/snapshotSaveLoad.h @@ -151,7 +151,7 @@ struct LibraryLookup { uintptr_t _loadAddress; std::string _libraryPath; - LibraryLookup( const std::string libraryPath ) : _libraryPath(libraryPath), _loadAddress(0) {}; + LibraryLookup( const std::string libraryPath ) : _loadAddress(0), _libraryPath(libraryPath) {}; std::map _symbolToAddress; std::map _addressToSymbol; diff --git a/include/clasp/gctools/threadlocal.fwd.h b/include/clasp/gctools/threadlocal.fwd.h index 924f6709e1..69ba1f06d6 100644 --- a/include/clasp/gctools/threadlocal.fwd.h +++ b/include/clasp/gctools/threadlocal.fwd.h @@ -40,14 +40,15 @@ namespace gctools { #endif GlobalAllocationProfiler() : + _HitAllocationNumberCounter(0), + _HitAllocationSizeCounter(0), + _AllocationNumberThreshold(16386), _AllocationSizeThreshold(1024*1024) - , _AllocationNumberThreshold(16386) - , _HitAllocationNumberCounter(0) - , _HitAllocationSizeCounter(0) {}; - GlobalAllocationProfiler(size_t size, size_t number) : _AllocationSizeThreshold(size), _AllocationNumberThreshold(number) - , _HitAllocationNumberCounter(0) - , _HitAllocationSizeCounter(0) + GlobalAllocationProfiler(size_t size, size_t number) : + _HitAllocationNumberCounter(0), + _HitAllocationSizeCounter(0), + _AllocationNumberThreshold(number), _AllocationSizeThreshold(size) {}; inline void registerAllocation(stamp_t stamp, size_t size) { diff --git a/include/clasp/gctools/threadlocal.h b/include/clasp/gctools/threadlocal.h index ddd243d946..a36bf577d7 100644 --- a/include/clasp/gctools/threadlocal.h +++ b/include/clasp/gctools/threadlocal.h @@ -138,7 +138,7 @@ struct VirtualMachine { inline core::T_O* alloca_vaslist2(core::T_O**& stackPointer, core::T_O** args, size_t nargs) { core::T_O* vl = this->alloca_vaslist1(stackPointer,args,nargs); - core::T_O* vl_backup = this->alloca_vaslist1(stackPointer,args,nargs); + this->alloca_vaslist1(stackPointer,args,nargs); return vl; } diff --git a/include/clasp/llvmo/code.h b/include/clasp/llvmo/code.h index 041d0b9dda..4bb20a86c4 100644 --- a/include/clasp/llvmo/code.h +++ b/include/clasp/llvmo/code.h @@ -97,23 +97,24 @@ typedef enum { SaveState, RunState } CodeState_t; DEBUG_OBJECT_FILES_PRINT(("%s:%d:%s objectId = %lu\n", __FILE__, __LINE__, __FUNCTION__, objectId)); }; ObjectFile_O( core::SimpleBaseString_sp codename, JITDylib_sp jitdylib, size_t objectId ) : - _State(RunState), - _CodeName(codename), - _TheJITDylib(jitdylib), - _gcRoots(NULL), - _CodeBlock(unbound()), - _ObjectId(objectId) { + _State(RunState), + _CodeName(codename), + _ObjectId(objectId), + _TheJITDylib(jitdylib), + _gcRoots(NULL), + _CodeBlock(unbound()) + { DEBUG_OBJECT_FILES_PRINT(("%s:%d:%s codename = %s\n", __FILE__, __LINE__, __FUNCTION__, _rep_(codename).c_str() )); }; ObjectFile_O( core::SimpleBaseString_sp codename, CodeBlock_sp codeBlock, JITDylib_sp dylib, size_t objectId) : - _State(RunState), - _CodeName(codename), - _TheJITDylib(dylib), - _gcRoots(NULL), - _CodeBlock(codeBlock), - _TextSectionStart(0), - _TextSectionEnd(0), - _ObjectId(objectId) + _State(RunState), + _CodeName(codename), + _ObjectId(objectId), + _TheJITDylib(dylib), + _gcRoots(NULL), + _TextSectionStart(0), + _TextSectionEnd(0), + _CodeBlock(codeBlock) { DEBUG_OBJECT_FILES_PRINT(("%s:%d:%s created with CodeBlock_sp codename = %s CodeBlock = %s\n", __FILE__, __LINE__, __FUNCTION__, _rep_(codename).c_str(), core::_rep_(codeBlock).c_str() )); }; @@ -396,7 +397,6 @@ template inline void allocateInCodeBlock( BasicLayout& BL, CodeBlock_sp& codeBlock ) { WITH_READ_WRITE_LOCK(globals_->_CodeBlocksMutex); size_t PageSize = getpagesize(); - bool newCodeBlock = false; auto SegsSizes = BL.getContiguousPageBasedLayoutSizes(PageSize); if (_lisp->_Roots._AllCodeBlocks.load().consp()) { core::Cons_sp ll = gc::As_unsafe(_lisp->_Roots._AllCodeBlocks.load()); diff --git a/include/clasp/llvmo/debugInfoExpose.h b/include/clasp/llvmo/debugInfoExpose.h index 006ae65ac8..220300be56 100644 --- a/include/clasp/llvmo/debugInfoExpose.h +++ b/include/clasp/llvmo/debugInfoExpose.h @@ -862,7 +862,7 @@ struct from_object>, } } from_object(const from_object& orig) = delete; - from_object(from_object&& orig) : _Storage(std::move(orig._Storage)), _v(orig._v) { + from_object(from_object&& orig) : _v(orig._v), _Storage(std::move(orig._Storage)) { if (this->_v.hasValue()) { // printf("%s:%d:%s from_object move ctor\n", __FILE__, __LINE__, __FUNCTION__ ); llvm::DIFile::ChecksumInfo checksum(this->_v->Kind,this->_Storage); diff --git a/include/clasp/llvmo/llvmoExpose.h b/include/clasp/llvmo/llvmoExpose.h index a2bbd2c5bf..8fc32fc11e 100644 --- a/include/clasp/llvmo/llvmoExpose.h +++ b/include/clasp/llvmo/llvmoExpose.h @@ -4323,8 +4323,6 @@ class PointerType_O : public Type_O { // static core::T_sp get(core::T_sp result_type, core::T_sp params, core::T_sp is_var_arg); public: // static methods static PointerType_sp get(Type_sp elementType, uint addressSpace); - - llvm::Type* getElementType() const; }; // PointerType_O }; // llvmo @@ -4438,8 +4436,8 @@ namespace translate { template <> struct from_object { typedef llvm::StringRef DeclareType; - DeclareType _v; string _Storage; + DeclareType _v; from_object(T_P object) : _Storage(gc::As(object)->get_std_string()), _v(this->_Storage) {}; from_object(const from_object& orig) = delete; from_object(from_object&& orig) : _Storage(std::move(orig._Storage)), _v(_Storage) {}; diff --git a/include/clasp/llvmo/read-stamp.cc b/include/clasp/llvmo/read-stamp.cc index a758471f0f..63457756f1 100644 --- a/include/clasp/llvmo/read-stamp.cc +++ b/include/clasp/llvmo/read-stamp.cc @@ -4,7 +4,6 @@ template core::T_O* template_read_stamp(TTT* obj) { uintptr_t tag = reinterpret_cast(obj)&gctools::ptag_mask; - int64_t stamp; switch (tag) { case FIXNUM0_TAG: case FIXNUM1_TAG: diff --git a/include/clasp/llvmo/translators.h b/include/clasp/llvmo/translators.h index 2741ac06c5..68684afec6 100644 --- a/include/clasp/llvmo/translators.h +++ b/include/clasp/llvmo/translators.h @@ -215,7 +215,7 @@ struct from_object> { from_object(core::T_sp o) { if ( core::Function_sp func = gc::As(o) ) { printf("%s:%d translate::from_object passing dummy for now \n", __FILE__, __LINE__ ); - this->_v = std::function ([&func] (const llvm::Function& f)->bool { + this->_v = std::function ([] (const llvm::Function& f)->bool { return true; } ); diff --git a/src/asttooling/astExpose1.cc b/src/asttooling/astExpose1.cc index 5988462a97..b01d81a53d 100644 --- a/src/asttooling/astExpose1.cc +++ b/src/asttooling/astExpose1.cc @@ -232,7 +232,7 @@ core::T_sp mostDerivedType(const clang::Type *x) { llvm::raw_string_ostream out(buf); clang::ASTDumper dumper(out,false); dumper.Visit(s); - SIMPLE_ERROR(("astExpose.cc>mostDerivedType. Could not cast clang::Type s->getTypeClass()-> %d. typename: %s ") , s->getTypeClass() , out.str() ); + SIMPLE_ERROR(("astExpose.cc>mostDerivedType. Could not cast clang::Type s->getTypeClass()-> %d. typename: %s ") , (int)(s->getTypeClass()) , out.str() ); } @@ -256,7 +256,6 @@ CL_DEFUN void cast__dump(core::T_sp obj, core::T_sp stream) { // .def("dump", (void (clang::Stmt::*)() const) & clang::Stmt::dump) // .def("dump", (void(clang::Type::*)() const)&clang::Type::dump) // .def("dump", (void (clang::Decl::*)() const) & clang::Decl::dump) - bool stringOutputStream = false; llvm::SmallString<1024> stringOutput; llvm::raw_svector_ostream ostream(stringOutput); core::WrappedPointer_sp wp_node = gc::As(obj); diff --git a/src/asttooling/clangTooling.cc b/src/asttooling/clangTooling.cc index 93f3d62bf7..92f34edfd0 100644 --- a/src/asttooling/clangTooling.cc +++ b/src/asttooling/clangTooling.cc @@ -120,13 +120,10 @@ struct from_object { if (o.nilp()) { SIMPLE_ERROR(("You cannot pass nil as a function")); } else if (core::Function_sp func = o.asOrNull()) { - void* function_address = (void*)func->entry(); - // printf("%s:%d intermediate from_object with Function arg: %s@%p - function_address: %p\n", __FILE__, __LINE__, _rep_(o).c_str(), (void*)o.tagged_(), function_address); - this->_v = [func,function_address](const clang::tooling::CommandLineArguments &args, llvm::StringRef filename ) -> clang::tooling::CommandLineArguments { + this->_v = [func](const clang::tooling::CommandLineArguments &args, llvm::StringRef filename ) -> clang::tooling::CommandLineArguments { // Should resolve to vector core::T_sp targs = translate::to_object::convert(args); core::T_sp tfilename = translate::to_object::convert(filename); -// printf("%s:%d About to funcall %s[lineno=%d] with targs %s and tfilename %s - it should have function address: %p\n", __FILE__, __LINE__, _rep_(func).c_str(), func->lineNumber(), _rep_(targs).c_str(), _rep_(tfilename).c_str(), function_address); core::T_mv result = core::eval::funcall(func,targs,tfilename);; translate::from_object cresult(result); return cresult._v; diff --git a/src/clbind/class_rep.cc b/src/clbind/class_rep.cc index b68707aa24..c619da8827 100644 --- a/src/clbind/class_rep.cc +++ b/src/clbind/class_rep.cc @@ -224,8 +224,8 @@ void ClassRep_O::add_base_class(core::Fixnum_sp pointer_offset, ClassRep_sp base // to tell clbind that it derives. ASSERTF(base.objectp(), ("You cannot derive from an unregistered type")); - ClassRep_sp bcrep = base; #if 0 + ClassRep_sp bcrep = base; // import all static constants for (std::map::const_iterator i = bcrep->m_static_constants.begin(); i != bcrep->m_static_constants.end(); ++i) diff --git a/src/core/array.cc b/src/core/array.cc index 7e94cf1652..2eedff0a53 100644 --- a/src/core/array.cc +++ b/src/core/array.cc @@ -244,7 +244,6 @@ size_t Array_O::arrayRowMajorIndex(Vaslist_sp indices) const { } size_t offset = 0; size_t idx = 0; - size_t idxEnd(indices_passed); for ( ; idxarrayDimension(idx); diff --git a/src/core/backtrace.cc b/src/core/backtrace.cc index 341125bcae..e80f11cded 100644 --- a/src/core/backtrace.cc +++ b/src/core/backtrace.cc @@ -176,6 +176,7 @@ T_sp dwarf_ep(size_t frameIndex, llvmo::ObjectFile_sp code = ofi; codeStart = (void*)code->codeStart(); uintptr_t codeEnd = code->codeEnd(); + (void)codeEnd; // sham use - used below in D uintptr_t absolute_LowPC = ranges.begin()->LowPC+(uintptr_t)codeStart; functionStartAddress = (void*)(absolute_LowPC); D(printf("%s:%d:%s Calculated functionStartAddress = %p\n", __FILE__, __LINE__, __FUNCTION__, functionStartAddress );); @@ -664,7 +665,7 @@ bool accessible_memory_p(void* ptr) { res = false; close(fd[0]); close(fd[1]); - } + } else return false; // Not sure if correct return res; } @@ -724,14 +725,14 @@ static T_mv os_call_with_frame(std::function func ) { } static bool os_sanity_check_backtrace() { MaybeTrace trace(__FUNCTION__); - uintptr_t stacktop = (uintptr_t)my_thread_low_level->_StackTop; + // uintptr_t stacktop = (uintptr_t)my_thread_low_level->_StackTop; size_t num = START_BACKTRACE_SIZE; void** buffer = (void**)calloc(sizeof(void*), num); for (size_t attempt = 0; attempt < MAX_BACKTRACE_SIZE_LOG2; ++attempt) { size_t returned = backtrace(buffer, num); if (returned < num) { void* fbp = __builtin_frame_address(0); - uintptr_t stackbot = (uintptr_t)&fbp; + // uintptr_t stackbot = (uintptr_t)&fbp; for (size_t j = 0; j < returned; ++j) { /* if (fbp && !((stackbot <= (uintptr_t)fbp) && ((uintptr_t)fbp <= stacktop))) { diff --git a/src/core/bits.cc b/src/core/bits.cc index 9efc06fcb2..012976ee06 100644 --- a/src/core/bits.cc +++ b/src/core/bits.cc @@ -253,7 +253,7 @@ mp_size_t next_xor(mp_limb_t* result, const mp_limb_t* s1, mp_size_t len1, if (len2 < 0) { // Both negative. Result is positive. // (-x) ^ (-y) = ~(x-1) ^ ~(y-1) = (x-1) ^ (y-1) - mp_size_t size1 = -len1, size2 = -len2, result_size; + mp_size_t size1 = -len1, size2 = -len2; mp_limb_t temp1[size1]; mpn_sub_1(temp1, s1, size1, (mp_limb_t)1); mp_limb_t temp2[size2]; diff --git a/src/core/bootStrapCoreSymbolMap.cc b/src/core/bootStrapCoreSymbolMap.cc index b82653692c..ee3337b9ca 100644 --- a/src/core/bootStrapCoreSymbolMap.cc +++ b/src/core/bootStrapCoreSymbolMap.cc @@ -97,13 +97,11 @@ bool BootStrapCoreSymbolMap::find_symbol(string const &packageName, string const void BootStrapCoreSymbolMap::finish_setup_of_symbols() { //printf("%s:%d finish_setup_of_symbols\n", __FILE__, __LINE__ ); - int idxEnd = this->_SymbolNamesToIndex.size(); for (map::const_iterator it = this->_SymbolNamesToIndex.begin(); it != this->_SymbolNamesToIndex.end(); it++) { int idx = it->second; SymbolStorage &ss = this->_IndexToSymbol[idx]; string packageName = ss._PackageName; -// printf("%s:%d Adding symbol(%s)[%d/%d] to package: %s\n", __FILE__, __LINE__, ss._SymbolName.c_str(), idx, idxEnd, packageName.c_str()); T_sp tpackage = _lisp->findPackage(packageName,true); Package_sp pkg = gc::As(tpackage); // printf("%s:%d The package most derived pointer base address adding symbol to: %p\n", __FILE__, __LINE__, pkg.raw_()); diff --git a/src/core/bytecode.cc b/src/core/bytecode.cc index 3b11581739..2f9b6136a4 100644 --- a/src/core/bytecode.cc +++ b/src/core/bytecode.cc @@ -714,7 +714,6 @@ static gctools::return_type bytecode_vm(VirtualMachine& vm, case vm_entry: { uint8_t n = *(++pc); DBG_VM("entry %" PRIu8 "\n", n); - T_O** old_sp = sp; pc++; jmp_buf target; void* frame = __builtin_frame_address(0); @@ -1126,6 +1125,7 @@ static unsigned char *long_dispatch(VirtualMachine& vm, throwUnrecognizedKeywordArgumentError(tclosure, tunknown); } pc += 9; + break; } case vm_check_arg_count_LE : { uint8_t low = *(pc + 1); diff --git a/src/core/bytecode_compiler.cc b/src/core/bytecode_compiler.cc index 856aa4ace6..1a359f20c3 100644 --- a/src/core/bytecode_compiler.cc +++ b/src/core/bytecode_compiler.cc @@ -895,7 +895,7 @@ CL_DEFUN void compile_locally(List_sp body, Lexenv_sp env, Context_sp ctxt) { List_sp specials; eval::extract_declares_docstring_code_specials(body, declares, false, docstring, code, specials); Lexenv_sp inner1 = env->add_specials(specials); - Lexenv_sp inner2 = env->add_notinlines(decl_notinlines(declares)); + Lexenv_sp inner2 = inner1->add_notinlines(decl_notinlines(declares)); compile_progn(code, inner2, ctxt); } @@ -1777,7 +1777,6 @@ CL_DEFUN void compile_combination(T_sp head, T_sp rest, Lexenv_sp env, Context_s // not a special form else { if (gc::IsA(head)) { - Symbol_sp shead = gc::As_unsafe(head); T_sp info = fun_info(head, env); if (gc::IsA(info)) { GlobalMacroInfo_sp minfo = gc::As_unsafe(info); @@ -1893,7 +1892,7 @@ CL_DEFUN T_mv bytecode_toplevel_locally(List_sp body, Lexenv_sp env) { List_sp specials; eval::extract_declares_docstring_code_specials(body, declares, false, docstring, code, specials); Lexenv_sp inner1 = env->add_specials(specials); - Lexenv_sp inner2 = env->add_notinlines(decl_notinlines(declares)); + Lexenv_sp inner2 = inner1->add_notinlines(decl_notinlines(declares)); return bytecode_toplevel_progn(code, inner2); } diff --git a/src/core/commandLineOptions.cc b/src/core/commandLineOptions.cc index 4875df5c13..62b3431a61 100644 --- a/src/core/commandLineOptions.cc +++ b/src/core/commandLineOptions.cc @@ -407,10 +407,15 @@ void process_clasp_arguments(CommandLineOptions *options) { } CommandLineOptions::CommandLineOptions(int argc, const char *argv[]) - : _ProcessArguments(process_clasp_arguments), _DisableMpi(false), _AddressesP(false), _StartupType(DEFAULT_STARTUP_TYPE), - _FreezeStartupType(false), _HasDescribeFile(false), _StartupFile(""), _ExportedSymbolsAccumulate(false), _RandomNumberSeed(0), - _NoInform(false), _NoPrint(false), _DebuggerDisabled(false), _Interactive(true), _Version(false), _SilentStartup(true), - _RCFileName(std::string(getenv("HOME")) + "/.clasprc"), _NoRc(false), _PauseForDebugger(false) { + : _ProcessArguments(process_clasp_arguments), + _DisableMpi(false), _AddressesP(false), + _FreezeStartupType(false), _StartupType(DEFAULT_STARTUP_TYPE), + _StartupFile(""), _HasDescribeFile(false), + _RandomNumberSeed(0), _ExportedSymbolsAccumulate(false), + _NoInform(false), _NoPrint(false), _DebuggerDisabled(false), + _Interactive(true), _Version(false), _SilentStartup(true), + _RCFileName(std::string(getenv("HOME")) + "/.clasprc"), _NoRc(false), + _PauseForDebugger(false) { if (argc == 0) { this->_RawArguments.push_back("./"); } else { @@ -456,7 +461,7 @@ CL_DEFUN List_sp core__command_line_load_eval_sequence() { one = Cons_O::create(kw::_sym_script, SimpleBaseString_O::make(it.second)); break; default: - SIMPLE_ERROR("Unknown load type %d for %s%N", it.first, it.second); + SIMPLE_ERROR("BUG: Unknown load type %d for %s%N", it.second); break; } loadEvals = Cons_O::create(one, loadEvals); diff --git a/src/core/compiler.cc b/src/core/compiler.cc index c97c60f7c1..dfdc845ad8 100644 --- a/src/core/compiler.cc +++ b/src/core/compiler.cc @@ -434,7 +434,6 @@ CL_DEFUN T_mv core__mangle_name(Symbol_sp sym, bool is_function) { } return Values(nil(), name, make_fixnum(0), make_fixnum(CALL_ARGUMENTS_LIMIT)); } - Function_sp fsym = coerce::functionDesignator(sym); return Values(nil(), SimpleBaseString_O::make("Provide-func-name"), make_fixnum(0), make_fixnum(CALL_ARGUMENTS_LIMIT)); } @@ -769,10 +768,7 @@ CL_DEFUN core::T_sp core__load_faso(T_sp pathDesig, T_sp verbose, T_sp print, T_ std::string uniqueName = llvmo::ensureUniqueMemoryBufferName(tryUniqueName.str()); llvm::StringRef name(uniqueName); std::unique_ptr memoryBuffer(llvm::MemoryBuffer::getMemBuffer(sbuffer, name, false)); - llvmo::ObjectFile_sp objectFile = - jit->addObjectFile(jitDylib, std::move(memoryBuffer), print.notnilp(), header->_ObjectFiles[fasoIndex]._ObjectId); - // printf("%s:%d:%s addObjectFile objectFile = %p badge: 0x%0x jitDylib = %p\n", __FILE__, __LINE__, __FUNCTION__, - // objectFile.raw_(), lisp_badge(objectFile), jitDylib.raw_()); + jit->addObjectFile(jitDylib, std::move(memoryBuffer), print.notnilp(), header->_ObjectFiles[fasoIndex]._ObjectId); T_mv startupName = core__startup_linkage_shutdown_names(header->_ObjectFiles[fasoIndex]._ObjectId, nil()); String_sp str = gc::As(startupName); DEBUG_OBJECT_FILES_PRINT(("%s:%d:%s running startup %s\n", __FILE__, __LINE__, __FUNCTION__, str->get_std_string().c_str())); @@ -837,14 +833,9 @@ CL_DEFUN core::T_sp core__describe_faso(T_sp pathDesig) { close(fd); SIMPLE_ERROR(("Could not mmap %s because of %s"), _rep_(pathDesig), strerror(errno)); } - llvmo::ClaspJIT_sp jit = llvmo::llvm_sys__clasp_jit(); FasoHeader *header = (FasoHeader *)memory; write_bf_stream(fmt::sprintf("NumberOfObjectFiles %d\n", header->_NumberOfObjectFiles)); for (size_t fasoIndex = 0; fasoIndex < header->_NumberOfObjectFiles; ++fasoIndex) { - size_t fasoIndexd = header->_ObjectFiles[fasoIndex]._ObjectId; - void *of_start = (void *)((char *)header + header->_ObjectFiles[fasoIndex]._StartPage * header->_PageSize); - size_t of_length = header->_ObjectFiles[fasoIndex]._ObjectFileSize; - // write_bf_stream(fmt::sprintf("Adding faso %s object file %d to jit\n" , _rep_(filename) , fasoIndex)); write_bf_stream(fmt::sprintf("Object file %d ObjectId: %lu start-page: %lu bytes: %lu pages: %lu\n", fasoIndex, header->_ObjectFiles[fasoIndex]._ObjectId, header->_ObjectFiles[fasoIndex]._StartPage, header->_ObjectFiles[fasoIndex]._ObjectFileSize, header->_ObjectFiles[fasoIndex]._NumberOfPages)); @@ -1221,7 +1212,6 @@ CL_DOCSTRING(R"dx(multipleValueFuncall)dx"); DOCGROUP(clasp); CL_DEFUN T_mv core__multiple_value_funcall(Function_sp fmv, List_sp thunks) { MAKE_STACK_FRAME(frame, MultipleValues::MultipleValuesLimit); - size_t numArgs = 0; size_t idx = 0; for (auto cur : thunks) { Function_sp tfunc = gc::As(oCar(cur)); @@ -1560,14 +1550,7 @@ T_O *ltvc_read_object(gctools::GCRootsInModule *roots, //SELF_CHECK(T_O *, stream, index); if (bytecode >= byteend) SIMPLE_ERROR("Unexpected EOF"); char tag = *bytecode++; - char ttag; - if (tag == 'l') - ttag = 0; // literal - else if (tag == 't') - ttag = 1; // transient - else if (tag == 'i') - ttag = 2; // immediate - else { + if (!((tag == 'l') || (tag == 't') || (tag == 'i'))) { printf("%s:%d The object tag must be 'l', 't' or 'i'\n", __FILE__, __LINE__); abort(); } diff --git a/src/core/creator.cc b/src/core/creator.cc index 258f2847cc..b83d0a432e 100644 --- a/src/core/creator.cc +++ b/src/core/creator.cc @@ -66,7 +66,6 @@ T_sp FuncallableInstanceCreator_O::creator_allocate() { // Used during early boot when STANDARD-CLASS itself is being created, and such. namespace core { T_sp StandardClassCreator_O::creator_allocate() { - size_t size = gctools::sizeof_with_header(); Instance_sp c = lisp_standard_class(); auto class_ = gctools::GC::allocate(c); return class_; @@ -76,7 +75,6 @@ T_sp StandardClassCreator_O::creator_allocate() { namespace core { T_sp DerivableCxxClassCreator_O::creator_allocate() { - size_t size = gctools::sizeof_with_header(); auto class_ = gctools::GC::allocate(lisp_standard_class()/*,REF_CLASS_NUMBER_OF_SLOTS_IN_STRUCTURE_CLASS*/); return class_; }; @@ -85,7 +83,6 @@ T_sp DerivableCxxClassCreator_O::creator_allocate() { namespace core { T_sp ClassRepCreator_O::creator_allocate() { - size_t size = gctools::sizeof_with_header(); auto class_ = gctools::GC::allocate(lisp_clbind_cxx_class()); return class_; }; diff --git a/src/core/debug_macosx.cc b/src/core/debug_macosx.cc index 39f137f2fe..7daf1b0a53 100644 --- a/src/core/debug_macosx.cc +++ b/src/core/debug_macosx.cc @@ -110,6 +110,7 @@ format_display_size(char buf[5], uint64_t size) { precision = 1; } int len = snprintf(buf, 5, "%.*f%c", precision, display_size, scale[scale_index]); + (void)len; // sham assert(len > 0 && len < 5); } @@ -119,6 +120,7 @@ format_memory_protection(char buf[4], int prot) { (prot & VM_PROT_READ ? 'r' : '-'), (prot & VM_PROT_WRITE ? 'w' : '-'), (prot & VM_PROT_EXECUTE ? 'x' : '-')); + (void)len; // sham assert(len == 3); } @@ -222,19 +224,12 @@ bool mygetsegmentsize( bool errorP, { const struct mach_header_64* mhp = (const struct mach_header_64*)vmhp; struct segment_command_64 *sgp; - struct section_64 *sp; - uint32_t i, j; - intptr_t slide; + uint32_t i; uintptr_t address = (uintptr_t)vmhp; - slide = 0; - sp = 0; sgp = (struct segment_command_64 *) ((char *)mhp + sizeof(struct mach_header_64)); for(i = 0; i < mhp->ncmds; i++, sgp = (struct segment_command_64 *)((char *)sgp + sgp->cmdsize)){ if(sgp->cmd == LC_SEGMENT_64){ - if(strcmp(sgp->segname, "__TEXT") == 0){ - slide = (uintptr_t)mhp - sgp->vmaddr; - } // printf("%s:%d:%s Looking at segment: %s\n", __FILE__, __LINE__, __FUNCTION__, sgp->segname); if (strcmp(sgp->segname, segname) == 0){ segment_start = (gctools::clasp_ptr_t)address; // (gctools::clasp_ptr_t)sgp->vmaddr; @@ -349,24 +344,14 @@ void add_dynamic_library_impl(add_dynamic_library* callback, bool is_executable, //printf("%s:%d:%s library: %s given library_origin @%p !!!! I need the size!!!!!!\n", __FILE__, __LINE__, __FUNCTION__, libraryName.c_str(), (void*)library_origin); } - uintptr_t exec_header; // printf("%s:%d:%s library_origin %p\n", __FILE__, __LINE__, __FUNCTION__, (void*)library_origin); dlerror(); - exec_header = (uintptr_t)dlsym(RTLD_DEFAULT,"_mh_execute_header"); + dlsym(RTLD_DEFAULT,"_mh_execute_header"); const char* dle = dlerror(); if (dle) { printf("Could not find the symbol _mh_execute_header\n"); abort(); } -// printf("%s:%d:%s Executable header _mh_execute_header %p\n", __FILE__, __LINE__, __FUNCTION__, (void*)exec_header); - SymbolTable symbol_table; - size_t section_size; -// printf("%s:%d:%s About to load_stackmap_info library_origin = %p\n", __FILE__, __LINE__, __FUNCTION__, (void*)library_origin ); - uintptr_t p_section = load_stackmap_info(libraryName.c_str(),library_origin,section_size); - if (p_section) { - symbol_table._StackmapStart = p_section; - symbol_table._StackmapEnd = p_section+section_size; - } BT_LOG(("OpenDynamicLibraryInfo libraryName: %s handle: %p library_origin: %p\n", libraryName.c_str(),(void*)handle,(void*)library_origin)); gctools::clasp_ptr_t text_segment_start; uintptr_t text_segment_size; @@ -384,7 +369,7 @@ void add_dynamic_library_impl(add_dynamic_library* callback, bool is_executable, found = vmmap(seek,vtableRegionStart,vtableRegionEnd,false); } OpenDynamicLibraryInfo odli(is_executable, - libraryName,handle,symbol_table, + libraryName,handle, reinterpret_cast(library_origin), reinterpret_cast(library_origin), reinterpret_cast(library_origin+text_segment_size), diff --git a/src/core/debug_unixes.cc b/src/core/debug_unixes.cc index ba1eadf9d6..496b3d3e94 100644 --- a/src/core/debug_unixes.cc +++ b/src/core/debug_unixes.cc @@ -58,7 +58,6 @@ THE SOFTWARE. #include #include #include -#define _GNU_SOURCE #include #include #endif @@ -150,21 +149,12 @@ void walk_elf_symbol_table(struct dl_phdr_info *info, for (ii = 0; ii < count; ++ii) { GElf_Sym sym; gelf_getsym(data, ii, &sym); - int seg = sym.st_shndx; uintptr_t addr = 0; symbol_start = (uintptr_t)sym.st_value + addr; // symbols are loaded at 0x0 // +start; symbol_end = symbol_start+sym.st_size; if (symbol_end>highest_end_address) { highest_end_address = symbol_end; } - char type = '?'; - if (ELF64_ST_TYPE(sym.st_info) == STT_FUNC) { - if (ELF64_ST_BIND(sym.st_info) == STB_GLOBAL) type = 'T'; - else type = 't'; - } else if (ELF64_ST_TYPE(sym.st_info) == STT_OBJECT) { - if (ELF64_ST_BIND(sym.st_info) == STB_GLOBAL) type = 'D'; - else type = 'd'; - } BT_LOG(("Looking at symbol %s type: %d\n", elf_strptr(elf,shdr.sh_link , (size_t)sym.st_name), ELF64_ST_TYPE(sym.st_info))); const char* sname = elf_strptr(elf,shdr.sh_link , (size_t)sym.st_name); if (symbolCallback->debug()) { @@ -283,17 +273,6 @@ int elf_walk_loaded_object_callback(struct dl_phdr_info *info, size_t size, void for (int j = 0; j < info->dlpi_phnum; j++) { int p_type = info->dlpi_phdr[j].p_type; #if 1 - const char* type; - type = (p_type == PT_LOAD) ? "PT_LOAD" : - (p_type == PT_DYNAMIC) ? "PT_DYNAMIC" : - (p_type == PT_INTERP) ? "PT_INTERP" : - (p_type == PT_NOTE) ? "PT_NOTE" : - (p_type == PT_INTERP) ? "PT_INTERP" : - (p_type == PT_PHDR) ? "PT_PHDR" : - (p_type == PT_TLS) ? "PT_TLS" : - (p_type == PT_GNU_EH_FRAME) ? "PT_GNU_EH_FRAME" : - (p_type == PT_GNU_STACK) ? "PT_GNU_STACK" : - (p_type == PT_GNU_RELRO) ? "PT_GNU_RELRO" : NULL; printf(" %2d: [%14p; memsz:%7jx; END: %14p] flags: %#jx; \n", j, (void *) (info->dlpi_addr + info->dlpi_phdr[j].p_vaddr), (uintmax_t) info->dlpi_phdr[j].p_memsz, @@ -420,7 +399,6 @@ void add_dynamic_library_impl(add_dynamic_library* callback, library_origin = (uintptr_t)find_base_of_loaded_object(libraryName.c_str()); if (library_origin==0) { // Try looking for _init symbol - void* lorigin; Dl_info data; dlerror(); void* addr = dlsym(handle,"_init"); @@ -437,29 +415,8 @@ void add_dynamic_library_impl(add_dynamic_library* callback, library_origin = (uintptr_t)data.dli_fbase; } } -// printf("%s:%d:%s data.dli_fbase = %p\n", __FILE__, __LINE__, __FUNCTION__, (void*)data.dli_fbase); - uintptr_t stackmap_start; - size_t section_size; -// SymbolTable symbol_table = load_linux_symbol_table(libraryName.c_str(),library_origin,stackmap_start,section_size); - SymbolTable symbol_table; - if (is_executable) { - symbol_table._StackmapStart = stackmap_start; - symbol_table._StackmapEnd = stackmap_start+section_size; - } else { - if (stackmap_start) { - symbol_table._StackmapStart = stackmap_start+library_origin; - symbol_table._StackmapEnd = stackmap_start+section_size+library_origin; - } - } -// symbol_table.optimize(); -// symbol_table.sort(); -// if (!symbol_table.is_sorted()) { -// printf("%s:%d The symbol table for %s is not sorted\n", __FILE__, __LINE__, libraryName.c_str()); -// abort(); -// } BT_LOG(("OpenDynamicLibraryInfo libraryName: %s handle: %p library_origin: %p\n", libraryName.c_str(),(void*)handle,(void*)library_origin)); - gctools::clasp_ptr_t library_end = (gctools::clasp_ptr_t)library_origin; - OpenDynamicLibraryInfo odli(is_executable,libraryName,handle,symbol_table,(gctools::clasp_ptr_t)library_origin,text_start,text_end, + OpenDynamicLibraryInfo odli(is_executable,libraryName,handle,(gctools::clasp_ptr_t)library_origin,text_start,text_end, hasVtableSection,vtableSectionStart,vtableSectionEnd); if (callback) { (*callback)(odli); diff --git a/src/core/debugger.cc b/src/core/debugger.cc index 58e02af4b1..4df8b7e71d 100644 --- a/src/core/debugger.cc +++ b/src/core/debugger.cc @@ -204,7 +204,6 @@ bool if_dynamic_library_loaded_remove(const std::string& libraryName) { void executablePath(std::string& name) { WITH_READ_LOCK(debugInfo()._OpenDynamicLibraryMutex); - size_t index; for ( auto& entry : debugInfo()._OpenDynamicLibraryHandles ) { if (entry.second._IsExecutable) { name = entry.second._Filename; @@ -215,7 +214,6 @@ void executablePath(std::string& name) { } void executableVtableSectionRange( gctools::clasp_ptr_t& start, gctools::clasp_ptr_t& end ) { WITH_READ_LOCK(debugInfo()._OpenDynamicLibraryMutex); - size_t index; for ( auto& entry : debugInfo()._OpenDynamicLibraryHandles ) { if (entry.second._IsExecutable) { start = entry.second._VtableSectionStart; @@ -228,7 +226,6 @@ void executableVtableSectionRange( gctools::clasp_ptr_t& start, gctools::clasp_p void executableTextSectionRange( gctools::clasp_ptr_t& start, gctools::clasp_ptr_t& end ) { WITH_READ_LOCK(debugInfo()._OpenDynamicLibraryMutex); - size_t index; for ( auto& entry : debugInfo()._OpenDynamicLibraryHandles ) { if (entry.second._IsExecutable) { start = entry.second._TextStart; @@ -243,10 +240,9 @@ void executableTextSectionRange( gctools::clasp_ptr_t& start, gctools::clasp_ptr bool lookup_address_in_library(gctools::clasp_ptr_t address, gctools::clasp_ptr_t& start, gctools::clasp_ptr_t& end, std::string& libraryName, bool& executable, uintptr_t& vtableStart, uintptr_t& vtableEnd ) { WITH_READ_LOCK(debugInfo()._OpenDynamicLibraryMutex); - size_t index; for ( auto entry : debugInfo()._OpenDynamicLibraryHandles ) { // printf("%s:%d:%s Looking at entry: %s start: %p end: %p\n", __FILE__, __LINE__, __FUNCTION__, entry.second._Filename.c_str(), entry.second._LibraryStart, entry.second._LibraryEnd ); - if (entry.second._TextStart <= address && address < entry.second._TextEnd + if ((entry.second._TextStart <= address && address < entry.second._TextEnd) || (entry.second._VtableSectionStart <= address && address < entry.second._VtableSectionEnd ) ){ libraryName = entry.second._Filename; start = entry.second._TextStart; @@ -263,10 +259,9 @@ bool lookup_address_in_library(gctools::clasp_ptr_t address, gctools::clasp_ptr_ bool library_with_name( const std::string& name, bool isExecutable, std::string& libraryName, uintptr_t& start, uintptr_t& end, uintptr_t& vtableStart, uintptr_t& vtableEnd ) { WITH_READ_LOCK(debugInfo()._OpenDynamicLibraryMutex); - size_t index; for ( auto entry : debugInfo()._OpenDynamicLibraryHandles ) { std::string libName = entry.second._Filename; - if ( name.size()<= libName.size() && name == libName.substr(libName.size()-name.size()) + if ((name.size()<= libName.size() && name == libName.substr(libName.size()-name.size())) || ( isExecutable && entry.second._IsExecutable)) { libraryName = entry.second._Filename; start = (uintptr_t)(entry.second._TextStart); diff --git a/src/core/dtree-interpreter.cc b/src/core/dtree-interpreter.cc index b94230b333..6a8e57d27b 100644 --- a/src/core/dtree-interpreter.cc +++ b/src/core/dtree-interpreter.cc @@ -152,7 +152,6 @@ case MAYBE_LONG_ADD + DTREE_OP_SLOT_WRITE: { case MAYBE_LONG_ADD + DTREE_OP_RPLACA: { DTILOG("class cell\n"); T_sp location = ReadArg::read_literal(ip, (DTREE_SLOT_WRITER_INDEX_OFFSET), literals); - size_t index = location.unsafe_fixnum(); Cons_sp cell = gc::As_unsafe(location); T_sp value = T_sp((gctools::Tagged)(lcc_args[0])); DTILOG("Got value@%p %s\n", (void *)value.raw_(), _safe_rep_(value)); @@ -215,7 +214,6 @@ case MAYBE_LONG_ADD + DTREE_OP_SLOT_WRITE: { case MAYBE_LONG_ADD + DTREE_OP_RPLACA: { DTILOG("class cell\n"); T_sp location = ReadArg::read_literal(ip, (DTREE_SLOT_WRITER_INDEX_OFFSET), literals); - size_t index = location.unsafe_fixnum(); Cons_sp cell = gc::As_unsafe(location); T_sp value((gc::Tagged)lcc_farg0); DTILOG("Got value@%p %s\n", (void *)value.raw_(), _safe_rep_(value)); @@ -344,7 +342,9 @@ case MAYBE_LONG_ADD + DTREE_OP_SD_EQ_BRANCH: { } break; } +/* case MAYBE_LONG_ADD + DTREE_OP_SINGLE_DISPATCH_MISS: goto SINGLE_DISPATCH_MISS; +*/ #endif diff --git a/src/core/evaluator.cc b/src/core/evaluator.cc index de300a4d15..df4ec3c35b 100644 --- a/src/core/evaluator.cc +++ b/src/core/evaluator.cc @@ -148,7 +148,6 @@ T_mv apply0_inner_valist(Function_sp func, Vaslist_sp var) { T_O *a0, *a1, *a2, *a3; int lenRest = var->nargs(); int nargs = lenRest + 0; - Vaslist* vaslist = &*var; switch (lenRest) { case 0: return (*func).entry_0()(func.raw_()); @@ -746,25 +745,6 @@ CL_DEFUN T_sp core__extract_lambda_name_from_declares(List_sp declares, T_sp def } -CL_LAMBDA(declare-list); -CL_DECLARE(); -CL_DOCSTRING(R"dx(If form has is a list of declares ((function-name xxx) ...) or else looks like `(lambda lambda-list [[declaration* | documentation]] (block xxx form*) ) then return XXX)dx"); -DOCGROUP(clasp); -CL_DEFUN T_sp core__extract_dump_module_from_declares(List_sp declares) { - // First check for a (declare (core:function-name XXX)) - for ( auto cur : declares ) { - T_sp decl = CONS_CAR(declares); - if (decl.consp()) { - if (oCar(decl) == core::_sym_dump_module) { - return oCadr(decl); - } else if (decl == core::_sym_dump_module) { - return _lisp->_true(); - } - } - } - return nil(); -} - CL_LAMBDA(form &optional default); CL_DECLARE(); CL_DOCSTRING(R"dx(If form has is a list of declares ((function-name xxx) ...) or else looks like `(lambda lambda-list [[declaration* | documentation]] (block xxx form*) ) then return XXX)dx"); @@ -784,7 +764,6 @@ CL_DEFUN T_sp core__extract_lambda_name(List_sp lambdaExpression, T_sp defaultVa T_sp first = oCar(form); if ((first).consp()) { if (oCar(first) == cl::_sym_block) { - T_sp second = oCadr(first); Symbol_sp name = gc::As(oCadr(first)); if (name.notnilp()) { // Only return block name if not nil diff --git a/src/core/exceptions.cc b/src/core/exceptions.cc index fccaade308..fa4519a3d5 100644 --- a/src/core/exceptions.cc +++ b/src/core/exceptions.cc @@ -524,8 +524,7 @@ void DebugStream::setSuppressMessages(bool s) { char *internalPrintf(const LispPtr &lisp, const char *fmt, va_list arg_ptr) { char *outBuffer; - int n; - n = vasprintf(&outBuffer, fmt, arg_ptr); + vasprintf(&outBuffer, fmt, arg_ptr); if (outBuffer == NULL) { SIMPLE_ERROR(("Could not allocate a large enough internalPrintf buffer")); } diff --git a/src/core/fileSystem.cc b/src/core/fileSystem.cc index fc9ae1a5ea..f691d9720d 100644 --- a/src/core/fileSystem.cc +++ b/src/core/fileSystem.cc @@ -523,11 +523,11 @@ CL_DEFMETHOD bool FileStatus_O::isOther() { Pathname_sp getcwd(bool change_d_p_d) { Str8Ns_sp namestring = ext::ext__getcwd(); - size_t i = namestring->length(); // This commented out code adds a directory delimiter if none is there yet. // Not currently required because ext::ext__getcwd already does it. // However, ext::ext__getcwd() shouldn't, so leave this here to re-activate // on cleanup. + // size_t i = namestring->length(); //if (!IS_DIR_SEPARATOR(clasp_as_claspCharacter(namestring->rowMajorAref(i - 1)))) // namestring = SimpleBaseString_O::make(namestring->get() + DIR_SEPARATOR); Pathname_sp pathname = gc::As(cl__parse_namestring(namestring)); diff --git a/src/core/fli.cc b/src/core/fli.cc index 3af10f8b82..c5cf64eafb 100644 --- a/src/core/fli.cc +++ b/src/core/fli.cc @@ -117,9 +117,9 @@ THE SOFTWARE. // --------------------------------------------------------------------------- #if defined( DEBUG_LEVEL_FULL ) -#define DEBUG_PRINT(_msg_) LOG(_msg_) +#define DEBUG_PRINT(...) LOG(__VA_ARGS__) #else -#define DEBUG_PRINT(msg) +#define DEBUG_PRINT(...) #endif // --------------------------------------------------------------------------- @@ -301,7 +301,7 @@ void register_foreign_type_spec( core::ComplexVector_T_sp sp_tst, sp_tst->rowMajorAset( n_index, sp_fts->asSmartPtr() ); - DEBUG_PRINT(BF("%s (%s:%d) | Registered type %s with size = %d and alignment = %d\n.") % __FUNCTION__ % __FILE__ % __LINE__ % lisp_name % size % alignment ); + DEBUG_PRINT(("%s (%s:%d) | Registered type %s with size = %d and alignment = %d\n.") , __FUNCTION__ , __FILE__ , __LINE__ , lisp_name , size , alignment ); }; @@ -721,7 +721,7 @@ int64_t foreign_type_size( core::Symbol_sp atype ) RETURN_FROM_CORE__PERCENT_FOREIGN_TYPE_SIZE: - DEBUG_PRINT(BF("%s (%s:%d) | size = %d\n.") % __FUNCTION__ % __FILE__ % __LINE__ % result ); + DEBUG_PRINT(("%s (%s:%d) | size = %d\n.") , __FUNCTION__ , __FILE__ , __LINE__ , result ); return result; } @@ -968,182 +968,182 @@ inline T mem_ref( uintptr_t address ) core::T_sp PERCENTmem_ref_short( core::Integer_sp address ) { short v = mem_ref< short >( core::clasp_to_uintptr_t( address ) ); - DEBUG_PRINT(BF("%s (%s:%d) | v = %d\n.") % __FUNCTION__ % __FILE__ % __LINE__ % v ); + DEBUG_PRINT(("%s (%s:%d) | v = %d\n.") , __FUNCTION__ , __FILE__ , __LINE__ , v ); return mk_fixnum_short( v ); } core::T_sp PERCENTmem_ref_unsigned_short( core::Integer_sp address ) { unsigned short v = mem_ref< unsigned short >( core::clasp_to_uintptr_t( address ) ); - DEBUG_PRINT(BF("%s (%s:%d) | v = %d\n.") % __FUNCTION__ % __FILE__ % __LINE__ % v ); + DEBUG_PRINT(("%s (%s:%d) | v = %d\n.") , __FUNCTION__ , __FILE__ , __LINE__ , v ); return mk_fixnum_ushort( v ); } core::T_sp PERCENTmem_ref_int( core::Integer_sp address ) { int v = mem_ref< int >( core::clasp_to_uintptr_t( address ) ); - DEBUG_PRINT(BF("%s (%s:%d) | v = %d\n.") % __FUNCTION__ % __FILE__ % __LINE__ % v ); + DEBUG_PRINT(("%s (%s:%d) | v = %d\n.") , __FUNCTION__ , __FILE__ , __LINE__ , v ); return mk_fixnum_int( v ); } core::T_sp PERCENTmem_ref_unsigned_int( core::Integer_sp address ) { unsigned int v = mem_ref< unsigned int >( core::clasp_to_uintptr_t( address ) ); - DEBUG_PRINT(BF("%s (%s:%d) | v = %d\n.") % __FUNCTION__ % __FILE__ % __LINE__ % v ); + DEBUG_PRINT(("%s (%s:%d) | v = %d\n.") , __FUNCTION__ , __FILE__ , __LINE__ , v ); return mk_fixnum_uint( v ); } core::T_sp PERCENTmem_ref_int8( core::Integer_sp address ) { int8_t v = mem_ref< int8_t >( core::clasp_to_uintptr_t( address ) ); - DEBUG_PRINT(BF("%s (%s:%d) | v = %d\n.") % __FUNCTION__ % __FILE__ % __LINE__ % v ); + DEBUG_PRINT(("%s (%s:%d) | v = %d\n.") , __FUNCTION__ , __FILE__ , __LINE__ , v ); return mk_fixnum_int8( v ); } core::T_sp PERCENTmem_ref_uint8( core::Integer_sp address ) { int8_t v = mem_ref< int8_t >( core::clasp_to_uintptr_t( address ) ); - DEBUG_PRINT(BF("%s (%s:%d) | v = %d\n.") % __FUNCTION__ % __FILE__ % __LINE__ % v ); + DEBUG_PRINT(("%s (%s:%d) | v = %d\n.") , __FUNCTION__ , __FILE__ , __LINE__ , v ); return mk_fixnum_uint8( v ); } core::T_sp PERCENTmem_ref_int16( core::Integer_sp address ) { int16_t v = mem_ref< int16_t >( core::clasp_to_uintptr_t( address ) ); - DEBUG_PRINT(BF("%s (%s:%d) | v = %d\n.") % __FUNCTION__ % __FILE__ % __LINE__ % v ); + DEBUG_PRINT(("%s (%s:%d) | v = %d\n.") , __FUNCTION__ , __FILE__ , __LINE__ , v ); return mk_fixnum_int16( v ); } core::T_sp PERCENTmem_ref_uint16( core::Integer_sp address ) { uint16_t v = mem_ref< uint16_t >( core::clasp_to_uintptr_t( address ) ); - DEBUG_PRINT(BF("%s (%s:%d) | v = %d\n.") % __FUNCTION__ % __FILE__ % __LINE__ % v ); + DEBUG_PRINT(("%s (%s:%d) | v = %d\n.") , __FUNCTION__ , __FILE__ , __LINE__ , v ); return mk_fixnum_uint16( v ); } core::T_sp PERCENTmem_ref_int32( core::Integer_sp address ) { int32_t v = mem_ref< int32_t >( core::clasp_to_uintptr_t( address ) ); - DEBUG_PRINT(BF("%s (%s:%d) | v = %d\n.") % __FUNCTION__ % __FILE__ % __LINE__ % v ); + DEBUG_PRINT(("%s (%s:%d) | v = %d\n.") , __FUNCTION__ , __FILE__ , __LINE__ , v ); return mk_fixnum_int32( v ); } core::T_sp PERCENTmem_ref_uint32( core::Integer_sp address ) { uint32_t v = mem_ref< uint32_t >( core::clasp_to_uintptr_t( address ) ); - DEBUG_PRINT(BF("%s (%s:%d) | v = %d\n.") % __FUNCTION__ % __FILE__ % __LINE__ % v ); + DEBUG_PRINT(("%s (%s:%d) | v = %d\n.") , __FUNCTION__ , __FILE__ , __LINE__ , v ); return mk_fixnum_uint32( v ); } core::T_sp PERCENTmem_ref_int64( core::Integer_sp address ) { int64_t v = mem_ref< int64_t >( core::clasp_to_uintptr_t( address ) ); - DEBUG_PRINT(BF("%s (%s:%d) | v = %d\n.") % __FUNCTION__ % __FILE__ % __LINE__ % v ); + DEBUG_PRINT(("%s (%s:%d) | v = %d\n.") , __FUNCTION__ , __FILE__ , __LINE__ , v ); return mk_integer_int64( v ); } core::T_sp PERCENTmem_ref_uint64( core::Integer_sp address ) { uint64_t v = mem_ref< uint64_t >( core::clasp_to_uintptr_t( address ) ); - DEBUG_PRINT(BF("%s (%s:%d) | v = %d\n.") % __FUNCTION__ % __FILE__ % __LINE__ % v ); + DEBUG_PRINT(("%s (%s:%d) | v = %d\n.") , __FUNCTION__ , __FILE__ , __LINE__ , v ); return mk_integer_uint64( v ); } core::T_sp PERCENTmem_ref_long( core::Integer_sp address ) { long v = mem_ref< long >( core::clasp_to_uintptr_t( address ) ); - DEBUG_PRINT(BF("%s (%s:%d) | v = %d\n.") % __FUNCTION__ % __FILE__ % __LINE__ % v ); + DEBUG_PRINT(("%s (%s:%d) | v = %d\n.") , __FUNCTION__ , __FILE__ , __LINE__ , v ); return mk_integer_long( v ); } core::T_sp PERCENTmem_ref_unsigned_long( core::Integer_sp address ) { unsigned long v = mem_ref< unsigned long >( core::clasp_to_uintptr_t( address ) ); - DEBUG_PRINT(BF("%s (%s:%d) | v = %d\n.") % __FUNCTION__ % __FILE__ % __LINE__ % v ); + DEBUG_PRINT(("%s (%s:%d) | v = %d\n.") , __FUNCTION__ , __FILE__ , __LINE__ , v ); return mk_integer_ulong( v ); } core::T_sp PERCENTmem_ref_long_long( core::Integer_sp address ) { long long v = mem_ref< long long >( core::clasp_to_uintptr_t( address ) ); - DEBUG_PRINT(BF("%s (%s:%d) | v = %d\n.") % __FUNCTION__ % __FILE__ % __LINE__ % v ); + DEBUG_PRINT(("%s (%s:%d) | v = %d\n.") , __FUNCTION__ , __FILE__ , __LINE__ , v ); return mk_integer_longlong( v ); } core::T_sp PERCENTmem_ref_unsigned_long_long( core::Integer_sp address ) { unsigned long long v = mem_ref< unsigned long long >( core::clasp_to_uintptr_t( address ) ); - DEBUG_PRINT(BF("%s (%s:%d) | v = %d\n.") % __FUNCTION__ % __FILE__ % __LINE__ % v ); + DEBUG_PRINT(("%s (%s:%d) | v = %d\n.") , __FUNCTION__ , __FILE__ , __LINE__ , v ); return mk_integer_ulonglong( v ); } core::T_sp PERCENTmem_ref_double( core::Integer_sp address ) { double v = mem_ref< double >( core::clasp_to_uintptr_t( address ) ); - DEBUG_PRINT(BF("%s (%s:%d) | v = %d\n.") % __FUNCTION__ % __FILE__ % __LINE__ % v ); + DEBUG_PRINT(("%s (%s:%d) | v = %d\n.") , __FUNCTION__ , __FILE__ , __LINE__ , v ); return mk_double_float( v ); } core::T_sp PERCENTmem_ref_float( core::Integer_sp address ) { float v = mem_ref< float >( core::clasp_to_uintptr_t( address ) ); - DEBUG_PRINT(BF("%s (%s:%d) | v = %d\n.") % __FUNCTION__ % __FILE__ % __LINE__ % v ); + DEBUG_PRINT(("%s (%s:%d) | v = %d\n.") , __FUNCTION__ , __FILE__ , __LINE__ , v ); return mk_single_float( v ); } core::T_sp PERCENTmem_ref_long_double( core::Integer_sp address ) { long double v = mem_ref< long double >( core::clasp_to_uintptr_t( address ) ); - DEBUG_PRINT(BF("%s (%s:%d) | v = %d\n.") % __FUNCTION__ % __FILE__ % __LINE__ % v ); + DEBUG_PRINT(("%s (%s:%d) | v = %d\n.") , __FUNCTION__ , __FILE__ , __LINE__ , v ); return mk_long_double( v ); } core::T_sp PERCENTmem_ref_time( core::Integer_sp address ) { time_t v = mem_ref< time_t >( core::clasp_to_uintptr_t( address ) ); - DEBUG_PRINT(BF("%s (%s:%d) | v = %d\n.") % __FUNCTION__ % __FILE__ % __LINE__ % v ); + DEBUG_PRINT(("%s (%s:%d) | v = %d\n.") , __FUNCTION__ , __FILE__ , __LINE__ , v ); return mk_time( v ); } core::T_sp PERCENTmem_ref_pointer( core::Integer_sp address ) { void *v = mem_ref< void * >( core::clasp_to_uintptr_t( address ) ); - DEBUG_PRINT(BF("%s (%s:%d) | v = %p\n.") % __FUNCTION__ % __FILE__ % __LINE__ % v ); + DEBUG_PRINT(("%s (%s:%d) | v = %p\n.") , __FUNCTION__ , __FILE__ , __LINE__ , v ); return mk_pointer( v ); } core::T_sp PERCENTmem_ref_size( core::Integer_sp address ) { size_t v = mem_ref< size_t >( core::clasp_to_uintptr_t( address ) ); - DEBUG_PRINT(BF("%s (%s:%d) | v = %d\n.") % __FUNCTION__ % __FILE__ % __LINE__ % v ); + DEBUG_PRINT(("%s (%s:%d) | v = %d\n.") , __FUNCTION__ , __FILE__ , __LINE__ , v ); return mk_size( v ); } core::T_sp PERCENTmem_ref_ssize( core::Integer_sp address ) { ssize_t v = mem_ref< ssize_t >( core::clasp_to_uintptr_t( address ) ); - DEBUG_PRINT(BF("%s (%s:%d) | v = %d\n.") % __FUNCTION__ % __FILE__ % __LINE__ % v ); + DEBUG_PRINT(("%s (%s:%d) | v = %d\n.") , __FUNCTION__ , __FILE__ , __LINE__ , v ); return mk_ssize( v ); } core::T_sp PERCENTmem_ref_ptrdiff( core::Integer_sp address ) { ptrdiff_t v = mem_ref< ptrdiff_t >( core::clasp_to_uintptr_t( address ) ); - DEBUG_PRINT(BF("%s (%s:%d) | v = %d\n.") % __FUNCTION__ % __FILE__ % __LINE__ % v ); + DEBUG_PRINT(("%s (%s:%d) | v = %d\n.") , __FUNCTION__ , __FILE__ , __LINE__ , v ); return mk_ptrdiff( v ); } core::T_sp PERCENTmem_ref_char( core::Integer_sp address ) { int8_t v = mem_ref< int8_t >( core::clasp_to_uintptr_t( address ) ); - DEBUG_PRINT(BF("%s (%s:%d) | v = %d\n.") % __FUNCTION__ % __FILE__ % __LINE__ % v ); + DEBUG_PRINT(("%s (%s:%d) | v = %d\n.") , __FUNCTION__ , __FILE__ , __LINE__ , v ); return mk_fixnum_int8( v ); } core::T_sp PERCENTmem_ref_unsigned_char( core::Integer_sp address ) { uint8_t v = mem_ref< uint8_t >( core::clasp_to_uintptr_t( address ) ); - DEBUG_PRINT(BF("%s (%s:%d) | v = %d\n.") % __FUNCTION__ % __FILE__ % __LINE__ % v ); + DEBUG_PRINT(("%s (%s:%d) | v = %d\n.") , __FUNCTION__ , __FILE__ , __LINE__ , v ); return mk_fixnum_uint8( v ); } @@ -1296,7 +1296,7 @@ core::T_sp PERCENTmem_set_long_long( core::Integer_sp address, core::T_sp value long long tmp; translate::from_object< long long > v( value ); tmp = mem_set< long long >( core::clasp_to_uintptr_t( address ), v._v ); - DEBUG_PRINT(BF("%s (%s:%d) | v = %d\n.") % __FUNCTION__ % __FILE__ % __LINE__ % v._v ); + DEBUG_PRINT(("%s (%s:%d) | v = %d\n.") , __FUNCTION__ , __FILE__ , __LINE__ , v._v ); return mk_integer_longlong( tmp ); } @@ -1305,7 +1305,7 @@ core::T_sp PERCENTmem_set_unsigned_long_long( core::Integer_sp address, core::T_ unsigned long long tmp; translate::from_object< uint64_t /*unsigned long long*/ > v( value ); tmp = mem_set< unsigned long long >( core::clasp_to_uintptr_t( address ), v._v ); - DEBUG_PRINT(BF("%s (%s:%d) | v = %d\n.") % __FUNCTION__ % __FILE__ % __LINE__ % v._v ); + DEBUG_PRINT(("%s (%s:%d) | v = %d\n.") , __FUNCTION__ , __FILE__ , __LINE__ , v._v ); return mk_integer_ulonglong( tmp ); } @@ -1314,7 +1314,7 @@ core::T_sp PERCENTmem_set_double( core::Integer_sp address, core::T_sp value ) double tmp; translate::from_object< double > v( value ); tmp = mem_set< double >( core::clasp_to_uintptr_t( address ), v._v ); - DEBUG_PRINT(BF("%s (%s:%d) | v = %d\n.") % __FUNCTION__ % __FILE__ % __LINE__ % v._v ); + DEBUG_PRINT(("%s (%s:%d) | v = %d\n.") , __FUNCTION__ , __FILE__ , __LINE__ , v._v ); return mk_double_float( tmp ); } @@ -1323,7 +1323,7 @@ core::T_sp PERCENTmem_set_float( core::Integer_sp address, core::T_sp value ) float tmp; translate::from_object< float > v( value ); tmp = mem_set< float >( core::clasp_to_uintptr_t( address ), v._v ); - DEBUG_PRINT(BF("%s (%s:%d) | v = %d\n.") % __FUNCTION__ % __FILE__ % __LINE__ % v._v ); + DEBUG_PRINT(("%s (%s:%d) | v = %d\n.") , __FUNCTION__ , __FILE__ , __LINE__ , v._v ); return mk_single_float( tmp ); } @@ -1340,7 +1340,7 @@ core::T_sp PERCENTmem_set_time( core::Integer_sp address, core::T_sp value ) time_t tmp; translate::from_object< time_t > v( value ); tmp = mem_set< time_t >( core::clasp_to_uintptr_t( address ), v._v ); - DEBUG_PRINT(BF("%s (%s:%d) | v = %d\n.") % __FUNCTION__ % __FILE__ % __LINE__ % v._v ); + DEBUG_PRINT(("%s (%s:%d) | v = %d\n.") , __FUNCTION__ , __FILE__ , __LINE__ , v._v ); return mk_time( tmp ); } @@ -1349,7 +1349,7 @@ core::T_sp PERCENTmem_set_pointer( core::Integer_sp address, core::T_sp value ) void * tmp; translate::from_object< void * > v( value ); tmp = mem_set< void * >( core::clasp_to_uintptr_t( address ), v._v ); - DEBUG_PRINT(BF("%s (%s:%d) | v = %p\n.") % __FUNCTION__ % __FILE__ % __LINE__ % v._v ); + DEBUG_PRINT(("%s (%s:%d) | v = %p\n.") , __FUNCTION__ , __FILE__ , __LINE__ , v._v ); return mk_pointer( tmp ); } @@ -1358,7 +1358,7 @@ core::T_sp PERCENTmem_set_size( core::Integer_sp address, core::T_sp value ) size_t tmp; translate::from_object< size_t > v( value ); tmp = mem_set< size_t >( core::clasp_to_uintptr_t( address ), v._v ); - DEBUG_PRINT(BF("%s (%s:%d) | v = %d\n.") % __FUNCTION__ % __FILE__ % __LINE__ % v._v ); + DEBUG_PRINT(("%s (%s:%d) | v = %d\n.") , __FUNCTION__ , __FILE__ , __LINE__ , v._v ); return mk_size( tmp ); } @@ -1367,7 +1367,7 @@ core::T_sp PERCENTmem_set_ssize( core::Integer_sp address, core::T_sp value ) ssize_t tmp; translate::from_object< ssize_t > v( value ); tmp = mem_set< ssize_t >( core::clasp_to_uintptr_t( address ), v._v ); - DEBUG_PRINT(BF("%s (%s:%d) | v = %d\n.") % __FUNCTION__ % __FILE__ % __LINE__ % v._v ); + DEBUG_PRINT(("%s (%s:%d) | v = %d\n.") , __FUNCTION__ , __FILE__ , __LINE__ , v._v ); return mk_ssize( tmp ); } @@ -1376,7 +1376,7 @@ core::T_sp PERCENTmem_set_ptrdiff( core::Integer_sp address, core::T_sp value ) ptrdiff_t tmp; translate::from_object< ptrdiff_t > v( value ); tmp = mem_set< ptrdiff_t >( core::clasp_to_uintptr_t( address ), v._v ); - DEBUG_PRINT(BF("%s (%s:%d) | v = %d\n.") % __FUNCTION__ % __FILE__ % __LINE__ % v._v ); + DEBUG_PRINT(("%s (%s:%d) | v = %d\n.") , __FUNCTION__ , __FILE__ , __LINE__ , v._v ); return mk_ptrdiff( tmp ); } @@ -1385,7 +1385,7 @@ core::T_sp PERCENTmem_set_char( core::Integer_sp address, core::T_sp value ) int8_t tmp; translate::from_object< int8_t > v( value ); tmp = mem_set< int8_t >( core::clasp_to_uintptr_t( address ), v._v ); - DEBUG_PRINT(BF("%s (%s:%d) | v = %d\n.") % __FUNCTION__ % __FILE__ % __LINE__ % v._v ); + DEBUG_PRINT(("%s (%s:%d) | v = %d\n.") , __FUNCTION__ , __FILE__ , __LINE__ , v._v ); return mk_fixnum_int8( tmp ); } @@ -1394,7 +1394,7 @@ core::T_sp PERCENTmem_set_unsigned_char( core::Integer_sp address, core::T_sp va uint8_t tmp; translate::from_object< uint8_t > v( value ); tmp = mem_set< uint8_t >( core::clasp_to_uintptr_t( address ), v._v ); - DEBUG_PRINT(BF("%s (%s:%d) | v = %d\n.") % __FUNCTION__ % __FILE__ % __LINE__ % v._v ); + DEBUG_PRINT(("%s (%s:%d) | v = %d\n.") , __FUNCTION__ , __FILE__ , __LINE__ , v._v ); return mk_fixnum_uint8( tmp ); } diff --git a/src/core/float_to_digits.cc b/src/core/float_to_digits.cc index 0d206590ce..83eb558d89 100644 --- a/src/core/float_to_digits.cc +++ b/src/core/float_to_digits.cc @@ -94,7 +94,6 @@ static float_approx *setup(Float_sp number, float_approx *approx) { } approx->low_ok = approx->high_ok = clasp_evenp(f); if (e > 0) { - Fixnum_sp zz(make_fixnum(1)); Real_sp be = EXPT_RADIX(e); if (limit_f) { Real_sp be1 = gc::As(clasp_times(be, clasp_make_fixnum(FLT_RADIX))); @@ -192,9 +191,7 @@ static void change_precision(float_approx *approx, T_sp tposition, T_sp relativep) { if (tposition.nilp()) return; - gctools::Fixnum pos; Fixnum_sp position = gc::As(tposition); - pos = position.unsafe_fixnum(); if (!relativep.nilp()) { Real_sp k = clasp_make_fixnum(0); Real_sp l = clasp_make_fixnum(1); @@ -207,7 +204,6 @@ change_precision(float_approx *approx, T_sp tposition, T_sp relativep) { { Real_sp e1 = gc::As(cl__expt(PRINT_BASE, position)); Real_sp e2 = gc::As(clasp_divide(e1, clasp_make_fixnum(2))); - Real_sp e3 = gc::As(cl__expt(PRINT_BASE, k)); if (clasp_greatereq(clasp_plus(approx->r, clasp_times(approx->s, e1)), clasp_times(approx->s, e2))) position = gc::As(clasp_one_minus(position)); diff --git a/src/core/float_to_string.cc b/src/core/float_to_string.cc index 5959962911..a6a8742a1f 100644 --- a/src/core/float_to_string.cc +++ b/src/core/float_to_string.cc @@ -82,7 +82,7 @@ print_float_exponent(T_sp buffer, T_sp number, gc::Fixnum exp) { break; #endif default: - SIMPLE_ERROR(("Handle additional enumeration values value=%s t_of=%d") , _rep_(number).c_str() , clasp_t_of(gc::As(number))); + TYPE_ERROR(number, cl::_sym_float); } if (e != 'e' || exp != 0) { StrNs_sp sbuffer = gc::As(buffer); diff --git a/src/core/foundation.cc b/src/core/foundation.cc index b11ac1973b..ee8d8109cd 100644 --- a/src/core/foundation.cc +++ b/src/core/foundation.cc @@ -95,7 +95,6 @@ void dump_class_ids() { printf("The global_registered_ids_ptr is NULL\n"); return; } - char buffer[1024]; for (auto it : (*global_registered_ids_ptr)) { const char *fnName = it.first.name(); size_t length; @@ -580,7 +579,7 @@ bool lispify_match(const char *&cur, const char *match, NextCharTest nextCharTes } return false; } - SIMPLE_ERROR(("Unknown nextCharTest(%d)"), nextCharTest); + SIMPLE_ERROR(("Internal error: Unknown nextCharTest")); } string lispify_symbol_name(const string &s) { @@ -879,7 +878,6 @@ List_sp lisp_lexical_variable_names(List_sp lambda_list, bool &trivial_wrapper) RestArgument restarg; T_sp key_flag; T_sp allow_other_keys; - T_sp decl_dict = nil(); parse_lambda_list(lambda_list, cl::_sym_function, reqs, optionals, restarg, key_flag, keys, allow_other_keys, auxs); // // trivial_wrapper is true if only required arguments are in lambda_list @@ -1258,7 +1256,6 @@ T_sp lisp_createFixnum(int fn) { return make_fixnum(fn); } SourcePosInfo_sp lisp_createSourcePosInfo(const string &fileName, size_t filePos, int lineno) { SimpleBaseString_sp fn = SimpleBaseString_O::make(fileName); T_mv sfi_mv = core__file_scope(fn); - FileScope_sp sfi = gc::As(sfi_mv); MultipleValues &mvn = core::lisp_multipleValues(); Fixnum_sp handle = gc::As(mvn.valueGet(1, sfi_mv.number_of_values())); int sfindex = unbox_fixnum(handle); @@ -1285,9 +1282,9 @@ T_sp lisp_createList(T_sp a1, T_sp a2, T_sp a3, T_sp a4, T_sp a5, T_sp a6, T_sp [[noreturn]] void lisp_error_no_stamp(void *ptr) { gctools::Header_s *header = reinterpret_cast(gctools::GeneralPtrToHeaderPtr(ptr)); - SIMPLE_ERROR(("This General_O object %p does not return a stamp because its subclass should overload get_stamp_() and return one " + SIMPLE_ERROR(("BUG: This General_O object %p does not return a stamp because its subclass should overload get_stamp_() and return one " " - the subclass header stamp value is %lu"), - ((void *)ptr), header->_badge_stamp_wtag_mtag.stamp_()); + ((void *)ptr), (unsigned long)(header->_badge_stamp_wtag_mtag.stamp_())); } void lisp_errorCannotAllocateInstanceWithMissingDefaultConstructor(T_sp aclass_symbol) { diff --git a/src/core/funcallableInstance.cc b/src/core/funcallableInstance.cc index 3ce575b094..715fd85ac8 100644 --- a/src/core/funcallableInstance.cc +++ b/src/core/funcallableInstance.cc @@ -300,7 +300,7 @@ template <> struct ReadArg<2> { unsigned char high = *(addr + 1 + 2 * (offset - 1) + 1); size_t val = (high << 8) + low; // printf("%s:%d:%s read low %u high %u val = %lu\n", __FILE__, __LINE__, __FUNCTION__, low, high, val ); - return (high << 8) + low; + return val; } inline static T_sp read_literal(unsigned char *addr, uintptr_t offset, T_sp *literals) { size_t index = read(addr, offset); @@ -382,11 +382,14 @@ struct GFBytecodeEntryPoint { #define MAYBE_LONG_MUL 1 #define MAYBE_LONG_ADD 0 #include "src/core/dtree-interpreter.cc" +#undef MAYBE_LONG_ADD #undef MAYBE_LONG_MUL #define MAYBE_LONG_MUL 2 #define MAYBE_LONG_ADD DTREE_OP_COUNT #include "src/core/dtree-interpreter.cc" +#undef MAYBE_LONG_ADD #undef MAYBE_LONG_MUL +#undef ENABLE_REGISTER default: printf("%s:%d:%s Invalid dtree opcode ip0: %p ip: %p opcode %u %s\n", __FILE__, __LINE__, __FUNCTION__, ip0, ip, op, dtree_op_name(op).c_str()); @@ -401,6 +404,7 @@ struct GFBytecodeEntryPoint { Function_sp generic_function = gfep->_GenericFunction; return core::eval::funcall(clos::_sym_dispatch_miss_va, generic_function, error_args); } + /* TODO SINGLE_DISPATCH_MISS : { DTILOG("dispatch miss. arg %lu stamp %lu\n", arg, stamp); Vaslist vaslist(lcc_nargs, lcc_args); @@ -408,6 +412,7 @@ struct GFBytecodeEntryPoint { Function_sp generic_function = gfep->_GenericFunction; return core::eval::funcall(clos::_sym_single_dispatch_miss_va, generic_function, error_args); } +*/ } #undef GENERAL_ARITY_CALL @@ -445,10 +450,12 @@ struct GFBytecodeEntryPoint { #define MAYBE_LONG_MUL 1 #define MAYBE_LONG_ADD 0 #include "src/core/dtree-interpreter.cc" +#undef MAYBE_LONG_ADD #undef MAYBE_LONG_MUL #define MAYBE_LONG_MUL 2 #define MAYBE_LONG_ADD DTREE_OP_COUNT #include "src/core/dtree-interpreter.cc" +#undef MAYBE_LONG_ADD #undef MAYBE_LONG_MUL #undef GENERAL_ARITY_CALL #undef ENABLE_REGISTER @@ -466,6 +473,7 @@ struct GFBytecodeEntryPoint { Function_sp generic_function = gfep->_GenericFunction; return core::eval::funcall(clos::_sym_dispatch_miss_va, generic_function, error_args); } + /* SINGLE_DISPATCH_MISS : { core::T_O *args[1] = {lcc_farg0}; Vaslist vaslist(1, args); @@ -473,6 +481,7 @@ struct GFBytecodeEntryPoint { Function_sp generic_function = gfep->_GenericFunction; return core::eval::funcall(clos::_sym_single_dispatch_miss_va, generic_function, error_args); } +*/ } static inline LCC_RETURN error_entry_point_2(core::T_O *lcc_closure, core::T_O *lcc_farg0, core::T_O *lcc_farg1) { @@ -502,10 +511,12 @@ struct GFBytecodeEntryPoint { #define MAYBE_LONG_MUL 1 #define MAYBE_LONG_ADD 0 #include "src/core/dtree-interpreter.cc" +#undef MAYBE_LONG_ADD #undef MAYBE_LONG_MUL #define MAYBE_LONG_MUL 2 #define MAYBE_LONG_ADD DTREE_OP_COUNT #include "src/core/dtree-interpreter.cc" +#undef MAYBE_LONG_ADD #undef MAYBE_LONG_MUL #undef GENERAL_ARITY_CALL #undef ENABLE_REGISTER @@ -523,6 +534,7 @@ struct GFBytecodeEntryPoint { Function_sp generic_function = gfep->_GenericFunction; return core::eval::funcall(clos::_sym_dispatch_miss_va, generic_function, error_args); } + /* SINGLE_DISPATCH_MISS : { core::T_O *args[2] = {lcc_farg0, lcc_farg1}; Vaslist vaslist(2, args); @@ -530,6 +542,7 @@ struct GFBytecodeEntryPoint { Function_sp generic_function = gfep->_GenericFunction; return core::eval::funcall(clos::_sym_single_dispatch_miss_va, generic_function, error_args); } +*/ } static inline LCC_RETURN error_entry_point_3(core::T_O *lcc_closure, core::T_O *lcc_farg0, core::T_O *lcc_farg1, @@ -560,10 +573,12 @@ struct GFBytecodeEntryPoint { #define MAYBE_LONG_MUL 1 #define MAYBE_LONG_ADD 0 #include "src/core/dtree-interpreter.cc" +#undef MAYBE_LONG_ADD #undef MAYBE_LONG_MUL #define MAYBE_LONG_MUL 2 #define MAYBE_LONG_ADD DTREE_OP_COUNT #include "src/core/dtree-interpreter.cc" +#undef MAYBE_LONG_ADD #undef MAYBE_LONG_MUL #undef GENERAL_ARITY_CALL #undef ENABLE_REGISTER @@ -581,6 +596,7 @@ struct GFBytecodeEntryPoint { Function_sp generic_function = gfep->_GenericFunction; return core::eval::funcall(clos::_sym_dispatch_miss_va, generic_function, error_args); } + /* SINGLE_DISPATCH_MISS : { core::T_O *args[3] = {lcc_farg0, lcc_farg1, lcc_farg2}; Vaslist vaslist(3, args); @@ -588,6 +604,7 @@ struct GFBytecodeEntryPoint { Function_sp generic_function = gfep->_GenericFunction; return core::eval::funcall(clos::_sym_single_dispatch_miss_va, generic_function, error_args); } +*/ } static inline LCC_RETURN error_entry_point_4(core::T_O *lcc_closure, core::T_O *lcc_farg0, core::T_O *lcc_farg1, @@ -618,10 +635,12 @@ struct GFBytecodeEntryPoint { #define MAYBE_LONG_MUL 1 #define MAYBE_LONG_ADD 0 #include "src/core/dtree-interpreter.cc" +#undef MAYBE_LONG_ADD #undef MAYBE_LONG_MUL #define MAYBE_LONG_MUL 2 #define MAYBE_LONG_ADD DTREE_OP_COUNT #include "src/core/dtree-interpreter.cc" +#undef MAYBE_LONG_ADD #undef MAYBE_LONG_MUL #undef GENERAL_ARITY_CALL #undef ENABLE_REGISTER @@ -639,6 +658,7 @@ struct GFBytecodeEntryPoint { Function_sp generic_function = gfep->_GenericFunction; return core::eval::funcall(clos::_sym_dispatch_miss_va, generic_function, error_args); } + /* SINGLE_DISPATCH_MISS : { core::T_O *args[4] = {lcc_farg0, lcc_farg1, lcc_farg2, lcc_farg3}; Vaslist vaslist(4, args); @@ -646,6 +666,7 @@ struct GFBytecodeEntryPoint { Function_sp generic_function = gfep->_GenericFunction; return core::eval::funcall(clos::_sym_single_dispatch_miss_va, generic_function, error_args); } +*/ } static inline LCC_RETURN error_entry_point_5(core::T_O *lcc_closure, core::T_O *lcc_farg0, core::T_O *lcc_farg1, @@ -676,10 +697,12 @@ struct GFBytecodeEntryPoint { #define MAYBE_LONG_MUL 1 #define MAYBE_LONG_ADD 0 #include "src/core/dtree-interpreter.cc" +#undef MAYBE_LONG_ADD #undef MAYBE_LONG_MUL #define MAYBE_LONG_MUL 2 #define MAYBE_LONG_ADD DTREE_OP_COUNT #include "src/core/dtree-interpreter.cc" +#undef MAYBE_LONG_ADD #undef MAYBE_LONG_MUL #undef GENERAL_ARITY_CALL #undef ENABLE_REGISTER @@ -697,6 +720,7 @@ struct GFBytecodeEntryPoint { Function_sp generic_function = gfep->_GenericFunction; return core::eval::funcall(clos::_sym_dispatch_miss_va, generic_function, error_args); } + /* SINGLE_DISPATCH_MISS : { core::T_O *args[5] = {lcc_farg0, lcc_farg1, lcc_farg2, lcc_farg3, lcc_farg4}; Vaslist vaslist(5, args); @@ -704,6 +728,7 @@ struct GFBytecodeEntryPoint { Function_sp generic_function = gfep->_GenericFunction; return core::eval::funcall(clos::_sym_single_dispatch_miss_va, generic_function, error_args); } +*/ } }; @@ -721,7 +746,6 @@ GFBytecodeSimpleFun_sp GFBytecodeSimpleFun_O::make(Function_sp generic_function) T_mv compiled = eval::funcall(clos::_sym_bytecode_dtree_compile, generic_function); SimpleVector_byte8_t_sp bytecode = gc::As(compiled); MultipleValues &mv = my_thread->_MultipleValues; - SimpleVector_sp entryPoints = mv.second(compiled.number_of_values()); SimpleVector_sp literals = mv.third(compiled.number_of_values()); size_t specialized_length = mv.fourth(compiled.number_of_values()).unsafe_fixnum(); auto obj = gctools::GC::allocate(fdesc, 0, bytecode, literals, generic_function, specialized_length); diff --git a/src/core/function.cc b/src/core/function.cc index 025e898d83..2191b3d71b 100644 --- a/src/core/function.cc +++ b/src/core/function.cc @@ -469,7 +469,6 @@ GlobalBytecodeSimpleFun_sp core__makeGlobalBytecodeSimpleFun(FunctionDescription size_t pcIndex, Pointer_sp trampoline ) { - size_t idx = 0; ClaspXepFunction xep; xep.setup(); auto entryPoint = gctools::GC::allocate( fdesc, diff --git a/src/core/hashTable.cc b/src/core/hashTable.cc index 7751ff5632..2e02423e63 100644 --- a/src/core/hashTable.cc +++ b/src/core/hashTable.cc @@ -790,7 +790,6 @@ T_mv HashTable_O::gethash(T_sp key, T_sp default_value) { HT_READ_LOCK(this); VERIFY_HASH_TABLE(this); HashGenerator hg; - size_t sz = this->_Table.size(); cl_index index = this->sxhashKey(key, this->_Table.size(), hg ); KeyValuePair* keyValuePair = this->tableRef_no_read_lock(key, false /*under_write_lock*/, index, hg); LOG("Found keyValueCons"); // % keyValueCons->__repr__() ); INFINITE-LOOP @@ -937,7 +936,9 @@ KeyValuePair* HashTable_O::rehash_no_lock(bool expandTable, T_sp findKey) { } gc::Vec0 oldTable; oldTable.swap(this->_Table); +#if DEBUG_REHASH_COUNT size_t oldHashTableCount = this->_HashTableCount; +#endif newSize = this->resizeEmptyTable_no_lock(newSize); LOG("Resizing table to size: %d" , newSize); size_t oldSize = oldTable.size(); @@ -965,13 +966,13 @@ KeyValuePair* HashTable_O::rehash_no_lock(bool expandTable, T_sp findKey) { } #ifdef DEBUG_REHASH_COUNT this->_RehashCount++; - MONITOR(BF("Hash-table rehash id %lu initial-size %lu rehash-number %lu rehash-size %lu oldHashTableCount %lu _HashTableCount %lu\n") - % this->_HashTableId - % this->_InitialSize - % this->_RehashCount - % newSize - % oldHashTableCount - % this->_HashTableCount); + MONITOR(fmt::sprintf("Hash-table rehash id %lu initial-size %lu rehash-number %lu rehash-size %lu oldHashTableCount %lu _HashTableCount %lu\n" + , this->_HashTableId + , this->_InitialSize + , this->_RehashCount + , newSize + , oldHashTableCount + , this->_HashTableCount)); #endif VERIFY_HASH_TABLE(this); // @@ -1002,11 +1003,7 @@ KeyValuePair* HashTable_O::rehash_upgrade_write_lock(bool expandTable, T_sp find this->_Mutex->write_unlock( false /*releaseReadLock*/); return result; } -#ifdef _TARGET_OS_DARWIN - pthread_yield_np(); -#else - pthread_yield(); -#endif + sched_yield(); goto tryAgain; } else { return this->rehash_no_lock(expandTable,findKey); @@ -1141,7 +1138,7 @@ void HashTable_O::hash_table_early_dump() { string HashTable_O::keysAsString() { stringstream ss; - this->mapHash([&ss, this](T_sp key, T_sp val) { + this->mapHash([&ss](T_sp key, T_sp val) { ss << _rep_(key) << " "; }); return ss.str(); diff --git a/src/core/instance.cc b/src/core/instance.cc index c3ad73760f..d7894a589b 100644 --- a/src/core/instance.cc +++ b/src/core/instance.cc @@ -114,11 +114,7 @@ CL_DEFUN T_sp core__cas_rack(T_sp order, T_sp old, T_sp newval, Rack_sp rack, si if (order != kw::_sym_SequentiallyConsistent) { SIMPLE_ERROR("Add support for order %s", _rep_(order).c_str()); } - bool result = rack->low_level_rack_compare_exchange_strong(index, old, newval); -#if 0 - printf("%s:%d:%s order = %s old = %p newval = %p rack = %p index = %zu result = %d\n", - __FILE__, __LINE__, __FUNCTION__, _rep_(order).c_str(), old.raw_(), newval.raw_(), rack.raw_(), index, result ); -#endif + rack->low_level_rack_compare_exchange_strong(index, old, newval); return old; } diff --git a/src/core/lambdaListHandler.cc b/src/core/lambdaListHandler.cc index 5a80a646d2..909c283680 100644 --- a/src/core/lambdaListHandler.cc +++ b/src/core/lambdaListHandler.cc @@ -403,6 +403,7 @@ bool switch_add_argument_mode(T_sp context, T_sp symbol, ArgumentMode &mode, T_s switch (mode) { case keyword: key_flag = _lisp->_true(); + [[fallthrough]]; case allowOtherKeys: if (context == cl::_sym_define_modify_macro) goto ILLEGAL_MODE; @@ -718,7 +719,6 @@ CL_DEFUN T_mv core__process_lambda_list(List_sp lambdaList, T_sp context) { RestArgument restarg; T_sp key_flag; T_sp allow_other_keys; - T_sp decl_dict = nil(); parse_lambda_list(lambdaList, context, reqs, diff --git a/src/core/lisp.cc b/src/core/lisp.cc index 5f9af62137..66702e0b7f 100644 --- a/src/core/lisp.cc +++ b/src/core/lisp.cc @@ -196,9 +196,9 @@ struct FindApropos : public KeyValueMapper //, public gctools::StackRoot // Lisp::GCRoots::GCRoots() : _ClaspJIT(nil()), + _AllLibraries(nil()), _AllObjectFiles(nil()), _AllCodeBlocks(nil()), - _AllLibraries(nil()), #ifdef CLASP_THREADS _UnboundSymbolFunctionEntryPoint(unbound()), _UnboundSetfSymbolFunctionEntryPoint(unbound()), @@ -215,11 +215,11 @@ Lisp::GCRoots::GCRoots() : this->_SingleDispatchGenericFunctions.store(nil()); }; -Lisp::Lisp() : _Booted(false), - _MpiEnabled(false), - _MpiRank(0), - _MpiSize(1), - _BootClassTableIsValid(true) { +Lisp::Lisp() : _BootClassTableIsValid(true), + _Booted(false), + _MpiEnabled(false), + _MpiRank(0), + _MpiSize(1) { // this->_Roots._Bindings.reserve(1024); // moved to Lisp::initialize() } @@ -236,10 +236,6 @@ void Lisp::shutdownLispEnvironment() { // my_thread->destroy_sigaltstack(); } -void Lisp::lisp_initSymbols(LispPtr lisp) { - Package_sp corePackage = lisp->_Roots._CorePackage; -} - /*! Allocations go here */ void Lisp::initialize() { @@ -427,7 +423,7 @@ void Lisp::startupLispEnvironment() { printf("%s:%d There are DEBUG_xxxx flags on - check the top of configure_clasp.h !!!!\n", __FILE__, __LINE__ ); #endif - MONITOR(BF("Starting lisp environment\n")); + MONITOR(("Starting lisp environment\n")); global_dump_functions = getenv("CLASP_DUMP_FUNCTIONS"); char* debug_start_code = getenv("CLASP_DEBUG_START_CODE"); if (debug_start_code) { @@ -1306,7 +1302,6 @@ T_mv Lisp::readEvalPrint(T_sp stream, T_sp environ, bool printResults, bool prom if (printResults) { for (int i(0); i < vresults.size(); i++) { T_sp obj = vresults[i]; - // this->print(BF("; --> %s\n")% _rep_(obj)); eval::funcall(cl::_sym_print, obj); } } @@ -1846,7 +1841,6 @@ void searchForApropos(List_sp packages, SimpleString_sp insubstring, bool print_ ss << cl__class_of(cl__symbol_function((sym)))->_classNameAsString(); T_sp tfn = cl__symbol_function(sym); if ( !tfn.unboundp() && gc::IsA(tfn)) { - Function_sp fn = gc::As_unsafe(tfn); if (sym->macroP()) ss << "(MACRO)"; } } @@ -2043,8 +2037,11 @@ DOCGROUP(clasp); NEVER_OPTIMIZE CL_DEFUN void cl__error(T_sp datum, List_sp initializers) { // These are volatile in an effort to make them available to debuggers. + // How well that actually works is not clear. volatile T_sp saved_datum = datum; volatile List_sp saved_initializers = initializers; + (void)saved_datum; + (void)saved_initializers; T_sp objErrorDepth = _sym_STARnestedErrorDepthSTAR->symbolValue(); int nestedErrorDepth; /* *nested-error-depth* should be a fixnum, but if it's not we can't signal @@ -2194,12 +2191,10 @@ void Lisp::parseStringIntoPackageAndSymbolName(const string &name, bool &package packageDefined = false; return; } - bool doubleColon = false; size_t secondPart = colonPos + 1; if (name[secondPart] == ':') { LOG("It's a non-exported symbol"); exported = false; - doubleColon = true; secondPart++; if (name.find_first_of(":", secondPart) != string::npos) { SIMPLE_ERROR(("There can only be one ':' or '::' in a symbol name")); @@ -2214,7 +2209,6 @@ void Lisp::parseStringIntoPackageAndSymbolName(const string &name, bool &package Symbol_mv Lisp::intern(const string &name, T_sp optionalPackageDesignator) { Package_sp package; string symbolName; - bool exported, packageDefined; symbolName = name; package = coerce::packageDesignator(optionalPackageDesignator); ASSERTNOTNULL(package); @@ -2355,7 +2349,6 @@ bool Lisp::load(int &exitCode) { int Lisp::run() { int exitCode; - MultipleValues &mvn = core::lisp_multipleValues(); try { if (ext::_sym_STARtoplevel_hookSTAR->symbolValue().notnilp()) { core::T_sp fn = ext::_sym_STARtoplevel_hookSTAR->symbolValue(); diff --git a/src/core/lispReader.cc b/src/core/lispReader.cc index 81ae8b761b..a66ab7a13c 100644 --- a/src/core/lispReader.cc +++ b/src/core/lispReader.cc @@ -58,10 +58,10 @@ THE SOFTWARE. #if 0 FILE* fDebug = NULL; #define LOG_READ_SETUP() if (!fDebug) {fDebug = fopen("/tmp/read.log","w");} -#define LOG_READ(fmt) fprintf(fDebug,"%s:%d ", __FILE__, __LINE__); fprintf(fDebug,"%s\n", (fmt).str().c_str()); fflush(fDebug); +#define LOG_READ(...) fmt::fprintf(fDebug,"%s:%d:%s ", __FILE__, __LINE__, __FUNCTION__); fmt::fprintf(fDebug, __VA_ARGS__); fflush(fDebug); #else #define LOG_READ_SETUP() -#define LOG_READ(fmt) +#define LOG_READ(...) #endif namespace core { // Store characters and flags about the characters @@ -109,7 +109,7 @@ struct Token { #define TRAP_BAD_CONS(x) \ { \ if ((x).consp()) { \ - LOG_READ(BF("About to try trap bad cons")); \ + LOG_READ(("About to try trap bad cons")); \ string ssss = core__file_scope(x)->fileName(); \ } \ } @@ -545,7 +545,6 @@ void apply_readtable_case(Token& token, size_t start, size_t end) { SimpleString_sp symbolTokenStr(T_sp stream, Token &token, size_t start, size_t end, bool only_dots_ok=false) { - bool extended = false; SafeBufferStrWNs buffer; apply_readtable_case(token,start,end); bool only_dots = true; @@ -572,7 +571,6 @@ SimpleString_sp symbolTokenStr(T_sp stream, Token &token, size_t start, size_t e } SimpleString_sp tokenStr(T_sp stream, const Token &token, size_t start = 0, size_t end = UNDEF_UINT, bool only_dots_ok=false) { - bool extended = false; if (end==UNDEF_UINT) end = token.size(); SafeBufferStrWNs buffer; bool only_dots = true; @@ -596,7 +594,7 @@ SimpleString_sp tokenStr(T_sp stream, const Token &token, size_t start = 0, size } T_sp interpret_token_or_throw_reader_error(T_sp sin, Token &token, bool only_dots_ok) { - LOG_READ(BF("About to interpret_token_or_throw_reader_error")); + LOG_READ(("About to interpret_token_or_throw_reader_error")); ASSERTF(token.size() > 0, ("The token is empty!")); const trait_chr_type *start = token.data(); const trait_chr_type *cur = start; @@ -728,7 +726,7 @@ T_sp interpret_token_or_throw_reader_error(T_sp sin, Token &token, bool only_dot case tsymbad: ELSE(tsymbad); default: - SIMPLE_ERROR(("unhandled state[%d] for token assignment") , state); + SIMPLE_ERROR(("BUG: unhandled state[%d] for token assignment") , (int)state); } NEXT: ++cur; @@ -743,7 +741,7 @@ T_sp interpret_token_or_throw_reader_error(T_sp sin, Token &token, bool only_dot } SIMPLE_ERROR(("There was no token!!!!")); case tsymdot: - LOG_READ(BF("Returning sym_dot")); + LOG_READ(("Returning sym_dot")); return _sym_dot; case tsyms: case tsymf: @@ -756,7 +754,7 @@ T_sp interpret_token_or_throw_reader_error(T_sp sin, Token &token, bool only_dot if (cl::_sym_STARread_suppressSTAR->symbolValue().isTrue()) return nil(); SimpleString_sp sym_name = symbolTokenStr(sin,token, name_marker - token.data(),token.size(),only_dots_ok); Symbol_sp sym = _lisp->getCurrentPackage()->intern(sym_name); - LOG_READ(BF("sym_name = |%s| sym->symbolNameAsString() = |%s|") % sym_name->get_std_string() % sym->symbolNameAsString()); + LOG_READ(("sym_name = |%s| sym->symbolNameAsString() = |%s|") , sym_name->get_std_string() , sym->symbolNameAsString()); return sym; } break; @@ -780,7 +778,7 @@ T_sp interpret_token_or_throw_reader_error(T_sp sin, Token &token, bool only_dot } // TODO Handle proper string names SimpleString_sp symbol_name_str = symbolTokenStr(sin,token, name_marker - token.data(),token.size(),only_dots_ok); - LOG_READ(BF("Interpreting token as packageName[%s] and symbol-name[%s]") % _rep_(packageSin.string()) % symbol_name_str->get_std_string()); + LOG_READ(("Interpreting token as packageName[%s] and symbol-name[%s]") , _rep_(packageSin.string()) , symbol_name_str->get_std_string()); // TODO Deal with proper string package names string packageName = packageSin.string()->get_std_string(); Package_sp pkg = gc::As(_lisp->findPackage(packageName, true)); @@ -804,7 +802,6 @@ T_sp interpret_token_or_throw_reader_error(T_sp sin, Token &token, bool only_dot if (cl::_sym_STARread_suppressSTAR->symbolValue().isTrue()) return nil(); // interpret good keywords - LOG_READ(BF("Token[%s] interpreted as keyword") % name_marker); // :\. is a valid keyword symbol, so allow only dots here SimpleString_sp keyword_name = symbolTokenStr(sin,token, name_marker - token.data(),token.size(),true); return _lisp->keywordPackage()->intern(keyword_name); @@ -812,7 +809,7 @@ T_sp interpret_token_or_throw_reader_error(T_sp sin, Token &token, bool only_dot case tsymk:{ if (cl::_sym_STARread_suppressSTAR->symbolValue().isTrue()) return nil(); // interpret :|| keyword - LOG_READ(BF("Token[:||] interpreted as keyword")); + LOG_READ(("Token[:||] interpreted as keyword")); SimpleBaseString_sp keyword_name = SimpleBaseString_O::make(""); // tokenStr(sin,token, name_marker - token.data()); return _lisp->keywordPackage()->intern(keyword_name); } break; @@ -929,7 +926,7 @@ T_sp interpret_token_or_throw_reader_error(T_sp sin, Token &token, bool only_dot SIMPLE_ERROR(("Shouldn't get here - unhandled exponent type")); } } - LOG_READ(BF("Bad state %d") % state); + LOG_READ(("Bad state %d") , state); SIMPLE_ERROR(("create(sin));")); } @@ -962,7 +959,7 @@ List_sp read_list(T_sp sin, claspCharacter end_char, bool allow_consing_dot) { List_sp cur = first; while (1) { Character_sp cp = gc::As(cl__peek_char(_lisp->_true(), sin, _lisp->_true(), nil(), _lisp->_true())); - LOG_READ(BF("read_list ---> peeked char[%s]") % _rep_(cp)); + LOG_READ(("read_list ---> peeked char[%s]") , _rep_(cp)); if (clasp_as_claspCharacter(cp) == end_char) { cl__read_char(sin, _lisp->_true(), nil(), _lisp->_true()); if (dotted_object.notnilp()) { @@ -985,7 +982,7 @@ List_sp read_list(T_sp sin, claspCharacter end_char, bool allow_consing_dot) { ivalues = mv.number_of_values(); if (ivalues > 0) { obj = mv; - LOG_READ(BF("lisp_object_query: %s") % _rep_(obj)); + LOG_READ(("lisp_object_query: %s") , _rep_(obj)); // Could get ending lineNumber and column here if (obj == _sym_dot) { if (allow_consing_dot) { @@ -1006,10 +1003,7 @@ List_sp read_list(T_sp sin, claspCharacter end_char, bool allow_consing_dot) { nil(), sin); } Cons_sp one = Cons_O::create(obj, nil()); - LOG_READ(BF("One = %s") % _rep_(one)); -// LOG_READ(BF("one->sourceFileInfo()=%s") % _rep_(core__file_scope(one))); -// LOG_READ(BF("one->sourceFileInfo()->fileName()=%s") % core__file_scope(one)->fileName()); -// LOG_READ(BF("one->sourceFileInfo()->fileName().c_str() = %s") % core__file_scope(one)->fileName().c_str()); + LOG_READ(("One = %s") , _rep_(one)); TRAP_BAD_CONS(one); cur.asCons()->setCdr(one); cur = one; @@ -1022,11 +1016,11 @@ SYMBOL_SC_(CorePkg, STARsharp_equal_final_tableSTAR); T_sp read_lisp_object(T_sp sin, bool eofErrorP, T_sp eofValue, bool recursiveP) { LOG_READ_SETUP(); - LOG_READ(BF("Entered read_lisp_object recursiveP=%d") % recursiveP); + LOG_READ(("Entered read_lisp_object recursiveP=%d") , recursiveP); T_sp result = nil(); if (recursiveP) { while (1) { - LOG_READ(BF("At top of while loop")); + LOG_READ(("At top of while loop")); T_mv mv = lisp_object_query(sin, eofErrorP, eofValue, recursiveP); int ivalues = mv.number_of_values(); if (ivalues > 0) { @@ -1036,7 +1030,7 @@ T_sp read_lisp_object(T_sp sin, bool eofErrorP, T_sp eofValue, bool recursiveP) nil(), sin); } if (cl::_sym_STARread_suppressSTAR->symbolValue().isTrue()) { - LOG_READ(BF("read_suppress == true")); + LOG_READ(("read_suppress == true")); result = nil(); } break; @@ -1044,11 +1038,11 @@ T_sp read_lisp_object(T_sp sin, bool eofErrorP, T_sp eofValue, bool recursiveP) } } else { DynamicScopeManager scope(_sym_STARsharp_equal_final_tableSTAR, nil()); - LOG_READ(BF("About to call read_lisp_object")); + LOG_READ(("About to call read_lisp_object")); result = read_lisp_object(sin, eofErrorP, eofValue, true); - LOG_READ(BF("Came out of read_lisp_object with: |%s|") % _rep_(result).c_str()); + LOG_READ(("Came out of read_lisp_object with: |%s|") , _rep_(result).c_str()); } - LOG_READ(BF("Returning from read_lisp_object")); + LOG_READ(("Returning from read_lisp_object")); return (result); } @@ -1071,7 +1065,7 @@ T_mv lisp_object_query(T_sp sin, bool eofErrorP, T_sp eofValue, bool recursiveP) Character_sp xxx, y, z, X, Y, Z; /* See the CLHS 2.2 Reader Algorithm - continue has the effect of jumping to step 1 */ step1: - LOG_READ(BF("step1")); + LOG_READ(("step1")); SourcePosInfo_sp xxxsp; T_sp tx = cl__read_char(sin, nil(), nil(), _lisp->_true()); if (tx.nilp()) { @@ -1080,22 +1074,22 @@ T_mv lisp_object_query(T_sp sin, bool eofErrorP, T_sp eofValue, bool recursiveP) return Values(eofValue); } xxx = gc::As(tx); - LOG_READ(BF("Read character x[%d/%s]") % (int)clasp_as_claspCharacter(xxx) % (char)clasp_as_claspCharacter(xxx)); + LOG_READ(("Read character x[%d/%c]") , (int)clasp_as_claspCharacter(xxx) , (char)clasp_as_claspCharacter(xxx)); Symbol_sp xxx_syntax_type = core__syntax_type(readTable,xxx); // step2: if (xxx_syntax_type == kw::_sym_invalid) { - LOG_READ(BF("step2 - invalid-character[%c]") % clasp_as_claspCharacter(xxx)); + LOG_READ(("step2 - invalid-character[%c]") , clasp_as_claspCharacter(xxx)); READER_ERROR(SimpleBaseString_O::make("A char with syntax type invalid was encountered by the reader."), nil(), sin); } // step3: if (xxx_syntax_type == kw::_sym_whitespace) { - LOG_READ(BF("step3 - whitespace character[%c/%d]") % clasp_as_claspCharacter(xxx) % clasp_as_claspCharacter(xxx)); + LOG_READ(("step3 - whitespace character[%c/%d]") , clasp_as_claspCharacter(xxx) , clasp_as_claspCharacter(xxx)); goto step1; } // step4: if ((xxx_syntax_type == kw::_sym_terminating_macro) || (xxx_syntax_type == kw::_sym_non_terminating_macro)) { - LOG_READ(BF("step4 - terminating-macro-character or non-terminating-macro-character char[%c]") % clasp_as_claspCharacter(xxx)); + LOG_READ(("step4 - terminating-macro-character or non-terminating-macro-character char[%c]") , clasp_as_claspCharacter(xxx)); T_sp reader_macro; reader_macro = cl__get_macro_character(xxx,readTable); ASSERT(reader_macro.notnilp()); @@ -1123,8 +1117,8 @@ T_mv lisp_object_query(T_sp sin, bool eofErrorP, T_sp eofValue, bool recursiveP) } // step5: if (xxx_syntax_type == kw::_sym_single_escape) { - LOG_READ(BF("step5 - single-escape-character char[%c]") % clasp_as_claspCharacter(xxx)); - LOG_READ(BF("Handling single escape")); + LOG_READ(("step5 - single-escape-character char[%c]") , clasp_as_claspCharacter(xxx)); + LOG_READ(("Handling single escape")); T_sp ty = cl__read_char(sin, _lisp->_true(), nil(), _lisp->_true()); if ( !ty.characterp() ) { SIMPLE_ERROR(("Expected character - hit end")); @@ -1132,13 +1126,13 @@ T_mv lisp_object_query(T_sp sin, bool eofErrorP, T_sp eofValue, bool recursiveP) y = gc::As(ty); token.clear(); token.push_back(constituentChar(y, TRAIT_ALPHABETIC)); - LOG_READ(BF("Read y[%d/%s]") % (int)clasp_as_claspCharacter(y) % clasp_as_claspCharacter(y)); + LOG_READ(("Read y[%d/%s]") , (int)clasp_as_claspCharacter(y) , clasp_as_claspCharacter(y)); goto step8; } // step6: if (xxx_syntax_type == kw::_sym_multiple_escape) { - LOG_READ(BF("step6 - multiple-escape-character char[%c]") % clasp_as_claspCharacter(xxx)); - LOG_READ(BF("Handling multiple escape - clearing token")); + LOG_READ(("step6 - multiple-escape-character char[%c]") , clasp_as_claspCharacter(xxx)); + LOG_READ(("Handling multiple escape - clearing token")); token.clear(); // |....| or ....|| or ..|.|.. is ok only_dots_ok = true; @@ -1146,35 +1140,35 @@ T_mv lisp_object_query(T_sp sin, bool eofErrorP, T_sp eofValue, bool recursiveP) } // step7: if ( xxx_syntax_type /*readTable->syntax_type(xxx)*/ == kw::_sym_constituent) { - LOG_READ(BF("step7 - Handling constituent-character char[%s]") % _rep_(xxx)); + LOG_READ(("step7 - Handling constituent-character char[%s]") , _rep_(xxx)); token.clear(); // X = readTable->convert_case(x); X = xxx; // convert case once the entire token is accumulated token.push_back(constituentChar(X)); } step8: - LOG_READ(BF("step8")); + LOG_READ(("step8")); { T_sp ty = cl__read_char(sin, nil(), nil(), _lisp->_true()); if (ty.nilp()) { - LOG_READ(BF("Hit eof")); + LOG_READ(("Hit eof")); goto step10; } Character_sp y(gc::As_unsafe(ty)); - LOG_READ(BF("Step8: Read y[%s/%c]") % clasp_as_claspCharacter(y) % (char)clasp_as_claspCharacter(y)); + LOG_READ(("Step8: Read y[%c]") , (char)clasp_as_claspCharacter(y)); Symbol_sp y8_syntax_type = core__syntax_type(readTable,y); - LOG_READ(BF("y8_syntax_type=%s") % _rep_(y8_syntax_type)); + LOG_READ(("y8_syntax_type=%s") , _rep_(y8_syntax_type)); if ((y8_syntax_type == kw::_sym_constituent) || (y8_syntax_type == kw::_sym_non_terminating_macro)) { // Y = readTable->convert_case(y); Y = y; // convert case once the entire token is accumulated - LOG_READ(BF(" Pushing back character %d") % constituentChar(Y)); + LOG_READ((" Pushing back character %d") , constituentChar(Y)); token.push_back(constituentChar(Y)); goto step8; } if (y8_syntax_type == kw::_sym_single_escape) { z = gc::As(cl__read_char(sin, _lisp->_true(), nil(), _lisp->_true())); token.push_back(constituentChar(z, TRAIT_ALPHABETIC|TRAIT_ESCAPED)); - LOG_READ(BF("Single escape read z[%s] accumulated token[%s]") % clasp_as_claspCharacter(z) % tokenStr(sin,token)); + LOG_READ(("Single escape read z[%s] accumulated token[%s]") , clasp_as_claspCharacter(z) , _rep_(tokenStr(sin,token))); goto step8; } if (y8_syntax_type == kw::_sym_multiple_escape) { @@ -1185,15 +1179,15 @@ T_mv lisp_object_query(T_sp sin, bool eofErrorP, T_sp eofValue, bool recursiveP) if (y8_syntax_type == kw::_sym_invalid) SIMPLE_ERROR(("ReaderError_O::create()")); if (y8_syntax_type == kw::_sym_terminating_macro) { - LOG_READ(BF("UNREADING char y[%s]") % clasp_as_claspCharacter(y)); + LOG_READ(("UNREADING char y[%d]") , clasp_as_claspCharacter(y)); clasp_unread_char(clasp_as_claspCharacter(y), sin); goto step10; } if (y8_syntax_type == kw::_sym_whitespace) { - LOG_READ(BF("y is whitespace")); + LOG_READ(("y is whitespace")); #if 0 if (_sym_STARpreserve_whitespace_pSTAR->symbolValue().isTrue()) { // Can this be recursiveP? - LOG_READ(BF("unreading y[%s]") % clasp_as_claspCharacter(y)); + LOG_READ(("unreading y[%s]") , clasp_as_claspCharacter(y)); clasp_unread_char(clasp_as_claspCharacter(y), sin); } #else @@ -1203,26 +1197,26 @@ T_mv lisp_object_query(T_sp sin, bool eofErrorP, T_sp eofValue, bool recursiveP) } } step9: - LOG_READ(BF("step9")); + LOG_READ(("step9")); { y = gc::As(cl__read_char(sin, _lisp->_true(), nil(), _lisp->_true())); Symbol_sp y9_syntax_type = core__syntax_type(readTable,y); - LOG_READ(BF("Step9: Read y[%s] y9_syntax_type[%s]") % clasp_as_claspCharacter(y) % _rep_(y9_syntax_type)); + LOG_READ(("Step9: Read y[%s] y9_syntax_type[%s]") , clasp_as_claspCharacter(y) , _rep_(y9_syntax_type)); if ((y9_syntax_type == kw::_sym_constituent) || (y9_syntax_type == kw::_sym_non_terminating_macro) || (y9_syntax_type == kw::_sym_terminating_macro) || (y9_syntax_type == kw::_sym_whitespace)) { token.push_back(constituentChar(y, TRAIT_ALPHABETIC|TRAIT_ESCAPED)); - LOG_READ(BF("token[%s]") % tokenStr(sin,token)); + LOG_READ(("token[%s]") , _rep_(tokenStr(sin,token))); goto step9; } - LOG_READ(BF("About to test y9_syntax_type[%s] single_escape[%s] are equal? ==> %d") % _rep_(y9_syntax_type) % _rep_(kw::_sym_single_escape) % (y9_syntax_type == kw::_sym_single_escape)); + LOG_READ(("About to test y9_syntax_type[%s] single_escape[%s] are equal? ==> %d") , _rep_(y9_syntax_type) , _rep_(kw::_sym_single_escape) , (y9_syntax_type == kw::_sym_single_escape)); if (y9_syntax_type == kw::_sym_single_escape) { - LOG_READ(BF("Handling single_escape_character")); + LOG_READ(("Handling single_escape_character")); z = gc::As(cl__read_char(sin, _lisp->_true(), nil(), _lisp->_true())); token.push_back(constituentChar(z, TRAIT_ALPHABETIC|TRAIT_ESCAPED)); - LOG_READ(BF("Read z[%s] accumulated token[%s]") % clasp_as_claspCharacter(z) % tokenStr(sin,token)); + LOG_READ(("Read z[%s] accumulated token[%s]") , clasp_as_claspCharacter(z) , _rep_(tokenStr(sin,token))); goto step9; } if (y9_syntax_type == kw::_sym_multiple_escape) { - LOG_READ(BF("Handling multiple_escape_character")); + LOG_READ(("Handling multiple_escape_character")); // |....| or ....|| or ..|.|.. is ok only_dots_ok = true; goto step8; @@ -1233,7 +1227,7 @@ T_mv lisp_object_query(T_sp sin, bool eofErrorP, T_sp eofValue, bool recursiveP) SIMPLE_ERROR(("Should never get here")); } step10: - LOG_READ(BF("step10")); + LOG_READ(("step10")); // At this point convert the string in tokenSin.str() into an object // Lets just return it as an annotated string // Throw a ReaderError if the token is not valid syntax diff --git a/src/core/lispStream.cc b/src/core/lispStream.cc index 93125be26e..2e633e2dbd 100644 --- a/src/core/lispStream.cc +++ b/src/core/lispStream.cc @@ -935,7 +935,6 @@ static claspCharacter eformat_write_char_crlf(T_sp strm, claspCharacter c) { */ static claspCharacter passthrough_decoder(T_sp stream, unsigned char **buffer, unsigned char *buffer_end) { - unsigned char aux; if (*buffer >= buffer_end) return EOF; else @@ -1351,7 +1350,7 @@ static int utf_8_encoder(T_sp stream, unsigned char *buffer, claspCharacter c) { c >>= 6; buffer[0] = c | 0xE0; nbytes = 3; - } else if (c <= 0x1FFFFFL) { + } else if (c <= 0x1FFFFFL) { // upper limit of encoding - unicode is 10ffff buffer[3] = (c & 0x3f) | 0x80; c >>= 6; buffer[2] = (c & 0x3f) | 0x80; @@ -1360,7 +1359,7 @@ static int utf_8_encoder(T_sp stream, unsigned char *buffer, claspCharacter c) { c >>= 6; buffer[0] = c | 0xF0; nbytes = 4; - } + } else UNREACHABLE(); return nbytes; } #endif @@ -1527,13 +1526,8 @@ static cl_index illegal_op_vector(T_sp strm, T_sp data, cl_index start, cl_index abort(); } -static T_sp illegal_op_T_sp__T_sp(T_sp strm, T_sp c) { - printf("%s:%d Illegal op\n", __FILE__, __LINE__); - abort(); -} - static claspCharacter illegal_op_char__T_sp(T_sp strm) { - printf("%s:%d Illegal op\n", __FILE__, __LINE__); + printf("%s:%d Illegal op\n", __FILE__, __LINE__ ); abort(); } @@ -2673,7 +2667,7 @@ static FILE *safe_fdopen(int fildes, const char *mode) { if (output == NULL) { std::string serr = strerror(errno); struct stat info; - int fstat_error = fstat(fildes, &info); + fstat(fildes, &info); int flags, fdflags, tmp, oflags; if ((flags = sflags(mode, &oflags)) == 0) perror("sflags failed"); @@ -3520,17 +3514,20 @@ T_sp clasp_make_file_stream_from_fd(T_sp fname, int fd, enum StreamMode smm, gct switch (smm) { case clasp_smm_input: smm = clasp_smm_input_file; + [[fallthrough]]; case clasp_smm_input_file: case clasp_smm_probe: StreamOps(stream) = duplicate_dispatch_table(input_file_ops); break; case clasp_smm_output: smm = clasp_smm_output_file; + [[fallthrough]]; case clasp_smm_output_file: StreamOps(stream) = duplicate_dispatch_table(output_file_ops); break; case clasp_smm_io: smm = clasp_smm_io_file; + [[fallthrough]]; case clasp_smm_io_file: StreamOps(stream) = duplicate_dispatch_table(io_file_ops); break; @@ -4283,6 +4280,8 @@ CL_DEFUN T_sp ext__make_stream_from_fd(int fd, T_sp direction, T_sp buffering, T smm_mode = clasp_smm_output; } else if (direction == kw::_sym_io || direction == kw::_sym_input_output) { smm_mode = clasp_smm_io; + } else { + SIMPLE_ERROR("Illegal direction %s", _rep_(direction)); } if (cl__integerp(element_type)) { external_format = nil(); @@ -4296,6 +4295,36 @@ CL_DEFUN T_sp ext__make_stream_from_fd(int fd, T_sp direction, T_sp buffering, T return stream; } +static const char* stream_mode_string(enum StreamMode mode) { + switch (mode) { + case clasp_smm_input: return "input"; + case clasp_smm_input_file: return "input file"; + case clasp_smm_output: return "output"; + case clasp_smm_output_file: return "output file"; + case clasp_smm_io: return "input/output"; + case clasp_smm_io_file: return "input/output file"; + case clasp_smm_synonym: return "synonym"; + case clasp_smm_broadcast: return "broadcast"; + case clasp_smm_concatenated: return "concatenated"; + case clasp_smm_two_way: return "two-way"; + case clasp_smm_echo: return "echo"; + case clasp_smm_string_input: return "string input"; + case clasp_smm_string_output: return "string output"; + case clasp_smm_probe: return "probe"; +#if defined(ECL_WSOCK) + case clasp_smm_input_wsock: return "input Windows socket"; + case clasp_smm_output_wsock: return "output Windows socket"; + case clasp_smm_io_wsock: return "input/output Windows socket"; +#endif +#if defined(CLASP_MS_WINDOWS_HOST) + case clasp_smm_io_wcon: return "Windows console"; +#endif + case clasp_smm_sequence_input: return "sequence input"; + case clasp_smm_sequence_output: return "sequence output"; + default: return "[unknown]"; + } +} + int clasp_stream_to_handle(T_sp s, bool output) { BEGIN: if (UNLIKELY(!AnsiStreamP(s))) @@ -4361,7 +4390,7 @@ CL_DEFUN T_sp ext__file_stream_file_descriptor(T_sp s) { ret = make_fixnum(IOFileStreamDescriptor(s)); break; default: - SIMPLE_ERROR(("Internal error: %s:%d Wrong Stream Mode %d\n"), __FILE__, __LINE__, StreamMode(s)); + SIMPLE_ERROR(("Internal error: %s:%d No file descriptor for a stream with this mode %s\n") , __FILE__ , __LINE__ , stream_mode_string(StreamMode(s))); } return ret; } @@ -4636,7 +4665,6 @@ T_sp si_do_read_sequence(T_sp seq, T_sp stream, T_sp s, T_sp e) { T_sp elt_type = cl__stream_element_type(stream); bool ischar = (elt_type == cl::_sym_base_char) || (elt_type == cl::_sym_character); seq = cl__nthcdr(clasp_make_integer(start), seq); - T_sp orig = seq; for (; seq.notnilp(); seq = oCdr(seq)) { if (start >= end) { return make_fixnum(start); @@ -4937,7 +4965,7 @@ T_sp clasp_open_stream(T_sp fn, enum StreamMode smm, T_sp if_exists, T_sp if_doe } } } else { - FEerror("Illegal stream mode ~S", 1, make_fixnum(smm).raw_()); + FEerror("Illegal stream mode ~S", 1, stream_mode_string(smm)); } if (flags & CLASP_STREAM_C_STREAM) { FILE *fp = NULL; @@ -4955,8 +4983,10 @@ T_sp clasp_open_stream(T_sp fn, enum StreamMode smm, T_sp if_exists, T_sp if_doe case clasp_smm_io: fp = safe_fopen(fname.c_str(), OPEN_RW); break; - default:; /* never reached */ - SIMPLE_ERROR(("Illegal smm mode: %d for CLASP_STREAM_C_STREAM"), smm); + default: + /* should never be reached */ + SIMPLE_ERROR(("Illegal smm mode: %s for CLASP_STREAM_C_STREAM"), + stream_mode_string(smm)); UNREACHABLE(); } output = clasp_make_stream_from_FILE(fn, fp, smm, byte_size, flags, external_format); @@ -6201,7 +6231,6 @@ SYMBOL_EXPORT_SC_(ExtPkg, file_stream_file_descriptor); CL_DOCSTRING(R"dx(Use read to read characters if they are available - return (values num-read errno-or-nil))dx"); DOCGROUP(clasp); CL_DEFUN T_mv core__read_fd(int filedes, SimpleBaseString_sp buffer) { - char c; size_t buffer_length = cl__length(buffer); unsigned char *buffer_data = &(*buffer)[0]; while (1) { diff --git a/src/core/mpPackage.cc b/src/core/mpPackage.cc index bea9f61ddf..c5a5d712e1 100644 --- a/src/core/mpPackage.cc +++ b/src/core/mpPackage.cc @@ -539,8 +539,10 @@ CL_DEFUN core::T_sp mp__process_enable(Process_sp process) { /* process_env and ok are changed after the setjmp call in * ECL_UNWIND_PROTECT_BEGIN, so they need to be declared volatile */ +#if 0 volatile core::cl_env_ptr process_env = NULL; core::cl_env_ptr the_env = core::clasp_process_env(); +#endif volatile int ok = 0; core::funwind_protect( [&]() { /* Try to gain exclusive access to the process at the same diff --git a/src/core/myReadLine.cc b/src/core/myReadLine.cc index 2ba53b3a4f..d1b7bcaff4 100644 --- a/src/core/myReadLine.cc +++ b/src/core/myReadLine.cc @@ -43,7 +43,6 @@ string myReadLine(const string &prompt, bool &end_of_transmission) { #ifdef READLINE char *line_read; /* Get a line from the user. */ - // lisp->print(BF("%s")%prompt); stringstream ss; ss << std::endl << prompt; diff --git a/src/core/num_arith.cc b/src/core/num_arith.cc index 2a272e7787..b6916fe8ea 100644 --- a/src/core/num_arith.cc +++ b/src/core/num_arith.cc @@ -69,7 +69,6 @@ Integer_sp clasp_integer_divide(Integer_sp x, Integer_sp y) { case_Bignum_v_Fixnum : { T_mv trunc = core__next_ftruncate(gc::As_unsafe(x), y.unsafe_fixnum()); - T_sp quotient = trunc; return gc::As_unsafe(trunc); } case_Bignum_v_Bignum : { @@ -79,7 +78,6 @@ Integer_sp clasp_integer_divide(Integer_sp x, Integer_sp y) { // Would save some heap allocation. T_mv trunc = core__next_truncate(gc::As_unsafe(x), gc::As_unsafe(y)); - T_sp quotient = trunc; return gc::As_unsafe(trunc); } }; diff --git a/src/core/num_co.cc b/src/core/num_co.cc index c075b22473..9439216c5d 100644 --- a/src/core/num_co.cc +++ b/src/core/num_co.cc @@ -102,7 +102,7 @@ CL_DEFUN Float_sp cl__float(Real_sp x, T_sp y) { #endif if (y.nilp() || ty == tx) return gc::As_unsafe(x); - // otherwise, fall through + [[fallthrough]]; case number_Fixnum: case number_Bignum: case number_Ratio: diff --git a/src/core/numbers.cc b/src/core/numbers.cc index 4058fee2ef..3b7a37704f 100644 --- a/src/core/numbers.cc +++ b/src/core/numbers.cc @@ -75,7 +75,7 @@ core::Fixnum not_fixnum_error( core::T_sp o ) , naclass , nbclass); } -void clasp_report_divide_by_zero(Number_sp x) { +[[noreturn]] void clasp_report_divide_by_zero(Number_sp x) { ERROR_DIVISION_BY_ZERO(clasp_make_fixnum(1),x); } @@ -773,62 +773,6 @@ CL_DEFUN Number_sp cl___DIVIDE_(Number_sp num, List_sp numbers) { See file '../Copyright' for full details. */ -/* - * In Common Lisp, comparisons between floats and integers are performed - * via an intermediate rationalization of the floating point number. In C, - * on the other hand, the comparison is performed by converting the integer - * into a floating point number. However, if the double type is too small - * this may lead to a loss of precision and two numbers being told equal - * when, by Common Lisp standards, would not. - */ -static int -double_fix_compare(Fixnum n, double d) { - if ((double)n < d) { - return -1; - } else if ((double)n > d) { - return +1; - } else if (sizeof(double) > sizeof(Fixnum)) { - return 0; - } else { - /* When we reach here, the double type has no - * significant decimal part. However, as explained - * above, the double type is too small and integers - * may coerce to the same double number giving a false - * positive. Hence we perform the comparison in - * integer space. */ - Fixnum m = d; - if (n == m) { - return 0; - } else if (n > m) { - return +1; - } else { - return -1; - } - } -} - -#ifdef CLASP_LONG_FLOAT -static int -long_double_fix_compare(Fixnum n, LongFloat d) { - if ((LongFloat)n < d) { - return -1; - } else if ((LongFloat)n > d) { - return +1; - } else if (sizeof(LongFloat) > sizeof(Fixnum)) { - return 0; - } else { - Fixnum m = d; - if (n == m) { - return 0; - } else if (n > m) { - return +1; - } else { - return -1; - } - } -} -#endif - /* ---------------------------------------------------------------------- basic_compare @@ -2486,13 +2430,12 @@ expt_zero(Number_sp x, Number_sp y) { Number_sp clasp_expt(Number_sp x, Number_sp y) { - NumberType ty, tx; + NumberType ty; Number_sp z; if (clasp_unlikely(clasp_zerop(y))) { return expt_zero(x, y); } ty = clasp_t_of(y); - tx = clasp_t_of(x); if (clasp_unlikely(!gc::IsA(x))) { QERROR_WRONG_TYPE_NTH_ARG(1, x, cl::_sym_Number_O); } diff --git a/src/core/package.cc b/src/core/package.cc index 47c43b03a4..7c620a6ce7 100644 --- a/src/core/package.cc +++ b/src/core/package.cc @@ -900,7 +900,6 @@ void Package_O::unexport(Symbol_sp sym) { goto package_lock_violation; SimpleString_sp nameKey = sym->_Name; T_mv values = this->findSymbol_SimpleString_no_lock(nameKey); - Symbol_sp foundSym = gc::As(values); Symbol_sp status = gc::As(mvn.second(values.number_of_values())); if (status.nilp()) { goto not_accessible; diff --git a/src/core/pathname.cc b/src/core/pathname.cc index e5cd2737a4..659ea4421a 100644 --- a/src/core/pathname.cc +++ b/src/core/pathname.cc @@ -1640,6 +1640,8 @@ bool clasp_stringMatch(T_sp s, size_t j, size_t ls, T_sp p, size_t i, size_t lp) Trailing slash is interpreted as a slash. */ if (++i >= lp) i--; + cp = cl__char(gc::As(p), i).unsafe_character(); + [[fallthrough]]; default: if ((j >= ls) || (cp != cl__char(gc::As(s), j).unsafe_character())) { /* Either there are no characters left in "s" diff --git a/src/core/posixTime.cc b/src/core/posixTime.cc index c3e7881397..85e5df4ee1 100644 --- a/src/core/posixTime.cc +++ b/src/core/posixTime.cc @@ -81,7 +81,6 @@ void first_exit() { } void last_exit() { - struct timespec now_time; systemReadClock(global__end_end_time); size_t seconds = global__end_end_time.tv_sec - global__start_end_time.tv_sec; if (strcmp(getenv("CLASP_TIME_EXIT"),"wait-")==0 || diff --git a/src/core/primitives.cc b/src/core/primitives.cc index 8fd5d8d790..30a0b58da3 100644 --- a/src/core/primitives.cc +++ b/src/core/primitives.cc @@ -125,7 +125,7 @@ CL_DEFUN T_sp cl__sleep(Real_sp oseconds) { if (dsec < 0.0) { TYPE_ERROR(oseconds,Cons_O::createList(cl::_sym_float,clasp_make_single_float(0.0))); } - int retval = clasp_musleep(dsec,false); + clasp_musleep(dsec,false); return nil(); } @@ -628,7 +628,7 @@ CL_DOCSTRING(R"dx(validFunctionNameP)dx"); DOCGROUP(clasp); CL_DEFUN T_sp core__valid_function_name_p(T_sp arg) { bool correct; - Symbol_sp name = functionBlockName(arg, &correct); + functionBlockName(arg, &correct); if (!correct) return nil(); return _lisp->_true(); @@ -1880,7 +1880,6 @@ CL_DEFUN SimpleVector_byte8_t_sp core__character_string_that_fits_in_base_string AbstractSimpleVector_sp basesv; size_t start, end; sarray->asAbstractSimpleVectorRange(basesv,start,end); - SimpleCharacterString_sp sbs = gc::As_unsafe(basesv); SimpleVector_byte8_t_sp result = SimpleVector_byte8_t_O::make((end-start),0,false); for ( int i=0; ilength(); ++i ) { int c = (*sarray)[i]; @@ -2012,106 +2011,6 @@ void print_add_two_numbers(int x, int y) { SYMBOL_SC_(CorePkg, bdsVar); SYMBOL_SC_(CorePkg, bdsVal); - - - -namespace core { - - - - -int tak_aux(int x, int y, int z, bool allocate) -{ - if (y < x) { - return tak_aux(tak_aux(x-1,y,z,allocate),tak_aux(y-1,z,x,allocate),tak_aux(z-1,x,y,allocate),allocate); - } else { - if (allocate) { -#ifdef USE_BOEHM - GC_MALLOC(128); -#endif - } - return z; - } -} - -int tak(int x, int y, int z, bool allocate, int times) { - int ret; - for ( int ii=0; ii(olimit)) { Bignum_sp gbn = gc::As_unsafe(olimit); mp_size_t len = gbn->length(); - const mp_limb_t* limbs = gbn->limbs(); if (len < 1) TYPE_ERROR_cl_random(olimit); // positive only mp_limb_t res[len]; const mp_limb_t minlimb = std::numeric_limits::min(); diff --git a/src/core/singleDispatchGenericFunction.cc b/src/core/singleDispatchGenericFunction.cc index 50b667cddc..acf3904890 100644 --- a/src/core/singleDispatchGenericFunction.cc +++ b/src/core/singleDispatchGenericFunction.cc @@ -101,7 +101,6 @@ CL_DEFUN SingleDispatchGenericFunction_sp core__ensure_single_dispatch_generic_f ASSERT(gc::IsA(gfname)); Symbol_sp gfname_symbol = gc::As_unsafe(gfname); if (gfname_symbol->fboundp()) { - T_sp symFunc = gfname_symbol->symbolFunction(); SIMPLE_ERROR(("The symbol %s has something bound to its function slot but not a single dispatch generic function") , _rep_(gfname)); } gfn = SingleDispatchGenericFunction_O::create_single_dispatch_generic_function(gfname,singleDispatchArgumentIndex, lambdaList); diff --git a/src/core/stackmap.cc b/src/core/stackmap.cc index 0e0cc8d63b..a587df7531 100644 --- a/src/core/stackmap.cc +++ b/src/core/stackmap.cc @@ -25,7 +25,6 @@ static T read_then_advance(uintptr_t& address) { static bool parse_header(uintptr_t& address, uintptr_t end, smHeader& header, size_t& NumFunctions, size_t& NumConstants, size_t& NumRecords) { - uintptr_t headerAddress = address; header.version = read_then_advance(address); header.reserved0 = read_then_advance(address); header.reserved1 = read_then_advance(address); @@ -40,7 +39,6 @@ static bool parse_header(uintptr_t& address, uintptr_t end, smHeader& header, } static void parse_function(uintptr_t& address, smStkSizeRecord& function) { - uintptr_t functionAddress = address; function.FunctionAddress = read_then_advance(address); function.StackSize = read_then_advance(address); function.RecordCount = read_then_advance(address); @@ -55,9 +53,8 @@ static void parse_record(std::function(address); - uint32_t instructionOffset = read_then_advance(address); + read_then_advance(address); // instructionOffset - unused /* record.Reserved = */ read_then_advance(address); size_t NumLocations = read_then_advance(address); for ( size_t index=0; indexrowMajorAref(i); claspCharacter c = cc.unsafe_character(); claspCharacter u = char_upcase(c); - Character_sp cu = clasp_make_character(u); result->rowMajorAset(i,clasp_make_character(u)); } return (result); @@ -189,7 +188,7 @@ struct StringCharPointer { size_t _pos; size_t _start; typedef typename T::simple_element_type CharacterType; - StringCharPointer(const T* strP, size_t start) : _stringPtr(strP), _start(start), _pos(start) {} + StringCharPointer(const T* strP, size_t start) : _stringPtr(strP), _pos(start), _start(start) {} inline size_t offset() { return this->_pos - this->_start;}; CharacterType operator*() { CharacterType c = (*this->_stringPtr)[this->_pos]; @@ -1119,10 +1118,8 @@ cl_index fsmInteger(mpz_class &result, cl_index &numDigits, bool &sawJunk, Strin break; } case itrailspace: { - if (!isspace(c)) { - state = ijunk; - break; - } + if (!isspace(c)) state = ijunk; + break; } case ijunk: break; diff --git a/src/core/symbol.cc b/src/core/symbol.cc index 45c4ebda96..4b6708b82f 100644 --- a/src/core/symbol.cc +++ b/src/core/symbol.cc @@ -559,7 +559,6 @@ string Symbol_O::formattedName(bool prefixAlways) const { //no guard if (myPackage->isKeywordPackage()) { ss << ":" << this->_Name->get_std_string(); } else { - Package_sp currentPackage = _lisp->getCurrentPackage(); if (prefixAlways) { ss << myPackage->getName() << "::" << this->_Name->get_std_string(); } else { diff --git a/src/core/unixfsys.cc b/src/core/unixfsys.cc index 5bee16f004..51dd083ea4 100644 --- a/src/core/unixfsys.cc +++ b/src/core/unixfsys.cc @@ -103,9 +103,9 @@ typedef int mode_t; #include #if defined( DEBUG_LEVEL_FULL ) -#define DEBUG_PRINT(_msg_) fprintf( stderr, "%s", (_msg_).str().c_str()) +#define DEBUG_PRINT(...) fmt::fprintf( stderr, __VA_ARGS__ ) #else -#define DEBUG_PRINT(msg) +#define DEBUG_PRINT(...) #endif @@ -146,7 +146,6 @@ String_sp clasp_strerror(int e) { void rmtree(const char* path) { - size_t path_len; DIR *dir; struct stat stat_path, stat_entry; struct dirent *entry; @@ -172,9 +171,6 @@ String_sp clasp_strerror(int e) { return; } - // the length of the path - path_len = strlen(path); - // iteration through entries in the directory while ((entry = readdir(dir)) != NULL) { @@ -837,8 +833,6 @@ file_truename(T_sp pathname, T_sp filename, int flags) { SIMPLE_ERROR(("Unprintable pathname %s found in TRUENAME") , _rep_(pathname)); } } - T_sp original_pathname = pathname; - T_sp original_filename = filename; kind = file_kind((char *)gc::As(filename)->get_std_string().c_str(), false); // kind = smart_file_kind( filename, false); if (kind.nilp()) { @@ -2016,7 +2010,7 @@ CL_DEFUN T_mv ext__vfork_execvp(List_sp call_and_arguments, T_sp return_stream) if( WIFEXITED( status ) ) { child_exit_status = WEXITSTATUS( status ); - DEBUG_PRINT(BF("%s (%s:%d) | Child process exited with status %d\n.") % __FUNCTION__ % __FILE__ % __LINE__ % child_exit_status ); + DEBUG_PRINT(("%s (%s:%d) | Child process exited with status %d\n.") , __FUNCTION__ , __FILE__ , __LINE__ , child_exit_status ); b_done = true; } @@ -2026,14 +2020,15 @@ CL_DEFUN T_mv ext__vfork_execvp(List_sp call_and_arguments, T_sp return_stream) int signal = 0; signal = WTERMSIG( status ); - DEBUG_PRINT(BF("%s (%s:%d) | Child process got signal %d\n.") % __FUNCTION__ % __FILE__ % __LINE__ % signal ); + (void)signal; // sham use + DEBUG_PRINT(("%s (%s:%d) | Child process got signal %d\n.") , __FUNCTION__ , __FILE__ , __LINE__ , signal ); // Continue waiting ! } } - DEBUG_PRINT(BF("%s (%s:%d) | Child process cmd = %s\n.") % __FUNCTION__ % __FILE__ % __LINE__ % execvp_args[ 0 ] ); - DEBUG_PRINT(BF("%s (%s:%d) | Child process wait(): return code = %d, errno = %d, error = %s\n.") % __FUNCTION__ % __FILE__ % __LINE__ % wait_ret % errno % strerror(errno) ); + DEBUG_PRINT(("%s (%s:%d) | Child process cmd = %s\n.") , __FUNCTION__ , __FILE__ , __LINE__ , execvp_args[ 0 ] ); + DEBUG_PRINT(("%s (%s:%d) | Child process wait(): return code = %d, errno = %d, error = %s\n.") , __FUNCTION__ , __FILE__ , __LINE__ , wait_ret , errno , strerror(errno) ); // Clean up args for ( int i(0); i < execvp_args.size() - 1; ++i ) @@ -2053,19 +2048,19 @@ CL_DEFUN T_mv ext__vfork_execvp(List_sp call_and_arguments, T_sp return_stream) fcntl(filedes[0],F_SETFL,flags|O_NONBLOCK); T_sp stream = clasp_make_file_stream_from_fd(SimpleBaseString_O::make("execvp"), filedes[0], clasp_smm_input_file, 8, CLASP_STREAM_DEFAULT_FORMAT, nil()); - DEBUG_PRINT(BF("%s (%s:%d) | Values( %d %d %p )\n.") % __FUNCTION__ % __FILE__ % __LINE__ % 0 % child_PID % stream ); + DEBUG_PRINT(("%s (%s:%d) | Values( %d %d %p )\n.") , __FUNCTION__ , __FILE__ , __LINE__ , 0 , child_PID , stream ); return Values( clasp_make_fixnum( 0 ), clasp_make_fixnum( child_PID ), stream); } - DEBUG_PRINT(BF("%s (%s:%d) | Values( %d %d %d )\n.") % __FUNCTION__ % __FILE__ % __LINE__ % 0 % child_PID % 0 ); + DEBUG_PRINT(("%s (%s:%d) | Values( %d %d %d )\n.") , __FUNCTION__ , __FILE__ , __LINE__ , 0 , child_PID , 0 ); return Values( clasp_make_fixnum( 0 ), clasp_make_fixnum( child_PID ), nil() ); } // error - DEBUG_PRINT(BF("%s (%s:%d) | Values( %d %d %d )\n.") % __FUNCTION__ % __FILE__ % __LINE__ % errno % strerror( errno ) % 0 ); + DEBUG_PRINT(("%s (%s:%d) | Values( %d %d %d )\n.") , __FUNCTION__ , __FILE__ , __LINE__ , errno , strerror( errno ) , 0 ); char* serr = std::strerror(errno); return Values( clasp_make_fixnum( errno ), SimpleBaseString_O::make(serr), nil() ); diff --git a/src/core/unixsys.cc b/src/core/unixsys.cc index 3f279bff41..ee63ae9fce 100644 --- a/src/core/unixsys.cc +++ b/src/core/unixsys.cc @@ -263,8 +263,8 @@ CL_DEFUN T_sp sys__killpid(T_sp pid, T_sp signal) void describe_fildes(int fildes, const char* name) { struct stat info; - int fstat_error = fstat( fildes, &info ); - int fdflags, tmp, oflags; + fstat( fildes, &info ); + int fdflags; if ((fdflags = fcntl(fildes, F_GETFL, 0)) < 0) perror("fcntl failed"); printf("%s:%d name: %s filedes: %d fdflags = %d\n", __FUNCTION__, __LINE__, name, fildes, fdflags ); } diff --git a/src/core/weakHashTable.cc b/src/core/weakHashTable.cc index a4a57eea6c..5135a54230 100644 --- a/src/core/weakHashTable.cc +++ b/src/core/weakHashTable.cc @@ -193,23 +193,7 @@ CL_DEFUN void core__weak_splat(WeakKeyHashTable_sp ht, Fixnum_sp idx) { TESTING(); // Test the NULL value (*ht->_HashTable._Keys).set(unbox_fixnum(idx), WeakKeyHashTable_O::value_type(splatted)); }; -CL_LAMBDA(ht &optional sz); -CL_DECLARE(); -CL_DOCSTRING(R"dx(weakRehash)dx"); -DOCGROUP(clasp); -CL_DEFUN void core__weak_rehash(WeakKeyHashTable_sp ht, T_sp sz) { - size_t newLength; - if (sz.nilp()) { - newLength = ht->_HashTable._Keys->length() * 2; - } else { - newLength = unbox_fixnum(gc::As(sz)); - // newLength = unbox_fixnum(As(sz)); - } - WeakKeyHashTable_O::value_type dummyKey; - size_t dummyPos; - ht->_HashTable.rehash(dummyKey, dummyPos); -}; -}; +}; // namespace core diff --git a/src/gctools/boehmGarbageCollection.cc b/src/gctools/boehmGarbageCollection.cc index 3a55faf0d7..fd37115594 100644 --- a/src/gctools/boehmGarbageCollection.cc +++ b/src/gctools/boehmGarbageCollection.cc @@ -114,7 +114,6 @@ void boehm_callback_reachable_object_find_owners(void *ptr, size_t sz, void *cli uintptr_t tag = (uintptr_t)tp&0xf; if (GC_is_heap_ptr(tp) && (tag == GENERAL_TAG || tag == CONS_TAG)) { void* obj = gctools::untag_object(tp); - uintptr_t addr = (uintptr_t)obj; void* base = gctools::GeneralPtrToHeaderPtr(obj); #if 0 printf("%s:%d Looking at cur->%p\n", __FILE__, __LINE__, cur); @@ -146,20 +145,11 @@ size_t dumpResults(const std::string &name, T *data, std::ostringstream& OutputS sort(values.begin(), values.end(), [](const value_type &x, const value_type &y) { return (x.totalSize > y.totalSize); }); - size_t idx = 0; - size_t totalCons = 0; - size_t numCons = 0; for (auto it : values) { // Does that print? If so should go to the OutputStream size_t sz = it.print(OutputStream); totalSize += sz; if (sz < 1) break; - idx += 1; -#if 0 - if ( idx % 100 == 0 ) { - gctools::poll_signals(); - } -#endif } return totalSize; } @@ -183,10 +173,7 @@ size_t summarizeResults(T *data, Summary& summary ) { for (auto it : *data) { values.push_back(it.second); } - size_t idx = 0; - size_t totalCons = 0; size_t totalSize = 0; - size_t numCons = 0; for (auto it : values) { // Does that print? If so should go to the OutputStream Fixnum k = it._Kind; @@ -200,7 +187,6 @@ size_t summarizeResults(T *data, Summary& summary ) { } totalSize += sz; if (sz < 1) break; - idx += 1; } return totalSize; @@ -270,6 +256,7 @@ void run_finalizers(core::T_sp obj, void* data) void boehm_general_finalizer_from_BoehmFinalizer(void* client, void* data) { gctools::Header_s* header = (gctools::Header_s*)((char*)client - sizeof(gctools::Header_s)); + (void)header; // sham use // printf("%s:%d:%s for client: %p stamp: %lu\n", __FILE__, __LINE__, __FUNCTION__, (void*)client, header->_badge_stamp_wtag_mtag.stamp()); // printf(" obj class from stamp -> %s\n", obj_name(header->_badge_stamp_wtag_mtag.stamp()) ); if ((uintptr_t)client&gctools::ptag_mask) { @@ -393,7 +380,6 @@ void boehm_clear_finalizer_list(gctools::Tagged object_tagged) void* base = SmartPtrToBasePtr(object); GC_register_finalizer_no_order(base,NULL,NULL,&orig_finalizer,&data); if ( data != NULL ) { - gctools::Tagged list_tagged = *reinterpret_cast(data); GC_free(data); data = NULL; } @@ -404,7 +390,6 @@ void boehm_clear_finalizer_list(gctools::Tagged object_tagged) void* base = (void*)gctools::ConsPtrToHeaderPtr(&*object); GC_register_finalizer_no_order(base,NULL,NULL,&orig_finalizer,&data); if ( data != NULL ) { - gctools::Tagged list_tagged = *reinterpret_cast(data); GC_free(data); data = NULL; } diff --git a/src/gctools/cons_scan.cc b/src/gctools/cons_scan.cc index 4327e73f6e..a1780221cd 100644 --- a/src/gctools/cons_scan.cc +++ b/src/gctools/cons_scan.cc @@ -60,7 +60,6 @@ RESULT_TYPE CONS_SCAN(SCAN_STRUCT_T ss, ADDR_T client, ADDR_T limit EXTRA_ARGUME #ifdef CONS_SKIP ADDR_T CONS_SKIP(ADDR_T client,size_t& objectSize) { // printf("%s:%d in %s\n", __FILE__, __LINE__, __FUNCTION__ ); - ADDR_T oldClient = client; core::Cons_O* cons = reinterpret_cast(client); gctools::Header_s* header = (gctools::Header_s*)gctools::ConsPtrToHeaderPtr(cons); if ( header->_badge_stamp_wtag_mtag.pad1P() ) { @@ -84,8 +83,7 @@ ADDR_T CONS_SKIP_IN_CONS_FWD(ADDR_T client); static void CONS_FWD(ADDR_T old_client, ADDR_T new_client) { // printf("%s:%d in %s\n", __FILE__, __LINE__, __FUNCTION__ ); // I'm assuming both old and new client pointers have valid headers at this point - ADDR_T limit = CONS_SKIP_IN_CONS_FWD(old_client); - size_t size = (char *)limit - (char *)old_client; + CONS_SKIP_IN_CONS_FWD(old_client); core::Cons_O* cons = reinterpret_cast(old_client); gctools::Header_s* header = (gctools::Header_s*)gctools::ConsPtrToHeaderPtr(cons); header->_badge_stamp_wtag_mtag.setFwdPointer((void*)new_client); diff --git a/src/gctools/exposeClasses0.cc b/src/gctools/exposeClasses0.cc index c0ace30e10..a50ca2ee42 100644 --- a/src/gctools/exposeClasses0.cc +++ b/src/gctools/exposeClasses0.cc @@ -175,7 +175,7 @@ void calculate_class_precedence_lists() template void add_single_typeq_test(const string& cname, core::HashTable_sp theMap) { - Fixnum header_val = gctools::Header_s::StampWtagMtag::GenerateHeaderValue(); + //Fixnum header_val = gctools::Header_s::StampWtagMtag::GenerateHeaderValue(); // printf("%s:%d Header value for type %s -> %lld stamp: %u flags: %zu\n", __FILE__, __LINE__, _rep_(TSingle::static_class_symbol).c_str(), header_val, gctools::GCStamp::Stamp, gctools::GCStamp::Flags); theMap->setf_gethash(TSingle::static_classSymbol(),core::make_fixnum(gctools::Header_s::StampWtagMtag::GenerateHeaderValue())); } diff --git a/src/gctools/gcFunctions.cc b/src/gctools/gcFunctions.cc index e75075fd0c..13df9025e1 100644 --- a/src/gctools/gcFunctions.cc +++ b/src/gctools/gcFunctions.cc @@ -831,7 +831,6 @@ CL_DEFUN void gctools__debug_allocations(core::T_sp debugOn) { }; bool debugging_configuration(bool setFeatures, bool buildReport, stringstream& ss) { - bool metrics_file = false; core::List_sp features = cl::_sym_STARfeaturesSTAR->symbolValue(); bool debugging = false; bool use_boehm_memory_marker = false; @@ -980,9 +979,7 @@ bool debugging_configuration(bool setFeatures, bool buildReport, stringstream& s #endif if (buildReport) ss << (fmt::sprintf("DEBUG_GFDISPATCH = %s\n" , (debug_gfdispatch ? "**DEFINED**" : "undefined") )); - bool debug_cst = false; #ifdef CST - debug_cst = true; debugging = true; if (setFeatures) features = core::Cons_O::create(_lisp->internKeyword("CST"),features); #endif @@ -1196,9 +1193,7 @@ bool debugging_configuration(bool setFeatures, bool buildReport, stringstream& s #endif if (buildReport) ss << (fmt::sprintf("DISABLE_TYPE_INFERENCE = %s\n" , (disable_type_inference ? "**DEFINED**" : "undefined") )); - bool use_compile_file_parallel = true; #if USE_COMPILE_FILE_PARALLEL == 0 - use_compile_file_parallel = false; INTERN_(comp,STARuse_compile_file_parallelSTAR)->defparameter(nil()); printf("%s:%d You have turned off compile-file-parallel\n - you can enable it by setting USE_COMPILE_FILE_PARALLEL in the wscript.config\n - compile-file-parallel should be enabled by default\n", __FILE__, __LINE__ ); #else @@ -1206,41 +1201,32 @@ bool debugging_configuration(bool setFeatures, bool buildReport, stringstream& s #endif if (buildReport) ss << (fmt::sprintf("USE_COMPILE_FILE_PARALLEL = %s\n" , USE_COMPILE_FILE_PARALLEL)); - bool force_startup_external_linkage = true; #if FORCE_STARTUP_EXTERNAL_LINKAGE == 0 - force_startup_external_linkage = false; INTERN_(comp,STARforce_startup_external_linkageSTAR)->defparameter(nil()); #else INTERN_(comp,STARforce_startup_external_linkageSTAR)->defparameter(_lisp->_true()); #endif if (buildReport) ss << (fmt::sprintf("FORCE_STARTUP_EXTERNAL_LINKAGE = %s\n" , FORCE_STARTUP_EXTERNAL_LINKAGE)); - bool use_lto = false; // CLASP_BUILD_MODE == 0 means generate fasls #if CLASP_BUILD_MODE == 0 - use_lto = false; debugging = true; INTERN_(core,STARclasp_build_modeSTAR)->defparameter(kw::_sym_fasl); // CLASP_BUILD_MODE == 1 means generate object files #elif CLASP_BUILD_MODE == 1 - use_lto = false; debugging = true; INTERN_(core,STARclasp_build_modeSTAR)->defparameter(kw::_sym_object); // CLASP_BUILD_MODE == 2 means generate bitcode and use thinlto #elif CLASP_BUILD_MODE == 2 - use_lto = true; debugging = false; INTERN_(core,STARclasp_build_modeSTAR)->defparameter(kw::_sym_bitcode); #elif CLASP_BUILD_MODE == 3 - use_lto = false; debugging = false; INTERN_(core,STARclasp_build_modeSTAR)->defparameter(kw::_sym_faso); #elif CLASP_BUILD_MODE == 4 - use_lto = false; debugging = false; INTERN_(core,STARclasp_build_modeSTAR)->defparameter(kw::_sym_fasoll); #elif CLASP_BUILD_MODE == 5 - use_lto = false; debugging = false; INTERN_(core,STARclasp_build_modeSTAR)->defparameter(kw::_sym_fasobc); #endif @@ -1306,7 +1292,7 @@ DOCGROUP(clasp); CL_DEFUN void gctools__configuration() { stringstream ss; - bool debugging = debugging_configuration(false,true,ss); + debugging_configuration(false,true,ss); core::clasp_writeln_string(ss.str()); } diff --git a/src/gctools/gc_boot.cc b/src/gctools/gc_boot.cc index 38ecb495fd..5476cbc09e 100644 --- a/src/gctools/gc_boot.cc +++ b/src/gctools/gc_boot.cc @@ -193,9 +193,11 @@ void walk_stamp_field_layout_tables(WalkKind walk, std::ostream& fout) Field_layout* local_field_layout = new Field_layout[number_of_fixable_fields]; // (Field_layout*)malloc(sizeof(Field_layout)*number_of_fixable_fields); Field_layout* cur_field_layout= local_field_layout; Field_layout* max_field_layout = (Field_layout*)((char*)local_field_layout + sizeof(Field_layout)*number_of_fixable_fields); + (void)max_field_layout; // used in assert below Field_info* local_field_info = new Field_info[number_of_fixable_fields]; // (Field_info*)malloc(sizeof(Field_info)*(number_of_fixable_fields)); Field_info* cur_field_info = local_field_info; Field_info* max_field_info = (Field_info*)((char*)local_field_info + sizeof(Field_info)*number_of_fixable_fields); + (void)max_field_info; // used in assert below Container_layout* local_container_layout = new Container_layout[number_of_containers+1]; // (Container_layout*)malloc(sizeof(Container_layout)*(number_of_containers+1)); Container_info* local_container_info = new Container_info[number_of_containers+1]; // (Container_info*)malloc(sizeof(Container_info)*(number_of_containers+1)); // Fill in the immediate stamps @@ -207,12 +209,16 @@ void walk_stamp_field_layout_tables(WalkKind walk, std::ostream& fout) idx = 0; size_t fixed_index = 0; size_t container_variable_index = 0; +#if DEBUG_ASSERT size_t prev_field_offset = ~0; +#endif for ( idx=0; idxlocal_stamp_max) { printf("%s:%d class_kind cur_stamp = %d local_stamp_max = %lu\n", __FILE__, __LINE__, cur_stamp, local_stamp_max ); @@ -237,7 +243,6 @@ void walk_stamp_field_layout_tables(WalkKind walk, std::ostream& fout) case fixed_field: { size_t data_type = codes[idx].data0; - size_t index = local_stamp_layout[cur_stamp].number_of_fields; const char* field_name = codes[idx].description; size_t field_offset = codes[idx].data2; if (walk == lldb_info) { @@ -295,7 +300,9 @@ void walk_stamp_field_layout_tables(WalkKind walk, std::ostream& fout) } #endif cur_field_layout->field_offset = field_offset; +#ifdef DEBUG_ASSERT prev_field_offset = field_offset; +#endif GCTOOLS_ASSERT(cur_field_infonumber_of_fields; size_t field_offset = codes[idx].data2; const char* field_name = codes[idx].description; if (walk == lldb_info) fmt::print(fout, "{}Init__variable_field( stamp={}, index={}, data_type={}, field_name=\"{}\", field_offset={} )\n", @@ -430,7 +440,9 @@ void walk_stamp_field_layout_tables(WalkKind walk, std::ostream& fout) break; case templated_kind: { +#ifdef DEBUG_ASSERT prev_field_offset = ~0; +#endif cur_stamp = STAMP(codes[idx].data0); size_t size = codes[idx].data1; const char* name = codes[idx].description; diff --git a/src/gctools/gc_interface.cc b/src/gctools/gc_interface.cc index a4b745f19f..247f699077 100644 --- a/src/gctools/gc_interface.cc +++ b/src/gctools/gc_interface.cc @@ -740,7 +740,7 @@ void dumpBoehmLayoutTables(std::ostream& fout) { #define Init_templated_kind(_class_) \ fmt::print(fout, "Init_templated_kind( stamp={}, name=\"{}\", size={});\n", LAYOUT_STAMP(_class_),#_class_,sizeof(*(_class_*)0x0)); #define Init__fixed_field(_class_,_index_,_type_,_field_name_) \ - fmt::print(fout, "Init__fixed_field( stamp={}, index={}, data_type={},field_name=\"{}\",field_offset={});\n", LAYOUT_STAMP(_class_),_index_,_type_,#_field_name_,offsetof(_class_,_field_name_)); + fmt::print(fout, "Init__fixed_field( stamp={}, index={}, data_type={},field_name=\"{}\",field_offset={});\n", LAYOUT_STAMP(_class_),_index_,(int)_type_,#_field_name_,offsetof(_class_,_field_name_)); #define Init__variable_array0(_class_,_data_field_) \ fmt::print(fout,"Init__variable_array0( stamp={}, name=\"{}\", offset={} );\n", LAYOUT_STAMP(_class_),#_data_field_,offsetof(_class_,_data_field_)); #define Init__variable_capacity(_class_,_value_type_,_end_,_capacity_) \ diff --git a/src/gctools/gcweak.cc b/src/gctools/gcweak.cc index 39d01bd246..5d4a0a5dd1 100644 --- a/src/gctools/gcweak.cc +++ b/src/gctools/gcweak.cc @@ -202,7 +202,8 @@ int WeakKeyHashTable::rehash_not_safe(const value_type &key, size_t &key_bucket) size_t found; size_t b; found = WeakKeyHashTable::find_no_lock(newHashTable._Keys, old_key, b); - GCTOOLS_ASSERT(found);// assert(found); /* new table shouldn't be full */ + (void)found; + GCTOOLS_ASSERT(found); /* new table shouldn't be full */ if ( !(*newHashTable._Keys)[b].unboundp() ) { printf("%s:%d About to copy key: %12p at index %zu to newHashTable at index: %zu\n", __FILE__, __LINE__, old_key.raw_(), i, b ); @@ -382,6 +383,7 @@ void WeakKeyHashTable::set(core::T_sp key, core::T_sp value) { size_t dummyPos; this->rehash( dummyKey, dummyPos ); res = this->trySet( key, value); + (void)res; // sham use GCTOOLS_ASSERT(res); } }); @@ -478,7 +480,6 @@ DOCGROUP(clasp); CL_DEFUN core::Vector_sp weak_key_hash_table_pairs(const gctools::WeakKeyHashTable& ht) { size_t len = (*ht._Keys).length(); core::ComplexVector_T_sp keyvalues = core::ComplexVector_T_O::make(len*2,nil(),core::make_fixnum(0)); - size_t idx(0); HT_READ_LOCK(&ht); for ( size_t i(0); i_badge_stamp_wtag_mtag.weakObjectP()) { // It's a weak object size_t objectSize; uintptr_t client = (uintptr_t)HeaderPtrToWeakPtr(header); - uintptr_t clientLimit = mw_weak_skip( client, false, objectSize ); + mw_weak_skip( client, false, objectSize ); return objectSize; } else { // It's a general object - walk it diff --git a/src/gctools/obj_scan.cc b/src/gctools/obj_scan.cc index f0a448cedb..5990fc7ca6 100644 --- a/src/gctools/obj_scan.cc +++ b/src/gctools/obj_scan.cc @@ -39,13 +39,17 @@ RESULT_TYPE OBJECT_SCAN(SCAN_STRUCT_T ss, ADDR_T client, ADDR_T limit EXTRA_A #ifdef DEBUG_OBJECT_SCAN // printf("%s:%d obj_scan client = %p limit = %p\n", __FILE__, __LINE__, client, limit ); #endif - + +#ifdef DEBUG_MPS_SIZE ADDR_T oldClient; +#endif size_t stamp_index; size_t size; SCAN_BEGIN(ss) { while (client < limit) { +#ifdef DEBUG_MPS_SIZE oldClient = (ADDR_T)client; +#endif // The client must have a valid header const gctools::Header_s& header = *reinterpret_cast(GENERAL_PTR_TO_HEADER_PTR(client)); const gctools::Header_s::BadgeStampWtagMtag& header_value = header._badge_stamp_wtag_mtag; @@ -89,7 +93,6 @@ RESULT_TYPE OBJECT_SCAN(SCAN_STRUCT_T ss, ADDR_T client, ADDR_T limit EXTRA_A } else { #if 1 // Use pointer bitmaps - int idx = 0; uintptr_t pointer_bitmap = stamp_layout.class_field_pointer_bitmap; #ifdef DEBUG_POINTER_BITMAPS const gctools::Field_layout* field_layout_cur = stamp_layout.field_layout_start; @@ -120,7 +123,9 @@ RESULT_TYPE OBJECT_SCAN(SCAN_STRUCT_T ss, ADDR_T client, ADDR_T limit EXTRA_A #endif } if ( stamp_layout.container_layout ) { +#ifdef DEBUG_POINTER_BITMAPS const gctools::Container_layout& container_layout = *stamp_layout.container_layout; +#endif size_t capacity = std::abs(*(int64_t*)((const char*)client + stamp_layout.capacity_offset)); size = stamp_layout.element_size*capacity + stamp_layout.data_offset; if (stamp_wtag == gctools::STAMPWTAG_core__SimpleBaseString_O) size = size + 1; // Add \0 for SimpleBaseString @@ -249,7 +254,6 @@ RESULT_TYPE OBJECT_SCAN(SCAN_STRUCT_T ss, ADDR_T client, ADDR_T limit EXTRA_A #ifdef OBJECT_SKIP ADDR_T OBJECT_SKIP(ADDR_T client,bool dbg, size_t& obj_size) { - ADDR_T oldClient = client; const gctools::Header_s* header_ptr = reinterpret_cast(GENERAL_PTR_TO_HEADER_PTR(client)); const gctools::Header_s& header = *header_ptr; const gctools::Header_s::BadgeStampWtagMtag& header_value = header._badge_stamp_wtag_mtag; @@ -327,7 +331,6 @@ ADDR_T OBJECT_SKIP(ADDR_T client,bool dbg, size_t& obj_size) { } { gctools::Container_layout* container_layoutP = stamp_layout.container_layout; - gctools::Container_layout** vvv = &container_layoutP; if ( container_layoutP ) { #ifdef DEBUG_ON if (dbg) {LOG("container_layout\n");} @@ -337,7 +340,6 @@ ADDR_T OBJECT_SKIP(ADDR_T client,bool dbg, size_t& obj_size) { llvmo::ObjectFile_O* code = (llvmo::ObjectFile_O*)client; obj_size = gctools::AlignUp(llvmo::ObjectFile_O::sizeofInState(code,code->_State)); } else { - gctools::Container_layout& container_layout = *container_layoutP; // For bignums we allow the _MaybeSignedLength(capacity) to be a negative value to represent negative bignums // because GMP only stores positive bignums. So the value at stamp_layout.capacity_offset is a signed int64_t // Because of this we need to take the absolute value to get the number of entries. @@ -449,7 +451,6 @@ struct GC_ms_entry* Lisp_object_mark(GC_word addr, if (header._badge_stamp_wtag_mtag._header_badge == 0 ) return msp; // If addr points to unused object residing on a free list then second word is zero (void)ENSURE_VALID_HEADER((void*)addr); void* client = (char*)addr + sizeof(gctools::Header_s); - const gctools::Header_s::BadgeStampWtagMtag& header_value = header._badge_stamp_wtag_mtag; size_t stamp_index = header._badge_stamp_wtag_mtag.stamp_(); #ifdef DEBUG_GUARD_VALIDATE const gctools::Stamp_info& stamp_info = gctools::global_stamp_info[stamp_index]; @@ -462,8 +463,6 @@ struct GC_ms_entry* Lisp_object_mark(GC_word addr, #ifdef DEBUG_GUARD_VALIDATE const gctools::Field_info* field_info_cur = stamp_info.field_info_ptr; #endif - gctools::tagged_stamp_t mtag = header_value.mtag(); - gctools::GCStampEnum stamp_wtag = header._badge_stamp_wtag_mtag.stamp_wtag(); const gctools::Stamp_layout& stamp_layout = gctools::global_stamp_layout[stamp_index]; int num_fields = stamp_layout.number_of_fields; const gctools::Field_layout* field_layout_cur = stamp_layout.field_layout_start; @@ -503,7 +502,6 @@ struct GC_ms_entry* class_mark(GC_word addr, if (header._badge_stamp_wtag_mtag._value == 0 ) return msp; (void)ENSURE_VALID_HEADER((void*)addr); void* client = (char*)addr + sizeof(gctools::Header_s); - const gctools::Header_s::BadgeStampWtagMtag& header_value = header._badge_stamp_wtag_mtag; size_t stamp_index = header._badge_stamp_wtag_mtag.stamp_(); #ifdef DEBUG_OBJECT_SCAN const gctools::Stamp_info& stamp_info = gctools::global_stamp_info[stamp_index]; @@ -512,10 +510,7 @@ struct GC_ms_entry* class_mark(GC_word addr, } const gctools::Field_info* field_info_cur = stamp_info.field_info_ptr; #endif - gctools::tagged_stamp_t mtag = header_value.mtag(); - gctools::GCStampEnum stamp_wtag = header._badge_stamp_wtag_mtag.stamp_wtag(); const gctools::Stamp_layout& stamp_layout = gctools::global_stamp_layout[stamp_index]; - int idx = 0; uintptr_t pointer_bitmap = stamp_layout.boehm._class_bitmap; #ifdef DEBUG_POINTER_BITMAPS const gctools::Field_layout* field_layout_cur = stamp_layout.field_layout_start; diff --git a/src/gctools/snapshotSaveLoad.cc b/src/gctools/snapshotSaveLoad.cc index 0e06bb2197..27bf6c83a1 100644 --- a/src/gctools/snapshotSaveLoad.cc +++ b/src/gctools/snapshotSaveLoad.cc @@ -106,13 +106,11 @@ bool loadLibrarySymbolLookup(const std::string& filename, LibraryLookup& library } #define BUFLEN 2048 int baddigit = 0; - size_t lineno = 0; struct stat buf; if (stat(filename.c_str(),&buf)!=0) { return false; } stringstream nm_cmd; - uintptr_t textRegionStart = 0; bool gotSearchSymbol = false; std::string searchSymbol; uintptr_t searchAddress = 0; @@ -127,7 +125,6 @@ bool loadLibrarySymbolLookup(const std::string& filename, LibraryLookup& library gctools::clasp_ptr_t start; gctools::clasp_ptr_t end; core::executableTextSectionRange( start, end ); - textRegionStart = (uintptr_t)start; nm_cmd << NM_BINARY << " -p --defined-only \"" << filename << "\""; #else #error "Handle other operating systems - how is main found using dlsym and in the output of nm" @@ -146,8 +143,6 @@ bool loadLibrarySymbolLookup(const std::string& filename, LibraryLookup& library char name[BUFLEN+1]; const char* version; size_t lineno = 0; - char prev_type = '\0'; - uintptr_t prev_real_address; std::string prev_sname; uintptr_t highest_code_address(0); uintptr_t lowest_other_address(~0); @@ -602,7 +597,6 @@ uintptr_t encodeEntryPointOffset( uintptr_t address, uintptr_t codeStart, uintpt void encodeEntryPointInLibrary(Fixup* fixup, uintptr_t* ptrptr) { size_t libraryIndex = fixup->ensureLibraryRegistered(*ptrptr); - uintptr_t val = *ptrptr; fixup->registerFunctionPointer(libraryIndex,ptrptr); } @@ -686,10 +680,8 @@ void decodeEntryPoint(Fixup* fixup, uintptr_t* ptrptr, core::T_sp codebase) { decodeEntryPointInLibrary( fixup, ptrptr ); } } else if (gc::IsA(codebase)) { - llvmo::Library_sp library = gc::As_unsafe(codebase); decodeEntryPointInLibrary(fixup,ptrptr); } else if (gc::IsA(codebase)) { - llvmo::Library_sp library = gc::As_unsafe(codebase); decodeEntryPointInLibrary(fixup,ptrptr); } else { SIMPLE_ERROR(("The codebase must be a Code_sp or a Library_sp it is %s") , _rep_(codebase) ); @@ -995,18 +987,20 @@ gctools::clasp_ptr_t maybe_follow_forwarding_pointer(gctools::clasp_ptr_t* clien #include "obj_scan.cc" #undef OBJECT_SKIP +/* +// Forwarding pointers are unused for now. #define OBJECT_SKIP_IN_OBJECT_FWD isl_obj_skip #define OBJECT_FWD isl_obj_fwd #include "obj_scan.cc" #undef OBJECT_FWD - +*/ #define CONS_SCAN isl_cons_scan #define CONS_SKIP isl_cons_skip -#define CONS_FWD isl_cons_fwd -#define CONS_SKIP_IN_CONS_FWD isl_cons_skip +//#define CONS_FWD isl_cons_fwd +//#define CONS_SKIP_IN_CONS_FWD isl_cons_skip #include "cons_scan.cc" -#undef CONS_FWD +//#undef CONS_FWD #undef CONS_SKIP #undef CONS_SCAN @@ -1036,8 +1030,10 @@ gctools::clasp_ptr_t maybe_follow_forwarding_pointer(gctools::clasp_ptr_t* clien void followForwardingPointersForRoots(gctools::clasp_ptr_t* start, size_t number, void* user_data) { for ( size_t idx = 0; idx_global_JITDylibCounter = llvmo::global_JITDylibCounter.load(); this->_global_JITCompileCounter = core::core__get_jit_compile_counter(); }; @@ -1243,6 +1243,7 @@ void boehm_walker_callback(void* ptr, size_t sz, void* client_data) { if ( notFreeListPtr || secondWordNotZero ) { // If there is a non-zero header then walk it gctools::Header_s* header = (gctools::Header_s*)ptr; + (void)header; // sham DBG_SL_WALK_GC(BF("Walking to GC managed header %p %s\n") % (void*)header % header->description() ); walker->callback((gctools::Header_s*)ptr); } else { @@ -1328,7 +1329,7 @@ ISLHeader_s* ISLHeader_s::next(ISLKind k) const { } else if (k==Weak) { headerSize = sizeof(ISLWeakHeader_s); } else { - SIMPLE_ERROR(("Add support to calculate size of ISLKind %d") , k ); + SIMPLE_ERROR(("Add support to calculate size of ISLKind %d") , (int)k ); } return (ISLHeader_s*)((char*)this + headerSize + this->_Size); } @@ -1347,7 +1348,6 @@ gctools::BaseHeader_s::BadgeStampWtagMtag ISLHeader_s::stamp_wtag_mtag(ISLKind k gctools::ConsHeader_s* header = consCur->header(); return header->_badge_stamp_wtag_mtag; } else if (k==Weak) { - ISLWeakHeader_s* weakCur = (ISLWeakHeader_s*)this; gctools::Header_s* header = (gctools::Header_s*)((char*)this + offsetof(ISLWeakHeader_s,_Header)); return header->_badge_stamp_wtag_mtag; } @@ -1486,7 +1486,7 @@ struct calculate_size_t : public walker_callback_t { this->_ObjectFileTotalSize += objectFileSize; this->_TotalSize += sizeof(ISLGeneralHeader_s) + sizeof(llvmo::ObjectFile_O); } else { - size_t delta = isl_obj_skip(client,false,objectSize)-client; + isl_obj_skip(client,false,objectSize); // FIXME: Necessary? DBG_SL1(BF(" general header@%p value: 0x%x badge: 0x%x sz = %lu obj_skip = %lu\n") % header % header->_badge_stamp_wtag_mtag._value @@ -1506,7 +1506,7 @@ struct calculate_size_t : public walker_callback_t { this->_weak_count++; DBG_SL1(BF("weak object header %p client: %p\n") % (void*)header % (void*)client ); size_t objectSize; - gctools::clasp_ptr_t nextClient = isl_weak_skip(client,false,objectSize); + isl_weak_skip(client,false,objectSize); // nextClient this->_TotalSize += sizeof(ISLWeakHeader_s) + objectSize; } } @@ -1545,10 +1545,10 @@ struct copy_objects_t : public walker_callback_t { copy_buffer_t* _objectFiles; copy_objects_t( copy_buffer_t* objects, copy_buffer_t* objectFiles, ISLInfo* info) - : _objects(objects), - _objectFiles(objectFiles), + : walker_callback_t(info), + _objects(objects), _NumberOfObjects(0), - walker_callback_t(info) {}; + _objectFiles(objectFiles) {}; void callback(gctools::BaseHeader_s* header) { std::string str; @@ -1560,18 +1560,17 @@ struct copy_objects_t : public walker_callback_t { gctools::clasp_ptr_t clientStart = (gctools::clasp_ptr_t)HEADER_PTR_TO_GENERAL_PTR(header); if (header->_badge_stamp_wtag_mtag._value == DO_SHIFT_STAMP(gctools::STAMPWTAG_llvmo__ObjectFile_O)) { llvmo::ObjectFile_O* objectFile = (llvmo::ObjectFile_O*)clientStart; - size_t objectFileSize = objectFile->objectFileSizeAlignedUp(); DBG_OF( printf("%s:%d:%s Saving object file %p with badge 0x%0x name: %s\n", __FILE__, __LINE__, __FUNCTION__, objectFile, header->_badge_stamp_wtag_mtag._header_badge, _rep_(objectFile->_CodeName).c_str() ); printf("%s:%d:%s _ObjectId = %lu\n", __FILE__, __LINE__, __FUNCTION__, objectFile->_ObjectId ); printf("%s:%d:%s TheJITDylib = %p\n", __FILE__, __LINE__, __FUNCTION__, objectFile->_TheJITDylib.raw_() ); ); size_t generalSize; - gctools::clasp_ptr_t dummy = isl_obj_skip(clientStart,false,generalSize); + isl_obj_skip(clientStart,false,generalSize); if (generalSize==0) ISL_ERROR(fmt::sprintf("A zero size general at %p was encountered", (void*)clientStart )); llvmo::ObjectFile_O* code = (llvmo::ObjectFile_O*)clientStart; ISLGeneralHeader_s islheader( General, code->frontSize()+code->literalsSize(), (gctools::Header_s*)header ); - char* islh = this->_objects->write_buffer( (char*)&islheader , sizeof(ISLGeneralHeader_s)); + this->_objects->write_buffer( (char*)&islheader , sizeof(ISLGeneralHeader_s)); char* new_client = this->_objects->write_buffer((char*)clientStart, code->frontSize() ); llvmo::ObjectFile_O* newObjectFile = (llvmo::ObjectFile_O*)new_client; DBG_OF( @@ -1617,11 +1616,12 @@ struct copy_objects_t : public walker_callback_t { // Now write it into the buffer // size_t generalSize; - gctools::clasp_ptr_t dummy = isl_obj_skip(clientStart,false,generalSize); + isl_obj_skip(clientStart,false,generalSize); if (generalSize==0) ISL_ERROR(fmt::sprintf("A zero size general at %p was encountered", (void*)clientStart )); gctools::clasp_ptr_t clientEnd = clientStart + generalSize; ISLGeneralHeader_s islheader( General, clientEnd-clientStart, (gctools::Header_s*)header ); - char* islh = this->_objects->write_buffer( (char*)&islheader , sizeof(ISLGeneralHeader_s)); + char* islh = this->_objects->write_buffer( (char*)&islheader , sizeof(ISLGeneralHeader_s)); + (void)islh; char* new_client = this->_objects->write_buffer((char*)clientStart, clientEnd-clientStart); DBG_SAVECOPY(BF(" copied general header %p to %p - %p\n") % header % (void*)islh % (void*)this->_buffer ); set_forwarding_pointer(header, new_client, this->_info ); // This is a client pointer @@ -1635,8 +1635,10 @@ struct copy_objects_t : public walker_callback_t { if (consSize==0) ISL_ERROR(fmt::sprintf("A zero size cons at %p was encountered" , (void*)client )); ISLConsHeader_s islheader( Cons, sizeof(core::Cons_O), header->_badge_stamp_wtag_mtag ); char* islh = this->_objects->write_buffer( (char*)&islheader , sizeof(ISLConsHeader_s)); + (void)islh; char* new_addr = this->_objects->write_buffer((char*)client, consSize); core::Cons_O* cons = (core::Cons_O*)client; + (void)cons; set_forwarding_pointer(header, new_addr, this->_info ); DBG_SAVECOPY(BF(" copied cons header %p to %p - %p | CAR: %p CDR: %p\n") % header % (void*)islh % (void*)this->_buffer @@ -1646,11 +1648,12 @@ struct copy_objects_t : public walker_callback_t { // printf("%s:%d:%s weak_skip\n", __FILE__, __LINE__, __FUNCTION__ ); gctools::clasp_ptr_t clientStart = (gctools::clasp_ptr_t)HEADER_PTR_TO_WEAK_PTR(header); size_t weakSize; - gctools::clasp_ptr_t dummyNextClient = isl_weak_skip(clientStart,false,weakSize); + isl_weak_skip(clientStart,false,weakSize); if (weakSize==0) ISL_ERROR(fmt::sprintf("A zero size weak object at %p was encountered" , (void*)clientStart )); gctools::clasp_ptr_t clientEnd = clientStart + weakSize; ISLWeakHeader_s islheader( Weak, clientEnd-clientStart, (gctools::Header_s*)header ); - char* islh = this->_objects->write_buffer( (char*)&islheader , sizeof(ISLWeakHeader_s)); + char* islh = this->_objects->write_buffer( (char*)&islheader , sizeof(ISLWeakHeader_s)); + (void)islh; char* new_addr = this->_objects->write_buffer((char*)clientStart, clientEnd-clientStart); set_forwarding_pointer(header, new_addr, this->_info ); DBG_SAVECOPY(BF(" copied weak header %p to %p - %p\n") % header % (void*)islh % (void*)this->_buffer ); @@ -1682,6 +1685,7 @@ void walk_snapshot_save_load_objects( ISLHeader_s* start, Walker& walker) { walker.callback(header); } else if (cur->_Kind == Weak) { ISLWeakHeader_s* weakCur = (ISLWeakHeader_s*)cur; + (void)weakCur; gctools::Header_s* header = (gctools::Header_s*)((char*)cur + offsetof(ISLWeakHeader_s,_Header)); DBG_SL_WALK_SL(BF("weak header: %p %s next: %p\n") % header % header->description() % (void*)weakCur->next() ); walker.callback(header); @@ -1738,7 +1742,6 @@ struct fixup_internals_t : public walker_callback_t { void callback(gctools::BaseHeader_s* header) { if (header->_badge_stamp_wtag_mtag.stampP()) { - gctools::clasp_ptr_t client = (gctools::clasp_ptr_t)HEADER_PTR_TO_GENERAL_PTR(header); if (header->_badge_stamp_wtag_mtag._value == DO_SHIFT_STAMP(gctools::STAMPWTAG_gctools__GCVector_moveable_clbind__detail__edge_)) { // printf("%s:%d:%s load_snapshot saw STAMPWTAG_gctools__GCVector_moveable_clbind__detail__edge_\n", __FILE__, __LINE__, __FUNCTION__ ); gctools::GCVector_moveable* edges = (gctools::GCVector_moveable*)HEADER_PTR_TO_GENERAL_PTR(header); @@ -1791,7 +1794,6 @@ struct fixup_vtables_t : public walker_callback_t { } void callback(gctools::BaseHeader_s* header) { - uintptr_t new_vtable; if (header->_badge_stamp_wtag_mtag.stampP()) { if (header->preciseIsPolymorphic()) { uintptr_t client = (uintptr_t)HEADER_PTR_TO_GENERAL_PTR(header); @@ -2364,6 +2366,7 @@ void* snapshot_save_impl(void* data) { ISLEndHeader_s end_header( End ); char* endend = snapshot._Memory->write_buffer( (char*)&end_header , sizeof(end_header)); + (void)endend; DBG_SAVECOPY(BF(" copying END into buffer @ %p\n") % (void*)endend ); // @@ -2799,7 +2802,6 @@ void snapshot_load( void* maybeStartOfSnapshot, void* maybeEndOfSnapshot, const } } // When loading forwarding pointers must always forward into GC managed objects - size_t loadTimeID = 0; globalFwdMustBeInGCMemory = true; core::FunctionDescription_O funcdes; DBG_SL("1 FunctionDescription_O vtable pointer is: %p\n" , *(void**)&funcdes ); @@ -3223,6 +3225,7 @@ void snapshot_load( void* maybeStartOfSnapshot, void* maybeEndOfSnapshot, const loadedObjectFile->_MemoryBuffer.reset(); loadedObjectFile->_MemoryBuffer = std::move(memoryBuffer); llvmo::ObjectFile_O* oldCode = loadedObjectFile; // ->_Code; + (void)oldCode; // Allocate a new ObjectFile_O // // I don't think I should be allocating an ObjectFile here. @@ -3291,12 +3294,12 @@ void snapshot_load( void* maybeStartOfSnapshot, void* maybeEndOfSnapshot, const abort(); } core::T_mv startupName = core::core__startup_linkage_shutdown_names(allocatedObjectFile->_ObjectId,nil()); - core::String_sp str = gc::As(startupName); + (void)startupName; DBG_OF( printf("%s:%d:%s I added the ObjectFile to the LLJIT loadedObjectFile->_ObjectId = %lu startupName: %s --- JITDylib %p\n", __FILE__, __LINE__, __FUNCTION__, loadedObjectFile->_ObjectId, - core::_rep_(str).c_str(), jitdylib.raw_() ); + core::_rep_(startupName).c_str(), jitdylib.raw_() ); ); // // Everything after this will have to change when we do multicore startup. @@ -3309,6 +3312,7 @@ void snapshot_load( void* maybeStartOfSnapshot, void* maybeEndOfSnapshot, const core::startup_shutdown_names( objectId, "", start, shutdown ); void* ptr; bool found = obj_claspJIT->do_lookup( jitdylib, start, ptr ); + (void)found; DBG_OF( printf("%s:%d:%s Ran lookup of objectId: %lu name %s jitdylib %p in thread pool found = %d\n", __FILE__, __LINE__, __FUNCTION__, objectId, start.c_str(), jitdylib.raw_(), found ); ); @@ -3316,8 +3320,7 @@ void snapshot_load( void* maybeStartOfSnapshot, void* maybeEndOfSnapshot, const } } next_header = cur_header->next(cur_header->_Kind); - size_t size = cur_header->_Size; - DBG_SL1(BF("Done working with cur_header@%p advanced to %p where cur_header->_Size = %lu\n") % (void*)cur_header % (void*)next_header % size ); + DBG_SL1(BF("Done working with cur_header@%p advanced to %p where cur_header->_Size = %lu\n") % (void*)cur_header % (void*)next_header % cur_header->_Size ); cur_header = next_header; } pool.wait_for_tasks(); @@ -3455,7 +3458,6 @@ void snapshot_load( void* maybeStartOfSnapshot, void* maybeEndOfSnapshot, const } else if (cur_header->_Kind == Cons ) { ISLConsHeader_s* consHeader = (ISLConsHeader_s*)cur_header; gctools::clasp_ptr_t clientStart = (gctools::clasp_ptr_t)(consHeader+1); - gctools::clasp_ptr_t clientEnd = clientStart + sizeof(core::Cons_O); gctools::ConsHeader_s* header = consHeader->header(); core::Cons_O* cons = (core::Cons_O*)clientStart; auto obj = gctools::ConsAllocator::snapshot_save_load_allocate(header->_badge_stamp_wtag_mtag, cons->_Car.load(), cons->_Cdr.load()); @@ -3548,8 +3550,7 @@ void snapshot_load( void* maybeStartOfSnapshot, void* maybeEndOfSnapshot, const printf("%s:%d:%s Unknown header at offset 0x%lx qword: 0x%lx\n", __FILE__, __LINE__, __FUNCTION__, (uintptr_t)cur_header - (uintptr_t)fileHeader, *(uintptr_t*)cur_header ); } next_header = cur_header->next(cur_header->_Kind); - size_t size = cur_header->_Size; - DBG_SL1(BF("Done working with cur_header@%p advanced to %p where cur_header->_Size = %lu\n") % (void*)cur_header % (void*)next_header % size ); + DBG_SL1(BF("Done working with cur_header@%p advanced to %p where cur_header->_Size = %lu\n") % (void*)cur_header % (void*)next_header % cur_header->_Size ); cur_header = next_header; } } @@ -3561,8 +3562,7 @@ void snapshot_load( void* maybeStartOfSnapshot, void* maybeEndOfSnapshot, const } next_header = cur_header->next(cur_header->_Kind); - size_t size = cur_header->_Size; - DBG_SL1(BF("Done working with cur_header@%p advanced to %p where cur_header->_Size = %lu\n") % (void*)cur_header % (void*)next_header % size ); + DBG_SL1(BF("Done working with cur_header@%p advanced to %p where cur_header->_Size = %lu\n") % (void*)cur_header % (void*)next_header % cur_header->_Size ); cur_header = next_header; } } @@ -3609,7 +3609,6 @@ void snapshot_load( void* maybeStartOfSnapshot, void* maybeEndOfSnapshot, const newCodeClient, newCodeClient->literalsSize() ); abort(); } - uintptr_t oldCodeLiteralsStart = (uintptr_t)oldCodeClient->literalsStart(); uintptr_t newCodeLiteralsStart = (uintptr_t)newCodeClient->literalsStart(); uintptr_t newCodeLiteralsEnd = (uintptr_t)newCodeClient->literalsStart() + newCodeClient->literalsSize(); llvmo::CodeBlock_sp codeBlock = newCodeClient->_CodeBlock; @@ -3620,7 +3619,7 @@ void snapshot_load( void* maybeStartOfSnapshot, void* maybeEndOfSnapshot, const printf("%s:%d:%s\n" " oldCodeClient = %p oldCodeLiteralsStart = %p\n" " newCodeClient = %p newCodeLiteralsStart = %p\n", - __FILE__, __LINE__, __FUNCTION__, oldCodeClient, (void*)oldCodeLiteralsStart, + __FILE__, __LINE__, __FUNCTION__, oldCodeClient, (void*)oldCodeClient->literalsStart(), (void*)&*newCodeClient, (void*)newCodeLiteralsStart ); ); if (oldCodeClient->literalsSize() != 0 && @@ -3700,7 +3699,7 @@ void snapshot_load( void* maybeStartOfSnapshot, void* maybeEndOfSnapshot, const // Fixup the roots // { - gctools::clasp_ptr_t* lispRoot = (gctools::clasp_ptr_t*) ((char*)islbuffer + fileHeader->_LispRootOffset + sizeof(ISLRootHeader_s)); +// gctools::clasp_ptr_t* lispRoot = (gctools::clasp_ptr_t*) ((char*)islbuffer + fileHeader->_LispRootOffset + sizeof(ISLRootHeader_s)); // followForwardingPointersForRoots( lispRoot, fileHeader->_LispRootCount, (void*)&islInfo ); // copyRoots((uintptr_t*)&_lisp, (uintptr_t*)lispRoot, fileHeader->_LispRootCount ); gctools::clasp_ptr_t* symbolRoots = (gctools::clasp_ptr_t*) ((char*)islbuffer + fileHeader->_SymbolRootsOffset + sizeof(ISLRootHeader_s)); diff --git a/src/gctools/threadlocal.cc b/src/gctools/threadlocal.cc index 48c7dd5777..e0380502c2 100644 --- a/src/gctools/threadlocal.cc +++ b/src/gctools/threadlocal.cc @@ -137,8 +137,7 @@ bool DynamicBindingStack::thread_local_boundp(int32_t index) const { namespace gctools { ThreadLocalStateLowLevel::ThreadLocalStateLowLevel(void* stack_top) : - _DisableInterrupts(false) - , _StackTop(stack_top) + _StackTop(stack_top), _DisableInterrupts(false) #ifdef DEBUG_RECURSIVE_ALLOCATIONS , _RecursiveAllocationCounter(0) #endif @@ -213,16 +212,16 @@ VirtualMachine::~VirtualMachine() { // ThreadLocalState::finish_initialization_main_thread() after the Nil symbol is // in GC managed memory. ThreadLocalState::ThreadLocalState(bool dummy) : - _unwinds(0) - ,_CleanupFunctions(NULL) + _ObjectFiles() ,_PendingInterrupts() - ,_ObjectFiles() ,_BufferStr8NsPool() ,_BufferStrWNsPool() + ,_unwinds(0) ,_Breakstep(false) ,_BreakstepFrame(NULL) ,_DynEnvStackBottom() ,_UnwindDest() + ,_CleanupFunctions(NULL) ,_DtreeInterpreterCallCount(0) { my_thread = this; @@ -289,14 +288,14 @@ void ThreadLocalState::finish_initialization_main_thread(core::T_sp theNilObject // This is for constructing ThreadLocalState for threads ThreadLocalState::ThreadLocalState() : - _unwinds(0) + _ObjectFiles(nil()) , _PendingInterrupts(nil()) - , _ObjectFiles(nil()) - , _CleanupFunctions(NULL) + , _unwinds(0) , _Breakstep(false) , _BreakstepFrame(NULL) , _DynEnvStackBottom(nil()) , _UnwindDest(nil()) + , _CleanupFunctions(NULL) { my_thread = this; #ifdef _TARGET_OS_DARWIN diff --git a/src/koga/configure.lisp b/src/koga/configure.lisp index 3606878f01..4dff7cb649 100644 --- a/src/koga/configure.lisp +++ b/src/koga/configure.lisp @@ -909,6 +909,7 @@ the function to the overall configuration." (uiop:version<= max-version version)) (failure "Module ~a with a version of ~a is not less then maximum version of ~a." library version max-version)) (t + (message nil "Found library ~a with a version of ~a." library version) (apply #'append-cflags configuration (run-program-capture (list (pkg-config configuration) "--cflags" library)) rest) diff --git a/src/koga/units.lisp b/src/koga/units.lisp index da6b07ea19..dbaf3ed0b3 100644 --- a/src/koga/units.lisp +++ b/src/koga/units.lisp @@ -178,12 +178,25 @@ (defmethod configure-unit (configuration (unit (eql :base))) "Add base cflags and ldflags." (message :emph "Configuring base") + ;; Some explanation as to the warnings we allow: + ;; invalid-offsetof means we use offsetof on non-standard-layout classes. + ;; This is I think required for precise GC, and should be okay since we're + ;; clang-only and clang lets us do this. + ;; mismatched-tags means we sometimes declare classes in one place with + ;; "struct" and some with "class". This is okay in C++, but the Microsoft + ;; ABI apparently mangles names differently for some ungodly reason. + ;; To keep things consistent we'd probably have to track struct vs. class + ;; in the scraper codegen. + ;; deprecated-(anon-)enum-enum-conversion is triggered by Clang's own + ;; headers for the time being. This conversion is only deprecated as of + ;; C++20, so clang has probably just not kept up. + ;; The othere warnings I'm not sure about. (append-cflags configuration - (format nil "-Wno-macro-redefined -Wno-deprecated-declarations ~ --Wno-deprecated-register -Wno-expansion-to-defined -Wno-return-type-c-linkage ~ --Wno-invalid-offsetof -Wno-#pragma-messages -Wno-inconsistent-missing-override ~ --Wno-error=c++11-narrowing -Wno-c++11-narrowing -Wno-deprecated-enum-enum-conversion ~ --Wno-deprecated-anon-enum-enum-conversion")) + (format nil "-Wall -Wno-return-type-c-linkage ~ +-Wno-invalid-offsetof -Wno-inconsistent-missing-override ~ +-Wno-mismatched-tags -Wno-overloaded-virtual ~ +-Wno-deprecated-enum-enum-conversion -Wno-deprecated-anon-enum-enum-conversion ~ +-Wno-delete-non-abstract-non-virtual-dtor")) (loop for variant in (variants configuration) do (append-cflags variant (format nil "-I~a" (variant-bitcode-name variant))) (append-cflags variant (format nil "-I~a/generated" (variant-bitcode-name variant)))) diff --git a/src/llvmo/code.cc b/src/llvmo/code.cc index c65d04e93a..863edf5e33 100644 --- a/src/llvmo/code.cc +++ b/src/llvmo/code.cc @@ -49,7 +49,6 @@ void JITMemoryReadWriteMaybeExecute(llvm::jitlink::BasicLayout& BL) { size_t PageSize = getpagesize(); auto rwxProt = llvm::sys::Memory::MF_READ | llvm::sys::Memory::MF_WRITE | llvm::sys::Memory::MF_EXEC; for (auto &KV : BL.segments()) { - const auto &AG = KV.first; auto &Seg = KV.second; uint64_t SegSize = alignTo(Seg.ContentSize + Seg.ZeroFillSize, PageSize ); @@ -487,7 +486,6 @@ CL_DEFUN core::T_mv object_file_for_instruction_pointer(void* instruction_pointe { DEBUG_OBJECT_FILES_PRINT(("%s:%d:%s entered looking for instruction_pointer@%p search Code_O objects\n", __FILE__, __LINE__, __FUNCTION__, instruction_pointer )); core::T_sp cur = _lisp->_Roots._AllObjectFiles.load(); - size_t count; DEBUG_OBJECT_FILES_PRINT(("%s:%d:%s instruction_pointer = %p object_files = %p\n", __FILE__, __LINE__, __FUNCTION__, (char*)instruction_pointer, cur.raw_())); if ((cur.nilp()) && verbose){ core::write_bf_stream(fmt::sprintf("No object files registered - cannot find object file for address %p\n" , (void*)instruction_pointer)); @@ -501,7 +499,6 @@ CL_DEFUN core::T_mv object_file_for_instruction_pointer(void* instruction_pointe return Values(sectionedAddress,ofi); } cur = CONS_CDR(gc::As_unsafe(cur)); - count++; } return Values(nil()); } @@ -613,7 +610,6 @@ CL_DEFUN void ext__generate_perf_map() { FILE* fout = fopen(ss.str().c_str(),"w"); jit_code_entry* jce = __jit_debug_descriptor.first_entry; ql::list ll; - size_t idx; while (jce) { const char* of_start = jce->symfile_addr; size_t of_length = jce->symfile_size; @@ -713,6 +709,7 @@ bool CodeBlock_O::calculate(BasicLayout& BL) { base = this->calculateHead( SegmentSize, Seg.Alignment.value(), headOffset); allocKind = "head"; } + (void)allocKind; // sham use DEBUG_OBJECT_FILES_PRINT(("%s:%d:%s calculated %s from the base = %p - %p = %lu bytes \n", __FILE__, __LINE__, __FUNCTION__, allocKind, base, (void*)((uintptr_t)base+SegmentSize), SegmentSize )); Seg.Addr = (llvm::orc::ExecutorAddr)(uintptr_t)base; Seg.WorkingMem = jitTargetAddressToPointer((llvm::JITTargetAddress)base); @@ -782,7 +779,6 @@ size_t countObjectFileNames(const std::string& name) { }; CL_DEFUN core::T_sp llvm_sys__allObjectFileNames() { - size_t count = 0; core::T_sp result = nil(); core::T_sp cur = _lisp->_Roots._AllObjectFiles.load(); while ( cur.consp() ) { diff --git a/src/llvmo/debugInfoExpose.cc b/src/llvmo/debugInfoExpose.cc index aa915efad8..c3018d4750 100644 --- a/src/llvmo/debugInfoExpose.cc +++ b/src/llvmo/debugInfoExpose.cc @@ -542,7 +542,7 @@ CL_DEFUN DWARFContext_sp DWARFContext_O::createDWARFContext(ObjectFile_sp ofi) { return core::RP_Create_wrapped(uptr.release()); } SIMPLE_ERROR(("Could not get ObjectFile:\n%s") - , llvm::toString(std::move(errOrObj.takeError()))); + , llvm::toString(errOrObj.takeError())); } CL_DEFMETHOD size_t DWARFContext_O::getNumCompileUnits() const { diff --git a/src/llvmo/intrinsics.cc b/src/llvmo/intrinsics.cc index eea896a15b..27ecc0d8c7 100644 --- a/src/llvmo/intrinsics.cc +++ b/src/llvmo/intrinsics.cc @@ -140,9 +140,9 @@ ALWAYS_INLINE core::T_O *cc_stack_enclose(void* closure_address, ASSERT(((uintptr_t)(closure_address)&0x7)==0); // gctools::Header_s* header = reinterpret_cast(closure_address); const gctools::Header_s::BadgeStampWtagMtag closure_header = gctools::Header_s::BadgeStampWtagMtag::make(gctools::lisp_stack_badge()); +#ifdef DEBUG_GUARD size_t size = gctools::sizeof_container_with_header(numCells); // gctools::global_stack_closure_bytes_allocated += size; -#ifdef DEBUG_GUARD new (header) gctools::GCHeader::HeaderType(closure_header,size,0,size); #else new (header) gctools::GCHeader::HeaderType(closure_header); diff --git a/src/llvmo/link_intrinsics.cc b/src/llvmo/link_intrinsics.cc index eac38c0040..83c1bcc3b7 100644 --- a/src/llvmo/link_intrinsics.cc +++ b/src/llvmo/link_intrinsics.cc @@ -121,7 +121,7 @@ namespace llvmo { SIMPLE_ERROR(("The object with pointer %p is not a cell") , (void*)arg0.raw_()); } default: - SIMPLE_ERROR(("An intrinsicError %d was signaled and there needs to be a more descriptive error message for it in gctools::intrinsic_error arg0: %s arg1: %s arg2: %s") , err , _rep_(arg0) , _rep_(arg1) , _rep_(arg2)); + SIMPLE_ERROR(("An intrinsicError %d was signaled and there needs to be a more descriptive error message for it in gctools::intrinsic_error arg0: %s arg1: %s arg2: %s") , (int)err , _rep_(arg0) , _rep_(arg1) , _rep_(arg2)); }; }; @@ -490,7 +490,7 @@ LtvcReturnVoid ltvc_set_mlf_creator_funcall(gctools::GCRootsInModule* holder, ch LtvcReturnVoid ltvc_mlf_init_funcall(gctools::GCRootsInModule* holder, size_t simpleFunIndex, const char* name) { // printf("%s:%d:%s make entry-point-index got simpleFunIndex %lu name: %s\n", __FILE__, __LINE__, __FUNCTION__, simpleFunIndex, name ); core::GlobalSimpleFun_sp ep((gctools::Tagged)holder->getLiteral(simpleFunIndex)); - LCC_RETURN ret = ep->entry()(ep.raw_(),0,NULL); + ep->entry()(ep.raw_(),0,NULL); } // Similar to the above, but puts value in the table. @@ -510,7 +510,7 @@ LtvcReturnVoid ltvc_toplevel_funcall(gctools::GCRootsInModule* holder, size_t si #ifdef DEBUG_SLOW MaybeDebugStartup startup((void*)ep->_EntryPoints[1],name); #endif - LCC_RETURN ret = ep->entry()(ep.raw_(),0,NULL); + ep->entry()(ep.raw_(),0,NULL); } }; diff --git a/src/llvmo/llvmoExpose.cc b/src/llvmo/llvmoExpose.cc index fffa1f5a2d..f430a0dc70 100644 --- a/src/llvmo/llvmoExpose.cc +++ b/src/llvmo/llvmoExpose.cc @@ -450,7 +450,7 @@ CL_DEFUN core::T_mv llvm_sys__linkModules(Module_sp linkedModule, Module_sp modu // Take ownership of the pointer and give it to the linker llvm::Module* linkedModulePtr = linkedModule->wrappedPtr(); llvm::Module* mptr = module->wrappedPtr(); - llvm::LLVMContext &Ctx = mptr->getContext(); +// llvm::LLVMContext &Ctx = mptr->getContext(); module->reset_wrappedPtr(); std::unique_ptr u_module(mptr); // Ctx.setDiagnosticHandler(std::make_unique(), true); @@ -536,6 +536,7 @@ CL_DEFUN void llvm_sys__dump_instruction_list(BasicBlock_sp cbb) } } +// FIXME: Delete this, probably? What is it supposed to do? DOCGROUP(clasp); CL_DEFUN void llvm_sys__sanity_check_module(Module_sp module, int depth) { @@ -547,7 +548,7 @@ CL_DEFUN void llvm_sys__sanity_check_module(Module_sp module, int depth) for ( auto &B : F ) { if (depth > 1) { for ( auto &I : B ) - /*nothing*/; + (void)I/*nothing*/; } } } @@ -610,10 +611,8 @@ CL_DEFMETHOD core::T_sp TargetMachine_O::addPassesToEmitFileAndRunPassManager(Pa } Safe_raw_pwrite_stream ostream; llvm::SmallString<1024> stringOutput; - bool stringOutputStream = false; if (core::StringOutputStream_sp sos = stream.asOrNull()) { ostream.set_stream(new llvm::raw_svector_ostream(stringOutput)); - stringOutputStream = true; } else if ( stream == kw::_sym_simple_vector_byte8 ) { (void)sos; ostream.set_stream(new llvm::raw_svector_ostream(stringOutput)); @@ -627,11 +626,9 @@ CL_DEFMETHOD core::T_sp TargetMachine_O::addPassesToEmitFileAndRunPassManager(Pa } llvm::SmallString<1024> dwo_stringOutput; Safe_raw_pwrite_stream dwo_ostream; - bool dwo_stringOutputStream = false; if (core::StringOutputStream_sp sos = dwo_stream.asOrNull()) { (void)sos; dwo_ostream.set_stream(new llvm::raw_svector_ostream(dwo_stringOutput)); - dwo_stringOutputStream = true; } else if (core::IOFileStream_sp fs = dwo_stream.asOrNull()) { dwo_ostream.set_stream(new llvm::raw_fd_ostream(fs->fileDescriptor(), false, true)); } else if (core::IOStreamStream_sp iostr = dwo_stream.asOrNull()) { @@ -1198,7 +1195,7 @@ CL_DEFUN Module_sp llvm_sys__parseBitcodeFile(core::T_sp tfilename, LLVMContext_ if (!eom) SIMPLE_ERROR(("Could not parse bitcode for file %s - there was an error\n%s") , spathname->get_std_string() - , llvm::toString(std::move(eom.takeError()))); + , llvm::toString(eom.takeError())); Module_sp omodule = core::RP_Create_wrapped((*eom).release()); return omodule; }; @@ -1373,7 +1370,6 @@ CL_DEFUN bool llvm_sys__valid(core::T_sp value) { namespace llvmo { void convert_sequence_types_to_vector(core::T_sp elements, vector &velements) { - core::T_sp save_elements = elements; if (elements.nilp()) { return; } else if (core::Cons_sp celements = elements.asOrNull()) { @@ -1517,7 +1513,6 @@ CL_DEFMETHOD void Module_O::moduleDelete() { CL_LISPIFY_NAME("dump_namedMDList"); CL_DEFMETHOD void Module_O::dump_namedMDList() const { - llvm::Module *M = this->wrappedPtr(); IMPLEMENT_MEF("Come up with a way to dump the MDList without using dump() (only enabled when LLVM_ENABLE_DUMP is on)"); } @@ -1684,10 +1679,6 @@ CL_EXTERN_DEFMETHOD(ExecutionEngine_O, &llvm::ExecutionEngine::getOrEmitGlobalVa namespace llvmo { -CL_DEFMETHOD llvm::Type* PointerType_O::getElementType() const { - return dyn_cast(this->wrappedPtr())->getElementType(); -} - CL_DEFUN bool llvm_sys__isOpaqueOrPointeeTypeMatches(Type_sp ptrType, Type_sp ty) { return dyn_cast(ptrType->wrappedPtr())->isOpaqueOrPointeeTypeMatches(ty->wrappedPtr()); } @@ -1724,7 +1715,6 @@ CL_EXTERN_DEFMETHOD(DataLayout_O,&llvm::DataLayout::getStringRepresentation); CL_LISPIFY_NAME(struct-layout-get-element-offset); CL_DEFMETHOD size_t StructLayout_O::getElementOffset(size_t idx) const { - size_t offset = this->_StructLayout->getElementOffset(idx); return this->_StructLayout->getElementOffset(idx); } @@ -2058,11 +2048,11 @@ CL_DEFUN core::T_mv llvm_sys__getDebugLocInfo(Instruction_sp instr) { } return Values(nil()); } -CL_DOCSTRING(R"dx(Erase the instruction from its parent basic block and return the next instruction or NIL)dx"); +CL_DOCSTRING(R"dx(Erase the instruction from its parent basic block.)dx"); DOCGROUP(clasp); CL_DEFUN void llvm_sys__instruction_eraseFromParent(Instruction_sp instr) { - llvm::SymbolTableList::iterator next = instr->wrappedPtr()->eraseFromParent(); + instr->wrappedPtr()->eraseFromParent(); } CL_DOCSTRING(R"dx(Return the next non-debug instruction or NIL if there is none)dx"); @@ -2464,14 +2454,12 @@ DOCGROUP(clasp); CL_DEFUN APInt_sp APInt_O::makeAPIntWidth(core::Integer_sp value, uint width, bool sign) { auto self = gctools::GC::allocate_with_default_constructor(); llvm::APInt apint; - int numbits; if (value.fixnump()) { Fixnum fixnum_value = value.unsafe_fixnum(); if (!sign && fixnum_value < 0) { SIMPLE_ERROR(("You tried to create an unsigned APInt32 with the negative value: %d") , fixnum_value); } apint = llvm::APInt(width, fixnum_value, sign); - numbits = gc::fixnum_bits; } else { // bignum // TODO: use As_unsafe core::Bignum_sp bignum_value = gc::As(value); @@ -3425,7 +3413,6 @@ CL_DEFMETHOD BasicBlock_sp Function_O::getEntryBlock() const { CL_LISPIFY_NAME("basic-blocks"); CL_DEFMETHOD core::List_sp Function_O::basic_blocks() const { - llvm::Function::BasicBlockListType& Blocks = this->wrappedPtr()->getBasicBlockList(); ql::list result; for (llvm::Function::iterator b = this->wrappedPtr()->begin(), be = this->wrappedPtr()->end(); b != be; ++b) { llvm::BasicBlock& BB = *b; @@ -4499,7 +4486,6 @@ std::shared_ptr optimizeModule(std::shared_ptr M) { // by clang before we need them. llvm::GlobalVariable* used = M->getGlobalVariable("llvm.used"); if (used) { - Value* init = used->getInitializer(); used->eraseFromParent(); } @@ -4657,7 +4643,7 @@ std::string SectionedAddress_O::__repr__() const { void python_dump_field(std::ostream& fout, const char* name, bool comma, gctools::Data_types dt, size_t offset, size_t sz=0) { if (comma) fmt::print(fout, ","); - fmt::print(fout, "[ \"{}\", {}, {}, {} ]\n", name, dt, offset, sz ); + fmt::print(fout, "[ \"{}\", {}, {}, {} ]\n", name, (int)dt, offset, sz ); } void dump_objects_for_debugger(std::ostream& fout,std::string indent) diff --git a/src/llvmo/llvmoPackage.cc b/src/llvmo/llvmoPackage.cc index 5e14f76ff1..c2fb9edf4e 100644 --- a/src/llvmo/llvmoPackage.cc +++ b/src/llvmo/llvmoPackage.cc @@ -146,8 +146,7 @@ JITDylib_sp loadModule(llvmo::Module_sp module, size_t startupID, const std::str // printf("%s:%d ptr->%p\n", __FILE__, __LINE__, startup); (startup)(); } - size_t num = core::startup_functions_are_waiting(); -// printf("%s:%d There are %lu startup functions waiting to be evaluated\n", __FILE__, __LINE__, num); +// printf("%s:%d There are %lu startup functions waiting to be evaluated\n", __FILE__, __LINE__, core::startup_functions_are_waiting()); core::startup_functions_invoke(NULL); // printf("%s:%d Invoked startup functions - continuing\n", __FILE__, __LINE__ ); return jitDylib; @@ -342,7 +341,6 @@ CL_DEFUN core::T_sp llvm_sys__cxxDataStructuresInfo() { ENTRY(list, "ENTRY-POINT-ARITY-BEGIN",make_fixnum(ENTRY_POINT_ARITY_BEGIN)); ENTRY(list, "ENTRY-POINT-ARITY-END",make_fixnum(ENTRY_POINT_ARITY_END)); ENTRY(list, "NUMBER-OF-ENTRY-POINTS",make_fixnum(NUMBER_OF_ENTRY_POINTS)); - ENTRY(list, "ENDIAN-LSB-OFFSET", make_fixnum(ENDIAN_LSB_OFFSET) ); ENTRY(list, "UNBOUND-MASK", make_fixnum(UNBOUND_MASK) ); ENTRY(list, "UNBOUND-BYTE", make_fixnum(UNBOUND_BYTE) ); return list; diff --git a/src/llvmo/runtimeJit.cc b/src/llvmo/runtimeJit.cc index 713b81274b..f6a2791aac 100644 --- a/src/llvmo/runtimeJit.cc +++ b/src/llvmo/runtimeJit.cc @@ -228,7 +228,6 @@ class ClaspAllocator : public JITLinkMemoryManager { } private: Error applyProtections() { - size_t PageSize = getpagesize(); JITMemoryReadExecute(BL); return Error::success(); } @@ -242,6 +241,7 @@ class ClaspAllocator : public JITLinkMemoryManager { BasicLayout BL(G); size_t segmentCount = 0; for ( auto& KV : BL.segments() ) { + (void)KV; segmentCount++; } @@ -282,12 +282,10 @@ class ClaspAllocator : public JITLinkMemoryManager { #endif DEBUG_OBJECT_FILES_PRINT(("%s:%d:%s allocating JD = %p \n", __FILE__, __LINE__, __FUNCTION__, JD )); ObjectFile_sp codeObject; - size_t objectId = objectIdFromName(G.getName()); - DEBUG_OBJECT_FILES_PRINT(("%s:%d:%s About to allocate ObjectFile_sp with name %s objectId = %lu\n", __FILE__, __LINE__, __FUNCTION__, G.getName().c_str(), objectId )); + DEBUG_OBJECT_FILES_PRINT(("%s:%d:%s About to allocate ObjectFile_sp with name %s objectId = %lu\n", __FILE__, __LINE__, __FUNCTION__, G.getName().c_str(), objectIdFromName(G.getName()) )); codeObject = lookupObjectFile(G.getName()); codeObject->_CodeBlock = codeBlock; - core::SimpleBaseString_sp codeName = createSimpleBaseStringForStage(G.getName()); - DEBUG_OBJECT_FILES_PRINT(("%s:%d:%s looked up codeObject = %p with name: %s\n", __FILE__, __LINE__, __FUNCTION__, &*codeObject, _rep_(codeName).c_str() )); + DEBUG_OBJECT_FILES_PRINT(("%s:%d:%s looked up codeObject = %p with name: %s\n", __FILE__, __LINE__, __FUNCTION__, &*codeObject, _rep_(createSimpleBaseStringForStage(G.getName())).c_str() )); } else { for ( auto& KV : BL.segments() ) { #ifdef DEBUG_OBJECT_FILES @@ -350,7 +348,7 @@ class ClaspPlugin : public llvm::orc::ObjectLinkingLayer::Plugin { MR.getTargetJITDylib().getExecutionSession().intern("DW.ref.__gxx_personality_v0"); if (!MR.getSymbols().count(PersonalitySymbol)) Config.PrePrunePasses.insert( Config.PrePrunePasses.begin(), - [this](jitlink::LinkGraph&G) -> Error { + [](jitlink::LinkGraph&G) -> Error { for (auto ssym : G.defined_symbols()) { if (ssym->getName() == "DW.ref.__gxx_personality_v0") { DEBUG_OBJECT_FILES_PRINT(("%s:%d:%s PrePrunePass found DW.ref.__gxx_personality_v0 setting Strong Linkage and Local scope\n", __FILE__, __LINE__, __FUNCTION__ )); @@ -362,7 +360,7 @@ class ClaspPlugin : public llvm::orc::ObjectLinkingLayer::Plugin { return Error::success(); }); Config.PrePrunePasses.push_back( - [this](jitlink::LinkGraph &G) -> Error { + [](jitlink::LinkGraph &G) -> Error { size_t count = 0; for (auto &Sec : G.sections()) { if (Sec.getName() == EH_FRAME_NAME ) @@ -455,7 +453,6 @@ class ClaspPlugin : public llvm::orc::ObjectLinkingLayer::Plugin { DEBUG_OBJECT_FILES_PRINT(("%s:%d:%s Entered with G.getName() = %s\n", __FILE__, __LINE__, __FUNCTION__, G.getName().c_str() )); uintptr_t textStart = ~0; uintptr_t textEnd = 0; - bool gotGcroots = false; ObjectFile_sp currentCode = lookupObjectFile(G.getName()); DEBUG_OBJECT_FILES_PRINT(("%s:%d:%s currentCode: %p\n", __FILE__, __LINE__, __FUNCTION__, &*currentCode )); for (auto &S : G.sections()) { @@ -467,9 +464,7 @@ class ClaspPlugin : public llvm::orc::ObjectLinkingLayer::Plugin { llvm::jitlink::SectionRange range(S); for ( auto& sym : S.symbols() ) { std::string name = sym->getName().str(); - void* address = (void*)sym->getAddress().getValue(); - size_t size = sym->getSize(); - DEBUG_OBJECT_FILES_PRINT(("%s:%d:%s section: %s symbol: %s at %p size: %lu\n", __FILE__, __LINE__, __FUNCTION__, S.getName().str().c_str(), name.c_str(), address, size)); + DEBUG_OBJECT_FILES_PRINT(("%s:%d:%s section: %s symbol: %s at %p size: %lu\n", __FILE__, __LINE__, __FUNCTION__, S.getName().str().c_str(), name.c_str(), (void*)sym->getAddress().getValue(), sym->getSize)); } } #if 0 @@ -510,9 +505,7 @@ class ClaspPlugin : public llvm::orc::ObjectLinkingLayer::Plugin { } } else if (sectionName.find(EH_FRAME_NAME)!=string::npos) { llvm::jitlink::SectionRange range(S); - void* start = (void*)range.getStart().getValue(); - uintptr_t size = range.getSize(); - DEBUG_OBJECT_FILES_PRINT(("%s:%d:%s eh_frame section segment_start = %p segment_size = %lu\n", __FILE__, __LINE__, __FUNCTION__, start, size )); + DEBUG_OBJECT_FILES_PRINT(("%s:%d:%s eh_frame section segment_start = %p segment_size = %lu\n", __FILE__, __LINE__, __FUNCTION__, (void*)range.getStart().getValue(), range.getSize() )); } else if (sectionName.find(STACKMAPS_NAME)!=string::npos) { DEBUG_OBJECT_FILES_PRINT(("%s:%d:%s Saving stackmaps range currentCode %s\n", __FILE__, __LINE__, __FUNCTION__, core::_rep_(currentCode).c_str() )); llvm::jitlink::SectionRange range(S); @@ -537,8 +530,6 @@ class ClaspPlugin : public llvm::orc::ObjectLinkingLayer::Plugin { printf("%s:%d:%s No executable region was found for the Code_O object\n", __FILE__, __LINE__, __FUNCTION__ ); } // - size_t gcroots_in_module_name_len = gcroots_in_module_name.size(); - size_t literals_name_len = literals_name.size(); bool found_gcroots_in_module = false; bool found_literals = false; for (auto ssym : G.defined_symbols()) { @@ -566,10 +557,9 @@ class ClaspPlugin : public llvm::orc::ObjectLinkingLayer::Plugin { if (pos!=std::string::npos) { found_gcroots_in_module = true; void* address = (void*)ssym->getAddress().getValue(); - size_t size = ssym->getSize(); DEBUG_OBJECT_FILES_PRINT(("%s:%d:%s Symbol-info %s %p %lu\n", __FILE__, __LINE__, __FUNCTION__, gcroots_in_module_name.c_str(), - address, size )); + address, ssym->getSize )); currentCode->_gcRoots = (gctools::GCRootsInModule*)address; continue; } @@ -703,7 +693,7 @@ ClaspJIT_O::ClaspJIT_O(bool loading, JITDylib_O* mainJITDylib) { .setExecutionSession(std::make_unique(std::move(TPC))) .setNumCompileThreads(0) // <<<<<<< In May 2021 a path will open to use multicores for LLJIT. .setJITTargetMachineBuilder(std::move(JTMB)) - .setObjectLinkingLayerCreator([this,&ExitOnErr](ExecutionSession &ES, const Triple &TT) { + .setObjectLinkingLayerCreator([&ExitOnErr](ExecutionSession &ES, const Triple &TT) { auto ObjLinkingLayer = std::make_unique(ES, std::make_unique()); ObjLinkingLayer->addPlugin(std::make_unique(ES,std::make_unique())); DEBUG_OBJECT_FILES_PRINT(("%s:%d:%s About to addPlugin for ClaspPlugin\n", __FILE__, __LINE__, __FUNCTION__ )); @@ -853,7 +843,6 @@ ObjectFile_sp ClaspJIT_O::addObjectFile( JITDylib_sp dylib, std::unique_ptrwrappedPtr(); DEBUG_OBJECT_FILES_PRINT(("%s:%d:%s About to evaluate the LoadtimeCode - with startupName: %s\n", __FILE__, __LINE__, __FUNCTION__, startupName.c_str() )); void* ptr; bool found = this->do_lookup(dylibsp,startupName,ptr); diff --git a/src/main/main.cc b/src/main/main.cc index 09748fa15a..39fc2727d4 100644 --- a/src/main/main.cc +++ b/src/main/main.cc @@ -115,77 +115,6 @@ void initialize_llvm(int argc, char **argv); // IMPLEMENTATION // --------------------------------------------------------------------------- -// PRINT STACKTRACE PROGRAMMICALLY - -static inline void print_stacktrace(FILE *out = stderr, unsigned int max_frames = 63) { - fprintf(out, "stack trace:\n"); - - // storage array for stack trace address data - void *addrlist[max_frames + 1]; - - // retrieve current stack addresses - int addrlen = backtrace(addrlist, sizeof(addrlist) / sizeof(void *)); - - if (addrlen == 0) { - fprintf(out, " \n"); - return; - } - - // resolve addresses into strings containing "filename(function+address)", - // this array must be free()-ed - char **symbollist = backtrace_symbols(addrlist, addrlen); - - // allocate string which will be filled with the demangled function name - size_t funcnamesize = 256; - char *funcname = (char *)malloc(funcnamesize); - - // iterate over the returned symbol lines. skip the first, it is the - // address of this function. - for (int i = 1; i < addrlen; i++) { - char *begin_name = 0, *begin_offset = 0, *end_offset = 0; - - // find parentheses and +address offset surrounding the mangled name: - // ./module(function+0x15c) [0x8048a6d] - for (char *p = symbollist[i]; *p; ++p) { - if (*p == '(') - begin_name = p; - else if (*p == '+') - begin_offset = p; - else if (*p == ')' && begin_offset) { - end_offset = p; - break; - } - } - - if (begin_name && begin_offset && end_offset && begin_name < begin_offset) { - *begin_name++ = '\0'; - *begin_offset++ = '\0'; - *end_offset = '\0'; - - // mangled name is now in [begin_name, begin_offset) and caller - // offset in [begin_offset, end_offset). now apply - // __cxa_demangle(): - - int status; - char *ret = abi::__cxa_demangle(begin_name, funcname, &funcnamesize, &status); - if (status == 0) { - funcname = ret; // use possibly realloc()-ed string - fprintf(out, " %s : %s+%s\n", symbollist[i], funcname, begin_offset); - } else { - // demangling failed. Output function name as a C function with - // no arguments. - fprintf(out, " %s : %s()+%s\n", symbollist[i], begin_name, begin_offset); - } - } else { - // couldn't parse the line? print the whole line. - fprintf(out, " %s\n", symbollist[i]); - } - } - - free(funcname); - free(symbollist); -} - // ABORT FLAG HANDLING // EXCEPTION HANDLING diff --git a/src/sockets/sockets.cc b/src/sockets/sockets.cc index 684201f64a..9f1c15db5a 100644 --- a/src/sockets/sockets.cc +++ b/src/sockets/sockets.cc @@ -865,7 +865,6 @@ CL_DEFUN int sockets_internal__do_select(core::T_sp to_secs, unsigned int to_musecs, core::Pointer_sp rfds, int max_fd) { - int count; struct timeval tv; if (to_secs.fixnump()) { tv.tv_sec = to_secs.unsafe_fixnum();