Commit 2c36f81b authored by Adam Rice's avatar Adam Rice Committed by Commit Bot

Streams: Put binding originals behind a flag

Copying MessageChannel and other functions to the binding object caused
a memory regression. As a temporary workaround, only copy them to the
binding object when the TransferableStreams feature is enabled.

BUG=897046,900141,899637

Change-Id: If312f2e0967a19e9db427f60125d96c48d45fdc7
Reviewed-on: https://chromium-review.googlesource.com/c/1307534Reviewed-by: default avatarYuki Shiino <yukishiino@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Reviewed-by: default avatarYutaka Hirano <yhirano@chromium.org>
Commit-Queue: Adam Rice <ricea@chromium.org>
Cr-Commit-Position: refs/heads/master@{#604178}
parent 656eb711
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include "third_party/blink/renderer/platform/bindings/to_v8.h" #include "third_party/blink/renderer/platform/bindings/to_v8.h"
#include "third_party/blink/renderer/platform/bindings/v8_binding.h" #include "third_party/blink/renderer/platform/bindings/v8_binding.h"
#include "third_party/blink/renderer/platform/bindings/v8_throw_exception.h" #include "third_party/blink/renderer/platform/bindings/v8_throw_exception.h"
#include "third_party/blink/renderer/platform/runtime_enabled_features.h"
#include "v8/include/v8.h" #include "v8/include/v8.h"
namespace blink { namespace blink {
...@@ -87,6 +88,10 @@ void AddCountUse(ScriptState* script_state, v8::Local<v8::Object> binding) { ...@@ -87,6 +88,10 @@ void AddCountUse(ScriptState* script_state, v8::Local<v8::Object> binding) {
} }
void AddOriginals(ScriptState* script_state, v8::Local<v8::Object> binding) { void AddOriginals(ScriptState* script_state, v8::Local<v8::Object> binding) {
// These values are only used when serialization is enabled.
if (!RuntimeEnabledFeatures::TransferableStreamsEnabled())
return;
v8::Local<v8::Object> global = script_state->GetContext()->Global(); v8::Local<v8::Object> global = script_state->GetContext()->Global();
v8::Local<v8::Context> context = script_state->GetContext(); v8::Local<v8::Context> context = script_state->GetContext();
v8::Isolate* isolate = script_state->GetIsolate(); v8::Isolate* isolate = script_state->GetIsolate();
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "third_party/blink/renderer/core/streams/underlying_source_base.h" #include "third_party/blink/renderer/core/streams/underlying_source_base.h"
#include "third_party/blink/renderer/platform/bindings/exception_state.h" #include "third_party/blink/renderer/platform/bindings/exception_state.h"
#include "third_party/blink/renderer/platform/bindings/script_state.h" #include "third_party/blink/renderer/platform/bindings/script_state.h"
#include "third_party/blink/renderer/platform/runtime_enabled_features.h"
#include "third_party/blink/renderer/platform/wtf/assertions.h" #include "third_party/blink/renderer/platform/wtf/assertions.h"
namespace blink { namespace blink {
...@@ -271,6 +272,7 @@ MessagePort* ReadableStreamOperations::ReadableStreamSerialize( ...@@ -271,6 +272,7 @@ MessagePort* ReadableStreamOperations::ReadableStreamSerialize(
ScriptValue stream, ScriptValue stream,
ExceptionState& exception_state) { ExceptionState& exception_state) {
DCHECK(IsReadableStreamForDCheck(script_state, stream)); DCHECK(IsReadableStreamForDCheck(script_state, stream));
DCHECK(RuntimeEnabledFeatures::TransferableStreamsEnabled());
v8::TryCatch block(script_state->GetIsolate()); v8::TryCatch block(script_state->GetIsolate());
v8::Local<v8::Value> args[] = {stream.V8Value()}; v8::Local<v8::Value> args[] = {stream.V8Value()};
ScriptValue result( ScriptValue result(
...@@ -297,6 +299,7 @@ ScriptValue ReadableStreamOperations::ReadableStreamDeserialize( ...@@ -297,6 +299,7 @@ ScriptValue ReadableStreamOperations::ReadableStreamDeserialize(
MessagePort* port, MessagePort* port,
ExceptionState& exception_state) { ExceptionState& exception_state) {
DCHECK(port); DCHECK(port);
DCHECK(RuntimeEnabledFeatures::TransferableStreamsEnabled());
auto* isolate = script_state->GetIsolate(); auto* isolate = script_state->GetIsolate();
v8::Local<v8::Context> context = script_state->GetContext(); v8::Local<v8::Context> context = script_state->GetContext();
v8::Local<v8::Value> port_v8 = ToV8(port, context->Global(), isolate); v8::Local<v8::Value> port_v8 = ToV8(port, context->Global(), isolate);
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include "third_party/blink/renderer/platform/bindings/v8_binding_macros.h" #include "third_party/blink/renderer/platform/bindings/v8_binding_macros.h"
#include "third_party/blink/renderer/platform/bindings/v8_throw_exception.h" #include "third_party/blink/renderer/platform/bindings/v8_throw_exception.h"
#include "third_party/blink/renderer/platform/heap/handle.h" #include "third_party/blink/renderer/platform/heap/handle.h"
#include "third_party/blink/renderer/platform/runtime_enabled_features.h"
#include "third_party/blink/renderer/platform/testing/unit_test_helpers.h" #include "third_party/blink/renderer/platform/testing/unit_test_helpers.h"
#include "v8/include/v8.h" #include "v8/include/v8.h"
...@@ -494,6 +495,8 @@ TEST(ReadableStreamOperationsTest, Tee) { ...@@ -494,6 +495,8 @@ TEST(ReadableStreamOperationsTest, Tee) {
} }
TEST(ReadableStreamOperationsTest, Serialize) { TEST(ReadableStreamOperationsTest, Serialize) {
RuntimeEnabledFeatures::SetTransferableStreamsEnabled(true);
V8TestingScope scope; V8TestingScope scope;
TryCatchScope try_catch_scope(scope.GetIsolate()); TryCatchScope try_catch_scope(scope.GetIsolate());
ScriptValue original = EvalWithPrintingError(&scope, ScriptValue original = EvalWithPrintingError(&scope,
......
...@@ -1256,6 +1256,9 @@ ...@@ -1256,6 +1256,9 @@
{ {
name: "TrackLayoutPassesPerBlock", name: "TrackLayoutPassesPerBlock",
}, },
{
name: "TransferableStreams",
},
{ {
name: "TrustedDOMTypes", name: "TrustedDOMTypes",
status: "experimental", status: "experimental",
......
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