本文整理汇总了C++中CallFrame类的典型用法代码示例。如果您正苦于以下问题:C++ CallFrame类的具体用法?C++ CallFrame怎么用?C++ CallFrame使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CallFrame类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createScriptCallStack
PassRefPtr<ScriptCallStack> createScriptCallStack(size_t maxStackSize, bool emptyIsAllowed)
{
Vector<ScriptCallFrame> frames;
if (JSC::ExecState* exec = JSMainThreadExecState::currentState()) {
CallFrame* frame = exec->vm().topCallFrame;
for (StackIterator iter = frame->begin(); iter != frame->end() && maxStackSize--; ++iter) {
unsigned line;
unsigned column;
iter->computeLineAndColumn(line, column);
frames.append(ScriptCallFrame(iter->functionName(), iter->sourceURL(), line, column));
}
}
if (frames.isEmpty() && !emptyIsAllowed) {
// No frames found. It may happen in the case where
// a bound function is called from native code for example.
// Fallback to setting lineNumber to 0, and source and function name to "undefined".
frames.append(ScriptCallFrame("undefined", "undefined", 0, 0));
}
return ScriptCallStack::create(frames);
}
示例2: get_variables_frame
CallFrame* VM::get_variables_frame(ssize_t up) {
CallFrame* frame = call_frame_;
while(frame && up-- > 0) {
frame = frame->previous;
}
while(frame) {
if(!frame->is_inline_block()
&& !frame->native_method_p()
&& frame->scope)
{
return frame;
}
frame = frame->previous;
}
return NULL;
}
示例3: asActivation
JSValue JSActivation::argumentsGetter(ExecState* exec, const Identifier&, const PropertySlot& slot)
{
JSActivation* activation = asActivation(slot.slotBase());
if (activation->d()->functionExecutable->usesArguments()) {
PropertySlot slot;
activation->symbolTableGet(exec->propertyNames().arguments, slot);
return slot.getValue(exec, exec->propertyNames().arguments);
}
CallFrame* callFrame = CallFrame::create(activation->d()->registers);
Arguments* arguments = callFrame->optionalCalleeArguments();
if (!arguments) {
arguments = new (callFrame) Arguments(callFrame);
arguments->copyRegisters();
callFrame->setCalleeArguments(arguments);
}
ASSERT(arguments->inherits(&Arguments::info));
return arguments;
}
示例4: createScriptCallStackForConsole
Ref<ScriptCallStack> createScriptCallStackForConsole(JSC::ExecState* exec, size_t maxStackSize)
{
if (!exec)
return ScriptCallStack::create();
JSLockHolder locker(exec);
Vector<ScriptCallFrame> frames;
CallFrame* frame = exec->vm().topCallFrame;
if (!frame)
return ScriptCallStack::create();
CreateScriptCallStackFunctor functor(true, frames, maxStackSize);
frame->iterate(functor);
if (frames.isEmpty()) {
CreateScriptCallStackFunctor functor(false, frames, maxStackSize);
frame->iterate(functor);
}
return ScriptCallStack::create(frames);
}
示例5: while
void ScriptCallStack::fillFrames()
{
if (m_filled || !m_caller)
return;
/*
AJValue function = m_exec->interpreter()->retrieveCaller(m_exec, m_caller);
while (!function.isNull()) {
InternalFunction* internal = asInternalFunction(function);
m_frames.append(ScriptCallFrame(internal->name(m_exec), UString(), 0, ArgList(), 0));
function = m_exec->interpreter()->retrieveCaller(m_exec, internal);
}*/
CallFrame* callFrame = m_exec->callerFrame();
while(callFrame) {
UString functionName;
int tmpLineNO;
intptr_t sourceID;
UString urlString;
AJValue function;
m_exec->interpreter()->retrieveLastCaller(callFrame, tmpLineNO, sourceID, urlString, function);
if (function) {
functionName = asInternalFunction(function)->name(m_exec);
} else {
if (!m_frames.isEmpty())
break;
}
unsigned lineNO = tmpLineNO >= 0 ? tmpLineNO : 0;
m_frames.append(ScriptCallFrame(functionName, urlString, lineNO, ArgList(), 0));
if (!function)
break;
callFrame = callFrame->callerFrame();
}
m_filled = true;
}
示例6: getOwnNonIndexPropertyNames
void JSActivation::getOwnNonIndexPropertyNames(JSObject* object, ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode)
{
JSActivation* thisObject = jsCast<JSActivation*>(object);
CallFrame* callFrame = CallFrame::create(reinterpret_cast<Register*>(thisObject->m_registers));
if (mode == IncludeDontEnumProperties && !thisObject->isTornOff() && (callFrame->codeBlock()->usesArguments() || callFrame->codeBlock()->usesEval()))
propertyNames.add(exec->propertyNames().arguments);
{
ConcurrentJITLocker locker(thisObject->symbolTable()->m_lock);
SymbolTable::Map::iterator end = thisObject->symbolTable()->end(locker);
for (SymbolTable::Map::iterator it = thisObject->symbolTable()->begin(locker); it != end; ++it) {
if (it->value.getAttributes() & DontEnum && mode != IncludeDontEnumProperties)
continue;
if (!thisObject->isValid(it->value))
continue;
propertyNames.add(Identifier(exec, it->key.get()));
}
}
// Skip the JSVariableObject implementation of getOwnNonIndexPropertyNames
JSObject::getOwnNonIndexPropertyNames(thisObject, exec, propertyNames, mode);
}
示例7: ASSERT
void StackIterator::readInlinedFrame(CallFrame* callFrame, CodeOrigin* codeOrigin)
{
ASSERT(codeOrigin);
ASSERT(!callFrame->hasHostCallFrameFlag());
unsigned frameOffset = inlinedFrameOffset(codeOrigin);
bool isInlined = !!frameOffset;
if (isInlined) {
InlineCallFrame* inlineCallFrame = codeOrigin->inlineCallFrame;
m_frame.m_callFrame = callFrame;
m_frame.m_inlineCallFrame = inlineCallFrame;
m_frame.m_argumentCountIncludingThis = inlineCallFrame->arguments.size();
m_frame.m_codeBlock = inlineCallFrame->baselineCodeBlock();
m_frame.m_bytecodeOffset = codeOrigin->bytecodeIndex;
JSFunction* callee = inlineCallFrame->callee.get();
if (callee) {
m_frame.m_scope = callee->scope();
m_frame.m_callee = callee;
} else {
CallFrame* inlinedFrame = callFrame + frameOffset;
m_frame.m_scope = inlinedFrame->scope();
m_frame.m_callee = inlinedFrame->callee();
}
ASSERT(m_frame.scope());
ASSERT(m_frame.callee());
// The callerFrame just needs to be non-null to indicate that we
// haven't reached the last frame yet. Setting it to the root
// frame (i.e. the callFrame that this inlined frame is called from)
// would work just fine.
m_frame.m_callerFrame = callFrame;
return;
}
readNonInlinedFrame(callFrame, codeOrigin);
}
示例8: while
void ScriptCallStack::initialize()
{
if (!m_caller || m_initialized)
return;
int signedLineNumber;
intptr_t sourceID;
UString urlString;
JSValue function;
// callFrame must exist if m_caller is not null.
CallFrame* callFrame = m_exec->callerFrame();
while (true) {
ASSERT(callFrame);
m_exec->interpreter()->retrieveLastCaller(callFrame, signedLineNumber, sourceID, urlString, function);
if (!function)
break;
JSFunction* jsFunction = asFunction(function);
unsigned lineNumber = signedLineNumber >= 0 ? signedLineNumber : 0;
m_frames.append(ScriptCallFrame(jsFunction->name(m_exec), urlString, lineNumber, m_exec, 0));
callFrame = callFrame->callerFrame();
}
m_initialized = true;
}
示例9: ASSERT
// Evaluate some JavaScript code in the scope of this frame.
JSValue DebuggerCallFrame::evaluate(const String& script, NakedPtr<Exception>& exception)
{
ASSERT(isValid());
CallFrame* callFrame = m_callFrame;
if (!callFrame)
return jsNull();
JSLockHolder lock(callFrame);
if (!callFrame->codeBlock())
return JSValue();
DebuggerEvalEnabler evalEnabler(callFrame);
VM& vm = callFrame->vm();
auto& codeBlock = *callFrame->codeBlock();
ThisTDZMode thisTDZMode = codeBlock.unlinkedCodeBlock()->constructorKind() == ConstructorKind::Derived ? ThisTDZMode::AlwaysCheck : ThisTDZMode::CheckIfNeeded;
VariableEnvironment variablesUnderTDZ;
JSScope::collectVariablesUnderTDZ(scope()->jsScope(), variablesUnderTDZ);
EvalExecutable* eval = EvalExecutable::create(callFrame, makeSource(script), codeBlock.isStrictMode(), thisTDZMode, codeBlock.unlinkedCodeBlock()->isDerivedConstructorContext(), codeBlock.unlinkedCodeBlock()->isArrowFunction(), &variablesUnderTDZ);
if (vm.exception()) {
exception = vm.exception();
vm.clearException();
return jsUndefined();
}
JSValue thisValue = thisValueForCallFrame(callFrame);
JSValue result = vm.interpreter->execute(eval, callFrame, thisValue, scope()->jsScope());
if (vm.exception()) {
exception = vm.exception();
vm.clearException();
}
ASSERT(result);
return result;
}
示例10: argumentsGetter
EncodedJSValue JSLexicalEnvironment::argumentsGetter(ExecState*, JSObject* slotBase, EncodedJSValue, PropertyName)
{
JSLexicalEnvironment* lexicalEnvironment = jsCast<JSLexicalEnvironment*>(slotBase);
CallFrame* callFrame = CallFrame::create(reinterpret_cast<Register*>(lexicalEnvironment->m_registers));
return JSValue::encode(jsUndefined());
VirtualRegister argumentsRegister = callFrame->codeBlock()->argumentsRegister();
if (JSValue arguments = callFrame->uncheckedR(argumentsRegister.offset()).jsValue())
return JSValue::encode(arguments);
int realArgumentsRegister = unmodifiedArgumentsRegister(argumentsRegister).offset();
JSValue arguments = JSValue(Arguments::create(callFrame->vm(), callFrame));
callFrame->uncheckedR(argumentsRegister.offset()) = arguments;
callFrame->uncheckedR(realArgumentsRegister) = arguments;
ASSERT(callFrame->uncheckedR(realArgumentsRegister).jsValue().inherits(Arguments::info()));
return JSValue::encode(callFrame->uncheckedR(realArgumentsRegister).jsValue());
}
示例11: jsUndefined
JSValue JSActivation::argumentsGetter(ExecState*, JSValue slotBase, PropertyName)
{
JSActivation* activation = jsCast<JSActivation*>(slotBase);
if (activation->isTornOff())
return jsUndefined();
CallFrame* callFrame = CallFrame::create(reinterpret_cast<Register*>(activation->m_registers));
int argumentsRegister = callFrame->codeBlock()->argumentsRegister();
if (JSValue arguments = callFrame->uncheckedR(argumentsRegister).jsValue())
return arguments;
int realArgumentsRegister = unmodifiedArgumentsRegister(argumentsRegister);
JSValue arguments = JSValue(Arguments::create(callFrame->vm(), callFrame));
callFrame->uncheckedR(argumentsRegister) = arguments;
callFrame->uncheckedR(realArgumentsRegister) = arguments;
ASSERT(callFrame->uncheckedR(realArgumentsRegister).jsValue().inherits(Arguments::info()));
return callFrame->uncheckedR(realArgumentsRegister).jsValue();
}
示例12: asActivation
JSValue JSActivation::argumentsGetter(ExecState*, JSValue slotBase, const Identifier&)
{
JSActivation* activation = asActivation(slotBase);
CallFrame* callFrame = CallFrame::create(reinterpret_cast<Register*>(activation->m_registers));
int argumentsRegister = activation->m_argumentsRegister;
if (JSValue arguments = callFrame->uncheckedR(argumentsRegister).jsValue())
return arguments;
int realArgumentsRegister = unmodifiedArgumentsRegister(argumentsRegister);
JSValue arguments = JSValue(Arguments::create(callFrame->globalData(), callFrame));
callFrame->uncheckedR(argumentsRegister) = arguments;
callFrame->uncheckedR(realArgumentsRegister) = arguments;
ASSERT(callFrame->uncheckedR(realArgumentsRegister).jsValue().inherits(&Arguments::s_info));
return callFrame->uncheckedR(realArgumentsRegister).jsValue();
}
示例13: asActivation
JSValue JSActivation::argumentsGetter(ExecState*, JSValue slotBase, const Identifier&)
{
JSActivation* activation = asActivation(slotBase);
CallFrame* callFrame = CallFrame::create(activation->d()->registers);
int argumentsRegister = activation->d()->functionExecutable->generatedBytecode().argumentsRegister();
if (!callFrame->uncheckedR(argumentsRegister).jsValue()) {
JSValue arguments = JSValue(new (callFrame) Arguments(callFrame));
callFrame->uncheckedR(argumentsRegister) = arguments;
callFrame->uncheckedR(unmodifiedArgumentsRegister(argumentsRegister)) = arguments;
}
ASSERT(callFrame->uncheckedR(argumentsRegister).jsValue().inherits(&Arguments::info));
return callFrame->uncheckedR(argumentsRegister).jsValue();
}
示例14: codeBlock
CallFrame* CallFrame::trueCallFrame(AbstractPC pc)
{
// Am I an inline call frame? If so, we're done.
if (isInlineCallFrame())
return this;
// If I don't have a code block, then I'm not DFG code, so I'm the true call frame.
CodeBlock* machineCodeBlock = codeBlock();
if (!machineCodeBlock)
return this;
// If the code block does not have any code origins, then there was no inlining, so
// I'm done.
if (!machineCodeBlock->hasCodeOrigins())
return this;
// At this point the PC must be due either to the DFG, or it must be unset.
ASSERT(pc.hasJITReturnAddress() || !pc);
// Try to determine the CodeOrigin. If we don't have a pc set then the only way
// that this makes sense is if the CodeOrigin index was set in the call frame.
// FIXME: Note that you will see "Not currently in inlined code" comments below.
// Currently, we do not record code origins for code that is not inlined, because
// the only thing that we use code origins for is determining the inline stack.
// But in the future, we'll want to use this same functionality (having a code
// origin mapping for any calls out of JIT code) to determine the PC at any point
// in the stack even if not in inlined code. When that happens, the code below
// will have to change the way it detects the presence of inlining: it will always
// get a code origin, but sometimes, that code origin will not have an inline call
// frame. In that case, this method should bail and return this.
CodeOrigin codeOrigin;
if (pc.isSet()) {
ReturnAddressPtr currentReturnPC = pc.jitReturnAddress();
bool hasCodeOrigin = machineCodeBlock->codeOriginForReturn(currentReturnPC, codeOrigin);
ASSERT_UNUSED(hasCodeOrigin, hasCodeOrigin);
} else {
unsigned index = codeOriginIndexForDFG();
codeOrigin = machineCodeBlock->codeOrigin(index);
}
if (!codeOrigin.inlineCallFrame)
return this; // Not currently in inlined code.
for (InlineCallFrame* inlineCallFrame = codeOrigin.inlineCallFrame; inlineCallFrame;) {
InlineCallFrame* nextInlineCallFrame = inlineCallFrame->caller.inlineCallFrame;
CallFrame* inlinedCaller = this + inlineCallFrame->stackOffset;
JSFunction* calleeAsFunction = inlineCallFrame->callee.get();
// Fill in the inlinedCaller
inlinedCaller->setCodeBlock(machineCodeBlock);
inlinedCaller->setScopeChain(calleeAsFunction->scope());
if (nextInlineCallFrame)
inlinedCaller->setCallerFrame(this + nextInlineCallFrame->stackOffset);
else
inlinedCaller->setCallerFrame(this);
inlinedCaller->setInlineCallFrame(inlineCallFrame);
inlinedCaller->setArgumentCountIncludingThis(inlineCallFrame->arguments.size());
inlinedCaller->setCallee(calleeAsFunction);
inlineCallFrame = nextInlineCallFrame;
}
return this + codeOrigin.inlineCallFrame->stackOffset;
}
示例15: print_backtraces
void SignalThread::print_backtraces() {
STATE = shared_.env()->state;
ThreadList* threads = shared_.thread_nexus()->threads();
for(ThreadList::iterator i = threads->begin(); i != threads->end(); ++i) {
VM* vm = (*i)->as_vm();
if(!vm) continue;
bool first = true;
CallFrame* frame = vm->call_frame();
while(frame) {
if(first) {
logger::fatal("--- %s %d backtrace ---", vm->kind_name(), vm->thread_id());
first = false;
}
std::ostringstream stream;
if(NativeMethodFrame* nmf = frame->native_method_frame()) {
stream << static_cast<void*>(frame) << ": ";
NativeMethod* nm = try_as<NativeMethod>(nmf->get_object(nmf->method()));
if(nm && nm->name()->symbol_p()) {
stream << "capi:" << nm->name()->debug_str(state) << " at ";
stream << nm->file()->c_str(state);
} else {
stream << "unknown capi";
}
} else if(frame->compiled_code) {
if(frame->is_block_p(state)) {
stream << "__block__";
} else {
if(SingletonClass* sc = try_as<SingletonClass>(frame->module())) {
Object* obj = sc->singleton();
if(Module* mod = try_as<Module>(obj)) {
stream << mod->debug_str(state) << ".";
} else {
if(obj == G(main)) {
stream << "MAIN.";
} else {
stream << "#<" << obj->class_object(state)->debug_str(state) <<
":" << (void*)obj->id(state)->to_native() << ">.";
}
}
} else if(IncludedModule* im = try_as<IncludedModule>(frame->module())) {
stream << im->module()->debug_str(state) << "#";
} else {
Symbol* name;
std::string mod_name;
if(frame->module()->nil_p()) {
mod_name = frame->lexical_scope()->module()->debug_str(state);
} else {
if((name = try_as<Symbol>(frame->module()->module_name()))) {
mod_name = name->debug_str(state);
} else if((name = try_as<Symbol>(
frame->lexical_scope()->module()->module_name()))) {
mod_name = name->debug_str(state);
} else {
mod_name = "<anonymous module>";
}
}
stream << mod_name << "#";
}
Symbol* name = try_as<Symbol>(frame->name());
if(name) {
stream << name->debug_str(state);
} else {
stream << frame->compiled_code->name()->debug_str(state);
}
}
stream << " in ";
if(Symbol* file_sym = try_as<Symbol>(frame->compiled_code->file())) {
stream << file_sym->debug_str(state) << ":" << frame->line(state);
} else {
stream << "<unknown>";
}
stream << " (+" << frame->ip();
if(frame->is_inline_frame()) {
stream << " inline";
} else if(frame->jitted_p()) {
stream << " jit";
}
stream << ")";
}
logger::fatal(stream.str().c_str());
frame = frame->previous;
}
}
}