Commit 63dc18c0 authored by pthier's avatar pthier Committed by Commit Bot

[csa] Optional data_type out-parameter for GetSharedFunctionInfoCode()

Using an out-parameter for the SFI data type in
GetSharedFunctionInfoCode() avoids loading the CodeKind in
CompileLazy().

Bug: v8:11429
Change-Id: Ib8eccdf6d169cce28a9ff50bb415447b61ad71a9
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2715197
Auto-Submit: Patrick Thier <pthier@chromium.org>
Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
Commit-Queue: Patrick Thier <pthier@chromium.org>
Cr-Commit-Position: refs/heads/master@{#73073}
parent d61c64b2
......@@ -116,7 +116,9 @@ void LazyBuiltinsAssembler::CompileLazy(TNode<JSFunction> function) {
// feedback vector marker.
TNode<SharedFunctionInfo> shared =
CAST(LoadObjectField(function, JSFunction::kSharedFunctionInfoOffset));
TNode<Code> sfi_code = GetSharedFunctionInfoCode(shared, &compile_function);
TVARIABLE(Uint16T, sfi_data_type);
TNode<Code> sfi_code =
GetSharedFunctionInfoCode(shared, &sfi_data_type, &compile_function);
TNode<HeapObject> feedback_cell_value = LoadFeedbackCellValue(function);
......@@ -149,14 +151,8 @@ void LazyBuiltinsAssembler::CompileLazy(TNode<JSFunction> function) {
TVARIABLE(Code, code);
// Check if we have baseline code.
// TODO(v8:11429): We already know if we have baseline code in
// GetSharedFunctionInfoCode, make that jump to here.
TNode<Uint32T> code_flags =
LoadObjectField<Uint32T>(sfi_code, Code::kFlagsOffset);
TNode<Uint32T> code_kind = DecodeWord32<Code::KindField>(code_flags);
TNode<BoolT> is_baseline =
IsEqualInWord32<Code::KindField>(code_kind, CodeKind::BASELINE);
GotoIf(is_baseline, &baseline);
GotoIf(InstanceTypeEqual(sfi_data_type.value(), BASELINE_DATA_TYPE),
&baseline);
// Finally, check for presence of an NCI cached Code object - if an entry
// possibly exists, call into runtime to query the cache.
......
......@@ -13435,7 +13435,8 @@ TNode<Code> CodeStubAssembler::LoadBuiltin(TNode<Smi> builtin_id) {
}
TNode<Code> CodeStubAssembler::GetSharedFunctionInfoCode(
TNode<SharedFunctionInfo> shared_info, Label* if_compile_lazy) {
TNode<SharedFunctionInfo> shared_info, TVariable<Uint16T>* data_type_out,
Label* if_compile_lazy) {
TNode<Object> sfi_data =
LoadObjectField(shared_info, SharedFunctionInfo::kFunctionDataOffset);
......@@ -13446,6 +13447,9 @@ TNode<Code> CodeStubAssembler::GetSharedFunctionInfoCode(
// IsSmi: Is builtin
GotoIf(TaggedIsNotSmi(sfi_data), &check_instance_type);
if (data_type_out) {
*data_type_out = Uint16Constant(0);
}
if (if_compile_lazy) {
GotoIf(SmiEqual(CAST(sfi_data), SmiConstant(Builtins::kCompileLazy)),
if_compile_lazy);
......@@ -13456,6 +13460,9 @@ TNode<Code> CodeStubAssembler::GetSharedFunctionInfoCode(
// Switch on data's instance type.
BIND(&check_instance_type);
TNode<Uint16T> data_type = LoadInstanceType(CAST(sfi_data));
if (data_type_out) {
*data_type_out = data_type;
}
int32_t case_values[] = {BYTECODE_ARRAY_TYPE,
BASELINE_DATA_TYPE,
......
......@@ -3487,10 +3487,15 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
TNode<Code> LoadBuiltin(TNode<Smi> builtin_id);
// Figure out the SFI's code object using its data field.
// If |data_type_out| is provided, the instance type of the function data will
// be stored in it. In case the code object is a builtin (data is a Smi),
// data_type_out will be set to 0.
// If |if_compile_lazy| is provided then the execution will go to the given
// label in case of an CompileLazy code object.
TNode<Code> GetSharedFunctionInfoCode(TNode<SharedFunctionInfo> shared_info,
Label* if_compile_lazy = nullptr);
TNode<Code> GetSharedFunctionInfoCode(
TNode<SharedFunctionInfo> shared_info,
TVariable<Uint16T>* data_type_out = nullptr,
Label* if_compile_lazy = nullptr);
TNode<JSFunction> AllocateFunctionWithMapAndContext(
TNode<Map> map, TNode<SharedFunctionInfo> shared_info,
......
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