Exemple #1
0
void caml_load_code(int fd, asize_t len)
{
  /* OCamlCC: fix g++ warning */
  asize_t i;

  caml_code_size = len;
  caml_start_code = (code_t) caml_stat_alloc(caml_code_size);
  /* OCamlCC: fix g++ warning */
  if (read(fd, (char *) caml_start_code, caml_code_size) !=
      (ssize_t) caml_code_size)
    caml_fatal_error("Fatal error: truncated bytecode file.\n");
  caml_init_code_fragments();
  /* Prepare the code for execution */
#ifdef ARCH_BIG_ENDIAN
  caml_fixup_endianness(caml_start_code, caml_code_size);
#endif
  if (caml_debugger_in_use) {
    len /= sizeof(opcode_t);
    caml_saved_code = (unsigned char *) caml_stat_alloc(len);
    for (i = 0; i < len; i++) caml_saved_code[i] = caml_start_code[i];
  }
#ifdef THREADED_CODE
  /* Better to thread now than at the beginning of [caml_interprete],
     since the debugger interface needs to perform SET_EVENT requests
     on the code. */
  caml_thread_code(caml_start_code, caml_code_size);
#endif
}
Exemple #2
0
CAMLprim value caml_reify_bytecode(value prog, value len)
{
  value clos;
#ifdef ARCH_BIG_ENDIAN
  caml_fixup_endianness((code_t) prog, (asize_t) Long_val(len));
#endif
#ifdef THREADED_CODE
  caml_thread_code((code_t) prog, (asize_t) Long_val(len));
#endif
  clos = caml_alloc_small (1, Closure_tag);
  Init_field(clos, 0, Val_bytecode(prog));
  return clos;
}
Exemple #3
0
CAMLprim value caml_reify_bytecode(value prog, value len)
{
  value clos;
#ifdef ARCH_BIG_ENDIAN
  caml_fixup_endianness((code_t) prog, (asize_t) Long_val(len));
#endif
#ifdef THREADED_CODE
  caml_thread_code((code_t) prog, (asize_t) Long_val(len));
#endif
  caml_prepare_bytecode((code_t) prog, (asize_t) Long_val(len));
  clos = caml_alloc_small (1, Closure_tag);
  Code_val(clos) = (code_t) prog;
  return clos;
}