summaryrefslogtreecommitdiff
path: root/Source/JavaScriptCore/ftl/FTLAbstractHeap.cpp
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2016-04-10 09:28:39 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2016-04-10 09:28:39 +0000
commit32761a6cee1d0dee366b885b7b9c777e67885688 (patch)
treed6bec92bebfb216f4126356e55518842c2f476a1 /Source/JavaScriptCore/ftl/FTLAbstractHeap.cpp
parenta4e969f4965059196ca948db781e52f7cfebf19e (diff)
downloadWebKitGtk-tarball-32761a6cee1d0dee366b885b7b9c777e67885688.tar.gz
webkitgtk-2.4.11webkitgtk-2.4.11
Diffstat (limited to 'Source/JavaScriptCore/ftl/FTLAbstractHeap.cpp')
-rw-r--r--Source/JavaScriptCore/ftl/FTLAbstractHeap.cpp176
1 files changed, 52 insertions, 124 deletions
diff --git a/Source/JavaScriptCore/ftl/FTLAbstractHeap.cpp b/Source/JavaScriptCore/ftl/FTLAbstractHeap.cpp
index 90211fd94..eadd5af97 100644
--- a/Source/JavaScriptCore/ftl/FTLAbstractHeap.cpp
+++ b/Source/JavaScriptCore/ftl/FTLAbstractHeap.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2013, 2015-2016 Apple Inc. All rights reserved.
+ * Copyright (C) 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
@@ -28,114 +28,51 @@
#if ENABLE(FTL_JIT)
-#include "DFGCommon.h"
-#include "FTLAbbreviatedTypes.h"
+#include "FTLAbbreviations.h"
#include "FTLAbstractHeapRepository.h"
#include "FTLOutput.h"
#include "FTLTypedPointer.h"
-#include "JSCInlines.h"
+#include "Operations.h"
#include "Options.h"
namespace JSC { namespace FTL {
-using namespace B3;
-
-AbstractHeap::AbstractHeap(AbstractHeap* parent, const char* heapName, ptrdiff_t offset)
- : m_offset(offset)
- , m_heapName(heapName)
+LValue AbstractHeap::tbaaMetadataSlow(const AbstractHeapRepository& repository) const
{
- changeParent(parent);
+ m_tbaaMetadata = mdNode(
+ repository.m_context,
+ mdString(repository.m_context, m_heapName),
+ m_parent->tbaaMetadata(repository));
+ return m_tbaaMetadata;
}
-void AbstractHeap::changeParent(AbstractHeap* parent)
+void AbstractHeap::decorateInstruction(LValue instruction, const AbstractHeapRepository& repository) const
{
- if (m_parent) {
- bool result = m_parent->m_children.removeFirst(this);
- RELEASE_ASSERT(result);
- }
-
- m_parent = parent;
-
- if (parent) {
- ASSERT(!m_parent->m_children.contains(this));
- m_parent->m_children.append(this);
- }
-}
-
-void AbstractHeap::compute(unsigned begin)
-{
- // This recursively computes the ranges of the tree. This solves the following constraints
- // in linear time:
- //
- // - A node's end is greater than its begin.
- // - A node's begin is greater than or equal to its parent's begin.
- // - A node's end is less than or equal to its parent's end.
- // - The ranges are as small as possible.
- //
- // It's OK to recurse because we keep the depth of our abstract heap hierarchy fairly sane.
- // I think that it gets 4 deep at most.
-
- if (m_children.isEmpty()) {
- // Must special-case leaves so that they use just one slot on the number line.
- m_range = HeapRange(begin);
+ if (!Options::useFTLTBAA())
return;
- }
-
- unsigned current = begin;
- for (AbstractHeap* child : m_children) {
- child->compute(current);
- current = child->range().end();
- }
-
- m_range = HeapRange(begin, current);
-}
-
-void AbstractHeap::shallowDump(PrintStream& out) const
-{
- out.print(heapName(), "(", m_offset, ")");
- if (m_range)
- out.print("<", m_range, ">");
-}
-
-void AbstractHeap::dump(PrintStream& out) const
-{
- shallowDump(out);
- if (m_parent)
- out.print("->", *m_parent);
+ setMetadata(instruction, repository.m_tbaaKind, tbaaMetadata(repository));
}
-void AbstractHeap::deepDump(PrintStream& out, unsigned indent) const
-{
- auto printIndent = [&] () {
- for (unsigned i = indent; i--;)
- out.print(" ");
- };
-
- printIndent();
- shallowDump(out);
-
- if (m_children.isEmpty()) {
- out.print("\n");
- return;
- }
-
- out.print(":\n");
- for (AbstractHeap* child : m_children)
- child->deepDump(out, indent + 1);
-}
-
-void AbstractHeap::badRangeError() const
-{
- dataLog("Heap does not have range: ", *this, "\n");
- RELEASE_ASSERT_NOT_REACHED();
-}
-
-IndexedAbstractHeap::IndexedAbstractHeap(AbstractHeap* parent, const char* heapName, ptrdiff_t offset, size_t elementSize)
+IndexedAbstractHeap::IndexedAbstractHeap(LContext context, AbstractHeap* parent, const char* heapName, size_t elementSize)
: m_heapForAnyIndex(parent, heapName)
, m_heapNameLength(strlen(heapName))
- , m_offset(offset)
, m_elementSize(elementSize)
-{
+ , m_scaleTerm(0)
+ , m_canShift(false)
+{
+ // See if there is a common shift amount we could use instead of multiplying. Don't
+ // try too hard. This is just a speculative optimization to reduce load on LLVM.
+ for (unsigned i = 0; i < 4; ++i) {
+ if ((1 << i) == m_elementSize) {
+ if (i)
+ m_scaleTerm = constInt(intPtrType(context), i, ZeroExtend);
+ m_canShift = true;
+ break;
+ }
+ }
+
+ if (!m_canShift)
+ m_scaleTerm = constInt(intPtrType(context), m_elementSize, ZeroExtend);
}
IndexedAbstractHeap::~IndexedAbstractHeap()
@@ -146,29 +83,36 @@ TypedPointer IndexedAbstractHeap::baseIndex(Output& out, LValue base, LValue ind
{
if (indexAsConstant.isInt32())
return out.address(base, at(indexAsConstant.asInt32()), offset);
-
- LValue result = out.add(base, out.mul(index, out.constIntPtr(m_elementSize)));
- return TypedPointer(atAnyIndex(), out.addPtr(result, m_offset + offset));
+ LValue result;
+ if (m_canShift) {
+ if (!m_scaleTerm)
+ result = out.add(base, index);
+ else
+ result = out.add(base, out.shl(index, m_scaleTerm));
+ } else
+ result = out.add(base, out.mul(index, m_scaleTerm));
+
+ return TypedPointer(atAnyIndex(), out.addPtr(result, offset));
}
-const AbstractHeap& IndexedAbstractHeap::atSlow(ptrdiff_t index)
+const AbstractField& IndexedAbstractHeap::atSlow(ptrdiff_t index)
{
ASSERT(static_cast<size_t>(index) >= m_smallIndices.size());
if (UNLIKELY(!m_largeIndices))
- m_largeIndices = std::make_unique<MapType>();
+ m_largeIndices = adoptPtr(new MapType());
- std::unique_ptr<AbstractHeap>& field = m_largeIndices->add(index, nullptr).iterator->value;
+ std::unique_ptr<AbstractField>& field = m_largeIndices->add(index, nullptr).iterator->value;
if (!field) {
- field = std::make_unique<AbstractHeap>();
+ field = std::make_unique<AbstractField>();
initialize(*field, index);
}
return *field;
}
-void IndexedAbstractHeap::initialize(AbstractHeap& field, ptrdiff_t signedIndex)
+void IndexedAbstractHeap::initialize(AbstractField& field, ptrdiff_t signedIndex)
{
// Build up a name of the form:
//
@@ -187,10 +131,7 @@ void IndexedAbstractHeap::initialize(AbstractHeap& field, ptrdiff_t signedIndex)
//
// Blah_neg_A
//
- // This naming convention comes from our previous use of LLVM. It's not clear that we need
- // it anymore, though it is sort of nifty. Basically, B3 doesn't need string names for
- // abstract heaps, but the fact that we have a reasonably efficient way to always name the
- // heaps will probably come in handy for debugging.
+ // This is important because LLVM uses the string to distinguish the types.
static const char* negSplit = "_neg_";
static const char* posSplit = "_";
@@ -227,20 +168,16 @@ void IndexedAbstractHeap::initialize(AbstractHeap& field, ptrdiff_t signedIndex)
accumulator >>= 4;
}
- field.initialize(&m_heapForAnyIndex, characters, m_offset + signedIndex * m_elementSize);
+ field.initialize(&m_heapForAnyIndex, characters, signedIndex * m_elementSize);
return;
}
RELEASE_ASSERT_NOT_REACHED();
}
-void IndexedAbstractHeap::dump(PrintStream& out) const
-{
- out.print("Indexed:", atAnyIndex());
-}
-
-NumberedAbstractHeap::NumberedAbstractHeap(AbstractHeap* heap, const char* heapName)
- : m_indexedHeap(heap, heapName, 0, 1)
+NumberedAbstractHeap::NumberedAbstractHeap(
+ LContext context, AbstractHeap* heap, const char* heapName)
+ : m_indexedHeap(context, heap, heapName, 1)
{
}
@@ -248,13 +185,9 @@ NumberedAbstractHeap::~NumberedAbstractHeap()
{
}
-void NumberedAbstractHeap::dump(PrintStream& out) const
-{
- out.print("Numbered: ", atAnyNumber());
-}
-
-AbsoluteAbstractHeap::AbsoluteAbstractHeap(AbstractHeap* heap, const char* heapName)
- : m_indexedHeap(heap, heapName, 0, 1)
+AbsoluteAbstractHeap::AbsoluteAbstractHeap(
+ LContext context, AbstractHeap* heap, const char* heapName)
+ : m_indexedHeap(context, heap, heapName, 1)
{
}
@@ -262,11 +195,6 @@ AbsoluteAbstractHeap::~AbsoluteAbstractHeap()
{
}
-void AbsoluteAbstractHeap::dump(PrintStream& out) const
-{
- out.print("Absolute:", atAnyAddress());
-}
-
} } // namespace JSC::FTL
#endif // ENABLE(FTL_JIT)