Bug 1116491 - IonMonkey: Use a larger code alignment on x86/x64 to load SIMD constants from code sections. r=bbouvier

Delta:
 - Rename SimdStackAlignment to SimdMemoryAlignment
 - Add an assertion which ensure that Code sections in which SIMD constants are
   added are well aligned.
 - Increase x86 & x64 CodeAlignment to match the previous assertion.
This commit is contained in:
Nicolas B. Pierron 2015-01-09 12:39:58 +01:00
Родитель b70f054b41
Коммит 91b4714487
12 изменённых файлов: 39 добавлений и 24 удалений

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

@ -290,7 +290,7 @@ AsmJSModule::finish(ExclusiveContext *cx, TokenStream &tokenStream, MacroAssembl
// The global data section sits immediately after the executable (and
// other) data allocated by the MacroAssembler, so ensure it is
// SIMD-aligned.
pod.codeBytes_ = AlignBytes(masm.bytesNeeded(), SimdStackAlignment);
pod.codeBytes_ = AlignBytes(masm.bytesNeeded(), SimdMemoryAlignment);
// The entire region is allocated via mmap/VirtualAlloc which requires
// units of pages.

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

@ -550,15 +550,15 @@ LMoveGroup::add(LAllocation *from, LAllocation *to, LDefinition::Type type)
if (LDefinition(type).isSimdType()) {
if (from->isMemory()) {
if (from->isArgument())
MOZ_ASSERT(from->toArgument()->index() % SimdStackAlignment == 0);
MOZ_ASSERT(from->toArgument()->index() % SimdMemoryAlignment == 0);
else
MOZ_ASSERT(from->toStackSlot()->slot() % SimdStackAlignment == 0);
MOZ_ASSERT(from->toStackSlot()->slot() % SimdMemoryAlignment == 0);
}
if (to->isMemory()) {
if (to->isArgument())
MOZ_ASSERT(to->toArgument()->index() % SimdStackAlignment == 0);
MOZ_ASSERT(to->toArgument()->index() % SimdMemoryAlignment == 0);
else
MOZ_ASSERT(to->toStackSlot()->slot() % SimdStackAlignment == 0);
MOZ_ASSERT(to->toStackSlot()->slot() % SimdMemoryAlignment == 0);
}
}
#endif

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

@ -153,9 +153,14 @@ static const uint32_t CodeAlignment = 8;
// here such that it is accessible from the entire codebase. Once full support
// for SIMD is reached on all tier-1 platforms, this constant can be deleted.
static const bool SupportsSimd = false;
static const uint32_t SimdStackAlignment = 8;
static const uint32_t SimdMemoryAlignment = 8;
static const uint32_t AsmJSStackAlignment = SimdStackAlignment;
static_assert(CodeAlignment % SimdMemoryAlignment == 0,
"Code alignment should be larger than any of the alignment which are used for "
"the constant sections of the code buffer. Thus it should be larger than the "
"alignment for SIMD constants.");
static const uint32_t AsmJSStackAlignment = SimdMemoryAlignment;
static const Scale ScalePointer = TimesFour;

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

@ -170,9 +170,9 @@ static const uint32_t CodeAlignment = 4;
static const bool SupportsSimd = false;
// TODO this is just a filler to prevent a build failure. The MIPS SIMD
// alignment requirements still need to be explored.
static const uint32_t SimdStackAlignment = 8;
static const uint32_t SimdMemoryAlignment = 8;
static const uint32_t AsmJSStackAlignment = SimdStackAlignment;
static const uint32_t AsmJSStackAlignment = SimdMemoryAlignment;
static const Scale ScalePointer = TimesFour;

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

@ -15,7 +15,7 @@ namespace js {
namespace jit {
static const bool SupportsSimd = false;
static const uint32_t SimdStackAlignment = 4; // Make it 4 to avoid a bunch of div-by-zero warnings
static const uint32_t SimdMemoryAlignment = 4; // Make it 4 to avoid a bunch of div-by-zero warnings
static const uint32_t AsmJSStackAlignment = 4;
class Registers

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

@ -310,8 +310,8 @@ CodeGeneratorX86Shared::visitAsmJSPassStackArg(LAsmJSPassStackArg *ins)
case MIRType_Float32:
masm.storeDouble(ToFloatRegister(ins->arg()), dst);
return;
// StackPointer is SimdStackAlignment-aligned and ABIArgGenerator guarantees stack
// offsets are SimdStackAlignment-aligned.
// StackPointer is SIMD-aligned and ABIArgGenerator guarantees
// stack offsets are SIMD-aligned.
case MIRType_Int32x4:
masm.storeAlignedInt32x4(ToFloatRegister(ins->arg()), dst);
return;

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

@ -34,7 +34,7 @@ ABIArgGenerator::next(MIRType type)
// On Win64, >64 bit args need to be passed by reference, but asm.js
// doesn't allow passing SIMD values to FFIs. The only way to reach
// here is asm to asm calls, so we can break the ABI here.
stackOffset_ = AlignBytes(stackOffset_, SimdStackAlignment);
stackOffset_ = AlignBytes(stackOffset_, SimdMemoryAlignment);
current_ = ABIArg(stackOffset_);
stackOffset_ += Simd128DataSize;
} else {
@ -86,7 +86,7 @@ ABIArgGenerator::next(MIRType type)
case MIRType_Int32x4:
case MIRType_Float32x4:
if (floatRegIndex_ == NumFloatArgRegs) {
stackOffset_ = AlignBytes(stackOffset_, SimdStackAlignment);
stackOffset_ = AlignBytes(stackOffset_, SimdMemoryAlignment);
current_ = ABIArg(stackOffset_);
stackOffset_ += Simd128DataSize;
break;

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

@ -178,16 +178,21 @@ static MOZ_CONSTEXPR_VAR Register OsrFrameReg = IntArgReg3;
static MOZ_CONSTEXPR_VAR Register PreBarrierReg = rdx;
static const uint32_t ABIStackAlignment = 16;
static const uint32_t CodeAlignment = 8;
static const uint32_t CodeAlignment = 16;
// This boolean indicates whether we support SIMD instructions flavoured for
// this architecture or not. Rather than a method in the LIRGenerator, it is
// here such that it is accessible from the entire codebase. Once full support
// for SIMD is reached on all tier-1 platforms, this constant can be deleted.
static const bool SupportsSimd = true;
static const uint32_t SimdStackAlignment = 16;
static const uint32_t SimdMemoryAlignment = 16;
static const uint32_t AsmJSStackAlignment = SimdStackAlignment;
static_assert(CodeAlignment % SimdMemoryAlignment == 0,
"Code alignment should be larger than any of the alignment which are used for "
"the constant sections of the code buffer. Thus it should be larger than the "
"alignment for SIMD constants.");
static const uint32_t AsmJSStackAlignment = SimdMemoryAlignment;
static const Scale ScalePointer = TimesEight;

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

@ -160,7 +160,7 @@ MacroAssemblerX64::finish()
// SIMD memory values must be suitably aligned.
if (!simds_.empty())
masm.align(SimdStackAlignment);
masm.align(SimdMemoryAlignment);
for (size_t i = 0; i < simds_.length(); i++) {
SimdData &v = simds_[i];
bind(&v.uses);

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

@ -34,8 +34,8 @@ ABIArgGenerator::next(MIRType type)
case MIRType_Float32x4:
// SIMD values aren't passed in or out of C++, so we can make up
// whatever internal ABI we like. visitAsmJSPassArg assumes
// SimdStackAlignment.
stackOffset_ = AlignBytes(stackOffset_, SimdStackAlignment);
// SimdMemoryAlignment.
stackOffset_ = AlignBytes(stackOffset_, SimdMemoryAlignment);
current_ = ABIArg(stackOffset_);
stackOffset_ += Simd128DataSize;
break;

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

@ -108,16 +108,21 @@ static const uint32_t ABIStackAlignment = 16;
#else
static const uint32_t ABIStackAlignment = 4;
#endif
static const uint32_t CodeAlignment = 8;
static const uint32_t CodeAlignment = 16;
// This boolean indicates whether we support SIMD instructions flavoured for
// this architecture or not. Rather than a method in the LIRGenerator, it is
// here such that it is accessible from the entire codebase. Once full support
// for SIMD is reached on all tier-1 platforms, this constant can be deleted.
static const bool SupportsSimd = true;
static const uint32_t SimdStackAlignment = 16;
static const uint32_t SimdMemoryAlignment = 16;
static const uint32_t AsmJSStackAlignment = SimdStackAlignment;
static_assert(CodeAlignment % SimdMemoryAlignment == 0,
"Code alignment should be larger than any of the alignment which are used for "
"the constant sections of the code buffer. Thus it should be larger than the "
"alignment for SIMD constants.");
static const uint32_t AsmJSStackAlignment = SimdMemoryAlignment;
struct ImmTag : public Imm32
{

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

@ -187,7 +187,7 @@ MacroAssemblerX86::finish()
// SIMD memory values must be suitably aligned.
if (!simds_.empty())
masm.align(SimdStackAlignment);
masm.align(SimdMemoryAlignment);
for (size_t i = 0; i < simds_.length(); i++) {
CodeLabel cl(simds_[i].uses);
SimdData &v = simds_[i];