Commit 5a09c0c0 authored by mbrandy's avatar mbrandy Committed by Commit bot

PPC: Remove usages of Heap::NewSpaceStart and its external reference

Port f2a58593

Original commit message:
    Replace the uses with proper page flag lookups.

R=mlippautz@chromium.org, joransiu@ca.ibm.com, jyan@ca.ibm.com, michael_dawson@ca.ibm.com
BUG=chromium:581412
LOG=N
TEST=mjsunit/allocation-site-info

Review URL: https://codereview.chromium.org/1845753005

Cr-Commit-Position: refs/heads/master@{#35172}
parent da934aba
......@@ -4487,9 +4487,10 @@ void LCodeGen::DoTransitionElementsKind(LTransitionElementsKind* instr) {
void LCodeGen::DoTrapAllocationMemento(LTrapAllocationMemento* instr) {
Register object = ToRegister(instr->object());
Register temp = ToRegister(instr->temp());
Register temp1 = ToRegister(instr->temp1());
Register temp2 = ToRegister(instr->temp2());
Label no_memento_found;
__ TestJSArrayForAllocationMemento(object, temp, &no_memento_found);
__ TestJSArrayForAllocationMemento(object, temp1, temp2, &no_memento_found);
DeoptimizeIf(eq, instr, Deoptimizer::kMementoFound);
__ bind(&no_memento_found);
}
......
......@@ -2239,9 +2239,10 @@ LInstruction* LChunkBuilder::DoTransitionElementsKind(
LInstruction* LChunkBuilder::DoTrapAllocationMemento(
HTrapAllocationMemento* instr) {
LOperand* object = UseRegister(instr->object());
LOperand* temp = TempRegister();
LOperand* temp1 = TempRegister();
LOperand* temp2 = TempRegister();
LTrapAllocationMemento* result =
new (zone()) LTrapAllocationMemento(object, temp);
new (zone()) LTrapAllocationMemento(object, temp1, temp2);
return AssignEnvironment(result);
}
......
......@@ -2058,16 +2058,17 @@ class LTransitionElementsKind final : public LTemplateInstruction<0, 2, 1> {
ElementsKind to_kind() { return hydrogen()->to_kind(); }
};
class LTrapAllocationMemento final : public LTemplateInstruction<0, 1, 1> {
class LTrapAllocationMemento final : public LTemplateInstruction<0, 1, 2> {
public:
LTrapAllocationMemento(LOperand* object, LOperand* temp) {
LTrapAllocationMemento(LOperand* object, LOperand* temp1, LOperand* temp2) {
inputs_[0] = object;
temps_[0] = temp;
temps_[0] = temp1;
temps_[1] = temp2;
}
LOperand* object() { return inputs_[0]; }
LOperand* temp() { return temps_[0]; }
LOperand* temp1() { return temps_[0]; }
LOperand* temp2() { return temps_[1]; }
DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento, "trap-allocation-memento")
};
......
......@@ -136,7 +136,7 @@ void ElementsTransitionGenerator::GenerateMapChangeElementsTransition(
if (mode == TRACK_ALLOCATION_SITE) {
DCHECK(allocation_memento_found != NULL);
__ JumpIfJSArrayHasAllocationMemento(receiver, scratch_elements,
__ JumpIfJSArrayHasAllocationMemento(receiver, scratch_elements, r11,
allocation_memento_found);
}
......@@ -169,7 +169,7 @@ void ElementsTransitionGenerator::GenerateSmiToDouble(
scratch2));
if (mode == TRACK_ALLOCATION_SITE) {
__ JumpIfJSArrayHasAllocationMemento(receiver, elements, fail);
__ JumpIfJSArrayHasAllocationMemento(receiver, elements, scratch3, fail);
}
// Check for empty arrays, which only require a map transition and no changes
......@@ -289,7 +289,7 @@ void ElementsTransitionGenerator::GenerateDoubleToObject(
scratch));
if (mode == TRACK_ALLOCATION_SITE) {
__ JumpIfJSArrayHasAllocationMemento(receiver, elements, fail);
__ JumpIfJSArrayHasAllocationMemento(receiver, elements, scratch3, fail);
}
// Check for empty arrays, which only require a map transition and no changes
......
......@@ -4472,28 +4472,52 @@ void MacroAssembler::StoreDouble(DoubleRegister src, const MemOperand& mem,
}
}
void MacroAssembler::TestJSArrayForAllocationMemento(Register receiver_reg,
Register scratch_reg,
Register scratch2_reg,
Label* no_memento_found) {
ExternalReference new_space_start =
ExternalReference::new_space_start(isolate());
Label map_check;
Label top_check;
ExternalReference new_space_allocation_top =
ExternalReference::new_space_allocation_top_address(isolate());
addi(scratch_reg, receiver_reg,
Operand(JSArray::kSize + AllocationMemento::kSize - kHeapObjectTag));
Cmpi(scratch_reg, Operand(new_space_start), r0);
blt(no_memento_found);
mov(ip, Operand(new_space_allocation_top));
LoadP(ip, MemOperand(ip));
cmp(scratch_reg, ip);
const int kMementoMapOffset = JSArray::kSize - kHeapObjectTag;
const int kMementoEndOffset = kMementoMapOffset + AllocationMemento::kSize;
Register mask = scratch2_reg;
DCHECK(!AreAliased(receiver_reg, scratch_reg, mask));
// Bail out if the object is not in new space.
JumpIfNotInNewSpace(receiver_reg, scratch_reg, no_memento_found);
DCHECK((~Page::kPageAlignmentMask & 0xffff) == 0);
lis(mask, Operand((~Page::kPageAlignmentMask >> 16)));
addi(scratch_reg, receiver_reg, Operand(kMementoEndOffset));
// If the object is in new space, we need to check whether it is on the same
// page as the current top.
Xor(r0, scratch_reg, Operand(new_space_allocation_top));
and_(r0, r0, mask, SetRC);
beq(&top_check, cr0);
// The object is on a different page than allocation top. Bail out if the
// object sits on the page boundary as no memento can follow and we cannot
// touch the memory following it.
xor_(r0, scratch_reg, receiver_reg);
and_(r0, r0, mask, SetRC);
bne(no_memento_found, cr0);
// Continue with the actual map check.
b(&map_check);
// If top is on the same page as the current object, we need to check whether
// we are below top.
bind(&top_check);
Cmpi(scratch_reg, Operand(new_space_allocation_top), r0);
bgt(no_memento_found);
LoadP(scratch_reg, MemOperand(scratch_reg, -AllocationMemento::kSize));
// Memento map check.
bind(&map_check);
LoadP(scratch_reg, MemOperand(receiver_reg, kMementoMapOffset));
Cmpi(scratch_reg, Operand(isolate()->factory()->allocation_memento_map()),
r0);
}
Register GetRegisterThatIsNotOneOf(Register reg1, Register reg2, Register reg3,
Register reg4, Register reg5,
Register reg6) {
......
......@@ -1509,13 +1509,15 @@ class MacroAssembler : public Assembler {
// If allocation info is present, condition flags are set to eq.
void TestJSArrayForAllocationMemento(Register receiver_reg,
Register scratch_reg,
Register scratch2_reg,
Label* no_memento_found);
void JumpIfJSArrayHasAllocationMemento(Register receiver_reg,
Register scratch_reg,
Register scratch2_reg,
Label* memento_found) {
Label no_memento_found;
TestJSArrayForAllocationMemento(receiver_reg, scratch_reg,
TestJSArrayForAllocationMemento(receiver_reg, scratch_reg, scratch2_reg,
&no_memento_found);
beq(memento_found);
bind(&no_memento_found);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment