Optimize/annotate kernel/object.h

  * Remove not used code
  * Add `const` where appropriate
  * Annotate parameters as `not NULL` where appropriate to help static code analyzers find possible bugs
  * Move helper functions to `object.h` and make them inline