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

Side by Side Diff: src/lithium.h

Issue 9455088: Remove static initializers in v8. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address Florian's comments. Created 8 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 | « src/isolate.cc ('k') | 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 bool IsIgnored() const { return kind() == INVALID; } 62 bool IsIgnored() const { return kind() == INVALID; }
63 bool Equals(LOperand* other) const { return value_ == other->value_; } 63 bool Equals(LOperand* other) const { return value_ == other->value_; }
64 64
65 void PrintTo(StringStream* stream); 65 void PrintTo(StringStream* stream);
66 void ConvertTo(Kind kind, int index) { 66 void ConvertTo(Kind kind, int index) {
67 value_ = KindField::encode(kind); 67 value_ = KindField::encode(kind);
68 value_ |= index << kKindFieldWidth; 68 value_ |= index << kKindFieldWidth;
69 ASSERT(this->index() == index); 69 ASSERT(this->index() == index);
70 } 70 }
71 71
72 // Calls SetUpCache() for each subclass. Don't forget to update this method
73 // if you add a new LOperand subclass.
74 static void SetUpCaches();
75
72 protected: 76 protected:
73 static const int kKindFieldWidth = 3; 77 static const int kKindFieldWidth = 3;
74 class KindField : public BitField<Kind, 0, kKindFieldWidth> { }; 78 class KindField : public BitField<Kind, 0, kKindFieldWidth> { };
75 79
76 LOperand(Kind kind, int index) { ConvertTo(kind, index); } 80 LOperand(Kind kind, int index) { ConvertTo(kind, index); }
77 81
78 unsigned value_; 82 unsigned value_;
79 }; 83 };
80 84
81 85
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 261
258 static LConstantOperand* cast(LOperand* op) { 262 static LConstantOperand* cast(LOperand* op) {
259 ASSERT(op->IsConstantOperand()); 263 ASSERT(op->IsConstantOperand());
260 return reinterpret_cast<LConstantOperand*>(op); 264 return reinterpret_cast<LConstantOperand*>(op);
261 } 265 }
262 266
263 static void SetUpCache(); 267 static void SetUpCache();
264 268
265 private: 269 private:
266 static const int kNumCachedOperands = 128; 270 static const int kNumCachedOperands = 128;
267 static LConstantOperand cache[]; 271 static LConstantOperand* cache;
268 272
269 LConstantOperand() : LOperand() { } 273 LConstantOperand() : LOperand() { }
270 explicit LConstantOperand(int index) : LOperand(CONSTANT_OPERAND, index) { } 274 explicit LConstantOperand(int index) : LOperand(CONSTANT_OPERAND, index) { }
271 }; 275 };
272 276
273 277
274 class LArgument: public LOperand { 278 class LArgument: public LOperand {
275 public: 279 public:
276 explicit LArgument(int index) : LOperand(ARGUMENT, index) { } 280 explicit LArgument(int index) : LOperand(ARGUMENT, index) { }
277 281
(...skipping 14 matching lines...) Expand all
292 296
293 static LStackSlot* cast(LOperand* op) { 297 static LStackSlot* cast(LOperand* op) {
294 ASSERT(op->IsStackSlot()); 298 ASSERT(op->IsStackSlot());
295 return reinterpret_cast<LStackSlot*>(op); 299 return reinterpret_cast<LStackSlot*>(op);
296 } 300 }
297 301
298 static void SetUpCache(); 302 static void SetUpCache();
299 303
300 private: 304 private:
301 static const int kNumCachedOperands = 128; 305 static const int kNumCachedOperands = 128;
302 static LStackSlot cache[]; 306 static LStackSlot* cache;
303 307
304 LStackSlot() : LOperand() { } 308 LStackSlot() : LOperand() { }
305 explicit LStackSlot(int index) : LOperand(STACK_SLOT, index) { } 309 explicit LStackSlot(int index) : LOperand(STACK_SLOT, index) { }
306 }; 310 };
307 311
308 312
309 class LDoubleStackSlot: public LOperand { 313 class LDoubleStackSlot: public LOperand {
310 public: 314 public:
311 static LDoubleStackSlot* Create(int index) { 315 static LDoubleStackSlot* Create(int index) {
312 ASSERT(index >= 0); 316 ASSERT(index >= 0);
313 if (index < kNumCachedOperands) return &cache[index]; 317 if (index < kNumCachedOperands) return &cache[index];
314 return new LDoubleStackSlot(index); 318 return new LDoubleStackSlot(index);
315 } 319 }
316 320
317 static LDoubleStackSlot* cast(LOperand* op) { 321 static LDoubleStackSlot* cast(LOperand* op) {
318 ASSERT(op->IsStackSlot()); 322 ASSERT(op->IsStackSlot());
319 return reinterpret_cast<LDoubleStackSlot*>(op); 323 return reinterpret_cast<LDoubleStackSlot*>(op);
320 } 324 }
321 325
322 static void SetUpCache(); 326 static void SetUpCache();
323 327
324 private: 328 private:
325 static const int kNumCachedOperands = 128; 329 static const int kNumCachedOperands = 128;
326 static LDoubleStackSlot cache[]; 330 static LDoubleStackSlot* cache;
327 331
328 LDoubleStackSlot() : LOperand() { } 332 LDoubleStackSlot() : LOperand() { }
329 explicit LDoubleStackSlot(int index) : LOperand(DOUBLE_STACK_SLOT, index) { } 333 explicit LDoubleStackSlot(int index) : LOperand(DOUBLE_STACK_SLOT, index) { }
330 }; 334 };
331 335
332 336
333 class LRegister: public LOperand { 337 class LRegister: public LOperand {
334 public: 338 public:
335 static LRegister* Create(int index) { 339 static LRegister* Create(int index) {
336 ASSERT(index >= 0); 340 ASSERT(index >= 0);
337 if (index < kNumCachedOperands) return &cache[index]; 341 if (index < kNumCachedOperands) return &cache[index];
338 return new LRegister(index); 342 return new LRegister(index);
339 } 343 }
340 344
341 static LRegister* cast(LOperand* op) { 345 static LRegister* cast(LOperand* op) {
342 ASSERT(op->IsRegister()); 346 ASSERT(op->IsRegister());
343 return reinterpret_cast<LRegister*>(op); 347 return reinterpret_cast<LRegister*>(op);
344 } 348 }
345 349
346 static void SetUpCache(); 350 static void SetUpCache();
347 351
348 private: 352 private:
349 static const int kNumCachedOperands = 16; 353 static const int kNumCachedOperands = 16;
350 static LRegister cache[]; 354 static LRegister* cache;
351 355
352 LRegister() : LOperand() { } 356 LRegister() : LOperand() { }
353 explicit LRegister(int index) : LOperand(REGISTER, index) { } 357 explicit LRegister(int index) : LOperand(REGISTER, index) { }
354 }; 358 };
355 359
356 360
357 class LDoubleRegister: public LOperand { 361 class LDoubleRegister: public LOperand {
358 public: 362 public:
359 static LDoubleRegister* Create(int index) { 363 static LDoubleRegister* Create(int index) {
360 ASSERT(index >= 0); 364 ASSERT(index >= 0);
361 if (index < kNumCachedOperands) return &cache[index]; 365 if (index < kNumCachedOperands) return &cache[index];
362 return new LDoubleRegister(index); 366 return new LDoubleRegister(index);
363 } 367 }
364 368
365 static LDoubleRegister* cast(LOperand* op) { 369 static LDoubleRegister* cast(LOperand* op) {
366 ASSERT(op->IsDoubleRegister()); 370 ASSERT(op->IsDoubleRegister());
367 return reinterpret_cast<LDoubleRegister*>(op); 371 return reinterpret_cast<LDoubleRegister*>(op);
368 } 372 }
369 373
370 static void SetUpCache(); 374 static void SetUpCache();
371 375
372 private: 376 private:
373 static const int kNumCachedOperands = 16; 377 static const int kNumCachedOperands = 16;
374 static LDoubleRegister cache[]; 378 static LDoubleRegister* cache;
375 379
376 LDoubleRegister() : LOperand() { } 380 LDoubleRegister() : LOperand() { }
377 explicit LDoubleRegister(int index) : LOperand(DOUBLE_REGISTER, index) { } 381 explicit LDoubleRegister(int index) : LOperand(DOUBLE_REGISTER, index) { }
378 }; 382 };
379 383
380 384
381 class LParallelMove : public ZoneObject { 385 class LParallelMove : public ZoneObject {
382 public: 386 public:
383 LParallelMove() : move_operands_(4) { } 387 LParallelMove() : move_operands_(4) { }
384 388
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
599 ShallowIterator current_iterator_; 603 ShallowIterator current_iterator_;
600 }; 604 };
601 605
602 606
603 int ElementsKindToShiftSize(ElementsKind elements_kind); 607 int ElementsKindToShiftSize(ElementsKind elements_kind);
604 608
605 609
606 } } // namespace v8::internal 610 } } // namespace v8::internal
607 611
608 #endif // V8_LITHIUM_H_ 612 #endif // V8_LITHIUM_H_
OLDNEW
« no previous file with comments | « src/isolate.cc ('k') | src/lithium.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698