OLD | NEW |
1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 | 100 |
101 | 101 |
102 Result RegisterAllocator::Allocate(Register target) { | 102 Result RegisterAllocator::Allocate(Register target) { |
103 // If the target is not referenced, it can simply be allocated. | 103 // If the target is not referenced, it can simply be allocated. |
104 if (!is_used(target)) { | 104 if (!is_used(target)) { |
105 return Result(target, cgen_); | 105 return Result(target, cgen_); |
106 } | 106 } |
107 // If the target is only referenced in the frame, it can be spilled and | 107 // If the target is only referenced in the frame, it can be spilled and |
108 // then allocated. | 108 // then allocated. |
109 ASSERT(cgen_->has_valid_frame()); | 109 ASSERT(cgen_->has_valid_frame()); |
110 if (count(target) == cgen_->frame()->register_count(target)) { | 110 if (cgen_->frame()->is_used(target) && count(target) == 1) { |
111 cgen_->frame()->Spill(target); | 111 cgen_->frame()->Spill(target); |
112 ASSERT(!is_used(target)); | 112 ASSERT(!is_used(target)); |
113 return Result(target, cgen_); | 113 return Result(target, cgen_); |
114 } | 114 } |
115 // Otherwise (if it's referenced outside the frame) we cannot allocate it. | 115 // Otherwise (if it's referenced outside the frame) we cannot allocate it. |
116 return Result(cgen_); | 116 return Result(cgen_); |
117 } | 117 } |
118 | 118 |
119 | 119 |
120 } } // namespace v8::internal | 120 } } // namespace v8::internal |
OLD | NEW |