Skip to content

Commit a9c6792

Browse files
committed
Read-only cown
1 parent 10174c5 commit a9c6792

File tree

11 files changed

+1354
-155
lines changed

11 files changed

+1354
-155
lines changed

src/rt/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ endif()
4343

4444
if(USE_EXECINFO)
4545
if (${CMAKE_BUILD_TYPE} MATCHES "Debug|RelWithDebInfo")
46-
target_link_libraries(verona_rt INTERFACE -rdynamic)
46+
target_link_libraries(verona_rt INTERFACE -rdynamic -g -fno-omit-frame-pointer)
4747
endif()
4848

4949
find_library(LIBEXECINFO execinfo)

src/rt/cpp/cown_array.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,25 @@ namespace verona::cpp
6464
cown_array& operator=(cown_array&&) = delete;
6565
cown_array& operator=(const cown_array&) = delete;
6666
};
67+
68+
/* A cown_array<const T> is used to mark that the cown is being accessed as
69+
* read-only. (This combines the type as the capability. We do not have deep
70+
* immutability in C++, so acquired_cown<const T> is an approximation.)
71+
*
72+
* We use inheritance to allow us to construct a cown_array<const T> from a
73+
* cown_array<T>.
74+
*/
75+
template<typename T>
76+
class cown_array<const T> : public cown_array<T>
77+
{
78+
public:
79+
cown_array(const cown_array<T>& other) : cown_array<T>(other){};
80+
};
81+
82+
template<typename T>
83+
cown_array<const T> read(cown_array<T> cown)
84+
{
85+
Logging::cout() << "Read returning const array ptr" << Logging::endl;
86+
return cown;
87+
}
6788
}

src/rt/debug/harness.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ class SystematicTestHarness
8484
size_t seed_upper;
8585
high_resolution_clock::time_point start;
8686

87+
void (*run_at_termination)(void) = nullptr;
88+
8789
SystematicTestHarness(int argc, const char* const* argv) : opt(argc, argv)
8890
{
8991
std::cout << "Harness starting." << std::endl;
@@ -155,7 +157,11 @@ class SystematicTestHarness
155157
#else
156158
UNUSED(seed);
157159
#endif
158-
sched.init(cores);
160+
161+
if (run_at_termination)
162+
sched.init(cores, run_at_termination);
163+
else
164+
sched.init(cores);
159165

160166
f(std::forward<Args>(args)...);
161167

src/rt/sched/behaviour.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ namespace verona::rt
101101
auto* s = new (&slots[i]) Slot(requests[i].cown());
102102
if (requests[i].is_move())
103103
s->set_move();
104+
if (requests[i].is_read())
105+
s->set_read_only();
104106
}
105107

106108
return body;

0 commit comments

Comments
 (0)