Reviewers: Dmitry Lomov (chromium), rossberg, arv,

Message:
On 2014/11/21 04:49:11, caitp wrote:
mailto:[email protected] changed reviewers:
+ mailto:[email protected], mailto:[email protected],
mailto:[email protected]

It's based on https://codereview.chromium.org/742643003/#ps60001 --- but a
simpler approach that will allocate more memory than is needed in ascii cases.

Description:
Fix raw TemplateLiteral spans with non-ascii characters

BUG=v8:3710

Please review this at https://codereview.chromium.org/745233002/

Base URL: https://chromium.googlesource.com/v8/v8.git@master

Affected files (+8, -5 lines):
  M src/parser.cc
  M test/mjsunit/harmony/templates.js


Index: src/parser.cc
diff --git a/src/parser.cc b/src/parser.cc
index e6c0e2645e4decdf522c9118af01ddf56b6d240c..efc7df7b48885309c48993853f83c96cc25ee601 100644
--- a/src/parser.cc
+++ b/src/parser.cc
@@ -5336,8 +5336,13 @@ ZoneList<Expression*>* Parser::TemplateRawStrings(const TemplateLiteral* lit,
       raw_chars[to_index++] = ch;
     }

-    const AstRawString* raw_str = ast_value_factory()->GetOneByteString(
-        OneByteVector(raw_chars.get(), to_index));
+    unibrow::Utf8Decoder<256> decoder(raw_chars.get(), to_index);
+    int utf16_length = decoder.Utf16Length();
+    uc16* utf16_buffer = zone()->NewArray<uc16>(utf16_length);
+    to_index = decoder.WriteUtf16(utf16_buffer, utf16_length);
+    const AstRawString* raw_str = ast_value_factory()->GetTwoByteString(
+ Vector<const uint16_t>(reinterpret_cast<const uint16_t*>(utf16_buffer),
+            to_index));
Literal* raw_lit = factory()->NewStringLiteral(raw_str, span_start - 1);
     raw_strings->Add(raw_lit, zone());
   }
Index: test/mjsunit/harmony/templates.js
diff --git a/test/mjsunit/harmony/templates.js b/test/mjsunit/harmony/templates.js index 3baf05eb5d0583734e09a4896663f49119742438..92c1ba057eb97b29500d224ee8cf7812ad20197e 100644
--- a/test/mjsunit/harmony/templates.js
+++ b/test/mjsunit/harmony/templates.js
@@ -401,9 +401,7 @@ var obj = {
   assertEquals("안녕", callSites[0][0]);
   assertEquals("\\uc548\\ub155", callSites[0].raw[0]);
   assertEquals("안녕", callSites[1][0]);
-  // TODO(caitp, arv): blocked on correctly generating raw strings from
-  // multi-byte UTF8.
-  // assertEquals("안녕", callSites[1].raw[0]);
+  assertEquals("안녕", callSites[1].raw[0]);
 })();




--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to