From 52722e54e7c7e1547d1732c210d9df9e43edc0f6 Mon Sep 17 00:00:00 2001 From: Tooru Fujisawa Date: Fri, 15 Apr 2016 12:32:37 +0900 Subject: [PATCH] Bug 1263558 - Part 3: Remove JSFUN_GENERIC_NATIVE. r=till --- js/src/jsapi.h | 12 +----------- js/src/jsobj.cpp | 49 ------------------------------------------------ 2 files changed, 1 insertion(+), 60 deletions(-) diff --git a/js/src/jsapi.h b/js/src/jsapi.h index daba47b02108..55e47c98ecd2 100644 --- a/js/src/jsapi.h +++ b/js/src/jsapi.h @@ -837,17 +837,7 @@ class MOZ_STACK_CLASS SourceBufferHolder final #define JSFUN_CONSTRUCTOR 0x400 /* native that can be called as a ctor */ -/* - * Specify a generic native prototype methods, i.e., methods of a class - * prototype that are exposed as static methods taking an extra leading - * argument: the generic |this| parameter. - * - * If you set this flag in a JSFunctionSpec struct's flags initializer, then - * that struct must live at least as long as the native static method object - * created due to this flag by JS_DefineFunctions or JS_InitClass. Typically - * JSFunctionSpec structs are allocated in static arrays. - */ -#define JSFUN_GENERIC_NATIVE 0x800 +// 0x800 /* Unused */ #define JSFUN_HAS_REST 0x1000 /* function has ...rest parameter. */ diff --git a/js/src/jsobj.cpp b/js/src/jsobj.cpp index 987bbce51934..606d7833fd5b 100644 --- a/js/src/jsobj.cpp +++ b/js/src/jsobj.cpp @@ -2899,34 +2899,6 @@ js::HasDataProperty(JSContext* cx, NativeObject* obj, jsid id, Value* vp) return false; } -static bool -GenericNativeMethodDispatcher(JSContext* cx, unsigned argc, Value* vp) -{ - CallArgs args = CallArgsFromVp(argc, vp); - - const JSFunctionSpec* fs = (JSFunctionSpec*) - args.callee().as().getExtendedSlot(0).toPrivate(); - MOZ_ASSERT((fs->flags & JSFUN_GENERIC_NATIVE) != 0); - - if (argc < 1) { - ReportMissingArg(cx, args.calleev(), 0); - return false; - } - - /* - * Copy all actual (argc) arguments down over our |this| parameter, vp[1], - * which is almost always the class constructor object, e.g. Array. Then - * call the corresponding prototype native method with our first argument - * passed as |this|. - */ - memmove(vp + 1, vp + 2, argc * sizeof(Value)); - - /* Clear the last parameter in case too few arguments were passed. */ - vp[2 + --argc].setUndefined(); - - return fs->call.op(cx, argc, vp); -} - extern bool PropertySpecNameToId(JSContext* cx, const char* name, MutableHandleId id, js::PinningBehavior pin = js::DoNotPinAtom); @@ -2954,27 +2926,6 @@ DefineFunctionFromSpec(JSContext* cx, HandleObject obj, const JSFunctionSpec* fs if (!PropertySpecNameToId(cx, fs->name, &id)) return false; - // Define a generic arity N+1 static method for the arity N prototype - // method if flags contains JSFUN_GENERIC_NATIVE. - if (flags & JSFUN_GENERIC_NATIVE) { - // We require that any consumers using JSFUN_GENERIC_NATIVE stash - // the prototype and constructor in the global slots before invoking - // JS_DefineFunctions on the proto. - JSProtoKey key = JSCLASS_CACHED_PROTO_KEY(obj->getClass()); - MOZ_ASSERT(obj == &obj->global().getPrototype(key).toObject()); - RootedObject ctor(cx, &obj->global().getConstructor(key).toObject()); - - flags &= ~JSFUN_GENERIC_NATIVE; - JSFunction* fun = DefineFunction(cx, ctor, id, - GenericNativeMethodDispatcher, - fs->nargs + 1, flags, - gc::AllocKind::FUNCTION_EXTENDED); - if (!fun) - return false; - - fun->setExtendedSlot(0, PrivateValue(const_cast(fs))); - } - JSFunction* fun = NewFunctionFromSpec(cx, fs, id); if (!fun) return false;