Arguments* StackVisitor::Frame::existingArguments() { if (codeBlock()->codeType() != FunctionCode) return 0; if (!codeBlock()->usesArguments()) return 0; VirtualRegister reg; #if ENABLE(DFG_JIT) if (isInlinedFrame()) reg = inlineCallFrame()->argumentsRegister; else #endif // ENABLE(DFG_JIT) reg = codeBlock()->argumentsRegister(); // Care should be taken here since exception fuzzing may raise exceptions in // places where they would be otherwise impossible. Therefore, callFrame may // lack activation even if the codeBlock signals need of activation. Also, // even if codeBlock signals the use of arguments, the // unmodifiedArgumentsRegister may not be initialized yet (neither locally // nor in lexicalEnvironment). JSValue result = jsUndefined(); if (codeBlock()->needsActivation() && callFrame()->hasActivation()) result = callFrame()->lexicalEnvironment()->registerAt(unmodifiedArgumentsRegister(reg).offset()).get(); if (!result || !result.isCell()) // Try local unmodifiedArgumentsRegister if lexicalEnvironment is not present (generally possible) or has not set up registers yet (only possible if fuzzing exceptions). result = callFrame()->r(unmodifiedArgumentsRegister(reg).offset()).jsValue(); if (!result || !result.isCell()) // Protect against the case when exception fuzzing throws when unmodifiedArgumentsRegister is not set up yet (e.g., in op_enter). return 0; return jsCast<Arguments*>(result); }
String StackVisitor::Frame::functionName() const { String traceLine; switch (codeType()) { case CodeType::Wasm: traceLine = makeString(m_wasmFunctionIndexOrName); break; case CodeType::Eval: traceLine = "eval code"_s; break; case CodeType::Module: traceLine = "module code"_s; break; case CodeType::Native: { JSCell* callee = this->callee().asCell(); if (callee) traceLine = getCalculatedDisplayName(callFrame()->vm(), jsCast<JSObject*>(callee)).impl(); break; } case CodeType::Function: traceLine = getCalculatedDisplayName(callFrame()->vm(), jsCast<JSObject*>(this->callee().asCell())).impl(); break; case CodeType::Global: traceLine = "global code"_s; break; } return traceLine.isNull() ? emptyString() : traceLine; }
String StackVisitor::Frame::functionName() { String traceLine; JSObject* callee = this->callee(); switch (codeType()) { case CodeType::Eval: traceLine = ASCIILiteral("eval code"); break; case CodeType::Module: traceLine = ASCIILiteral("module code"); break; case CodeType::Native: if (callee) traceLine = getCalculatedDisplayName(callFrame(), callee).impl(); break; case CodeType::Function: traceLine = getCalculatedDisplayName(callFrame(), callee).impl(); break; case CodeType::Global: traceLine = ASCIILiteral("global code"); break; } return traceLine.isNull() ? emptyString() : traceLine; }
DebuggerCallFrame::Type DebuggerCallFrame::type() const { if (callFrame()[RegisterFile::Callee].getJSValue()) return FunctionType; return ProgramType; }
const UString* DebuggerCallFrame::functionName() const { if (!m_codeBlock) return 0; JSFunction* function = static_cast<JSFunction*>(callFrame()[RegisterFile::Callee].getJSValue()); if (!function) return 0; return &function->name(m_exec); }
Arguments* StackVisitor::Frame::existingArguments() { if (codeBlock()->codeType() != FunctionCode) return 0; if (!codeBlock()->usesArguments()) return 0; VirtualRegister reg; #if ENABLE(DFG_JIT) if (isInlinedFrame()) reg = inlineCallFrame()->argumentsRegister; else #endif // ENABLE(DFG_JIT) reg = codeBlock()->argumentsRegister(); JSValue result = callFrame()->r(unmodifiedArgumentsRegister(reg).offset()).jsValue(); if (!result || !result.isCell()) // Protect against Undefined in case we throw in op_enter. return 0; return jsCast<Arguments*>(result); }