bool WatchpointMap::watch(JSContext *cx, HandleObject obj, HandleId id, JSWatchPointHandler handler, HandleObject closure) { JS_ASSERT(JSID_IS_STRING(id) || JSID_IS_INT(id)); if (!obj->setWatched(cx)) return false; Watchpoint w; w.handler = handler; w.closure = closure; w.held = false; if (!map.put(WatchKey(obj, id), w)) { js_ReportOutOfMemory(cx); return false; } return true; }
bool WatchpointMap::watch(JSContext* cx, HandleObject obj, HandleId id, JSWatchPointHandler handler, HandleObject closure) { MOZ_ASSERT(JSID_IS_STRING(id) || JSID_IS_INT(id) || JSID_IS_SYMBOL(id)); if (!obj->setWatched(cx)) return false; Watchpoint w(handler, closure, false); if (!map.put(WatchKey(obj, id), w)) { ReportOutOfMemory(cx); return false; } /* * For generational GC, we don't need to post-barrier writes to the * hashtable here because we mark all watchpoints as part of root marking in * markAll(). */ return true; }