Commit 046b58d6 authored by Igor Sheludko's avatar Igor Sheludko Committed by V8 LUCI CQ

[ext-code-space] Migrate Baseline/InterpreterData's code fields to CodeT

This CL migrates BaselineData::baseline_code field and
InterpreterData::interpreter_trampoline field to CodeT.

Bug: v8:11880
Change-Id: Ibd202f0dcd4266e5b98aa5c46754ba8a4fadff43
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2968415Reviewed-by: 's avatarToon Verwaest <verwaest@chromium.org>
Commit-Queue: Igor Sheludko <ishell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#75233}
parent 8d24d68c
......@@ -1351,11 +1351,6 @@ void Builtins::Generate_InterpreterEntryTrampoline(MacroAssembler* masm) {
__ LoadTaggedPointerField(rcx,
FieldOperand(kInterpreterBytecodeArrayRegister,
BaselineData::kBaselineCodeOffset));
if (V8_EXTERNAL_CODE_SPACE_BOOL) {
// At this point |rcx| is still Code object, so "convert" it to CodeT.
__ LoadTaggedPointerField(
rcx, FieldOperand(rcx, Code::kCodeDataContainerOffset));
}
static_assert(kJavaScriptCallCodeStartRegister == rcx, "ABI mismatch");
ReplaceClosureCodeWithOptimizedCode(
masm, rcx, closure, kInterpreterBytecodeArrayRegister,
......@@ -1544,7 +1539,11 @@ static void Generate_InterpreterEnterBytecode(MacroAssembler* masm) {
__ LoadTaggedPointerField(
rbx, FieldOperand(rbx, InterpreterData::kInterpreterTrampolineOffset));
__ addq(rbx, Immediate(Code::kHeaderSize - kHeapObjectTag));
if (V8_EXTERNAL_CODE_SPACE_BOOL) {
__ LoadCodeDataContainerEntry(rbx, rbx);
} else {
__ addq(rbx, Immediate(Code::kHeaderSize - kHeapObjectTag));
}
__ jmp(&trampoline_loaded, Label::kNear);
__ bind(&builtin_trampoline);
......@@ -4433,6 +4432,9 @@ void Generate_BaselineEntry(MacroAssembler* masm, bool next_bytecode,
FieldOperand(code_obj, SharedFunctionInfo::kFunctionDataOffset));
__ LoadTaggedPointerField(
code_obj, FieldOperand(code_obj, BaselineData::kBaselineCodeOffset));
if (V8_EXTERNAL_CODE_SPACE_BOOL) {
__ LoadCodeDataContainerCodeNonBuiltin(code_obj, code_obj);
}
// Compute baseline pc for bytecode offset.
ExternalReference get_baseline_pc_extref;
......
......@@ -14240,11 +14240,11 @@ TNode<Code> CodeStubAssembler::GetSharedFunctionInfoCode(
// IsBaselineData: Execute baseline code
BIND(&check_is_baseline_data);
TNode<BaselineData> baseline_data = CAST(sfi_data);
TNode<Code> baseline_code =
CAST(LoadObjectField(baseline_data, BaselineData::kBaselineCodeOffset));
sfi_code = baseline_code;
Goto(&done);
{
TNode<CodeT> baseline_code = LoadBaselineDataBaselineCode(CAST(sfi_data));
sfi_code = FromCodeT(baseline_code);
Goto(&done);
}
// IsUncompiledDataWithPreparseData | IsUncompiledDataWithoutPreparseData:
// Compile lazy
......@@ -14264,8 +14264,11 @@ TNode<Code> CodeStubAssembler::GetSharedFunctionInfoCode(
// This is the default branch, so assert that we have the expected data type.
CSA_ASSERT(this,
Word32Equal(data_type, Int32Constant(INTERPRETER_DATA_TYPE)));
sfi_code = CAST(LoadObjectField(
CAST(sfi_data), InterpreterData::kInterpreterTrampolineOffset));
{
TNode<CodeT> trampoline =
LoadInterpreterDataInterpreterTrampoline(CAST(sfi_data));
sfi_code = FromCodeT(trampoline);
}
Goto(&done);
#if V8_ENABLE_WEBASSEMBLY
......@@ -14288,6 +14291,7 @@ TNode<Code> CodeStubAssembler::GetSharedFunctionInfoCode(
TNode<JSFunction> CodeStubAssembler::AllocateFunctionWithMapAndContext(
TNode<Map> map, TNode<SharedFunctionInfo> shared_info,
TNode<Context> context) {
// TODO(v8:11880): avoid roundtrips between cdc and code.
const TNode<Code> code = GetSharedFunctionInfoCode(shared_info);
// TODO(ishell): All the callers of this function pass map loaded from
......
......@@ -98,9 +98,18 @@ OBJECT_CONSTRUCTORS_IMPL(InterpreterData, Struct)
CAST_ACCESSOR(InterpreterData)
ACCESSORS(InterpreterData, bytecode_array, BytecodeArray, kBytecodeArrayOffset)
ACCESSORS(InterpreterData, interpreter_trampoline, Code,
ACCESSORS(InterpreterData, raw_interpreter_trampoline, CodeT,
kInterpreterTrampolineOffset)
DEF_GETTER(InterpreterData, interpreter_trampoline, Code) {
return FromCodeT(raw_interpreter_trampoline(cage_base));
}
void InterpreterData::set_interpreter_trampoline(Code code,
WriteBarrierMode mode) {
set_raw_interpreter_trampoline(ToCodeT(code), mode);
}
TQ_OBJECT_CONSTRUCTORS_IMPL(SharedFunctionInfo)
NEVER_READ_ONLY_SPACE_IMPL(SharedFunctionInfo)
DEFINE_DEOPT_ELEMENT_ACCESSORS(SharedFunctionInfo, Object)
......@@ -504,6 +513,14 @@ BytecodeArray SharedFunctionInfo::GetBytecodeArray(IsolateT* isolate) const {
return GetActiveBytecodeArray();
}
DEF_GETTER(BaselineData, baseline_code, Code) {
return FromCodeT(TorqueGeneratedClass::baseline_code(cage_base));
}
void BaselineData::set_baseline_code(Code code, WriteBarrierMode mode) {
return TorqueGeneratedClass::set_baseline_code(ToCodeT(code), mode);
}
BytecodeArray BaselineData::GetActiveBytecodeArray() const {
Object data = this->data();
if (data.IsBytecodeArray()) {
......
......@@ -153,6 +153,9 @@ class InterpreterData : public Struct {
DECL_PRINTER(InterpreterData)
DECL_VERIFIER(InterpreterData)
private:
DECL_ACCESSORS(raw_interpreter_trampoline, CodeT)
OBJECT_CONSTRUCTORS(InterpreterData, Struct);
};
......@@ -161,6 +164,8 @@ class BaselineData : public TorqueGeneratedBaselineData<BaselineData, Struct> {
inline BytecodeArray GetActiveBytecodeArray() const;
inline void SetActiveBytecodeArray(BytecodeArray bytecode);
DECL_ACCESSORS(baseline_code, Code)
TQ_OBJECT_CONSTRUCTORS(BaselineData)
};
......
......@@ -11,13 +11,15 @@ extern class PreparseData extends HeapObject {
extern class InterpreterData extends Struct {
bytecode_array: BytecodeArray;
interpreter_trampoline: Code;
@if(V8_EXTERNAL_CODE_SPACE) interpreter_trampoline: CodeDataContainer;
@ifnot(V8_EXTERNAL_CODE_SPACE) interpreter_trampoline: Code;
}
@generateCppClass
@generatePrint
extern class BaselineData extends Struct {
baseline_code: Code;
@if(V8_EXTERNAL_CODE_SPACE) baseline_code: CodeDataContainer;
@ifnot(V8_EXTERNAL_CODE_SPACE) baseline_code: Code;
data: BytecodeArray|InterpreterData;
}
......
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