OLD | NEW |
1 // Copyright 2008 the V8 project authors. All rights reserved. | 1 // Copyright 2008 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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 | 68 |
69 // Construct a Result whose value is a compile-time constant. | 69 // Construct a Result whose value is a compile-time constant. |
70 explicit Result(Handle<Object> value) { | 70 explicit Result(Handle<Object> value) { |
71 value_ = TypeField::encode(CONSTANT) | 71 value_ = TypeField::encode(CONSTANT) |
72 | DataField::encode(ConstantList()->length()); | 72 | DataField::encode(ConstantList()->length()); |
73 ConstantList()->Add(value); | 73 ConstantList()->Add(value); |
74 } | 74 } |
75 | 75 |
76 // The copy constructor and assignment operators could each create a new | 76 // The copy constructor and assignment operators could each create a new |
77 // register reference. | 77 // register reference. |
78 Result(const Result& other) { | 78 inline Result(const Result& other); |
79 other.CopyTo(this); | |
80 } | |
81 | 79 |
82 Result& operator=(const Result& other) { | 80 inline Result& operator=(const Result& other); |
83 if (this != &other) { | |
84 Unuse(); | |
85 other.CopyTo(this); | |
86 } | |
87 return *this; | |
88 } | |
89 | 81 |
90 inline ~Result(); | 82 inline ~Result(); |
91 | 83 |
92 // Static indirection table for handles to constants. If a Result | 84 // Static indirection table for handles to constants. If a Result |
93 // represents a constant, the data contains an index into this table | 85 // represents a constant, the data contains an index into this table |
94 // of handles to the actual constants. | 86 // of handles to the actual constants. |
95 typedef ZoneList<Handle<Object> > ZoneObjectList; | 87 typedef ZoneList<Handle<Object> > ZoneObjectList; |
96 | 88 |
97 static ZoneObjectList* ConstantList(); | 89 static ZoneObjectList* ConstantList(); |
98 | 90 |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 // platform-specific XXX-inl.h files.. | 222 // platform-specific XXX-inl.h files.. |
231 static inline bool IsReserved(Register reg); | 223 static inline bool IsReserved(Register reg); |
232 | 224 |
233 // Convert between (unreserved) assembler registers and allocator | 225 // Convert between (unreserved) assembler registers and allocator |
234 // numbers. Defined in the platform-specific XXX-inl.h files. | 226 // numbers. Defined in the platform-specific XXX-inl.h files. |
235 static inline int ToNumber(Register reg); | 227 static inline int ToNumber(Register reg); |
236 static inline Register ToRegister(int num); | 228 static inline Register ToRegister(int num); |
237 | 229 |
238 // Predicates and accessors for the registers' reference counts. | 230 // Predicates and accessors for the registers' reference counts. |
239 bool is_used(int num) { return registers_.is_used(num); } | 231 bool is_used(int num) { return registers_.is_used(num); } |
240 bool is_used(Register reg) { return registers_.is_used(ToNumber(reg)); } | 232 inline bool is_used(Register reg); |
241 | 233 |
242 int count(int num) { return registers_.count(num); } | 234 int count(int num) { return registers_.count(num); } |
243 int count(Register reg) { return registers_.count(ToNumber(reg)); } | 235 inline int count(Register reg); |
244 | 236 |
245 // Explicitly record a reference to a register. | 237 // Explicitly record a reference to a register. |
246 void Use(int num) { registers_.Use(num); } | 238 void Use(int num) { registers_.Use(num); } |
247 void Use(Register reg) { registers_.Use(ToNumber(reg)); } | 239 inline void Use(Register reg); |
248 | 240 |
249 // Explicitly record that a register will no longer be used. | 241 // Explicitly record that a register will no longer be used. |
250 void Unuse(int num) { registers_.Unuse(num); } | 242 void Unuse(int num) { registers_.Unuse(num); } |
251 void Unuse(Register reg) { registers_.Unuse(ToNumber(reg)); } | 243 inline void Unuse(Register reg); |
252 | 244 |
253 // Reset the register reference counts to free all non-reserved registers. | 245 // Reset the register reference counts to free all non-reserved registers. |
254 void Reset() { registers_.Reset(); } | 246 void Reset() { registers_.Reset(); } |
255 | 247 |
256 // Initialize the register allocator for entry to a JS function. On | 248 // Initialize the register allocator for entry to a JS function. On |
257 // entry, the (non-reserved) registers used by the JS calling | 249 // entry, the (non-reserved) registers used by the JS calling |
258 // convention are referenced and the other (non-reserved) registers | 250 // convention are referenced and the other (non-reserved) registers |
259 // are free. | 251 // are free. |
260 inline void Initialize(); | 252 inline void Initialize(); |
261 | 253 |
(...skipping 26 matching lines...) Expand all Loading... |
288 } | 280 } |
289 | 281 |
290 private: | 282 private: |
291 CodeGenerator* cgen_; | 283 CodeGenerator* cgen_; |
292 RegisterFile registers_; | 284 RegisterFile registers_; |
293 }; | 285 }; |
294 | 286 |
295 } } // namespace v8::internal | 287 } } // namespace v8::internal |
296 | 288 |
297 #endif // V8_REGISTER_ALLOCATOR_H_ | 289 #endif // V8_REGISTER_ALLOCATOR_H_ |
OLD | NEW |