Skip to content

Commit

Permalink
Various updates, mostly to the compiler, including a new lambda
Browse files Browse the repository at this point in the history
commonizatio pass and support for specifying default record
equal and hash procedures:

- more staid and consistent Mf-cross main target
    Mf-cross
- cpletrec now replaces the incoming prelexes with new ones so
  that it doesn't have to alter the flags on the incoming ones, since
  the same expander output is passed through the compiler twice while
  compiling a file with macro definitions or libraries.  we were
  getting away without this just by luck.
    cpletrec.ss
- pure? and ivory? now return #t for a primref only if the prim is
  declared to be a proc, since some non-proc prims are mutable, e.g.,
  $active-threads and $collect-request-pending.
    cp0.ss
- $error-handling-mode? and $eol-style? are now properly declared to
  be procs rather than system state variables.
    primdata.ss
- the new pass $check-prelex-flags verifies that prelex referenced,
  multiply-referenced, and assigned flags are set when they
  should be.  (it doesn't, however, complain if a flag is set
  when it need not be.)  when the new system parameter
  $enable-check-prelex-flags is set, $check-prelex-flags is
  called after each major pass that produces Lsrc forms to verify
  that the flags are set correctly in the output of the pass.
  this parameter is unset by default but set when running the
  mats.
    cprep.ss, back.ss, compile.ss, primdata.ss,
    mats/Mf-base
- removed the unnecessary set of prelex referenced flag from the
  build-ref routines when we've just established that it is set.
    syntax.ss, compile.ss
- equivalent-expansion? now prints differences to the current output
  port to aid in debugging.
    mat.ss
- the nanopass that patches calls to library globals into calls to
  their local counterparts during whole-program optimization now
  creates new prelexes and sets the prelex referenced, multiply
  referenced, and assigned flags on the new prelexes rather than
  destructively setting flags on the incoming prelexes.  The
  only known problems this fixes are (1) the multiply referenced
  flag was not previously being set for cross-library calls when
  it should have been, resulting in overly aggressive inlining
  of library exports during whole-program optimization, and (2)
  the referenced flag could sometimes be set for library exports
  that aren't actually used in the final program, which could
  prevent some unreachable code from being eliminated.
    compile.ss
- added support for specifying default record-equal and
  record-hash procedures.
    primdata.ss, cmacros.ss, cpnanopass.ss, prims.ss, newhash.ss,
    gc.c,
    record.ms
- added missing call to relocate for subset-mode tc field, which
  wasn't burning us because the only valid non-false value, the
  symbol system, is in the static generation after the initial heap
  compaction.
    gc.c
- added a lambda-commonization pass that runs after the other
  source optimizations, particularly inlining, and a new parameter
  that controls how hard it works.  the value of commonization-level
  ranges from 0 through 9, with 0 disabling commonization and 9
  maximizing it.  The default value is 0 (disabled).  At present,
  for non-zero level n, the commonizer attempts to commonize
  lambda expressions consisting of 2^(10-n) or more nodes.
  commonization of one or more lambda expressions requires that
  they have identical structure down to the leaf nodes for quote
  expressions, references to unassigned variables, and primitives.
  So that various downstream optimizations aren't disabled, there
  are some additional restrictions, the most important of which
  being that call-position expressions must be identical.  The
  commonizer works by abstracting the code into a helper that
  takes the values of the differing leaf nodes as arguments.
  the name of the helper is formed by concatenating the names of
  the original procedures, separated by '&', and this is the name
  that will show up in a stack trace.  The source location will
  be that of one of the original procedures.  Profiling inhibits
  commonization, because commonization requires profile source
  locations to be identical.
    cpcommonize.ss (new), compile.ss, interpret.ss, cprep.ss,
    primdata.ss, s/Mf-base,
    mats/Mf-base
- cpletrec now always produces a letrec rather than a let for
  single immutable lambda bindings, even when not recursive, for
  consistent expand/optimize output whether the commonizer is
  run or not.
    cpletrec.ss,
    record.ms
- trans-make-ftype-pointer no longer generates a call to
  $verify-ftype-address if the address expression is a call to
  ftype-pointer-address.
    ftype.ss
  • Loading branch information
