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

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

Issue 1097723002: Type and constant propagator should guard against mutable class ids. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix LoadStaticField Created 5 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
« no previous file with comments | « no previous file | runtime/vm/dart_api_impl_test.cc » ('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) 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/constant_propagator.h" 5 #include "vm/constant_propagator.h"
6 6
7 #include "vm/bit_vector.h" 7 #include "vm/bit_vector.h"
8 #include "vm/flow_graph_builder.h" 8 #include "vm/flow_graph_builder.h"
9 #include "vm/flow_graph_compiler.h" 9 #include "vm/flow_graph_compiler.h"
10 #include "vm/flow_graph_range_analysis.h" 10 #include "vm/flow_graph_range_analysis.h"
(...skipping 765 matching lines...) Expand 10 before | Expand all | Expand 10 after
776 SetValue(instr, non_constant_); 776 SetValue(instr, non_constant_);
777 } 777 }
778 778
779 779
780 void ConstantPropagator::VisitLoadClassId(LoadClassIdInstr* instr) { 780 void ConstantPropagator::VisitLoadClassId(LoadClassIdInstr* instr) {
781 intptr_t cid = instr->object()->Type()->ToCid(); 781 intptr_t cid = instr->object()->Type()->ToCid();
782 if (cid != kDynamicCid) { 782 if (cid != kDynamicCid) {
783 SetValue(instr, Smi::ZoneHandle(Z, Smi::New(cid))); 783 SetValue(instr, Smi::ZoneHandle(Z, Smi::New(cid)));
784 return; 784 return;
785 } 785 }
786
786 const Object& object = instr->object()->definition()->constant_value(); 787 const Object& object = instr->object()->definition()->constant_value();
787 if (IsConstant(object)) { 788 if (IsConstant(object)) {
788 SetValue(instr, Smi::ZoneHandle(Z, Smi::New(object.GetClassId()))); 789 cid = object.GetClassId();
789 return; 790 if (CheckClassInstr::IsImmutableClassId(cid)) {
791 SetValue(instr, Smi::ZoneHandle(Z, Smi::New(cid)));
792 return;
793 }
790 } 794 }
791 SetValue(instr, non_constant_); 795 SetValue(instr, non_constant_);
792 } 796 }
793 797
794 798
795 void ConstantPropagator::VisitLoadField(LoadFieldInstr* instr) { 799 void ConstantPropagator::VisitLoadField(LoadFieldInstr* instr) {
796 Value* instance = instr->instance(); 800 Value* instance = instr->instance();
797 if ((instr->recognized_kind() == MethodRecognizer::kObjectArrayLength) && 801 if ((instr->recognized_kind() == MethodRecognizer::kObjectArrayLength) &&
798 instance->definition()->OriginalDefinition()->IsCreateArray()) { 802 instance->definition()->OriginalDefinition()->IsCreateArray()) {
799 Value* num_elements = instance->definition()->OriginalDefinition() 803 Value* num_elements = instance->definition()->OriginalDefinition()
(...skipping 858 matching lines...) Expand 10 before | Expand all | Expand 10 after
1658 graph_->MergeBlocks(); 1662 graph_->MergeBlocks();
1659 GrowableArray<BitVector*> dominance_frontier; 1663 GrowableArray<BitVector*> dominance_frontier;
1660 graph_->ComputeDominators(&dominance_frontier); 1664 graph_->ComputeDominators(&dominance_frontier);
1661 1665
1662 if (FLAG_trace_constant_propagation) { 1666 if (FLAG_trace_constant_propagation) {
1663 FlowGraphPrinter::PrintGraph("After CP", graph_); 1667 FlowGraphPrinter::PrintGraph("After CP", graph_);
1664 } 1668 }
1665 } 1669 }
1666 1670
1667 } // namespace dart 1671 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/dart_api_impl_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698