1995-08-09 08:06:35 -07:00
|
|
|
/***********************************************************************/
|
|
|
|
/* */
|
1996-04-30 07:53:58 -07:00
|
|
|
/* Objective Caml */
|
1995-08-09 08:06:35 -07:00
|
|
|
/* */
|
|
|
|
/* Xavier Leroy, projet Cristal, INRIA Rocquencourt */
|
|
|
|
/* */
|
1996-04-30 07:53:58 -07:00
|
|
|
/* Copyright 1996 Institut National de Recherche en Informatique et */
|
1995-08-09 08:06:35 -07:00
|
|
|
/* Automatique. Distributed only by permission. */
|
|
|
|
/* */
|
|
|
|
/***********************************************************************/
|
|
|
|
|
|
|
|
/* $Id$ */
|
|
|
|
|
1995-05-04 03:15:53 -07:00
|
|
|
/* Primitives for the toplevel */
|
|
|
|
|
|
|
|
#include "alloc.h"
|
1996-05-28 05:41:37 -07:00
|
|
|
#include "config.h"
|
1995-05-09 02:34:59 -07:00
|
|
|
#include "fix_code.h"
|
1995-05-04 03:15:53 -07:00
|
|
|
#include "interp.h"
|
|
|
|
#include "major_gc.h"
|
|
|
|
#include "memory.h"
|
|
|
|
#include "minor_gc.h"
|
|
|
|
#include "misc.h"
|
|
|
|
#include "mlvalues.h"
|
|
|
|
#include "prims.h"
|
1995-09-14 04:52:50 -07:00
|
|
|
#include "stacks.h"
|
1995-05-04 03:15:53 -07:00
|
|
|
|
1997-09-02 05:55:01 -07:00
|
|
|
value get_global_data(value unit) /* ML */
|
1995-05-04 03:15:53 -07:00
|
|
|
{
|
|
|
|
return global_data;
|
|
|
|
}
|
|
|
|
|
1997-09-02 05:55:01 -07:00
|
|
|
value reify_bytecode(value prog, value len) /* ML */
|
1995-05-04 03:15:53 -07:00
|
|
|
{
|
1996-05-28 05:41:37 -07:00
|
|
|
value clos;
|
1996-07-01 05:43:28 -07:00
|
|
|
#ifdef ARCH_BIG_ENDIAN
|
1995-05-04 03:15:53 -07:00
|
|
|
fixup_endianness((code_t) prog, (asize_t) Long_val(len));
|
|
|
|
#endif
|
1996-05-28 05:41:37 -07:00
|
|
|
#ifdef THREADED_CODE
|
|
|
|
thread_code((code_t) prog, (asize_t) Long_val(len));
|
|
|
|
#endif
|
|
|
|
clos = alloc(1, Closure_tag);
|
|
|
|
Code_val(clos) = (code_t) prog;
|
|
|
|
return clos;
|
1995-05-04 03:15:53 -07:00
|
|
|
}
|
|
|
|
|
1997-09-02 05:55:01 -07:00
|
|
|
value realloc_global(value size) /* ML */
|
1995-05-04 03:15:53 -07:00
|
|
|
{
|
|
|
|
mlsize_t requested_size, actual_size, i;
|
|
|
|
value new_global_data;
|
|
|
|
|
|
|
|
requested_size = Long_val(size);
|
|
|
|
actual_size = Wosize_val(global_data);
|
|
|
|
if (requested_size >= actual_size) {
|
|
|
|
requested_size = (requested_size + 0x100) & 0xFFFFFF00;
|
1997-05-13 07:45:38 -07:00
|
|
|
gc_message ("Growing global data to %lu entries.\n", requested_size);
|
1995-05-04 03:15:53 -07:00
|
|
|
new_global_data = alloc_shr(requested_size, 0);
|
|
|
|
for (i = 0; i < actual_size; i++)
|
|
|
|
initialize(&Field(new_global_data, i), Field(global_data, i));
|
|
|
|
for (i = actual_size; i < requested_size; i++){
|
|
|
|
Field (new_global_data, i) = Val_long (0);
|
|
|
|
}
|
|
|
|
global_data = new_global_data;
|
|
|
|
}
|
1995-06-18 07:44:56 -07:00
|
|
|
return Val_unit;
|
1995-05-04 03:15:53 -07:00
|
|
|
}
|
|
|
|
|
1997-09-02 05:55:01 -07:00
|
|
|
value available_primitives(value unit) /* ML */
|
1995-05-04 03:15:53 -07:00
|
|
|
{
|
|
|
|
return copy_string_array(names_of_cprim);
|
|
|
|
}
|
1995-09-14 04:52:50 -07:00
|
|
|
|
1997-09-02 05:55:01 -07:00
|
|
|
value get_current_environment(value unit) /* ML */
|
1995-09-14 04:52:50 -07:00
|
|
|
{
|
|
|
|
return *extern_sp;
|
|
|
|
}
|