X-Git-Url: https://git.saurik.com/apple/javascriptcore.git/blobdiff_plain/6fe7ccc865dc7d7541b93c5bcaf6368d2c98a174..refs/heads/master:/API/JSWeakObjectMapRefPrivate.cpp diff --git a/API/JSWeakObjectMapRefPrivate.cpp b/API/JSWeakObjectMapRefPrivate.cpp index bdd56f6..925c00f 100644 --- a/API/JSWeakObjectMapRefPrivate.cpp +++ b/API/JSWeakObjectMapRefPrivate.cpp @@ -27,10 +27,12 @@ #include "JSWeakObjectMapRefPrivate.h" #include "APICast.h" -#include "APIShims.h" +#include "JSCJSValue.h" #include "JSCallbackObject.h" -#include "JSValue.h" #include "JSWeakObjectMapRefInternal.h" +#include "JSCInlines.h" +#include "Weak.h" +#include "WeakGCMapInlines.h" #include #include @@ -44,35 +46,49 @@ extern "C" { JSWeakObjectMapRef JSWeakObjectMapCreate(JSContextRef context, void* privateData, JSWeakMapDestroyedCallback callback) { ExecState* exec = toJS(context); - APIEntryShim entryShim(exec); - RefPtr map = OpaqueJSWeakObjectMap::create(privateData, callback); + JSLockHolder locker(exec); + RefPtr map = OpaqueJSWeakObjectMap::create(exec->vm(), privateData, callback); exec->lexicalGlobalObject()->registerWeakMap(map.get()); return map.get(); } void JSWeakObjectMapSet(JSContextRef ctx, JSWeakObjectMapRef map, void* key, JSObjectRef object) { + if (!ctx) { + ASSERT_NOT_REACHED(); + return; + } ExecState* exec = toJS(ctx); - APIEntryShim entryShim(exec); + JSLockHolder locker(exec); JSObject* obj = toJS(object); if (!obj) return; - ASSERT(obj->inherits(&JSCallbackObject::s_info) || obj->inherits(&JSCallbackObject::s_info)); - map->map().set(exec->globalData(), key, obj); + ASSERT(obj->inherits(JSProxy::info()) + || obj->inherits(JSCallbackObject::info()) + || obj->inherits(JSCallbackObject::info())); + map->map().set(key, obj); } JSObjectRef JSWeakObjectMapGet(JSContextRef ctx, JSWeakObjectMapRef map, void* key) { + if (!ctx) { + ASSERT_NOT_REACHED(); + return 0; + } ExecState* exec = toJS(ctx); - APIEntryShim entryShim(exec); + JSLockHolder locker(exec); return toRef(jsCast(map->map().get(key))); } void JSWeakObjectMapRemove(JSContextRef ctx, JSWeakObjectMapRef map, void* key) { + if (!ctx) { + ASSERT_NOT_REACHED(); + return; + } ExecState* exec = toJS(ctx); - APIEntryShim entryShim(exec); - map->map().take(key); + JSLockHolder locker(exec); + map->map().remove(key); } // We need to keep this function in the build to keep the nightlies running.