Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

define-record-type methods and interfaces #596

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
125 changes: 125 additions & 0 deletions LOG
Original file line number Diff line number Diff line change
Expand Up @@ -2251,3 +2251,128 @@
users to create standard ftype bindings for the native-types if that
is preferred.
s/ftype.ss, mats/ftype.ms
- for each input-list element that is an identifier, symbol, or string,
generate-temporaries uses the identifier name, symbol name, or string
as the name for the corresponding generated temporary.
syntax.ss
- updated the just-reports target to look for reports to regenerate in
the output* directories.
mats/Mf-base
- fixed bug in strip: was counting on the two definitions of the table
record type in fasl.ss and the table record type in strip.ss being
identical without assigning a uid. this worked at optimize-level 3
but not at optimize-level 2. also eliminated an unused variable
addr from put-padty and fixed the call to put-field to pass in the
correct (target) fld record.
strip.ss, fasl.ss
- added define-record-type support for declaring methods and implementing
interfaces, along with a new define-interfaces form for defining
interfaces. the implementation is based on a combination of the
existing define-record-type code and the code for define-class
that used to reside in mats/oop.ss. every record-type descriptor
dybvig marked this conversation as resolved.
Show resolved Hide resolved
now contains an slot for interfaces (accessed via
record-type-interfaces), and those for record types with methods
additionally have one slot per method. bootstrapping with this
change to record-type descriptors required using a modified
fasl.patch to rewrite all rtds to include the extra rtd field.
the various procedures for creating record types now check to
make sure the interfaces and extra fields are equal when verifying
equality of nongenerative record types with the same name.
record-defn.ss (new), syntax.ss, cmacros.ss, cp0.ss, cpnanopass.ss,
mkheader.ss, pretty.ss, s/Mf-base,
record.ms, mats/Mf-base, 8.ms, patch-compile-0-f-t-f,
patch-interpret-0-f-f-f, patch=interpret-0-f-t-f,
root-experr-compile-0-f-f-f
- removed the old oop mat files
mats/oop.ss (removed), mats/oop.ms (removed)
- added missing unwrap-drtinfo call to record-type-descriptor so that
it recognizes record types with methods.
record-defn.ss
- changed the syntax of define-interface to be more like that of
define-record-type, with explicit parent and methods clauses.
(define-interface <name> clause ...) now defines a predicate
<name?> that returns true for records that support the interface,
and (define-interface (<name> <pred-name>) clause ...) uses
<pred-name> as the name of the predicate. removed the user-visible
record-type-interfaces primitive and replaced it with the system
primitive $record-type-interfaces. fixed a typo in the
define-record-type multiple methods clause error message.
record-defn.ss, cpnanopass.ss, primdata.ss, record.ss,
record.ms, root-experr-compile-0-f-f-f
- updated comments describing the new features
record-defn.ss
- fixed newly improved generate-temporaries so it doesn't loop
indefinitely on cycles in the elemenents of the input list.
syntax.ss,
8.mo, root-experr-compile-0-f-f-f
- cp0 record-construct handlers now keep record-type wrappers when
propagating constants and refs.
cp0.ss
- added immutable-vector primitive along with cp0 handling of
fully (foldable) and partially static immutable vectors.
primdata.ss, cpnanopass.ss, base-lang.ss, cpcheck.ss, cpletrec.ss,
cpcommonize.ss, cprep.ss, prims.ss, cp0.ss,
5_6.ms, cp0.ms
- define-values now uses an immutable vector rather than a mutable
vector to package the values.
syntax.ss
- now working harder to determine the truth of the test part of an
if expression in order to eliminate the if itself.
cp0.ss,
cp0.ms
- eliminated some code duplication in rfa and rfm helpers.
cp0.ss
- now using compile-time (nongenerative) record types as proxies
for the run-time (generative) counterparts for defining record-type
accessors and mutators. this improves cross-library optimization
of generative record types in general, and specifically breaks
an otherwise unresolvable cycle among the internal definitions
of a record type with methods for which cpvalid was inserting
valid checks and assignments.
record-defn.ss, record.ss, cp0.ss, primdata.ss,
record.ms
- improved handling of records with methods. Lsrc record-type form
now hosts base-rtd and extras, which cp0 now uses to inline methods
through vtable indirects when it can. cp0 also propagates
record-type information through record forms, i.e., it no longer
drops the record-type wrapper around the record-type expression
that gets placed in the record form. cp0's record? handler also
now recognizes record-types as records.
cp0.ss, base-lang.ss, cpletrec.ss, cpcommonize.ss, cprep.ss,
interpret.ss,
record.ms
- fixed cp0 handler for $record to handle the case where the rtrd is
constant and all fields are immutable. it was punting this case and
thus possibly disabling some optimization.
cp0.ss
- added cp0 handler for $record-type-field-offsets.
cp0.ss
- define-record-type now requires that all the ancestors of a new
type with methods must be known at cmompile time, i.e., must all
have been specified via parent rather than parent-rtd. this
ensures we can determine the full set of methods that the type
inherits at expand time, hence the set of new generics that the
new type definition should bind.
record-defn.ss,
record.ms, root-experr-compile-0-f-f-f
- interface methods now use an out-of-line $query-interface operator,
interfaces are now packaged in an immutable vector, and cp0 tries
to fold $query-interface at compile time when possible.
cp0.ss, record-defn.ss, primdata.ss,
record.ms
- added open-interface as a friendly wrapper on $query-interface.
record-defn.ss, primdata.ss,
record.ms, root-experr-compile-0-f-f-f
- updated patch files
patch-compile-0-f-t-f, patch-compile-0-t-f-f, patch-interpret-0-f-t-f
- moved $diinfo? test above first reference to the diinfo in
$trans-open-interface. added several define-interface and
open-interface syntax-error mats to catch this and other such
problems.
record-defn.ss,
record.ms, root-experr-compile-0-f-f-f, root-experr-compile-2-f-f-f
- improved $query-interface optimization so that it optimizes to #f if
it can prove the interface rtd will not be found. added a couple of
new mats to test the optimization.
cp0.ss,
record.ms
4 changes: 3 additions & 1 deletion boot/a6le/equates.h
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,7 @@ typedef unsigned long U64;
#define record_type_disp 0x1
#define record_type_flags_disp 0x39
#define record_type_flds_disp 0x31
#define record_type_interfaces_disp 0x51
#define record_type_mpm_disp 0x21
#define record_type_name_disp 0x29
#define record_type_parent_disp 0x9
Expand Down Expand Up @@ -508,7 +509,7 @@ typedef unsigned long U64;
#define size_pair 0x10
#define size_port 0x50
#define size_ratnum 0x20
#define size_record_type 0x50
#define size_record_type 0x60
#define size_rp_header 0x20
#define size_rtd_counts 0x810
#define size_symbol 0x30
Expand Down Expand Up @@ -875,6 +876,7 @@ typedef unsigned long U64;
#define RECORDDESCFLAGS(x) (*((ptr *)((uptr)(x)+57)))
#define RECORDDESCUID(x) (*((ptr *)((uptr)(x)+65)))
#define RECORDDESCCOUNTS(x) (*((ptr *)((uptr)(x)+73)))
#define RECORDDESINTERFACES(x) (*((ptr *)((uptr)(x)+81)))
#define RECORDINSTTYPE(x) (*((ptr *)((uptr)(x)+1)))
#define RECORDINSTIT(x,i) (((ptr *)((uptr)(x)+9))[i])
#define CLOSCODE(p) ((ptr)((uptr)CLOSENTRY(p)-code_data_disp))
Expand Down
Binary file modified boot/a6le/petite.boot
Binary file not shown.
Binary file modified boot/a6le/scheme.boot
Binary file not shown.
4 changes: 3 additions & 1 deletion boot/a6nt/equates.h
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,7 @@ typedef unsigned long long U64;
#define record_type_disp 0x1
#define record_type_flags_disp 0x39
#define record_type_flds_disp 0x31
#define record_type_interfaces_disp 0x51
#define record_type_mpm_disp 0x21
#define record_type_name_disp 0x29
#define record_type_parent_disp 0x9
Expand Down Expand Up @@ -508,7 +509,7 @@ typedef unsigned long long U64;
#define size_pair 0x10
#define size_port 0x50
#define size_ratnum 0x20
#define size_record_type 0x50
#define size_record_type 0x60
#define size_rp_header 0x20
#define size_rtd_counts 0x810
#define size_symbol 0x30
Expand Down Expand Up @@ -875,6 +876,7 @@ typedef unsigned long long U64;
#define RECORDDESCFLAGS(x) (*((ptr *)((uptr)(x)+57)))
#define RECORDDESCUID(x) (*((ptr *)((uptr)(x)+65)))
#define RECORDDESCCOUNTS(x) (*((ptr *)((uptr)(x)+73)))
#define RECORDDESINTERFACES(x) (*((ptr *)((uptr)(x)+81)))
#define RECORDINSTTYPE(x) (*((ptr *)((uptr)(x)+1)))
#define RECORDINSTIT(x,i) (((ptr *)((uptr)(x)+9))[i])
#define CLOSCODE(p) ((ptr)((uptr)CLOSENTRY(p)-code_data_disp))
Expand Down
Binary file modified boot/a6nt/petite.boot
Binary file not shown.
Binary file modified boot/a6nt/scheme.boot
Binary file not shown.
4 changes: 3 additions & 1 deletion boot/a6osx/equates.h
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,7 @@ typedef unsigned long U64;
#define record_type_disp 0x1
#define record_type_flags_disp 0x39
#define record_type_flds_disp 0x31
#define record_type_interfaces_disp 0x51
#define record_type_mpm_disp 0x21
#define record_type_name_disp 0x29
#define record_type_parent_disp 0x9
Expand Down Expand Up @@ -508,7 +509,7 @@ typedef unsigned long U64;
#define size_pair 0x10
#define size_port 0x50
#define size_ratnum 0x20
#define size_record_type 0x50
#define size_record_type 0x60
#define size_rp_header 0x20
#define size_rtd_counts 0x810
#define size_symbol 0x30
Expand Down Expand Up @@ -875,6 +876,7 @@ typedef unsigned long U64;
#define RECORDDESCFLAGS(x) (*((ptr *)((uptr)(x)+57)))
#define RECORDDESCUID(x) (*((ptr *)((uptr)(x)+65)))
#define RECORDDESCCOUNTS(x) (*((ptr *)((uptr)(x)+73)))
#define RECORDDESINTERFACES(x) (*((ptr *)((uptr)(x)+81)))
#define RECORDINSTTYPE(x) (*((ptr *)((uptr)(x)+1)))
#define RECORDINSTIT(x,i) (((ptr *)((uptr)(x)+9))[i])
#define CLOSCODE(p) ((ptr)((uptr)CLOSENTRY(p)-code_data_disp))
Expand Down
Binary file modified boot/a6osx/petite.boot
Binary file not shown.
Binary file modified boot/a6osx/scheme.boot
Binary file not shown.
4 changes: 3 additions & 1 deletion boot/arm32le/equates.h
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,7 @@ typedef unsigned long long U64;
#define record_type_disp 0x1
#define record_type_flags_disp 0x1D
#define record_type_flds_disp 0x19
#define record_type_interfaces_disp 0x29
#define record_type_mpm_disp 0x11
#define record_type_name_disp 0x15
#define record_type_parent_disp 0x5
Expand Down Expand Up @@ -507,7 +508,7 @@ typedef unsigned long long U64;
#define size_pair 0x8
#define size_port 0x28
#define size_ratnum 0x10
#define size_record_type 0x28
#define size_record_type 0x30
#define size_rp_header 0x10
#define size_rtd_counts 0x410
#define size_symbol 0x18
Expand Down Expand Up @@ -873,6 +874,7 @@ typedef unsigned long long U64;
#define RECORDDESCFLAGS(x) (*((ptr *)((uptr)(x)+29)))
#define RECORDDESCUID(x) (*((ptr *)((uptr)(x)+33)))
#define RECORDDESCCOUNTS(x) (*((ptr *)((uptr)(x)+37)))
#define RECORDDESINTERFACES(x) (*((ptr *)((uptr)(x)+41)))
#define RECORDINSTTYPE(x) (*((ptr *)((uptr)(x)+1)))
#define RECORDINSTIT(x,i) (((ptr *)((uptr)(x)+5))[i])
#define CLOSCODE(p) ((ptr)((uptr)CLOSENTRY(p)-code_data_disp))
Expand Down
Binary file modified boot/arm32le/petite.boot
Binary file not shown.
Binary file modified boot/arm32le/scheme.boot
Binary file not shown.
4 changes: 3 additions & 1 deletion boot/i3le/equates.h
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,7 @@ typedef unsigned long long U64;
#define record_type_disp 0x1
#define record_type_flags_disp 0x1D
#define record_type_flds_disp 0x19
#define record_type_interfaces_disp 0x29
#define record_type_mpm_disp 0x11
#define record_type_name_disp 0x15
#define record_type_parent_disp 0x5
Expand Down Expand Up @@ -506,7 +507,7 @@ typedef unsigned long long U64;
#define size_pair 0x8
#define size_port 0x28
#define size_ratnum 0x10
#define size_record_type 0x28
#define size_record_type 0x30
#define size_rp_header 0x10
#define size_rtd_counts 0x410
#define size_symbol 0x18
Expand Down Expand Up @@ -873,6 +874,7 @@ typedef unsigned long long U64;
#define RECORDDESCFLAGS(x) (*((ptr *)((uptr)(x)+29)))
#define RECORDDESCUID(x) (*((ptr *)((uptr)(x)+33)))
#define RECORDDESCCOUNTS(x) (*((ptr *)((uptr)(x)+37)))
#define RECORDDESINTERFACES(x) (*((ptr *)((uptr)(x)+41)))
#define RECORDINSTTYPE(x) (*((ptr *)((uptr)(x)+1)))
#define RECORDINSTIT(x,i) (((ptr *)((uptr)(x)+5))[i])
#define CLOSCODE(p) ((ptr)((uptr)CLOSENTRY(p)-code_data_disp))
Expand Down
Binary file modified boot/i3le/petite.boot
Binary file not shown.
Binary file modified boot/i3le/scheme.boot
Binary file not shown.
4 changes: 3 additions & 1 deletion boot/i3nt/equates.h
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,7 @@ typedef unsigned long long U64;
#define record_type_disp 0x1
#define record_type_flags_disp 0x1D
#define record_type_flds_disp 0x19
#define record_type_interfaces_disp 0x29
#define record_type_mpm_disp 0x11
#define record_type_name_disp 0x15
#define record_type_parent_disp 0x5
Expand Down Expand Up @@ -506,7 +507,7 @@ typedef unsigned long long U64;
#define size_pair 0x8
#define size_port 0x28
#define size_ratnum 0x10
#define size_record_type 0x28
#define size_record_type 0x30
#define size_rp_header 0x10
#define size_rtd_counts 0x410
#define size_symbol 0x18
Expand Down Expand Up @@ -874,6 +875,7 @@ typedef unsigned long long U64;
#define RECORDDESCFLAGS(x) (*((ptr *)((uptr)(x)+29)))
#define RECORDDESCUID(x) (*((ptr *)((uptr)(x)+33)))
#define RECORDDESCCOUNTS(x) (*((ptr *)((uptr)(x)+37)))
#define RECORDDESINTERFACES(x) (*((ptr *)((uptr)(x)+41)))
#define RECORDINSTTYPE(x) (*((ptr *)((uptr)(x)+1)))
#define RECORDINSTIT(x,i) (((ptr *)((uptr)(x)+5))[i])
#define CLOSCODE(p) ((ptr)((uptr)CLOSENTRY(p)-code_data_disp))
Expand Down
Binary file modified boot/i3nt/petite.boot
Binary file not shown.
Binary file modified boot/i3nt/scheme.boot
Binary file not shown.
4 changes: 3 additions & 1 deletion boot/i3osx/equates.h
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,7 @@ typedef unsigned long long U64;
#define record_type_disp 0x1
#define record_type_flags_disp 0x1D
#define record_type_flds_disp 0x19
#define record_type_interfaces_disp 0x29
#define record_type_mpm_disp 0x11
#define record_type_name_disp 0x15
#define record_type_parent_disp 0x5
Expand Down Expand Up @@ -506,7 +507,7 @@ typedef unsigned long long U64;
#define size_pair 0x8
#define size_port 0x28
#define size_ratnum 0x10
#define size_record_type 0x28
#define size_record_type 0x30
#define size_rp_header 0x10
#define size_rtd_counts 0x410
#define size_symbol 0x18
Expand Down Expand Up @@ -873,6 +874,7 @@ typedef unsigned long long U64;
#define RECORDDESCFLAGS(x) (*((ptr *)((uptr)(x)+29)))
#define RECORDDESCUID(x) (*((ptr *)((uptr)(x)+33)))
#define RECORDDESCCOUNTS(x) (*((ptr *)((uptr)(x)+37)))
#define RECORDDESINTERFACES(x) (*((ptr *)((uptr)(x)+41)))
#define RECORDINSTTYPE(x) (*((ptr *)((uptr)(x)+1)))
#define RECORDINSTIT(x,i) (((ptr *)((uptr)(x)+5))[i])
#define CLOSCODE(p) ((ptr)((uptr)CLOSENTRY(p)-code_data_disp))
Expand Down
Binary file modified boot/i3osx/petite.boot
Binary file not shown.
Binary file modified boot/i3osx/scheme.boot
Binary file not shown.
4 changes: 3 additions & 1 deletion boot/ta6le/equates.h
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,7 @@ typedef unsigned long U64;
#define record_type_disp 0x1
#define record_type_flags_disp 0x39
#define record_type_flds_disp 0x31
#define record_type_interfaces_disp 0x51
#define record_type_mpm_disp 0x21
#define record_type_name_disp 0x29
#define record_type_parent_disp 0x9
Expand Down Expand Up @@ -508,7 +509,7 @@ typedef unsigned long U64;
#define size_pair 0x10
#define size_port 0x50
#define size_ratnum 0x20
#define size_record_type 0x50
#define size_record_type 0x60
#define size_rp_header 0x20
#define size_rtd_counts 0x810
#define size_symbol 0x30
Expand Down Expand Up @@ -875,6 +876,7 @@ typedef unsigned long U64;
#define RECORDDESCFLAGS(x) (*((ptr *)((uptr)(x)+57)))
#define RECORDDESCUID(x) (*((ptr *)((uptr)(x)+65)))
#define RECORDDESCCOUNTS(x) (*((ptr *)((uptr)(x)+73)))
#define RECORDDESINTERFACES(x) (*((ptr *)((uptr)(x)+81)))
#define RECORDINSTTYPE(x) (*((ptr *)((uptr)(x)+1)))
#define RECORDINSTIT(x,i) (((ptr *)((uptr)(x)+9))[i])
#define CLOSCODE(p) ((ptr)((uptr)CLOSENTRY(p)-code_data_disp))
Expand Down
Binary file modified boot/ta6le/petite.boot
Binary file not shown.
Binary file modified boot/ta6le/scheme.boot
Binary file not shown.
4 changes: 3 additions & 1 deletion boot/ta6nt/equates.h
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,7 @@ typedef unsigned long long U64;
#define record_type_disp 0x1
#define record_type_flags_disp 0x39
#define record_type_flds_disp 0x31
#define record_type_interfaces_disp 0x51
#define record_type_mpm_disp 0x21
#define record_type_name_disp 0x29
#define record_type_parent_disp 0x9
Expand Down Expand Up @@ -508,7 +509,7 @@ typedef unsigned long long U64;
#define size_pair 0x10
#define size_port 0x50
#define size_ratnum 0x20
#define size_record_type 0x50
#define size_record_type 0x60
#define size_rp_header 0x20
#define size_rtd_counts 0x810
#define size_symbol 0x30
Expand Down Expand Up @@ -875,6 +876,7 @@ typedef unsigned long long U64;
#define RECORDDESCFLAGS(x) (*((ptr *)((uptr)(x)+57)))
#define RECORDDESCUID(x) (*((ptr *)((uptr)(x)+65)))
#define RECORDDESCCOUNTS(x) (*((ptr *)((uptr)(x)+73)))
#define RECORDDESINTERFACES(x) (*((ptr *)((uptr)(x)+81)))
#define RECORDINSTTYPE(x) (*((ptr *)((uptr)(x)+1)))
#define RECORDINSTIT(x,i) (((ptr *)((uptr)(x)+9))[i])
#define CLOSCODE(p) ((ptr)((uptr)CLOSENTRY(p)-code_data_disp))
Expand Down
Binary file modified boot/ta6nt/petite.boot
Binary file not shown.
Binary file modified boot/ta6nt/scheme.boot
Binary file not shown.
4 changes: 3 additions & 1 deletion boot/ta6osx/equates.h
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,7 @@ typedef unsigned long U64;
#define record_type_disp 0x1
#define record_type_flags_disp 0x39
#define record_type_flds_disp 0x31
#define record_type_interfaces_disp 0x51
#define record_type_mpm_disp 0x21
#define record_type_name_disp 0x29
#define record_type_parent_disp 0x9
Expand Down Expand Up @@ -508,7 +509,7 @@ typedef unsigned long U64;
#define size_pair 0x10
#define size_port 0x50
#define size_ratnum 0x20
#define size_record_type 0x50
#define size_record_type 0x60
#define size_rp_header 0x20
#define size_rtd_counts 0x810
#define size_symbol 0x30
Expand Down Expand Up @@ -875,6 +876,7 @@ typedef unsigned long U64;
#define RECORDDESCFLAGS(x) (*((ptr *)((uptr)(x)+57)))
#define RECORDDESCUID(x) (*((ptr *)((uptr)(x)+65)))
#define RECORDDESCCOUNTS(x) (*((ptr *)((uptr)(x)+73)))
#define RECORDDESINTERFACES(x) (*((ptr *)((uptr)(x)+81)))
#define RECORDINSTTYPE(x) (*((ptr *)((uptr)(x)+1)))
#define RECORDINSTIT(x,i) (((ptr *)((uptr)(x)+9))[i])
#define CLOSCODE(p) ((ptr)((uptr)CLOSENTRY(p)-code_data_disp))
Expand Down
Binary file modified boot/ta6osx/petite.boot
Binary file not shown.
Binary file modified boot/ta6osx/scheme.boot
Binary file not shown.
Loading