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

Side by Side Diff: src/frame-element.h

Issue 146077: Removed static type inference and add a dynamic test for string addition. (Closed)
Patch Set: And it lints too. Created 11 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 unified diff | Download patch
OLDNEW
1 // Copyright 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 47
48 class FrameElement BASE_EMBEDDED { 48 class FrameElement BASE_EMBEDDED {
49 public: 49 public:
50 enum SyncFlag { 50 enum SyncFlag {
51 NOT_SYNCED, 51 NOT_SYNCED,
52 SYNCED 52 SYNCED
53 }; 53 };
54 54
55 // The default constructor creates an invalid frame element. 55 // The default constructor creates an invalid frame element.
56 FrameElement() { 56 FrameElement() {
57 value_ = StaticTypeField::encode(StaticType::UNKNOWN_TYPE) 57 value_ = TypeField::encode(INVALID)
58 | TypeField::encode(INVALID)
59 | CopiedField::encode(false) 58 | CopiedField::encode(false)
60 | SyncedField::encode(false) 59 | SyncedField::encode(false)
61 | DataField::encode(0); 60 | DataField::encode(0);
62 } 61 }
63 62
64 // Factory function to construct an invalid frame element. 63 // Factory function to construct an invalid frame element.
65 static FrameElement InvalidElement() { 64 static FrameElement InvalidElement() {
66 FrameElement result; 65 FrameElement result;
67 return result; 66 return result;
68 } 67 }
69 68
70 // Factory function to construct an in-memory frame element. 69 // Factory function to construct an in-memory frame element.
71 static FrameElement MemoryElement() { 70 static FrameElement MemoryElement() {
72 FrameElement result(MEMORY, no_reg, SYNCED); 71 FrameElement result(MEMORY, no_reg, SYNCED);
73 return result; 72 return result;
74 } 73 }
75 74
76 // Factory function to construct an in-register frame element. 75 // Factory function to construct an in-register frame element.
77 static FrameElement RegisterElement(Register reg, 76 static FrameElement RegisterElement(Register reg,
78 SyncFlag is_synced, 77 SyncFlag is_synced) {
79 StaticType static_type = StaticType()) { 78 return FrameElement(REGISTER, reg, is_synced);
80 return FrameElement(REGISTER, reg, is_synced, static_type);
81 } 79 }
82 80
83 // Factory function to construct a frame element whose value is known at 81 // Factory function to construct a frame element whose value is known at
84 // compile time. 82 // compile time.
85 static FrameElement ConstantElement(Handle<Object> value, 83 static FrameElement ConstantElement(Handle<Object> value,
86 SyncFlag is_synced) { 84 SyncFlag is_synced) {
87 FrameElement result(value, is_synced); 85 FrameElement result(value, is_synced);
88 return result; 86 return result;
89 } 87 }
90 88
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 Handle<Object> handle() const { 134 Handle<Object> handle() const {
137 ASSERT(is_constant()); 135 ASSERT(is_constant());
138 return ConstantList()->at(DataField::decode(value_)); 136 return ConstantList()->at(DataField::decode(value_));
139 } 137 }
140 138
141 int index() const { 139 int index() const {
142 ASSERT(is_copy()); 140 ASSERT(is_copy());
143 return DataField::decode(value_); 141 return DataField::decode(value_);
144 } 142 }
145 143
146 StaticType static_type() {
147 return StaticType(StaticTypeField::decode(value_));
148 }
149
150 void set_static_type(StaticType static_type) {
151 value_ = value_ & ~StaticTypeField::mask();
152 value_ = value_ | StaticTypeField::encode(static_type.static_type_);
153 }
154
155 bool Equals(FrameElement other) { 144 bool Equals(FrameElement other) {
156 uint32_t masked_difference = (value_ ^ other.value_) & ~CopiedField::mask(); 145 uint32_t masked_difference = (value_ ^ other.value_) & ~CopiedField::mask();
157 if (!masked_difference) { 146 if (!masked_difference) {
158 // The elements are equal if they agree exactly except on copied field. 147 // The elements are equal if they agree exactly except on copied field.
159 return true; 148 return true;
160 } else { 149 } else {
161 // If two constants have the same value, and agree otherwise, return true. 150 // If two constants have the same value, and agree otherwise, return true.
162 return !(masked_difference & ~DataField::mask()) && 151 return !(masked_difference & ~DataField::mask()) &&
163 is_constant() && 152 is_constant() &&
164 handle().is_identical_to(other.handle()); 153 handle().is_identical_to(other.handle());
(...skipping 12 matching lines...) Expand all
177 } 166 }
178 167
179 // Given a pair of non-null frame element pointers, return one of them 168 // Given a pair of non-null frame element pointers, return one of them
180 // as an entry frame candidate or null if they are incompatible. 169 // as an entry frame candidate or null if they are incompatible.
181 FrameElement* Combine(FrameElement* other) { 170 FrameElement* Combine(FrameElement* other) {
182 // If either is invalid, the result is. 171 // If either is invalid, the result is.
183 if (!is_valid()) return this; 172 if (!is_valid()) return this;
184 if (!other->is_valid()) return other; 173 if (!other->is_valid()) return other;
185 174
186 if (!SameLocation(other)) return NULL; 175 if (!SameLocation(other)) return NULL;
187 // If either is unsynced, the result is. The result static type is 176 // If either is unsynced, the result is.
188 // the merge of the static types. It's safe to set it on one of the
189 // frame elements, and harmless too (because we are only going to
190 // merge the reaching frames and will ensure that the types are
191 // coherent, and changing the static type does not emit code).
192 FrameElement* result = is_synced() ? other : this; 177 FrameElement* result = is_synced() ? other : this;
193 result->set_static_type(static_type().merge(other->static_type()));
194 return result; 178 return result;
195 } 179 }
196 180
197 private: 181 private:
198 enum Type { 182 enum Type {
199 INVALID, 183 INVALID,
200 MEMORY, 184 MEMORY,
201 REGISTER, 185 REGISTER,
202 CONSTANT, 186 CONSTANT,
203 COPY 187 COPY
204 }; 188 };
205 189
206 // Used to construct memory and register elements. 190 // Used to construct memory and register elements.
207 FrameElement(Type type, Register reg, SyncFlag is_synced) { 191 FrameElement(Type type, Register reg, SyncFlag is_synced) {
208 value_ = StaticTypeField::encode(StaticType::UNKNOWN_TYPE) 192 value_ = TypeField::encode(type)
209 | TypeField::encode(type)
210 | CopiedField::encode(false) 193 | CopiedField::encode(false)
211 | SyncedField::encode(is_synced != NOT_SYNCED) 194 | SyncedField::encode(is_synced != NOT_SYNCED)
212 | DataField::encode(reg.code_ > 0 ? reg.code_ : 0); 195 | DataField::encode(reg.code_ > 0 ? reg.code_ : 0);
213 }
214
215 FrameElement(Type type, Register reg, SyncFlag is_synced, StaticType stype) {
216 value_ = StaticTypeField::encode(stype.static_type_)
217 | TypeField::encode(type)
218 | CopiedField::encode(false)
219 | SyncedField::encode(is_synced != NOT_SYNCED)
220 | DataField::encode(reg.code_ > 0 ? reg.code_ : 0);
221 } 196 }
222 197
223 // Used to construct constant elements. 198 // Used to construct constant elements.
224 FrameElement(Handle<Object> value, SyncFlag is_synced) { 199 FrameElement(Handle<Object> value, SyncFlag is_synced) {
225 value_ = StaticTypeField::encode(StaticType::TypeOf(*value).static_type_) 200 value_ = TypeField::encode(CONSTANT)
226 | TypeField::encode(CONSTANT)
227 | CopiedField::encode(false) 201 | CopiedField::encode(false)
228 | SyncedField::encode(is_synced != NOT_SYNCED) 202 | SyncedField::encode(is_synced != NOT_SYNCED)
229 | DataField::encode(ConstantList()->length()); 203 | DataField::encode(ConstantList()->length());
230 ConstantList()->Add(value); 204 ConstantList()->Add(value);
231 } 205 }
232 206
233 Type type() const { return TypeField::decode(value_); } 207 Type type() const { return TypeField::decode(value_); }
234 void set_type(Type type) { 208 void set_type(Type type) {
235 value_ = value_ & ~TypeField::mask(); 209 value_ = value_ & ~TypeField::mask();
236 value_ = value_ | TypeField::encode(type); 210 value_ = value_ | TypeField::encode(type);
237 } 211 }
238 212
239 void set_index(int new_index) { 213 void set_index(int new_index) {
240 ASSERT(is_copy()); 214 ASSERT(is_copy());
241 value_ = value_ & ~DataField::mask(); 215 value_ = value_ & ~DataField::mask();
242 value_ = value_ | DataField::encode(new_index); 216 value_ = value_ | DataField::encode(new_index);
243 } 217 }
244 218
245 void set_reg(Register new_reg) { 219 void set_reg(Register new_reg) {
246 ASSERT(is_register()); 220 ASSERT(is_register());
247 value_ = value_ & ~DataField::mask(); 221 value_ = value_ & ~DataField::mask();
248 value_ = value_ | DataField::encode(new_reg.code_); 222 value_ = value_ | DataField::encode(new_reg.code_);
249 } 223 }
250 224
251 // Encode static type, type, copied, synced and data in one 32 bit integer. 225 // Encode type, copied, synced and data in one 32 bit integer.
252 uint32_t value_; 226 uint32_t value_;
253 227
254 class StaticTypeField: public BitField<StaticType::StaticTypeEnum, 0, 3> {}; 228 class TypeField: public BitField<Type, 0, 3> {};
255 class TypeField: public BitField<Type, 3, 3> {}; 229 class CopiedField: public BitField<uint32_t, 3, 1> {};
256 class CopiedField: public BitField<uint32_t, 6, 1> {}; 230 class SyncedField: public BitField<uint32_t, 4, 1> {};
257 class SyncedField: public BitField<uint32_t, 7, 1> {}; 231 class DataField: public BitField<uint32_t, 5, 32 - 6> {};
258 class DataField: public BitField<uint32_t, 8, 32 - 9> {};
259 232
260 friend class VirtualFrame; 233 friend class VirtualFrame;
261 }; 234 };
262 235
263 } } // namespace v8::internal 236 } } // namespace v8::internal
264 237
265 #endif // V8_FRAME_ELEMENT_H_ 238 #endif // V8_FRAME_ELEMENT_H_
OLDNEW
« no previous file with comments | « src/arm/virtual-frame-arm.h ('k') | src/ia32/codegen-ia32.cc » ('j') | src/ia32/codegen-ia32.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698