Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(207)

Unified Diff: src/safepoint-table.cc

Issue 6125007: Allow arguments in safepoints with registers. (Closed)
Patch Set: Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« src/safepoint-table.h ('K') | « src/safepoint-table.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/safepoint-table.cc
diff --git a/src/safepoint-table.cc b/src/safepoint-table.cc
index b9468a50bf244770181d8f605dd1ed34c22cc399..39b211cd925e4d52ad66aa7c8d56c9b9f98ad700 100644
--- a/src/safepoint-table.cc
+++ b/src/safepoint-table.cc
@@ -26,11 +26,34 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "safepoint-table.h"
+
#include "disasm.h"
+#include "macro-assembler.h"
namespace v8 {
namespace internal {
+
+bool SafepointEntry::HasRegisters() const {
+ ASSERT(is_valid());
+ ASSERT(IsAligned(kNumSafepointRegisters, kBitsPerByte));
+ const int num_reg_bytes = kNumSafepointRegisters >> kBitsPerByteLog2;
+ for (int i = 0; i < num_reg_bytes; i++) {
+ if (bits_[i] != SafepointTable::kNoRegisters) return true;
+ }
+ return false;
+}
+
+
+bool SafepointEntry::HasRegisterAt(int reg_index) const {
+ ASSERT(is_valid());
+ ASSERT(reg_index >= 0 && reg_index < kNumSafepointRegisters);
+ int byte_index = reg_index >> kBitsPerByteLog2;
+ int bit_index = reg_index & (kBitsPerByte - 1);
+ return (bits_[byte_index] & (1 << bit_index)) != 0;
+}
+
+
SafepointTable::SafepointTable(Code* code) {
ASSERT(code->kind() == Code::OPTIMIZED_FUNCTION);
code_ = code;
@@ -41,45 +64,39 @@ SafepointTable::SafepointTable(Code* code) {
entries_ = pc_and_deoptimization_indexes_ +
(length_ * kPcAndDeoptimizationIndexSize);
ASSERT(entry_size_ > 0);
- ASSERT_EQ(DeoptimizationIndexField::max(), Safepoint::kNoDeoptimizationIndex);
+ ASSERT_EQ(SafepointEntry::DeoptimizationIndexField::max(),
+ Safepoint::kNoDeoptimizationIndex);
}
-bool SafepointTable::HasRegisters(uint8_t* entry) {
- ASSERT(IsAligned(kNumSafepointRegisters, kBitsPerByte));
- const int num_reg_bytes = kNumSafepointRegisters >> kBitsPerByteLog2;
- for (int i = 0; i < num_reg_bytes; i++) {
- if (entry[i] != kNoRegisters) return true;
+SafepointEntry SafepointTable::FindEntry(Address pc) const {
+ unsigned pc_offset = static_cast<unsigned>(pc - code_->instruction_start());
+ for (unsigned i = 0; i < length(); i++) {
+ // TODO(kasperl): Replace the linear search with binary search.
+ if (GetPcOffset(i) == pc_offset) return GetEntry(i);
}
- return false;
-}
-
-
-bool SafepointTable::HasRegisterAt(uint8_t* entry, int reg_index) {
- ASSERT(reg_index >= 0 && reg_index < kNumSafepointRegisters);
- int byte_index = reg_index >> kBitsPerByteLog2;
- int bit_index = reg_index & (kBitsPerByte - 1);
- return (entry[byte_index] & (1 << bit_index)) != 0;
+ return SafepointEntry();
}
void SafepointTable::PrintEntry(unsigned index) const {
disasm::NameConverter converter;
- uint8_t* entry = GetEntry(index);
+ SafepointEntry entry = GetEntry(index);
+ uint8_t* bits = entry.bits();
// Print the stack slot bits.
if (entry_size_ > 0) {
ASSERT(IsAligned(kNumSafepointRegisters, kBitsPerByte));
const int first = kNumSafepointRegisters >> kBitsPerByteLog2;
int last = entry_size_ - 1;
- for (int i = first; i < last; i++) PrintBits(entry[i], kBitsPerByte);
+ for (int i = first; i < last; i++) PrintBits(bits[i], kBitsPerByte);
int last_bits = code_->stack_slots() - ((last - first) * kBitsPerByte);
- PrintBits(entry[last], last_bits);
+ PrintBits(bits[last], last_bits);
// Print the registers (if any).
- if (!HasRegisters(entry)) return;
+ if (!entry.HasRegisters()) return;
for (int j = 0; j < kNumSafepointRegisters; j++) {
- if (HasRegisterAt(entry, j)) {
+ if (entry.HasRegisterAt(j)) {
PrintF(" | %s", converter.NameOfCPURegister(j));
}
}
fschneider 2011/01/12 09:57:02 Maybe print the number of arguments for the entry
Vitaly Repeshko 2011/01/12 14:14:35 Good idea. Done.
@@ -95,6 +112,11 @@ void SafepointTable::PrintBits(uint8_t byte, int digits) {
}
+void Safepoint::DefinePointerRegister(Register reg) {
+ registers_->Add(reg.code());
+}
+
+
Safepoint SafepointTableBuilder::DefineSafepoint(Assembler* assembler,
int deoptimization_index) {
ASSERT(deoptimization_index != -1);
@@ -102,6 +124,7 @@ Safepoint SafepointTableBuilder::DefineSafepoint(Assembler* assembler,
pc_and_deoptimization_index.pc = assembler->pc_offset();
pc_and_deoptimization_index.deoptimization_index = deoptimization_index;
pc_and_deoptimization_index.pc_after_gap = assembler->pc_offset();
+ pc_and_deoptimization_index.arguments = 0;
deoptimization_info_.Add(pc_and_deoptimization_index);
indexes_.Add(new ZoneList<int>(8));
registers_.Add(NULL);
@@ -112,11 +135,12 @@ Safepoint SafepointTableBuilder::DefineSafepoint(Assembler* assembler,
Safepoint SafepointTableBuilder::DefineSafepointWithRegisters(
Assembler* assembler, int arguments, int deoptimization_index) {
ASSERT(deoptimization_index != -1);
- ASSERT(arguments == 0); // Only case that works for now.
+ ASSERT(arguments >= 0);
DeoptimizationInfo pc_and_deoptimization_index;
pc_and_deoptimization_index.pc = assembler->pc_offset();
pc_and_deoptimization_index.deoptimization_index = deoptimization_index;
pc_and_deoptimization_index.pc_after_gap = assembler->pc_offset();
+ pc_and_deoptimization_index.arguments = arguments;
deoptimization_info_.Add(pc_and_deoptimization_index);
indexes_.Add(new ZoneList<int>(8));
registers_.Add(new ZoneList<int>(4));
@@ -152,7 +176,7 @@ void SafepointTableBuilder::Emit(Assembler* assembler, int bits_per_entry) {
// pc after gap information.
for (int i = 0; i < length; i++) {
assembler->dd(deoptimization_info_[i].pc);
- assembler->dd(EncodeDeoptimizationIndexAndGap(deoptimization_info_[i]));
+ assembler->dd(EncodeExceptPC(deoptimization_info_[i]));
}
// Emit table of bitmaps.
@@ -197,12 +221,12 @@ void SafepointTableBuilder::Emit(Assembler* assembler, int bits_per_entry) {
}
-uint32_t SafepointTableBuilder::EncodeDeoptimizationIndexAndGap(
- DeoptimizationInfo info) {
+uint32_t SafepointTableBuilder::EncodeExceptPC(const DeoptimizationInfo& info) {
unsigned index = info.deoptimization_index;
unsigned gap_size = info.pc_after_gap - info.pc;
- uint32_t encoding = SafepointTable::DeoptimizationIndexField::encode(index);
- encoding |= SafepointTable::GapCodeSizeField::encode(gap_size);
+ uint32_t encoding = SafepointEntry::DeoptimizationIndexField::encode(index);
+ encoding |= SafepointEntry::GapCodeSizeField::encode(gap_size);
+ encoding |= SafepointEntry::ArgumentsField::encode(info.arguments);
return encoding;
}
« src/safepoint-table.h ('K') | « src/safepoint-table.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698