| OLD | NEW |
| 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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 | 93 |
| 94 CodeGenerator* cgen_; | 94 CodeGenerator* cgen_; |
| 95 }; | 95 }; |
| 96 | 96 |
| 97 | 97 |
| 98 // ------------------------------------------------------------------------- | 98 // ------------------------------------------------------------------------- |
| 99 // Virtual frame elements | 99 // Virtual frame elements |
| 100 // | 100 // |
| 101 // The internal elements of the virtual frames. There are several kinds of | 101 // The internal elements of the virtual frames. There are several kinds of |
| 102 // elements: | 102 // elements: |
| 103 // * Invalid: elements that are uninitialized or not actually part |
| 104 // of the virtual frame. They should not be read. |
| 103 // * Memory: an element that resides in the actual frame. Its address is | 105 // * Memory: an element that resides in the actual frame. Its address is |
| 104 // given by its position in the virtual frame. | 106 // given by its position in the virtual frame. |
| 105 // * Register: an element that resides in a register. | 107 // * Register: an element that resides in a register. |
| 106 // * Constant: an element whose value is known at compile time. | 108 // * Constant: an element whose value is known at compile time. |
| 107 | 109 |
| 108 class FrameElement BASE_EMBEDDED { | 110 class FrameElement BASE_EMBEDDED { |
| 109 public: | 111 public: |
| 110 enum SyncFlag { SYNCED, NOT_SYNCED }; | 112 enum SyncFlag { |
| 113 SYNCED, |
| 114 NOT_SYNCED |
| 115 }; |
| 111 | 116 |
| 112 // Construct an in-memory frame element. | 117 // The default constructor creates an invalid frame element. |
| 113 FrameElement() { | 118 FrameElement() { |
| 114 type_ = TypeField::encode(MEMORY) | SyncField::encode(SYNCED); | 119 type_ = TypeField::encode(INVALID) | SyncField::encode(NOT_SYNCED); |
| 115 // In-memory elements have no useful data. | |
| 116 data_.reg_ = no_reg; | 120 data_.reg_ = no_reg; |
| 117 } | 121 } |
| 118 | 122 |
| 119 // Construct an in-register frame element. | 123 // Factory function to construct an in-memory frame element. |
| 120 FrameElement(Register reg, SyncFlag is_synced) { | 124 static FrameElement MemoryElement() { |
| 121 type_ = TypeField::encode(REGISTER) | SyncField::encode(is_synced); | 125 FrameElement result; |
| 122 data_.reg_ = reg; | 126 result.type_ = TypeField::encode(MEMORY) | SyncField::encode(SYNCED); |
| 127 // In-memory elements have no useful data. |
| 128 result.data_.reg_ = no_reg; |
| 129 return result; |
| 123 } | 130 } |
| 124 | 131 |
| 125 // Construct a frame element whose value is known at compile time. | 132 // Factory function to construct an in-register frame element. |
| 126 FrameElement(Handle<Object> value, SyncFlag is_synced) { | 133 static FrameElement RegisterElement(Register reg, SyncFlag is_synced) { |
| 127 type_ = TypeField::encode(CONSTANT) | SyncField::encode(is_synced); | 134 FrameElement result; |
| 128 data_.handle_ = value.location(); | 135 result.type_ = TypeField::encode(REGISTER) | SyncField::encode(is_synced); |
| 136 result.data_.reg_ = reg; |
| 137 return result; |
| 138 } |
| 139 |
| 140 // Factory function to construct a frame element whose value is known at |
| 141 // compile time. |
| 142 static FrameElement ConstantElement(Handle<Object> value, |
| 143 SyncFlag is_synced) { |
| 144 FrameElement result; |
| 145 result.type_ = TypeField::encode(CONSTANT) | SyncField::encode(is_synced); |
| 146 result.data_.handle_ = value.location(); |
| 147 return result; |
| 129 } | 148 } |
| 130 | 149 |
| 131 bool is_synced() const { return SyncField::decode(type_) == SYNCED; } | 150 bool is_synced() const { return SyncField::decode(type_) == SYNCED; } |
| 132 | 151 |
| 133 void set_sync() { | 152 void set_sync() { |
| 134 ASSERT(type() != MEMORY); | 153 ASSERT(type() != MEMORY); |
| 135 type_ = (type_ & ~SyncField::mask()) | SyncField::encode(SYNCED); | 154 type_ = (type_ & ~SyncField::mask()) | SyncField::encode(SYNCED); |
| 136 } | 155 } |
| 137 | 156 |
| 138 void clear_sync() { | 157 void clear_sync() { |
| 139 ASSERT(type() != MEMORY); | 158 ASSERT(type() != MEMORY); |
| 140 type_ = (type_ & ~SyncField::mask()) | SyncField::encode(NOT_SYNCED); | 159 type_ = (type_ & ~SyncField::mask()) | SyncField::encode(NOT_SYNCED); |
| 141 } | 160 } |
| 142 | 161 |
| 143 bool is_memory() const { return type() == MEMORY; } | 162 bool is_memory() const { return type() == MEMORY; } |
| 144 bool is_register() const { return type() == REGISTER; } | 163 bool is_register() const { return type() == REGISTER; } |
| 145 bool is_constant() const { return type() == CONSTANT; } | 164 bool is_constant() const { return type() == CONSTANT; } |
| 146 | 165 |
| 147 Register reg() const { | 166 Register reg() const { |
| 148 ASSERT(type() == REGISTER); | 167 ASSERT(type() == REGISTER); |
| 149 return data_.reg_; | 168 return data_.reg_; |
| 150 } | 169 } |
| 151 | 170 |
| 152 Handle<Object> handle() const { | 171 Handle<Object> handle() const { |
| 153 ASSERT(type() == CONSTANT); | 172 ASSERT(type() == CONSTANT); |
| 154 return Handle<Object>(data_.handle_); | 173 return Handle<Object>(data_.handle_); |
| 155 } | 174 } |
| 156 | 175 |
| 157 private: | 176 private: |
| 158 enum Type { MEMORY, REGISTER, CONSTANT }; | 177 enum Type { |
| 178 INVALID, |
| 179 MEMORY, |
| 180 REGISTER, |
| 181 CONSTANT |
| 182 }; |
| 159 | 183 |
| 160 // BitField is <type, shift, size>. | 184 // BitField is <type, shift, size>. |
| 161 class SyncField : public BitField<SyncFlag, 0, 1> {}; | 185 class SyncField : public BitField<SyncFlag, 0, 1> {}; |
| 162 class TypeField : public BitField<Type, 1, 32 - 1> {}; | 186 class TypeField : public BitField<Type, 1, 32 - 1> {}; |
| 163 | 187 |
| 164 Type type() const { return TypeField::decode(type_); } | 188 Type type() const { return TypeField::decode(type_); } |
| 165 | 189 |
| 166 // The element's type and a dirty bit. The dirty bit can be cleared | 190 // The element's type and a dirty bit. The dirty bit can be cleared |
| 167 // for non-memory elements to indicate that the element agrees with | 191 // for non-memory elements to indicate that the element agrees with |
| 168 // the value in memory in the actual frame. | 192 // the value in memory in the actual frame. |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 491 // This is because some new memory-to-register moves are | 515 // This is because some new memory-to-register moves are |
| 492 // created in order to break cycles of register moves. | 516 // created in order to break cycles of register moves. |
| 493 // Used in the implementation of MergeTo(). | 517 // Used in the implementation of MergeTo(). |
| 494 void MergeMoveRegistersToRegisters(VirtualFrame *expected); | 518 void MergeMoveRegistersToRegisters(VirtualFrame *expected); |
| 495 }; | 519 }; |
| 496 | 520 |
| 497 | 521 |
| 498 } } // namespace v8::internal | 522 } } // namespace v8::internal |
| 499 | 523 |
| 500 #endif // V8_VIRTUAL_FRAME_IA32_H_ | 524 #endif // V8_VIRTUAL_FRAME_IA32_H_ |
| OLD | NEW |