mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 11:55:49 +00:00
Bug 989373, part 2 - Remove unused JS API methods related to global sharing while compiling to functions. r=shu
These functions are only needed for B2G-style global sharing, which is based getting |this| as the special JSM object by compiling .jsms are functions. I left in place the comments relating this sharing because we may still reuse that machinery. MozReview-Commit-ID: IBBW5P70TQm --HG-- extra : rebase_source : 60cdf549db737ab8dac81c7f48ff7287639a851d
This commit is contained in:
parent
05d8bb3c65
commit
bcb1ad469b
@ -27,7 +27,6 @@ UNIFIED_SOURCES += [
|
||||
'testDefinePropertyIgnoredAttributes.cpp',
|
||||
'testDeflateStringToUTF8Buffer.cpp',
|
||||
'testDifferentNewTargetInvokeConstructor.cpp',
|
||||
'testEnclosingFunction.cpp',
|
||||
'testErrorCopying.cpp',
|
||||
'testException.cpp',
|
||||
'testExternalArrayBuffer.cpp',
|
||||
|
@ -1,68 +0,0 @@
|
||||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* vim: set ts=8 sts=4 et sw=4 tw=99:
|
||||
*
|
||||
* Test script cloning.
|
||||
*/
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "jsfriendapi.h"
|
||||
|
||||
#include "jsapi-tests/tests.h"
|
||||
|
||||
using namespace js;
|
||||
|
||||
static JSFunction* foundFun = nullptr;
|
||||
|
||||
static bool
|
||||
CheckEnclosing(JSContext* cx, unsigned argc, Value* vp)
|
||||
{
|
||||
CallArgs args = CallArgsFromVp(argc, vp);
|
||||
|
||||
foundFun = js::GetOutermostEnclosingFunctionOfScriptedCaller(cx);
|
||||
|
||||
args.rval().set(UndefinedValue());
|
||||
return true;
|
||||
}
|
||||
|
||||
BEGIN_TEST(test_enclosingFunction)
|
||||
{
|
||||
CHECK(JS_DefineFunction(cx, global, "checkEnclosing", CheckEnclosing, 0, 0));
|
||||
|
||||
EXEC("checkEnclosing()");
|
||||
CHECK(foundFun == nullptr);
|
||||
|
||||
RootedFunction fun(cx);
|
||||
|
||||
JS::CompileOptions options(cx);
|
||||
options.setFileAndLine(__FILE__, __LINE__);
|
||||
|
||||
const char s1chars[] = "checkEnclosing()";
|
||||
JS::AutoObjectVector emptyScopeChain(cx);
|
||||
CHECK(JS::CompileFunction(cx, emptyScopeChain, options, "s1", 0, nullptr, s1chars,
|
||||
strlen(s1chars), &fun));
|
||||
CHECK(fun);
|
||||
CHECK(JS_DefineProperty(cx, global, "s1", fun, JSPROP_ENUMERATE));
|
||||
EXEC("s1()");
|
||||
CHECK(foundFun == fun);
|
||||
|
||||
const char s2chars[] = "return function() { checkEnclosing() }";
|
||||
CHECK(JS::CompileFunction(cx, emptyScopeChain, options, "s2", 0, nullptr, s2chars,
|
||||
strlen(s2chars), &fun));
|
||||
CHECK(fun);
|
||||
CHECK(JS_DefineProperty(cx, global, "s2", fun, JSPROP_ENUMERATE));
|
||||
EXEC("s2()()");
|
||||
CHECK(foundFun == fun);
|
||||
|
||||
const char s3chars[] = "return function() { { let x; function g() { checkEnclosing() } return g() } }";
|
||||
CHECK(JS::CompileFunction(cx, emptyScopeChain, options, "s3", 0, nullptr, s3chars,
|
||||
strlen(s3chars), &fun));
|
||||
CHECK(fun);
|
||||
CHECK(JS_DefineProperty(cx, global, "s3", fun, JSPROP_ENUMERATE));
|
||||
EXEC("s3()()");
|
||||
CHECK(foundFun == fun);
|
||||
|
||||
return true;
|
||||
}
|
||||
END_TEST(test_enclosingFunction)
|
@ -418,34 +418,6 @@ js::RunningWithTrustedPrincipals(JSContext* cx)
|
||||
return cx->runningWithTrustedPrincipals();
|
||||
}
|
||||
|
||||
JS_FRIEND_API(JSFunction*)
|
||||
js::GetOutermostEnclosingFunctionOfScriptedCaller(JSContext* cx)
|
||||
{
|
||||
ScriptFrameIter iter(cx);
|
||||
|
||||
// Skip eval frames.
|
||||
while (!iter.done() && iter.isEvalFrame())
|
||||
++iter;
|
||||
|
||||
if (iter.done())
|
||||
return nullptr;
|
||||
|
||||
if (!iter.isFunctionFrame())
|
||||
return nullptr;
|
||||
|
||||
if (iter.compartment() != cx->compartment())
|
||||
return nullptr;
|
||||
|
||||
RootedFunction curr(cx, iter.callee(cx));
|
||||
for (ScopeIter si(curr->nonLazyScript()); si; si++) {
|
||||
if (si.kind() == ScopeKind::Function)
|
||||
curr = si.scope()->as<FunctionScope>().canonicalFunction();
|
||||
}
|
||||
|
||||
assertSameCompartment(cx, curr);
|
||||
return curr;
|
||||
}
|
||||
|
||||
JS_FRIEND_API(JSFunction*)
|
||||
js::DefineFunctionWithReserved(JSContext* cx, JSObject* objArg, const char* name, JSNative call,
|
||||
unsigned nargs, unsigned attrs)
|
||||
|
@ -667,18 +667,6 @@ inline void AssertSameCompartment(JSObject* objA, JSObject* objB) {}
|
||||
JS_FRIEND_API(void)
|
||||
NotifyAnimationActivity(JSObject* obj);
|
||||
|
||||
/**
|
||||
* Return the outermost enclosing function (script) of the scripted caller.
|
||||
* This function returns nullptr in several cases:
|
||||
* - no script is running on the context
|
||||
* - the caller is in global or eval code
|
||||
* In particular, this function will "stop" its outermost search at eval() and
|
||||
* thus it will really return the outermost enclosing function *since the
|
||||
* innermost eval*.
|
||||
*/
|
||||
JS_FRIEND_API(JSFunction*)
|
||||
GetOutermostEnclosingFunctionOfScriptedCaller(JSContext* cx);
|
||||
|
||||
JS_FRIEND_API(JSFunction*)
|
||||
DefineFunctionWithReserved(JSContext* cx, JSObject* obj, const char* name, JSNative call,
|
||||
unsigned nargs, unsigned attrs);
|
||||
@ -2840,14 +2828,6 @@ extern JS_FRIEND_API(void)
|
||||
SetJitExceptionHandler(JitExceptionHandler handler);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Get the nearest enclosing with environment object for a given function. If
|
||||
* the function is not scripted or is not enclosed by a with scope, returns
|
||||
* the global.
|
||||
*/
|
||||
extern JS_FRIEND_API(JSObject*)
|
||||
GetNearestEnclosingWithEnvironmentObjectForFunction(JSFunction* fun);
|
||||
|
||||
/**
|
||||
* Get the first SavedFrame object in this SavedFrame stack whose principals are
|
||||
* subsumed by the cx's principals. If there is no such frame, return nullptr.
|
||||
|
@ -3095,23 +3095,6 @@ js::GetDebugEnvironmentForGlobalLexicalEnvironment(JSContext* cx)
|
||||
return GetDebugEnvironment(cx, ei);
|
||||
}
|
||||
|
||||
// See declaration and documentation in jsfriendapi.h
|
||||
JS_FRIEND_API(JSObject*)
|
||||
js::GetNearestEnclosingWithEnvironmentObjectForFunction(JSFunction* fun)
|
||||
{
|
||||
if (!fun->isInterpreted())
|
||||
return &fun->global();
|
||||
|
||||
JSObject* env = fun->environment();
|
||||
while (env && !env->is<WithEnvironmentObject>())
|
||||
env = env->enclosingEnvironment();
|
||||
|
||||
if (!env)
|
||||
return &fun->global();
|
||||
|
||||
return &env->as<WithEnvironmentObject>().object();
|
||||
}
|
||||
|
||||
bool
|
||||
js::CreateObjectsForEnvironmentChain(JSContext* cx, AutoObjectVector& chain,
|
||||
HandleObject terminatingEnv, MutableHandleObject envObj)
|
||||
|
Loading…
Reference in New Issue
Block a user