Commit 79095dfe authored by Andreas Haas's avatar Andreas Haas Committed by Commit Bot

[message-event] Unregister external memory earlier

Apparently https://crrev.com/c/2044272 caused double accounting of
memory in the GC, which lead to an increased number of garbage
collection runs. With this CL the external memory is unregistered once
it is moved on the GC heap.

R=haraken@chromium.org

Bug: 1054347
Change-Id: I49a6bdd593298776bad9116d34793b1eec05dafe
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2066733
Commit-Queue: Andreas Haas <ahaas@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Reviewed-by: default avatarUlan Degenbaev <ulan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#744648}
parent 6bf41b0a
......@@ -85,6 +85,7 @@ void MessageEvent::UnregisterAmountOfExternallyAllocatedMemory() {
if (amount_of_external_memory_ > 0) {
v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(
-static_cast<int64_t>(amount_of_external_memory_));
amount_of_external_memory_ = 0;
}
}
......@@ -316,6 +317,10 @@ ScriptValue MessageEvent::data(ScriptState* script_state) {
case MessageEvent::kDataTypeSerializedScriptValue:
if (data_as_serialized_script_value_) {
// The data is put on the V8 GC heap here, and therefore the V8 GC does
// the accounting from here on. We unregister the registered memory to
// avoid double accounting.
UnregisterAmountOfExternallyAllocatedMemory();
MessagePortArray message_ports = ports();
SerializedScriptValue::DeserializeOptions options;
options.message_ports = &message_ports;
......
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