Skip to content

Commit f6e44d9

Browse files
committed
dylan: Ensure important object slots are guaranteed initialized
Slots that the compiler knows are aways initialized don't need to be checked for %unbound when they are accessed, reducing overhead. * sources/dylan/new-dispatch.dylan (<dispatch-state>): Add dummy initializations to slots that don't already have them (%ds-gf, %ds-parent, %ds-args, %ds-argnum-set, %ds-headed-methods). * sources/dylan/condition.dylan (<handler>): Mark all slot init keywords as required.
1 parent d85b27e commit f6e44d9

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

sources/dylan/condition.dylan

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ Warranty: Distributed WITHOUT WARRANTY OF ANY KIND
88
//// HANDLERS
99

1010
define primary class <handler> (<object>)
11-
constant slot handler-type, init-keyword: type:;
12-
constant slot handler-function, init-keyword: function:;
13-
constant slot handler-test, init-keyword: test:;
14-
constant slot handler-init-arguments, init-keyword: init-arguments:;
11+
constant slot handler-type, required-init-keyword: type:;
12+
constant slot handler-function, required-init-keyword: function:;
13+
constant slot handler-test, required-init-keyword: test:;
14+
constant slot handler-init-arguments, required-init-keyword: init-arguments:;
1515
end class <handler>;
1616

1717
define sealed domain make (singleton(<handler>));

sources/dylan/new-dispatch.dylan

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1427,14 +1427,18 @@ end function;
14271427

14281428
//// Handle-missed-dispatch
14291429

1430+
// NB: Slot initializations are not respected when <dispatch-state>
1431+
// instances are allocated using system-allocate-simple-instance, but
1432+
// are included so that the compiler sees the slots as
1433+
// guaranteed-initialized.
14301434

14311435
define primary class <dispatch-state> (<object>)
1432-
slot %ds-gf :: <generic-function>;
1433-
slot %ds-parent :: <dispatch-starter>;
1434-
slot %ds-args :: <simple-object-vector>;
1435-
slot %ds-argnum-set :: <argnum-set>;
1436+
slot %ds-gf :: <generic-function> = sorted-applicable-methods;
1437+
slot %ds-parent :: <dispatch-starter> = sorted-applicable-methods;
1438+
slot %ds-args :: <simple-object-vector> = #[];
1439+
slot %ds-argnum-set :: <argnum-set> = #(0);
14361440
slot %ds-args-to-check-first :: <list> = #();
1437-
slot %ds-headed-methods :: <pair>;
1441+
slot %ds-headed-methods :: <pair> = #(#f);
14381442
slot %ds-cache = #f;
14391443
slot %ds-result = #f;
14401444
slot %ds-conditions = #();

0 commit comments

Comments
 (0)