Bug 1122856 - OdinMonkey: Split out the flag that says "bounds checks are unneeded because of signal handling" r=luke

This commit is contained in:
Dan Gohman 2015-02-24 07:50:14 -08:00
Родитель ed1b0adc6c
Коммит 036bcf67ff
6 изменённых файлов: 43 добавлений и 39 удалений

Просмотреть файл

@ -2519,7 +2519,9 @@ class FunctionCompiler
const JitCompileOptions options;
mirGen_ = lifo_.new_<MIRGenerator>(CompileCompartment::get(cx()->compartment()),
options, alloc_,
graph_, info_, optimizationInfo);
graph_, info_, optimizationInfo,
&m().onOutOfBoundsLabel(),
m().usesSignalHandlersForOOB());
if (!newBlock(/* pred = */ nullptr, &curBlock_, fn_))
return false;
@ -2871,7 +2873,7 @@ class FunctionCompiler
if (inDeadCode())
return nullptr;
bool needsBoundsCheck = chk == NEEDS_BOUNDS_CHECK && !m().usesSignalHandlersForOOB();
bool needsBoundsCheck = chk == NEEDS_BOUNDS_CHECK;
MOZ_ASSERT(!Scalar::isSimdType(accessType), "SIMD loads should use loadSimdHeap");
MAsmJSLoadHeap *load = MAsmJSLoadHeap::New(alloc(), accessType, ptr, needsBoundsCheck);
curBlock_->add(load);
@ -2884,11 +2886,10 @@ class FunctionCompiler
if (inDeadCode())
return nullptr;
bool needsBoundsCheck = chk == NEEDS_BOUNDS_CHECK && !m().usesSignalHandlersForOOB();
bool needsBoundsCheck = chk == NEEDS_BOUNDS_CHECK;
MOZ_ASSERT(Scalar::isSimdType(accessType), "loadSimdHeap can only load from a SIMD view");
Label *outOfBoundsLabel = &m().onOutOfBoundsLabel();
MAsmJSLoadHeap *load = MAsmJSLoadHeap::New(alloc(), accessType, ptr, needsBoundsCheck,
outOfBoundsLabel, numElems);
numElems);
curBlock_->add(load);
return load;
}
@ -2898,7 +2899,7 @@ class FunctionCompiler
if (inDeadCode())
return;
bool needsBoundsCheck = chk == NEEDS_BOUNDS_CHECK && !m().usesSignalHandlersForOOB();
bool needsBoundsCheck = chk == NEEDS_BOUNDS_CHECK;
MOZ_ASSERT(!Scalar::isSimdType(accessType), "SIMD stores should use loadSimdHeap");
MAsmJSStoreHeap *store = MAsmJSStoreHeap::New(alloc(), accessType, ptr, v, needsBoundsCheck);
curBlock_->add(store);
@ -2910,11 +2911,10 @@ class FunctionCompiler
if (inDeadCode())
return;
bool needsBoundsCheck = chk == NEEDS_BOUNDS_CHECK && !m().usesSignalHandlersForOOB();
bool needsBoundsCheck = chk == NEEDS_BOUNDS_CHECK;
MOZ_ASSERT(Scalar::isSimdType(accessType), "storeSimdHeap can only load from a SIMD view");
Label *outOfBoundsLabel = &m().onOutOfBoundsLabel();
MAsmJSStoreHeap *store = MAsmJSStoreHeap::New(alloc(), accessType, ptr, v, needsBoundsCheck,
outOfBoundsLabel, numElems);
numElems);
curBlock_->add(store);
}
@ -2931,9 +2931,8 @@ class FunctionCompiler
if (inDeadCode())
return nullptr;
bool needsBoundsCheck = chk == NEEDS_BOUNDS_CHECK && !m().usesSignalHandlersForOOB();
bool needsBoundsCheck = chk == NEEDS_BOUNDS_CHECK;
MAsmJSLoadHeap *load = MAsmJSLoadHeap::New(alloc(), accessType, ptr, needsBoundsCheck,
/* outOfBoundsLabel = */ nullptr,
/* numElems */ 0,
MembarBeforeLoad, MembarAfterLoad);
curBlock_->add(load);
@ -2945,9 +2944,8 @@ class FunctionCompiler
if (inDeadCode())
return;
bool needsBoundsCheck = chk == NEEDS_BOUNDS_CHECK && !m().usesSignalHandlersForOOB();
bool needsBoundsCheck = chk == NEEDS_BOUNDS_CHECK;
MAsmJSStoreHeap *store = MAsmJSStoreHeap::New(alloc(), accessType, ptr, v, needsBoundsCheck,
/* outOfBoundsLabel = */ nullptr,
/* numElems = */ 0,
MembarBeforeStore, MembarAfterStore);
curBlock_->add(store);

