static Map convertObjectMetaToMap(IMeta o, IF0<Map> createEmptyMap default () -> makeObjectMetaMap()) {
  if (o == null) null;
  
  // The following shortcut depends on the assumption that a meta field never reverts
  // to null when it was a map
  ifndef MetaCanRevertToNull
    O meta = o._getMeta();
    if (meta cast Map) ret meta;
  endifndef
  
  // non-shortcut path (create meta)
  temp var mutex = tempMetaMutex(o);
  var actualMutex = mutex!;
  synchronized(actualMutex) {
    meta = o._getMeta();
    if (meta cast Map) ret meta;
    Map map = createEmptyMap!;
    if (meta != null) map.put(previousMeta := meta);
    o._setMeta(map);
    ret map;
  }
}