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

Side by Side Diff: runtime/vm/flow_graph.cc

Issue 2891113002: Use same range info when emitting code and computing if instruction can deopt. (Closed)
Patch Set: Add a comment to the test Created 3 years, 7 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 | « runtime/vm/constant_propagator.cc ('k') | runtime/vm/flow_graph_range_analysis.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/flow_graph.h" 5 #include "vm/flow_graph.h"
6 6
7 #include "vm/bit_vector.h" 7 #include "vm/bit_vector.h"
8 #include "vm/cha.h" 8 #include "vm/cha.h"
9 #include "vm/flow_graph_builder.h" 9 #include "vm/flow_graph_builder.h"
10 #include "vm/flow_graph_compiler.h" 10 #include "vm/flow_graph_compiler.h"
(...skipping 2262 matching lines...) Expand 10 before | Expand all | Expand 10 after
2273 Definition* right_def = curr_instr->right()->definition(); 2273 Definition* right_def = curr_instr->right()->definition();
2274 for (intptr_t k = i + 1; k < merge_candidates->length(); k++) { 2274 for (intptr_t k = i + 1; k < merge_candidates->length(); k++) {
2275 BinarySmiOpInstr* other_binop = (*merge_candidates)[k]; 2275 BinarySmiOpInstr* other_binop = (*merge_candidates)[k];
2276 // 'other_binop' can be NULL if it was already merged. 2276 // 'other_binop' can be NULL if it was already merged.
2277 if ((other_binop != NULL) && (other_binop->op_kind() == other_kind) && 2277 if ((other_binop != NULL) && (other_binop->op_kind() == other_kind) &&
2278 (other_binop->left()->definition() == left_def) && 2278 (other_binop->left()->definition() == left_def) &&
2279 (other_binop->right()->definition() == right_def)) { 2279 (other_binop->right()->definition() == right_def)) {
2280 (*merge_candidates)[k] = NULL; // Clear it. 2280 (*merge_candidates)[k] = NULL; // Clear it.
2281 ASSERT(curr_instr->HasUses()); 2281 ASSERT(curr_instr->HasUses());
2282 AppendExtractNthOutputForMerged( 2282 AppendExtractNthOutputForMerged(
2283 curr_instr, MergedMathInstr::OutputIndexOf(curr_instr->op_kind()), 2283 curr_instr, TruncDivModInstr::OutputIndexOf(curr_instr->op_kind()),
2284 kTagged, kSmiCid); 2284 kTagged, kSmiCid);
2285 ASSERT(other_binop->HasUses()); 2285 ASSERT(other_binop->HasUses());
2286 AppendExtractNthOutputForMerged( 2286 AppendExtractNthOutputForMerged(
2287 other_binop, MergedMathInstr::OutputIndexOf(other_binop->op_kind()), 2287 other_binop,
2288 kTagged, kSmiCid); 2288 TruncDivModInstr::OutputIndexOf(other_binop->op_kind()), kTagged,
2289 2289 kSmiCid);
2290 ZoneGrowableArray<Value*>* args = new (Z) ZoneGrowableArray<Value*>(2);
2291 args->Add(new (Z) Value(curr_instr->left()->definition()));
2292 args->Add(new (Z) Value(curr_instr->right()->definition()));
2293 2290
2294 // Replace with TruncDivMod. 2291 // Replace with TruncDivMod.
2295 MergedMathInstr* div_mod = new (Z) MergedMathInstr( 2292 TruncDivModInstr* div_mod = new (Z) TruncDivModInstr(
2296 args, curr_instr->deopt_id(), MergedMathInstr::kTruncDivMod); 2293 curr_instr->left()->CopyWithType(),
2294 curr_instr->right()->CopyWithType(), curr_instr->deopt_id());
2297 curr_instr->ReplaceWith(div_mod, NULL); 2295 curr_instr->ReplaceWith(div_mod, NULL);
2298 other_binop->ReplaceUsesWith(div_mod); 2296 other_binop->ReplaceUsesWith(div_mod);
2299 other_binop->RemoveFromGraph(); 2297 other_binop->RemoveFromGraph();
2300 // Only one merge possible. Because canonicalization happens later, 2298 // Only one merge possible. Because canonicalization happens later,
2301 // more candidates are possible. 2299 // more candidates are possible.
2302 // TODO(srdjan): Allow merging of trunc-div/mod into truncDivMod. 2300 // TODO(srdjan): Allow merging of trunc-div/mod into truncDivMod.
2303 break; 2301 break;
2304 } 2302 }
2305 } 2303 }
2306 } 2304 }
2307 } 2305 }
2308 2306
2309 2307
2310 void FlowGraph::AppendExtractNthOutputForMerged(Definition* instr, 2308 void FlowGraph::AppendExtractNthOutputForMerged(Definition* instr,
2311 intptr_t index, 2309 intptr_t index,
2312 Representation rep, 2310 Representation rep,
2313 intptr_t cid) { 2311 intptr_t cid) {
2314 ExtractNthOutputInstr* extract = 2312 ExtractNthOutputInstr* extract =
2315 new (Z) ExtractNthOutputInstr(new (Z) Value(instr), index, rep, cid); 2313 new (Z) ExtractNthOutputInstr(new (Z) Value(instr), index, rep, cid);
2316 instr->ReplaceUsesWith(extract); 2314 instr->ReplaceUsesWith(extract);
2317 InsertAfter(instr, extract, NULL, FlowGraph::kValue); 2315 InsertAfter(instr, extract, NULL, FlowGraph::kValue);
2318 } 2316 }
2319 2317
2320 2318
2321 } // namespace dart 2319 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/constant_propagator.cc ('k') | runtime/vm/flow_graph_range_analysis.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698