Просмотреть файл

@ -12183,14 +12183,11 @@ class MAsmJSHeapAccess
{
Scalar::Type accessType_;
bool needsBoundsCheck_;
Label *outOfBoundsLabel_;
unsigned numSimdElems_;
public:
MAsmJSHeapAccess(Scalar::Type accessType, bool needsBoundsCheck,
Label *outOfBoundsLabel = nullptr, unsigned numSimdElems = 0)
: accessType_(accessType), needsBoundsCheck_(needsBoundsCheck),
outOfBoundsLabel_(outOfBoundsLabel), numSimdElems_(numSimdElems)
MAsmJSHeapAccess(Scalar::Type accessType, bool needsBoundsCheck, unsigned numSimdElems = 0)
: accessType_(accessType), needsBoundsCheck_(needsBoundsCheck), numSimdElems_(numSimdElems)
{
MOZ_ASSERT(numSimdElems <= ScalarTypeToLength(accessType));
}
@ -12198,7 +12195,6 @@ class MAsmJSHeapAccess
Scalar::Type accessType() const { return accessType_; }
bool needsBoundsCheck() const { return needsBoundsCheck_; }
void removeBoundsCheck() { needsBoundsCheck_ = false; }
Label *outOfBoundsLabel() const { return outOfBoundsLabel_; }
unsigned numSimdElems() const { MOZ_ASSERT(Scalar::isSimdType(accessType_)); return numSimdElems_; }
};
@ -12211,10 +12207,9 @@ class MAsmJSLoadHeap
MemoryBarrierBits barrierAfter_;
MAsmJSLoadHeap(Scalar::Type accessType, MDefinition *ptr, bool needsBoundsCheck,
Label *outOfBoundsLabel, unsigned numSimdElems,
MemoryBarrierBits before, MemoryBarrierBits after)
unsigned numSimdElems, MemoryBarrierBits before, MemoryBarrierBits after)
: MUnaryInstruction(ptr),
MAsmJSHeapAccess(accessType, needsBoundsCheck, outOfBoundsLabel, numSimdElems),
MAsmJSHeapAccess(accessType, needsBoundsCheck, numSimdElems),
barrierBefore_(before),
barrierAfter_(after)
{
@ -12255,12 +12250,11 @@ class MAsmJSLoadHeap
static MAsmJSLoadHeap *New(TempAllocator &alloc, Scalar::Type accessType,
MDefinition *ptr, bool needsBoundsCheck,
Label *outOfBoundsLabel = nullptr,
unsigned numSimdElems = 0,
MemoryBarrierBits barrierBefore = MembarNobits,
MemoryBarrierBits barrierAfter = MembarNobits)
{
return new(alloc) MAsmJSLoadHeap(accessType, ptr, needsBoundsCheck, outOfBoundsLabel,
return new(alloc) MAsmJSLoadHeap(accessType, ptr, needsBoundsCheck,
numSimdElems, barrierBefore, barrierAfter);
}
@ -12284,10 +12278,9 @@ class MAsmJSStoreHeap
MemoryBarrierBits barrierAfter_;
MAsmJSStoreHeap(Scalar::Type accessType, MDefinition *ptr, MDefinition *v, bool needsBoundsCheck,
Label *outOfBoundsLabel, unsigned numSimdElems,
MemoryBarrierBits before, MemoryBarrierBits after)
unsigned numSimdElems, MemoryBarrierBits before, MemoryBarrierBits after)
: MBinaryInstruction(ptr, v),
MAsmJSHeapAccess(accessType, needsBoundsCheck, outOfBoundsLabel, numSimdElems),
MAsmJSHeapAccess(accessType, needsBoundsCheck, numSimdElems),
barrierBefore_(before),
barrierAfter_(after)
{
@ -12300,12 +12293,11 @@ class MAsmJSStoreHeap
static MAsmJSStoreHeap *New(TempAllocator &alloc, Scalar::Type accessType,
MDefinition *ptr, MDefinition *v, bool needsBoundsCheck,
Label *outOfBoundsLabel = nullptr,
unsigned numSimdElems = 0,
MemoryBarrierBits barrierBefore = MembarNobits,
MemoryBarrierBits barrierAfter = MembarNobits)
{
return new(alloc) MAsmJSStoreHeap(accessType, ptr, v, needsBoundsCheck, outOfBoundsLabel,
return new(alloc) MAsmJSStoreHeap(accessType, ptr, v, needsBoundsCheck,
numSimdElems, barrierBefore, barrierAfter);
}

Просмотреть файл

@ -38,7 +38,8 @@ class MIRGenerator
public:
MIRGenerator(CompileCompartment *compartment, const JitCompileOptions &options,
TempAllocator *alloc, MIRGraph *graph,
CompileInfo *info, const OptimizationInfo *optimizationInfo);
CompileInfo *info, const OptimizationInfo *optimizationInfo,
Label *outOfBoundsLabel = nullptr, bool usesSignalHandlersForOOB = false);
TempAllocator &alloc() {
return *alloc_;
@ -199,6 +200,9 @@ class MIRGenerator
// CodeGenerator::link).
ObjectVector nurseryObjects_;
Label *outOfBoundsLabel_;
bool usesSignalHandlersForOOB_;
void addAbortedNewScriptPropertiesGroup(ObjectGroup *type);
void setForceAbort() {
shouldForceAbort_ = true;
@ -222,6 +226,13 @@ class MIRGenerator
const ObjectVector &nurseryObjects() const {
return nurseryObjects_;
}
bool usesSignalHandlersForOOB() const {
return usesSignalHandlersForOOB_;
}
Label *outOfBoundsLabel() const {
return outOfBoundsLabel_;
}
};
} // namespace jit

Просмотреть файл

@ -19,7 +19,8 @@ using mozilla::Swap;
MIRGenerator::MIRGenerator(CompileCompartment *compartment, const JitCompileOptions &options,
TempAllocator *alloc, MIRGraph *graph, CompileInfo *info,
const OptimizationInfo *optimizationInfo)
const OptimizationInfo *optimizationInfo,
Label *outOfBoundsLabel, bool usesSignalHandlersForOOB)
: compartment(compartment),
info_(info),
optimizationInfo_(optimizationInfo),
@ -40,6 +41,8 @@ MIRGenerator::MIRGenerator(CompileCompartment *compartment, const JitCompileOpti
instrumentedProfiling_(false),
instrumentedProfilingIsCached_(false),
nurseryObjects_(*alloc),
outOfBoundsLabel_(outOfBoundsLabel),
usesSignalHandlersForOOB_(usesSignalHandlersForOOB),
options(options)
{ }

Просмотреть файл

@ -313,9 +313,9 @@ CodeGeneratorX64::emitSimdLoad(LAsmJSLoadHeap *ins)
}
uint32_t maybeCmpOffset = AsmJSHeapAccess::NoLengthCheck;
if (mir->needsBoundsCheck()) {
if (mir->needsBoundsCheck() && !gen->usesSignalHandlersForOOB()) {
maybeCmpOffset = masm.cmp32WithPatch(ToRegister(ptr), Imm32(0)).offset();
masm.j(Assembler::AboveOrEqual, mir->outOfBoundsLabel()); // Throws RangeError
masm.j(Assembler::AboveOrEqual, gen->outOfBoundsLabel()); // Throws RangeError
}
unsigned numElems = mir->numSimdElems();
@ -376,7 +376,7 @@ CodeGeneratorX64::visitAsmJSLoadHeap(LAsmJSLoadHeap *ins)
memoryBarrier(ins->mir()->barrierBefore());
OutOfLineLoadTypedArrayOutOfBounds *ool = nullptr;
uint32_t maybeCmpOffset = AsmJSHeapAccess::NoLengthCheck;
if (mir->needsBoundsCheck()) {
if (mir->needsBoundsCheck() && !gen->usesSignalHandlersForOOB()) {
CodeOffsetLabel cmp = masm.cmp32WithPatch(ToRegister(ptr), Imm32(0));
ool = new(alloc()) OutOfLineLoadTypedArrayOutOfBounds(ToAnyRegister(out), vt);
addOutOfLineCode(ool, ins->mir());
@ -467,9 +467,9 @@ CodeGeneratorX64::emitSimdStore(LAsmJSStoreHeap *ins)
}
uint32_t maybeCmpOffset = AsmJSHeapAccess::NoLengthCheck;
if (mir->needsBoundsCheck()) {
if (mir->needsBoundsCheck() && !gen->usesSignalHandlersForOOB()) {
maybeCmpOffset = masm.cmp32WithPatch(ToRegister(ptr), Imm32(0)).offset();
masm.j(Assembler::AboveOrEqual, mir->outOfBoundsLabel()); // Throws RangeError
masm.j(Assembler::AboveOrEqual, gen->outOfBoundsLabel()); // Throws RangeError
}
unsigned numElems = mir->numSimdElems();
@ -529,7 +529,7 @@ CodeGeneratorX64::visitAsmJSStoreHeap(LAsmJSStoreHeap *ins)
memoryBarrier(ins->mir()->barrierBefore());
Label rejoin;
uint32_t maybeCmpOffset = AsmJSHeapAccess::NoLengthCheck;
if (mir->needsBoundsCheck()) {
if (mir->needsBoundsCheck() && !gen->usesSignalHandlersForOOB()) {
CodeOffsetLabel cmp = masm.cmp32WithPatch(ToRegister(ptr), Imm32(0));
masm.j(Assembler::AboveOrEqual, &rejoin);
maybeCmpOffset = cmp.offset();

Просмотреть файл

@ -479,7 +479,7 @@ CodeGeneratorX86::visitAsmJSLoadHeap(LAsmJSLoadHeap *ins)
if (Scalar::isSimdType(accessType)) {
return emitSimdLoad(accessType, mir->numSimdElems(), ptr, ToFloatRegister(out),
mir->needsBoundsCheck(), mir->outOfBoundsLabel());
mir->needsBoundsCheck(), gen->outOfBoundsLabel());
}
memoryBarrier(ins->mir()->barrierBefore());
@ -698,7 +698,7 @@ CodeGeneratorX86::visitAsmJSStoreHeap(LAsmJSStoreHeap *ins)
if (Scalar::isSimdType(vt)) {
return emitSimdStore(vt, mir->numSimdElems(), ToFloatRegister(value), ptr,
mir->needsBoundsCheck(), mir->outOfBoundsLabel());
mir->needsBoundsCheck(), gen->outOfBoundsLabel());
}
memoryBarrier(ins->mir()->barrierBefore());