Original bug ID: 7026 Reporter: tianyicui Assigned to:@gasche Status: closed (set by @xavierleroy on 2017-02-16T14:18:25Z) Resolution: fixed Priority: normal Severity: minor Platform: x86-64 OS: Linux Version: 4.02.3 Target version: 4.03.0+dev / +beta1 Fixed in version: 4.03.0+dev / +beta1 Category: middle end (typedtree to clambda) Monitored by:@diml@hcarty
Bug description
When a record field has a polymorphic variant type with no arguments (like [a | b]), use '<-' to assign it involves an unnecessary caml_modify call.Immediate p
Steps to reproduce
$ cat test.ml
type t =
{ mutable field : [ a | b ]
}
Original bug ID: 7026
Reporter: tianyicui
Assigned to: @gasche
Status: closed (set by @xavierleroy on 2017-02-16T14:18:25Z)
Resolution: fixed
Priority: normal
Severity: minor
Platform: x86-64
OS: Linux
Version: 4.02.3
Target version: 4.03.0+dev / +beta1
Fixed in version: 4.03.0+dev / +beta1
Category: middle end (typedtree to clambda)
Monitored by: @diml @hcarty
Bug description
When a record field has a polymorphic variant type with no arguments (like [
a |
b]), use '<-' to assign it involves an unnecessary caml_modify call.Immediate pSteps to reproduce
$ cat test.ml
type t =
{ mutable field : [
a |
b ]}
let assign t field =
t.field <- field
$ ocamlopt.opt -S test.ml
$ cat test.s
...
camlTest__assign_1010:
.cfi_startproc
subq $8, %rsp
.cfi_adjust_cfa_offset 8
.L100:
movq %rax, %rdi
movq %rbx, %rsi
call caml_modify@PLT
movq $1, %rax
addq $8, %rsp
.cfi_adjust_cfa_offset -8
ret
.cfi_adjust_cfa_offset 8
.cfi_endproc
...
Changing the variant into a non-polymorphic one eliminates this caml_modify.
The text was updated successfully, but these errors were encountered: