Reviewers: danno, Jakob Kummerow, paul.l..., akos.palfi.imgtec,
balazs.kilvady,
Message:
PTAL.
Description:
MIPS64: Optimize generated code size for deoptimization table entry.
Reuse optimization introduced in 6dee8884.
TEST=
BUG=
Please review this at https://codereview.chromium.org/960963002/
Base URL: https://chromium.googlesource.com/v8/v8.git@master
Affected files (+50, -23 lines):
M src/mips64/deoptimizer-mips64.cc
Index: src/mips64/deoptimizer-mips64.cc
diff --git a/src/mips64/deoptimizer-mips64.cc
b/src/mips64/deoptimizer-mips64.cc
index
e77faedd3b1a448d6479b90bbd49beb4b72c3673..9d7dcb9e5a6b1ddeb4eb6ed81b1ef9834fa52536
100644
--- a/src/mips64/deoptimizer-mips64.cc
+++ b/src/mips64/deoptimizer-mips64.cc
@@ -329,39 +329,66 @@ void Deoptimizer::EntryGenerator::Generate() {
// Maximum size of a table entry generated below.
-const int Deoptimizer::table_entry_size_ = 11 * Assembler::kInstrSize;
+const int Deoptimizer::table_entry_size_ = 2 * Assembler::kInstrSize;
void Deoptimizer::TableEntryGenerator::GeneratePrologue() {
Assembler::BlockTrampolinePoolScope block_trampoline_pool(masm());
// Create a sequence of deoptimization entries.
// Note that registers are still live when jumping to an entry.
- Label table_start;
+ Label table_start, done, done_special, trampoline_jump;
__ bind(&table_start);
- for (int i = 0; i < count(); i++) {
- Label start;
- __ bind(&start);
- __ daddiu(sp, sp, -1 * kPointerSize);
- // Jump over the remaining deopt entries (including this one).
- // This code is always reached by calling Jump, which puts the target
(label
- // start) into t9.
- const int remaining_entries = (count() - i) * table_entry_size_;
- __ Daddu(t9, t9, remaining_entries);
- // 'at' was clobbered so we can only load the current entry value here.
- __ li(t8, i);
- __ jr(t9); // Expose delay slot.
- __ sd(t8, MemOperand(sp, 0 * kPointerSize)); // In the delay slot.
-
- // Pad the rest of the code.
- while (table_entry_size_ > (masm()->SizeOfCodeGeneratedSince(&start)))
{
- __ nop();
+ int kMaxEntriesBranchReach =
+ (1 << (kImm16Bits - 2)) / (table_entry_size_ /
Assembler::kInstrSize);
+
+ if (count() <= kMaxEntriesBranchReach) {
+ // Common case.
+ for (int i = 0; i < count(); i++) {
+ Label start;
+ __ bind(&start);
+ DCHECK(is_int16(i));
+ __ Branch(USE_DELAY_SLOT, &done); // Expose delay slot.
+ __ li(at, i); // In the delay slot.
+
+ DCHECK_EQ(table_entry_size_,
masm()->SizeOfCodeGeneratedSince(&start));
}
- DCHECK_EQ(table_entry_size_, masm()->SizeOfCodeGeneratedSince(&start));
- }
+ DCHECK_EQ(masm()->SizeOfCodeGeneratedSince(&table_start),
+ count() * table_entry_size_);
+ __ bind(&done);
+ __ Push(at);
+ } else {
+ // Uncommon case, the branch cannot reach.
+ // Create mini trampoline and adjust id constants to get proper value
at
+ // the end of table.
+ for (int i = kMaxEntriesBranchReach; i > 1; i--) {
+ Label start;
+ __ bind(&start);
+ DCHECK(is_int16(i));
+ __ Branch(USE_DELAY_SLOT, &trampoline_jump); // Expose delay slot.
+ __ li(at, -i); // In the delay slot.
+ DCHECK_EQ(table_entry_size_,
masm()->SizeOfCodeGeneratedSince(&start));
+ }
+ // Entry with id == kMaxEntriesBranchReach - 1.
+ __ bind(&trampoline_jump);
+ __ Branch(USE_DELAY_SLOT, &done_special);
+ __ li(at, -1);
+
+ for (int i = kMaxEntriesBranchReach; i < count(); i++) {
+ Label start;
+ __ bind(&start);
+ DCHECK(is_int16(i));
+ __ Branch(USE_DELAY_SLOT, &done); // Expose delay slot.
+ __ li(at, i); // In the delay slot.
+ }
- DCHECK_EQ(masm()->SizeOfCodeGeneratedSince(&table_start),
- count() * table_entry_size_);
+ DCHECK_EQ(masm()->SizeOfCodeGeneratedSince(&table_start),
+ count() * table_entry_size_);
+ __ bind(&done_special);
+ __ daddiu(at, at, kMaxEntriesBranchReach);
+ __ bind(&done);
+ __ Push(at);
+ }
}
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.