Skip to content

Commit ae6e114

Browse files
author
Irina Yatsenko
committed
Replace literal nullptr with null var object in JavascriptStackWalker::GetThis
1 parent 817a44f commit ae6e114

File tree

2 files changed

+24
-18
lines changed

2 files changed

+24
-18
lines changed

lib/Runtime/Language/JavascriptStackWalker.cpp

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -187,21 +187,20 @@ namespace Js
187187
return FALSE;
188188
}
189189

190-
bool JavascriptStackWalker::GetThis(Var* pVarThis, int moduleId) const
190+
void JavascriptStackWalker::GetThis(Var* pVarThis, int moduleId) const
191191
{
192192
#if ENABLE_NATIVE_CODEGEN
193193
if (inlinedFramesBeingWalked)
194194
{
195195
if (inlinedFrameWalker.GetArgc() == 0)
196196
{
197197
*pVarThis = JavascriptOperators::OP_GetThis(this->scriptContext->GetLibrary()->GetUndefined(), moduleId, scriptContext);
198-
return false;
199198
}
200-
201-
*pVarThis = inlinedFrameWalker.GetThisObject();
202-
Assert(*pVarThis);
203-
204-
return true;
199+
else
200+
{
201+
*pVarThis = inlinedFrameWalker.GetThisObject();
202+
Assert(*pVarThis);
203+
}
205204
}
206205
else
207206
#endif
@@ -210,11 +209,16 @@ namespace Js
210209
if (callInfo.Count == 0)
211210
{
212211
*pVarThis = JavascriptOperators::OP_GetThis(scriptContext->GetLibrary()->GetUndefined(), moduleId, scriptContext);
213-
return false;
214212
}
213+
else
214+
{
215+
*pVarThis = this->GetThisFromFrame();
216+
}
217+
}
215218

216-
*pVarThis = this->GetThisFromFrame();
217-
return (*pVarThis) != nullptr;
219+
if (*pVarThis == nullptr)
220+
{
221+
*pVarThis = this->scriptContext->GetLibrary()->GetNull();
218222
}
219223
}
220224

@@ -1188,14 +1192,17 @@ namespace Js
11881192
return FALSE;
11891193
}
11901194

1191-
bool JavascriptStackWalker::GetThis(Var* pThis, int moduleId, ScriptContext* scriptContext)
1195+
void JavascriptStackWalker::GetThis(Var* pThis, int moduleId, ScriptContext* scriptContext)
11921196
{
11931197
JavascriptStackWalker walker(scriptContext);
11941198
JavascriptFunction* caller;
1195-
return walker.GetCaller(&caller) && walker.GetThis(pThis, moduleId);
1199+
if (walker.GetCaller(&caller))
1200+
{
1201+
walker.GetThis(pThis, moduleId);
1202+
}
11961203
}
11971204

1198-
bool JavascriptStackWalker::GetThis(Var* pThis, int moduleId, JavascriptFunction* func, ScriptContext* scriptContext)
1205+
void JavascriptStackWalker::GetThis(Var* pThis, int moduleId, JavascriptFunction* func, ScriptContext* scriptContext)
11991206
{
12001207
JavascriptStackWalker walker(scriptContext);
12011208
JavascriptFunction* caller;
@@ -1204,10 +1211,9 @@ namespace Js
12041211
if (caller == func)
12051212
{
12061213
walker.GetThis(pThis, moduleId);
1207-
return true;
1214+
return;
12081215
}
12091216
}
1210-
return false;
12111217
}
12121218

12131219
// Try to see whether there is a top-most javascript frame, and if there is return true if it's native.

lib/Runtime/Language/JavascriptStackWalker.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ namespace Js
217217
void SetCurrentFunction(JavascriptFunction * function);
218218
CallInfo GetCallInfo(bool includeInlinedFrames = true) const;
219219
CallInfo GetCallInfoFromPhysicalFrame() const;
220-
bool GetThis(Var *pThis, int moduleId) const;
220+
void GetThis(Var *pThis, int moduleId) const;
221221
Js::Var * GetJavascriptArgs(bool boxArgsAndDeepCopy) const;
222222
void **GetCurrentArgv() const;
223223

@@ -244,8 +244,8 @@ namespace Js
244244
// noinline, we want to use own stack frame.
245245
static _NOINLINE BOOL GetCaller(_Out_opt_ JavascriptFunction** ppFunc, ScriptContext* scriptContext);
246246
static _NOINLINE BOOL GetCaller(_Out_opt_ JavascriptFunction** ppFunc, uint32* byteCodeOffset, ScriptContext* scriptContext);
247-
static _NOINLINE bool GetThis(Var* pThis, int moduleId, ScriptContext* scriptContext);
248-
static _NOINLINE bool GetThis(Var* pThis, int moduleId, JavascriptFunction* func, ScriptContext* scriptContext);
247+
static _NOINLINE void GetThis(Var* pThis, int moduleId, ScriptContext* scriptContext);
248+
static _NOINLINE void GetThis(Var* pThis, int moduleId, JavascriptFunction* func, ScriptContext* scriptContext);
249249

250250
static bool IsDisplayCaller(JavascriptFunction* func);
251251
bool GetDisplayCaller(_Out_opt_ JavascriptFunction ** ppFunc);

0 commit comments

Comments
 (0)