Skip to content

Commit

Permalink
Bug 1236600 - Properly pre-barrier sets to inline TypedObject Any-typ…
Browse files Browse the repository at this point in the history
…e Elements. (r=jandem)
  • Loading branch information
Eric Faust committed Jan 13, 2016
1 parent 6877e14 commit 24be047
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 8 deletions.
16 changes: 16 additions & 0 deletions js/src/jit-test/tests/TypedObject/jit-write-references-2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
if (typeof TypedObject === "undefined" || typeof Intl === "undefined")
quit();

try {
gczeal(4)
} catch (exc) {}
var T = TypedObject;
var ValueStruct = new T.StructType({
f: T.Any
})
var v = new ValueStruct;
new class get extends Number {};
function writeValue(o, v)
o.f = v
for (var i = 0; i < 5; i++)
writeValue(v, {}, "helo")
8 changes: 4 additions & 4 deletions js/src/jit/CodeGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7054,7 +7054,7 @@ CodeGenerator::visitStoreElementT(LStoreElementT* store)
const LAllocation* index = store->index();

if (store->mir()->needsBarrier())
emitPreBarrier(elements, index);
emitPreBarrier(elements, index, store->mir()->offsetAdjustment());

if (store->mir()->needsHoleCheck())
emitStoreHoleCheck(elements, index, store->mir()->offsetAdjustment(), store->snapshot());
Expand All @@ -7072,7 +7072,7 @@ CodeGenerator::visitStoreElementV(LStoreElementV* lir)
const LAllocation* index = lir->index();

if (lir->mir()->needsBarrier())
emitPreBarrier(elements, index);
emitPreBarrier(elements, index, lir->mir()->offsetAdjustment());

if (lir->mir()->needsHoleCheck())
emitStoreHoleCheck(elements, index, lir->mir()->offsetAdjustment(), lir->snapshot());
Expand Down Expand Up @@ -7104,7 +7104,7 @@ CodeGenerator::visitStoreElementHoleT(LStoreElementHoleT* lir)
masm.branchKey(Assembler::BelowOrEqual, initLength, ToInt32Key(index), ool->entry());

if (lir->mir()->needsBarrier())
emitPreBarrier(elements, index);
emitPreBarrier(elements, index, 0);

masm.bind(ool->rejoinStore());
emitStoreElementTyped(lir->value(), lir->mir()->value()->type(), lir->mir()->elementType(),
Expand Down Expand Up @@ -7154,7 +7154,7 @@ CodeGenerator::visitStoreElementHoleV(LStoreElementHoleV* lir)
masm.branchKey(Assembler::BelowOrEqual, initLength, ToInt32Key(index), ool->entry());

if (lir->mir()->needsBarrier())
emitPreBarrier(elements, index);
emitPreBarrier(elements, index, 0);

masm.bind(ool->rejoinStore());
if (index->isConstant())
Expand Down
6 changes: 3 additions & 3 deletions js/src/jit/shared/CodeGenerator-shared.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1530,13 +1530,13 @@ CodeGeneratorShared::emitAsmJSCall(LAsmJSCall* ins)
}

void
CodeGeneratorShared::emitPreBarrier(Register base, const LAllocation* index)
CodeGeneratorShared::emitPreBarrier(Register base, const LAllocation* index, int32_t offsetAdjustment)
{
if (index->isConstant()) {
Address address(base, ToInt32(index) * sizeof(Value));
Address address(base, ToInt32(index) * sizeof(Value) + offsetAdjustment);
masm.patchableCallPreBarrier(address, MIRType_Value);
} else {
BaseIndex address(base, ToRegister(index), TimesEight);
BaseIndex address(base, ToRegister(index), TimesEight, offsetAdjustment);
masm.patchableCallPreBarrier(address, MIRType_Value);
}
}
Expand Down
2 changes: 1 addition & 1 deletion js/src/jit/shared/CodeGenerator-shared.h
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ class CodeGeneratorShared : public LElementVisitor

void emitAsmJSCall(LAsmJSCall* ins);

void emitPreBarrier(Register base, const LAllocation* index);
void emitPreBarrier(Register base, const LAllocation* index, int32_t offsetAdjustment);
void emitPreBarrier(Address address);

// We don't emit code for trivial blocks, so if we want to branch to the
Expand Down

0 comments on commit 24be047

Please sign in to comment.