| 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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 | 99 |
| 100 // Factory function to construct a frame element whose value is known at | 100 // Factory function to construct a frame element whose value is known at |
| 101 // compile time. | 101 // compile time. |
| 102 static FrameElement ConstantElement(Handle<Object> value, | 102 static FrameElement ConstantElement(Handle<Object> value, |
| 103 SyncFlag is_synced) { | 103 SyncFlag is_synced) { |
| 104 TypeInfo info = TypeInfo::TypeFromValue(value); | 104 TypeInfo info = TypeInfo::TypeFromValue(value); |
| 105 FrameElement result(value, is_synced, info); | 105 FrameElement result(value, is_synced, info); |
| 106 return result; | 106 return result; |
| 107 } | 107 } |
| 108 | 108 |
| 109 // Static indirection table for handles to constants. If a frame | |
| 110 // element represents a constant, the data contains an index into | |
| 111 // this table of handles to the actual constants. | |
| 112 typedef ZoneList<Handle<Object> > ZoneObjectList; | |
| 113 | |
| 114 static ZoneObjectList* ConstantList(); | |
| 115 | |
| 116 static bool ConstantPoolOverflowed() { | 109 static bool ConstantPoolOverflowed() { |
| 117 return !DataField::is_valid(ConstantList()->length()); | 110 return !DataField::is_valid( |
| 118 } | 111 Isolate::Current()->frame_element_constant_list()->length()); |
| 119 | |
| 120 // Clear the constants indirection table. | |
| 121 static void ClearConstantList() { | |
| 122 ConstantList()->Clear(); | |
| 123 } | 112 } |
| 124 | 113 |
| 125 bool is_synced() const { return SyncedField::decode(value_); } | 114 bool is_synced() const { return SyncedField::decode(value_); } |
| 126 | 115 |
| 127 void set_sync() { | 116 void set_sync() { |
| 128 ASSERT(type() != MEMORY); | 117 ASSERT(type() != MEMORY); |
| 129 value_ = value_ | SyncedField::encode(true); | 118 value_ = value_ | SyncedField::encode(true); |
| 130 } | 119 } |
| 131 | 120 |
| 132 void clear_sync() { | 121 void clear_sync() { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 157 Register reg() const { | 146 Register reg() const { |
| 158 ASSERT(is_register()); | 147 ASSERT(is_register()); |
| 159 uint32_t reg = DataField::decode(value_); | 148 uint32_t reg = DataField::decode(value_); |
| 160 Register result; | 149 Register result; |
| 161 result.code_ = reg; | 150 result.code_ = reg; |
| 162 return result; | 151 return result; |
| 163 } | 152 } |
| 164 | 153 |
| 165 Handle<Object> handle() const { | 154 Handle<Object> handle() const { |
| 166 ASSERT(is_constant()); | 155 ASSERT(is_constant()); |
| 167 return ConstantList()->at(DataField::decode(value_)); | 156 return Isolate::Current()->frame_element_constant_list()-> |
| 157 at(DataField::decode(value_)); |
| 168 } | 158 } |
| 169 | 159 |
| 170 int index() const { | 160 int index() const { |
| 171 ASSERT(is_copy()); | 161 ASSERT(is_copy()); |
| 172 return DataField::decode(value_); | 162 return DataField::decode(value_); |
| 173 } | 163 } |
| 174 | 164 |
| 175 bool Equals(FrameElement other) { | 165 bool Equals(FrameElement other) { |
| 176 uint32_t masked_difference = (value_ ^ other.value_) & ~CopiedField::mask(); | 166 uint32_t masked_difference = (value_ ^ other.value_) & ~CopiedField::mask(); |
| 177 if (!masked_difference) { | 167 if (!masked_difference) { |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 TypeInfo info) { | 215 TypeInfo info) { |
| 226 value_ = TypeField::encode(type) | 216 value_ = TypeField::encode(type) |
| 227 | CopiedField::encode(false) | 217 | CopiedField::encode(false) |
| 228 | SyncedField::encode(is_synced != NOT_SYNCED) | 218 | SyncedField::encode(is_synced != NOT_SYNCED) |
| 229 | TypeInfoField::encode(info.ToInt()) | 219 | TypeInfoField::encode(info.ToInt()) |
| 230 | DataField::encode(reg.code_ > 0 ? reg.code_ : 0); | 220 | DataField::encode(reg.code_ > 0 ? reg.code_ : 0); |
| 231 } | 221 } |
| 232 | 222 |
| 233 // Used to construct constant elements. | 223 // Used to construct constant elements. |
| 234 FrameElement(Handle<Object> value, SyncFlag is_synced, TypeInfo info) { | 224 FrameElement(Handle<Object> value, SyncFlag is_synced, TypeInfo info) { |
| 225 ZoneObjectList* constant_list = |
| 226 Isolate::Current()->frame_element_constant_list(); |
| 235 value_ = TypeField::encode(CONSTANT) | 227 value_ = TypeField::encode(CONSTANT) |
| 236 | CopiedField::encode(false) | 228 | CopiedField::encode(false) |
| 237 | SyncedField::encode(is_synced != NOT_SYNCED) | 229 | SyncedField::encode(is_synced != NOT_SYNCED) |
| 238 | TypeInfoField::encode(info.ToInt()) | 230 | TypeInfoField::encode(info.ToInt()) |
| 239 | DataField::encode(ConstantList()->length()); | 231 | DataField::encode(constant_list->length()); |
| 240 ConstantList()->Add(value); | 232 constant_list->Add(value); |
| 241 } | 233 } |
| 242 | 234 |
| 243 Type type() const { return TypeField::decode(value_); } | 235 Type type() const { return TypeField::decode(value_); } |
| 244 void set_type(Type type) { | 236 void set_type(Type type) { |
| 245 value_ = value_ & ~TypeField::mask(); | 237 value_ = value_ & ~TypeField::mask(); |
| 246 value_ = value_ | TypeField::encode(type); | 238 value_ = value_ | TypeField::encode(type); |
| 247 } | 239 } |
| 248 | 240 |
| 249 void set_index(int new_index) { | 241 void set_index(int new_index) { |
| 250 ASSERT(is_copy()); | 242 ASSERT(is_copy()); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 268 class UntaggedInt32Field: public BitField<bool, 5, 1> {}; | 260 class UntaggedInt32Field: public BitField<bool, 5, 1> {}; |
| 269 class TypeInfoField: public BitField<int, 6, 7> {}; | 261 class TypeInfoField: public BitField<int, 6, 7> {}; |
| 270 class DataField: public BitField<uint32_t, 13, 32 - 13> {}; | 262 class DataField: public BitField<uint32_t, 13, 32 - 13> {}; |
| 271 | 263 |
| 272 friend class VirtualFrame; | 264 friend class VirtualFrame; |
| 273 }; | 265 }; |
| 274 | 266 |
| 275 } } // namespace v8::internal | 267 } } // namespace v8::internal |
| 276 | 268 |
| 277 #endif // V8_FRAME_ELEMENT_H_ | 269 #endif // V8_FRAME_ELEMENT_H_ |
| OLD | NEW |