☠☠ backed out by a37fedd51b7d ☠ ☠ | |
author | Boris Zbarsky <bzbarsky@mit.edu> |
Thu, 30 Oct 2014 17:40:15 -0400 | |
changeset 213249 | 2d449a2b4e1cc684f316f2ad116e352497f6798e |
parent 213248 | 49ac8f33ab70633088ef1121f9646d5dac9294a6 |
child 213250 | de692c3335f2c67402d155a6b512cab4b7b88e70 |
push id | 27745 |
push user | cbook@mozilla.com |
push date | Fri, 31 Oct 2014 13:09:12 +0000 |
treeherder | mozilla-central@6bd2071b373f [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | shu |
bugs | 1088228 |
milestone | 36.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
js/src/jsapi.cpp | file | annotate | diff | comparison | revisions | |
js/src/jsapi.h | file | annotate | diff | comparison | revisions |
--- a/js/src/jsapi.cpp +++ b/js/src/jsapi.cpp @@ -3914,16 +3914,31 @@ JS_CloneFunctionObject(JSContext *cx, Ha if (fun->isNative() && IsAsmJSModuleNative(fun->native())) { JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_CANT_CLONE_OBJECT); return nullptr; } return CloneFunctionObject(cx, fun, parent, fun->getAllocKind()); } +namespace JS { + +JS_PUBLIC_API(JSObject *) +CloneFunctionObject(JSContext *cx, HandleObject funobj, AutoObjectVector &scopeChain) +{ + RootedObject dynamicScope(cx); + RootedObject unusedStaticScope(cx); + if (!CreateScopeObjectsForScopeChain(cx, scopeChain, &dynamicScope, &unusedStaticScope)) + return nullptr; + + return JS_CloneFunctionObject(cx, funobj, dynamicScope); +} + +} // namespace JS + JS_PUBLIC_API(JSObject *) JS_GetFunctionObject(JSFunction *fun) { return fun; } JS_PUBLIC_API(JSString *) JS_GetFunctionId(JSFunction *fun)
--- a/js/src/jsapi.h +++ b/js/src/jsapi.h @@ -3529,16 +3529,28 @@ JS_DefineFunctionById(JSContext *cx, JS: /* * Clone a top-level function into a new scope. This function will dynamically * fail if funobj was lexically nested inside some other function. */ extern JS_PUBLIC_API(JSObject *) JS_CloneFunctionObject(JSContext *cx, JS::Handle<JSObject*> funobj, JS::Handle<JSObject*> parent); +namespace JS { + +/* + * As above, but providing an explicit scope chain. scopeChain must not include + * the global object on it; that's implicit. It needs to contain the other + * objects that should end up on the clone's scope chain. + */ +extern JS_PUBLIC_API(JSObject *) +CloneFunctionObject(JSContext *cx, HandleObject funobj, AutoObjectVector &scopeChain); + +} // namespace JS + /* * Given a buffer, return false if the buffer might become a valid * javascript statement with the addition of more lines. Otherwise return * true. The intent is to support interactive compilation - accumulate * lines in a buffer until JS_BufferIsCompilableUnit is true, then pass it to * the compiler. */ extern JS_PUBLIC_API(bool)