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

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

Issue 26682003: Cache number of type arguments in class object instead of recalculating it. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 2 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 | « runtime/vm/flow_graph_compiler_x64.cc ('k') | runtime/vm/flow_graph_type_propagator.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/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 2629 matching lines...) Expand 10 before | Expand all | Expand 10 after
2640 // Returns a Boolean constant if all classes in ic_data yield the same type-test 2640 // Returns a Boolean constant if all classes in ic_data yield the same type-test
2641 // result and the type tests do not depend on type arguments. Otherwise return 2641 // result and the type tests do not depend on type arguments. Otherwise return
2642 // Bool::null(). 2642 // Bool::null().
2643 RawBool* FlowGraphOptimizer::InstanceOfAsBool(const ICData& ic_data, 2643 RawBool* FlowGraphOptimizer::InstanceOfAsBool(const ICData& ic_data,
2644 const AbstractType& type) const { 2644 const AbstractType& type) const {
2645 ASSERT(ic_data.num_args_tested() == 1); // Unary checks only. 2645 ASSERT(ic_data.num_args_tested() == 1); // Unary checks only.
2646 if (!type.IsInstantiated() || type.IsMalformed() || type.IsMalbounded()) { 2646 if (!type.IsInstantiated() || type.IsMalformed() || type.IsMalbounded()) {
2647 return Bool::null(); 2647 return Bool::null();
2648 } 2648 }
2649 const Class& type_class = Class::Handle(type.type_class()); 2649 const Class& type_class = Class::Handle(type.type_class());
2650 if (type_class.HasTypeArguments()) { 2650 if (type_class.NumTypeArguments() > 0) {
2651 // Only raw types can be directly compared, thus disregarding type 2651 // Only raw types can be directly compared, thus disregarding type
2652 // arguments. 2652 // arguments.
2653 const AbstractTypeArguments& type_arguments = 2653 const AbstractTypeArguments& type_arguments =
2654 AbstractTypeArguments::Handle(type.arguments()); 2654 AbstractTypeArguments::Handle(type.arguments());
2655 const bool is_raw_type = type_arguments.IsNull() || 2655 const bool is_raw_type = type_arguments.IsNull() ||
2656 type_arguments.IsRaw(type_arguments.Length()); 2656 type_arguments.IsRaw(type_arguments.Length());
2657 if (!is_raw_type) { 2657 if (!is_raw_type) {
2658 // Unknown result. 2658 // Unknown result.
2659 return Bool::null(); 2659 return Bool::null();
2660 } 2660 }
2661 } 2661 }
2662 const ClassTable& class_table = *Isolate::Current()->class_table(); 2662 const ClassTable& class_table = *Isolate::Current()->class_table();
2663 Bool& prev = Bool::Handle(); 2663 Bool& prev = Bool::Handle();
2664 Class& cls = Class::Handle(); 2664 Class& cls = Class::Handle();
2665 for (int i = 0; i < ic_data.NumberOfChecks(); i++) { 2665 for (int i = 0; i < ic_data.NumberOfChecks(); i++) {
2666 cls = class_table.At(ic_data.GetReceiverClassIdAt(i)); 2666 cls = class_table.At(ic_data.GetReceiverClassIdAt(i));
2667 if (cls.HasTypeArguments()) return Bool::null(); 2667 if (cls.NumTypeArguments() > 0) return Bool::null();
2668 const bool is_subtype = cls.IsSubtypeOf(TypeArguments::Handle(), 2668 const bool is_subtype = cls.IsSubtypeOf(TypeArguments::Handle(),
2669 type_class, 2669 type_class,
2670 TypeArguments::Handle(), 2670 TypeArguments::Handle(),
2671 NULL); 2671 NULL);
2672 if (prev.IsNull()) { 2672 if (prev.IsNull()) {
2673 prev = Bool::Get(is_subtype).raw(); 2673 prev = Bool::Get(is_subtype).raw();
2674 } else { 2674 } else {
2675 if (is_subtype != prev.value()) return Bool::null(); 2675 if (is_subtype != prev.value()) return Bool::null();
2676 } 2676 }
2677 } 2677 }
(...skipping 4988 matching lines...) Expand 10 before | Expand all | Expand 10 after
7666 } 7666 }
7667 7667
7668 // Insert materializations at environment uses. 7668 // Insert materializations at environment uses.
7669 for (intptr_t i = 0; i < exits.length(); i++) { 7669 for (intptr_t i = 0; i < exits.length(); i++) {
7670 CreateMaterializationAt(exits[i], alloc, alloc->cls(), *fields); 7670 CreateMaterializationAt(exits[i], alloc, alloc->cls(), *fields);
7671 } 7671 }
7672 } 7672 }
7673 7673
7674 7674
7675 } // namespace dart 7675 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_compiler_x64.cc ('k') | runtime/vm/flow_graph_type_propagator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698