RESOLVED FIXED 107655
[v8] prepare SerializedScriptValue for transition to Latin-1
https://bugs.webkit.org/show_bug.cgi?id=107655
Summary [v8] prepare SerializedScriptValue for transition to Latin-1
Dan Carney
Reported 2013-01-23 03:10:34 PST
[v8] prepare SerializedScriptValue for transition to Latin-1
Attachments
Patch (9.98 KB, patch)
2013-01-23 03:12 PST, Dan Carney
no flags
Patch (2.06 KB, patch)
2013-01-24 05:34 PST, Dan Carney
no flags
Dan Carney
Comment 1 2013-01-23 03:12:00 PST
Kentaro Hara
Comment 2 2013-01-23 03:21:20 PST
Comment on attachment 184190 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=184190&action=review > LayoutTests/platform/chromium/fast/storage/serialized-script-value.html:13 > +var curVer = 0x02ff; Nit: curVer => currentVersion WebKit uses a fully qualified variable name. > LayoutTests/platform/chromium/fast/storage/serialized-script-value.html:28 > - [ 0x02ff, 0x003f, 0x3f6f, 0x5301, 0x6603, > + [ curVer, 0x003f, 0x3f6f, 0x5301, 0x6603, Won't this change lose compatibility for already stored serialized script values (e.g. localStorage)? (I just wanted to confirm that it's OK to change the serialized results.)
Dan Carney
Comment 3 2013-01-23 03:24:43 PST
Comment on attachment 184190 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=184190&action=review >> LayoutTests/platform/chromium/fast/storage/serialized-script-value.html:13 >> +var curVer = 0x02ff; > > Nit: curVer => currentVersion > > WebKit uses a fully qualified variable name. I used curVer to have 6 characters and keep all the byte arrays nicely lined up. >> LayoutTests/platform/chromium/fast/storage/serialized-script-value.html:28 >> + [ curVer, 0x003f, 0x3f6f, 0x5301, 0x6603, > > Won't this change lose compatibility for already stored serialized script values (e.g. localStorage)? (I just wanted to confirm that it's OK to change the serialized results.) This change is backwards but not forwards compatible. If i'm reading SerializedScriptValue.cpp correctly, this bumping the version number is the correct way to do this transition.
Kentaro Hara
Comment 4 2013-01-23 03:28:15 PST
(In reply to comment #3) > I used curVer to have 6 characters and keep all the byte arrays nicely lined up. Ah, makes sense. > This change is backwards but not forwards compatible. If i'm reading SerializedScriptValue.cpp correctly, this bumping the version number is the correct way to do this transition. Looks like so. jsbell, alecflett: would you check that the patch is safe in terms of compatibility?
Dan Carney
Comment 5 2013-01-23 03:41:45 PST
jsbell, alecflett: just to clarify what will happen. Once V8_ONE_BYTE_STRINGS_ENABLED is defined in v8, one byte strings will now potentially have payloads with bytes > 0xf. This was previously impossible, so a version 2 SSV should not be allowed to read from a version 3 value. Version 3 can read version 2 without issue.
Joshua Bell
Comment 6 2013-01-23 09:29:47 PST
(In reply to comment #5) > jsbell, alecflett: just to clarify what will happen. Once V8_ONE_BYTE_STRINGS_ENABLED is defined in v8, one byte strings will now potentially have payloads with bytes > 0xf. This was previously impossible, so a version 2 SSV should not be allowed to read from a version 3 value. Version 3 can read version 2 without issue. Thanks. Conceptually, this looks correct. There is a problem, though - this conceptually *removes* test coverage for parsing v2 SSVs, since with this patch and once the new flag is defined, the test will only exercise parsing v3 SSVs. You'll need to add tests that use the (optional) oldFormat param of _testSerialization and explicitly test 0x02ff, or expand testSerialization() to insert the version prefix since most v2 and v3 SSVs will serialize identically. I'm not sure which is better. Or perhaps oldFormat should turn into a map of version/serializations? Not sure what is best here. (alecflett's not going to be able to look at this until tomorrow, unfortunately.)
Dan Carney
Comment 7 2013-01-23 10:15:33 PST
(In reply to comment #6) > (In reply to comment #5) > > jsbell, alecflett: just to clarify what will happen. Once V8_ONE_BYTE_STRINGS_ENABLED is defined in v8, one byte strings will now potentially have payloads with bytes > 0xf. This was previously impossible, so a version 2 SSV should not be allowed to read from a version 3 value. Version 3 can read version 2 without issue. > > Thanks. Conceptually, this looks correct. > > There is a problem, though - this conceptually *removes* test coverage for parsing v2 SSVs, since with this patch and once the new flag is defined, the test will only exercise parsing v3 SSVs. > > You'll need to add tests that use the (optional) oldFormat param of _testSerialization and explicitly test 0x02ff, or expand testSerialization() to insert the version prefix since most v2 and v3 SSVs will serialize identically. I'm not sure which is better. Or perhaps oldFormat should turn into a map of version/serializations? Not sure what is best here. > > (alecflett's not going to be able to look at this until tomorrow, unfortunately.) Good point. I'll work something into the test to test both v2 and v3, including something that differs between v2 and v3.
Dan Carney
Comment 8 2013-01-24 05:34:49 PST
Dan Carney
Comment 9 2013-01-24 05:37:41 PST
After looking into it, I realized that only utf8 and two byte strings are supported by the current system. I've adjusted the patch to handle this, without needing to bump the version. It comes at a performance cost, but once v8 latin-1 support is stable, I'll implement a version 3 SSV which handles one byte strings directly, without the need to unnecessarily jump in and out of utf8.
Alec Flett
Comment 10 2013-01-24 10:47:59 PST
Yes, the test should be purely additive - all existing tests should remain or be tweaked to indicate that its testing an old version (to avoid the bidirectional serialization tests for those) (The "old version" parameter should probably be tweaked to take a list of old versioned data, so we can keep adding to the test with each subsequent version)
WebKit Review Bot
Comment 11 2013-01-24 18:24:50 PST
Comment on attachment 184470 [details] Patch Attachment 184470 [details] did not pass chromium-ews (chromium-xvfb): Output: http://queues.webkit.org/results/16119005 New failing tests: inspector-protocol/debugger-terminate-dedicated-worker-while-paused.html
Kentaro Hara
Comment 12 2013-01-25 00:28:16 PST
jsbell: Does it look fine?
Build Bot
Comment 13 2013-01-25 00:43:16 PST
Comment on attachment 184470 [details] Patch Attachment 184470 [details] did not pass mac-wk2-ews (mac-wk2): Output: http://queues.webkit.org/results/16112351 New failing tests: svg/as-image/img-preserveAspectRatio-support-2.html
Joshua Bell
Comment 14 2013-01-25 07:51:57 PST
Comment on attachment 184470 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=184470&action=review Looks fine to me. > Source/WebCore/bindings/v8/SerializedScriptValue.cpp:324 > + ensureSpace(utf8Length); Could move this up and use ensureSpace(sizeof(StringTag) + sizeof(uint32_t) + utf8Length) (probably premature optimization, though)
Kentaro Hara
Comment 15 2013-01-25 16:48:21 PST
Comment on attachment 184470 [details] Patch Please apply jsbell's comment before landing.
Dan Carney
Comment 16 2013-01-26 07:33:08 PST
(In reply to comment #15) > (From update of attachment 184470 [details]) > Please apply jsbell's comment before landing. kentaro, I'm marking this cq? for now as I have no access to a dev environment this weekend. I have to do a bunch of optimization in this class after latin-1 is stable in v8, so I'll apply jsbell's optimization there instead.
WebKit Review Bot
Comment 17 2013-01-26 08:10:11 PST
Comment on attachment 184470 [details] Patch Clearing flags on attachment: 184470 Committed r140911: <http://trac.webkit.org/changeset/140911>
WebKit Review Bot
Comment 18 2013-01-26 08:10:15 PST
All reviewed patches have been landed. Closing bug.
noel gordon
Comment 19 2013-06-11 00:49:46 PDT
(In reply to comment #9) > After looking into it, I realized that only utf8 and two byte strings are supported by the current system. huh? > I've adjusted the patch to handle this, without needing to bump the version. It comes at a performance cost, but once v8 latin-1 support is stable, I'll implement a version 3 SSV which handles one byte strings directly, without the need to unnecessarily jump in and out of utf8. And did we file about that somewhere?
Ryosuke Niwa
Comment 20 2013-06-11 01:14:05 PDT
This bug is clearly dead since we've removed V8 from WebKit.
noel gordon
Comment 21 2013-06-11 19:23:45 PDT
Remove yourself from the bug then, seeing as it's dead to you.
Note You need to log in before you can comment on or make changes to this bug.