Commit ff747f9e authored by ishell@chromium.org's avatar ishell@chromium.org Committed by V8 LUCI CQ

[cleanup] Cage base'ify accessors in SharedFunctionInfo

Bug: v8:11880
Change-Id: I07d5811132d2b1e3cb853f58972970c77fdae026
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3769697
Commit-Queue: Igor Sheludko <ishell@chromium.org>
Reviewed-by: 's avatarPatrick Thier <pthier@chromium.org>
Cr-Commit-Position: refs/heads/main@{#81786}
parent 50e944f0
...@@ -83,6 +83,10 @@ V8_INLINE constexpr bool IsFreeSpaceOrFiller(InstanceType instance_type) { ...@@ -83,6 +83,10 @@ V8_INLINE constexpr bool IsFreeSpaceOrFiller(InstanceType instance_type) {
return instance_type == FREE_SPACE_TYPE || instance_type == FILLER_TYPE; return instance_type == FREE_SPACE_TYPE || instance_type == FILLER_TYPE;
} }
V8_INLINE constexpr bool IsCodeT(InstanceType instance_type) {
return instance_type == CODET_TYPE;
}
} // namespace InstanceTypeChecker } // namespace InstanceTypeChecker
// INSTANCE_TYPE_CHECKERS macro defines some "types" that do not have // INSTANCE_TYPE_CHECKERS macro defines some "types" that do not have
......
...@@ -293,6 +293,8 @@ INSTANCE_TYPE_CHECKERS(IS_TYPE_FUNCTION_DECL) ...@@ -293,6 +293,8 @@ INSTANCE_TYPE_CHECKERS(IS_TYPE_FUNCTION_DECL)
TYPED_ARRAYS(TYPED_ARRAY_IS_TYPE_FUNCTION_DECL) TYPED_ARRAYS(TYPED_ARRAY_IS_TYPE_FUNCTION_DECL)
#undef TYPED_ARRAY_IS_TYPE_FUNCTION_DECL #undef TYPED_ARRAY_IS_TYPE_FUNCTION_DECL
IS_TYPE_FUNCTION_DECL(CodeT)
#undef IS_TYPE_FUNCTION_DECL #undef IS_TYPE_FUNCTION_DECL
} // namespace InstanceTypeChecker } // namespace InstanceTypeChecker
......
...@@ -549,9 +549,14 @@ FunctionTemplateInfo SharedFunctionInfo::get_api_func_data() const { ...@@ -549,9 +549,14 @@ FunctionTemplateInfo SharedFunctionInfo::get_api_func_data() const {
return FunctionTemplateInfo::cast(function_data(kAcquireLoad)); return FunctionTemplateInfo::cast(function_data(kAcquireLoad));
} }
bool SharedFunctionInfo::HasBytecodeArray() const { DEF_GETTER(SharedFunctionInfo, HasBytecodeArray, bool) {
Object data = function_data(kAcquireLoad); Object data = function_data(cage_base, kAcquireLoad);
return data.IsBytecodeArray() || data.IsInterpreterData() || data.IsCodeT(); if (!data.IsHeapObject()) return false;
InstanceType instance_type =
HeapObject::cast(data).map(cage_base).instance_type();
return InstanceTypeChecker::IsBytecodeArray(instance_type) ||
InstanceTypeChecker::IsInterpreterData(instance_type) ||
InstanceTypeChecker::IsCodeT(instance_type);
} }
template <typename IsolateT> template <typename IsolateT>
...@@ -635,28 +640,28 @@ bool SharedFunctionInfo::ShouldFlushCode( ...@@ -635,28 +640,28 @@ bool SharedFunctionInfo::ShouldFlushCode(
return bytecode.IsOld(); return bytecode.IsOld();
} }
CodeT SharedFunctionInfo::InterpreterTrampoline() const { DEF_GETTER(SharedFunctionInfo, InterpreterTrampoline, CodeT) {
DCHECK(HasInterpreterData()); DCHECK(HasInterpreterData(cage_base));
return interpreter_data().interpreter_trampoline(); return interpreter_data(cage_base).interpreter_trampoline(cage_base);
} }
bool SharedFunctionInfo::HasInterpreterData() const { DEF_GETTER(SharedFunctionInfo, HasInterpreterData, bool) {
Object data = function_data(kAcquireLoad); Object data = function_data(cage_base, kAcquireLoad);
if (data.IsCodeT()) { if (data.IsCodeT(cage_base)) {
CodeT baseline_code = CodeT::cast(data); CodeT baseline_code = CodeT::cast(data);
DCHECK_EQ(baseline_code.kind(), CodeKind::BASELINE); DCHECK_EQ(baseline_code.kind(), CodeKind::BASELINE);
data = baseline_code.bytecode_or_interpreter_data(); data = baseline_code.bytecode_or_interpreter_data(cage_base);
} }
return data.IsInterpreterData(); return data.IsInterpreterData(cage_base);
} }
InterpreterData SharedFunctionInfo::interpreter_data() const { DEF_GETTER(SharedFunctionInfo, interpreter_data, InterpreterData) {
DCHECK(HasInterpreterData()); DCHECK(HasInterpreterData(cage_base));
Object data = function_data(kAcquireLoad); Object data = function_data(cage_base, kAcquireLoad);
if (data.IsCodeT()) { if (data.IsCodeT(cage_base)) {
CodeT baseline_code = CodeT::cast(data); CodeT baseline_code = CodeT::cast(data);
DCHECK_EQ(baseline_code.kind(), CodeKind::BASELINE); DCHECK_EQ(baseline_code.kind(), CodeKind::BASELINE);
data = baseline_code.bytecode_or_interpreter_data(); data = baseline_code.bytecode_or_interpreter_data(cage_base);
} }
return InterpreterData::cast(data); return InterpreterData::cast(data);
} }
...@@ -668,24 +673,25 @@ void SharedFunctionInfo::set_interpreter_data( ...@@ -668,24 +673,25 @@ void SharedFunctionInfo::set_interpreter_data(
set_function_data(interpreter_data, kReleaseStore); set_function_data(interpreter_data, kReleaseStore);
} }
bool SharedFunctionInfo::HasBaselineCode() const { DEF_GETTER(SharedFunctionInfo, HasBaselineCode, bool) {
Object data = function_data(kAcquireLoad); Object data = function_data(cage_base, kAcquireLoad);
if (data.IsCodeT()) { if (data.IsCodeT(cage_base)) {
DCHECK_EQ(CodeT::cast(data).kind(), CodeKind::BASELINE); DCHECK_EQ(CodeT::cast(data).kind(), CodeKind::BASELINE);
return true; return true;
} }
return false; return false;
} }
CodeT SharedFunctionInfo::baseline_code(AcquireLoadTag) const { DEF_ACQUIRE_GETTER(SharedFunctionInfo, baseline_code, CodeT) {
DCHECK(HasBaselineCode()); DCHECK(HasBaselineCode(cage_base));
return CodeT::cast(function_data(kAcquireLoad)); return CodeT::cast(function_data(cage_base, kAcquireLoad));
} }
void SharedFunctionInfo::set_baseline_code(CodeT baseline_code, void SharedFunctionInfo::set_baseline_code(CodeT baseline_code,
ReleaseStoreTag) { ReleaseStoreTag tag,
WriteBarrierMode mode) {
DCHECK_EQ(baseline_code.kind(), CodeKind::BASELINE); DCHECK_EQ(baseline_code.kind(), CodeKind::BASELINE);
set_function_data(baseline_code, kReleaseStore); set_function_data(baseline_code, tag, mode);
} }
void SharedFunctionInfo::FlushBaselineCode() { void SharedFunctionInfo::FlushBaselineCode() {
......
...@@ -327,18 +327,17 @@ class SharedFunctionInfo ...@@ -327,18 +327,17 @@ class SharedFunctionInfo
inline bool is_class_constructor() const; inline bool is_class_constructor() const;
inline FunctionTemplateInfo get_api_func_data() const; inline FunctionTemplateInfo get_api_func_data() const;
inline void set_api_func_data(FunctionTemplateInfo data); inline void set_api_func_data(FunctionTemplateInfo data);
inline bool HasBytecodeArray() const; DECL_GETTER(HasBytecodeArray, bool)
template <typename IsolateT> template <typename IsolateT>
inline BytecodeArray GetBytecodeArray(IsolateT* isolate) const; inline BytecodeArray GetBytecodeArray(IsolateT* isolate) const;
inline void set_bytecode_array(BytecodeArray bytecode); inline void set_bytecode_array(BytecodeArray bytecode);
inline CodeT InterpreterTrampoline() const; DECL_GETTER(InterpreterTrampoline, CodeT)
inline bool HasInterpreterData() const; DECL_GETTER(HasInterpreterData, bool)
inline InterpreterData interpreter_data() const; DECL_GETTER(interpreter_data, InterpreterData)
inline void set_interpreter_data(InterpreterData interpreter_data); inline void set_interpreter_data(InterpreterData interpreter_data);
inline bool HasBaselineCode() const; DECL_GETTER(HasBaselineCode, bool)
inline CodeT baseline_code(AcquireLoadTag) const; DECL_RELEASE_ACQUIRE_ACCESSORS(baseline_code, CodeT)
inline void set_baseline_code(CodeT baseline_code, ReleaseStoreTag);
inline void FlushBaselineCode(); inline void FlushBaselineCode();
inline BytecodeArray GetActiveBytecodeArray() const; inline BytecodeArray GetActiveBytecodeArray() const;
inline void SetActiveBytecodeArray(BytecodeArray bytecode); inline void SetActiveBytecodeArray(BytecodeArray bytecode);
......
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