Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Fix x86 encoder to use 64-bit type to accumulate opcode/prefix bits #8382

Merged
merged 1 commit into from
Dec 1, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 57 additions & 3 deletions src/jit/emit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6038,7 +6038,7 @@ unsigned char emitter::emitOutputLong(BYTE* dst, ssize_t val)
#ifdef DEBUG
if (emitComp->opts.dspEmit)
{
printf("; emit_long 0%08XH\n", val);
printf("; emit_long 0%08XH\n", (int)val);
}
#ifdef _TARGET_AMD64_
// if we're emitting code bytes, ensure that we've already emitted the rex prefix!
Expand All @@ -6062,16 +6062,70 @@ unsigned char emitter::emitOutputSizeT(BYTE* dst, ssize_t val)
if (emitComp->opts.dspEmit)
{
#ifdef _TARGET_AMD64_
printf("; emit_size_t 0%016llXH\n", (size_t)val);
printf("; emit_size_t 0%016llXH\n", val);
#else // _TARGET_AMD64_
printf("; emit_size_t 0%08XH\n", (size_t)val);
printf("; emit_size_t 0%08XH\n", val);
#endif // _TARGET_AMD64_
}
#endif // DEBUG

return sizeof(size_t);
}

//------------------------------------------------------------------------
// Wrappers to emitOutputByte, emitOutputWord, emitOutputLong, emitOutputSizeT
// that take unsigned __int64 or size_t type instead of ssize_t. Used on RyuJIT/x86.
//
// Arguments:
// dst - passed through
// val - passed through
//
// Return Value:
// Same as wrapped function.
//

#if !defined(LEGACY_BACKEND) && defined(_TARGET_X86_)
unsigned char emitter::emitOutputByte(BYTE* dst, size_t val)
{
return emitOutputByte(dst, (ssize_t)val);
}

unsigned char emitter::emitOutputWord(BYTE* dst, size_t val)
{
return emitOutputWord(dst, (ssize_t)val);
}

unsigned char emitter::emitOutputLong(BYTE* dst, size_t val)
{
return emitOutputLong(dst, (ssize_t)val);
}

unsigned char emitter::emitOutputSizeT(BYTE* dst, size_t val)
{
return emitOutputSizeT(dst, (ssize_t)val);
}

unsigned char emitter::emitOutputByte(BYTE* dst, unsigned __int64 val)
{
return emitOutputByte(dst, (ssize_t)val);
}

unsigned char emitter::emitOutputWord(BYTE* dst, unsigned __int64 val)
{
return emitOutputWord(dst, (ssize_t)val);
}

unsigned char emitter::emitOutputLong(BYTE* dst, unsigned __int64 val)
{
return emitOutputLong(dst, (ssize_t)val);
}

unsigned char emitter::emitOutputSizeT(BYTE* dst, unsigned __int64 val)
{
return emitOutputSizeT(dst, (ssize_t)val);
}
#endif // !defined(LEGACY_BACKEND) && defined(_TARGET_X86_)

/*****************************************************************************
*
* Given a block cookie and a code position, return the actual code offset;
Expand Down
12 changes: 12 additions & 0 deletions src/jit/emit.h
Original file line number Diff line number Diff line change
Expand Up @@ -1664,6 +1664,18 @@ class emitter
unsigned char emitOutputLong(BYTE* dst, ssize_t val);
unsigned char emitOutputSizeT(BYTE* dst, ssize_t val);

#if !defined(LEGACY_BACKEND) && defined(_TARGET_X86_)
unsigned char emitOutputByte(BYTE* dst, size_t val);
unsigned char emitOutputWord(BYTE* dst, size_t val);
unsigned char emitOutputLong(BYTE* dst, size_t val);
unsigned char emitOutputSizeT(BYTE* dst, size_t val);

unsigned char emitOutputByte(BYTE* dst, unsigned __int64 val);
unsigned char emitOutputWord(BYTE* dst, unsigned __int64 val);
unsigned char emitOutputLong(BYTE* dst, unsigned __int64 val);
unsigned char emitOutputSizeT(BYTE* dst, unsigned __int64 val);
#endif // !defined(LEGACY_BACKEND) && defined(_TARGET_X86_)

size_t emitIssue1Instr(insGroup* ig, instrDesc* id, BYTE** dp);
size_t emitOutputInstr(insGroup* ig, instrDesc* id, BYTE** dp);

Expand Down
Loading