You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

210 lines
6.5 KiB

  1. Description: upstream mips fix
  2. Origin: https://github.com/nodejs/node/issues/31118
  3. Last-Update: 2020-05-30
  4. --- a/deps/v8/AUTHORS
  5. +++ b/deps/v8/AUTHORS
  6. @@ -106,6 +106,7 @@
  7. James M Snell <jasnell@gmail.com>
  8. Jianghua Yang <jianghua.yjh@alibaba-inc.com>
  9. Jiawen Geng <technicalcute@gmail.com>
  10. +Jiaxun Yang <jiaxun.yang@flygoat.com>
  11. Joel Stanley <joel@jms.id.au>
  12. Johan Bergström <johan@bergstroem.nu>
  13. Jonathan Liu <net147@gmail.com>
  14. --- a/deps/v8/src/snapshot/embedded/platform-embedded-file-writer-aix.cc
  15. +++ b/deps/v8/src/snapshot/embedded/platform-embedded-file-writer-aix.cc
  16. @@ -94,10 +94,6 @@
  17. void PlatformEmbeddedFileWriterAIX::DeclareFunctionEnd(const char* name) {}
  18. -int PlatformEmbeddedFileWriterAIX::HexLiteral(uint64_t value) {
  19. - return fprintf(fp_, "0x%" PRIx64, value);
  20. -}
  21. -
  22. void PlatformEmbeddedFileWriterAIX::FilePrologue() {}
  23. void PlatformEmbeddedFileWriterAIX::DeclareExternalFilename(
  24. @@ -120,12 +116,6 @@
  25. return kLong;
  26. }
  27. -int PlatformEmbeddedFileWriterAIX::WriteByteChunk(const uint8_t* data) {
  28. - DCHECK_EQ(ByteChunkDataDirective(), kLong);
  29. - const uint32_t* long_ptr = reinterpret_cast<const uint32_t*>(data);
  30. - return HexLiteral(*long_ptr);
  31. -}
  32. -
  33. #undef SYMBOL_PREFIX
  34. } // namespace internal
  35. --- a/deps/v8/src/snapshot/embedded/platform-embedded-file-writer-aix.h
  36. +++ b/deps/v8/src/snapshot/embedded/platform-embedded-file-writer-aix.h
  37. @@ -37,8 +37,6 @@
  38. void DeclareFunctionBegin(const char* name) override;
  39. void DeclareFunctionEnd(const char* name) override;
  40. - int HexLiteral(uint64_t value) override;
  41. -
  42. void Comment(const char* string) override;
  43. void FilePrologue() override;
  44. @@ -48,7 +46,6 @@
  45. int IndentedDataDirective(DataDirective directive) override;
  46. DataDirective ByteChunkDataDirective() const override;
  47. - int WriteByteChunk(const uint8_t* data) override;
  48. private:
  49. void DeclareSymbolGlobal(const char* name);
  50. --- a/deps/v8/src/snapshot/embedded/platform-embedded-file-writer-base.cc
  51. +++ b/deps/v8/src/snapshot/embedded/platform-embedded-file-writer-base.cc
  52. @@ -24,6 +24,10 @@
  53. }
  54. }
  55. +int PlatformEmbeddedFileWriterBase::HexLiteral(uint64_t value) {
  56. + return fprintf(fp_, "0x%" PRIx64, value);
  57. +}
  58. +
  59. int DataDirectiveSize(DataDirective directive) {
  60. switch (directive) {
  61. case kByte:
  62. @@ -39,24 +43,37 @@
  63. }
  64. int PlatformEmbeddedFileWriterBase::WriteByteChunk(const uint8_t* data) {
  65. - DCHECK_EQ(ByteChunkDataDirective(), kOcta);
  66. -
  67. - static constexpr size_t kSize = kInt64Size;
  68. -
  69. - uint64_t part1, part2;
  70. - // Use memcpy for the reads since {data} is not guaranteed to be aligned.
  71. + size_t kSize = DataDirectiveSize(ByteChunkDataDirective());
  72. + size_t kHalfSize = kSize / 2;
  73. + uint64_t high = 0, low = 0;
  74. +
  75. + switch (kSize) {
  76. + case 1:
  77. + low = *data;
  78. + break;
  79. + case 4:
  80. + low = *reinterpret_cast<const uint32_t*>(data);
  81. + break;
  82. + case 8:
  83. + low = *reinterpret_cast<const uint64_t*>(data);
  84. + break;
  85. + case 16:
  86. #ifdef V8_TARGET_BIG_ENDIAN
  87. - memcpy(&part1, data, kSize);
  88. - memcpy(&part2, data + kSize, kSize);
  89. + memcpy(&high, data, kHalfSize);
  90. + memcpy(&low, data + kHalfSize, kHalfSize);
  91. #else
  92. - memcpy(&part1, data + kSize, kSize);
  93. - memcpy(&part2, data, kSize);
  94. + memcpy(&high, data + kHalfSize, kHalfSize);
  95. + memcpy(&low, data, kHalfSize);
  96. #endif // V8_TARGET_BIG_ENDIAN
  97. + break;
  98. + default:
  99. + UNREACHABLE();
  100. + }
  101. - if (part1 != 0) {
  102. - return fprintf(fp(), "0x%" PRIx64 "%016" PRIx64, part1, part2);
  103. + if (high != 0) {
  104. + return fprintf(fp(), "0x%" PRIx64 "%016" PRIx64, high, low);
  105. } else {
  106. - return fprintf(fp(), "0x%" PRIx64, part2);
  107. + return fprintf(fp(), "0x%" PRIx64, low);
  108. }
  109. }
  110. --- a/deps/v8/src/snapshot/embedded/platform-embedded-file-writer-base.h
  111. +++ b/deps/v8/src/snapshot/embedded/platform-embedded-file-writer-base.h
  112. @@ -67,7 +67,7 @@
  113. virtual void DeclareFunctionEnd(const char* name) = 0;
  114. // Returns the number of printed characters.
  115. - virtual int HexLiteral(uint64_t value) = 0;
  116. + virtual int HexLiteral(uint64_t value);
  117. virtual void Comment(const char* string) = 0;
  118. virtual void Newline() { fprintf(fp_, "\n"); }
  119. --- a/deps/v8/src/snapshot/embedded/platform-embedded-file-writer-generic.cc
  120. +++ b/deps/v8/src/snapshot/embedded/platform-embedded-file-writer-generic.cc
  121. @@ -112,10 +112,6 @@
  122. void PlatformEmbeddedFileWriterGeneric::DeclareFunctionEnd(const char* name) {}
  123. -int PlatformEmbeddedFileWriterGeneric::HexLiteral(uint64_t value) {
  124. - return fprintf(fp_, "0x%" PRIx64, value);
  125. -}
  126. -
  127. void PlatformEmbeddedFileWriterGeneric::FilePrologue() {}
  128. void PlatformEmbeddedFileWriterGeneric::DeclareExternalFilename(
  129. @@ -142,6 +138,18 @@
  130. return fprintf(fp_, " %s ", DirectiveAsString(directive));
  131. }
  132. +DataDirective PlatformEmbeddedFileWriterGeneric::ByteChunkDataDirective()
  133. + const {
  134. +#if defined(V8_TARGET_ARCH_MIPS) || defined(V8_TARGET_ARCH_MIPS64)
  135. + // MIPS uses a fixed 4 byte instruction set, using .long
  136. + // to prevent any unnecessary padding.
  137. + return kLong;
  138. +#else
  139. + // Other ISAs just listen to the base
  140. + return PlatformEmbeddedFileWriterBase::ByteChunkDataDirective();
  141. +#endif
  142. +}
  143. +
  144. #undef SYMBOL_PREFIX
  145. } // namespace internal
  146. --- a/deps/v8/src/snapshot/embedded/platform-embedded-file-writer-generic.h
  147. +++ b/deps/v8/src/snapshot/embedded/platform-embedded-file-writer-generic.h
  148. @@ -39,8 +39,6 @@
  149. void DeclareFunctionBegin(const char* name) override;
  150. void DeclareFunctionEnd(const char* name) override;
  151. - int HexLiteral(uint64_t value) override;
  152. -
  153. void Comment(const char* string) override;
  154. void FilePrologue() override;
  155. @@ -49,6 +47,8 @@
  156. int IndentedDataDirective(DataDirective directive) override;
  157. + DataDirective ByteChunkDataDirective() const override;
  158. +
  159. private:
  160. void DeclareSymbolGlobal(const char* name);
  161. --- a/deps/v8/src/snapshot/embedded/platform-embedded-file-writer-mac.cc
  162. +++ b/deps/v8/src/snapshot/embedded/platform-embedded-file-writer-mac.cc
  163. @@ -87,10 +87,6 @@
  164. void PlatformEmbeddedFileWriterMac::DeclareFunctionEnd(const char* name) {}
  165. -int PlatformEmbeddedFileWriterMac::HexLiteral(uint64_t value) {
  166. - return fprintf(fp_, "0x%" PRIx64, value);
  167. -}
  168. -
  169. void PlatformEmbeddedFileWriterMac::FilePrologue() {}
  170. void PlatformEmbeddedFileWriterMac::DeclareExternalFilename(
  171. --- a/deps/v8/src/snapshot/embedded/platform-embedded-file-writer-mac.h
  172. +++ b/deps/v8/src/snapshot/embedded/platform-embedded-file-writer-mac.h
  173. @@ -37,8 +37,6 @@
  174. void DeclareFunctionBegin(const char* name) override;
  175. void DeclareFunctionEnd(const char* name) override;
  176. - int HexLiteral(uint64_t value) override;
  177. -
  178. void Comment(const char* string) override;
  179. void FilePrologue() override;