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/DFGEdge.h | |
parent | 32761a6cee1d0dee366b885b7b9c777e67885688 (diff) | |
download | WebKitGtk-tarball-master.tar.gz |
webkitgtk-2.16.5HEADwebkitgtk-2.16.5master
Diffstat (limited to 'Source/JavaScriptCore/dfg/DFGEdge.h')
-rw-r--r-- | Source/JavaScriptCore/dfg/DFGEdge.h | 66 |
1 files changed, 43 insertions, 23 deletions
diff --git a/Source/JavaScriptCore/dfg/DFGEdge.h b/Source/JavaScriptCore/dfg/DFGEdge.h index e641b65b7..31aa2d5df 100644 --- a/Source/JavaScriptCore/dfg/DFGEdge.h +++ b/Source/JavaScriptCore/dfg/DFGEdge.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011, 2013 Apple Inc. All rights reserved. + * Copyright (C) 2011, 2013, 2014 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -23,10 +23,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef DFGEdge_h -#define DFGEdge_h - -#include <wtf/Platform.h> +#pragma once #if ENABLE(DFG_JIT) @@ -117,14 +114,10 @@ public: { return proofStatus() == IsProved; } - bool needsCheck() const - { - return proofStatus() == NeedsCheck; - } bool willNotHaveCheck() const { - return isProved() || useKind() == UntypedUse; + return isProved() || shouldNotHaveTypeCheck(useKind()); } bool willHaveCheck() const { @@ -150,14 +143,22 @@ public: #endif } bool doesKill() const { return DFG::doesKill(killStatus()); } - bool doesNotKill() const { return !doesKill(); } - + bool isSet() const { return !!node(); } - - typedef void* Edge::*UnspecifiedBoolType; - operator UnspecifiedBoolType*() const { return reinterpret_cast<UnspecifiedBoolType*>(isSet()); } - + + Edge sanitized() const + { + Edge result = *this; +#if USE(JSVALUE64) + result.m_encodedWord = makeWord(node(), useKindUnchecked(), NeedsCheck, DoesNotKill); +#else + result.m_encodedWord = makeWord(useKindUnchecked(), NeedsCheck, DoesNotKill); +#endif + return result; + } + bool operator!() const { return !isSet(); } + explicit operator bool() const { return isSet(); } bool operator==(Edge other) const { @@ -173,12 +174,21 @@ public: } void dump(PrintStream&) const; + + unsigned hash() const + { +#if USE(JSVALUE64) + return IntHash<uintptr_t>::hash(m_encodedWord); +#else + return PtrHash<Node*>::hash(m_node) + m_encodedWord; +#endif + } private: friend class AdjacencyList; #if USE(JSVALUE64) - static uint32_t shift() { return 7; } + static constexpr uint32_t shift() { return 8; } static uintptr_t makeWord(Node* node, UseKind useKind, ProofStatus proofStatus, KillStatus killStatus) { @@ -186,14 +196,27 @@ private: uintptr_t shiftedValue = bitwise_cast<uintptr_t>(node) << shift(); ASSERT((shiftedValue >> shift()) == bitwise_cast<uintptr_t>(node)); ASSERT(useKind >= 0 && useKind < LastUseKind); - ASSERT((static_cast<uintptr_t>(LastUseKind) << 2) <= (static_cast<uintptr_t>(2) << shift())); - return shiftedValue | (static_cast<uintptr_t>(useKind) << 2) | (DFG::doesKill(killStatus) << 1) | DFG::isProved(proofStatus); + static_assert((static_cast<uintptr_t>(LastUseKind) << 2) < (static_cast<uintptr_t>(1) << shift()), "We rely on this being true to not clobber the node pointer."); + uintptr_t result = shiftedValue | (static_cast<uintptr_t>(useKind) << 2) | (DFG::doesKill(killStatus) << 1) | static_cast<uintptr_t>(DFG::isProved(proofStatus)); + if (!ASSERT_DISABLED) { + union U { + U() { word = 0; } + uintptr_t word; + Edge edge; + } u; + u.word = result; + ASSERT(u.edge.useKindUnchecked() == useKind); + ASSERT(u.edge.node() == node); + ASSERT(u.edge.proofStatusUnchecked() == proofStatus); + ASSERT(u.edge.killStatusUnchecked() == killStatus); + } + return result; } #else static uintptr_t makeWord(UseKind useKind, ProofStatus proofStatus, KillStatus killStatus) { - return (static_cast<uintptr_t>(useKind) << 2) | (DFG::doesKill(killStatus) << 1) | DFG::isProved(proofStatus); + return (static_cast<uintptr_t>(useKind) << 2) | (DFG::doesKill(killStatus) << 1) | static_cast<uintptr_t>(DFG::isProved(proofStatus)); } Node* m_node; @@ -224,6 +247,3 @@ inline bool operator!=(Node* node, Edge edge) } } // namespace JSC::DFG #endif // ENABLE(DFG_JIT) - -#endif // DFGEdge_h - |