mirror of https://gitee.com/openkylin/nodejs.git
upstream mips fix
Origin: https://github.com/nodejs/node/issues/31118 Last-Update: 2020-05-30 Gbp-Pq: Name mips-fix.patch
This commit is contained in:
parent
bc89866cfd
commit
58bbae335e
|
@ -106,6 +106,7 @@ James Pike <g00gle@chilon.net>
|
|||
James M Snell <jasnell@gmail.com>
|
||||
Jianghua Yang <jianghua.yjh@alibaba-inc.com>
|
||||
Jiawen Geng <technicalcute@gmail.com>
|
||||
Jiaxun Yang <jiaxun.yang@flygoat.com>
|
||||
Joel Stanley <joel@jms.id.au>
|
||||
Johan Bergström <johan@bergstroem.nu>
|
||||
Jonathan Liu <net147@gmail.com>
|
||||
|
|
|
@ -94,10 +94,6 @@ void PlatformEmbeddedFileWriterAIX::DeclareFunctionBegin(const char* name) {
|
|||
|
||||
void PlatformEmbeddedFileWriterAIX::DeclareFunctionEnd(const char* name) {}
|
||||
|
||||
int PlatformEmbeddedFileWriterAIX::HexLiteral(uint64_t value) {
|
||||
return fprintf(fp_, "0x%" PRIx64, value);
|
||||
}
|
||||
|
||||
void PlatformEmbeddedFileWriterAIX::FilePrologue() {}
|
||||
|
||||
void PlatformEmbeddedFileWriterAIX::DeclareExternalFilename(
|
||||
|
@ -120,12 +116,6 @@ DataDirective PlatformEmbeddedFileWriterAIX::ByteChunkDataDirective() const {
|
|||
return kLong;
|
||||
}
|
||||
|
||||
int PlatformEmbeddedFileWriterAIX::WriteByteChunk(const uint8_t* data) {
|
||||
DCHECK_EQ(ByteChunkDataDirective(), kLong);
|
||||
const uint32_t* long_ptr = reinterpret_cast<const uint32_t*>(data);
|
||||
return HexLiteral(*long_ptr);
|
||||
}
|
||||
|
||||
#undef SYMBOL_PREFIX
|
||||
|
||||
} // namespace internal
|
||||
|
|
|
@ -37,8 +37,6 @@ class PlatformEmbeddedFileWriterAIX : public PlatformEmbeddedFileWriterBase {
|
|||
void DeclareFunctionBegin(const char* name) override;
|
||||
void DeclareFunctionEnd(const char* name) override;
|
||||
|
||||
int HexLiteral(uint64_t value) override;
|
||||
|
||||
void Comment(const char* string) override;
|
||||
|
||||
void FilePrologue() override;
|
||||
|
@ -48,7 +46,6 @@ class PlatformEmbeddedFileWriterAIX : public PlatformEmbeddedFileWriterBase {
|
|||
int IndentedDataDirective(DataDirective directive) override;
|
||||
|
||||
DataDirective ByteChunkDataDirective() const override;
|
||||
int WriteByteChunk(const uint8_t* data) override;
|
||||
|
||||
private:
|
||||
void DeclareSymbolGlobal(const char* name);
|
||||
|
|
|
@ -24,6 +24,10 @@ DataDirective PointerSizeDirective() {
|
|||
}
|
||||
}
|
||||
|
||||
int PlatformEmbeddedFileWriterBase::HexLiteral(uint64_t value) {
|
||||
return fprintf(fp_, "0x%" PRIx64, value);
|
||||
}
|
||||
|
||||
int DataDirectiveSize(DataDirective directive) {
|
||||
switch (directive) {
|
||||
case kByte:
|
||||
|
@ -39,24 +43,37 @@ int DataDirectiveSize(DataDirective directive) {
|
|||
}
|
||||
|
||||
int PlatformEmbeddedFileWriterBase::WriteByteChunk(const uint8_t* data) {
|
||||
DCHECK_EQ(ByteChunkDataDirective(), kOcta);
|
||||
size_t kSize = DataDirectiveSize(ByteChunkDataDirective());
|
||||
size_t kHalfSize = kSize / 2;
|
||||
uint64_t high = 0, low = 0;
|
||||
|
||||
static constexpr size_t kSize = kInt64Size;
|
||||
|
||||
uint64_t part1, part2;
|
||||
// Use memcpy for the reads since {data} is not guaranteed to be aligned.
|
||||
switch (kSize) {
|
||||
case 1:
|
||||
low = *data;
|
||||
break;
|
||||
case 4:
|
||||
low = *reinterpret_cast<const uint32_t*>(data);
|
||||
break;
|
||||
case 8:
|
||||
low = *reinterpret_cast<const uint64_t*>(data);
|
||||
break;
|
||||
case 16:
|
||||
#ifdef V8_TARGET_BIG_ENDIAN
|
||||
memcpy(&part1, data, kSize);
|
||||
memcpy(&part2, data + kSize, kSize);
|
||||
memcpy(&high, data, kHalfSize);
|
||||
memcpy(&low, data + kHalfSize, kHalfSize);
|
||||
#else
|
||||
memcpy(&part1, data + kSize, kSize);
|
||||
memcpy(&part2, data, kSize);
|
||||
memcpy(&high, data + kHalfSize, kHalfSize);
|
||||
memcpy(&low, data, kHalfSize);
|
||||
#endif // V8_TARGET_BIG_ENDIAN
|
||||
break;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
}
|
||||
|
||||
if (part1 != 0) {
|
||||
return fprintf(fp(), "0x%" PRIx64 "%016" PRIx64, part1, part2);
|
||||
if (high != 0) {
|
||||
return fprintf(fp(), "0x%" PRIx64 "%016" PRIx64, high, low);
|
||||
} else {
|
||||
return fprintf(fp(), "0x%" PRIx64, part2);
|
||||
return fprintf(fp(), "0x%" PRIx64, low);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -67,7 +67,7 @@ class PlatformEmbeddedFileWriterBase {
|
|||
virtual void DeclareFunctionEnd(const char* name) = 0;
|
||||
|
||||
// Returns the number of printed characters.
|
||||
virtual int HexLiteral(uint64_t value) = 0;
|
||||
virtual int HexLiteral(uint64_t value);
|
||||
|
||||
virtual void Comment(const char* string) = 0;
|
||||
virtual void Newline() { fprintf(fp_, "\n"); }
|
||||
|
|
|
@ -112,10 +112,6 @@ void PlatformEmbeddedFileWriterGeneric::DeclareFunctionBegin(const char* name) {
|
|||
|
||||
void PlatformEmbeddedFileWriterGeneric::DeclareFunctionEnd(const char* name) {}
|
||||
|
||||
int PlatformEmbeddedFileWriterGeneric::HexLiteral(uint64_t value) {
|
||||
return fprintf(fp_, "0x%" PRIx64, value);
|
||||
}
|
||||
|
||||
void PlatformEmbeddedFileWriterGeneric::FilePrologue() {}
|
||||
|
||||
void PlatformEmbeddedFileWriterGeneric::DeclareExternalFilename(
|
||||
|
@ -142,6 +138,18 @@ int PlatformEmbeddedFileWriterGeneric::IndentedDataDirective(
|
|||
return fprintf(fp_, " %s ", DirectiveAsString(directive));
|
||||
}
|
||||
|
||||
DataDirective PlatformEmbeddedFileWriterGeneric::ByteChunkDataDirective()
|
||||
const {
|
||||
#if defined(V8_TARGET_ARCH_MIPS) || defined(V8_TARGET_ARCH_MIPS64)
|
||||
// MIPS uses a fixed 4 byte instruction set, using .long
|
||||
// to prevent any unnecessary padding.
|
||||
return kLong;
|
||||
#else
|
||||
// Other ISAs just listen to the base
|
||||
return PlatformEmbeddedFileWriterBase::ByteChunkDataDirective();
|
||||
#endif
|
||||
}
|
||||
|
||||
#undef SYMBOL_PREFIX
|
||||
|
||||
} // namespace internal
|
||||
|
|
|
@ -39,8 +39,6 @@ class PlatformEmbeddedFileWriterGeneric
|
|||
void DeclareFunctionBegin(const char* name) override;
|
||||
void DeclareFunctionEnd(const char* name) override;
|
||||
|
||||
int HexLiteral(uint64_t value) override;
|
||||
|
||||
void Comment(const char* string) override;
|
||||
|
||||
void FilePrologue() override;
|
||||
|
@ -49,6 +47,8 @@ class PlatformEmbeddedFileWriterGeneric
|
|||
|
||||
int IndentedDataDirective(DataDirective directive) override;
|
||||
|
||||
DataDirective ByteChunkDataDirective() const override;
|
||||
|
||||
private:
|
||||
void DeclareSymbolGlobal(const char* name);
|
||||
|
||||
|
|
|
@ -87,10 +87,6 @@ void PlatformEmbeddedFileWriterMac::DeclareFunctionBegin(const char* name) {
|
|||
|
||||
void PlatformEmbeddedFileWriterMac::DeclareFunctionEnd(const char* name) {}
|
||||
|
||||
int PlatformEmbeddedFileWriterMac::HexLiteral(uint64_t value) {
|
||||
return fprintf(fp_, "0x%" PRIx64, value);
|
||||
}
|
||||
|
||||
void PlatformEmbeddedFileWriterMac::FilePrologue() {}
|
||||
|
||||
void PlatformEmbeddedFileWriterMac::DeclareExternalFilename(
|
||||
|
|
|
@ -37,8 +37,6 @@ class PlatformEmbeddedFileWriterMac : public PlatformEmbeddedFileWriterBase {
|
|||
void DeclareFunctionBegin(const char* name) override;
|
||||
void DeclareFunctionEnd(const char* name) override;
|
||||
|
||||
int HexLiteral(uint64_t value) override;
|
||||
|
||||
void Comment(const char* string) override;
|
||||
|
||||
void FilePrologue() override;
|
||||
|
|
Loading…
Reference in New Issue