Commit 0ba4c8d4 authored by Leszek Swirski's avatar Leszek Swirski Committed by Commit Bot

[offthread] Walk script SFIs to ensure source positions.

Rather than walking SharedFunctionInfos recursively via bytecode
constant pools to ensure they have source positions, walk the script's
shared function info list.

Bug: chromium:1011762
Change-Id: I19ab0f3355dc8169f7a0170b4198075bd3823c04
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2084816
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Auto-Submit: Leszek Swirski <leszeks@chromium.org>
Reviewed-by: 's avatarRoss McIlroy <rmcilroy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#66571}
parent 1ed46983
...@@ -39,6 +39,7 @@ ...@@ -39,6 +39,7 @@
#include "src/objects/feedback-cell-inl.h" #include "src/objects/feedback-cell-inl.h"
#include "src/objects/map.h" #include "src/objects/map.h"
#include "src/objects/object-list-macros.h" #include "src/objects/object-list-macros.h"
#include "src/objects/shared-function-info.h"
#include "src/parsing/parse-info.h" #include "src/parsing/parse-info.h"
#include "src/parsing/parser.h" #include "src/parsing/parser.h"
#include "src/parsing/parsing.h" #include "src/parsing/parsing.h"
...@@ -2345,28 +2346,6 @@ MaybeHandle<JSFunction> Compiler::GetWrappedFunction( ...@@ -2345,28 +2346,6 @@ MaybeHandle<JSFunction> Compiler::GetWrappedFunction(
wrapped, context, AllocationType::kYoung); wrapped, context, AllocationType::kYoung);
} }
namespace {
void RecursivelyEnsureSourcePositionsAvailable(
Isolate* isolate, Handle<SharedFunctionInfo> shared_info) {
SharedFunctionInfo::EnsureSourcePositionsAvailable(isolate, shared_info);
if (shared_info->HasBytecodeArray()) {
Handle<FixedArray> constant_pool(
shared_info->GetBytecodeArray().constant_pool(isolate), isolate);
int length = constant_pool->length();
FOR_WITH_HANDLE_SCOPE(isolate, int, i = 0, i, i < length, i++, {
Object entry = constant_pool->get(isolate, i);
if (entry.IsSharedFunctionInfo(isolate)) {
RecursivelyEnsureSourcePositionsAvailable(
isolate, handle(SharedFunctionInfo::cast(entry), isolate));
}
});
}
}
} // namespace
MaybeHandle<SharedFunctionInfo> MaybeHandle<SharedFunctionInfo>
Compiler::GetSharedFunctionInfoForStreamedScript( Compiler::GetSharedFunctionInfoForStreamedScript(
Isolate* isolate, Handle<String> source, Isolate* isolate, Handle<String> source,
...@@ -2413,12 +2392,23 @@ Compiler::GetSharedFunctionInfoForStreamedScript( ...@@ -2413,12 +2392,23 @@ Compiler::GetSharedFunctionInfoForStreamedScript(
origin_options, NOT_NATIVES_CODE); origin_options, NOT_NATIVES_CODE);
// It's possible that source position collection was enabled after the // It's possible that source position collection was enabled after the
// background compile was started in which the compiled bytecode will not // background compile was started (for instance by enabling the cpu
// be missing source positions (for instance by enabling the cpu // profiler), and the compiled bytecode is missing source positions. So,
// profiler). So force source position collection now in that case. // walk all the SharedFunctionInfos in the script and force source
// position collection.
if (!task->collected_source_positions() && if (!task->collected_source_positions() &&
isolate->NeedsDetailedOptimizedCodeLineInfo()) { isolate->NeedsDetailedOptimizedCodeLineInfo()) {
RecursivelyEnsureSourcePositionsAvailable(isolate, sfi); Handle<WeakFixedArray> shared_function_infos(
script->shared_function_infos(isolate), isolate);
int length = shared_function_infos->length();
FOR_WITH_HANDLE_SCOPE(isolate, int, i = 0, i, i < length, i++, {
Object entry = shared_function_infos->Get(isolate, i)
.GetHeapObjectOrSmi(isolate);
if (entry.IsSharedFunctionInfo(isolate)) {
SharedFunctionInfo::EnsureSourcePositionsAvailable(
isolate, handle(SharedFunctionInfo::cast(entry), isolate));
}
});
} }
maybe_result = sfi; maybe_result = sfi;
......
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