Skip to content

Commit 414383f

Browse files
author
meister
committed
Merge issues
1 parent 91f3369 commit 414383f

File tree

4 files changed

+98
-32
lines changed

4 files changed

+98
-32
lines changed

include/clasp/core/exceptions.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,13 +193,18 @@ class ExitProgramException : public std::exception {
193193
int getExitResult() { return this->_ExitResult; };
194194
};
195195

196+
typedef enum { undef, stomp, noStomp, testStomp } ForwardingEnum;
197+
198+
196199
struct SaveLispAndDie {
197200
string _FileName;
198201
bool _Executable;
199202
string _LibDir;
200203
bool _Exit; // Set to true unless debugging
201-
SaveLispAndDie(const std::string& filename, bool executable, const std::string& libDir, bool ep=true)
202-
: _FileName(filename), _Executable(executable), _LibDir(libDir), _Exit(ep){};
204+
ForwardingEnum _ForwardingKind;
205+
bool _TestMemory;
206+
SaveLispAndDie(const std::string& filename, bool executable, const std::string& libDir, bool ep=true, ForwardingEnum fk=noStomp, bool tm=true)
207+
: _FileName(filename), _Executable(executable), _LibDir(libDir), _Exit(ep), _ForwardingKind(fk), _TestMemory(tm) {};
203208
};
204209

