diff options
author | Ryan Dahl <ry@tinyclouds.org> | 2011-01-17 11:32:56 -0800 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2011-01-17 11:32:56 -0800 |
commit | cf2e4f44afbfb208c5976786c96ec963930323cc (patch) | |
tree | 7e9ddac16d51490f1428abb610afd02eda98aacf /deps/v8/src/safepoint-table.h | |
parent | 082a4b6033df22a68518c58d320e86f688db7bda (diff) | |
download | node-new-cf2e4f44afbfb208c5976786c96ec963930323cc.tar.gz |
Upgrade V8 to 3.0.8
Diffstat (limited to 'deps/v8/src/safepoint-table.h')
-rw-r--r-- | deps/v8/src/safepoint-table.h | 127 |
1 files changed, 103 insertions, 24 deletions
diff --git a/deps/v8/src/safepoint-table.h b/deps/v8/src/safepoint-table.h index 010ac5759b..d703051423 100644 --- a/deps/v8/src/safepoint-table.h +++ b/deps/v8/src/safepoint-table.h @@ -30,13 +30,89 @@ #include "v8.h" -#include "macro-assembler.h" +#include "heap.h" #include "zone.h" #include "zone-inl.h" namespace v8 { namespace internal { +struct Register; + +class SafepointEntry BASE_EMBEDDED { + public: + SafepointEntry() : info_(0), bits_(NULL) {} + + SafepointEntry(unsigned info, uint8_t* bits) : info_(info), bits_(bits) { + ASSERT(is_valid()); + } + + bool is_valid() const { return bits_ != NULL; } + + bool Equals(const SafepointEntry& other) const { + return info_ == other.info_ && bits_ == other.bits_; + } + + void Reset() { + info_ = 0; + bits_ = NULL; + } + + int deoptimization_index() const { + ASSERT(is_valid()); + return DeoptimizationIndexField::decode(info_); + } + + int gap_code_size() const { + ASSERT(is_valid()); + return GapCodeSizeField::decode(info_); + } + + int argument_count() const { + ASSERT(is_valid()); + return ArgumentsField::decode(info_); + } + + bool has_doubles() const { + ASSERT(is_valid()); + return SaveDoublesField::decode(info_); + } + + uint8_t* bits() { + ASSERT(is_valid()); + return bits_; + } + + bool HasRegisters() const; + bool HasRegisterAt(int reg_index) const; + + // Reserve 13 bits for the gap code size. On ARM a constant pool can be + // emitted when generating the gap code. The size of the const pool is less + // than what can be represented in 12 bits, so 13 bits gives room for having + // instructions before potentially emitting a constant pool. + static const int kGapCodeSizeBits = 13; + static const int kArgumentsFieldBits = 3; + static const int kSaveDoublesFieldBits = 1; + static const int kDeoptIndexBits = + 32 - kGapCodeSizeBits - kArgumentsFieldBits - kSaveDoublesFieldBits; + class GapCodeSizeField: public BitField<unsigned, 0, kGapCodeSizeBits> {}; + class DeoptimizationIndexField: public BitField<int, + kGapCodeSizeBits, + kDeoptIndexBits> {}; // NOLINT + class ArgumentsField: public BitField<unsigned, + kGapCodeSizeBits + kDeoptIndexBits, + kArgumentsFieldBits> {}; // NOLINT + class SaveDoublesField: public BitField<bool, + kGapCodeSizeBits + kDeoptIndexBits + + kArgumentsFieldBits, + kSaveDoublesFieldBits> { }; // NOLINT + + private: + unsigned info_; + uint8_t* bits_; +}; + + class SafepointTable BASE_EMBEDDED { public: explicit SafepointTable(Code* code); @@ -52,28 +128,15 @@ class SafepointTable BASE_EMBEDDED { return Memory::uint32_at(GetPcOffsetLocation(index)); } - int GetDeoptimizationIndex(unsigned index) const { - ASSERT(index < length_); - unsigned value = Memory::uint32_at(GetDeoptimizationLocation(index)); - return DeoptimizationIndexField::decode(value); - } - - unsigned GetGapCodeSize(unsigned index) const { + SafepointEntry GetEntry(unsigned index) const { ASSERT(index < length_); - unsigned value = Memory::uint32_at(GetDeoptimizationLocation(index)); - return GapCodeSizeField::decode(value); + unsigned info = Memory::uint32_at(GetInfoLocation(index)); + uint8_t* bits = &Memory::uint8_at(entries_ + (index * entry_size_)); + return SafepointEntry(info, bits); } - uint8_t* GetEntry(unsigned index) const { - ASSERT(index < length_); - return &Memory::uint8_at(entries_ + (index * entry_size_)); - } - - class GapCodeSizeField: public BitField<unsigned, 0, 8> {}; - class DeoptimizationIndexField: public BitField<int, 8, 24> {}; - - static bool HasRegisters(uint8_t* entry); - static bool HasRegisterAt(uint8_t* entry, int reg_index); + // Returns the entry for the given pc. + SafepointEntry FindEntry(Address pc) const; void PrintEntry(unsigned index) const; @@ -94,7 +157,7 @@ class SafepointTable BASE_EMBEDDED { (index * kPcAndDeoptimizationIndexSize); } - Address GetDeoptimizationLocation(unsigned index) const { + Address GetInfoLocation(unsigned index) const { return GetPcOffsetLocation(index) + kPcSize; } @@ -109,15 +172,19 @@ class SafepointTable BASE_EMBEDDED { Address entries_; friend class SafepointTableBuilder; + friend class SafepointEntry; + + DISALLOW_COPY_AND_ASSIGN(SafepointTable); }; class Safepoint BASE_EMBEDDED { public: - static const int kNoDeoptimizationIndex = 0x00ffffff; + static const int kNoDeoptimizationIndex = + (1 << (SafepointEntry::kDeoptIndexBits)) - 1; void DefinePointerSlot(int index) { indexes_->Add(index); } - void DefinePointerRegister(Register reg) { registers_->Add(reg.code()); } + void DefinePointerRegister(Register reg); private: Safepoint(ZoneList<int>* indexes, ZoneList<int>* registers) : @@ -153,6 +220,16 @@ class SafepointTableBuilder BASE_EMBEDDED { int arguments, int deoptimization_index = Safepoint::kNoDeoptimizationIndex); + // Define a new safepoint with all double registers and the normal + // registers on the stack for the current position in the body and + // take the number of arguments on top of the registers into account. + // TODO(1043) Rewrite the three SafepointTableBuilder::DefineSafepoint + // methods to one method that uses template arguments. + Safepoint DefineSafepointWithRegistersAndDoubles( + Assembler* assembler, + int arguments, + int deoptimization_index = Safepoint::kNoDeoptimizationIndex); + // Update the last safepoint with the size of the code generated for the gap // following it. void SetPcAfterGap(int pc) { @@ -170,9 +247,11 @@ class SafepointTableBuilder BASE_EMBEDDED { unsigned pc; unsigned deoptimization_index; unsigned pc_after_gap; + unsigned arguments; + bool has_doubles; }; - uint32_t EncodeDeoptimizationIndexAndGap(DeoptimizationInfo info); + uint32_t EncodeExceptPC(const DeoptimizationInfo& info); ZoneList<DeoptimizationInfo> deoptimization_info_; ZoneList<ZoneList<int>*> indexes_; |