Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(18)

Unified Diff: src/IceDefs.h

Issue 1738443002: Subzero. Performance tweaks. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Addresses comments -- all of them Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/IceConverter.cpp ('k') | src/IceGlobalContext.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/IceDefs.h
diff --git a/src/IceDefs.h b/src/IceDefs.h
index 1222424378c7ed41768ae3666128bca9a3170d25..c90b052409ef9dbb4cd40da627837820c51de899 100644
--- a/src/IceDefs.h
+++ b/src/IceDefs.h
@@ -11,14 +11,13 @@
/// \brief Declares various useful types and classes that have widespread use
/// across Subzero.
///
-/// Every Subzero source file is expected to include IceDefs.h.
-///
//===----------------------------------------------------------------------===//
#ifndef SUBZERO_SRC_ICEDEFS_H
#define SUBZERO_SRC_ICEDEFS_H
#include "IceBuildDefs.h" // TODO(stichnot): move into individual files
+#include "IceMemory.h"
#include "IceTLS.h"
#include "llvm/ADT/ArrayRef.h"
@@ -26,10 +25,8 @@
#include "llvm/ADT/ilist.h"
#include "llvm/ADT/ilist_node.h"
#include "llvm/ADT/iterator_range.h"
-#include "llvm/ADT/SmallBitVector.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/STLExtras.h"
-#include "llvm/Support/Allocator.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/ELF.h"
#include "llvm/Support/raw_ostream.h"
@@ -46,6 +43,8 @@
#include <string>
#include <system_error>
#include <unordered_map>
+#include <unordered_set>
+#include <utility>
#include <vector>
namespace Ice {
@@ -75,43 +74,6 @@ class VariableDeclaration;
class VariablesMetadata;
constexpr char GlobalOffsetTable[] = "_GLOBAL_OFFSET_TABLE_";
-
-template <size_t SlabSize = 1024 * 1024>
-using ArenaAllocator =
- llvm::BumpPtrAllocatorImpl<llvm::MallocAllocator, SlabSize>;
-
-ArenaAllocator<> *getCurrentCfgAllocator();
-
-template <typename T> struct CfgLocalAllocator {
- using value_type = T;
- using pointer = T *;
- using const_pointer = const T *;
- using reference = T &;
- using const_reference = const T &;
- using size_type = std::size_t;
- CfgLocalAllocator() = default;
- template <class U> CfgLocalAllocator(const CfgLocalAllocator<U> &) {}
- pointer allocate(size_type Num) {
- return getCurrentCfgAllocator()->Allocate<T>(Num);
- }
- void deallocate(pointer, size_type) {}
- template <class U> struct rebind { typedef CfgLocalAllocator<U> other; };
- void construct(pointer P, const T &Val) {
- new (static_cast<void *>(P)) T(Val);
- }
- void destroy(pointer P) { P->~T(); }
-};
-template <typename T, typename U>
-inline bool operator==(const CfgLocalAllocator<T> &,
- const CfgLocalAllocator<U> &) {
- return true;
-}
-template <typename T, typename U>
-inline bool operator!=(const CfgLocalAllocator<T> &,
- const CfgLocalAllocator<U> &) {
- return false;
-}
-
// makeUnique should be used when memory is expected to be allocated from the
// heap (as opposed to allocated from some Allocator.) It is intended to be
// used instead of new.
@@ -160,15 +122,21 @@ using PhiList = InstList;
using AssignList = InstList;
// Standard library containers with CfgLocalAllocator.
-template <typename T> using CfgVector = std::vector<T, CfgLocalAllocator<T>>;
template <typename T> using CfgList = std::list<T, CfgLocalAllocator<T>>;
+template <typename T, typename H = std::hash<T>, typename Eq = std::equal_to<T>>
+using CfgUnorderedSet = std::unordered_set<T, H, Eq, CfgLocalAllocator<T>>;
+template <typename T, typename U, typename H = std::hash<T>,
+ typename Eq = std::equal_to<T>>
+using CfgUnorderedMap =
+ std::unordered_map<T, U, H, Eq, CfgLocalAllocator<std::pair<const T, U>>>;
+template <typename T> using CfgVector = std::vector<T, CfgLocalAllocator<T>>;
// Containers that are arena-allocated from the Cfg's allocator.
using OperandList = CfgVector<Operand *>;
using VarList = CfgVector<Variable *>;
using NodeList = CfgVector<CfgNode *>;
-// Contains that use the default (global) allocator.
+// Containers that use the default (global) allocator.
using ConstantList = std::vector<Constant *>;
using FunctionDeclarationList = std::vector<FunctionDeclaration *>;
using VariableDeclarationList = std::vector<VariableDeclaration *>;
« no previous file with comments | « src/IceConverter.cpp ('k') | src/IceGlobalContext.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698