From 04383998bb083709529b80753f253a9ae36c77fa Mon Sep 17 00:00:00 2001 From: generatedunixname89002005232357 Date: Tue, 18 Oct 2022 12:27:57 -0700 Subject: [PATCH] Revert D40283500: Multisect successfully blamed D40283500 for test or build failures Summary: This diff is reverting D40283500 D40283500 has been identified to be causing the following test or build failures: Tests affected: - https://www.internalfb.com/intern/test/844424945068193/ Here's the Multisect link: https://www.internalfb.com/intern/testinfra/multisect/1355177 Here are the tasks that are relevant to this breakage: T134940596: 3 tests started failing for oncall haas in the last 2 weeks We're generating a revert to back out the changes in this diff, please note the backout may land if someone accepts it. Reviewed By: fbmal7 Differential Revision: D40461524 fbshipit-source-id: 863435129d36e6742d60753617fdab1223e16ee7 --- include/hermes/Support/UTF16Stream.h | 4 ---- lib/VM/JSLib/JSONLexer.cpp | 21 +++------------------ 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/include/hermes/Support/UTF16Stream.h b/include/hermes/Support/UTF16Stream.h index dc2cc9f87f1..a752eaeff03 100644 --- a/include/hermes/Support/UTF16Stream.h +++ b/include/hermes/Support/UTF16Stream.h @@ -59,10 +59,6 @@ class UTF16Stream { return *this; } - const char16_t *position() const { - return cur_; - } - private: /// Tries to convert more data. Returns true if more data was converted. bool refill(); diff --git a/lib/VM/JSLib/JSONLexer.cpp b/lib/VM/JSLib/JSONLexer.cpp index 36c108dc1be..df47ef13f20 100644 --- a/lib/VM/JSLib/JSONLexer.cpp +++ b/lib/VM/JSLib/JSONLexer.cpp @@ -127,28 +127,20 @@ ExecutionStatus JSONLexer::scanNumber() { ExecutionStatus JSONLexer::scanString() { assert(*curCharPtr_ == '"'); ++curCharPtr_; - const char16_t *start = curCharPtr_.position(); - bool hasEscape = false; - // Ideally we don't have to use tmpStorage. In the case of a plain string with - // no escapes, we just construct an ArrayRef at the end of scanning that - // points to the beginning and end of the string. SmallU16String<32> tmpStorage; while (curCharPtr_.hasChar()) { if (*curCharPtr_ == '"') { // End of string. - llvh::ArrayRef strRef = hasEscape - ? tmpStorage.arrayRef() - : llvh::makeArrayRef(start, curCharPtr_.position()); ++curCharPtr_; // If the string exists in the identifier table, use that one. if (auto existing = runtime_.getIdentifierTable().getExistingStringPrimitiveOrNull( - runtime_, strRef)) { + runtime_, tmpStorage.arrayRef())) { token_.setString(runtime_.makeHandle(existing)); return ExecutionStatus::RETURNED; } - auto strRes = StringPrimitive::create(runtime_, strRef); + auto strRes = StringPrimitive::create(runtime_, tmpStorage.arrayRef()); if (LLVM_UNLIKELY(strRes == ExecutionStatus::EXCEPTION)) { return ExecutionStatus::EXCEPTION; } @@ -158,12 +150,6 @@ ExecutionStatus JSONLexer::scanString() { return error(u"U+0000 thru U+001F is not allowed in string"); } if (*curCharPtr_ == u'\\') { - if (!hasEscape && curCharPtr_.position() != start) { - // This is the first escape character encountered, so append everything - // we've seen so far to tmpStorage. - tmpStorage.append(start, curCharPtr_.position()); - } - hasEscape = true; ++curCharPtr_; if (!curCharPtr_.hasChar()) { return error("Unexpected end of input"); @@ -211,8 +197,7 @@ ExecutionStatus JSONLexer::scanString() { return errorWithChar(u"Invalid escape sequence: ", *curCharPtr_); } } else { - if (hasEscape) - tmpStorage.push_back(*curCharPtr_); + tmpStorage.push_back(*curCharPtr_); ++curCharPtr_; } }