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

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

Issue 51123003: VM: Fix checked mode crash (issue 13831). (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 1 month 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 (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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_optimizer.h" 5 #include "vm/flow_graph_optimizer.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/dart_entry.h" 9 #include "vm/dart_entry.h"
10 #include "vm/flow_graph_builder.h" 10 #include "vm/flow_graph_builder.h"
(...skipping 4176 matching lines...) Expand 10 before | Expand all | Expand 10 after
4187 // Host CheckSmi instruction and make this phi smi one. 4187 // Host CheckSmi instruction and make this phi smi one.
4188 Hoist(it, pre_header, current); 4188 Hoist(it, pre_header, current);
4189 4189
4190 // Replace value we are checking with phi's input. 4190 // Replace value we are checking with phi's input.
4191 current->value()->BindTo(phi->InputAt(non_smi_input)->definition()); 4191 current->value()->BindTo(phi->InputAt(non_smi_input)->definition());
4192 4192
4193 phi->UpdateType(CompileType::FromCid(kSmiCid)); 4193 phi->UpdateType(CompileType::FromCid(kSmiCid));
4194 } 4194 }
4195 4195
4196 4196
4197 // Load instructions handled by load elimination.
4198 static bool IsCandidateLoad(Instruction* instr) {
4199 return instr->IsLoadField()
4200 || instr->IsLoadIndexed()
4201 || instr->IsLoadStaticField()
4202 || instr->IsCurrentContext();
4203 }
4204
4205
4197 static bool IsLoopInvariantLoad(ZoneGrowableArray<BitVector*>* sets, 4206 static bool IsLoopInvariantLoad(ZoneGrowableArray<BitVector*>* sets,
4198 intptr_t loop_header_index, 4207 intptr_t loop_header_index,
4199 Instruction* instr) { 4208 Instruction* instr) {
4200 return (sets != NULL) && 4209 return IsCandidateLoad(instr) &&
4210 (sets != NULL) &&
4201 instr->HasPlaceId() && 4211 instr->HasPlaceId() &&
4202 ((*sets)[loop_header_index] != NULL) && 4212 ((*sets)[loop_header_index] != NULL) &&
4203 (*sets)[loop_header_index]->Contains(instr->place_id()); 4213 (*sets)[loop_header_index]->Contains(instr->place_id());
4204 } 4214 }
4205 4215
4206 4216
4207 void LICM::Optimize() { 4217 void LICM::Optimize() {
4208 const ZoneGrowableArray<BlockEntryInstr*>& loop_headers = 4218 const ZoneGrowableArray<BlockEntryInstr*>& loop_headers =
4209 flow_graph()->loop_headers(); 4219 flow_graph()->loop_headers();
4210 4220
(...skipping 2264 matching lines...) Expand 10 before | Expand all | Expand 10 after
6475 StoreInstanceFieldInstr* instr) { 6485 StoreInstanceFieldInstr* instr) {
6476 SetValue(instr, instr->value()->definition()->constant_value()); 6486 SetValue(instr, instr->value()->definition()->constant_value());
6477 } 6487 }
6478 6488
6479 6489
6480 void ConstantPropagator::VisitLoadStaticField(LoadStaticFieldInstr* instr) { 6490 void ConstantPropagator::VisitLoadStaticField(LoadStaticFieldInstr* instr) {
6481 const Field& field = instr->StaticField(); 6491 const Field& field = instr->StaticField();
6482 ASSERT(field.is_static()); 6492 ASSERT(field.is_static());
6483 if (field.is_final()) { 6493 if (field.is_final()) {
6484 Instance& obj = Instance::Handle(field.value()); 6494 Instance& obj = Instance::Handle(field.value());
6495 ASSERT(obj.raw() != Object::sentinel().raw());
6496 ASSERT(obj.raw() != Object::transition_sentinel().raw());
6485 if (obj.IsSmi() || obj.IsOld()) { 6497 if (obj.IsSmi() || obj.IsOld()) {
6486 SetValue(instr, obj); 6498 SetValue(instr, obj);
6487 return; 6499 return;
6488 } 6500 }
6489 } 6501 }
6490 SetValue(instr, non_constant_); 6502 SetValue(instr, non_constant_);
6491 } 6503 }
6492 6504
6493 6505
6494 void ConstantPropagator::VisitStoreStaticField(StoreStaticFieldInstr* instr) { 6506 void ConstantPropagator::VisitStoreStaticField(StoreStaticFieldInstr* instr) {
(...skipping 1416 matching lines...) Expand 10 before | Expand all | Expand 10 after
7911 } 7923 }
7912 7924
7913 // Insert materializations at environment uses. 7925 // Insert materializations at environment uses.
7914 for (intptr_t i = 0; i < exits.length(); i++) { 7926 for (intptr_t i = 0; i < exits.length(); i++) {
7915 CreateMaterializationAt(exits[i], alloc, alloc->cls(), *fields); 7927 CreateMaterializationAt(exits[i], alloc, alloc->cls(), *fields);
7916 } 7928 }
7917 } 7929 }
7918 7930
7919 7931
7920 } // namespace dart 7932 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698