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

Side by Side Diff: src/IceCfg.cpp

Issue 1776473007: Subzero. Allocate global initializers from a dedicated arena. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Removes global variable (and initializer) allocation methods from GlobalContext. Created 4 years, 9 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 unified diff | Download patch
« no previous file with comments | « src/IceCfg.h ('k') | src/IceCompiler.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 //===- subzero/src/IceCfg.cpp - Control flow graph implementation ---------===// 1 //===- subzero/src/IceCfg.cpp - Control flow graph implementation ---------===//
2 // 2 //
3 // The Subzero Code Generator 3 // The Subzero Code Generator
4 // 4 //
5 // This file is distributed under the University of Illinois Open Source 5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details. 6 // License. See LICENSE.TXT for details.
7 // 7 //
8 //===----------------------------------------------------------------------===// 8 //===----------------------------------------------------------------------===//
9 /// 9 ///
10 /// \file 10 /// \file
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 ImplicitArgs.push_back(Arg); 115 ImplicitArgs.push_back(Arg);
116 } 116 }
117 117
118 // Returns whether the stack frame layout has been computed yet. This is used 118 // Returns whether the stack frame layout has been computed yet. This is used
119 // for dumping the stack frame location of Variables. 119 // for dumping the stack frame location of Variables.
120 bool Cfg::hasComputedFrame() const { return getTarget()->hasComputedFrame(); } 120 bool Cfg::hasComputedFrame() const { return getTarget()->hasComputedFrame(); }
121 121
122 namespace { 122 namespace {
123 constexpr char BlockNameGlobalPrefix[] = ".L$profiler$block_name$"; 123 constexpr char BlockNameGlobalPrefix[] = ".L$profiler$block_name$";
124 constexpr char BlockStatsGlobalPrefix[] = ".L$profiler$block_info$"; 124 constexpr char BlockStatsGlobalPrefix[] = ".L$profiler$block_info$";
125 } // end of anonymous namespace
125 126
126 VariableDeclaration *nodeNameDeclaration(GlobalContext *Ctx, 127 void Cfg::createNodeNameDeclaration(const IceString &NodeAsmName) {
127 const IceString &NodeAsmName) { 128 auto *Var = VariableDeclaration::create(GlobalInits.get());
128 auto *Var = VariableDeclaration::create(Ctx);
129 Var->setName(BlockNameGlobalPrefix + NodeAsmName); 129 Var->setName(BlockNameGlobalPrefix + NodeAsmName);
130 Var->setIsConstant(true); 130 Var->setIsConstant(true);
131 Var->addInitializer(VariableDeclaration::DataInitializer::create( 131 Var->addInitializer(VariableDeclaration::DataInitializer::create(
132 NodeAsmName.data(), NodeAsmName.size() + 1)); 132 GlobalInits.get(), NodeAsmName.data(), NodeAsmName.size() + 1));
133 const SizeT Int64ByteSize = typeWidthInBytes(IceType_i64); 133 const SizeT Int64ByteSize = typeWidthInBytes(IceType_i64);
134 Var->setAlignment(Int64ByteSize); // Wasteful, 32-bit could use 4 bytes. 134 Var->setAlignment(Int64ByteSize); // Wasteful, 32-bit could use 4 bytes.
135 return Var; 135 GlobalInits->push_back(Var);
136 } 136 }
137 137
138 VariableDeclaration * 138 void Cfg::createBlockProfilingInfoDeclaration(
139 blockProfilingInfoDeclaration(GlobalContext *Ctx, const IceString &NodeAsmName, 139 const IceString &NodeAsmName, VariableDeclaration *NodeNameDeclaration) {
140 VariableDeclaration *NodeNameDeclaration) { 140 auto *Var = VariableDeclaration::create(GlobalInits.get());
141 auto *Var = VariableDeclaration::create(Ctx);
142 Var->setName(BlockStatsGlobalPrefix + NodeAsmName); 141 Var->setName(BlockStatsGlobalPrefix + NodeAsmName);
143 const SizeT Int64ByteSize = typeWidthInBytes(IceType_i64); 142 const SizeT Int64ByteSize = typeWidthInBytes(IceType_i64);
144 Var->addInitializer( 143 Var->addInitializer(VariableDeclaration::ZeroInitializer::create(
145 VariableDeclaration::ZeroInitializer::create(Int64ByteSize)); 144 GlobalInits.get(), Int64ByteSize));
146 145
147 const RelocOffsetT NodeNameDeclarationOffset = 0; 146 const RelocOffsetT NodeNameDeclarationOffset = 0;
148 Var->addInitializer(VariableDeclaration::RelocInitializer::create( 147 Var->addInitializer(VariableDeclaration::RelocInitializer::create(
149 NodeNameDeclaration, 148 GlobalInits.get(), NodeNameDeclaration,
150 {RelocOffset::create(Ctx, NodeNameDeclarationOffset)})); 149 {RelocOffset::create(Ctx, NodeNameDeclarationOffset)}));
151 Var->setAlignment(Int64ByteSize); 150 Var->setAlignment(Int64ByteSize);
152 return Var; 151 GlobalInits->push_back(Var);
153 } 152 }
154 } // end of anonymous namespace
155 153
156 void Cfg::profileBlocks() { 154 void Cfg::profileBlocks() {
157 if (GlobalInits == nullptr) 155 if (GlobalInits == nullptr)
158 GlobalInits.reset(new VariableDeclarationList()); 156 GlobalInits.reset(new VariableDeclarationList());
159 157
160 for (CfgNode *Node : Nodes) { 158 for (CfgNode *Node : Nodes) {
161 IceString NodeAsmName = Node->getAsmName(); 159 const IceString NodeAsmName = Node->getAsmName();
162 GlobalInits->push_back(nodeNameDeclaration(Ctx, NodeAsmName)); 160 createNodeNameDeclaration(NodeAsmName);
163 GlobalInits->push_back( 161 createBlockProfilingInfoDeclaration(NodeAsmName, GlobalInits->back());
164 blockProfilingInfoDeclaration(Ctx, NodeAsmName, GlobalInits->back()));
165 Node->profileExecutionCount(GlobalInits->back()); 162 Node->profileExecutionCount(GlobalInits->back());
166 } 163 }
167 } 164 }
168 165
169 bool Cfg::isProfileGlobal(const VariableDeclaration &Var) { 166 bool Cfg::isProfileGlobal(const VariableDeclaration &Var) {
170 return Var.getName().find(BlockStatsGlobalPrefix) == 0; 167 return Var.getName().find(BlockStatsGlobalPrefix) == 0;
171 } 168 }
172 169
173 void Cfg::addCallToProfileSummary() { 170 void Cfg::addCallToProfileSummary() {
174 // The call(s) to __Sz_profile_summary are added by the profiler in functions 171 // The call(s) to __Sz_profile_summary are added by the profiler in functions
(...skipping 968 matching lines...) Expand 10 before | Expand all | Expand 10 after
1143 } 1140 }
1144 } 1141 }
1145 // Print each basic block 1142 // Print each basic block
1146 for (CfgNode *Node : Nodes) 1143 for (CfgNode *Node : Nodes)
1147 Node->dump(this); 1144 Node->dump(this);
1148 if (isVerbose(IceV_Instructions)) 1145 if (isVerbose(IceV_Instructions))
1149 Str << "}\n"; 1146 Str << "}\n";
1150 } 1147 }
1151 1148
1152 } // end of namespace Ice 1149 } // end of namespace Ice
OLDNEW
« no previous file with comments | « src/IceCfg.h ('k') | src/IceCompiler.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698