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) { ...@@ -1351,11 +1351,6 @@ void Builtins::Generate_InterpreterEntryTrampoline(MacroAssembler* masm) {
__ LoadTaggedPointerField(rcx, __ LoadTaggedPointerField(rcx,
FieldOperand(kInterpreterBytecodeArrayRegister, FieldOperand(kInterpreterBytecodeArrayRegister,
BaselineData::kBaselineCodeOffset)); 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"); static_assert(kJavaScriptCallCodeStartRegister == rcx, "ABI mismatch");
ReplaceClosureCodeWithOptimizedCode( ReplaceClosureCodeWithOptimizedCode(
masm, rcx, closure, kInterpreterBytecodeArrayRegister, masm, rcx, closure, kInterpreterBytecodeArrayRegister,
...@@ -1544,7 +1539,11 @@ static void Generate_InterpreterEnterBytecode(MacroAssembler* masm) { ...@@ -1544,7 +1539,11 @@ static void Generate_InterpreterEnterBytecode(MacroAssembler* masm) {
__ LoadTaggedPointerField( __ LoadTaggedPointerField(
rbx, FieldOperand(rbx, InterpreterData::kInterpreterTrampolineOffset)); 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); __ jmp(&trampoline_loaded, Label::kNear);
__ bind(&builtin_trampoline); __ bind(&builtin_trampoline);
...@@ -4433,6 +4432,9 @@ void Generate_BaselineEntry(MacroAssembler* masm, bool next_bytecode, ...@@ -4433,6 +4432,9 @@ void Generate_BaselineEntry(MacroAssembler* masm, bool next_bytecode,
FieldOperand(code_obj, SharedFunctionInfo::kFunctionDataOffset)); FieldOperand(code_obj, SharedFunctionInfo::kFunctionDataOffset));
__ LoadTaggedPointerField( __ LoadTaggedPointerField(
code_obj, FieldOperand(code_obj, BaselineData::kBaselineCodeOffset)); code_obj, FieldOperand(code_obj, BaselineData::kBaselineCodeOffset));
if (V8_EXTERNAL_CODE_SPACE_BOOL) {
__ LoadCodeDataContainerCodeNonBuiltin(code_obj, code_obj);
}
// Compute baseline pc for bytecode offset. // Compute baseline pc for bytecode offset.
ExternalReference get_baseline_pc_extref; ExternalReference get_baseline_pc_extref;
......
...@@ -14240,11 +14240,11 @@ TNode<Code> CodeStubAssembler::GetSharedFunctionInfoCode( ...@@ -14240,11 +14240,11 @@ TNode<Code> CodeStubAssembler::GetSharedFunctionInfoCode(
// IsBaselineData: Execute baseline code // IsBaselineData: Execute baseline code
BIND(&check_is_baseline_data); BIND(&check_is_baseline_data);
TNode<BaselineData> baseline_data = CAST(sfi_data); {
TNode<Code> baseline_code = TNode<CodeT> baseline_code = LoadBaselineDataBaselineCode(CAST(sfi_data));
CAST(LoadObjectField(baseline_data, BaselineData::kBaselineCodeOffset)); sfi_code = FromCodeT(baseline_code);
sfi_code = baseline_code; Goto(&done);
Goto(&done); }
// IsUncompiledDataWithPreparseData | IsUncompiledDataWithoutPreparseData: // IsUncompiledDataWithPreparseData | IsUncompiledDataWithoutPreparseData:
// Compile lazy // Compile lazy
...@@ -14264,8 +14264,11 @@ TNode<Code> CodeStubAssembler::GetSharedFunctionInfoCode( ...@@ -14264,8 +14264,11 @@ TNode<Code> CodeStubAssembler::GetSharedFunctionInfoCode(
// This is the default branch, so assert that we have the expected data type. // This is the default branch, so assert that we have the expected data type.
CSA_ASSERT(this, CSA_ASSERT(this,
Word32Equal(data_type, Int32Constant(INTERPRETER_DATA_TYPE))); 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); Goto(&done);
#if V8_ENABLE_WEBASSEMBLY #if V8_ENABLE_WEBASSEMBLY
...@@ -14288,6 +14291,7 @@ TNode<Code> CodeStubAssembler::GetSharedFunctionInfoCode( ...@@ -14288,6 +14291,7 @@ TNode<Code> CodeStubAssembler::GetSharedFunctionInfoCode(
TNode<JSFunction> CodeStubAssembler::AllocateFunctionWithMapAndContext( TNode<JSFunction> CodeStubAssembler::AllocateFunctionWithMapAndContext(
TNode<Map> map, TNode<SharedFunctionInfo> shared_info, TNode<Map> map, TNode<SharedFunctionInfo> shared_info,
TNode<Context> context) { TNode<Context> context) {
// TODO(v8:11880): avoid roundtrips between cdc and code.
const TNode<Code> code = GetSharedFunctionInfoCode(shared_info); const TNode<Code> code = GetSharedFunctionInfoCode(shared_info);
// TODO(ishell): All the callers of this function pass map loaded from // TODO(ishell): All the callers of this function pass map loaded from
......
...@@ -98,9 +98,18 @@ OBJECT_CONSTRUCTORS_IMPL(InterpreterData, Struct) ...@@ -98,9 +98,18 @@ OBJECT_CONSTRUCTORS_IMPL(InterpreterData, Struct)
CAST_ACCESSOR(InterpreterData) CAST_ACCESSOR(InterpreterData)
ACCESSORS(InterpreterData, bytecode_array, BytecodeArray, kBytecodeArrayOffset) ACCESSORS(InterpreterData, bytecode_array, BytecodeArray, kBytecodeArrayOffset)
ACCESSORS(InterpreterData, interpreter_trampoline, Code, ACCESSORS(InterpreterData, raw_interpreter_trampoline, CodeT,
kInterpreterTrampolineOffset) 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) TQ_OBJECT_CONSTRUCTORS_IMPL(SharedFunctionInfo)
NEVER_READ_ONLY_SPACE_IMPL(SharedFunctionInfo) NEVER_READ_ONLY_SPACE_IMPL(SharedFunctionInfo)
DEFINE_DEOPT_ELEMENT_ACCESSORS(SharedFunctionInfo, Object) DEFINE_DEOPT_ELEMENT_ACCESSORS(SharedFunctionInfo, Object)
...@@ -504,6 +513,14 @@ BytecodeArray SharedFunctionInfo::GetBytecodeArray(IsolateT* isolate) const { ...@@ -504,6 +513,14 @@ BytecodeArray SharedFunctionInfo::GetBytecodeArray(IsolateT* isolate) const {
return GetActiveBytecodeArray(); 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 { BytecodeArray BaselineData::GetActiveBytecodeArray() const {
Object data = this->data(); Object data = this->data();
if (data.IsBytecodeArray()) { if (data.IsBytecodeArray()) {
......
...@@ -153,6 +153,9 @@ class InterpreterData : public Struct { ...@@ -153,6 +153,9 @@ class InterpreterData : public Struct {
DECL_PRINTER(InterpreterData) DECL_PRINTER(InterpreterData)
DECL_VERIFIER(InterpreterData) DECL_VERIFIER(InterpreterData)
private:
DECL_ACCESSORS(raw_interpreter_trampoline, CodeT)
OBJECT_CONSTRUCTORS(InterpreterData, Struct); OBJECT_CONSTRUCTORS(InterpreterData, Struct);
}; };
...@@ -161,6 +164,8 @@ class BaselineData : public TorqueGeneratedBaselineData<BaselineData, Struct> { ...@@ -161,6 +164,8 @@ class BaselineData : public TorqueGeneratedBaselineData<BaselineData, Struct> {
inline BytecodeArray GetActiveBytecodeArray() const; inline BytecodeArray GetActiveBytecodeArray() const;
inline void SetActiveBytecodeArray(BytecodeArray bytecode); inline void SetActiveBytecodeArray(BytecodeArray bytecode);
DECL_ACCESSORS(baseline_code, Code)
TQ_OBJECT_CONSTRUCTORS(BaselineData) TQ_OBJECT_CONSTRUCTORS(BaselineData)
}; };
......
...@@ -11,13 +11,15 @@ extern class PreparseData extends HeapObject { ...@@ -11,13 +11,15 @@ extern class PreparseData extends HeapObject {
extern class InterpreterData extends Struct { extern class InterpreterData extends Struct {
bytecode_array: BytecodeArray; bytecode_array: BytecodeArray;
interpreter_trampoline: Code; @if(V8_EXTERNAL_CODE_SPACE) interpreter_trampoline: CodeDataContainer;
@ifnot(V8_EXTERNAL_CODE_SPACE) interpreter_trampoline: Code;
} }
@generateCppClass @generateCppClass
@generatePrint @generatePrint
extern class BaselineData extends Struct { 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; 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