MIPS: Retry "Use a WeakCell in the CallIC type vector."

Port 6fc97a1965

Original commit message:
The first try failed because I needed to make a better distinction
between clearing ICs according to policy at GC time or unconditional
clearing (say, via %ClearFunctionTypeFeedback).

It was also blocked by an issue in super constructor calls.
This fix (https://codereview.chromium.org/892113002/) needs to land
before checking in this CL.

BUG=

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

Cr-Commit-Position: refs/heads/master@{#26432}
This commit is contained in:
balazs.kilvady 2015-02-04 08:05:11 -08:00 committed by Commit bot
parent ff0c70380a
commit 3b400fcb9b
4 changed files with 92 additions and 22 deletions

View File

@ -1001,6 +1001,7 @@ void CodeStub::GenerateStubsAheadOfTime(Isolate* isolate) {
StubFailureTrampolineStub::GenerateAheadOfTime(isolate); StubFailureTrampolineStub::GenerateAheadOfTime(isolate);
ArrayConstructorStubBase::GenerateStubsAheadOfTime(isolate); ArrayConstructorStubBase::GenerateStubsAheadOfTime(isolate);
CreateAllocationSiteStub::GenerateAheadOfTime(isolate); CreateAllocationSiteStub::GenerateAheadOfTime(isolate);
CreateWeakCellStub::GenerateAheadOfTime(isolate);
BinaryOpICStub::GenerateAheadOfTime(isolate); BinaryOpICStub::GenerateAheadOfTime(isolate);
StoreRegistersStateStub::GenerateAheadOfTime(isolate); StoreRegistersStateStub::GenerateAheadOfTime(isolate);
RestoreRegistersStateStub::GenerateAheadOfTime(isolate); RestoreRegistersStateStub::GenerateAheadOfTime(isolate);
@ -2797,7 +2798,27 @@ void CallICStub::Generate(MacroAssembler* masm) {
__ sll(t0, a3, kPointerSizeLog2 - kSmiTagSize); __ sll(t0, a3, kPointerSizeLog2 - kSmiTagSize);
__ Addu(t0, a2, Operand(t0)); __ Addu(t0, a2, Operand(t0));
__ lw(t0, FieldMemOperand(t0, FixedArray::kHeaderSize)); __ lw(t0, FieldMemOperand(t0, FixedArray::kHeaderSize));
__ Branch(&extra_checks_or_miss, ne, a1, Operand(t0));
// We don't know that we have a weak cell. We might have a private symbol
// or an AllocationSite, but the memory is safe to examine.
// AllocationSite::kTransitionInfoOffset - contains a Smi or pointer to
// FixedArray.
// WeakCell::kValueOffset - contains a JSFunction or Smi(0)
// Symbol::kHashFieldSlot - if the low bit is 1, then the hash is not
// computed, meaning that it can't appear to be a pointer. If the low bit is
// 0, then hash is computed, but the 0 bit prevents the field from appearing
// to be a pointer.
STATIC_ASSERT(WeakCell::kSize >= kPointerSize);
STATIC_ASSERT(AllocationSite::kTransitionInfoOffset ==
WeakCell::kValueOffset &&
WeakCell::kValueOffset == Symbol::kHashFieldSlot);
__ lw(t1, FieldMemOperand(t0, WeakCell::kValueOffset));
__ Branch(&extra_checks_or_miss, ne, a1, Operand(t1));
// The compare above could have been a SMI/SMI comparison. Guard against this
// convincing us that we have a monomorphic JSFunction.
__ JumpIfSmi(a1, &extra_checks_or_miss);
__ bind(&have_js_function); __ bind(&have_js_function);
if (CallAsMethod()) { if (CallAsMethod()) {
@ -2874,16 +2895,18 @@ void CallICStub::Generate(MacroAssembler* masm) {
__ Addu(t0, t0, Operand(Smi::FromInt(1))); __ Addu(t0, t0, Operand(Smi::FromInt(1)));
__ sw(t0, FieldMemOperand(a2, with_types_offset)); __ sw(t0, FieldMemOperand(a2, with_types_offset));
// Store the function. // Store the function. Use a stub since we need a frame for allocation.
__ sll(t0, a3, kPointerSizeLog2 - kSmiTagSize); // a2 - vector
__ Addu(t0, a2, Operand(t0)); // a3 - slot
__ Addu(t0, t0, Operand(FixedArray::kHeaderSize - kHeapObjectTag)); // a1 - function
__ sw(a1, MemOperand(t0, 0)); {
FrameScope scope(masm, StackFrame::INTERNAL);
CreateWeakCellStub create_stub(masm->isolate());
__ Push(a1);
__ CallStub(&create_stub);
__ Pop(a1);
}
// Update the write barrier.
__ mov(t1, a1);
__ RecordWrite(a2, t0, t1, kRAHasNotBeenSaved, kDontSaveFPRegs,
EMIT_REMEMBERED_SET, OMIT_SMI_CHECK);
__ Branch(&have_js_function); __ Branch(&have_js_function);
// We are here because tracing is on or we encountered a MISS case we can't // We are here because tracing is on or we encountered a MISS case we can't

View File

@ -98,7 +98,19 @@ void FastCloneShallowObjectDescriptor::Initialize(
void CreateAllocationSiteDescriptor::Initialize( void CreateAllocationSiteDescriptor::Initialize(
CallInterfaceDescriptorData* data) { CallInterfaceDescriptorData* data) {
Register registers[] = {cp, a2, a3}; Register registers[] = {cp, a2, a3};
data->Initialize(arraysize(registers), registers, NULL); Representation representations[] = {Representation::Tagged(),
Representation::Tagged(),
Representation::Smi()};
data->Initialize(arraysize(registers), registers, representations);
}
void CreateWeakCellDescriptor::Initialize(CallInterfaceDescriptorData* data) {
Register registers[] = {cp, a2, a3, a1};
Representation representations[] = {
Representation::Tagged(), Representation::Tagged(), Representation::Smi(),
Representation::Tagged()};
data->Initialize(arraysize(registers), registers, representations);
} }

View File

@ -997,6 +997,7 @@ void CodeStub::GenerateStubsAheadOfTime(Isolate* isolate) {
StubFailureTrampolineStub::GenerateAheadOfTime(isolate); StubFailureTrampolineStub::GenerateAheadOfTime(isolate);
ArrayConstructorStubBase::GenerateStubsAheadOfTime(isolate); ArrayConstructorStubBase::GenerateStubsAheadOfTime(isolate);
CreateAllocationSiteStub::GenerateAheadOfTime(isolate); CreateAllocationSiteStub::GenerateAheadOfTime(isolate);
CreateWeakCellStub::GenerateAheadOfTime(isolate);
BinaryOpICStub::GenerateAheadOfTime(isolate); BinaryOpICStub::GenerateAheadOfTime(isolate);
StoreRegistersStateStub::GenerateAheadOfTime(isolate); StoreRegistersStateStub::GenerateAheadOfTime(isolate);
RestoreRegistersStateStub::GenerateAheadOfTime(isolate); RestoreRegistersStateStub::GenerateAheadOfTime(isolate);
@ -2872,7 +2873,27 @@ void CallICStub::Generate(MacroAssembler* masm) {
__ dsrl(a4, a3, 32 - kPointerSizeLog2); __ dsrl(a4, a3, 32 - kPointerSizeLog2);
__ Daddu(a4, a2, Operand(a4)); __ Daddu(a4, a2, Operand(a4));
__ ld(a4, FieldMemOperand(a4, FixedArray::kHeaderSize)); __ ld(a4, FieldMemOperand(a4, FixedArray::kHeaderSize));
__ Branch(&extra_checks_or_miss, ne, a1, Operand(a4));
// We don't know that we have a weak cell. We might have a private symbol
// or an AllocationSite, but the memory is safe to examine.
// AllocationSite::kTransitionInfoOffset - contains a Smi or pointer to
// FixedArray.
// WeakCell::kValueOffset - contains a JSFunction or Smi(0)
// Symbol::kHashFieldSlot - if the low bit is 1, then the hash is not
// computed, meaning that it can't appear to be a pointer. If the low bit is
// 0, then hash is computed, but the 0 bit prevents the field from appearing
// to be a pointer.
STATIC_ASSERT(WeakCell::kSize >= kPointerSize);
STATIC_ASSERT(AllocationSite::kTransitionInfoOffset ==
WeakCell::kValueOffset &&
WeakCell::kValueOffset == Symbol::kHashFieldSlot);
__ ld(a5, FieldMemOperand(a4, WeakCell::kValueOffset));
__ Branch(&extra_checks_or_miss, ne, a1, Operand(a5));
// The compare above could have been a SMI/SMI comparison. Guard against this
// convincing us that we have a monomorphic JSFunction.
__ JumpIfSmi(a1, &extra_checks_or_miss);
__ bind(&have_js_function); __ bind(&have_js_function);
if (CallAsMethod()) { if (CallAsMethod()) {
@ -2949,16 +2970,18 @@ void CallICStub::Generate(MacroAssembler* masm) {
__ Daddu(a4, a4, Operand(Smi::FromInt(1))); __ Daddu(a4, a4, Operand(Smi::FromInt(1)));
__ sd(a4, FieldMemOperand(a2, with_types_offset)); __ sd(a4, FieldMemOperand(a2, with_types_offset));
// Store the function. // Store the function. Use a stub since we need a frame for allocation.
__ dsrl(a4, a3, 32 - kPointerSizeLog2); // a2 - vector
__ Daddu(a4, a2, Operand(a4)); // a3 - slot
__ Daddu(a4, a4, Operand(FixedArray::kHeaderSize - kHeapObjectTag)); // a1 - function
__ sd(a1, MemOperand(a4, 0)); {
FrameScope scope(masm, StackFrame::INTERNAL);
CreateWeakCellStub create_stub(masm->isolate());
__ Push(a1);
__ CallStub(&create_stub);
__ Pop(a1);
}
// Update the write barrier.
__ mov(a5, a1);
__ RecordWrite(a2, a4, a5, kRAHasNotBeenSaved, kDontSaveFPRegs,
EMIT_REMEMBERED_SET, OMIT_SMI_CHECK);
__ Branch(&have_js_function); __ Branch(&have_js_function);
// We are here because tracing is on or we encountered a MISS case we can't // We are here because tracing is on or we encountered a MISS case we can't

View File

@ -98,7 +98,19 @@ void FastCloneShallowObjectDescriptor::Initialize(
void CreateAllocationSiteDescriptor::Initialize( void CreateAllocationSiteDescriptor::Initialize(
CallInterfaceDescriptorData* data) { CallInterfaceDescriptorData* data) {
Register registers[] = {cp, a2, a3}; Register registers[] = {cp, a2, a3};
data->Initialize(arraysize(registers), registers, NULL); Representation representations[] = {Representation::Tagged(),
Representation::Tagged(),
Representation::Smi()};
data->Initialize(arraysize(registers), registers, representations);
}
void CreateWeakCellDescriptor::Initialize(CallInterfaceDescriptorData* data) {
Register registers[] = {cp, a2, a3, a1};
Representation representations[] = {
Representation::Tagged(), Representation::Tagged(), Representation::Smi(),
Representation::Tagged()};
data->Initialize(arraysize(registers), registers, representations);
} }