refactoring in profiling.js: use JS constructors, implement hash-consing, add some assertions, remove redundant register functions