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

Unified Diff: src/ppc/macro-assembler-ppc.cc

Issue 1214903009: PPC: Fix constant pool overflow access in Get/SetRelocatedValue. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Typo Created 5 years, 6 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
« no previous file with comments | « src/ppc/macro-assembler-ppc.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ppc/macro-assembler-ppc.cc
diff --git a/src/ppc/macro-assembler-ppc.cc b/src/ppc/macro-assembler-ppc.cc
index d0960cc90a4f459059fafc49a46dc29dbfb38916..7cd895583ab9667a8abb48926bcc531b3be70055 100644
--- a/src/ppc/macro-assembler-ppc.cc
+++ b/src/ppc/macro-assembler-ppc.cc
@@ -3242,6 +3242,35 @@ void MacroAssembler::FlushICache(Register address, size_t size,
}
+void MacroAssembler::DecodeConstantPoolOffset(Register result,
+ Register location) {
+ Label overflow_access, done;
+ DCHECK(!AreAliased(result, location, r0));
+
+ // Determine constant pool access type
+ // Caller has already placed the instruction word at location in result.
+ ExtractBitRange(r0, result, 31, 26);
+ cmpi(r0, Operand(ADDIS >> 26));
+ beq(&overflow_access);
+
+ // Regular constant pool access
+ // extract the load offset
+ andi(result, result, Operand(kImm16Mask));
+ b(&done);
+
+ bind(&overflow_access);
+ // Overflow constant pool access
+ // shift addis immediate
+ slwi(r0, result, Operand(16));
+ // sign-extend and add the load offset
+ lwz(result, MemOperand(location, kInstrSize));
+ extsh(result, result);
+ add(result, r0, result);
+
+ bind(&done);
+}
+
+
void MacroAssembler::SetRelocatedValue(Register location, Register scratch,
Register new_value) {
lwz(scratch, MemOperand(location));
@@ -3255,8 +3284,7 @@ void MacroAssembler::SetRelocatedValue(Register location, Register scratch,
// Scratch was clobbered. Restore it.
lwz(scratch, MemOperand(location));
}
- // Get the address of the constant and patch it.
- andi(scratch, scratch, Operand(kImm16Mask));
+ DecodeConstantPoolOffset(scratch, location);
StorePX(new_value, MemOperand(kConstantPoolRegister, scratch));
return;
}
@@ -3352,8 +3380,7 @@ void MacroAssembler::GetRelocatedValue(Register location, Register result,
Check(eq, kTheInstructionToPatchShouldBeALoadFromConstantPool);
lwz(result, MemOperand(location));
}
- // Get the address of the constant and retrieve it.
- andi(result, result, Operand(kImm16Mask));
+ DecodeConstantPoolOffset(result, location);
LoadPX(result, MemOperand(kConstantPoolRegister, result));
return;
}
« no previous file with comments | « src/ppc/macro-assembler-ppc.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698