UpNext

13.5.1  _Core

The _Core package is deepest, blackest magic. It is directly relevant only to maintainers working at the heart of the Mythryl system.

Bootstrapping a software system like the Mythryl compiler is quite tricky. There are a number of facilities which each seem to need to be defined before the others. For example, the symbol tables must exist in order to do any compiling at all, but the compiler must be operating in order to compile the symbol table source.

Working around these problems generally involves weird ad hoc hacks, and the earlier in the bootstrap process, the weirder and more ad hoc the hacks get.

The _Core package is the earliest and weirdest of them all; it is defined before anything else, and contains a grabbag of the functions, types and values absolutely most critical to bootstrapping the rest of the system, together with those requiring the most ad hoc of hacks.

The _Core package name is deliberately not legal surface syntax, to reduce the temptation to use this package for anything but its intended very early bootstrapping purposes.

The assembly sub-package provides a gateway to those functions actually implemented in assembly language, rather than C or Mythryl. Since there is actually no Mythryl source code at all for these functions, making this code look like a vanilla Mythryl package to the rest of the system requires some very special-case processing.

The tdp_* functions and values provide hooks for Timing, Debugging and Profiling functionality, which are implemented via low-level backdoors into code generation.

The exceptions defined are those needed at low internal levels within the system, which thus need to be available very early in bootstrapping.

The most relevant sourcefile is src/lib/core/init/core.pkg.

Also relevant are src/app/makelib/compile/core-hack.pkg and src/lib/compiler/front/typer-stuff/basics/core-symbol.pkg.

The above information is manually maintained and may contain errors.

api {    assign : (Ref(X ) , X) -> Void;
    delay : (Void -> X) -> Suspension(X );
    deref : Ref(X ) -> X;
    fin_to_inf : (?.Int1 , Bool) -> ?.core_multiword_int::Multiword_Int;
    force : Suspension(X ) -> X;
    get : (Rw_Vector(X ) , Int) -> X;
    iadd : (Int , Int) -> Int;
    inf_low_value : ?.core_multiword_int::Multiword_Int -> Int;
    make_float_vector : (Int , Float) -> Rw_Vector(Float );
    make_neg_inf : List(?.word ) -> ?.core_multiword_int::Multiword_Int;
    make_pos_inf : List(?.word ) -> ?.core_multiword_int::Multiword_Int;
    make_small_neg_inf : ?.word -> ?.core_multiword_int::Multiword_Int;
    make_small_pos_inf : ?.word -> ?.core_multiword_int::Multiword_Int;
    make_vector : (Int , X) -> Rw_Vector(X );
    maximum_vector_length : Int;
    poly_equal : (X , X) -> Bool;
    register_package_for_time_profiling : Ref(
                                            (String -> (Int , Rw_Vector(Int ) , Ref(Int )))
                                            );
    space_profiling_register : Ref(((runtime::Chunk , String) -> runtime::Chunk) );
    string_equal : (String , String) -> Bool;
    tdp_active_plugins : Ref(List(Tdp_Plugin ) );
    tdp_enter : Void -> (Int , Int) -> Void;
    tdp_idk_entry_point : Int;
    tdp_idk_non_tail_call : Int;
    tdp_idk_tail_call : Int;
    tdp_nopush : Void -> (Int , Int) -> Void;
    tdp_push : Void -> (Int , Int) -> Void -> Void;
    tdp_register : Void -> (Int , Int , Int , String) -> Void;
    tdp_reserve : Int -> Int;
    tdp_reset : Void -> Void;
    tdp_save : Void -> Void -> Void -> Void;
    test_inf : ?.core_multiword_int::Multiword_Int -> ?.Int1;
    trunc_inf : ?.core_multiword_int::Multiword_Int -> ?.Int1;
    unboxed_set : (Rw_Vector(X ) , Int , X) -> Void;
    zero_length_vector__global : ?.Vector(X );
    exception BIND;
    exception INDEX_OUT_OF_BOUNDS;
    exception MATCH;
    exception RANGE;
    exception SIZE;
    exception SUBSCRIPT;
    Suspension X;
    Tdp_Plugin  = {enter:(Int , Int) -> Void,  name:String, 
                   nopush:(Int , Int) -> Void, 
                   push:(Int , Int) -> Void -> Void, 
                   register:(Int , Int , Int , String) -> Void, 
                   save:Void -> Void -> Void};
    package runtime : api {
                          Chunk ;
                          Null_Or X = NULL | THE X;
                          package asm : api {
                                            Cfunction  = Cfunction;
                                            Unt8_Rw_Vector  = Unt8_Rw_Vector;
                                            Float64_Rw_Vector  = Float64_Rw_Vector;
                                            Spin_Lock  = Spin_Lock;
                                            make_typeagnostic_rw_vector : (Int , X) -> Rw_Vector(X );
                                            find_cfun : (String , String) -> Cfunction;
                                            call_cfun : (Cfunction , X) -> Y;
                                            make_unt8_rw_vector : Int -> Unt8_Rw_Vector;
                                            make_float64_rw_vector : Int -> Float64_Rw_Vector;
                                            make_string : Int -> String;
                                            make_typeagnostic_ro_vector : (Int , List(X )) -> ?.Vector(X );
                                            floor : Float -> Int;
                                            logb : Float -> Int;
                                            scalb : (Float , Int) -> Float;
                                            try_lock : Spin_Lock -> Bool;
                                            unlock : Spin_Lock -> Void;
                                        };;
                          exception DIVIDE_BY_ZERO;
                          exception OVERFLOW;
                          exception RUNTIME_EXCEPTION (String , Null_Or(Int ));
                          this_fn_profiling_hook_refcell__global : Ref(Int );
                          software_generated_periodic_events_switch_refcell__global : Ref(Bool );
                          software_generated_periodic_event_interval_refcell__global : Ref(Int );
                          software_generated_periodic_event_handler_refcell__global : Ref((?.Fate(Void ) -> ?.Fate(Void )) );
                          unused_int_refcell__global : Ref(Int );
                          pervasive_package_pickle_list__global : Ref(Chunk );
                          posix_interprocess_signal_handler_refcell__global : Ref(
                                                                                ((Int , Int , ?.Fate(Void )) -> ?.Fate(Void ))
                                                                                );
                          zero_length_vector__global : ?.Vector(X );
                      };;
};

Comments and suggestions to: bugs@mythryl.org

UpNext