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

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

Issue 668151: Make more use of the NumberInfo data.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 10 years, 9 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 | « no previous file | src/ia32/codegen-ia32.h » ('j') | src/ia32/codegen-ia32.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 // * Register: an element that resides in a register. 46 // * Register: an element that resides in a register.
47 // * Constant: an element whose value is known at compile time. 47 // * Constant: an element whose value is known at compile time.
48 48
49 class FrameElement BASE_EMBEDDED { 49 class FrameElement BASE_EMBEDDED {
50 public: 50 public:
51 enum SyncFlag { 51 enum SyncFlag {
52 NOT_SYNCED, 52 NOT_SYNCED,
53 SYNCED 53 SYNCED
54 }; 54 };
55 55
56 inline NumberInfo::Type number_info() { 56 inline NumberInfo number_info() {
57 // Copied elements do not have number info. Instead 57 // Copied elements do not have number info. Instead
58 // we have to inspect their backing element in the frame. 58 // we have to inspect their backing element in the frame.
59 ASSERT(!is_copy()); 59 ASSERT(!is_copy());
60 if (!is_constant()) return NumberInfoField::decode(value_); 60 if (!is_constant()) return NumberInfo::FromInt(NumberInfoField::decode(value _));
61 Handle<Object> value = handle(); 61 Handle<Object> value = handle();
62 if (value->IsSmi()) return NumberInfo::kSmi; 62 if (value->IsSmi()) return NumberInfo::Smi();
63 if (value->IsHeapNumber()) return NumberInfo::kHeapNumber; 63 if (value->IsHeapNumber()) return NumberInfo::HeapNumber();
64 return NumberInfo::kUnknown; 64 return NumberInfo::Unknown();
65 } 65 }
66 66
67 inline void set_number_info(NumberInfo::Type info) { 67 inline void set_number_info(NumberInfo info) {
68 // Copied elements do not have number info. Instead 68 // Copied elements do not have number info. Instead
69 // we have to inspect their backing element in the frame. 69 // we have to inspect their backing element in the frame.
70 ASSERT(!is_copy()); 70 ASSERT(!is_copy());
71 value_ = value_ & ~NumberInfoField::mask(); 71 value_ = value_ & ~NumberInfoField::mask();
72 value_ = value_ | NumberInfoField::encode(info); 72 value_ = value_ | NumberInfoField::encode(info.ToInt());
73 } 73 }
74 74
75 // The default constructor creates an invalid frame element. 75 // The default constructor creates an invalid frame element.
76 FrameElement() { 76 FrameElement() {
77 value_ = TypeField::encode(INVALID) 77 value_ = TypeField::encode(INVALID)
78 | CopiedField::encode(false) 78 | CopiedField::encode(false)
79 | SyncedField::encode(false) 79 | SyncedField::encode(false)
80 | NumberInfoField::encode(NumberInfo::kUninitialized) 80 | NumberInfoField::encode(NumberInfo::Uninitialized().ToInt())
81 | DataField::encode(0); 81 | DataField::encode(0);
82 } 82 }
83 83
84 // Factory function to construct an invalid frame element. 84 // Factory function to construct an invalid frame element.
85 static FrameElement InvalidElement() { 85 static FrameElement InvalidElement() {
86 FrameElement result; 86 FrameElement result;
87 return result; 87 return result;
88 } 88 }
89 89
90 // Factory function to construct an in-memory frame element. 90 // Factory function to construct an in-memory frame element.
91 static FrameElement MemoryElement(NumberInfo::Type info) { 91 static FrameElement MemoryElement(NumberInfo info) {
92 FrameElement result(MEMORY, no_reg, SYNCED, info); 92 FrameElement result(MEMORY, no_reg, SYNCED, info);
93 return result; 93 return result;
94 } 94 }
95 95
96 // Factory function to construct an in-register frame element. 96 // Factory function to construct an in-register frame element.
97 static FrameElement RegisterElement(Register reg, 97 static FrameElement RegisterElement(Register reg,
98 SyncFlag is_synced, 98 SyncFlag is_synced,
99 NumberInfo::Type info) { 99 NumberInfo info) {
100 return FrameElement(REGISTER, reg, is_synced, info); 100 return FrameElement(REGISTER, reg, is_synced, info);
101 } 101 }
102 102
103 // Factory function to construct a frame element whose value is known at 103 // Factory function to construct a frame element whose value is known at
104 // compile time. 104 // compile time.
105 static FrameElement ConstantElement(Handle<Object> value, 105 static FrameElement ConstantElement(Handle<Object> value,
106 SyncFlag is_synced) { 106 SyncFlag is_synced) {
107 FrameElement result(value, is_synced); 107 FrameElement result(value, is_synced);
108 return result; 108 return result;
109 } 109 }
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 MEMORY, 203 MEMORY,
204 REGISTER, 204 REGISTER,
205 CONSTANT, 205 CONSTANT,
206 COPY 206 COPY
207 }; 207 };
208 208
209 // Used to construct memory and register elements. 209 // Used to construct memory and register elements.
210 FrameElement(Type type, 210 FrameElement(Type type,
211 Register reg, 211 Register reg,
212 SyncFlag is_synced, 212 SyncFlag is_synced,
213 NumberInfo::Type info) { 213 NumberInfo info) {
214 value_ = TypeField::encode(type) 214 value_ = TypeField::encode(type)
215 | CopiedField::encode(false) 215 | CopiedField::encode(false)
216 | SyncedField::encode(is_synced != NOT_SYNCED) 216 | SyncedField::encode(is_synced != NOT_SYNCED)
217 | NumberInfoField::encode(info) 217 | NumberInfoField::encode(info.ToInt())
218 | DataField::encode(reg.code_ > 0 ? reg.code_ : 0); 218 | DataField::encode(reg.code_ > 0 ? reg.code_ : 0);
219 } 219 }
220 220
221 // Used to construct constant elements. 221 // Used to construct constant elements.
222 FrameElement(Handle<Object> value, SyncFlag is_synced) { 222 FrameElement(Handle<Object> value, SyncFlag is_synced) {
223 value_ = TypeField::encode(CONSTANT) 223 value_ = TypeField::encode(CONSTANT)
224 | CopiedField::encode(false) 224 | CopiedField::encode(false)
225 | SyncedField::encode(is_synced != NOT_SYNCED) 225 | SyncedField::encode(is_synced != NOT_SYNCED)
226 | NumberInfoField::encode(NumberInfo::kUninitialized) 226 | NumberInfoField::encode(NumberInfo::Uninitialized().ToInt())
227 | DataField::encode(ConstantList()->length()); 227 | DataField::encode(ConstantList()->length());
228 ConstantList()->Add(value); 228 ConstantList()->Add(value);
229 } 229 }
230 230
231 Type type() const { return TypeField::decode(value_); } 231 Type type() const { return TypeField::decode(value_); }
232 void set_type(Type type) { 232 void set_type(Type type) {
233 value_ = value_ & ~TypeField::mask(); 233 value_ = value_ & ~TypeField::mask();
234 value_ = value_ | TypeField::encode(type); 234 value_ = value_ | TypeField::encode(type);
235 } 235 }
236 236
237 void set_index(int new_index) { 237 void set_index(int new_index) {
238 ASSERT(is_copy()); 238 ASSERT(is_copy());
239 value_ = value_ & ~DataField::mask(); 239 value_ = value_ & ~DataField::mask();
240 value_ = value_ | DataField::encode(new_index); 240 value_ = value_ | DataField::encode(new_index);
241 } 241 }
242 242
243 void set_reg(Register new_reg) { 243 void set_reg(Register new_reg) {
244 ASSERT(is_register()); 244 ASSERT(is_register());
245 value_ = value_ & ~DataField::mask(); 245 value_ = value_ & ~DataField::mask();
246 value_ = value_ | DataField::encode(new_reg.code_); 246 value_ = value_ | DataField::encode(new_reg.code_);
247 } 247 }
248 248
249 // Encode type, copied, synced and data in one 32 bit integer. 249 // Encode type, copied, synced and data in one 32 bit integer.
250 uint32_t value_; 250 uint32_t value_;
251 251
252 class TypeField: public BitField<Type, 0, 3> {}; 252 class TypeField: public BitField<Type, 0, 3> {};
253 class CopiedField: public BitField<bool, 3, 1> {}; 253 class CopiedField: public BitField<bool, 3, 1> {};
254 class SyncedField: public BitField<bool, 4, 1> {}; 254 class SyncedField: public BitField<bool, 4, 1> {};
255 class NumberInfoField: public BitField<NumberInfo::Type, 5, 3> {}; 255 class NumberInfoField: public BitField<int, 5, 4> {};
256 class DataField: public BitField<uint32_t, 8, 32 - 8> {}; 256 class DataField: public BitField<uint32_t, 9, 32 - 9> {};
257 257
258 friend class VirtualFrame; 258 friend class VirtualFrame;
259 }; 259 };
260 260
261 } } // namespace v8::internal 261 } } // namespace v8::internal
262 262
263 #endif // V8_FRAME_ELEMENT_H_ 263 #endif // V8_FRAME_ELEMENT_H_
OLDNEW
« no previous file with comments | « no previous file | src/ia32/codegen-ia32.h » ('j') | src/ia32/codegen-ia32.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698