Backed out 2 changesets (bug 1421445) for Valgrind test failures r=backout on a CLOSED TREE

Backed out changeset 39f221c258fc (bug 1421445)
Backed out changeset 797d9e71b648 (bug 1421445)
This commit is contained in:
Cosmin Sabou 2017-11-30 22:33:01 +02:00
parent fd288de282
commit 044c09018c
3 changed files with 10 additions and 51 deletions

View File

@ -739,18 +739,6 @@ JitRuntime::getVMWrapper(const VMFunction& f) const
return trampolineCode(p->value());
}
void
JitCodeHeader::init(JitCode* jitCode)
{
jitCode_ = jitCode;
#if defined(JS_CODEGEN_X86) || defined(JS_CODEGEN_X64)
// On AMD Bobcat processors that may have eratas, insert a NOP slide to reduce crashes
if (CPUInfo::NeedAmdBugWorkaround())
memset((char *)&nops_, X86Encoding::OneByteOpcodeID::OP_NOP, sizeof(nops_));
#endif
}
template <AllowGC allowGC>
JitCode*
JitCode::New(JSContext* cx, uint8_t* code, uint32_t bufferSize, uint32_t headerSize,
@ -779,10 +767,9 @@ JitCode::New<NoGC>(JSContext* cx, uint8_t* code, uint32_t bufferSize, uint32_t h
void
JitCode::copyFrom(MacroAssembler& masm)
{
// Store the JitCode pointer in the JitCodeHeader so we can recover the
// gcthing from relocation tables.
JitCodeHeader::FromExecutable(code_)->init(this);
// Store the JitCode pointer right before the code buffer, so we can
// recover the gcthing from relocation tables.
*(JitCode**)(code_ - sizeof(JitCode*)) = this;
insnSize_ = masm.instructionsSize();
masm.executableCopy(code_);

View File

@ -29,30 +29,10 @@ class MacroAssembler;
class PatchableBackedge;
class IonBuilder;
class IonICEntry;
class JitCode;
typedef Vector<JSObject*, 4, JitAllocPolicy> ObjectVector;
typedef Vector<TraceLoggerEvent, 0, SystemAllocPolicy> TraceLoggerEventVector;
// Header at start of raw code buffer
struct JitCodeHeader
{
// Link back to corresponding gcthing
JitCode* jitCode_;
// !!! NOTE !!!
// If we are running on AMD Bobcat, insert a NOP-slide at end of the JitCode
// header so we can try to recover when the CPU screws up the branch landing
// site. See Bug 1281759.
void* nops_;
void init(JitCode* jitCode);
static JitCodeHeader* FromExecutable(uint8_t* buffer) {
return (JitCodeHeader*)(buffer - sizeof(JitCodeHeader));
}
};
class JitCode : public gc::TenuredCell
{
protected:
@ -149,7 +129,7 @@ class JitCode : public gc::TenuredCell
void copyFrom(MacroAssembler& masm);
static JitCode* FromExecutable(uint8_t* buffer) {
JitCode* code = JitCodeHeader::FromExecutable(buffer)->jitCode_;
JitCode* code = *(JitCode**)(buffer - sizeof(JitCode*));
MOZ_ASSERT(code->raw() == buffer);
return code;
}

View File

@ -23,35 +23,27 @@ Linker::newCode(JSContext* cx, CodeKind kind, bool hasPatchableBackedges /* = fa
if (masm.oom())
return fail(cx);
static const size_t ExecutableAllocatorAlignment = sizeof(void*);
static_assert(CodeAlignment >= ExecutableAllocatorAlignment,
"Unexpected alignment requirements");
// We require enough bytes for the code, header, and worst-case alignment padding.
size_t bytesNeeded = masm.bytesNeeded() +
sizeof(JitCodeHeader) +
(CodeAlignment - ExecutableAllocatorAlignment);
ExecutablePool* pool;
size_t bytesNeeded = masm.bytesNeeded() + sizeof(JitCode*) + CodeAlignment;
if (bytesNeeded >= MAX_BUFFER_SIZE)
return fail(cx);
// ExecutableAllocator requires bytesNeeded to be aligned.
bytesNeeded = AlignBytes(bytesNeeded, ExecutableAllocatorAlignment);
// ExecutableAllocator requires bytesNeeded to be word-size aligned.
bytesNeeded = AlignBytes(bytesNeeded, sizeof(void*));
ExecutableAllocator& execAlloc = hasPatchableBackedges
? cx->runtime()->jitRuntime()->backedgeExecAlloc()
: cx->runtime()->jitRuntime()->execAlloc();
ExecutablePool* pool;
uint8_t* result = (uint8_t*)execAlloc.alloc(cx, bytesNeeded, &pool, kind);
if (!result)
return fail(cx);
// The JitCodeHeader will be stored right before the code buffer.
uint8_t* codeStart = result + sizeof(JitCodeHeader);
// The JitCode pointer will be stored right before the code buffer.
uint8_t* codeStart = result + sizeof(JitCode*);
// Bump the code up to a nice alignment.
codeStart = (uint8_t*)AlignBytes((uintptr_t)codeStart, CodeAlignment);
MOZ_ASSERT(codeStart + masm.bytesNeeded() <= result + bytesNeeded);
uint32_t headerSize = codeStart - result;
JitCode* code = JitCode::New<allowGC>(cx, codeStart, bytesNeeded - headerSize,
headerSize, pool, kind);