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

Unified Diff: runtime/vm/object.h

Issue 10578018: Fix type test elimination using static type propagation in new compiler. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: runtime/vm/object.h
===================================================================
--- runtime/vm/object.h (revision 8864)
+++ runtime/vm/object.h (working copy)
@@ -337,6 +337,12 @@
static const ObjectKind kInstanceKind = kObject;
+ // Different kinds of type tests.
+ enum TypeTestKind {
+ kIsSubtypeOf = 0,
+ kIsMoreSpecificThan
+ };
+
protected:
// Used for extracting the C++ vtable during bringup.
Object() : raw_(null_) {}
@@ -602,8 +608,26 @@
bool IsSubtypeOf(const AbstractTypeArguments& type_arguments,
const Class& other,
const AbstractTypeArguments& other_type_arguments,
- Error* malformed_error) const;
+ Error* malformed_error) const {
+ return TypeTest(kIsSubtypeOf,
+ type_arguments,
+ other,
+ other_type_arguments,
+ malformed_error);
+ }
+ // Check the 'more specific' relationship.
+ bool IsMoreSpecificThan(const AbstractTypeArguments& type_arguments,
+ const Class& other,
+ const AbstractTypeArguments& other_type_arguments,
+ Error* malformed_error) const {
+ return TypeTest(kIsMoreSpecificThan,
+ type_arguments,
+ other,
+ other_type_arguments,
+ malformed_error);
+ }
+
// Check if this is the top level class.
bool IsTopLevel() const;
@@ -739,9 +763,17 @@
const Script& script,
intptr_t token_index);
+ // Check the subtype or 'more specific' relationship.
+ bool TypeTest(TypeTestKind test,
+ const AbstractTypeArguments& type_arguments,
+ const Class& other,
+ const AbstractTypeArguments& other_type_arguments,
+ Error* malformed_error) const;
+
HEAP_OBJECT_IMPLEMENTATION(Class, Object);
friend class Object;
friend class Instance;
+ friend class AbstractType;
friend class Type;
};
@@ -870,11 +902,26 @@
}
// Check the subtype relationship.
- bool IsSubtypeOf(const AbstractType& other, Error* malformed_error) const;
+ bool IsSubtypeOf(const AbstractType& other, Error* malformed_error) const {
+ return TypeTest(kIsSubtypeOf, other, malformed_error);
+ }
+ // Check the 'more specific' relationship.
+ bool IsMoreSpecificThan(const AbstractType& other,
+ Error* malformed_error) const {
+ return TypeTest(kIsMoreSpecificThan, other, malformed_error);
+ }
+
+ private:
+ // Check the subtype or 'more specific' relationship.
+ bool TypeTest(TypeTestKind test,
+ const AbstractType& other,
+ Error* malformed_error) const;
+
protected:
HEAP_OBJECT_IMPLEMENTATION(AbstractType, Object);
friend class Class;
+ friend class AbstractTypeArguments;
};
@@ -1083,8 +1130,18 @@
// Check the subtype relationship, considering only a prefix of length 'len'.
bool IsSubtypeOf(const AbstractTypeArguments& other,
intptr_t len,
- Error* malformed_error) const;
+ Error* malformed_error) const {
+ return TypeTest(kIsSubtypeOf, other, len, malformed_error);
+ }
+ // Check the 'more specific' relationship, considering only a prefix of
+ // length 'len'.
+ bool IsMoreSpecificThan(const AbstractTypeArguments& other,
+ intptr_t len,
+ Error* malformed_error) const {
+ return TypeTest(kIsMoreSpecificThan, other, len, malformed_error);
+ }
+
bool Equals(const AbstractTypeArguments& other) const;
// UNREACHABLEs as AbstractTypeArguments is an abstract class.
@@ -1102,6 +1159,13 @@
// instantiated from a vector of dynamic types.
bool IsDynamicTypes(bool raw_instantiated, intptr_t len) const;
+ // Check the subtype or 'more specific' relationship, considering only a
+ // prefix of length 'len'.
+ bool TypeTest(TypeTestKind test,
+ const AbstractTypeArguments& other,
+ intptr_t len,
+ Error* malformed_error) const;
+
protected:
HEAP_OBJECT_IMPLEMENTATION(AbstractTypeArguments, Object);
friend class Class;
« no previous file with comments | « runtime/vm/flow_graph_builder.cc ('k') | runtime/vm/object.cc » ('j') | runtime/vm/object.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698