зеркало из https://github.com/mozilla/gecko-dev.git
Bug 775788 - Modify JSFunctionSpec to accept JSJitInfos. (r=luke)
This commit is contained in:
Родитель
d50fdfb27d
Коммит
a2abc41ee2
|
@ -107,8 +107,8 @@ netscape_security_enablePrivilege(JSContext *cx, unsigned argc, jsval *vp)
|
|||
}
|
||||
|
||||
static JSFunctionSpec PrivilegeManager_static_methods[] = {
|
||||
{ "enablePrivilege", netscape_security_enablePrivilege, 1,0},
|
||||
{nullptr,nullptr,0,0}
|
||||
JS_FS("enablePrivilege", netscape_security_enablePrivilege, 1, 0),
|
||||
JS_FS_END
|
||||
};
|
||||
|
||||
/*
|
||||
|
|
|
@ -2612,14 +2612,14 @@ TraceMallocDumpAllocations(JSContext *cx, unsigned argc, jsval *vp)
|
|||
}
|
||||
|
||||
static JSFunctionSpec TraceMallocFunctions[] = {
|
||||
{"TraceMallocDisable", TraceMallocDisable, 0, 0},
|
||||
{"TraceMallocEnable", TraceMallocEnable, 0, 0},
|
||||
{"TraceMallocOpenLogFile", TraceMallocOpenLogFile, 1, 0},
|
||||
{"TraceMallocChangeLogFD", TraceMallocChangeLogFD, 1, 0},
|
||||
{"TraceMallocCloseLogFD", TraceMallocCloseLogFD, 1, 0},
|
||||
{"TraceMallocLogTimestamp", TraceMallocLogTimestamp, 1, 0},
|
||||
{"TraceMallocDumpAllocations", TraceMallocDumpAllocations, 1, 0},
|
||||
{nullptr, nullptr, 0, 0}
|
||||
JS_FS("TraceMallocDisable", TraceMallocDisable, 0, 0),
|
||||
JS_FS("TraceMallocEnable", TraceMallocEnable, 0, 0),
|
||||
JS_FS("TraceMallocOpenLogFile", TraceMallocOpenLogFile, 1, 0),
|
||||
JS_FS("TraceMallocChangeLogFD", TraceMallocChangeLogFD, 1, 0),
|
||||
JS_FS("TraceMallocCloseLogFD", TraceMallocCloseLogFD, 1, 0),
|
||||
JS_FS("TraceMallocLogTimestamp", TraceMallocLogTimestamp, 1, 0),
|
||||
JS_FS("TraceMallocDumpAllocations", TraceMallocDumpAllocations, 1, 0),
|
||||
JS_FS_END
|
||||
};
|
||||
|
||||
#endif /* NS_TRACE_MALLOC */
|
||||
|
|
|
@ -448,7 +448,7 @@ XrayResolveProperty(JSContext* cx, JSObject* wrapper, jsid id,
|
|||
size_t i = methods[prefIdx].specs - methodSpecs;
|
||||
for ( ; methodIds[i] != JSID_VOID; ++i) {
|
||||
if (id == methodIds[i]) {
|
||||
JSFunction *fun = JS_NewFunctionById(cx, methodSpecs[i].call,
|
||||
JSFunction *fun = JS_NewFunctionById(cx, methodSpecs[i].call.op,
|
||||
methodSpecs[i].nargs, 0,
|
||||
wrapper, id);
|
||||
if (!fun)
|
||||
|
|
|
@ -492,21 +492,21 @@ DumpHeap(JSContext *cx,
|
|||
|
||||
JSFunctionSpec gGlobalFunctions[] =
|
||||
{
|
||||
{"print", Print, 0,0},
|
||||
{"load", Load, 1,0},
|
||||
{"quit", Quit, 0,0},
|
||||
{"version", Version, 1,0},
|
||||
{"build", BuildDate, 0,0},
|
||||
{"dumpXPC", DumpXPC, 1,0},
|
||||
{"dump", Dump, 1,0},
|
||||
{"gc", GC, 0,0},
|
||||
#ifdef JS_GC_ZEAL
|
||||
{"gczeal", GCZeal, 1,0},
|
||||
#endif
|
||||
#ifdef DEBUG
|
||||
{"dumpHeap", DumpHeap, 5,0},
|
||||
#endif
|
||||
{nullptr,nullptr,0,0}
|
||||
JS_FS("print", Print, 0,0),
|
||||
JS_FS("load", Load, 1,0),
|
||||
JS_FS("quit", Quit, 0,0),
|
||||
JS_FS("version", Version, 1,0),
|
||||
JS_FS("build", BuildDate, 0,0),
|
||||
JS_FS("dumpXPC", DumpXPC, 1,0),
|
||||
JS_FS("dump", Dump, 1,0),
|
||||
JS_FS("gc", GC, 0,0),
|
||||
#ifdef JS_GC_ZEAL
|
||||
JS_FS("gczeal", GCZeal, 1,0),
|
||||
#endif
|
||||
#ifdef DEBUG
|
||||
JS_FS("dumpHeap", DumpHeap, 5,0),
|
||||
#endif
|
||||
JS_FS_END
|
||||
};
|
||||
|
||||
typedef enum JSShellErrNum
|
||||
|
|
|
@ -847,7 +847,7 @@ static JSFunctionSpecWithHelp TestingFunctions[] = {
|
|||
" Enables or disables the assertions related to SPS profiling. This is fairly\n"
|
||||
" expensive, so it shouldn't be enabled normally."),
|
||||
|
||||
JS_FS_END
|
||||
JS_FS_HELP_END
|
||||
};
|
||||
|
||||
namespace js {
|
||||
|
|
|
@ -832,7 +832,7 @@ InitTypeConstructor(JSContext* cx,
|
|||
MutableHandleObject typeProto,
|
||||
MutableHandleObject dataProto)
|
||||
{
|
||||
JSFunction* fun = js::DefineFunctionWithReserved(cx, parent, spec.name, spec.call,
|
||||
JSFunction* fun = js::DefineFunctionWithReserved(cx, parent, spec.name, spec.call.op,
|
||||
spec.nargs, spec.flags);
|
||||
if (!fun)
|
||||
return false;
|
||||
|
|
|
@ -4977,7 +4977,7 @@ js_generic_native_method_dispatcher(JSContext *cx, unsigned argc, Value *vp)
|
|||
/* Clear the last parameter in case too few arguments were passed. */
|
||||
vp[2 + --argc].setUndefined();
|
||||
|
||||
return fs->call(cx, argc, vp);
|
||||
return fs->call.op(cx, argc, vp);
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(JSBool)
|
||||
|
@ -5025,9 +5025,11 @@ JS_DefineFunctions(JSContext *cx, JSObject *objArg, JSFunctionSpec *fs)
|
|||
fun->setExtendedSlot(0, PrivateValue(fs));
|
||||
}
|
||||
|
||||
fun = js_DefineFunction(cx, obj, id, fs->call, fs->nargs, flags);
|
||||
fun = js_DefineFunction(cx, obj, id, fs->call.op, fs->nargs, flags);
|
||||
if (!fun)
|
||||
return JS_FALSE;
|
||||
if (fs->call.info)
|
||||
fun->setJitInfo(fs->call.info);
|
||||
}
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
|
|
@ -4353,9 +4353,16 @@ typedef struct JSPropertyOpWrapper {
|
|||
} JSPropertyOpWrapper;
|
||||
|
||||
/*
|
||||
* Macro static initializers which correspond to the old |op| and |NULL|
|
||||
* respectively, and make it easy to pass no JSJitInfo as part of a
|
||||
* JSPropertySpec.
|
||||
* Wrapper to do as above, but for JSNatives for JSFunctionSpecs.
|
||||
*/
|
||||
typedef struct JSNativeWrapper {
|
||||
JSNative op;
|
||||
const JSJitInfo *info;
|
||||
} JSNativeWrapper;
|
||||
|
||||
/*
|
||||
* Macro static initializers which make it easy to pass no JSJitInfo as part of a
|
||||
* JSPropertySpec or JSFunctionSpec.
|
||||
*/
|
||||
#define JSOP_WRAPPER(op) {op, NULL}
|
||||
#define JSOP_NULLWRAPPER JSOP_WRAPPER(NULL)
|
||||
|
@ -4375,7 +4382,7 @@ struct JSPropertySpec {
|
|||
|
||||
struct JSFunctionSpec {
|
||||
const char *name;
|
||||
JSNative call;
|
||||
JSNativeWrapper call;
|
||||
uint16_t nargs;
|
||||
uint16_t flags;
|
||||
};
|
||||
|
@ -4389,12 +4396,14 @@ struct JSFunctionSpec {
|
|||
/*
|
||||
* Initializer macros for a JSFunctionSpec array element. JS_FN (whose name
|
||||
* pays homage to the old JSNative/JSFastNative split) simply adds the flag
|
||||
* JSFUN_STUB_GSOPS.
|
||||
* JSFUN_STUB_GSOPS. JS_FNINFO allows the simple adding of JSJitInfos.
|
||||
*/
|
||||
#define JS_FS(name,call,nargs,flags) \
|
||||
{name, call, nargs, flags}
|
||||
{name, JSOP_WRAPPER(call), nargs, flags}
|
||||
#define JS_FN(name,call,nargs,flags) \
|
||||
{name, call, nargs, (flags) | JSFUN_STUB_GSOPS}
|
||||
{name, JSOP_WRAPPER(call), nargs, (flags) | JSFUN_STUB_GSOPS}
|
||||
#define JS_FNINFO(name,call,info,nargs,flags) \
|
||||
{name,{call,info},nargs,flags}
|
||||
|
||||
extern JS_PUBLIC_API(JSObject *)
|
||||
JS_InitClass(JSContext *cx, JSObject *obj, JSObject *parent_proto,
|
||||
|
|
|
@ -159,6 +159,8 @@ struct JSFunctionSpecWithHelp {
|
|||
|
||||
#define JS_FN_HELP(name,call,nargs,flags,usage,help) \
|
||||
{name, call, nargs, (flags) | JSPROP_ENUMERATE | JSFUN_STUB_GSOPS, usage, help}
|
||||
#define JS_FS_HELP_END \
|
||||
{NULL, NULL, 0, 0, NULL, NULL}
|
||||
|
||||
extern JS_FRIEND_API(bool)
|
||||
JS_DefineFunctionsWithHelp(JSContext *cx, JSObject *obj, const JSFunctionSpecWithHelp *fs);
|
||||
|
|
|
@ -3817,7 +3817,7 @@ static JSFunctionSpecWithHelp shell_functions[] = {
|
|||
" rooting hazards. This is helpful to reduce the time taken when interpreting\n"
|
||||
" heavily numeric code."),
|
||||
|
||||
JS_FS_END
|
||||
JS_FS_HELP_END
|
||||
};
|
||||
#ifdef MOZ_PROFILING
|
||||
# define PROFILING_FUNCTION_COUNT 5
|
||||
|
|
|
@ -271,12 +271,12 @@ File(JSContext *cx, unsigned argc, jsval *vp)
|
|||
}
|
||||
|
||||
static JSFunctionSpec gGlobalFun[] = {
|
||||
{"dump", Dump, 1,0},
|
||||
{"debug", Debug, 1,0},
|
||||
{"atob", Atob, 1,0},
|
||||
{"btoa", Btoa, 1,0},
|
||||
{"File", File, 1,JSFUN_CONSTRUCTOR},
|
||||
{nullptr,nullptr,0,0}
|
||||
JS_FS("dump", Dump, 1,0),
|
||||
JS_FS("debug", Debug, 1,0),
|
||||
JS_FS("atob", Atob, 1,0),
|
||||
JS_FS("btoa", Btoa, 1,0),
|
||||
JS_FS("File", File, 1,JSFUN_CONSTRUCTOR),
|
||||
JS_FS_END
|
||||
};
|
||||
|
||||
class JSCLContextHelper
|
||||
|
|
|
@ -786,26 +786,26 @@ Parent(JSContext *cx, unsigned argc, jsval *vp)
|
|||
}
|
||||
|
||||
static JSFunctionSpec glob_functions[] = {
|
||||
{"print", Print, 0,0},
|
||||
{"readline", ReadLine, 1,0},
|
||||
{"load", Load, 1,0},
|
||||
{"quit", Quit, 0,0},
|
||||
{"version", Version, 1,0},
|
||||
{"build", BuildDate, 0,0},
|
||||
{"dumpXPC", DumpXPC, 1,0},
|
||||
{"dump", Dump, 1,0},
|
||||
{"gc", GC, 0,0},
|
||||
JS_FS("print", Print, 0,0),
|
||||
JS_FS("readline", ReadLine, 1,0),
|
||||
JS_FS("load", Load, 1,0),
|
||||
JS_FS("quit", Quit, 0,0),
|
||||
JS_FS("version", Version, 1,0),
|
||||
JS_FS("build", BuildDate, 0,0),
|
||||
JS_FS("dumpXPC", DumpXPC, 1,0),
|
||||
JS_FS("dump", Dump, 1,0),
|
||||
JS_FS("gc", GC, 0,0),
|
||||
#ifdef JS_GC_ZEAL
|
||||
{"gczeal", GCZeal, 1,0},
|
||||
JS_FS("gczeal", GCZeal, 1,0),
|
||||
#endif
|
||||
{"options", Options, 0,0},
|
||||
JS_FS("options", Options, 0,0),
|
||||
JS_FN("parent", Parent, 1,0),
|
||||
#ifdef DEBUG
|
||||
{"dumpHeap", DumpHeap, 5,0},
|
||||
JS_FS("dumpHeap", DumpHeap, 5,0),
|
||||
#endif
|
||||
{"sendCommand", SendCommand, 1,0},
|
||||
{"getChildGlobalObject", GetChildGlobalObject, 0,0},
|
||||
{nullptr,nullptr,0,0}
|
||||
JS_FS("sendCommand", SendCommand, 1,0),
|
||||
JS_FS("getChildGlobalObject", GetChildGlobalObject, 0,0),
|
||||
JS_FS_END
|
||||
};
|
||||
|
||||
JSClass global_class = {
|
||||
|
|
|
@ -3002,10 +3002,10 @@ static JSClass SandboxClass = {
|
|||
};
|
||||
|
||||
static JSFunctionSpec SandboxFunctions[] = {
|
||||
{"dump", SandboxDump, 1,0},
|
||||
{"debug", SandboxDebug, 1,0},
|
||||
{"importFunction", SandboxImport, 1,0},
|
||||
{nullptr,nullptr,0,0}
|
||||
JS_FS("dump", SandboxDump, 1,0),
|
||||
JS_FS("debug", SandboxDebug, 1,0),
|
||||
JS_FS("importFunction", SandboxImport, 1,0),
|
||||
JS_FS_END
|
||||
};
|
||||
|
||||
/***************************************************************************/
|
||||
|
|
Загрузка…
Ссылка в новой задаче