summaryrefslogtreecommitdiff
path: root/Source/JavaScriptCore/bytecode/CodeOrigin.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/JavaScriptCore/bytecode/CodeOrigin.cpp')
-rw-r--r--Source/JavaScriptCore/bytecode/CodeOrigin.cpp132
1 files changed, 53 insertions, 79 deletions
diff --git a/Source/JavaScriptCore/bytecode/CodeOrigin.cpp b/Source/JavaScriptCore/bytecode/CodeOrigin.cpp
index d51695012..39b83fead 100644
--- a/Source/JavaScriptCore/bytecode/CodeOrigin.cpp
+++ b/Source/JavaScriptCore/bytecode/CodeOrigin.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012-2015 Apple Inc. All rights reserved.
+ * Copyright (C) 2012, 2013 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -29,15 +29,14 @@
#include "CallFrame.h"
#include "CodeBlock.h"
#include "Executable.h"
-#include "InlineCallFrame.h"
-#include "JSCInlines.h"
+#include "Operations.h"
namespace JSC {
unsigned CodeOrigin::inlineDepthForCallFrame(InlineCallFrame* inlineCallFrame)
{
unsigned result = 1;
- for (InlineCallFrame* current = inlineCallFrame; current; current = current->directCaller.inlineCallFrame)
+ for (InlineCallFrame* current = inlineCallFrame; current; current = current->caller.inlineCallFrame)
result++;
return result;
}
@@ -46,90 +45,18 @@ unsigned CodeOrigin::inlineDepth() const
{
return inlineDepthForCallFrame(inlineCallFrame);
}
-
-bool CodeOrigin::isApproximatelyEqualTo(const CodeOrigin& other) const
-{
- CodeOrigin a = *this;
- CodeOrigin b = other;
-
- if (!a.isSet())
- return !b.isSet();
- if (!b.isSet())
- return false;
-
- if (a.isHashTableDeletedValue())
- return b.isHashTableDeletedValue();
- if (b.isHashTableDeletedValue())
- return false;
- for (;;) {
- ASSERT(a.isSet());
- ASSERT(b.isSet());
-
- if (a.bytecodeIndex != b.bytecodeIndex)
- return false;
-
- if ((!!a.inlineCallFrame) != (!!b.inlineCallFrame))
- return false;
-
- if (!a.inlineCallFrame)
- return true;
-
- if (a.inlineCallFrame->baselineCodeBlock.get() != b.inlineCallFrame->baselineCodeBlock.get())
- return false;
-
- a = a.inlineCallFrame->directCaller;
- b = b.inlineCallFrame->directCaller;
- }
-}
-
-unsigned CodeOrigin::approximateHash() const
-{
- if (!isSet())
- return 0;
- if (isHashTableDeletedValue())
- return 1;
-
- unsigned result = 2;
- CodeOrigin codeOrigin = *this;
- for (;;) {
- result += codeOrigin.bytecodeIndex;
-
- if (!codeOrigin.inlineCallFrame)
- return result;
-
- result += WTF::PtrHash<JSCell*>::hash(codeOrigin.inlineCallFrame->baselineCodeBlock.get());
-
- codeOrigin = codeOrigin.inlineCallFrame->directCaller;
- }
-}
-
Vector<CodeOrigin> CodeOrigin::inlineStack() const
{
Vector<CodeOrigin> result(inlineDepth());
result.last() = *this;
unsigned index = result.size() - 2;
- for (InlineCallFrame* current = inlineCallFrame; current; current = current->directCaller.inlineCallFrame)
- result[index--] = current->directCaller;
+ for (InlineCallFrame* current = inlineCallFrame; current; current = current->caller.inlineCallFrame)
+ result[index--] = current->caller;
RELEASE_ASSERT(!result[0].inlineCallFrame);
return result;
}
-CodeBlock* CodeOrigin::codeOriginOwner() const
-{
- if (!inlineCallFrame)
- return 0;
- return inlineCallFrame->baselineCodeBlock.get();
-}
-
-int CodeOrigin::stackOffset() const
-{
- if (!inlineCallFrame)
- return 0;
-
- return inlineCallFrame->stackOffset;
-}
-
void CodeOrigin::dump(PrintStream& out) const
{
if (!isSet()) {
@@ -143,7 +70,7 @@ void CodeOrigin::dump(PrintStream& out) const
out.print(" --> ");
if (InlineCallFrame* frame = stack[i].inlineCallFrame) {
- out.print(frame->briefFunctionInformation(), ":<", RawPointer(frame->baselineCodeBlock.get()), "> ");
+ out.print(frame->briefFunctionInformation(), ":<", RawPointer(frame->executable.get()), "> ");
if (frame->isClosureCall)
out.print("(closure) ");
}
@@ -157,4 +84,51 @@ void CodeOrigin::dumpInContext(PrintStream& out, DumpContext*) const
dump(out);
}
+JSFunction* InlineCallFrame::calleeForCallFrame(ExecState* exec) const
+{
+ return jsCast<JSFunction*>(calleeRecovery.recover(exec));
+}
+
+CodeBlockHash InlineCallFrame::hash() const
+{
+ return jsCast<FunctionExecutable*>(executable.get())->codeBlockFor(
+ specializationKind())->hash();
+}
+
+CString InlineCallFrame::inferredName() const
+{
+ return jsCast<FunctionExecutable*>(executable.get())->inferredName().utf8();
+}
+
+CodeBlock* InlineCallFrame::baselineCodeBlock() const
+{
+ return jsCast<FunctionExecutable*>(executable.get())->baselineCodeBlockFor(specializationKind());
+}
+
+void InlineCallFrame::dumpBriefFunctionInformation(PrintStream& out) const
+{
+ out.print(inferredName(), "#", hash());
+}
+
+void InlineCallFrame::dumpInContext(PrintStream& out, DumpContext* context) const
+{
+ out.print(briefFunctionInformation(), ":<", RawPointer(executable.get()));
+ if (executable->isStrictMode())
+ out.print(" (StrictMode)");
+ out.print(", bc#", caller.bytecodeIndex, ", ", specializationKind());
+ if (isClosureCall)
+ out.print(", closure call");
+ else
+ out.print(", known callee: ", inContext(calleeRecovery.constant(), context));
+ out.print(", numArgs+this = ", arguments.size());
+ out.print(", stack < loc", VirtualRegister(stackOffset).toLocal());
+ out.print(">");
+}
+
+void InlineCallFrame::dump(PrintStream& out) const
+{
+ dumpInContext(out, 0);
+}
+
} // namespace JSC
+