Bug 933764 - Hide specific members of a TypeRepresentationSet r=jandem

This commit is contained in:
Nicholas D. Matsakis 2013-11-01 10:46:19 -04:00
Родитель d96a9ff104
Коммит 006bde45da
3 изменённых файлов: 29 добавлений и 15 удалений

Просмотреть файл

@ -6532,9 +6532,9 @@ IonBuilder::getElemTryScalarElemOfTypedObject(bool *emitted,
JS_ASSERT(objTypeReprs.allOfArrayKind()); JS_ASSERT(objTypeReprs.allOfArrayKind());
// Must always be loading the same scalar type // Must always be loading the same scalar type
if (elemTypeReprs.length() != 1) if (!elemTypeReprs.singleton())
return true; return true;
ScalarTypeRepresentation *elemTypeRepr = elemTypeReprs.get(0)->asScalar(); ScalarTypeRepresentation *elemTypeRepr = elemTypeReprs.getTypeRepresentation()->asScalar();
// Get the length. // Get the length.
size_t lenOfAll = objTypeReprs.arrayLength(); size_t lenOfAll = objTypeReprs.arrayLength();
@ -8231,9 +8231,9 @@ IonBuilder::getPropTryScalarPropOfTypedObject(bool *emitted,
types::TemporaryTypeSet *resultTypes) types::TemporaryTypeSet *resultTypes)
{ {
// Must always be loading the same scalar type // Must always be loading the same scalar type
if (fieldTypeReprs.length() != 1) if (!fieldTypeReprs.singleton())
return true; return true;
ScalarTypeRepresentation *fieldTypeRepr = fieldTypeReprs.get(0)->asScalar(); ScalarTypeRepresentation *fieldTypeRepr = fieldTypeReprs.getTypeRepresentation()->asScalar();
// OK! // OK!
*emitted = true; *emitted = true;
@ -8756,9 +8756,10 @@ IonBuilder::setPropTryTypedObject(bool *emitted, MDefinition *obj,
} }
// Must always be storing the same scalar type // Must always be storing the same scalar type
if (fieldTypeReprs.length() != 1) if (!fieldTypeReprs.singleton())
return true; return true;
ScalarTypeRepresentation *fieldTypeRepr = fieldTypeReprs.get(0)->asScalar(); ScalarTypeRepresentation *fieldTypeRepr =
fieldTypeReprs.getTypeRepresentation()->asScalar();
// OK! // OK!
*emitted = true; *emitted = true;

Просмотреть файл

@ -162,20 +162,20 @@ TypeRepresentationSet::TypeRepresentationSet()
bool bool
TypeRepresentationSet::empty() TypeRepresentationSet::empty()
{ {
return length() == 0; return length_ == 0;
} }
size_t bool
TypeRepresentationSet::length() TypeRepresentationSet::singleton()
{ {
return length_; return length_ == 1;
} }
TypeRepresentation * TypeRepresentation *
TypeRepresentationSet::get(size_t i) TypeRepresentationSet::getTypeRepresentation()
{ {
JS_ASSERT(i < length()); JS_ASSERT(singleton());
return entries_[i]; return get(0);
} }
bool bool

Просмотреть файл

@ -55,6 +55,7 @@ class TypeRepresentationSetBuilder {
class TypeRepresentationSet { class TypeRepresentationSet {
private: private:
friend struct TypeRepresentationSetHasher;
friend class TypeRepresentationSetBuilder; friend class TypeRepresentationSetBuilder;
size_t length_; size_t length_;
@ -62,6 +63,14 @@ class TypeRepresentationSet {
TypeRepresentationSet(size_t length, TypeRepresentation **entries); TypeRepresentationSet(size_t length, TypeRepresentation **entries);
size_t length() const {
return length_;
}
TypeRepresentation *get(uint32_t i) const {
return entries_[i];
}
public: public:
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
// Constructors // Constructors
@ -76,8 +85,7 @@ class TypeRepresentationSet {
// Query the set // Query the set
bool empty(); bool empty();
size_t length(); bool singleton();
TypeRepresentation *get(size_t i);
bool allOfKind(TypeRepresentation::Kind kind); bool allOfKind(TypeRepresentation::Kind kind);
// Returns true only when non-empty and `kind()` is // Returns true only when non-empty and `kind()` is
@ -99,6 +107,11 @@ class TypeRepresentationSet {
TypeRepresentation::Kind kind(); TypeRepresentation::Kind kind();
//////////////////////////////////////////////////////////////////////
// The following operations are only valid on a singleton set:
TypeRepresentation *getTypeRepresentation();
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
// Array operations // Array operations
// //