| 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 30 matching lines...) Expand all Loading... |
| 41 #elif V8_TARGET_ARCH_MIPS | 41 #elif V8_TARGET_ARCH_MIPS |
| 42 #include "mips/register-allocator-mips-inl.h" | 42 #include "mips/register-allocator-mips-inl.h" |
| 43 #else | 43 #else |
| 44 #error Unsupported target architecture. | 44 #error Unsupported target architecture. |
| 45 #endif | 45 #endif |
| 46 | 46 |
| 47 | 47 |
| 48 namespace v8 { | 48 namespace v8 { |
| 49 namespace internal { | 49 namespace internal { |
| 50 | 50 |
| 51 Result::Result(const Result& other) { |
| 52 other.CopyTo(this); |
| 53 } |
| 54 |
| 55 |
| 56 Result& Result::operator=(const Result& other) { |
| 57 if (this != &other) { |
| 58 Unuse(); |
| 59 other.CopyTo(this); |
| 60 } |
| 61 return *this; |
| 62 } |
| 63 |
| 64 |
| 51 Result::~Result() { | 65 Result::~Result() { |
| 52 if (is_register()) { | 66 if (is_register()) { |
| 53 CodeGeneratorScope::Current()->allocator()->Unuse(reg()); | 67 CodeGeneratorScope::Current()->allocator()->Unuse(reg()); |
| 54 } | 68 } |
| 55 } | 69 } |
| 56 | 70 |
| 57 | 71 |
| 58 void Result::Unuse() { | 72 void Result::Unuse() { |
| 59 if (is_register()) { | 73 if (is_register()) { |
| 60 CodeGeneratorScope::Current()->allocator()->Unuse(reg()); | 74 CodeGeneratorScope::Current()->allocator()->Unuse(reg()); |
| 61 } | 75 } |
| 62 invalidate(); | 76 invalidate(); |
| 63 } | 77 } |
| 64 | 78 |
| 65 | 79 |
| 66 void Result::CopyTo(Result* destination) const { | 80 void Result::CopyTo(Result* destination) const { |
| 67 destination->value_ = value_; | 81 destination->value_ = value_; |
| 68 if (is_register()) { | 82 if (is_register()) { |
| 69 CodeGeneratorScope::Current()->allocator()->Use(reg()); | 83 CodeGeneratorScope::Current()->allocator()->Use(reg()); |
| 70 } | 84 } |
| 71 } | 85 } |
| 72 | 86 |
| 73 | 87 |
| 88 bool RegisterAllocator::is_used(Register reg) { |
| 89 return registers_.is_used(ToNumber(reg)); |
| 90 } |
| 91 |
| 92 |
| 93 int RegisterAllocator::count(Register reg) { |
| 94 return registers_.count(ToNumber(reg)); |
| 95 } |
| 96 |
| 97 |
| 98 void RegisterAllocator::Use(Register reg) { |
| 99 registers_.Use(ToNumber(reg)); |
| 100 } |
| 101 |
| 102 |
| 103 void RegisterAllocator::Unuse(Register reg) { |
| 104 registers_.Unuse(ToNumber(reg)); |
| 105 } |
| 106 |
| 74 } } // namespace v8::internal | 107 } } // namespace v8::internal |
| 75 | 108 |
| 76 #endif // V8_REGISTER_ALLOCATOR_INL_H_ | 109 #endif // V8_REGISTER_ALLOCATOR_INL_H_ |
| OLD | NEW |