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

Side by Side Diff: src/lithium.h

Issue 9860028: Valgrind cleanliness, part 2: Delete lithium operand caches on exit. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 8 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/lithium.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 17 matching lines...) Expand all
28 #ifndef V8_LITHIUM_H_ 28 #ifndef V8_LITHIUM_H_
29 #define V8_LITHIUM_H_ 29 #define V8_LITHIUM_H_
30 30
31 #include "allocation.h" 31 #include "allocation.h"
32 #include "hydrogen.h" 32 #include "hydrogen.h"
33 #include "safepoint-table.h" 33 #include "safepoint-table.h"
34 34
35 namespace v8 { 35 namespace v8 {
36 namespace internal { 36 namespace internal {
37 37
38 #define LITHIUM_OPERAND_LIST(V) \
39 V(LConstantOperand, CONSTANT_OPERAND) \
40 V(LStackSlot, STACK_SLOT) \
41 V(LDoubleStackSlot, DOUBLE_STACK_SLOT) \
42 V(LRegister, REGISTER) \
43 V(LDoubleRegister, DOUBLE_REGISTER)
44
45
38 class LOperand: public ZoneObject { 46 class LOperand: public ZoneObject {
39 public: 47 public:
40 enum Kind { 48 enum Kind {
41 INVALID, 49 INVALID,
42 UNALLOCATED, 50 UNALLOCATED,
43 CONSTANT_OPERAND, 51 CONSTANT_OPERAND,
44 STACK_SLOT, 52 STACK_SLOT,
45 DOUBLE_STACK_SLOT, 53 DOUBLE_STACK_SLOT,
46 REGISTER, 54 REGISTER,
47 DOUBLE_REGISTER, 55 DOUBLE_REGISTER,
48 ARGUMENT 56 ARGUMENT
49 }; 57 };
50 58
51 LOperand() : value_(KindField::encode(INVALID)) { } 59 LOperand() : value_(KindField::encode(INVALID)) { }
52 60
53 Kind kind() const { return KindField::decode(value_); } 61 Kind kind() const { return KindField::decode(value_); }
54 int index() const { return static_cast<int>(value_) >> kKindFieldWidth; } 62 int index() const { return static_cast<int>(value_) >> kKindFieldWidth; }
55 bool IsConstantOperand() const { return kind() == CONSTANT_OPERAND; } 63 bool IsConstantOperand() const { return kind() == CONSTANT_OPERAND; }
56 bool IsStackSlot() const { return kind() == STACK_SLOT; } 64 bool IsStackSlot() const { return kind() == STACK_SLOT; }
Erik Corry 2012/03/28 12:24:16 You could use your shiny new 2nd order macro here
Sven Panne 2012/03/28 13:11:11 Done.
57 bool IsDoubleStackSlot() const { return kind() == DOUBLE_STACK_SLOT; } 65 bool IsDoubleStackSlot() const { return kind() == DOUBLE_STACK_SLOT; }
58 bool IsRegister() const { return kind() == REGISTER; } 66 bool IsRegister() const { return kind() == REGISTER; }
59 bool IsDoubleRegister() const { return kind() == DOUBLE_REGISTER; } 67 bool IsDoubleRegister() const { return kind() == DOUBLE_REGISTER; }
60 bool IsArgument() const { return kind() == ARGUMENT; } 68 bool IsArgument() const { return kind() == ARGUMENT; }
61 bool IsUnallocated() const { return kind() == UNALLOCATED; } 69 bool IsUnallocated() const { return kind() == UNALLOCATED; }
62 bool IsIgnored() const { return kind() == INVALID; } 70 bool IsIgnored() const { return kind() == INVALID; }
63 bool Equals(LOperand* other) const { return value_ == other->value_; } 71 bool Equals(LOperand* other) const { return value_ == other->value_; }
64 72
65 void PrintTo(StringStream* stream); 73 void PrintTo(StringStream* stream);
66 void ConvertTo(Kind kind, int index) { 74 void ConvertTo(Kind kind, int index) {
67 value_ = KindField::encode(kind); 75 value_ = KindField::encode(kind);
68 value_ |= index << kKindFieldWidth; 76 value_ |= index << kKindFieldWidth;
69 ASSERT(this->index() == index); 77 ASSERT(this->index() == index);
70 } 78 }
71 79
72 // Calls SetUpCache() for each subclass. Don't forget to update this method 80 // Calls SetUpCache()/TearDownCache() for each subclass.
73 // if you add a new LOperand subclass.
74 static void SetUpCaches(); 81 static void SetUpCaches();
82 static void TearDownCaches();
75 83
76 protected: 84 protected:
77 static const int kKindFieldWidth = 3; 85 static const int kKindFieldWidth = 3;
78 class KindField : public BitField<Kind, 0, kKindFieldWidth> { }; 86 class KindField : public BitField<Kind, 0, kKindFieldWidth> { };
79 87
80 LOperand(Kind kind, int index) { ConvertTo(kind, index); } 88 LOperand(Kind kind, int index) { ConvertTo(kind, index); }
81 89
82 unsigned value_; 90 unsigned value_;
83 }; 91 };
84 92
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 if (index < kNumCachedOperands) return &cache[index]; 266 if (index < kNumCachedOperands) return &cache[index];
259 return new LConstantOperand(index); 267 return new LConstantOperand(index);
260 } 268 }
261 269
262 static LConstantOperand* cast(LOperand* op) { 270 static LConstantOperand* cast(LOperand* op) {
263 ASSERT(op->IsConstantOperand()); 271 ASSERT(op->IsConstantOperand());
264 return reinterpret_cast<LConstantOperand*>(op); 272 return reinterpret_cast<LConstantOperand*>(op);
265 } 273 }
266 274
267 static void SetUpCache(); 275 static void SetUpCache();
276 static void TearDownCache();
268 277
269 private: 278 private:
270 static const int kNumCachedOperands = 128; 279 static const int kNumCachedOperands = 128;
271 static LConstantOperand* cache; 280 static LConstantOperand* cache;
272 281
273 LConstantOperand() : LOperand() { } 282 LConstantOperand() : LOperand() { }
274 explicit LConstantOperand(int index) : LOperand(CONSTANT_OPERAND, index) { } 283 explicit LConstantOperand(int index) : LOperand(CONSTANT_OPERAND, index) { }
275 }; 284 };
276 285
277 286
(...skipping 15 matching lines...) Expand all
293 if (index < kNumCachedOperands) return &cache[index]; 302 if (index < kNumCachedOperands) return &cache[index];
294 return new LStackSlot(index); 303 return new LStackSlot(index);
295 } 304 }
296 305
297 static LStackSlot* cast(LOperand* op) { 306 static LStackSlot* cast(LOperand* op) {
298 ASSERT(op->IsStackSlot()); 307 ASSERT(op->IsStackSlot());
299 return reinterpret_cast<LStackSlot*>(op); 308 return reinterpret_cast<LStackSlot*>(op);
300 } 309 }
301 310
302 static void SetUpCache(); 311 static void SetUpCache();
312 static void TearDownCache();
303 313
304 private: 314 private:
305 static const int kNumCachedOperands = 128; 315 static const int kNumCachedOperands = 128;
306 static LStackSlot* cache; 316 static LStackSlot* cache;
307 317
308 LStackSlot() : LOperand() { } 318 LStackSlot() : LOperand() { }
309 explicit LStackSlot(int index) : LOperand(STACK_SLOT, index) { } 319 explicit LStackSlot(int index) : LOperand(STACK_SLOT, index) { }
310 }; 320 };
311 321
312 322
313 class LDoubleStackSlot: public LOperand { 323 class LDoubleStackSlot: public LOperand {
314 public: 324 public:
315 static LDoubleStackSlot* Create(int index) { 325 static LDoubleStackSlot* Create(int index) {
316 ASSERT(index >= 0); 326 ASSERT(index >= 0);
317 if (index < kNumCachedOperands) return &cache[index]; 327 if (index < kNumCachedOperands) return &cache[index];
318 return new LDoubleStackSlot(index); 328 return new LDoubleStackSlot(index);
319 } 329 }
320 330
321 static LDoubleStackSlot* cast(LOperand* op) { 331 static LDoubleStackSlot* cast(LOperand* op) {
322 ASSERT(op->IsStackSlot()); 332 ASSERT(op->IsStackSlot());
323 return reinterpret_cast<LDoubleStackSlot*>(op); 333 return reinterpret_cast<LDoubleStackSlot*>(op);
324 } 334 }
325 335
326 static void SetUpCache(); 336 static void SetUpCache();
337 static void TearDownCache();
327 338
328 private: 339 private:
329 static const int kNumCachedOperands = 128; 340 static const int kNumCachedOperands = 128;
330 static LDoubleStackSlot* cache; 341 static LDoubleStackSlot* cache;
331 342
332 LDoubleStackSlot() : LOperand() { } 343 LDoubleStackSlot() : LOperand() { }
333 explicit LDoubleStackSlot(int index) : LOperand(DOUBLE_STACK_SLOT, index) { } 344 explicit LDoubleStackSlot(int index) : LOperand(DOUBLE_STACK_SLOT, index) { }
334 }; 345 };
335 346
336 347
337 class LRegister: public LOperand { 348 class LRegister: public LOperand {
338 public: 349 public:
339 static LRegister* Create(int index) { 350 static LRegister* Create(int index) {
340 ASSERT(index >= 0); 351 ASSERT(index >= 0);
341 if (index < kNumCachedOperands) return &cache[index]; 352 if (index < kNumCachedOperands) return &cache[index];
342 return new LRegister(index); 353 return new LRegister(index);
343 } 354 }
344 355
345 static LRegister* cast(LOperand* op) { 356 static LRegister* cast(LOperand* op) {
346 ASSERT(op->IsRegister()); 357 ASSERT(op->IsRegister());
347 return reinterpret_cast<LRegister*>(op); 358 return reinterpret_cast<LRegister*>(op);
348 } 359 }
349 360
350 static void SetUpCache(); 361 static void SetUpCache();
362 static void TearDownCache();
351 363
352 private: 364 private:
353 static const int kNumCachedOperands = 16; 365 static const int kNumCachedOperands = 16;
354 static LRegister* cache; 366 static LRegister* cache;
355 367
356 LRegister() : LOperand() { } 368 LRegister() : LOperand() { }
357 explicit LRegister(int index) : LOperand(REGISTER, index) { } 369 explicit LRegister(int index) : LOperand(REGISTER, index) { }
358 }; 370 };
359 371
360 372
361 class LDoubleRegister: public LOperand { 373 class LDoubleRegister: public LOperand {
362 public: 374 public:
363 static LDoubleRegister* Create(int index) { 375 static LDoubleRegister* Create(int index) {
364 ASSERT(index >= 0); 376 ASSERT(index >= 0);
365 if (index < kNumCachedOperands) return &cache[index]; 377 if (index < kNumCachedOperands) return &cache[index];
366 return new LDoubleRegister(index); 378 return new LDoubleRegister(index);
367 } 379 }
368 380
369 static LDoubleRegister* cast(LOperand* op) { 381 static LDoubleRegister* cast(LOperand* op) {
370 ASSERT(op->IsDoubleRegister()); 382 ASSERT(op->IsDoubleRegister());
371 return reinterpret_cast<LDoubleRegister*>(op); 383 return reinterpret_cast<LDoubleRegister*>(op);
372 } 384 }
373 385
374 static void SetUpCache(); 386 static void SetUpCache();
387 static void TearDownCache();
375 388
376 private: 389 private:
377 static const int kNumCachedOperands = 16; 390 static const int kNumCachedOperands = 16;
378 static LDoubleRegister* cache; 391 static LDoubleRegister* cache;
379 392
380 LDoubleRegister() : LOperand() { } 393 LDoubleRegister() : LOperand() { }
381 explicit LDoubleRegister(int index) : LOperand(DOUBLE_REGISTER, index) { } 394 explicit LDoubleRegister(int index) : LOperand(DOUBLE_REGISTER, index) { }
382 }; 395 };
383 396
384 397
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
603 ShallowIterator current_iterator_; 616 ShallowIterator current_iterator_;
604 }; 617 };
605 618
606 619
607 int ElementsKindToShiftSize(ElementsKind elements_kind); 620 int ElementsKindToShiftSize(ElementsKind elements_kind);
608 621
609 622
610 } } // namespace v8::internal 623 } } // namespace v8::internal
611 624
612 #endif // V8_LITHIUM_H_ 625 #endif // V8_LITHIUM_H_
OLDNEW
« no previous file with comments | « no previous file | src/lithium.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698