Skip to content

reachabilityFence and AOT #49662

Closed
Closed
@blaugold

Description

@blaugold

@dcharkes A while back, I asked whether there is a difference between the two reachability fences below (#48704 (comment)):

@pragma('vm:never-inline')
void reachabilityFence0(Object? object) => object;

@pragma('vm:never-inline')
void reachabilityFence1(Object? object) {}

void main(List<String> args) {
  reachabilityFence0(args);
  reachabilityFence1(args);
}

At least in AOT, it seems that the argument to reachabilityFence1 is replaced with a constant, rendering the fence ineffective:

*** BEGIN CFG
After AllocateRegisters
==== file:///Users/gabriel/Dev/cbl-dart/foo.dart_::_reachabilityFence1 (RegularFunction)
  0: B0[graph]:0 {
      v0 <- Constant(#null) T{Null?}
}
  2: B1[function entry]:2
  3:     ParallelMove r0 <- C
  4:     Return:10(v0)
*** END CFG
Code for optimized function 'file:///Users/gabriel/Dev/cbl-dart/foo.dart_::_reachabilityFence1' (RegularFunction) {
0x1019b65c0    aa1603e0               mov r0, nr
0x1019b65c4    d65f03c0               ret
}

*** BEGIN CFG
After AllocateRegisters
==== file:///Users/gabriel/Dev/cbl-dart/foo.dart_::_reachabilityFence0 (RegularFunction)
  0: B0[graph]:0 {
}
  2: B1[function entry]:2 {
      v2 <- Parameter(0) T{Object}
}
  3:     ParallelMove r0 <- S+0
  4:     Return:10(v2)
*** END CFG
Code for optimized function 'file:///Users/gabriel/Dev/cbl-dart/foo.dart_::_reachabilityFence0' (RegularFunction) {
0x1019b65e0    f94001e0               ldr r0, [sp]
0x1019b65e4    d65f03c0               ret
}

It might be a good idea to expose the reachabilityFence that is currently internal to the SDK, so that people don't run into this subtle difference.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-vmUse area-vm for VM related issues, including code coverage, and the AOT and JIT backends.library-ffi

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions