Question

Is it possible to use garbage collector inside pnacl? When I'm trying to link .bc files in .pexe with pnacl-clang++, I got

Function _ZN8PSModule14CreateInstanceEi has disallowed "gc" attribute

Function llvm.gcroot is a disallowed LLVM intrinsic

Was it helpful?

Solution

It is possible to use garbage collectors inside PNaCl in general, but PNaCl doesn't support the GC features of LLVM IR.

PNaCl doesn't allow LLVM IR's "gc" function attribute or the gcroot/gcread/gcwrite intrinsics. These features are not in PNaCl's whitelist, which omits LLVM IR's more complex features in order to keep the PNaCl ABI as simple as possible.

If you want to do tracing GC in PNaCl, the GC will have to use the same techniques that are normally used for implementing GC in portable C/C++. For example, if you want a local variable to be a GC root, you can write its value to an alloca'd block, and ensure that the block is linked into a list of roots.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top