Reviewers: dstence, michael_dawson,

Description:
PPC: Fix constant pool overflow access in Get/SetRelocatedValue.

This resolves the mirror-object test failure.

[email protected], [email protected]
BUG=

Please review this at https://codereview.chromium.org/1214903009/

Base URL: https://chromium.googlesource.com/v8/v8.git@master

Affected files (+42, -2 lines):
  M src/ppc/macro-assembler-ppc.cc


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..4fd330a0ea44e62218adaaf967de949281422590 100644
--- a/src/ppc/macro-assembler-ppc.cc
+++ b/src/ppc/macro-assembler-ppc.cc
@@ -3247,6 +3247,7 @@ void MacroAssembler::SetRelocatedValue(Register location, Register scratch,
   lwz(scratch, MemOperand(location));

   if (FLAG_enable_embedded_constant_pool) {
+    Label patch_constant, overflow_access;
     if (emit_debug_code()) {
// Check that the instruction sequence is a load from the constant pool
       ExtractBitMask(scratch, scratch, 0x1f * B16);
@@ -3255,8 +3256,27 @@ 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.
+
+    // Determine constant pool access type
+    ExtractBitRange(r0, scratch, 31, 26);
+    cmpi(r0, Operand(ADDIS >> 26));
+    beq(&overflow_access);
+
+    // Regular constant pool access
+    // extract the load offset
     andi(scratch, scratch, Operand(kImm16Mask));
+    b(&patch_constant);
+
+    bind(&overflow_access);
+    // Overflow constant pool access
+    // shift addis immediate
+    slwi(r0, scratch, Operand(16));
+    // sign-extend and add the load offset
+    lwz(scratch, MemOperand(location, kInstrSize));
+    extsh(scratch, scratch);
+    add(scratch, r0, scratch);
+
+    bind(&patch_constant);
     StorePX(new_value, MemOperand(kConstantPoolRegister, scratch));
     return;
   }
@@ -3345,6 +3365,7 @@ void MacroAssembler::GetRelocatedValue(Register location, Register result,
   lwz(result, MemOperand(location));

   if (FLAG_enable_embedded_constant_pool) {
+    Label load_constant, overflow_access;
     if (emit_debug_code()) {
// Check that the instruction sequence is a load from the constant pool
       ExtractBitMask(result, result, 0x1f * B16);
@@ -3352,8 +3373,27 @@ void MacroAssembler::GetRelocatedValue(Register location, Register result,
       Check(eq, kTheInstructionToPatchShouldBeALoadFromConstantPool);
       lwz(result, MemOperand(location));
     }
-    // Get the address of the constant and retrieve it.
+
+    // Determine constant pool access type
+    ExtractBitRange(scratch, result, 31, 26);
+    cmpi(scratch, Operand(ADDIS >> 26));
+    beq(&overflow_access);
+
+    // Regular constant pool access
+    // extract the load offset
     andi(result, result, Operand(kImm16Mask));
+    b(&load_constant);
+
+    bind(&overflow_access);
+    // Overflow constant pool access
+    // shift addis immediate
+    slwi(result, result, Operand(16));
+    // sign-extend and add the load offset
+    lwz(scratch, MemOperand(location, kInstrSize));
+    extsh(scratch, scratch);
+    add(result, result, scratch);
+
+    bind(&load_constant);
     LoadPX(result, MemOperand(kConstantPoolRegister, result));
     return;
   }


--
--
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.

Reply via email to