Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(966)

Unified Diff: src/parser.cc

Issue 745233002: Fix raw TemplateLiteral spans with non-ascii characters (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Don't use Utf8Decoder::WriteUtf16 when length is 0 Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | test/mjsunit/harmony/templates.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/parser.cc
diff --git a/src/parser.cc b/src/parser.cc
index e6c0e2645e4decdf522c9118af01ddf56b6d240c..653cc783bf5680026751029b506289add0e9ff05 100644
--- a/src/parser.cc
+++ b/src/parser.cc
@@ -5336,9 +5336,23 @@ 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));
- Literal* raw_lit = factory()->NewStringLiteral(raw_str, span_start - 1);
+ Access<UnicodeCache::Utf8Decoder>
+ decoder(isolate()->unicode_cache()->utf8_decoder());
+ decoder->Reset(raw_chars.get(), to_index);
marja 2014/12/01 15:53:59 Since we're now doing parsing on a background thre
Dmitry Lomov (no reviews) 2014/12/01 16:09:48 Oops, sorry, forgot about that! Good catch!
+ int utf16_length = decoder->Utf16Length();
+ Literal* raw_lit = NULL;
+ if (utf16_length > 0) {
+ uc16* utf16_buffer = zone()->NewArray<uc16>(utf16_length);
+ to_index = decoder->WriteUtf16(utf16_buffer, utf16_length);
+ const uint16_t* data = reinterpret_cast<const uint16_t*>(utf16_buffer);
+ const AstRawString* raw_str = ast_value_factory()->GetTwoByteString(
+ Vector<const uint16_t>(data, to_index));
+ raw_lit = factory()->NewStringLiteral(raw_str, span_start - 1);
+ } else {
+ raw_lit = factory()->NewStringLiteral(
+ ast_value_factory()->empty_string(), span_start - 1);
+ }
+ DCHECK_NOT_NULL(raw_lit);
raw_strings->Add(raw_lit, zone());
}
« no previous file with comments | « no previous file | test/mjsunit/harmony/templates.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698