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

Unified Diff: src/IceCfg.h

Issue 798693003: Subzero: Don't store std::string objects inside Variable. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Code review changes Created 6 years 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 | « no previous file | src/IceCfgNode.h » ('j') | src/IceOperand.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/IceCfg.h
diff --git a/src/IceCfg.h b/src/IceCfg.h
index c313a8998ca3df0251b7e91f5dfa2357694f5f1b..176876144662868d9c3b7769cdda9eaf7dc8680e 100644
--- a/src/IceCfg.h
+++ b/src/IceCfg.h
@@ -62,14 +62,24 @@ public:
CfgNode *makeNode();
SizeT getNumNodes() const { return Nodes.size(); }
const NodeList &getNodes() const { return Nodes; }
+
+ typedef int32_t IdentifierIndexType;
// Adds a name to the list and returns its index, suitable for the
- // argument to getNodeName(). No checking for duplicates is done.
- int32_t addNodeName(const IceString &Name) {
- int32_t Index = NodeNames.size();
- NodeNames.push_back(Name);
+ // argument to getIdentifierName(). No checking for duplicates is
+ // done. This is generally used for node names and variable names
+ // to avoid embedding a std::string inside an arena-allocated
+ // object.
+ IdentifierIndexType addIdentifierName(const IceString &Name) {
+ IdentifierIndexType Index = IdentifierNames.size();
+ IdentifierNames.push_back(Name);
return Index;
}
- const IceString &getNodeName(int32_t Index) const { return NodeNames[Index]; }
+ const IceString &getIdentifierName(IdentifierIndexType Index) const {
+ return IdentifierNames[Index];
+ }
+ enum {
+ IdentifierIndexInvalid = -1
+ };
// Manage instruction numbering.
InstNumberT newInstNumber() { return NextInstNumber++; }
@@ -78,10 +88,9 @@ public:
// Manage Variables.
// Create a new Variable with a particular type and an optional
// name. The Node argument is the node where the variable is defined.
- template <typename T = Variable>
- T *makeVariable(Type Ty, const IceString &Name = "") {
+ template <typename T = Variable> T *makeVariable(Type Ty) {
SizeT Index = Variables.size();
- T *Var = T::create(this, Ty, Index, Name);
+ T *Var = T::create(this, Ty, Index);
Variables.push_back(Var);
return Var;
}
@@ -183,7 +192,7 @@ private:
IceString ErrorMessage;
CfgNode *Entry; // entry basic block
NodeList Nodes; // linearized node list; Entry should be first
- std::vector<IceString> NodeNames;
+ std::vector<IceString> IdentifierNames;
InstNumberT NextInstNumber;
VarList Variables;
VarList Args; // subset of Variables, in argument order
« no previous file with comments | « no previous file | src/IceCfgNode.h » ('j') | src/IceOperand.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698