dybvig committed Jan 29, 2018
1 parent 6ead5d9 commit b6a3dcc
Show file tree
Hide file tree
Showing 59 changed files with 826 additions and 278 deletions.
89 changes: 89 additions & 0 deletions LOG
Original file line number Diff line number Diff line change
Expand Up @@ -790,3 +790,92 @@
cpnanopass.ss, 5_5.ms, 5_6.ms, bytevector.ms
- fix a few signatures
primdata.ss
- more staid and consistent Mf-cross main target
Mf-cross
- cpletrec now replaces the incoming prelexes with new ones so
that it doesn't have to alter the flags on the incoming ones, since
the same expander output is passed through the compiler twice while
compiling a file with macro definitions or libraries. we were
getting away without this just by luck.
cpletrec.ss
- pure? and ivory? now return #t for a primref only if the prim is
declared to be a proc, since some non-proc prims are mutable, e.g.,
$active-threads and $collect-request-pending.
cp0.ss
- $error-handling-mode? and $eol-style? are now properly declared to
be procs rather than system state variables.
primdata.ss
- the new pass $check-prelex-flags verifies that prelex referenced,
multiply-referenced, and assigned flags are set when they
should be. (it doesn't, however, complain if a flag is set
when it need not be.) when the new system parameter
$enable-check-prelex-flags is set, $check-prelex-flags is
called after each major pass that produces Lsrc forms to verify
that the flags are set correctly in the output of the pass.
this parameter is unset by default but set when running the
mats.
cprep.ss, back.ss, compile.ss, primdata.ss,
mats/Mf-base
- removed the unnecessary set of prelex referenced flag from the
build-ref routines when we've just established that it is set.
syntax.ss, compile.ss
- equivalent-expansion? now prints differences to the current output
port to aid in debugging.
mat.ss
- the nanopass that patches calls to library globals into calls to
their local counterparts during whole-program optimization now
creates new prelexes and sets the prelex referenced, multiply
referenced, and assigned flags on the new prelexes rather than
destructively setting flags on the incoming prelexes. The
only known problems this fixes are (1) the multiply referenced
flag was not previously being set for cross-library calls when
it should have been, resulting in overly aggressive inlining
of library exports during whole-program optimization, and (2)
the referenced flag could sometimes be set for library exports
that aren't actually used in the final program, which could
prevent some unreachable code from being eliminated.
compile.ss
- added support for specifying default record-equal and
record-hash procedures.
primdata.ss, cmacros.ss, cpnanopass.ss, prims.ss, newhash.ss,
gc.c,
record.ms
- added missing call to relocate for subset-mode tc field, which
wasn't burning us because the only valid non-false value, the
symbol system, is in the static generation after the initial heap
compaction.
gc.c
- added a lambda-commonization pass that runs after the other
source optimizations, particularly inlining, and a new parameter
that controls how hard it works. the value of commonization-level
ranges from 0 through 9, with 0 disabling commonization and 9
maximizing it. The default value is 0 (disabled). At present,
for non-zero level n, the commonizer attempts to commonize
lambda expressions consisting of 2^(10-n) or more nodes.
commonization of one or more lambda expressions requires that
they have identical structure down to the leaf nodes for quote
expressions, references to unassigned variables, and primitives.
So that various downstream optimizations aren't disabled, there
are some additional restrictions, the most important of which
being that call-position expressions must be identical. The
commonizer works by abstracting the code into a helper that
takes the values of the differing leaf nodes as arguments.
the name of the helper is formed by concatenating the names of
the original procedures, separated by '&', and this is the name
that will show up in a stack trace. The source location will
be that of one of the original procedures. Profiling inhibits
commonization, because commonization requires profile source
locations to be identical.
cpcommonize.ss (new), compile.ss, interpret.ss, cprep.ss,
primdata.ss, s/Mf-base,
mats/Mf-base
- cpletrec now always produces a letrec rather than a let for
single immutable lambda bindings, even when not recursive, for
consistent expand/optimize output whether the commonizer is
run or not.
cpletrec.ss,
record.ms
- trans-make-ftype-pointer no longer generates a call to
$verify-ftype-address if the address expression is a call to
ftype-pointer-address.
ftype.ss
18 changes: 11 additions & 7 deletions boot/a6le/equates.h
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ typedef unsigned long U64;
#define size_rp_header 0x20
#define size_rtd_counts 0x810
#define size_symbol 0x30
#define size_tc 0x270
#define size_tc 0x280
#define size_thread 0x10
#define size_tlc 0x20
#define size_typed_object 0x10
Expand Down Expand Up @@ -549,7 +549,7 @@ typedef unsigned long U64;
#define tc_ac0_disp 0x28
#define tc_ac1_disp 0x30
#define tc_active_disp 0x134
#define tc_alloc_counter_disp 0x260
#define tc_alloc_counter_disp 0x270
#define tc_ap_disp 0x50
#define tc_arg_regs_disp 0x0
#define tc_block_counter_disp 0x1D0
Expand All @@ -561,6 +561,8 @@ typedef unsigned long U64;
#define tc_current_input_disp 0x1B8
#define tc_current_mso_disp 0x1E0
#define tc_current_output_disp 0x1C0
#define tc_default_record_equal_procedure_disp 0x258
#define tc_default_record_hash_procedure_disp 0x260
#define tc_disable_count_disp 0x198
#define tc_eap_disp 0x58
#define tc_esp_disp 0x48
Expand All @@ -569,15 +571,15 @@ typedef unsigned long U64;
#define tc_generate_inspector_information_disp 0x230
#define tc_generate_profile_forms_disp 0x238
#define tc_guardian_entries_disp 0x118
#define tc_instr_counter_disp 0x258
#define tc_instr_counter_disp 0x268
#define tc_keyboard_interrupt_pending_disp 0x1A8
#define tc_meta_level_disp 0x220
#define tc_null_immutable_bytevector_disp 0x210
#define tc_null_immutable_fxvector_disp 0x208
#define tc_null_immutable_string_disp 0x218
#define tc_null_immutable_vector_disp 0x200
#define tc_optimize_level_disp 0x240
#define tc_parameters_disp 0x268
#define tc_parameters_disp 0x278
#define tc_random_seed_disp 0x130
#define tc_real_eap_disp 0x90
#define tc_ret_disp 0x60
Expand Down Expand Up @@ -904,7 +906,7 @@ typedef unsigned long U64;
#define AC0(x) (*((void* *)((uptr)(x)+40)))
#define AC1(x) (*((void* *)((uptr)(x)+48)))
#define ACTIVE(x) (*((I32 *)((uptr)(x)+308)))
#define ALLOCCOUNTER(x) (*((U64 *)((uptr)(x)+608)))
#define ALLOCCOUNTER(x) (*((U64 *)((uptr)(x)+624)))
#define AP(x) (*((void* *)((uptr)(x)+80)))
#define ARGREGS(x,i) (((void* *)((uptr)(x)+0))[i])
#define BLOCKCOUNTER(x) (*((ptr *)((uptr)(x)+464)))
Expand All @@ -916,6 +918,8 @@ typedef unsigned long U64;
#define CURRENTINPUT(x) (*((ptr *)((uptr)(x)+440)))
#define CURRENTMSO(x) (*((ptr *)((uptr)(x)+480)))
#define CURRENTOUTPUT(x) (*((ptr *)((uptr)(x)+448)))
#define DEFAULTRECORDEQUALPROCEDURE(x) (*((ptr *)((uptr)(x)+600)))
#define DEFAULTRECORDHASHPROCEDURE(x) (*((ptr *)((uptr)(x)+608)))
#define DISABLECOUNT(x) (*((ptr *)((uptr)(x)+408)))
#define EAP(x) (*((void* *)((uptr)(x)+88)))
#define ESP(x) (*((void* *)((uptr)(x)+72)))
Expand All @@ -924,15 +928,15 @@ typedef unsigned long U64;
#define GENERATEINSPECTORINFORMATION(x) (*((ptr *)((uptr)(x)+560)))
#define GENERATEPROFILEFORMS(x) (*((ptr *)((uptr)(x)+568)))
#define GUARDIANENTRIES(x) (*((ptr *)((uptr)(x)+280)))
#define INSTRCOUNTER(x) (*((U64 *)((uptr)(x)+600)))
#define INSTRCOUNTER(x) (*((U64 *)((uptr)(x)+616)))
#define KEYBOARDINTERRUPTPENDING(x) (*((ptr *)((uptr)(x)+424)))
#define METALEVEL(x) (*((ptr *)((uptr)(x)+544)))
#define NULLIMMUTABLEBYTEVECTOR(x) (*((ptr *)((uptr)(x)+528)))
#define NULLIMMUTABLEFXVECTOR(x) (*((ptr *)((uptr)(x)+520)))
#define NULLIMMUTABLESTRING(x) (*((ptr *)((uptr)(x)+536)))
#define NULLIMMUTABLEVECTOR(x) (*((ptr *)((uptr)(x)+512)))
#define OPTIMIZELEVEL(x) (*((ptr *)((uptr)(x)+576)))
#define PARAMETERS(x) (*((ptr *)((uptr)(x)+616)))
#define PARAMETERS(x) (*((ptr *)((uptr)(x)+632)))
#define RANDOMSEED(x) (*((U32 *)((uptr)(x)+304)))
#define REAL_EAP(x) (*((void* *)((uptr)(x)+144)))
#define RET(x) (*((void* *)((uptr)(x)+96)))
Expand Down
Binary file modified boot/a6le/petite.boot
Binary file not shown.
Binary file modified boot/a6le/scheme.boot
Binary file not shown.
18 changes: 11 additions & 7 deletions boot/a6nt/equates.h
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ typedef unsigned long long U64;
#define size_rp_header 0x20
#define size_rtd_counts 0x810
#define size_symbol 0x30
#define size_tc 0x270
#define size_tc 0x280
#define size_thread 0x10
#define size_tlc 0x20
#define size_typed_object 0x10
Expand Down Expand Up @@ -549,7 +549,7 @@ typedef unsigned long long U64;
#define tc_ac0_disp 0x28
#define tc_ac1_disp 0x30
#define tc_active_disp 0x134
#define tc_alloc_counter_disp 0x260
#define tc_alloc_counter_disp 0x270
#define tc_ap_disp 0x50
#define tc_arg_regs_disp 0x0
#define tc_block_counter_disp 0x1D0
Expand All @@ -561,6 +561,8 @@ typedef unsigned long long U64;
#define tc_current_input_disp 0x1B8
#define tc_current_mso_disp 0x1E0
#define tc_current_output_disp 0x1C0
#define tc_default_record_equal_procedure_disp 0x258
#define tc_default_record_hash_procedure_disp 0x260
#define tc_disable_count_disp 0x198
#define tc_eap_disp 0x58
#define tc_esp_disp 0x48
Expand All @@ -569,15 +571,15 @@ typedef unsigned long long U64;
#define tc_generate_inspector_information_disp 0x230
#define tc_generate_profile_forms_disp 0x238
#define tc_guardian_entries_disp 0x118
#define tc_instr_counter_disp 0x258
#define tc_instr_counter_disp 0x268
#define tc_keyboard_interrupt_pending_disp 0x1A8
#define tc_meta_level_disp 0x220
#define tc_null_immutable_bytevector_disp 0x210
#define tc_null_immutable_fxvector_disp 0x208
#define tc_null_immutable_string_disp 0x218
#define tc_null_immutable_vector_disp 0x200
#define tc_optimize_level_disp 0x240
#define tc_parameters_disp 0x268
#define tc_parameters_disp 0x278
#define tc_random_seed_disp 0x130
#define tc_real_eap_disp 0x90
#define tc_ret_disp 0x60
Expand Down Expand Up @@ -904,7 +906,7 @@ typedef unsigned long long U64;
#define AC0(x) (*((void* *)((uptr)(x)+40)))
#define AC1(x) (*((void* *)((uptr)(x)+48)))
#define ACTIVE(x) (*((I32 *)((uptr)(x)+308)))
#define ALLOCCOUNTER(x) (*((U64 *)((uptr)(x)+608)))
#define ALLOCCOUNTER(x) (*((U64 *)((uptr)(x)+624)))
#define AP(x) (*((void* *)((uptr)(x)+80)))
#define ARGREGS(x,i) (((void* *)((uptr)(x)+0))[i])
#define BLOCKCOUNTER(x) (*((ptr *)((uptr)(x)+464)))
Expand All @@ -916,6 +918,8 @@ typedef unsigned long long U64;
#define CURRENTINPUT(x) (*((ptr *)((uptr)(x)+440)))
#define CURRENTMSO(x) (*((ptr *)((uptr)(x)+480)))
#define CURRENTOUTPUT(x) (*((ptr *)((uptr)(x)+448)))
#define DEFAULTRECORDEQUALPROCEDURE(x) (*((ptr *)((uptr)(x)+600)))
#define DEFAULTRECORDHASHPROCEDURE(x) (*((ptr *)((uptr)(x)+608)))
#define DISABLECOUNT(x) (*((ptr *)((uptr)(x)+408)))
#define EAP(x) (*((void* *)((uptr)(x)+88)))
#define ESP(x) (*((void* *)((uptr)(x)+72)))
Expand All @@ -924,15 +928,15 @@ typedef unsigned long long U64;
#define GENERATEINSPECTORINFORMATION(x) (*((ptr *)((uptr)(x)+560)))
#define GENERATEPROFILEFORMS(x) (*((ptr *)((uptr)(x)+568)))
#define GUARDIANENTRIES(x) (*((ptr *)((uptr)(x)+280)))
#define INSTRCOUNTER(x) (*((U64 *)((uptr)(x)+600)))
#define INSTRCOUNTER(x) (*((U64 *)((uptr)(x)+616)))
#define KEYBOARDINTERRUPTPENDING(x) (*((ptr *)((uptr)(x)+424)))
#define METALEVEL(x) (*((ptr *)((uptr)(x)+544)))
#define NULLIMMUTABLEBYTEVECTOR(x) (*((ptr *)((uptr)(x)+528)))
#define NULLIMMUTABLEFXVECTOR(x) (*((ptr *)((uptr)(x)+520)))
#define NULLIMMUTABLESTRING(x) (*((ptr *)((uptr)(x)+536)))
#define NULLIMMUTABLEVECTOR(x) (*((ptr *)((uptr)(x)+512)))
#define OPTIMIZELEVEL(x) (*((ptr *)((uptr)(x)+576)))
#define PARAMETERS(x) (*((ptr *)((uptr)(x)+616)))
#define PARAMETERS(x) (*((ptr *)((uptr)(x)+632)))
#define RANDOMSEED(x) (*((U32 *)((uptr)(x)+304)))
#define REAL_EAP(x) (*((void* *)((uptr)(x)+144)))
#define RET(x) (*((void* *)((uptr)(x)+96)))
Expand Down
Binary file modified boot/a6nt/petite.boot
Binary file not shown.
Binary file modified boot/a6nt/scheme.boot
Binary file not shown.
18 changes: 11 additions & 7 deletions boot/a6osx/equates.h
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ typedef unsigned long U64;
#define size_rp_header 0x20
#define size_rtd_counts 0x810
#define size_symbol 0x30
#define size_tc 0x270
#define size_tc 0x280
#define size_thread 0x10
#define size_tlc 0x20
#define size_typed_object 0x10
Expand Down Expand Up @@ -549,7 +549,7 @@ typedef unsigned long U64;
#define tc_ac0_disp 0x28
#define tc_ac1_disp 0x30
#define tc_active_disp 0x134
#define tc_alloc_counter_disp 0x260
#define tc_alloc_counter_disp 0x270
#define tc_ap_disp 0x50
#define tc_arg_regs_disp 0x0
#define tc_block_counter_disp 0x1D0
Expand All @@ -561,6 +561,8 @@ typedef unsigned long U64;
#define tc_current_input_disp 0x1B8
#define tc_current_mso_disp 0x1E0
#define tc_current_output_disp 0x1C0
#define tc_default_record_equal_procedure_disp 0x258
#define tc_default_record_hash_procedure_disp 0x260
#define tc_disable_count_disp 0x198
#define tc_eap_disp 0x58
#define tc_esp_disp 0x48
Expand All @@ -569,15 +571,15 @@ typedef unsigned long U64;
#define tc_generate_inspector_information_disp 0x230
#define tc_generate_profile_forms_disp 0x238
#define tc_guardian_entries_disp 0x118
#define tc_instr_counter_disp 0x258
#define tc_instr_counter_disp 0x268
#define tc_keyboard_interrupt_pending_disp 0x1A8
#define tc_meta_level_disp 0x220
#define tc_null_immutable_bytevector_disp 0x210
#define tc_null_immutable_fxvector_disp 0x208
#define tc_null_immutable_string_disp 0x218
#define tc_null_immutable_vector_disp 0x200
#define tc_optimize_level_disp 0x240
#define tc_parameters_disp 0x268
#define tc_parameters_disp 0x278
#define tc_random_seed_disp 0x130
#define tc_real_eap_disp 0x90
#define tc_ret_disp 0x60
Expand Down Expand Up @@ -904,7 +906,7 @@ typedef unsigned long U64;
#define AC0(x) (*((void* *)((uptr)(x)+40)))
#define AC1(x) (*((void* *)((uptr)(x)+48)))
#define ACTIVE(x) (*((I32 *)((uptr)(x)+308)))
#define ALLOCCOUNTER(x) (*((U64 *)((uptr)(x)+608)))
#define ALLOCCOUNTER(x) (*((U64 *)((uptr)(x)+624)))
#define AP(x) (*((void* *)((uptr)(x)+80)))
#define ARGREGS(x,i) (((void* *)((uptr)(x)+0))[i])
#define BLOCKCOUNTER(x) (*((ptr *)((uptr)(x)+464)))
Expand All @@ -916,6 +918,8 @@ typedef unsigned long U64;
#define CURRENTINPUT(x) (*((ptr *)((uptr)(x)+440)))
#define CURRENTMSO(x) (*((ptr *)((uptr)(x)+480)))
#define CURRENTOUTPUT(x) (*((ptr *)((uptr)(x)+448)))
#define DEFAULTRECORDEQUALPROCEDURE(x) (*((ptr *)((uptr)(x)+600)))
#define DEFAULTRECORDHASHPROCEDURE(x) (*((ptr *)((uptr)(x)+608)))
#define DISABLECOUNT(x) (*((ptr *)((uptr)(x)+408)))
#define EAP(x) (*((void* *)((uptr)(x)+88)))
#define ESP(x) (*((void* *)((uptr)(x)+72)))
Expand All @@ -924,15 +928,15 @@ typedef unsigned long U64;
#define GENERATEINSPECTORINFORMATION(x) (*((ptr *)((uptr)(x)+560)))
#define GENERATEPROFILEFORMS(x) (*((ptr *)((uptr)(x)+568)))
#define GUARDIANENTRIES(x) (*((ptr *)((uptr)(x)+280)))
#define INSTRCOUNTER(x) (*((U64 *)((uptr)(x)+600)))
#define INSTRCOUNTER(x) (*((U64 *)((uptr)(x)+616)))
#define KEYBOARDINTERRUPTPENDING(x) (*((ptr *)((uptr)(x)+424)))
#define METALEVEL(x) (*((ptr *)((uptr)(x)+544)))
#define NULLIMMUTABLEBYTEVECTOR(x) (*((ptr *)((uptr)(x)+528)))
#define NULLIMMUTABLEFXVECTOR(x) (*((ptr *)((uptr)(x)+520)))
#define NULLIMMUTABLESTRING(x) (*((ptr *)((uptr)(x)+536)))
#define NULLIMMUTABLEVECTOR(x) (*((ptr *)((uptr)(x)+512)))
#define OPTIMIZELEVEL(x) (*((ptr *)((uptr)(x)+576)))
#define PARAMETERS(x) (*((ptr *)((uptr)(x)+616)))
#define PARAMETERS(x) (*((ptr *)((uptr)(x)+632)))
#define RANDOMSEED(x) (*((U32 *)((uptr)(x)+304)))
#define REAL_EAP(x) (*((void* *)((uptr)(x)+144)))
#define RET(x) (*((void* *)((uptr)(x)+96)))
Expand Down
Binary file modified boot/a6osx/petite.boot
Binary file not shown.
Binary file modified boot/a6osx/scheme.boot
Binary file not shown.
Loading

0 comments on commit b6a3dcc

Please sign in to comment.