205210
/*! To exit the program throw this exception

src/analysis/clasp_gc_cando.sif

Lines changed: 64 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -150,11 +150,12 @@
150150
"core::SimpleBitVector_O" "core::SimpleVector_int8_t_O" "chem::CDNode_O"
151151
"llvmo::ResumeInst_O" "llvmo::Function_O" "llvmo::DIType_O"
152152
"chem::AddIonOctree_O" "core::LocalSimpleFunGenerator_O"
153-
"chem::ZMatrixEntry_O" "comp::TagInfo_O" "geom::BoundingCuboid_O"
154-
"core::Readtable_O" "chem::CalculatePositionRelativeToOrigin_O"
155-
"chem::AtomIndexer_O" "chem::ChemInfoMatch_O" "chem::Restraint_O"
156-
"units::Quantity_O" "llvmo::IRBuilder_O" "chem::AtomPdbRec"
157-
"llvmo::ClaspJIT_O" "chem::FFParameter_O" "core::SimpleVector_byte8_t_O"
153+
"kinematics::StubJoint_O" "chem::ZMatrixEntry_O" "comp::TagInfo_O"
154+
"geom::BoundingCuboid_O" "core::Readtable_O"
155+
"chem::CalculatePositionRelativeToOrigin_O" "chem::AtomIndexer_O"
156+
"chem::ChemInfoMatch_O" "chem::Restraint_O" "units::Quantity_O"
157+
"llvmo::IRBuilder_O" "chem::AtomPdbRec" "llvmo::ClaspJIT_O"
158+
"chem::FFParameter_O" "core::SimpleVector_byte8_t_O"
158159
"llvmo::DILexicalBlockBase_O" "chem::RigidBodyAtomInfo" "llvmo::MDNode_O"
159160
"core::ComplexVector_fixnum_O" "chem::GenericOctree_O"
160161
"mp::RecursiveMutex_O" "core::BytecodeAstIf_O" "core::Vaslist_dummy_O"
@@ -1906,12 +1907,64 @@
19061907
:offset-ctype "gctools::smart_ptr<kinematics::Joint_O>"
19071908
:offset-base-ctype "kinematics::XyzJoint_O"
19081909
:layout-offset-field-names ("_Children" "[4]")}
1909-
{fixed-field :offset-type-cxx-identifier "ctype_double" :offset-ctype "double"
1910-
:offset-base-ctype "kinematics::XyzJoint_O" :layout-offset-field-names ("_X")}
1911-
{fixed-field :offset-type-cxx-identifier "ctype_double" :offset-ctype "double"
1912-
:offset-base-ctype "kinematics::XyzJoint_O" :layout-offset-field-names ("_Y")}
1913-
{fixed-field :offset-type-cxx-identifier "ctype_double" :offset-ctype "double"
1914-
:offset-base-ctype "kinematics::XyzJoint_O" :layout-offset-field-names ("_Z")}
1910+
{class-kind :stamp-name "STAMPWTAG_kinematics__StubJoint_O" :stamp-key "kinematics::StubJoint_O"
1911+
:parent-class "kinematics::XyzJoint_O" :lisp-class-base "kinematics::XyzJoint_O"
1912+
:root-class "core::T_O" :stamp-wtag 3 :definition-data "IS_POLYMORPHIC"}
1913+
{fixed-field :offset-type-cxx-identifier "SMART_PTR_OFFSET"
1914+
:offset-ctype "gctools::smart_ptr<kinematics::Joint_O>"
1915+
:offset-base-ctype "kinematics::StubJoint_O" :layout-offset-field-names ("_Parent")}
1916+
{fixed-field :offset-type-cxx-identifier "SMART_PTR_OFFSET"
1917+
:offset-ctype "gctools::smart_ptr<core::T_O>"
1918+
:offset-base-ctype "kinematics::StubJoint_O" :layout-offset-field-names ("_Name")}
1919+
{fixed-field :offset-type-cxx-identifier "ctype_int" :offset-ctype "int"
1920+
:offset-base-ctype "kinematics::StubJoint_O"
1921+
:layout-offset-field-names ("_Id" "._Molecule")}
1922+
{fixed-field :offset-type-cxx-identifier "ctype_int" :offset-ctype "int"
1923+
:offset-base-ctype "kinematics::StubJoint_O"
1924+
:layout-offset-field-names ("_Id" "._Residue")}
1925+
{fixed-field :offset-type-cxx-identifier "ctype_int" :offset-ctype "int"
1926+
:offset-base-ctype "kinematics::StubJoint_O"
1927+
:layout-offset-field-names ("_Id" "._Atom")}
1928+
{fixed-field :offset-type-cxx-identifier "ctype_int" :offset-ctype "int"
1929+
:offset-base-ctype "kinematics::StubJoint_O"
1930+
:layout-offset-field-names ("_PositionIndexX3")}
1931+
{fixed-field :offset-type-cxx-identifier "ctype_int" :offset-ctype "int"
1932+
:offset-base-ctype "kinematics::StubJoint_O"
1933+
:layout-offset-field-names ("_EndPositionIndexX3")}
1934+
{fixed-field :offset-type-cxx-identifier "SMART_PTR_OFFSET"
1935+
:offset-ctype "gctools::smart_ptr<core::List_V>"
1936+
:offset-base-ctype "kinematics::StubJoint_O"
1937+
:layout-offset-field-names ("_Properties")}
1938+
{fixed-field :offset-type-cxx-identifier "ctype_int" :offset-ctype "int"
1939+
:offset-base-ctype "kinematics::StubJoint_O"
1940+
:layout-offset-field-names ("_DofRefoldIndex")}
1941+
{fixed-field :offset-type-cxx-identifier "SMART_PTR_OFFSET"
1942+
:offset-ctype "gctools::smart_ptr<core::T_O>"
1943+
:offset-base-ctype "kinematics::StubJoint_O"
1944+
:layout-offset-field-names ("_Orientation")}
1945+
{fixed-field :offset-type-cxx-identifier "ctype_int" :offset-ctype "int"
1946+
:offset-base-ctype "kinematics::StubJoint_O"
1947+
:layout-offset-field-names ("_NumberOfChildren")}
1948+
{fixed-field :offset-type-cxx-identifier "SMART_PTR_OFFSET"
1949+
:offset-ctype "gctools::smart_ptr<kinematics::Joint_O>"
1950+
:offset-base-ctype "kinematics::StubJoint_O"
1951+
:layout-offset-field-names ("_Children" "[0]")}
1952+
{fixed-field :offset-type-cxx-identifier "SMART_PTR_OFFSET"
1953+
:offset-ctype "gctools::smart_ptr<kinematics::Joint_O>"
1954+
:offset-base-ctype "kinematics::StubJoint_O"
1955+
:layout-offset-field-names ("_Children" "[1]")}
1956+
{fixed-field :offset-type-cxx-identifier "SMART_PTR_OFFSET"
1957+
:offset-ctype "gctools::smart_ptr<kinematics::Joint_O>"
1958+
:offset-base-ctype "kinematics::StubJoint_O"
1959+
:layout-offset-field-names ("_Children" "[2]")}
1960+
{fixed-field :offset-type-cxx-identifier "SMART_PTR_OFFSET"
1961+
:offset-ctype "gctools::smart_ptr<kinematics::Joint_O>"
1962+
:offset-base-ctype "kinematics::StubJoint_O"
1963+
:layout-offset-field-names ("_Children" "[3]")}
1964+
{fixed-field :offset-type-cxx-identifier "SMART_PTR_OFFSET"
1965+
:offset-ctype "gctools::smart_ptr<kinematics::Joint_O>"
1966+
:offset-base-ctype "kinematics::StubJoint_O"
1967+
:layout-offset-field-names ("_Children" "[4]")}
19151968
{class-kind :stamp-name "STAMPWTAG_kinematics__BondedJoint_O"
19161969
:stamp-key "kinematics::BondedJoint_O" :parent-class "kinematics::Joint_O"
19171970
:lisp-class-base "kinematics::Joint_O" :root-class "core::T_O" :stamp-wtag 3

src/gctools/gcFunctions.cc

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ CL_DEFUN core::T_mv cl__room(core::Symbol_sp x) {
476476

477477
namespace gctools {
478478

479-
CL_LAMBDA(filename &key executable);
479+
CL_LAMBDA(filename &key executable test-memory);
480480
CL_DECLARE();
481481
CL_DOCSTRING(R"dx(Save a snapshot, i.e. enough information to restart a Lisp process
482482
later in the same state, in the file of the specified name. Only
@@ -486,12 +486,15 @@ The following &KEY arguments are defined:
486486
:EXECUTABLE
487487
If true, arrange to combine the Clasp runtime and the snapshot
488488
to create a standalone executable. If false (the default), the
489-
snapshot will not be executable on its own.)dx")
489+
snapshot will not be executable on its own.
490+
:TEST-MEMORY
491+
Test memory prior to saving snapshot.
492+
If NIL then snapshot saving is faster.)dx")
490493
DOCGROUP(clasp);
491-
CL_DEFUN void gctools__save_lisp_and_die(core::T_sp filename, core::T_sp executable) {
494+
CL_DEFUN void gctools__save_lisp_and_die(core::T_sp filename, core::T_sp executable, core::T_sp testMemory) {
492495
#ifdef USE_PRECISE_GC
493496
throw(core::SaveLispAndDie(gc::As<core::String_sp>(filename)->get_std_string(), executable.notnilp(),
494-
globals_->_Bundle->_Directories->_LibDir));
497+
globals_->_Bundle->_Directories->_LibDir, true, core::noStomp, testMemory.notnilp() ));
495498
#else
496499
SIMPLE_ERROR("save-lisp-and-die only works for precise GC");
497500
#endif
@@ -511,10 +514,13 @@ The following &KEY arguments are defined:
511514
snapshot will not be executable on its own.)dx")
512515
DOCGROUP(clasp);
513516
CL_DEFUN void gctools__save_lisp_and_continue(core::T_sp filename, core::T_sp executable) {
517+
#ifdef USE_PRECISE_GC
514518
core::SaveLispAndDie ee(gc::As<core::String_sp>(filename)->get_std_string(), executable.notnilp(),
515519
globals_->_Bundle->_Directories->_LibDir, false );
516520
#ifdef USE_PRECISE_GC
517521
snapshotSaveLoad::snapshot_save(ee);
522+
#else
523+
SIMPLE_ERROR("save-lisp-and-continue only works for precise GC");
518524
#endif
519525
}
520526

src/gctools/snapshotSaveLoad.cc

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -887,16 +887,15 @@ struct MemoryTest_t {
887887
// This is to test stomp.
888888
// undef - this means global_forwardingKind wasn't set yet.
889889
//
890-
typedef enum { undef, stomp, noStomp, testStomp } ForwardingEnum;
891-
ForwardingEnum global_forwardingKind = undef;
890+
core::ForwardingEnum global_forwardingKind = core::undef;
892891

893892
[[noreturn]] void errorBadForwardingKind() {
894893
printf("%s:%d:%s The global_forwardingKind wasn't set\n", __FILE__, __LINE__, __FUNCTION__);
895894
abort();
896895
}
897896

898897
void set_forwarding_pointer(gctools::BaseHeader_s* header, char* new_client, ISLInfo* info) {
899-
if (global_forwardingKind == testStomp) {
898+
if (global_forwardingKind == core::testStomp) {
900899
info->_forwarding[header] = (core::T_O*)new_client;
901900
if ((intptr_t)new_client < 0) {
902901
printf("%s:%d:%s Writing a bad forwarding pointer %p\n", __FILE__, __LINE__, __FUNCTION__, (void*)new_client);
@@ -906,17 +905,17 @@ void set_forwarding_pointer(gctools::BaseHeader_s* header, char* new_client, ISL
906905
printf("%s:%d:%s Forwarding pointer written and read don't match\n", __FILE__, __LINE__, __FUNCTION__);
907906
abort();
908907
}
909-
} else if (global_forwardingKind == noStomp) {
908+
} else if (global_forwardingKind == core::noStomp) {
910909
info->_forwarding[header] = (core::T_O*)new_client;
911-
} else if (global_forwardingKind == stomp) {
910+
} else if (global_forwardingKind == core::stomp) {
912911
header->_badge_stamp_wtag_mtag.setFwdPointer(new_client);
913912
} else {
914913
errorBadForwardingKind();
915914
}
916915
}
917916

918917
bool is_forwarding_pointer(gctools::BaseHeader_s* header, ISLInfo* info) {
919-
if (global_forwardingKind == testStomp) {
918+
if (global_forwardingKind == core::testStomp) {
920919
auto result = info->_forwarding.find(header);
921920
bool noStompResult = (result != info->_forwarding.end());
922921
bool stompResult = header->_badge_stamp_wtag_mtag.fwdP();
@@ -925,11 +924,11 @@ bool is_forwarding_pointer(gctools::BaseHeader_s* header, ISLInfo* info) {
925924
abort();
926925
}
927926
return stompResult;
928-
} else if (global_forwardingKind == noStomp) {
927+
} else if (global_forwardingKind == core::noStomp) {
929928
auto result = info->_forwarding.find(header);
930929
bool noStompResult = (result != info->_forwarding.end());
931930
return noStompResult;
932-
} else if (global_forwardingKind == stomp) {
931+
} else if (global_forwardingKind == core::stomp) {
933932
bool stompResult = header->_badge_stamp_wtag_mtag.fwdP();
934933
return stompResult;
935934
} else {
@@ -938,17 +937,17 @@ bool is_forwarding_pointer(gctools::BaseHeader_s* header, ISLInfo* info) {
938937
}
939938

940939
uintptr_t get_forwarding_pointer(gctools::BaseHeader_s* header, ISLInfo* info) {
941-
if (global_forwardingKind == testStomp) {
940+
if (global_forwardingKind == core::testStomp) {
942941
uintptr_t noStompResult = (uintptr_t)info->_forwarding[header];
943942
uintptr_t stompResult = (uintptr_t)header->_badge_stamp_wtag_mtag.fwdPointer();
944943
if (noStompResult != stompResult) {
945944
printf("%s:%d:%s results don't match\n", __FILE__, __LINE__, __FUNCTION__);
946945
abort();
947946
}
948947
return stompResult;
949-
} else if (global_forwardingKind == noStomp) {
948+
} else if (global_forwardingKind == core::noStomp) {
950949
return (uintptr_t)info->_forwarding[header];
951-
} else if (global_forwardingKind == stomp) {
950+
} else if (global_forwardingKind == core::stomp) {
952951
return (uintptr_t)header->_badge_stamp_wtag_mtag.fwdPointer();
953952
} else {
954953
errorBadForwardingKind();
@@ -1022,7 +1021,7 @@ gctools::clasp_ptr_t maybe_follow_forwarding_pointer(gctools::clasp_ptr_t* clien
10221021
pointer_pool(clientAddress), (void*)client, pointer_pool(client));
10231022
printf("%s:%d:%s general header %p IS NOT A FORWARDING POINTER - but it must be\n", __FILE__, __LINE__, __FUNCTION__,
10241023
(void*)header);
1025-
if (global_forwardingKind == noStomp) {
1024+
if (global_forwardingKind == core::noStomp) {
10261025
printf(" - for noStomp is not key in info->_forwarding[header]\n");
10271026
} else {
10281027
printf(" - *header should be fwd ptr but got %p\n", *(void**)header);
@@ -2778,9 +2777,12 @@ void snapshot_save(core::SaveLispAndDie& data) {
27782777
memory_test(true, NULL, "In preparation for snapshot_save.");
27792778

27802779
//
2781-
// For saving we may want to save snapshots and not die - so use noStomp forwarding.
2780+
// For saving we may want to save snapshots and continue (this is dangerous)
2781+
// In that case use noStomp forwarding.
2782+
// If we are ok with dying then use stomp.
27822783
//
2783-
global_forwardingKind = noStomp;
2784+
global_forwardingKind = data._ForwardingKind;
2785+
27842786
core::lisp_write(fmt::format("Updated with noStomp forwarding for snapshot_save\n"));
27852787
//
27862788
// Call Common Lisp code to release things at snapshot-save time
@@ -2909,7 +2911,7 @@ void snapshot_load(void* maybeStartOfSnapshot, void* maybeEndOfSnapshot, const s
29092911
//
29102912
// For loading we need speed - so use stomp forwarding
29112913
//
2912-
global_forwardingKind = stomp;
2914+
global_forwardingKind = core::stomp;
29132915

29142916
{
29152917
MaybeTimeStartup time1("Overall snapshot load time");

0 commit comments

Comments
 (0)