code_generation.txt 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. =========================
  2. Code generation with Rust
  3. =========================
  4. 53 tests currently passing (flag --rust):
  5. features/instate/test_instate.xml
  6. features/instate/test_instate_nested.xml
  7. features/event_params/test_internalparam.xml
  8. features/action_lang/test_closure.xml
  9. features/action_lang/test_cond.xml
  10. features/action_lang/test_expressions.xml
  11. features/action_lang/test_functions2.xml
  12. features/action_lang/test_guard_action.xml
  13. features/action_lang/test_guard_readonly.xml
  14. features/action_lang/test_nested.xml
  15. features/history/test_composite_shallow.xml
  16. features/history/test_deep.xml
  17. features/history/test_default.xml
  18. features/history/test_parallel_deep.xml
  19. features/history/test_shallow.xml
  20. features/after/test_after.xml
  21. features/after/test_after_reentry.xml
  22. features/parallel/test_parallel.xml
  23. day_atlee/test_01_dialer_takemany.xml
  24. day_atlee/test_01_dialer_takeone.xml
  25. day_atlee/test_02_counter_takeone.xml
  26. day_atlee/test_03_trafficlight_single.xml
  27. day_atlee/test_04_counter_single.xml
  28. day_atlee/test_06_counter_lifeline.xml
  29. day_atlee/test_13_invar_rhs_smallstep.xml
  30. day_atlee/test_21_counter_combo.xml
  31. semantics/priority/test_explicit_flat.xml
  32. semantics/priority/test_explicit_ortho.xml
  33. semantics/priority/test_source_child.xml
  34. semantics/priority/test_source_parent.xml
  35. semantics/memory_protocol/test_gcsmall.xml
  36. semantics/event_lifeline/test_flat_nextss_takemany.xml
  37. semantics/event_lifeline/test_flat_nextss_takeone.xml
  38. semantics/event_lifeline/test_flat_queue_first.xml
  39. semantics/event_lifeline/test_flat_queue_whole_takemany.xml
  40. semantics/event_lifeline/test_flat_remainder.xml
  41. semantics/event_lifeline/test_ortho_nextcs_takemany.xml
  42. semantics/event_lifeline/test_ortho_nextcs_takeone.xml
  43. semantics/event_lifeline/test_ortho_nextss.xml
  44. semantics/event_lifeline/test_ortho_queue.xml
  45. semantics/big_step_maximality/test_cross_region1.xml
  46. semantics/big_step_maximality/test_cross_region2.xml
  47. semantics/big_step_maximality/test_flat_syntactic.xml
  48. semantics/big_step_maximality/test_flat_takemany.xml
  49. semantics/big_step_maximality/test_flat_takeone.xml
  50. semantics/big_step_maximality/test_ortho_syntactic.xml
  51. semantics/big_step_maximality/test_ortho_takemany.xml
  52. semantics/big_step_maximality/test_ortho_takeone.xml
  53. xml_syntax/stateref/test_flat_absolute.xml
  54. xml_syntax/stateref/test_flat_relative.xml
  55. xml_syntax/stateref/test_nested_absolute.xml
  56. xml_syntax/stateref/test_nested_relative.xml
  57. Roadmap
  58. -------
  59. (DONE) Milestone 1: Initial compilation to Rust
  60. - (DONE) entering and exiting states correctly
  61. - (DONE) incoming event triggers the right transition
  62. - (DONE) a port of the Controller class to Rust
  63. - (DONE) one implemented action: raise output event
  64. - (DONE) fixed semantics (YAKINDU-like)
  65. - "Take One" big step maximality
  66. - parent-first
  67. - (DONE) goal: subset of SCCD tests passes:
  68. semantics/big_step_maximality/test_flat_takeone.xml
  69. semantics/big_step_maximality/test_ortho_takeone.xml
  70. semantics/priority/test_source_parent.xml
  71. semantics/priority/test_explicit_flat.xml
  72. semantics/priority/test_explicit_ortho.xml
  73. - no history
  74. - no action language
  75. - guards evals and action stmts are just logged to console
  76. - guards always true, actions no effect
  77. - no event parameters
  78. (DONE) Milestone 2: Minimal support for semantic variability:
  79. - (DONE) Priority: Child-first
  80. - (DONE) Big-Step Maximality: Take Many
  81. - (DONE) goal: following tests should pass:
  82. semantics/priority/test_source_child.xml
  83. semantics/big_step_maximality/test_flat_takemany.xml
  84. semantics/big_step_maximality/test_ortho_takemany.xml
  85. (DONE) Milestone 3: Support history
  86. (DONE) Milestone 4: Timers (should be easy)
  87. (DONE) Milestone 5: Internal Events
  88. (DONE) Milestone 6: Action language
  89. (DONE) Milestone 7: INSTATE-function -> INSTATE-macro
  90. - INVARIANT: Action lang must never depend on statechart lang!
  91. - Evaluation of action lang expression can only read/write to the expression's scope (and parent scopes, if expression occurs in a function)
  92. -> Action lang expression evaluation cannot take mut ref to "state configuration"
  93. - Background: Currently implemented in interpreter as a function in "builtin"-scope:
  94. - Builtin-scope instantiated when statechart is instantiated
  95. - INSTATE-function is a value in "builtin" scope, a function partially bound to the statechart's execution state (which contains the "state configuration")
  96. - INSTATE-function takes an array of strings of absolutate paths to states. At runtime, these strings are used as keys in a dictionary to convert them to state IDs.
  97. -> Better to statically convert the absolute state paths to state IDs by introducing *macros*.
  98. - Better implementation:
  99. 1) Support macros in action lang:
  100. - From the type system's point of view, a macro call is just a function call (depending on the macro called, takes typed parameters and returns a typed value)
  101. - Macro body is executed statically, and during type check (= right after constructing AST).
  102. -> For INSTATE-macro, the macro body converts every state path to its correct state object.
  103. - Action lang parser constructor gets a dict of supported macros, their types, and their "bodies"
  104. 2) Based on the insight that INSTATE cannot occur everywhere (e.g. cannot occur in datamodel block), in fact it can only occur during a transition's guard eval or actions, treat these as follows:
  105. - Wrap guard eval or action code in an implicit function with as parameter the "state configuration".
  106. - Expansion of the INSTATE-macro then reads this parameter.
  107. Milestone n+1: "TODO"
  108. - (DONE) Syntactic output events
  109. - (DONE) Event parameters
  110. - Memory Protocol semantics
  111. - Concurrency semantics
  112. Insights
  113. --------
  114. - Rust compiler warnings are actually useful for the modeler:
  115. - e.g. An unexecutable transition is detected as an unreachable statement
  116. - e.g. An unused event is detected as an unused variable or never-constructed enum variant.
  117. - Rust's product ("struct") and sum ("enum") types map perfectly onto And- and Or-states
  118. Performance over time
  119. ---------------------
  120. for test semantics/big_step_maximality/test_ortho_takemany.xml
  121. commit 91a048eedb6eaf224df3567b506cbda07d664781 - Dec 28, 2020 - implemented event parameters, use tuple structs for event types
  122. binary size, opt-level=3: 3244920 bytes
  123. instruction count (perf stat) (opt-level=3): 562.600 instructions:u
  124. commit 950fcc1e7eed1e3b3c5eda75b896078e53eb71c4 - Dec 26, 2020 - syntactic output events (enums instead of strings), re-implemented event queue (entries allocated on heap, 'canceled' flag)
  125. binary size, no opt: 3833544 bytes <- not sure what caused this sudden drop in unoptimized binary size
  126. binary size, opt-level=3: 3255368 bytes
  127. instruction count (perf stat) (opt-level=3): 569.488 instructions:u
  128. commit ae8a94e186ee972c0d3e0b229b77901352137c64 - Dec 23, 2020 - implement additional event lifeline semantics, pass input event by reference instead of by value
  129. binary size, no opt: 800592 bytes
  130. binary size, opt-level=3: 422200 bytes
  131. instruction count (perf stat) (opt-level=3): 570.824 instructions:u
  132. commit 39fc866428c595c7ed909569d998981d1d350059 - Dec 22, 2020 - various fixes, support INSTATE
  133. binary size, no opt: 800544 bytes
  134. binary size, opt-level=3: 422200 bytes
  135. instruction count (perf stat) (opt-level=3): 570.776 instructions:u
  136. commit ec39dd73ea42a9ccee6f1edc8863b36625e0721a - Dec 20, 2020 - put reusable stuff in library
  137. binary size, opt-level=3: 422192 bytes
  138. instruction count (perf stat) (opt-level=3): 571.641 instructions:u
  139. commit 354576dd47587fd8e6277539a26a4743b2167565 - Dec 17, 2020 - action lang working
  140. binary size, no opt: 513760 bytes
  141. binary size, opt-level=3: 421056 bytes
  142. binary size, opt-level=3 inline-threshold=1000: 421056 bytes
  143. binary size, opt-level=z: 429200 bytes
  144. instruction count (perf stat) (opt-level=3): 575.539 instructions:u
  145. commit aa6a734f7d900479de9be99a8cdf68af0d561481 - Dec 2, 2020 - implemented big-step maximality
  146. binary size, no opt: 478976 bytes
  147. binary size, opt-level=3 inline-threshold=1000: 410880 bytes
  148. binary size, opt-level=z: 413576 bytes
  149. instruction count (perf stat) (opt-level=3): 580.701 instructions:u
  150. Performance insights
  151. - non-optimized binary size increased as features were added, optimized binary size stayed pretty much the same. this assures that Rust is able to inline and optimize away the many unused parameters of enter and exit functions.
  152. - the same conclusion can be drawn from binary size being slightly worse when setting a lower inline threshold (opt-level=z). this means that inlining is actually reducing the binaries' size, as we would expect (lots of unused parameters can be eliminated)
  153. - passing input event by reference instead of by value did not change the optimized binary size. probably evidence of Rust inlining or passing by value anyway.