fib, new primitives, and useless analysis
Stephen Weeks
MLton@research.nj.nec.com
Wed, 21 Jun 2000 14:47:57 -0700 (PDT)
> In general, though, I think that optimization needs some tweaking. It's
> coming about because there is an implicit assumption that Prim's do not
> side-effect. (true?)
False. The optimization is only done for prims p such that
Prim.isFunctional p.
We can continue the debate about whether or not Int.+
> should or should not raise Overflow, but certainly FFI's should be
> considered side-effecting.
Of course. Here is the definition of Prim.Name.maySideEffect
val maySideEffect =
fn Array_update => true
| Exn_setTopLevelHandler => true
| FFI _ => true
| GC_collect => true
| MLton_halt => true
| Ref_assign => true
| Thread_copy => true
| Thread_copyShrink => true
| Thread_finishHandler => true
| Thread_switchTo => true
| Word8Array_updateWord => true
| World_save => true
| _ => false
And here is the definition of Prim.Name.isFunctional
val isFunctional =
fn Array_length => true
| Byte_byteToChar => true
| Byte_charToByte => true
| Char_lt => true
| Char_le => true
| Char_gt => true
| Char_ge => true
| Char_chr => true
| Char_ord => true
| Constant _ => true
| Cpointer_isNull => true
| Exn_name => true
| Int_mul => true
| Int_add => true
| Int_sub => true
| Int_lt => true
| Int_le => true
| Int_gt => true
| Int_ge => true
| Int_geu => true
| Int_gtu => true
| Int_quot => true
| Int_rem => true
| Int_neg => true
| IntInf_add => true
| IntInf_areSmall => true
| IntInf_fromWord => true
| IntInf_isSmall => true
| IntInf_mul => true
| IntInf_neg => true
| IntInf_quot => true
| IntInf_rem => true
| IntInf_sub => true
| IntInf_toString => true
| IntInf_toWord => true
| MLton_eq => true
(* MLton_equal is commented out because I don't want globalization or
* constant propagation to move it into the globals, because
* polymorphic equality isn't implemented there.
*)
(* | MLton_equal => true *)
| MLton_id => true
| Real_nequal => true
| Real_mul => true
| Real_muladd => true
| Real_mulsub => true
| Real_add => true
| Real_sub => true
| Real_div => true
| Real_lt => true
| Real_le => true
| Real_equal => true
| Real_gt => true
| Real_ge => true
| Real_qequal => true
| Real_abs => true
| Real_fromInt => true
| Real_toInt => true
| Real_neg => true
| Vector_sub => true
| Vector_length => true
| Word8_mul => true
| Word8_add => true
| Word8_sub => true
| Word8_lt => true
| Word8_lshift => true
| Word8_le => true
| Word8_gt => true
| Word8_ge => true
| Word8_rshift => true
| Word8_andb => true
| Word8_div => true
| Word8_fromInt => true
| Word8_fromLargeWord => true
| Word8_mod => true
| Word8_notb => true
| Word8_orb => true
| Word8_toInt => true
| Word8_toIntX => true
| Word8_toLargeWord => true
| Word8_toLargeWordX => true
| Word8_xorb => true
| Word8_arshift => true
| Word32_mul => true
| Word32_add => true
| Word32_sub => true
| Word32_lt => true
| Word32_lshift => true
| Word32_le => true
| Word32_gt => true
| Word32_ge => true
| Word32_rshift => true
| Word32_andb => true
| Word32_div => true
| Word32_fromInt => true
| Word32_mod => true
| Word32_notb => true
| Word32_orb => true
| Word32_toIntX => true
| Word32_xorb => true
| Word32_arshift => true
| _ => false