Commit 97a3d69d authored by Igor Sheludko's avatar Igor Sheludko Committed by V8 LUCI CQ

[ext-code-space] Cache is_off_heap_trampoline and is_turbofanned in CDC

Bug: v8:11880
Change-Id: Iadeac98dd0a4c0814a6d6a38a96a366369c2c536
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3684814
Commit-Queue: Igor Sheludko <ishell@chromium.org>
Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/main@{#80911}
parent 2b6cbda0
......@@ -129,7 +129,9 @@ MaybeHandle<Code> Factory::CodeBuilder::BuildInternal(
: AllocationType::kOld);
}
if (V8_EXTERNAL_CODE_SPACE_BOOL) {
data_container->initialize_flags(kind_, builtin_);
const bool set_is_off_heap_trampoline = read_only_data_container_;
data_container->initialize_flags(kind_, builtin_, is_turbofanned_,
set_is_off_heap_trampoline);
}
data_container->set_kind_specific_flags(kind_specific_flags_,
kRelaxedStore);
......@@ -2348,8 +2350,9 @@ Handle<Code> Factory::NewOffHeapTrampolineFor(Handle<Code> code,
// the value of the instruction start, so update it here.
code_data_container.UpdateCodeEntryPoint(isolate(), raw_result);
// Also update flag values cached on the code data container.
code_data_container.initialize_flags(raw_code.kind(),
raw_code.builtin_id());
code_data_container.initialize_flags(
raw_code.kind(), raw_code.builtin_id(), raw_code.is_turbofanned(),
set_is_off_heap_trampoline);
}
}
......@@ -2389,7 +2392,9 @@ Handle<Code> Factory::CopyCode(Handle<Code> code) {
#endif
}
if (V8_EXTERNAL_CODE_SPACE_BOOL) {
data_container->initialize_flags(code->kind(), code->builtin_id());
data_container->initialize_flags(code->kind(), code->builtin_id(),
code->is_turbofanned(),
code->is_off_heap_trampoline());
data_container->SetCodeAndEntryPoint(isolate(), *new_code);
}
......
......@@ -661,8 +661,20 @@ inline bool Code::is_turbofanned() const {
return IsTurbofannedField::decode(flags);
}
#ifdef V8_EXTERNAL_CODE_SPACE
inline bool CodeDataContainer::is_turbofanned() const {
return IsTurbofannedField::decode(flags(kRelaxedLoad));
}
#endif
bool Code::is_maglevved() const { return kind() == CodeKind::MAGLEV; }
#ifdef V8_EXTERNAL_CODE_SPACE
inline bool CodeDataContainer::is_maglevved() const {
return kind() == CodeKind::MAGLEV;
}
#endif
inline bool Code::can_have_weak_objects() const {
DCHECK(CodeKindIsOptimizedJSFunction(kind()));
int32_t flags =
......@@ -1075,9 +1087,13 @@ RELAXED_UINT16_ACCESSORS(CodeDataContainer, flags, kFlagsOffset)
static_assert(static_cast<int>(Builtin::kNoBuiltinId) == -1);
static_assert(Builtins::kBuiltinCount < std::numeric_limits<int16_t>::max());
void CodeDataContainer::initialize_flags(CodeKind kind, Builtin builtin_id) {
void CodeDataContainer::initialize_flags(CodeKind kind, Builtin builtin_id,
bool is_turbofanned,
bool is_off_heap_trampoline) {
CHECK(V8_EXTERNAL_CODE_SPACE_BOOL);
uint16_t value = KindField::encode(kind);
uint16_t value = KindField::encode(kind) |
IsTurbofannedField::encode(is_turbofanned) |
IsOffHeapTrampoline::encode(is_off_heap_trampoline);
set_flags(value, kRelaxedStore);
WriteField<int16_t>(kBuiltinIdOffset, static_cast<int16_t>(builtin_id));
......@@ -1104,6 +1120,10 @@ bool CodeDataContainer::is_builtin() const {
return builtin_id() != Builtin::kNoBuiltinId;
}
bool CodeDataContainer::is_off_heap_trampoline() const {
return IsOffHeapTrampoline::decode(flags(kRelaxedLoad));
}
bool CodeDataContainer::is_optimized_code() const {
return CodeKindIsOptimizedJSFunction(kind());
}
......@@ -1112,6 +1132,14 @@ inline bool CodeDataContainer::is_interpreter_trampoline_builtin() const {
return IsInterpreterTrampolineBuiltin(builtin_id());
}
inline bool CodeDataContainer::is_baseline_trampoline_builtin() const {
return IsBaselineTrampolineBuiltin(builtin_id());
}
inline bool CodeDataContainer::is_baseline_leave_frame_builtin() const {
return builtin_id() == Builtin::kBaselineLeaveFrame;
}
//
// A collection of getters and predicates that forward queries to associated
// Code object.
......@@ -1125,10 +1153,6 @@ inline bool CodeDataContainer::is_interpreter_trampoline_builtin() const {
return FromCodeT(*this).name(cage_base); \
}
DEF_PRIMITIVE_FORWARDING_CDC_GETTER(is_maglevved, bool)
DEF_PRIMITIVE_FORWARDING_CDC_GETTER(is_turbofanned, bool)
DEF_PRIMITIVE_FORWARDING_CDC_GETTER(is_off_heap_trampoline, bool)
DEF_FORWARDING_CDC_GETTER(deoptimization_data, FixedArray)
DEF_FORWARDING_CDC_GETTER(bytecode_or_interpreter_data, HeapObject)
DEF_FORWARDING_CDC_GETTER(source_position_table, ByteArray)
......
......@@ -99,7 +99,9 @@ class CodeDataContainer : public HeapObject {
// Initializes internal flags field which stores cached values of some
// properties of the respective Code object.
// Available only when V8_EXTERNAL_CODE_SPACE is enabled.
inline void initialize_flags(CodeKind kind, Builtin builtin_id);
inline void initialize_flags(CodeKind kind, Builtin builtin_id,
bool is_turbofanned,
bool is_off_heap_trampoline);
// Alias for code_entry_point to make it API compatible with Code.
inline Address InstructionStart() const;
......@@ -192,11 +194,13 @@ class CodeDataContainer : public HeapObject {
// Flags layout.
#define FLAGS_BIT_FIELDS(V, _) \
V(KindField, CodeKind, 4, _) \
/* The other 12 bits are still free. */
V(IsTurbofannedField, bool, 1, _) \
V(IsOffHeapTrampoline, bool, 1, _)
/* The other 10 bits are still free. */
DEFINE_BIT_FIELDS(FLAGS_BIT_FIELDS)
#undef FLAGS_BIT_FIELDS
static_assert(FLAGS_BIT_FIELDS_Ranges::kBitsCount == 4);
static_assert(FLAGS_BIT_FIELDS_Ranges::kBitsCount == 6);
static_assert(!V8_EXTERNAL_CODE_SPACE_BOOL ||
(FLAGS_BIT_FIELDS_Ranges::kBitsCount <=
FIELD_SIZE(CodeDataContainer::kFlagsOffset) * kBitsPerByte));
......
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