Bug 1383174 - Make GetNonSyntacticGlobalThis return void. r=jandem
This method always returns true.
Also, get rid of the unused return statement at the end of the
method. The loop is a while(true) and it has no break statements.
MozReview-Commit-ID: 5hxfSkq6ZUD
--- a/js/src/jit/BaselineCompiler.cpp
+++ b/js/src/jit/BaselineCompiler.cpp
@@ -1540,17 +1540,17 @@ BaselineCompiler::emit_JSOP_FUNCTIONTHIS
if (!callVM(GetFunctionThisInfo))
return false;
masm.bind(&skipCall);
frame.push(R0);
return true;
}
-typedef bool (*GetNonSyntacticGlobalThisFn)(JSContext*, HandleObject, MutableHandleValue);
+typedef void (*GetNonSyntacticGlobalThisFn)(JSContext*, HandleObject, MutableHandleValue);
static const VMFunction GetNonSyntacticGlobalThisInfo =
FunctionInfo<GetNonSyntacticGlobalThisFn>(js::GetNonSyntacticGlobalThis,
"GetNonSyntacticGlobalThis");
bool
BaselineCompiler::emit_JSOP_GLOBALTHIS()
{
frame.syncStack(0);
--- a/js/src/vm/EnvironmentObject.cpp
+++ b/js/src/vm/EnvironmentObject.cpp
@@ -3242,17 +3242,18 @@ js::GetThisValueForDebuggerMaybeOptimize
res.setMagic(JS_OPTIMIZED_OUT);
return true;
}
MOZ_CRASH("'this' binding must be found");
}
- return GetNonSyntacticGlobalThis(cx, scopeChain, res);
+ GetNonSyntacticGlobalThis(cx, scopeChain, res);
+ return true;
}
bool
js::CheckLexicalNameConflict(JSContext* cx, Handle<LexicalEnvironmentObject*> lexicalEnv,
HandleObject varObj, HandlePropertyName name)
{
const char* redeclKind = nullptr;
RootedId id(cx, NameToId(name));
--- a/js/src/vm/Interpreter.cpp
+++ b/js/src/vm/Interpreter.cpp
@@ -124,36 +124,34 @@ js::GetFunctionThis(JSContext* cx, Abstr
res.set(frame.thisArgument());
return true;
}
RootedValue thisv(cx, frame.thisArgument());
return BoxNonStrictThis(cx, thisv, res);
}
-bool
+void
js::GetNonSyntacticGlobalThis(JSContext* cx, HandleObject envChain, MutableHandleValue res)
{
RootedObject env(cx, envChain);
while (true) {
if (IsExtensibleLexicalEnvironment(env)) {
res.set(env->as<LexicalEnvironmentObject>().thisValue());
- return true;
+ return;
}
if (!env->enclosingEnvironment()) {
// This can only happen in Debugger eval frames: in that case we
// don't always have a global lexical env, see EvaluateInEnv.
MOZ_ASSERT(env->is<GlobalObject>());
res.set(GetThisValue(env));
- return true;
+ return;
}
env = env->enclosingEnvironment();
}
-
- return true;
}
bool
js::Debug_CheckSelfHosted(JSContext* cx, HandleValue fun)
{
#ifndef DEBUG
MOZ_CRASH("self-hosted checks should only be done in Debug builds");
#endif
@@ -2720,18 +2718,17 @@ CASE(JSOP_FUNCTIONTHIS)
if (!GetFunctionThis(cx, REGS.fp(), REGS.stackHandleAt(-1)))
goto error;
END_CASE(JSOP_FUNCTIONTHIS)
CASE(JSOP_GLOBALTHIS)
{
if (script->hasNonSyntacticScope()) {
PUSH_NULL();
- if (!GetNonSyntacticGlobalThis(cx, REGS.fp()->environmentChain(), REGS.stackHandleAt(-1)))
- goto error;
+ GetNonSyntacticGlobalThis(cx, REGS.fp()->environmentChain(), REGS.stackHandleAt(-1));
} else {
PUSH_COPY(cx->global()->lexicalEnvironment().thisValue());
}
}
END_CASE(JSOP_GLOBALTHIS)
CASE(JSOP_CHECKISOBJ)
{
--- a/js/src/vm/Interpreter.h
+++ b/js/src/vm/Interpreter.h
@@ -25,17 +25,17 @@ class EnvironmentIter;
* compartment, and replace other primitives with boxed versions.
*/
extern bool
BoxNonStrictThis(JSContext* cx, HandleValue thisv, MutableHandleValue vp);
extern bool
GetFunctionThis(JSContext* cx, AbstractFramePtr frame, MutableHandleValue res);
-extern bool
+extern void
GetNonSyntacticGlobalThis(JSContext* cx, HandleObject envChain, MutableHandleValue res);
/*
* numToSkip is the number of stack values the expression decompiler should skip
* before it reaches |v|. If it's -1, the decompiler will search the stack.
*/
extern bool
ReportIsNotFunction(JSContext* cx, HandleValue v, int numToSkip,