Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Polymorphic variant with no arguments aren't treated as immediate in record field assignment #7026

Closed
vicuna opened this issue Oct 19, 2015 · 2 comments

Comments

Projects
None yet
2 participants
@vicuna
Copy link

commented Oct 19, 2015

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 ]
}

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.

@vicuna

This comment has been minimized.

Copy link
Author

commented Nov 27, 2015

Comment author: @xavierleroy

Work in progress at #288

@vicuna

This comment has been minimized.

Copy link
Author

commented Dec 6, 2015

Comment author: @gasche

Fixed by Simon Cruanes in #288.

@vicuna vicuna closed this Feb 16, 2017

@vicuna vicuna added the middle-end label Mar 14, 2019

@vicuna vicuna added this to the 4.03.0 milestone Mar 14, 2019

@vicuna vicuna added the bug label Mar 20, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.