From 084d472f5104c6da996a3dd19fb8816dfb02ceec Mon Sep 17 00:00:00 2001 From: Leszek Swirski Date: Mon, 9 Jul 2018 10:40:26 +0100 Subject: [PATCH] [liveedit] Patch changed SFIs' constant pools When live edit patches a script, it distinguishes between 'changed' and 'unchanged' functions, and unchanged functions have their position and source script patched to the new script instead of being replaced by a new SFI. However, if a 'changed' function has an inner 'unchanged' function, it also holds a pointer to the inner function in its bytecode constant pool. This constant pool entry was not being updated for changed functions (it was for unchanged), and therefore the outer changed function would compile the redundant new function instead of the old, patched, unchanged function. This patch fixes this by patching 'changed' functions' bytecode constant pools. This is done by swapping the script and script function list position of the old new and old 'unchanged' function, rather than just setting the script (and position) on the old one, and using the new function (now pointing at the old script) to read off the old function literal id. This could also be done by reading the function_literal_id off the new function, but we are soon removing that field anyway. Cq-Include-Trybots: luci.chromium.try:linux_chromium_rel_ng Change-Id: Ib22078c06539c795b418d29a493d8224ecea182e Reviewed-on: https://chromium-review.googlesource.com/1127941 Reviewed-by: Yang Guo Reviewed-by: Aleksey Kozyatinskiy Commit-Queue: Leszek Swirski Cr-Commit-Position: refs/heads/master@{#54321} --- src/debug/liveedit.cc | 89 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 85 insertions(+), 4 deletions(-) diff --git a/src/debug/liveedit.cc b/src/debug/liveedit.cc index cd3f0d32cb..dd0eeeecee 100644 --- a/src/debug/liveedit.cc +++ b/src/debug/liveedit.cc @@ -1046,6 +1046,7 @@ void LiveEdit::PatchScript(Isolate* isolate, Handle