| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef V8_SAFEPOINT_TABLE_H_ | 5 #ifndef V8_SAFEPOINT_TABLE_H_ |
| 6 #define V8_SAFEPOINT_TABLE_H_ | 6 #define V8_SAFEPOINT_TABLE_H_ |
| 7 | 7 |
| 8 #include "src/allocation.h" | 8 #include "src/allocation.h" |
| 9 #include "src/heap.h" | 9 #include "src/heap.h" |
| 10 #include "src/v8memory.h" | 10 #include "src/v8memory.h" |
| 11 #include "src/zone.h" | 11 #include "src/zone.h" |
| 12 | 12 |
| 13 namespace v8 { | 13 namespace v8 { |
| 14 namespace internal { | 14 namespace internal { |
| 15 | 15 |
| 16 struct Register; | 16 struct Register; |
| 17 | 17 |
| 18 class SafepointEntry BASE_EMBEDDED { | 18 class SafepointEntry BASE_EMBEDDED { |
| 19 public: | 19 public: |
| 20 SafepointEntry() : info_(0), bits_(NULL) {} | 20 SafepointEntry() : info_(0), bits_(NULL) {} |
| 21 | 21 |
| 22 SafepointEntry(unsigned info, uint8_t* bits) : info_(info), bits_(bits) { | 22 SafepointEntry(unsigned info, uint8_t* bits) : info_(info), bits_(bits) { |
| 23 ASSERT(is_valid()); | 23 DCHECK(is_valid()); |
| 24 } | 24 } |
| 25 | 25 |
| 26 bool is_valid() const { return bits_ != NULL; } | 26 bool is_valid() const { return bits_ != NULL; } |
| 27 | 27 |
| 28 bool Equals(const SafepointEntry& other) const { | 28 bool Equals(const SafepointEntry& other) const { |
| 29 return info_ == other.info_ && bits_ == other.bits_; | 29 return info_ == other.info_ && bits_ == other.bits_; |
| 30 } | 30 } |
| 31 | 31 |
| 32 void Reset() { | 32 void Reset() { |
| 33 info_ = 0; | 33 info_ = 0; |
| 34 bits_ = NULL; | 34 bits_ = NULL; |
| 35 } | 35 } |
| 36 | 36 |
| 37 int deoptimization_index() const { | 37 int deoptimization_index() const { |
| 38 ASSERT(is_valid()); | 38 DCHECK(is_valid()); |
| 39 return DeoptimizationIndexField::decode(info_); | 39 return DeoptimizationIndexField::decode(info_); |
| 40 } | 40 } |
| 41 | 41 |
| 42 static const int kArgumentsFieldBits = 3; | 42 static const int kArgumentsFieldBits = 3; |
| 43 static const int kSaveDoublesFieldBits = 1; | 43 static const int kSaveDoublesFieldBits = 1; |
| 44 static const int kDeoptIndexBits = | 44 static const int kDeoptIndexBits = |
| 45 32 - kArgumentsFieldBits - kSaveDoublesFieldBits; | 45 32 - kArgumentsFieldBits - kSaveDoublesFieldBits; |
| 46 class DeoptimizationIndexField: | 46 class DeoptimizationIndexField: |
| 47 public BitField<int, 0, kDeoptIndexBits> {}; // NOLINT | 47 public BitField<int, 0, kDeoptIndexBits> {}; // NOLINT |
| 48 class ArgumentsField: | 48 class ArgumentsField: |
| 49 public BitField<unsigned, | 49 public BitField<unsigned, |
| 50 kDeoptIndexBits, | 50 kDeoptIndexBits, |
| 51 kArgumentsFieldBits> {}; // NOLINT | 51 kArgumentsFieldBits> {}; // NOLINT |
| 52 class SaveDoublesField: | 52 class SaveDoublesField: |
| 53 public BitField<bool, | 53 public BitField<bool, |
| 54 kDeoptIndexBits + kArgumentsFieldBits, | 54 kDeoptIndexBits + kArgumentsFieldBits, |
| 55 kSaveDoublesFieldBits> { }; // NOLINT | 55 kSaveDoublesFieldBits> { }; // NOLINT |
| 56 | 56 |
| 57 int argument_count() const { | 57 int argument_count() const { |
| 58 ASSERT(is_valid()); | 58 DCHECK(is_valid()); |
| 59 return ArgumentsField::decode(info_); | 59 return ArgumentsField::decode(info_); |
| 60 } | 60 } |
| 61 | 61 |
| 62 bool has_doubles() const { | 62 bool has_doubles() const { |
| 63 ASSERT(is_valid()); | 63 DCHECK(is_valid()); |
| 64 return SaveDoublesField::decode(info_); | 64 return SaveDoublesField::decode(info_); |
| 65 } | 65 } |
| 66 | 66 |
| 67 uint8_t* bits() { | 67 uint8_t* bits() { |
| 68 ASSERT(is_valid()); | 68 DCHECK(is_valid()); |
| 69 return bits_; | 69 return bits_; |
| 70 } | 70 } |
| 71 | 71 |
| 72 bool HasRegisters() const; | 72 bool HasRegisters() const; |
| 73 bool HasRegisterAt(int reg_index) const; | 73 bool HasRegisterAt(int reg_index) const; |
| 74 | 74 |
| 75 private: | 75 private: |
| 76 unsigned info_; | 76 unsigned info_; |
| 77 uint8_t* bits_; | 77 uint8_t* bits_; |
| 78 }; | 78 }; |
| 79 | 79 |
| 80 | 80 |
| 81 class SafepointTable BASE_EMBEDDED { | 81 class SafepointTable BASE_EMBEDDED { |
| 82 public: | 82 public: |
| 83 explicit SafepointTable(Code* code); | 83 explicit SafepointTable(Code* code); |
| 84 | 84 |
| 85 int size() const { | 85 int size() const { |
| 86 return kHeaderSize + | 86 return kHeaderSize + |
| 87 (length_ * (kPcAndDeoptimizationIndexSize + entry_size_)); } | 87 (length_ * (kPcAndDeoptimizationIndexSize + entry_size_)); } |
| 88 unsigned length() const { return length_; } | 88 unsigned length() const { return length_; } |
| 89 unsigned entry_size() const { return entry_size_; } | 89 unsigned entry_size() const { return entry_size_; } |
| 90 | 90 |
| 91 unsigned GetPcOffset(unsigned index) const { | 91 unsigned GetPcOffset(unsigned index) const { |
| 92 ASSERT(index < length_); | 92 DCHECK(index < length_); |
| 93 return Memory::uint32_at(GetPcOffsetLocation(index)); | 93 return Memory::uint32_at(GetPcOffsetLocation(index)); |
| 94 } | 94 } |
| 95 | 95 |
| 96 SafepointEntry GetEntry(unsigned index) const { | 96 SafepointEntry GetEntry(unsigned index) const { |
| 97 ASSERT(index < length_); | 97 DCHECK(index < length_); |
| 98 unsigned info = Memory::uint32_at(GetInfoLocation(index)); | 98 unsigned info = Memory::uint32_at(GetInfoLocation(index)); |
| 99 uint8_t* bits = &Memory::uint8_at(entries_ + (index * entry_size_)); | 99 uint8_t* bits = &Memory::uint8_at(entries_ + (index * entry_size_)); |
| 100 return SafepointEntry(info, bits); | 100 return SafepointEntry(info, bits); |
| 101 } | 101 } |
| 102 | 102 |
| 103 // Returns the entry for the given pc. | 103 // Returns the entry for the given pc. |
| 104 SafepointEntry FindEntry(Address pc) const; | 104 SafepointEntry FindEntry(Address pc) const; |
| 105 | 105 |
| 106 void PrintEntry(unsigned index, OStream& os) const; // NOLINT | 106 void PrintEntry(unsigned index, OStream& os) const; // NOLINT |
| 107 | 107 |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 int last_lazy_safepoint_; | 225 int last_lazy_safepoint_; |
| 226 | 226 |
| 227 Zone* zone_; | 227 Zone* zone_; |
| 228 | 228 |
| 229 DISALLOW_COPY_AND_ASSIGN(SafepointTableBuilder); | 229 DISALLOW_COPY_AND_ASSIGN(SafepointTableBuilder); |
| 230 }; | 230 }; |
| 231 | 231 |
| 232 } } // namespace v8::internal | 232 } } // namespace v8::internal |
| 233 | 233 |
| 234 #endif // V8_SAFEPOINT_TABLE_H_ | 234 #endif // V8_SAFEPOINT_TABLE_H_ |
| OLD | NEW |