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

Side by Side Diff: src/property-details.h

Issue 61623004: Add signed/unsigned 8-bit and 16-bit Representations (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address review feedback and prepare to land 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
« no previous file with comments | « src/ia32/macro-assembler-ia32.cc ('k') | src/x64/macro-assembler-x64.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 TRANSITION = 6, 75 TRANSITION = 6,
76 // Only used as a marker in LookupResult. 76 // Only used as a marker in LookupResult.
77 NONEXISTENT = 7 77 NONEXISTENT = 7
78 }; 78 };
79 79
80 80
81 class Representation { 81 class Representation {
82 public: 82 public:
83 enum Kind { 83 enum Kind {
84 kNone, 84 kNone,
85 kByte, 85 kInteger8,
86 kUInteger8,
87 kInteger16,
88 kUInteger16,
86 kSmi, 89 kSmi,
87 kInteger32, 90 kInteger32,
88 kDouble, 91 kDouble,
89 kHeapObject, 92 kHeapObject,
90 kTagged, 93 kTagged,
91 kExternal, 94 kExternal,
92 kNumRepresentations 95 kNumRepresentations
93 }; 96 };
94 97
95 Representation() : kind_(kNone) { } 98 Representation() : kind_(kNone) { }
96 99
97 static Representation None() { return Representation(kNone); } 100 static Representation None() { return Representation(kNone); }
98 static Representation Tagged() { return Representation(kTagged); } 101 static Representation Tagged() { return Representation(kTagged); }
99 static Representation Byte() { return Representation(kByte); } 102 static Representation Integer8() { return Representation(kInteger8); }
103 static Representation UInteger8() { return Representation(kUInteger8); }
104 static Representation Integer16() { return Representation(kInteger16); }
105 static Representation UInteger16() {
106 return Representation(kUInteger16);
107 }
100 static Representation Smi() { return Representation(kSmi); } 108 static Representation Smi() { return Representation(kSmi); }
101 static Representation Integer32() { return Representation(kInteger32); } 109 static Representation Integer32() { return Representation(kInteger32); }
102 static Representation Double() { return Representation(kDouble); } 110 static Representation Double() { return Representation(kDouble); }
103 static Representation HeapObject() { return Representation(kHeapObject); } 111 static Representation HeapObject() { return Representation(kHeapObject); }
104 static Representation External() { return Representation(kExternal); } 112 static Representation External() { return Representation(kExternal); }
105 113
106 static Representation FromKind(Kind kind) { return Representation(kind); } 114 static Representation FromKind(Kind kind) { return Representation(kind); }
107 115
108 // TODO(rossberg): this should die eventually. 116 // TODO(rossberg): this should die eventually.
109 static Representation FromType(TypeInfo info); 117 static Representation FromType(TypeInfo info);
110 static Representation FromType(Handle<Type> type); 118 static Representation FromType(Handle<Type> type);
111 119
112 bool Equals(const Representation& other) const { 120 bool Equals(const Representation& other) const {
113 return kind_ == other.kind_; 121 return kind_ == other.kind_;
114 } 122 }
115 123
116 bool IsCompatibleForLoad(const Representation& other) const { 124 bool IsCompatibleForLoad(const Representation& other) const {
117 return (IsDouble() && other.IsDouble()) || 125 return (IsDouble() && other.IsDouble()) ||
118 (!IsDouble() && !other.IsDouble()); 126 (!IsDouble() && !other.IsDouble());
119 } 127 }
120 128
121 bool IsCompatibleForStore(const Representation& other) const { 129 bool IsCompatibleForStore(const Representation& other) const {
122 return Equals(other); 130 return Equals(other);
123 } 131 }
124 132
125 bool is_more_general_than(const Representation& other) const { 133 bool is_more_general_than(const Representation& other) const {
126 ASSERT(kind_ != kExternal); 134 ASSERT(kind_ != kExternal);
127 ASSERT(other.kind_ != kExternal); 135 ASSERT(other.kind_ != kExternal);
128 if (IsHeapObject()) return other.IsDouble() || other.IsNone(); 136 if (IsHeapObject()) return other.IsDouble() || other.IsNone();
137 if (kind_ == kUInteger8 && other.kind_ == kInteger8) return false;
138 if (kind_ == kUInteger16 && other.kind_ == kInteger16) return false;
129 return kind_ > other.kind_; 139 return kind_ > other.kind_;
130 } 140 }
131 141
132 bool fits_into(const Representation& other) const { 142 bool fits_into(const Representation& other) const {
133 return other.is_more_general_than(*this) || other.Equals(*this); 143 return other.is_more_general_than(*this) || other.Equals(*this);
134 } 144 }
135 145
136 Representation generalize(Representation other) { 146 Representation generalize(Representation other) {
137 if (other.fits_into(*this)) return *this; 147 if (other.fits_into(*this)) return *this;
138 if (other.is_more_general_than(*this)) return other; 148 if (other.is_more_general_than(*this)) return other;
139 return Representation::Tagged(); 149 return Representation::Tagged();
140 } 150 }
141 151
152 int size() const {
153 ASSERT(!IsNone());
154 if (IsInteger8() || IsUInteger8()) {
155 return sizeof(uint8_t);
156 }
157 if (IsInteger16() || IsUInteger16()) {
158 return sizeof(uint16_t);
159 }
160 if (IsInteger32()) {
161 return sizeof(uint32_t);
162 }
163 return kPointerSize;
164 }
165
142 Kind kind() const { return static_cast<Kind>(kind_); } 166 Kind kind() const { return static_cast<Kind>(kind_); }
143 bool IsNone() const { return kind_ == kNone; } 167 bool IsNone() const { return kind_ == kNone; }
144 bool IsByte() const { return kind_ == kByte; } 168 bool IsInteger8() const { return kind_ == kInteger8; }
169 bool IsUInteger8() const { return kind_ == kUInteger8; }
170 bool IsInteger16() const { return kind_ == kInteger16; }
171 bool IsUInteger16() const { return kind_ == kUInteger16; }
145 bool IsTagged() const { return kind_ == kTagged; } 172 bool IsTagged() const { return kind_ == kTagged; }
146 bool IsSmi() const { return kind_ == kSmi; } 173 bool IsSmi() const { return kind_ == kSmi; }
147 bool IsSmiOrTagged() const { return IsSmi() || IsTagged(); } 174 bool IsSmiOrTagged() const { return IsSmi() || IsTagged(); }
148 bool IsInteger32() const { return kind_ == kInteger32; } 175 bool IsInteger32() const { return kind_ == kInteger32; }
149 bool IsSmiOrInteger32() const { return IsSmi() || IsInteger32(); } 176 bool IsSmiOrInteger32() const { return IsSmi() || IsInteger32(); }
150 bool IsDouble() const { return kind_ == kDouble; } 177 bool IsDouble() const { return kind_ == kDouble; }
151 bool IsHeapObject() const { return kind_ == kHeapObject; } 178 bool IsHeapObject() const { return kind_ == kHeapObject; }
152 bool IsExternal() const { return kind_ == kExternal; } 179 bool IsExternal() const { return kind_ == kExternal; }
153 bool IsSpecialization() const { 180 bool IsSpecialization() const {
154 return IsByte() || IsSmi() || IsInteger32() || IsDouble(); 181 return IsInteger8() || IsUInteger8() ||
182 IsInteger16() || IsUInteger16() ||
183 IsSmi() || IsInteger32() || IsDouble();
155 } 184 }
156 const char* Mnemonic() const; 185 const char* Mnemonic() const;
157 186
158 private: 187 private:
159 explicit Representation(Kind k) : kind_(k) { } 188 explicit Representation(Kind k) : kind_(k) { }
160 189
161 // Make sure kind fits in int8. 190 // Make sure kind fits in int8.
162 STATIC_ASSERT(kNumRepresentations <= (1 << kBitsPerByte)); 191 STATIC_ASSERT(kNumRepresentations <= (1 << kBitsPerByte));
163 192
164 int8_t kind_; 193 int8_t kind_;
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 // constants can be embedded in generated code. 278 // constants can be embedded in generated code.
250 class TypeField: public BitField<PropertyType, 0, 3> {}; 279 class TypeField: public BitField<PropertyType, 0, 3> {};
251 class AttributesField: public BitField<PropertyAttributes, 3, 3> {}; 280 class AttributesField: public BitField<PropertyAttributes, 3, 3> {};
252 281
253 // Bit fields for normalized objects. 282 // Bit fields for normalized objects.
254 class DeletedField: public BitField<uint32_t, 6, 1> {}; 283 class DeletedField: public BitField<uint32_t, 6, 1> {};
255 class DictionaryStorageField: public BitField<uint32_t, 7, 24> {}; 284 class DictionaryStorageField: public BitField<uint32_t, 7, 24> {};
256 285
257 // Bit fields for fast objects. 286 // Bit fields for fast objects.
258 class DescriptorPointer: public BitField<uint32_t, 6, 11> {}; 287 class DescriptorPointer: public BitField<uint32_t, 6, 11> {};
259 class RepresentationField: public BitField<uint32_t, 17, 3> {}; 288 class RepresentationField: public BitField<uint32_t, 17, 4> {};
260 class FieldIndexField: public BitField<uint32_t, 20, 11> {}; 289 class FieldIndexField: public BitField<uint32_t, 21, 10> {};
261 290
262 static const int kInitialIndex = 1; 291 static const int kInitialIndex = 1;
263 292
264 private: 293 private:
265 PropertyDetails(int value, int pointer) { 294 PropertyDetails(int value, int pointer) {
266 value_ = DescriptorPointer::update(value, pointer); 295 value_ = DescriptorPointer::update(value, pointer);
267 } 296 }
268 PropertyDetails(int value, Representation representation) { 297 PropertyDetails(int value, Representation representation) {
269 value_ = RepresentationField::update( 298 value_ = RepresentationField::update(
270 value, EncodeRepresentation(representation)); 299 value, EncodeRepresentation(representation));
271 } 300 }
272 PropertyDetails(int value, PropertyAttributes attributes) { 301 PropertyDetails(int value, PropertyAttributes attributes) {
273 value_ = AttributesField::update(value, attributes); 302 value_ = AttributesField::update(value, attributes);
274 } 303 }
275 304
276 uint32_t value_; 305 uint32_t value_;
277 }; 306 };
278 307
279 } } // namespace v8::internal 308 } } // namespace v8::internal
280 309
281 #endif // V8_PROPERTY_DETAILS_H_ 310 #endif // V8_PROPERTY_DETAILS_H_
OLDNEW
« no previous file with comments | « src/ia32/macro-assembler-ia32.cc ('k') | src/x64/macro-assembler-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698