[ext-code-space] Prepare frame-related code for Code-less builtins, pt.1
Bug: v8:11880 Change-Id: I62e3d309721f3de50c15c0a6e39b82831dd46337 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3780532 Reviewed-by: Patrick Thier <pthier@chromium.org> Commit-Queue: Igor Sheludko <ishell@chromium.org> Auto-Submit: Igor Sheludko <ishell@chromium.org> Cr-Commit-Position: refs/heads/main@{#81894}
This commit is contained in:
parent
edbe337397
commit
38e3ac8f88
@ -19,6 +19,15 @@ MaglevSafepointTable::MaglevSafepointTable(Isolate* isolate, Address pc,
|
|||||||
DCHECK(code.is_maglevved());
|
DCHECK(code.is_maglevved());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef V8_EXTERNAL_CODE_SPACE
|
||||||
|
MaglevSafepointTable::MaglevSafepointTable(Isolate* isolate, Address pc,
|
||||||
|
CodeDataContainer code)
|
||||||
|
: MaglevSafepointTable(code.InstructionStart(isolate, pc),
|
||||||
|
code.SafepointTableAddress()) {
|
||||||
|
DCHECK(code.is_maglevved());
|
||||||
|
}
|
||||||
|
#endif // V8_EXTERNAL_CODE_SPACE
|
||||||
|
|
||||||
MaglevSafepointTable::MaglevSafepointTable(Address instruction_start,
|
MaglevSafepointTable::MaglevSafepointTable(Address instruction_start,
|
||||||
Address safepoint_table_address)
|
Address safepoint_table_address)
|
||||||
: instruction_start_(instruction_start),
|
: instruction_start_(instruction_start),
|
||||||
|
@ -63,7 +63,10 @@ class MaglevSafepointTable {
|
|||||||
// The isolate and pc arguments are used for figuring out whether pc
|
// The isolate and pc arguments are used for figuring out whether pc
|
||||||
// belongs to the embedded or un-embedded code blob.
|
// belongs to the embedded or un-embedded code blob.
|
||||||
explicit MaglevSafepointTable(Isolate* isolate, Address pc, Code code);
|
explicit MaglevSafepointTable(Isolate* isolate, Address pc, Code code);
|
||||||
|
#ifdef V8_EXTERNAL_CODE_SPACE
|
||||||
|
explicit MaglevSafepointTable(Isolate* isolate, Address pc,
|
||||||
|
CodeDataContainer code);
|
||||||
|
#endif
|
||||||
MaglevSafepointTable(const MaglevSafepointTable&) = delete;
|
MaglevSafepointTable(const MaglevSafepointTable&) = delete;
|
||||||
MaglevSafepointTable& operator=(const MaglevSafepointTable&) = delete;
|
MaglevSafepointTable& operator=(const MaglevSafepointTable&) = delete;
|
||||||
|
|
||||||
|
@ -681,8 +681,7 @@ StackFrame::Type StackFrame::ComputeType(const StackFrameIteratorBase* iterator,
|
|||||||
switch (lookup_result.kind()) {
|
switch (lookup_result.kind()) {
|
||||||
case CodeKind::BUILTIN: {
|
case CodeKind::BUILTIN: {
|
||||||
if (StackFrame::IsTypeMarker(marker)) break;
|
if (StackFrame::IsTypeMarker(marker)) break;
|
||||||
// TODO(v8:11880): avoid unnecessary conversion to Code or CodeT.
|
CodeT code_obj = lookup_result.ToCodeT();
|
||||||
Code code_obj = lookup_result.ToCode();
|
|
||||||
if (code_obj.is_interpreter_trampoline_builtin() ||
|
if (code_obj.is_interpreter_trampoline_builtin() ||
|
||||||
// Frames for baseline entry trampolines on the stack are still
|
// Frames for baseline entry trampolines on the stack are still
|
||||||
// interpreted frames.
|
// interpreted frames.
|
||||||
@ -904,10 +903,10 @@ void BuiltinExitFrame::Summarize(std::vector<FrameSummary>* frames) const {
|
|||||||
DCHECK(frames->empty());
|
DCHECK(frames->empty());
|
||||||
Handle<FixedArray> parameters = GetParameters();
|
Handle<FixedArray> parameters = GetParameters();
|
||||||
DisallowGarbageCollection no_gc;
|
DisallowGarbageCollection no_gc;
|
||||||
Code code = LookupCode();
|
CodeLookupResult code = LookupCodeT();
|
||||||
int code_offset = code.GetOffsetFromInstructionStart(isolate(), pc());
|
int code_offset = code.GetOffsetFromInstructionStart(isolate(), pc());
|
||||||
FrameSummary::JavaScriptFrameSummary summary(
|
FrameSummary::JavaScriptFrameSummary summary(
|
||||||
isolate(), receiver(), function(), AbstractCode::cast(code), code_offset,
|
isolate(), receiver(), function(), code.ToAbstractCode(), code_offset,
|
||||||
IsConstructor(), *parameters);
|
IsConstructor(), *parameters);
|
||||||
frames->push_back(summary);
|
frames->push_back(summary);
|
||||||
}
|
}
|
||||||
@ -1094,36 +1093,33 @@ void CommonFrame::IterateCompiledFrame(RootVisitor* v) const {
|
|||||||
|
|
||||||
CHECK(entry->code.IsFound());
|
CHECK(entry->code.IsFound());
|
||||||
code_lookup_result = entry->code;
|
code_lookup_result = entry->code;
|
||||||
Code code = entry->code.ToCode();
|
is_maglev = code_lookup_result.is_maglevved();
|
||||||
is_maglev = code.is_maglevved();
|
|
||||||
|
|
||||||
if (is_maglev) {
|
if (is_maglev) {
|
||||||
if (!entry->maglev_safepoint_entry.is_initialized()) {
|
if (!entry->maglev_safepoint_entry.is_initialized()) {
|
||||||
entry->maglev_safepoint_entry =
|
entry->maglev_safepoint_entry =
|
||||||
entry->code.ToCode().GetMaglevSafepointEntry(isolate(),
|
entry->code.GetMaglevSafepointEntry(isolate(), inner_pointer);
|
||||||
inner_pointer);
|
|
||||||
DCHECK(entry->maglev_safepoint_entry.is_initialized());
|
DCHECK(entry->maglev_safepoint_entry.is_initialized());
|
||||||
} else {
|
} else {
|
||||||
DCHECK_EQ(entry->maglev_safepoint_entry,
|
DCHECK_EQ(
|
||||||
entry->code.ToCode().GetMaglevSafepointEntry(isolate(),
|
entry->maglev_safepoint_entry,
|
||||||
inner_pointer));
|
entry->code.GetMaglevSafepointEntry(isolate(), inner_pointer));
|
||||||
}
|
}
|
||||||
maglev_safepoint_entry = entry->maglev_safepoint_entry;
|
maglev_safepoint_entry = entry->maglev_safepoint_entry;
|
||||||
} else {
|
} else {
|
||||||
if (!entry->safepoint_entry.is_initialized()) {
|
if (!entry->safepoint_entry.is_initialized()) {
|
||||||
entry->safepoint_entry =
|
entry->safepoint_entry =
|
||||||
entry->code.ToCode().GetSafepointEntry(isolate(), inner_pointer);
|
entry->code.GetSafepointEntry(isolate(), inner_pointer);
|
||||||
DCHECK(entry->safepoint_entry.is_initialized());
|
DCHECK(entry->safepoint_entry.is_initialized());
|
||||||
} else {
|
} else {
|
||||||
DCHECK_EQ(
|
DCHECK_EQ(entry->safepoint_entry,
|
||||||
entry->safepoint_entry,
|
entry->code.GetSafepointEntry(isolate(), inner_pointer));
|
||||||
entry->code.ToCode().GetSafepointEntry(isolate(), inner_pointer));
|
|
||||||
}
|
}
|
||||||
safepoint_entry = entry->safepoint_entry;
|
safepoint_entry = entry->safepoint_entry;
|
||||||
}
|
}
|
||||||
stack_slots = code.stack_slots();
|
stack_slots = entry->code.stack_slots();
|
||||||
|
|
||||||
has_tagged_outgoing_params = code.has_tagged_outgoing_params();
|
has_tagged_outgoing_params = entry->code.has_tagged_outgoing_params();
|
||||||
|
|
||||||
#if V8_ENABLE_WEBASSEMBLY
|
#if V8_ENABLE_WEBASSEMBLY
|
||||||
// With inlined JS-to-Wasm calls, we can be in an OptimizedFrame and
|
// With inlined JS-to-Wasm calls, we can be in an OptimizedFrame and
|
||||||
@ -1390,7 +1386,7 @@ Code CommonFrameWithJSLinkage::unchecked_code() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int TurbofanFrame::ComputeParametersCount() const {
|
int TurbofanFrame::ComputeParametersCount() const {
|
||||||
Code code = LookupCode();
|
CodeLookupResult code = LookupCodeT();
|
||||||
if (code.kind() == CodeKind::BUILTIN) {
|
if (code.kind() == CodeKind::BUILTIN) {
|
||||||
return static_cast<int>(
|
return static_cast<int>(
|
||||||
Memory<intptr_t>(fp() + StandardFrameConstants::kArgCOffset)) -
|
Memory<intptr_t>(fp() + StandardFrameConstants::kArgCOffset)) -
|
||||||
@ -1428,9 +1424,9 @@ bool CommonFrameWithJSLinkage::IsConstructor() const {
|
|||||||
void CommonFrameWithJSLinkage::Summarize(
|
void CommonFrameWithJSLinkage::Summarize(
|
||||||
std::vector<FrameSummary>* functions) const {
|
std::vector<FrameSummary>* functions) const {
|
||||||
DCHECK(functions->empty());
|
DCHECK(functions->empty());
|
||||||
Code code = LookupCode();
|
CodeLookupResult code = LookupCodeT();
|
||||||
int offset = code.GetOffsetFromInstructionStart(isolate(), pc());
|
int offset = code.GetOffsetFromInstructionStart(isolate(), pc());
|
||||||
Handle<AbstractCode> abstract_code(AbstractCode::cast(code), isolate());
|
Handle<AbstractCode> abstract_code(code.ToAbstractCode(), isolate());
|
||||||
Handle<FixedArray> params = GetParameters();
|
Handle<FixedArray> params = GetParameters();
|
||||||
FrameSummary::JavaScriptFrameSummary summary(
|
FrameSummary::JavaScriptFrameSummary summary(
|
||||||
isolate(), receiver(), function(), *abstract_code, offset,
|
isolate(), receiver(), function(), *abstract_code, offset,
|
||||||
@ -1847,7 +1843,7 @@ void OptimizedFrame::Summarize(std::vector<FrameSummary>* frames) const {
|
|||||||
|
|
||||||
// Delegate to JS frame in absence of deoptimization info.
|
// Delegate to JS frame in absence of deoptimization info.
|
||||||
// TODO(turbofan): Revisit once we support deoptimization across the board.
|
// TODO(turbofan): Revisit once we support deoptimization across the board.
|
||||||
Code code = LookupCode();
|
CodeLookupResult code = LookupCodeT();
|
||||||
if (code.kind() == CodeKind::BUILTIN) {
|
if (code.kind() == CodeKind::BUILTIN) {
|
||||||
return JavaScriptFrame::Summarize(frames);
|
return JavaScriptFrame::Summarize(frames);
|
||||||
}
|
}
|
||||||
@ -1989,7 +1985,7 @@ void OptimizedFrame::GetFunctions(
|
|||||||
|
|
||||||
// Delegate to JS frame in absence of turbofan deoptimization.
|
// Delegate to JS frame in absence of turbofan deoptimization.
|
||||||
// TODO(turbofan): Revisit once we support deoptimization across the board.
|
// TODO(turbofan): Revisit once we support deoptimization across the board.
|
||||||
Code code = LookupCode();
|
CodeLookupResult code = LookupCodeT();
|
||||||
if (code.kind() == CodeKind::BUILTIN) {
|
if (code.kind() == CodeKind::BUILTIN) {
|
||||||
return JavaScriptFrame::GetFunctions(functions);
|
return JavaScriptFrame::GetFunctions(functions);
|
||||||
}
|
}
|
||||||
@ -2525,8 +2521,7 @@ void InternalFrame::Iterate(RootVisitor* v) const {
|
|||||||
// the full stack frame contains only tagged pointers or only raw values.
|
// the full stack frame contains only tagged pointers or only raw values.
|
||||||
// This is used for the WasmCompileLazy builtin, where we actually pass
|
// This is used for the WasmCompileLazy builtin, where we actually pass
|
||||||
// untagged arguments and also store untagged values on the stack.
|
// untagged arguments and also store untagged values on the stack.
|
||||||
// TODO(v8:11880): avoid unnecessary conversion to Code or CodeT.
|
if (code.has_tagged_outgoing_params()) IterateExpressions(v);
|
||||||
if (code.ToCode().has_tagged_outgoing_params()) IterateExpressions(v);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
|
@ -473,7 +473,50 @@ CODE_LOOKUP_RESULT_FWD_ACCESSOR(GetBuiltinCatchPrediction,
|
|||||||
|
|
||||||
#undef CODE_LOOKUP_RESULT_FWD_ACCESSOR
|
#undef CODE_LOOKUP_RESULT_FWD_ACCESSOR
|
||||||
|
|
||||||
|
int CodeLookupResult::GetOffsetFromInstructionStart(Isolate* isolate,
|
||||||
|
Address pc) const {
|
||||||
|
DCHECK(IsFound());
|
||||||
|
#ifdef V8_EXTERNAL_CODE_SPACE
|
||||||
|
if (IsCodeDataContainer()) {
|
||||||
|
return code_data_container().GetOffsetFromInstructionStart(isolate, pc);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return code().GetOffsetFromInstructionStart(isolate, pc);
|
||||||
|
}
|
||||||
|
|
||||||
|
SafepointEntry CodeLookupResult::GetSafepointEntry(Isolate* isolate,
|
||||||
|
Address pc) const {
|
||||||
|
DCHECK(IsFound());
|
||||||
|
#ifdef V8_EXTERNAL_CODE_SPACE
|
||||||
|
if (IsCodeDataContainer()) {
|
||||||
|
return code_data_container().GetSafepointEntry(isolate, pc);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return code().GetSafepointEntry(isolate, pc);
|
||||||
|
}
|
||||||
|
|
||||||
|
MaglevSafepointEntry CodeLookupResult::GetMaglevSafepointEntry(
|
||||||
|
Isolate* isolate, Address pc) const {
|
||||||
|
DCHECK(IsFound());
|
||||||
|
#ifdef V8_EXTERNAL_CODE_SPACE
|
||||||
|
if (IsCodeDataContainer()) {
|
||||||
|
return code_data_container().GetMaglevSafepointEntry(isolate, pc);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return code().GetMaglevSafepointEntry(isolate, pc);
|
||||||
|
}
|
||||||
|
|
||||||
|
AbstractCode CodeLookupResult::ToAbstractCode() const {
|
||||||
|
DCHECK(IsFound());
|
||||||
|
if (V8_REMOVE_BUILTINS_CODE_OBJECTS) {
|
||||||
|
return IsCodeDataContainer() ? AbstractCode::cast(code_data_container())
|
||||||
|
: AbstractCode::cast(code());
|
||||||
|
}
|
||||||
|
return AbstractCode::cast(ToCode());
|
||||||
|
}
|
||||||
|
|
||||||
Code CodeLookupResult::ToCode() const {
|
Code CodeLookupResult::ToCode() const {
|
||||||
|
DCHECK(IsFound());
|
||||||
#ifdef V8_EXTERNAL_CODE_SPACE
|
#ifdef V8_EXTERNAL_CODE_SPACE
|
||||||
return IsCode() ? code() : FromCodeT(code_data_container());
|
return IsCode() ? code() : FromCodeT(code_data_container());
|
||||||
#else
|
#else
|
||||||
@ -625,6 +668,16 @@ int Code::GetOffsetFromInstructionStart(Isolate* isolate, Address pc) const {
|
|||||||
return static_cast<int>(offset);
|
return static_cast<int>(offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef V8_EXTERNAL_CODE_SPACE
|
||||||
|
int CodeDataContainer::GetOffsetFromInstructionStart(Isolate* isolate,
|
||||||
|
Address pc) const {
|
||||||
|
Address instruction_start = InstructionStart(isolate, pc);
|
||||||
|
Address offset = pc - instruction_start;
|
||||||
|
DCHECK_LE(offset, InstructionSize());
|
||||||
|
return static_cast<int>(offset);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
Address Code::raw_metadata_end() const {
|
Address Code::raw_metadata_end() const {
|
||||||
return raw_metadata_start() + raw_metadata_size();
|
return raw_metadata_start() + raw_metadata_size();
|
||||||
}
|
}
|
||||||
|
@ -225,6 +225,15 @@ SafepointEntry Code::GetSafepointEntry(Isolate* isolate, Address pc) {
|
|||||||
return table.FindEntry(pc);
|
return table.FindEntry(pc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef V8_EXTERNAL_CODE_SPACE
|
||||||
|
SafepointEntry CodeDataContainer::GetSafepointEntry(Isolate* isolate,
|
||||||
|
Address pc) {
|
||||||
|
DCHECK(!is_maglevved());
|
||||||
|
SafepointTable table(isolate, pc, *this);
|
||||||
|
return table.FindEntry(pc);
|
||||||
|
}
|
||||||
|
#endif // V8_EXTERNAL_CODE_SPACE
|
||||||
|
|
||||||
MaglevSafepointEntry Code::GetMaglevSafepointEntry(Isolate* isolate,
|
MaglevSafepointEntry Code::GetMaglevSafepointEntry(Isolate* isolate,
|
||||||
Address pc) {
|
Address pc) {
|
||||||
DCHECK(is_maglevved());
|
DCHECK(is_maglevved());
|
||||||
@ -232,6 +241,15 @@ MaglevSafepointEntry Code::GetMaglevSafepointEntry(Isolate* isolate,
|
|||||||
return table.FindEntry(pc);
|
return table.FindEntry(pc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef V8_EXTERNAL_CODE_SPACE
|
||||||
|
MaglevSafepointEntry CodeDataContainer::GetMaglevSafepointEntry(
|
||||||
|
Isolate* isolate, Address pc) {
|
||||||
|
DCHECK(is_maglevved());
|
||||||
|
MaglevSafepointTable table(isolate, pc, *this);
|
||||||
|
return table.FindEntry(pc);
|
||||||
|
}
|
||||||
|
#endif // V8_EXTERNAL_CODE_SPACE
|
||||||
|
|
||||||
Address Code::OffHeapInstructionStart(Isolate* isolate, Address pc) const {
|
Address Code::OffHeapInstructionStart(Isolate* isolate, Address pc) const {
|
||||||
DCHECK(is_off_heap_trampoline());
|
DCHECK(is_off_heap_trampoline());
|
||||||
EmbeddedData d = EmbeddedData::GetEmbeddedDataForPC(isolate, pc);
|
EmbeddedData d = EmbeddedData::GetEmbeddedDataForPC(isolate, pc);
|
||||||
|
@ -204,6 +204,14 @@ class CodeDataContainer : public HeapObject {
|
|||||||
inline Address InstructionEnd() const;
|
inline Address InstructionEnd() const;
|
||||||
inline int InstructionSize() const;
|
inline int InstructionSize() const;
|
||||||
|
|
||||||
|
// Get the safepoint entry for the given pc.
|
||||||
|
SafepointEntry GetSafepointEntry(Isolate* isolate, Address pc);
|
||||||
|
|
||||||
|
// Get the maglev safepoint entry for the given pc.
|
||||||
|
MaglevSafepointEntry GetMaglevSafepointEntry(Isolate* isolate, Address pc);
|
||||||
|
|
||||||
|
inline int GetOffsetFromInstructionStart(Isolate* isolate, Address pc) const;
|
||||||
|
|
||||||
#endif // V8_EXTERNAL_CODE_SPACE
|
#endif // V8_EXTERNAL_CODE_SPACE
|
||||||
|
|
||||||
DECL_CAST(CodeDataContainer)
|
DECL_CAST(CodeDataContainer)
|
||||||
@ -906,6 +914,15 @@ class CodeLookupResult {
|
|||||||
inline int stack_slots() const;
|
inline int stack_slots() const;
|
||||||
inline HandlerTable::CatchPrediction GetBuiltinCatchPrediction() const;
|
inline HandlerTable::CatchPrediction GetBuiltinCatchPrediction() const;
|
||||||
|
|
||||||
|
inline int GetOffsetFromInstructionStart(Isolate* isolate, Address pc) const;
|
||||||
|
|
||||||
|
inline SafepointEntry GetSafepointEntry(Isolate* isolate, Address pc) const;
|
||||||
|
inline MaglevSafepointEntry GetMaglevSafepointEntry(Isolate* isolate,
|
||||||
|
Address pc) const;
|
||||||
|
|
||||||
|
// Helper method, coverts the successful lookup result to AbstractCode object.
|
||||||
|
inline AbstractCode ToAbstractCode() const;
|
||||||
|
|
||||||
// Helper method, coverts the successful lookup result to Code object.
|
// Helper method, coverts the successful lookup result to Code object.
|
||||||
// It's not safe to be used from GC because conversion to Code might perform
|
// It's not safe to be used from GC because conversion to Code might perform
|
||||||
// a map check.
|
// a map check.
|
||||||
|
Loading…
Reference in New Issue
Block a user