-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix regression when compiling with unique fibers enabled. Extend CI w…
…orkflow with unique fibers tests.
- Loading branch information
Showing
8 changed files
with
122 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
(library | ||
(name multicont_testlib) | ||
(modes byte best) | ||
(modules inspect_fiber) | ||
(foreign_stubs | ||
(language c) | ||
(mode byte) | ||
(flags :standard (:include c_byte_flags.sexp)) | ||
(names inspect_fiber_stubs)) | ||
(foreign_stubs | ||
(language c) | ||
(mode native) | ||
(flags :standard (:include c_native_flags.sexp)) | ||
(names inspect_fiber_stubs))) | ||
|
||
(rule | ||
(targets c_byte_flags.sexp c_native_flags.sexp) | ||
(action (run ../../config/configure.exe))) | ||
|
||
(executable | ||
(name unique_fibers) | ||
(modes byte_complete native) | ||
(modules unique_fibers) | ||
(libraries multicont multicont_testlib)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
type fiber | ||
external fiber_id : fiber -> Int64.t = "multicont_test_lib_fiber_id" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#define CAML_INTERNALS | ||
|
||
#include <caml/mlvalues.h> // provides basic CAML macros and type definitions | ||
#include <caml/fail.h> // provides [caml_raise_out_of_memory] | ||
#include <caml/alloc.h> // provides [caml_alloc_1] | ||
#include <caml/fiber.h> // provides Stack_* macros, [struct stack_info] | ||
#include <caml/memory.h> // provides CAMLparam* and CAMLreturn* macros | ||
#include <caml/misc.h> // provides [CAMLnoalloc] macro | ||
#include <caml/version.h> // provides OCaml versioning macros | ||
|
||
#ifdef NATIVE_CODE | ||
#include <caml/stack.h> | ||
#include <caml/frame_descriptors.h> | ||
#endif | ||
|
||
CAMLextern value caml_copy_int64 (int64_t); // defined in [ocaml/runtime/ints.c] | ||
|
||
CAMLprim value multicont_test_lib_fiber_id(value fiber) { | ||
CAMLparam1(fiber); | ||
CAMLlocal1(id); | ||
struct stack_info *stack = Ptr_val(Field(fiber, 0)); | ||
id = caml_copy_int64(stack->id); | ||
CAMLreturn(id); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
open Effect.Deep | ||
open Multicont.Deep | ||
|
||
type _ Effect.t += Clone : unit Effect.t | ||
|
||
let test unique_fibers_enabled = | ||
let result = ref [] in | ||
match_with Effect.perform Clone | ||
{ retc = (fun _ -> ()) | ||
; exnc = raise | ||
; effc = (fun (type a) (eff : a Effect.t) -> | ||
match eff with | ||
| Clone -> Some (fun (k : (a, _) continuation) -> | ||
let open Multicont_testlib.Inspect_fiber in | ||
let k' = clone_continuation k in | ||
(* NOTE(dhil): The fiber and continuation | ||
representation is the same for deep and | ||
shallow continuations. *) | ||
result := [ fiber_id (Obj.magic k) | ||
; fiber_id (Obj.magic k')]) | ||
| _ -> None ) }; | ||
match !result with | ||
| [original_id; clone_id] when unique_fibers_enabled -> | ||
assert (not (Int64.equal original_id clone_id)) | ||
| [original_id; clone_id] when not unique_fibers_enabled -> | ||
assert (Int64.equal original_id clone_id) | ||
| _ -> assert false | ||
|
||
let _ = | ||
match Sys.getenv_opt "TEST_UNIQUE_FIBERS" with | ||
| Some "true" -> test true | ||
| _ -> test false |