Commit baace4d9 authored by Andreas Haas's avatar Andreas Haas Committed by Commit Bot

[wasm] Fix wasm_downgrade_test

The wasm_downgrade_test uses special testing functions which allow to
serialize and deserialize a WebAssembly module. The deserialization
function takes a DOMArrayBuffer as parameter, converts it into a String,
and then uses the String to create a SerializedScriptValue. However,
if the length of the DOMArrayBuffer is not even, one byte gets lost
in the conversion to a String. With this CL we create the
SerializedScriptValue directly from the DOMArrayBuffer, and thereby
guarantee that all bytes from the DOMArrayBuffer are copied into the
SerializedScriptValue.

The bug caused by the conversion to a String was hiding another bug
which I'm currently fixing in V8. As soon as the fix in V8 rolled to
Chrome, we can continue with this CL.

R=binji@chromium.org, pkasting@chromium.org

Change-Id: I65b35676b764cd3d64c437b331510897b032b33b
Reviewed-on: https://chromium-review.googlesource.com/1006962Reviewed-by: default avatarJeremy Roman <jbroman@chromium.org>
Reviewed-by: default avatarBen Smith <binji@chromium.org>
Commit-Queue: Andreas Haas <ahaas@chromium.org>
Cr-Commit-Position: refs/heads/master@{#551002}
parent ec5cb40c
......@@ -2836,9 +2836,8 @@ DOMArrayBuffer* Internals::serializeObject(
scoped_refptr<SerializedScriptValue> Internals::deserializeBuffer(
DOMArrayBuffer* buffer) const {
String value(static_cast<const UChar*>(buffer->Data()),
buffer->ByteLength() / sizeof(UChar));
return SerializedScriptValue::Create(value);
return SerializedScriptValue::Create(static_cast<const char*>(buffer->Data()),
buffer->ByteLength());
}
DOMArrayBuffer* Internals::serializeWithInlineWasm(ScriptValue value) const {
......@@ -2858,14 +2857,11 @@ DOMArrayBuffer* Internals::serializeWithInlineWasm(ScriptValue value) const {
ScriptValue Internals::deserializeBufferContainingWasm(
ScriptState* state,
DOMArrayBuffer* buffer) const {
String value(static_cast<const UChar*>(buffer->Data()),
buffer->ByteLength() / sizeof(UChar));
DummyExceptionStateForTesting exception_state;
SerializedScriptValue::DeserializeOptions options;
options.read_wasm_from_stream = true;
return ScriptValue::From(state,
SerializedScriptValue::Create(value)->Deserialize(
state->GetIsolate(), options));
return ScriptValue::From(state, deserializeBuffer(buffer)->Deserialize(
state->GetIsolate(), options));
}
void Internals::forceReload(bool bypass_cache) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment