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

Side by Side Diff: runtime/vm/locations.h

Issue 868283002: Fix LoadOptimizer's handling of load/stores with constant indices for TypedData. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 10 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 | « runtime/vm/flow_graph_optimizer.cc ('k') | tests/language/language.status » ('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 (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #ifndef VM_LOCATIONS_H_ 5 #ifndef VM_LOCATIONS_H_
6 #define VM_LOCATIONS_H_ 6 #define VM_LOCATIONS_H_
7 7
8 #include "vm/allocation.h" 8 #include "vm/allocation.h"
9 #include "vm/assembler.h" 9 #include "vm/assembler.h"
10 #include "vm/bitfield.h" 10 #include "vm/bitfield.h"
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 ASSERT(i < kPairLength); 438 ASSERT(i < kPairLength);
439 return &locations_[i]; 439 return &locations_[i];
440 } 440 }
441 441
442 private: 442 private:
443 static const intptr_t kPairLength = 2; 443 static const intptr_t kPairLength = 2;
444 Location locations_[kPairLength]; 444 Location locations_[kPairLength];
445 }; 445 };
446 446
447 447
448 template<typename T>
449 class SmallSet {
450 public:
451 SmallSet() : data_(0) { }
452
453 explicit SmallSet(intptr_t data) : data_(data) { }
454
455 bool Contains(T value) const { return (data_ & ToMask(value)) != 0; }
456
457 void Add(T value) { data_ |= ToMask(value); }
458
459 void Remove(T value) { data_ &= ~ToMask(value); }
460
461 intptr_t data() const { return data_; }
462
463 private:
464 static intptr_t ToMask(T value) {
465 ASSERT(static_cast<intptr_t>(value) < (kWordSize * kBitsPerByte));
466 return 1 << static_cast<intptr_t>(value);
467 }
468
469 intptr_t data_;
470 };
471
472
448 class RegisterSet : public ValueObject { 473 class RegisterSet : public ValueObject {
449 public: 474 public:
450 RegisterSet() : cpu_registers_(0), untagged_cpu_registers_(0), 475 RegisterSet()
451 fpu_registers_(0) { 476 : cpu_registers_(),
477 untagged_cpu_registers_(),
478 fpu_registers_() {
452 ASSERT(kNumberOfCpuRegisters <= (kWordSize * kBitsPerByte)); 479 ASSERT(kNumberOfCpuRegisters <= (kWordSize * kBitsPerByte));
453 ASSERT(kNumberOfFpuRegisters <= (kWordSize * kBitsPerByte)); 480 ASSERT(kNumberOfFpuRegisters <= (kWordSize * kBitsPerByte));
454 } 481 }
455 482
456 483
457 void Add(Location loc, Representation rep = kTagged) { 484 void Add(Location loc, Representation rep = kTagged) {
458 if (loc.IsRegister()) { 485 if (loc.IsRegister()) {
459 cpu_registers_ |= (1 << loc.reg()); 486 cpu_registers_.Add(loc.reg());
460 if (rep != kTagged) { 487 if (rep != kTagged) {
461 // CPU register contains an untagged value. 488 // CPU register contains an untagged value.
462 MarkUntagged(loc); 489 MarkUntagged(loc);
463 } 490 }
464 } else if (loc.IsFpuRegister()) { 491 } else if (loc.IsFpuRegister()) {
465 fpu_registers_ |= (1 << loc.fpu_reg()); 492 fpu_registers_.Add(loc.fpu_reg());
466 } 493 }
467 } 494 }
468 495
469 void Remove(Location loc) { 496 void Remove(Location loc) {
470 if (loc.IsRegister()) { 497 if (loc.IsRegister()) {
471 cpu_registers_ &= ~(1 << loc.reg()); 498 cpu_registers_.Remove(loc.reg());
472 } else if (loc.IsFpuRegister()) { 499 } else if (loc.IsFpuRegister()) {
473 fpu_registers_ &= ~(1 << loc.fpu_reg()); 500 fpu_registers_.Remove(loc.fpu_reg());
474 } 501 }
475 } 502 }
476 503
477 bool Contains(Location loc) { 504 bool Contains(Location loc) {
478 if (loc.IsRegister()) { 505 if (loc.IsRegister()) {
479 return ContainsRegister(loc.reg()); 506 return ContainsRegister(loc.reg());
480 } else if (loc.IsFpuRegister()) { 507 } else if (loc.IsFpuRegister()) {
481 return ContainsFpuRegister(loc.fpu_reg()); 508 return ContainsFpuRegister(loc.fpu_reg());
482 } else { 509 } else {
483 UNREACHABLE(); 510 UNREACHABLE();
(...skipping 13 matching lines...) Expand all
497 for (intptr_t i = 0; i < kNumberOfFpuRegisters; i++) { 524 for (intptr_t i = 0; i < kNumberOfFpuRegisters; i++) {
498 FpuRegister r = static_cast<FpuRegister>(i); 525 FpuRegister r = static_cast<FpuRegister>(i);
499 if (ContainsFpuRegister(r)) { 526 if (ContainsFpuRegister(r)) {
500 OS::Print("%s\n", Assembler::FpuRegisterName(r)); 527 OS::Print("%s\n", Assembler::FpuRegisterName(r));
501 } 528 }
502 } 529 }
503 } 530 }
504 531
505 void MarkUntagged(Location loc) { 532 void MarkUntagged(Location loc) {
506 ASSERT(loc.IsRegister()); 533 ASSERT(loc.IsRegister());
507 untagged_cpu_registers_ |= (1 << loc.reg()); 534 untagged_cpu_registers_.Add(loc.reg());
508 } 535 }
509 536
510 bool IsTagged(Register reg) const { 537 bool IsTagged(Register reg) const {
511 return (untagged_cpu_registers_ & (1 << reg)) == 0; 538 return !untagged_cpu_registers_.Contains(reg);
512 } 539 }
513 540
514 bool ContainsRegister(Register reg) const { 541 bool ContainsRegister(Register reg) const {
515 return Contains(cpu_registers_, reg); 542 return cpu_registers_.Contains(reg);
516 } 543 }
517 544
518 bool ContainsFpuRegister(FpuRegister fpu_reg) const { 545 bool ContainsFpuRegister(FpuRegister fpu_reg) const {
519 return Contains(fpu_registers_, fpu_reg); 546 return fpu_registers_.Contains(fpu_reg);
520 } 547 }
521 548
522 intptr_t CpuRegisterCount() const { return RegisterCount(cpu_registers_); } 549 intptr_t CpuRegisterCount() const { return RegisterCount(cpu_registers()); }
523 intptr_t FpuRegisterCount() const { return RegisterCount(fpu_registers_); } 550 intptr_t FpuRegisterCount() const { return RegisterCount(fpu_registers()); }
524 551
525 static intptr_t RegisterCount(intptr_t registers); 552 static intptr_t RegisterCount(intptr_t registers);
526 static bool Contains(intptr_t register_set, intptr_t reg) { 553 static bool Contains(intptr_t register_set, intptr_t reg) {
527 return (register_set & (1 << reg)) != 0; 554 return (register_set & (1 << reg)) != 0;
528 } 555 }
529 556
530 intptr_t cpu_registers() const { return cpu_registers_; } 557 intptr_t cpu_registers() const { return cpu_registers_.data(); }
531 intptr_t fpu_registers() const { return fpu_registers_; } 558 intptr_t fpu_registers() const { return fpu_registers_.data(); }
532 559
533 private: 560 private:
534 intptr_t cpu_registers_; 561 SmallSet<Register> cpu_registers_;
535 intptr_t untagged_cpu_registers_; 562 SmallSet<Register> untagged_cpu_registers_;
536 intptr_t fpu_registers_; 563 SmallSet<FpuRegister> fpu_registers_;
537 564
538 DISALLOW_COPY_AND_ASSIGN(RegisterSet); 565 DISALLOW_COPY_AND_ASSIGN(RegisterSet);
539 }; 566 };
540 567
541 568
542 // Specification of locations for inputs and output. 569 // Specification of locations for inputs and output.
543 class LocationSummary : public ZoneAllocated { 570 class LocationSummary : public ZoneAllocated {
544 public: 571 public:
545 enum ContainsCall { 572 enum ContainsCall {
546 kNoCall, 573 kNoCall,
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
675 702
676 #if defined(DEBUG) 703 #if defined(DEBUG)
677 intptr_t writable_inputs_; 704 intptr_t writable_inputs_;
678 #endif 705 #endif
679 }; 706 };
680 707
681 708
682 } // namespace dart 709 } // namespace dart
683 710
684 #endif // VM_LOCATIONS_H_ 711 #endif // VM_LOCATIONS_H_
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_optimizer.cc ('k') | tests/language/language.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698