diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
commit | 1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch) | |
tree | 46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/JavaScriptCore/dfg/DFGNode.cpp | |
parent | 32761a6cee1d0dee366b885b7b9c777e67885688 (diff) | |
download | WebKitGtk-tarball-master.tar.gz |
webkitgtk-2.16.5HEADwebkitgtk-2.16.5master
Diffstat (limited to 'Source/JavaScriptCore/dfg/DFGNode.cpp')
-rw-r--r-- | Source/JavaScriptCore/dfg/DFGNode.cpp | 217 |
1 files changed, 211 insertions, 6 deletions
diff --git a/Source/JavaScriptCore/dfg/DFGNode.cpp b/Source/JavaScriptCore/dfg/DFGNode.cpp index bf43f29a4..5185187be 100644 --- a/Source/JavaScriptCore/dfg/DFGNode.cpp +++ b/Source/JavaScriptCore/dfg/DFGNode.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2013 Apple Inc. All rights reserved. + * Copyright (C) 2013, 2014, 2016 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,13 +29,38 @@ #if ENABLE(DFG_JIT) #include "DFGGraph.h" -#include "DFGNodeAllocator.h" +#include "DFGPromotedHeapLocation.h" +#include "JSCInlines.h" namespace JSC { namespace DFG { -unsigned Node::index() const +bool MultiPutByOffsetData::writesStructures() const { - return NodeAllocator::allocatorOf(this)->indexOf(this); + for (unsigned i = variants.size(); i--;) { + if (variants[i].writesStructures()) + return true; + } + return false; +} + +bool MultiPutByOffsetData::reallocatesStorage() const +{ + for (unsigned i = variants.size(); i--;) { + if (variants[i].reallocatesStorage()) + return true; + } + return false; +} + +void BranchTarget::dump(PrintStream& out) const +{ + if (!block) + return; + + out.print(*block); + + if (count == count) // If the count is not NaN, then print it. + out.print("/w:", count); } bool Node::hasVariableAccessData(Graph& graph) @@ -44,7 +69,6 @@ bool Node::hasVariableAccessData(Graph& graph) case Phi: return graph.m_form != SSA; case GetLocal: - case GetArgument: case SetLocal: case SetArgument: case Flush: @@ -55,6 +79,181 @@ bool Node::hasVariableAccessData(Graph& graph) } } +void Node::remove() +{ + ASSERT(!(flags() & NodeHasVarArgs)); + + children = children.justChecks(); + + setOpAndDefaultFlags(Check); +} + +void Node::convertToIdentity() +{ + RELEASE_ASSERT(child1()); + RELEASE_ASSERT(!child2()); + NodeFlags result = canonicalResultRepresentation(this->result()); + setOpAndDefaultFlags(Identity); + setResult(result); +} + +void Node::convertToIdentityOn(Node* child) +{ + children.reset(); + child1() = child->defaultEdge(); + NodeFlags output = canonicalResultRepresentation(this->result()); + NodeFlags input = canonicalResultRepresentation(child->result()); + if (output == input) { + setOpAndDefaultFlags(Identity); + setResult(output); + return; + } + switch (output) { + case NodeResultDouble: + setOpAndDefaultFlags(DoubleRep); + switch (input) { + case NodeResultInt52: + child1().setUseKind(Int52RepUse); + return; + case NodeResultJS: + child1().setUseKind(NumberUse); + return; + default: + RELEASE_ASSERT_NOT_REACHED(); + return; + } + case NodeResultInt52: + setOpAndDefaultFlags(Int52Rep); + switch (input) { + case NodeResultDouble: + child1().setUseKind(DoubleRepAnyIntUse); + return; + case NodeResultJS: + child1().setUseKind(AnyIntUse); + return; + default: + RELEASE_ASSERT_NOT_REACHED(); + return; + } + case NodeResultJS: + setOpAndDefaultFlags(ValueRep); + switch (input) { + case NodeResultDouble: + child1().setUseKind(DoubleRepUse); + return; + case NodeResultInt52: + child1().setUseKind(Int52RepUse); + return; + default: + RELEASE_ASSERT_NOT_REACHED(); + return; + } + default: + RELEASE_ASSERT_NOT_REACHED(); + return; + } +} + +void Node::convertToLazyJSConstant(Graph& graph, LazyJSValue value) +{ + m_op = LazyJSConstant; + m_flags &= ~NodeMustGenerate; + m_opInfo = graph.m_lazyJSValues.add(value); + children.reset(); +} + +void Node::convertToPutHint(const PromotedLocationDescriptor& descriptor, Node* base, Node* value) +{ + m_op = PutHint; + m_opInfo = descriptor.imm1(); + m_opInfo2 = descriptor.imm2(); + child1() = base->defaultEdge(); + child2() = value->defaultEdge(); + child3() = Edge(); +} + +void Node::convertToPutStructureHint(Node* structure) +{ + ASSERT(m_op == PutStructure); + ASSERT(structure->castConstant<Structure*>(*structure->asCell()->vm()) == transition()->next.get()); + convertToPutHint(StructurePLoc, child1().node(), structure); +} + +void Node::convertToPutByOffsetHint() +{ + ASSERT(m_op == PutByOffset); + convertToPutHint( + PromotedLocationDescriptor(NamedPropertyPLoc, storageAccessData().identifierNumber), + child2().node(), child3().node()); +} + +void Node::convertToPutClosureVarHint() +{ + ASSERT(m_op == PutClosureVar); + convertToPutHint( + PromotedLocationDescriptor(ClosureVarPLoc, scopeOffset().offset()), + child1().node(), child2().node()); +} + +void Node::convertToDirectCall(FrozenValue* executable) +{ + NodeType newOp = LastNodeType; + switch (op()) { + case Call: + newOp = DirectCall; + break; + case Construct: + newOp = DirectConstruct; + break; + case TailCallInlinedCaller: + newOp = DirectTailCallInlinedCaller; + break; + case TailCall: + newOp = DirectTailCall; + break; + default: + RELEASE_ASSERT_NOT_REACHED(); + break; + } + + m_op = newOp; + m_opInfo = executable; +} + +void Node::convertToCallDOM(Graph& graph) +{ + ASSERT(op() == Call); + ASSERT(signature()); + + Edge edges[3]; + // Skip the first one. This is callee. + RELEASE_ASSERT(numChildren() <= 4); + for (unsigned i = 1; i < numChildren(); ++i) + edges[i - 1] = graph.varArgChild(this, i); + + setOpAndDefaultFlags(CallDOM); + children.setChild1(edges[0]); + children.setChild2(edges[1]); + children.setChild3(edges[2]); + + if (!signature()->effect.mustGenerate()) + clearFlags(NodeMustGenerate); +} + +String Node::tryGetString(Graph& graph) +{ + if (hasConstant()) + return constant()->tryGetString(graph); + if (hasLazyJSValue()) + return lazyJSValue().tryGetString(graph); + return String(); +} + +PromotedLocationDescriptor Node::promotedLocationDescriptor() +{ + return PromotedLocationDescriptor(static_cast<PromotedLocationKind>(m_opInfo.as<uint32_t>()), m_opInfo2.as<uint32_t>()); +} + } } // namespace JSC::DFG namespace WTF { @@ -74,6 +273,9 @@ void printInternal(PrintStream& out, SwitchKind kind) case SwitchString: out.print("SwitchString"); return; + case SwitchCell: + out.print("SwitchCell"); + return; } RELEASE_ASSERT_NOT_REACHED(); } @@ -85,7 +287,10 @@ void printInternal(PrintStream& out, Node* node) return; } out.print("@", node->index()); - out.print(AbbreviatedSpeculationDump(node->prediction())); + if (node->hasDoubleResult()) + out.print("<Double>"); + else if (node->hasInt52Result()) + out.print("<Int52>"); } } // namespace WTF |