Skip to content

Commit a6bb947

Browse files
authored
Merge pull request #47 from fxpl/0-sealions
Mermaid: Small adjustments
2 parents 2592d3f + af5a2f6 commit a6bb947

18 files changed

+275
-119
lines changed

.github/workflows/buildci.yml

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ on:
1111
jobs:
1212
build:
1313
runs-on: ${{ matrix.os }}
14+
timeout-minutes: 10
1415

1516
strategy:
1617
# Set fail-fast to false to ensure that feedback is delivered for all matrix combinations. Consider changing this to true when your workflow is stable.
@@ -56,6 +57,7 @@ jobs:
5657

5758
format:
5859
runs-on: ubuntu-latest
60+
timeout-minutes: 5
5961

6062
steps:
6163
- uses: actions/checkout@v4

CMakeLists.txt

+3-1
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ set_property(TEST leak_with_global.vpy PROPERTY WILL_FAIL true)
7373
set_property(TEST invalid_read.vpy PROPERTY WILL_FAIL true)
7474
set_property(TEST invalid_shared_region.vpy PROPERTY WILL_FAIL true)
7575
set_property(TEST invalid_write.vpy PROPERTY WILL_FAIL true)
76-
set_property(TEST fail_cross_region_reg.vpy PROPERTY WILL_FAIL true)
76+
set_property(TEST invalid_child_region.vpy PROPERTY WILL_FAIL true)
77+
set_property(TEST invalid_not_bridge.vpy PROPERTY WILL_FAIL true)
7778
set_property(TEST region_bad_1.vpy PROPERTY WILL_FAIL true)
7879
set_property(TEST region_bad_2.vpy PROPERTY WILL_FAIL true)
80+
set_property(TEST fail_cross_region_ref.vpy PROPERTY WILL_FAIL true)

docs/builtin.md

+11-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Aborts the interpreter process. It's intended to indicate that an execution bran
1212

1313
## Constructors
1414

15-
#### `region()`
15+
#### `Region()`
1616

1717
Creates a new region object.
1818

@@ -74,12 +74,20 @@ This explicitly shows the "Cown region" in the generated diagrams.
7474

7575
#### `mermaid_hide_cown_region()`
7676

77-
This hides the "Cown region" and cown prototype in diagram. (This is the default)
77+
This hides the "Cown region" and cown prototype in diagram. (Default)
78+
79+
#### `mermaid_show_immutable_region()`
80+
81+
This explicitly shows the "Immutable region" in the generated diagrams
82+
83+
#### `mermaid_hide_immutable_region()`
84+
85+
This hides the "Immutable region" in diagram. (Default)
7886

7987
#### `mermaid_show_functions()`
8088

8189
Shows user defined functions in the diagram.
8290

8391
#### `mermaid_hide_functions()`
8492

85-
Hides user defined functions in the diagram. (This is the default)
93+
Hides user defined functions in the diagram. (Default)

src/rt/core.h

+15-10
Original file line numberDiff line numberDiff line change
@@ -196,19 +196,24 @@ namespace rt::core
196196
class CownObject : public objects::DynObject
197197
{
198198
public:
199-
CownObject(objects::DynObject* region)
199+
CownObject(objects::DynObject* bridge)
200200
: objects::DynObject(cownPrototypeObject(), objects::cown_region)
201201
{
202-
// FIXME: Add once regions are reified
203-
// assert(
204-
// region->get_prototype() == regionPrototype() &&
205-
// "Cowns can only store regions");
206-
//
207-
// FIXME: Also check that the region has a LRC == 1, with 1
208-
// being the reference passed into this constructor
202+
auto region = objects::get_region(bridge);
203+
if (region->bridge != bridge)
204+
{
205+
std::stringstream ss;
206+
ss << bridge << " is not the bridge object of the region";
207+
ui::error(ss.str(), bridge);
208+
}
209+
210+
if (region->local_reference_count > 1)
211+
{
212+
ui::error("The given region has a LRC > 1", bridge);
213+
}
209214

210215
// this->set would fail, since this is a cown
211-
this->fields["value"] = region;
216+
this->fields["value"] = bridge;
212217
}
213218

214219
std::string get_name() override
@@ -233,7 +238,7 @@ namespace rt::core
233238
{
234239
static std::set<objects::DynObject*>* globals =
235240
new std::set<objects::DynObject*>{
236-
objects::regionObjectPrototypeObject(),
241+
objects::regionPrototypeObject(),
237242
framePrototypeObject(),
238243
funcPrototypeObject(),
239244
bytecodeFuncPrototypeObject(),

src/rt/core/builtin.cc

+13
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,19 @@ namespace rt::core
124124
return std::nullopt;
125125
});
126126

127+
add_builtin(
128+
"mermaid_show_immutable_region", [mermaid](auto, auto, auto args) {
129+
assert(args == 0);
130+
mermaid->draw_immutable_region = true;
131+
return std::nullopt;
132+
});
133+
add_builtin(
134+
"mermaid_hide_immutable_region", [mermaid](auto, auto, auto args) {
135+
assert(args == 0);
136+
mermaid->draw_immutable_region = false;
137+
return std::nullopt;
138+
});
139+
127140
add_builtin("mermaid_show_functions", [mermaid](auto, auto, auto args) {
128141
assert(args == 0);
129142
mermaid->show_functions();

src/rt/objects/region.cc

+17-2
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ namespace rt::objects
5252
return false;
5353
}
5454

55-
if (obj->get_prototype() != objects::regionObjectPrototypeObject())
55+
if (obj->get_prototype() != objects::regionPrototypeObject())
5656
{
5757
ui::error("Cannot add interior region object to another region");
5858
}
@@ -133,7 +133,7 @@ namespace rt::objects
133133
return;
134134
}
135135

136-
if (target->get_prototype() != objects::regionObjectPrototypeObject())
136+
if (target->get_prototype() != objects::regionPrototypeObject())
137137
{
138138
ui::error("Cannot add interior region object to another region");
139139
}
@@ -251,4 +251,19 @@ namespace rt::objects
251251
return obj;
252252
}
253253

