aboutsummaryrefslogtreecommitdiff
path: root/kernel/nativevalues.ml
diff options
context:
space:
mode:
authorPierre Roux2019-09-12 19:02:18 +0200
committerPierre Roux2019-11-01 10:21:07 +0100
commita2ba4016a64f84193261db9a52196adc39cb5767 (patch)
treef8f0facb4d8c99d8bc5f6db34d6b97a58c8216ca /kernel/nativevalues.ml
parentdca0135a263717b3a1a1d7c4f054f039dc08109e (diff)
Reimplement is_float
is_float was relying on Obj.tag triggering a check that we are in the OCaml heap which is expensive. On extreme examples, this can lead to a global 2x speedup. Thanks to Maxime Dénès and Jacques-Henri Jourdan for their help in diagnosing this.
Diffstat (limited to 'kernel/nativevalues.ml')
-rw-r--r--kernel/nativevalues.ml6
1 files changed, 2 insertions, 4 deletions
diff --git a/kernel/nativevalues.ml b/kernel/nativevalues.ml
index 1d4fb5d39c..6b9d49052d 100644
--- a/kernel/nativevalues.ml
+++ b/kernel/nativevalues.ml
@@ -517,10 +517,8 @@ let print x =
(** Support for machine floating point values *)
-let is_float (x:t) =
- let o = Obj.repr x in
- Int.equal (Obj.tag o) Obj.double_tag
-[@@ocaml.inline always]
+external is_float : t -> bool = "coq_is_double"
+[@@noalloc]
let to_float (x:t) = (Obj.magic x : Float64.t)
[@@ocaml.inline always]