summaryrefslogtreecommitdiff
path: root/Source/JavaScriptCore/bytecode/CodeOrigin.cpp
diff options
context:
space:
mode:
authorKonstantin Tokarev <annulen@yandex.ru>2016-08-25 19:20:41 +0300
committerKonstantin Tokarev <annulen@yandex.ru>2017-02-02 12:30:55 +0000
commit6882a04fb36642862b11efe514251d32070c3d65 (patch)
treeb7959826000b061fd5ccc7512035c7478742f7b0 /Source/JavaScriptCore/bytecode/CodeOrigin.cpp
parentab6df191029eeeb0b0f16f127d553265659f739e (diff)
downloadqtwebkit-6882a04fb36642862b11efe514251d32070c3d65.tar.gz
Imported QtWebKit TP3 (git b57bc6801f1876c3220d5a4bfea33d620d477443)
Change-Id: I3b1d8a2808782c9f34d50240000e20cb38d3680f Reviewed-by: Konstantin Tokarev <annulen@yandex.ru>
Diffstat (limited to 'Source/JavaScriptCore/bytecode/CodeOrigin.cpp')
-rw-r--r--Source/JavaScriptCore/bytecode/CodeOrigin.cpp132
1 files changed, 87 insertions, 45 deletions
diff --git a/Source/JavaScriptCore/bytecode/CodeOrigin.cpp b/Source/JavaScriptCore/bytecode/CodeOrigin.cpp
index 52bc2bf7f..d51695012 100644
--- a/Source/JavaScriptCore/bytecode/CodeOrigin.cpp
+++ b/Source/JavaScriptCore/bytecode/CodeOrigin.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012, 2013 Apple Inc. All rights reserved.
+ * Copyright (C) 2012-2015 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,14 +29,15 @@
#include "CallFrame.h"
#include "CodeBlock.h"
#include "Executable.h"
-#include "Operations.h"
+#include "InlineCallFrame.h"
+#include "JSCInlines.h"
namespace JSC {
unsigned CodeOrigin::inlineDepthForCallFrame(InlineCallFrame* inlineCallFrame)
{
unsigned result = 1;
- for (InlineCallFrame* current = inlineCallFrame; current; current = current->caller.inlineCallFrame)
+ for (InlineCallFrame* current = inlineCallFrame; current; current = current->directCaller.inlineCallFrame)
result++;
return result;
}
@@ -45,28 +46,105 @@ 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->caller.inlineCallFrame)
- result[index--] = current->caller;
+ for (InlineCallFrame* current = inlineCallFrame; current; current = current->directCaller.inlineCallFrame)
+ result[index--] = current->directCaller;
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()) {
+ out.print("<none>");
+ return;
+ }
+
Vector<CodeOrigin> stack = inlineStack();
for (unsigned i = 0; i < stack.size(); ++i) {
if (i)
out.print(" --> ");
if (InlineCallFrame* frame = stack[i].inlineCallFrame) {
- out.print(frame->briefFunctionInformation(), ":<", RawPointer(frame->executable.get()), "> ");
- if (frame->isClosureCall())
+ out.print(frame->briefFunctionInformation(), ":<", RawPointer(frame->baselineCodeBlock.get()), "> ");
+ if (frame->isClosureCall)
out.print("(closure) ");
}
@@ -74,45 +152,9 @@ void CodeOrigin::dump(PrintStream& out) const
}
}
-JSFunction* InlineCallFrame::calleeForCallFrame(ExecState* exec) const
+void CodeOrigin::dumpInContext(PrintStream& out, DumpContext*) const
{
- if (!isClosureCall())
- return callee.get();
-
- return jsCast<JSFunction*>((exec + stackOffset)->callee());
-}
-
-CodeBlockHash InlineCallFrame::hash() const
-{
- return executable->hashFor(specializationKind());
-}
-
-String InlineCallFrame::inferredName() const
-{
- return jsCast<FunctionExecutable*>(executable.get())->inferredName().string();
-}
-
-CodeBlock* InlineCallFrame::baselineCodeBlock() const
-{
- return jsCast<FunctionExecutable*>(executable.get())->baselineCodeBlockFor(specializationKind());
-}
-
-void InlineCallFrame::dumpBriefFunctionInformation(PrintStream& out) const
-{
- out.print(inferredName(), "#", hash());
-}
-
-void InlineCallFrame::dump(PrintStream& out) const
-{
- out.print(briefFunctionInformation(), ":<", RawPointer(executable.get()), ", bc#", caller.bytecodeIndex, ", ", specializationKind());
- if (callee)
- out.print(", known callee: ", JSValue(callee.get()));
- else
- out.print(", closure call");
- out.print(", numArgs+this = ", arguments.size());
- out.print(", stack >= r", stackOffset);
- out.print(">");
+ dump(out);
}
} // namespace JSC
-