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

Side by Side Diff: src/hydrogen-escape-analysis.cc

Issue 251493004: Preserve Smi representation of non-escaping fields. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Tweaks Created 6 years, 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 HValue* value = state->map_value(); 154 HValue* value = state->map_value();
155 // TODO(mstarzinger): This will narrow a map check against a set of maps 155 // TODO(mstarzinger): This will narrow a map check against a set of maps
156 // down to the first element in the set. Revisit and fix this. 156 // down to the first element in the set. Revisit and fix this.
157 HCheckValue* check = HCheckValue::New( 157 HCheckValue* check = HCheckValue::New(
158 zone, NULL, value, mapcheck->first_map(), false); 158 zone, NULL, value, mapcheck->first_map(), false);
159 check->InsertBefore(mapcheck); 159 check->InsertBefore(mapcheck);
160 return check; 160 return check;
161 } 161 }
162 162
163 163
164 // Replace a field load with a given value, forcing Smi representation if
165 // necessary.
166 void HEscapeAnalysisPhase::ReplaceFieldLoadWithValue(
167 HLoadNamedField* load, HValue* load_value) {
168 HValue* replacement = load_value;
169 Representation representation = load->representation();
170 if (representation.IsSmi()) {
171 Zone* zone = graph()->zone();
172 HInstruction* new_instr =
173 HForceRepresentation::New(zone, NULL, load_value, representation);
174 new_instr->InsertAfter(load);
175 replacement = new_instr;
176 }
177 load->DeleteAndReplaceWith(replacement);
Michael Starzinger 2014/04/25 11:08:09 nit: I was actually thinking along the lines of ha
178 if (FLAG_trace_escape_analysis) {
179 PrintF("Replacing load #%d with #%d (%s)\n", load->id(),
180 replacement->id(), replacement->Mnemonic());
181 }
182 }
183
184
164 // Performs a forward data-flow analysis of all loads and stores on the 185 // Performs a forward data-flow analysis of all loads and stores on the
165 // given captured allocation. This uses a reverse post-order iteration 186 // given captured allocation. This uses a reverse post-order iteration
166 // over affected basic blocks. All non-escaping instructions are handled 187 // over affected basic blocks. All non-escaping instructions are handled
167 // and replaced during the analysis. 188 // and replaced during the analysis.
168 void HEscapeAnalysisPhase::AnalyzeDataFlow(HInstruction* allocate) { 189 void HEscapeAnalysisPhase::AnalyzeDataFlow(HInstruction* allocate) {
169 HBasicBlock* allocate_block = allocate->block(); 190 HBasicBlock* allocate_block = allocate->block();
170 block_states_.AddBlock(NULL, graph()->blocks()->length(), zone()); 191 block_states_.AddBlock(NULL, graph()->blocks()->length(), zone());
171 192
172 // Iterate all blocks starting with the allocation block, since the 193 // Iterate all blocks starting with the allocation block, since the
173 // allocation cannot dominate blocks that come before. 194 // allocation cannot dominate blocks that come before.
(...skipping 15 matching lines...) Expand all
189 case HValue::kAllocate: { 210 case HValue::kAllocate: {
190 if (instr != allocate) continue; 211 if (instr != allocate) continue;
191 state = NewStateForAllocation(allocate); 212 state = NewStateForAllocation(allocate);
192 break; 213 break;
193 } 214 }
194 case HValue::kLoadNamedField: { 215 case HValue::kLoadNamedField: {
195 HLoadNamedField* load = HLoadNamedField::cast(instr); 216 HLoadNamedField* load = HLoadNamedField::cast(instr);
196 int index = load->access().offset() / kPointerSize; 217 int index = load->access().offset() / kPointerSize;
197 if (load->object() != allocate) continue; 218 if (load->object() != allocate) continue;
198 ASSERT(load->access().IsInobject()); 219 ASSERT(load->access().IsInobject());
199 HValue* replacement = state->OperandAt(index); 220 ReplaceFieldLoadWithValue(load, state->OperandAt(index));
200 load->DeleteAndReplaceWith(replacement);
201 if (FLAG_trace_escape_analysis) {
202 PrintF("Replacing load #%d with #%d (%s)\n", instr->id(),
203 replacement->id(), replacement->Mnemonic());
204 }
205 break; 221 break;
206 } 222 }
207 case HValue::kStoreNamedField: { 223 case HValue::kStoreNamedField: {
208 HStoreNamedField* store = HStoreNamedField::cast(instr); 224 HStoreNamedField* store = HStoreNamedField::cast(instr);
209 int index = store->access().offset() / kPointerSize; 225 int index = store->access().offset() / kPointerSize;
210 if (store->object() != allocate) continue; 226 if (store->object() != allocate) continue;
211 ASSERT(store->access().IsInobject()); 227 ASSERT(store->access().IsInobject());
212 state = NewStateCopy(store->previous(), state); 228 state = NewStateCopy(store->previous(), state);
213 state->SetOperandAt(index, store->value()); 229 state->SetOperandAt(index, store->value());
214 if (store->has_transition()) { 230 if (store->has_transition()) {
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 for (int i = 0; i < max_fixpoint_iteration_count; i++) { 340 for (int i = 0; i < max_fixpoint_iteration_count; i++) {
325 CollectCapturedValues(); 341 CollectCapturedValues();
326 if (captured_.is_empty()) break; 342 if (captured_.is_empty()) break;
327 PerformScalarReplacement(); 343 PerformScalarReplacement();
328 captured_.Clear(); 344 captured_.Clear();
329 } 345 }
330 } 346 }
331 347
332 348
333 } } // namespace v8::internal 349 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/hydrogen-escape-analysis.h ('k') | test/mjsunit/regress/regress-escape-preserve-smi-representation.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698