From ac0c19b623cdf30c42c5893379a05d555cc2722c Mon Sep 17 00:00:00 2001 From: Leszek Swirski Date: Wed, 18 Jul 2018 16:50:15 +0100 Subject: [PATCH] [liveedit] Use start position in function lookup Instead of looking up functions by their function literal id (which can be slow now that function id involves a linear search for compiled functions), we key the lookup by the function's start position. This means that the script+literal id swapping to find equivalent unchanged functions during constant pool patching no longer works -- we could replace it by fixing up the start position of the redundant new function, but instead we just build up a side-table mapping (new) start positions to function literal ids, and use that function literal id to find the old function in the script's SFI list. Change-Id: I10bfce6c39665cba063e0ddbc8fd38a6f5fd5513 Reviewed-on: https://chromium-review.googlesource.com/1140169 Reviewed-by: Aleksey Kozyatinskiy Reviewed-by: Yang Guo Commit-Queue: Leszek Swirski Cr-Commit-Position: refs/heads/master@{#54542} --- src/debug/liveedit.cc | 144 +++++++++++++++++++++++------------------- 1 file changed, 78 insertions(+), 66 deletions(-) diff --git a/src/debug/liveedit.cc b/src/debug/liveedit.cc index 0c3fa983fb..6322bf430f 100644 --- a/src/debug/liveedit.cc +++ b/src/debug/liveedit.cc @@ -804,22 +804,22 @@ class FunctionDataMap : public ThreadVisitor { public: void AddInterestingLiteral(int script_id, FunctionLiteral* literal, bool should_restart) { - map_.emplace(std::make_pair(script_id, literal->function_literal_id()), + map_.emplace(GetFuncId(script_id, literal), FunctionData{literal, should_restart}); } - bool Lookup(Isolate* isolate, SharedFunctionInfo* sfi, FunctionData** data) { - int function_literal_id = sfi->FunctionLiteralId(isolate); - if (!sfi->script()->IsScript() || function_literal_id == -1) { + bool Lookup(SharedFunctionInfo* sfi, FunctionData** data) { + int start_position = sfi->StartPosition(); + if (!sfi->script()->IsScript() || start_position == -1) { return false; } Script* script = Script::cast(sfi->script()); - return Lookup(script->id(), function_literal_id, data); + return Lookup(GetFuncId(script->id(), sfi), data); } bool Lookup(Handle