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

Side by Side Diff: src/register-allocator-ia32.h

Issue 13746: Experimental: thread live register references to deferred code.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/toiger/
Patch Set: '' Created 12 years 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
OLDNEW
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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 61
62 // Record that a register will no longer be used by decrementing its 62 // Record that a register will no longer be used by decrementing its
63 // reference count. 63 // reference count.
64 void Unuse(Register reg) { 64 void Unuse(Register reg) {
65 ASSERT(is_used(reg.code())); 65 ASSERT(is_used(reg.code()));
66 if (is_used(reg.code())) { 66 if (is_used(reg.code())) {
67 ref_counts_[reg.code()]--; 67 ref_counts_[reg.code()]--;
68 } 68 }
69 } 69 }
70 70
71 // Copy the reference counts from this register file to the other.
72 void CopyTo(RegisterFile* other);
73
74 #ifdef DEBUG
75 // True if the reference counts all match the other register file.
76 bool Equals(RegisterFile* other);
77 #endif
78
71 static const int kNumRegisters = 8; 79 static const int kNumRegisters = 8;
72 80
73 private: 81 private:
74 int ref_counts_[kNumRegisters]; 82 int ref_counts_[kNumRegisters];
75 }; 83 };
76 84
77 85
78 // ------------------------------------------------------------------------- 86 // -------------------------------------------------------------------------
79 // Register allocator 87 // Register allocator
80 // 88 //
81 89
82 class RegisterAllocator BASE_EMBEDDED { 90 class RegisterAllocator BASE_EMBEDDED {
83 public: 91 public:
84 RegisterAllocator(CodeGenerator* cgen) : code_generator_(cgen) {} 92 explicit RegisterAllocator(CodeGenerator* cgen) : code_generator_(cgen) {}
85 93
86 int num_registers() const { return RegisterFile::kNumRegisters; } 94 int num_registers() const { return RegisterFile::kNumRegisters; }
87 95
88 int count(int reg_code) { return registers_.count(reg_code); } 96 int count(int reg_code) { return registers_.count(reg_code); }
89 97
90 // Explicitly record a reference to a register. 98 // Explicitly record a reference to a register.
91 void Use(Register reg) { registers_.Use(reg); } 99 void Use(Register reg) { registers_.Use(reg); }
92 100
93 // Explicitly record that a register will no lonber be used. 101 // Explicitly record that a register will no lonber be used.
94 void Unuse(Register reg) { registers_.Unuse(reg); } 102 void Unuse(Register reg) { registers_.Unuse(reg); }
95 103
96 // Initialize the register allocator for entry to a JS function. On 104 // Initialize the register allocator for entry to a JS function. On
97 // entry, esp, ebp, esi, and edi are externally referenced (ie, outside 105 // entry, esp, ebp, esi, and edi are externally referenced (ie, outside
98 // the virtual frame); and the other registers are free. 106 // the virtual frame); and the other registers are free.
99 void Initialize(); 107 void Initialize();
100 108
101 // Allocate a free register if possible or fail by returning no_reg. 109 // Allocate a free register if possible or fail by returning no_reg.
102 Register Allocate(); 110 Register Allocate();
103 111
104 // Allocate a free register without spilling any or fail and return 112 // Allocate a free register without spilling any or fail and return
105 // no_reg. 113 // no_reg.
106 Register AllocateWithoutSpilling(); 114 Register AllocateWithoutSpilling();
107 115
116 // Copy the internal state to a register file, to be restored later
117 // by RestoreFrom.
118 void SaveTo(RegisterFile* register_file) {
119 registers_.CopyTo(register_file);
120 }
121
122 void RestoreFrom(RegisterFile* register_file) {
123 register_file->CopyTo(&registers_);
124 }
125
126 #ifdef DEBUG
127 // True if the reference counts of this allocator match those saved in the
128 // given register file.
129 bool Matches(RegisterFile* register_file) {
130 return registers_.Equals(register_file);
131 }
132 #endif
133
108 private: 134 private:
109 CodeGenerator* code_generator_; 135 CodeGenerator* code_generator_;
110 RegisterFile registers_; 136 RegisterFile registers_;
111 }; 137 };
112 138
113 } } // namespace v8::internal 139 } } // namespace v8::internal
114 140
115 #endif // V8_REGISTER_ALLOCATOR_IA32_H_ 141 #endif // V8_REGISTER_ALLOCATOR_IA32_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698