254+
void Region::action(Region* r)
255+
{
256+
if ((r->local_reference_count == 0) && (r->parent == nullptr))
257+
{
258+
// TODO, this can be hooked to perform delayed operations like send.
259+
// Needs to check for sub_region_reference_count for send, but not
260+
// deallocate.
261+
262+
if (r != get_local_region() && r != cown_region)
263+
{
264+
to_collect.push_back(r);
265+
std::cout << "Collecting region: " << r << std::endl;
266+
}
267+
}
268+
}
254269
}

src/rt/objects/region.h

+4-15
Original file line numberDiff line numberDiff line change
@@ -55,18 +55,7 @@ namespace rt::objects
5555
return local_reference_count + sub_region_reference_count;
5656
}
5757

58-
static void action(Region* r)
59-
{
60-
if ((r->local_reference_count == 0) && (r->parent == nullptr))
61-
{
62-
// TODO, this can be hooked to perform delayed operations like send.
63-
// Needs to check for sub_region_reference_count for send, but not
64-
// deallocate.
65-
66-
to_collect.push_back(r);
67-
std::cout << "Collecting region: " << r << std::endl;
68-
}
69-
}
58+
static void action(Region*);
7059

7160
static void dec_lrc(Region* r)
7261
{
@@ -117,9 +106,9 @@ namespace rt::objects
117106
// Check if already parented to another region.
118107
if (r->parent != nullptr)
119108
{
120-
// FIXME: Highlight, once regions have been reified
121109
ui::error(
122-
"Region already has a parent: Creating region DAG not supported!");
110+
"Region already has a parent: Creating region DAG not supported!",
111+
r->bridge);
123112
}
124113

125114
// Prevent creating a cycle
@@ -129,7 +118,7 @@ namespace rt::objects
129118
if (ancestors == r)
130119
{
131120
// FIXME: Highlight, once regions have been reified
132-
ui::error("Cycle created in region hierarchy");
121+
ui::error("Cycle created in region hierarchy", r->bridge);
133122
}
134123
ancestors = ancestors->parent;
135124
}

src/rt/objects/region_object.h

+15-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
#pragma once
22

33
#include "prototype_object.h"
4+
#include "region.h"
45

56
namespace rt::objects
67
{
78
// The prototype object for region entry point objects
8-
inline PrototypeObject* regionObjectPrototypeObject()
9+
inline PrototypeObject* regionPrototypeObject()
910
{
1011
static PrototypeObject* proto = new PrototypeObject("RegionObject");
1112
return proto;
@@ -14,8 +15,17 @@ namespace rt::objects
1415
class RegionObject : public DynObject
1516
{
1617
public:
17-
RegionObject(Region* region)
18-
: DynObject(regionObjectPrototypeObject(), region)
19-
{}
18+
RegionObject(Region* region) : DynObject(regionPrototypeObject(), region) {}
19+
20+
std::string get_name() override
21+
{
22+
auto region = get_region(this);
23+
24+
std::stringstream stream;
25+
stream << this << std::endl;
26+
stream << "lrc=" << region->local_reference_count << std::endl;
27+
stream << "sbrc=" << region->sub_region_reference_count;
28+
return stream.str();
29+
}
2030
};
21-
}
31+
}

src/rt/rt.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ namespace rt
9292
{
9393
// TODO Add some checking. This is need to lookup the correct function in
9494
// the prototype chain.
95-
if (key->get_prototype() != core::stringPrototypeObject())
95+
if (key && key->get_prototype() != core::stringPrototypeObject())
9696
{
9797
ui::error("Key must be a string.", key);
9898
}

src/rt/ui.h

+2
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,10 @@ namespace rt::ui
5757
std::set<rt::objects::DynObject*> taint;
5858
/// Indicates if the cown region show be explicitly drawn
5959
bool draw_cown_region;
60+
bool draw_immutable_region;
6061
/// Indicates if local functions should be visible
6162
bool draw_funcs;
63+
bool highlight_unreachable = true;
6264

6365
std::vector<objects::DynObject*> error_objects;
6466
std::vector<objects::Edge> error_edges;

0 commit comments

Comments
 (0)