In Reland "[runtime] Speed up String::IsOneByte", the following check was added to NonOneByteStart in src/objects/string.h: DCHECK(IsAligned(reinterpret_cast<Address>(chars), sizeof(uc16)));
This is part of the very clever word at a time detection of code points > 256. Unfortunately for us, this code ends up getting called for data we pass to String::NewFromTwoByte. And while the name gives one pause, the comment says /** Allocates a new string from UTF-16 data.*/ so we've been using this against UTF-16 data which, UTF-16 being a serialization mechanism might not be two-byte aligned (ours is often in protocol buffer data). In any case, String::NewFromTwoByte calls Factory::NewStringFromTwoByte with the unaligned string which then calls String::IsOneByte with the unaligned string which then fails with the DCHECK. Without the DCHECK it works because the code that's scanning for the start of word alignment works fine for non-two-byte aligned data so this is only really an issue for debug builds though admittedly the non-one-byte scan won't be nearly as efficient for non-aligned data so maybe the code is doing us a favor by hitting us on the head. For non-two-byte aligned data, the clever algorithm could still be made to work by flipping the endian-specific word mask and a bit of up-front fiddling but far be it for me to advocate anyone going to that trouble though I guess if I were told that such a change would be accepted i'd be willing to contribute such a fix, myself. Another way to fix it would be to create the string in the heap as a two-byte string and then scan the aligned data in the heap, flipping the one-byte bit (or whatever indicates one-byte) in the string object. But haven't researched whether there is a call to do this bit flip. In any case, it doesn't seem nice that V8 no longer has an unaligned UTF-16 to string conversion mechanism, at least not one that works for debug builds. Opinions? -- -- v8-users mailing list v8-users@googlegroups.com http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups "v8-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/v8-users/7f027ba5-d190-45a0-ad94-954e61ec8a4f%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.