From 26609973314d2f0e2c419173094002c360f9c37e Mon Sep 17 00:00:00 2001 From: Camillo Bruni Date: Tue, 24 Aug 2021 11:51:51 +0200 Subject: [PATCH] [codegen] Assert that deserialized SFIs have correct origins Re-use the same check we already have in place for the compilation cache for when we use CodeSerializer::Deserialize. - Move HasOrigin to SharedFunctionInfo::HasMatchingOrigin - HasMatchingOrigin no longer allocates - Pass ScriptDetails in more places Bug: v8:10284 Change-Id: I6e074bd1e7db9a35fdf7123d04a65841d9813e02 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3090968 Commit-Queue: Camillo Bruni Reviewed-by: Leszek Swirski Cr-Commit-Position: refs/heads/main@{#76451} --- src/codegen/compilation-cache.cc | 41 +------------- src/codegen/compiler.cc | 19 ++++--- src/codegen/compiler.h | 2 +- src/codegen/script-details.h | 2 + src/objects/shared-function-info.cc | 58 +++++++++++++++++++ src/objects/shared-function-info.h | 19 ++++--- src/snapshot/code-serializer.cc | 87 +++++++++++++++++++++++------ src/snapshot/code-serializer.h | 12 ++-- test/cctest/heap/test-heap.cc | 9 +-- test/cctest/test-log.cc | 1 + test/cctest/test-serialize.cc | 4 +- 11 files changed, 173 insertions(+), 81 deletions(-) diff --git a/src/codegen/compilation-cache.cc b/src/codegen/compilation-cache.cc index fc054f6b5b..f299e5c20a 100644 --- a/src/codegen/compilation-cache.cc +++ b/src/codegen/compilation-cache.cc @@ -105,41 +105,6 @@ void CompilationSubCache::Remove(Handle function_info) { CompilationCacheScript::CompilationCacheScript(Isolate* isolate) : CompilationSubCache(isolate, 1) {} -namespace { - -// We only re-use a cached function for some script source code if the -// script originates from the same place. This is to avoid issues -// when reporting errors, etc. -bool HasOrigin(Isolate* isolate, Handle function_info, - const ScriptDetails& script_details) { - Handle