5#ifndef RUNTIME_VM_CODE_DESCRIPTORS_H_
6#define RUNTIME_VM_CODE_DESCRIPTORS_H_
32 intptr_t yield_index);
37 static constexpr intptr_t kInitialStreamSize = 64;
43 intptr_t prev_pc_offset;
44 intptr_t prev_deopt_id;
45 int32_t prev_token_pos;
53 : encoded_bytes_(zone, kInitialStreamSize) {}
57 intptr_t spill_slot_bit_count);
59 CompressedStackMapsPtr
Finalize()
const;
62 static constexpr intptr_t kInitialStreamSize = 16;
65 intptr_t last_pc_offset_ = 0;
81 has_async_handler_(
function.IsAsyncFunction() ||
84 intptr_t
Length()
const {
return list_.length(); }
88 data.outer_try_index = -1;
90 data.is_generated =
true;
91 data.handler_types =
nullptr;
92 data.needs_stacktrace =
false;
97 intptr_t outer_try_index,
100 const Array& handler_types,
101 bool needs_stacktrace) {
103 while (
Length() <= try_index) {
106 list_[try_index].outer_try_index = outer_try_index;
108 list_[try_index].pc_offset = pc_offset;
109 list_[try_index].is_generated = is_generated;
110 DEBUG_ASSERT(handler_types.IsNotTemporaryScopedHandle());
111 list_[try_index].handler_types = &handler_types;
112 list_[try_index].needs_stacktrace |= needs_stacktrace;
122 while (
Length() <= try_index) {
125 list_[try_index].needs_stacktrace =
true;
130 for (intptr_t
i = 0;
i < array.
Length();
i++) {
132 if (
type.IsCatchAllType()) {
143 const bool has_async_handler_;
147#if !defined(DART_PRECOMPILED_RUNTIME)
163 intptr_t current_pc_offset_;
202 int32_t* arg2 =
nullptr);
210 static constexpr intptr_t kOpBits = 3;
215 static constexpr int32_t kMaxArgValue =
217 static constexpr int32_t kMinArgValue = ~kMaxArgValue;
218 static constexpr int32_t kSignBits =
static_cast<uint32_t
>(kMinArgValue) << 1;
235 bool stack_traces_only,
252 intptr_t name_index);
262 return inline_id_to_function_;
266 intptr_t GetFunctionId(intptr_t inline_id);
267 void StartInliningInterval(int32_t pc_offset,
273 void WriteAdvancePC(int32_t
distance) {
277 void BufferPush(intptr_t inline_id) {
278 buffered_inline_id_stack_.
Add(inline_id);
281 void WritePush(intptr_t inline_id) {
283 GetFunctionId(inline_id));
284 written_inline_id_stack_.
Add(inline_id);
289 buffered_token_pos_stack_.RemoveLast();
294 written_token_pos_stack_.RemoveLast();
296 void WriteNullCheck(int32_t name_index) {
302 bool IsOnBufferedStack(intptr_t inline_id) {
303 for (intptr_t
i = 0;
i < buffered_inline_id_stack_.
length();
i++) {
304 if (buffered_inline_id_stack_[
i] == inline_id)
return true;
310 intptr_t buffered_pc_offset_;
311 GrowableArray<intptr_t> buffered_inline_id_stack_;
312 GrowableArray<TokenPosition> buffered_token_pos_stack_;
314 intptr_t written_pc_offset_;
315 GrowableArray<intptr_t> written_inline_id_stack_;
316 GrowableArray<TokenPosition> written_token_pos_stack_;
318 const GrowableArray<intptr_t>& caller_inline_id_;
319 const GrowableArray<TokenPosition>& inline_id_to_token_pos_;
320 const GrowableArray<const Function*>& inline_id_to_function_;
322 const GrowableObjectArray& inlined_functions_;
325 ZoneWriteStream stream_;
327 const bool stack_traces_only_;
335 const Array& functions,
337 : map_(
map), functions_(functions), root_(
root) {}
350 if (FLAG_precompiled_mode) {
353 return TokenPosition::kNoSource;
361 static TokenPosition ReadPosition(ReadStream*
stream);
363 const CodeSourceMap& map_;
364 const Array& functions_;
365 const Function& root_;
#define DEBUG_ASSERT(cond)
ObjectPtr At(intptr_t index) const
static constexpr int bitsize()
CatchEntryMovesMapBuilder()
void NewMapping(intptr_t pc_offset)
TypedDataPtr FinalizeCatchEntryMovesMap()
void Append(const CatchEntryMove &move)
TokenPosition RootPosition(const InstructionSource &source)
void EndCodeSourceRange(int32_t pc_offset, const InstructionSource &source)
void WriteFunctionEntrySourcePosition(const InstructionSource &source)
CodeSourceMapBuilder(Zone *zone, bool stack_traces_only, const GrowableArray< intptr_t > &caller_inline_id, const GrowableArray< TokenPosition > &inline_id_to_token_pos, const GrowableArray< const Function * > &inline_id_to_function)
void NoteNullCheck(int32_t pc_offset, const InstructionSource &source, intptr_t name_index)
static const TokenPosition & kInitialPosition
ArrayPtr InliningIdToFunction()
const GrowableArray< const Function * > & inline_id_to_function() const
void BeginCodeSourceRange(int32_t pc_offset, const InstructionSource &source)
CodeSourceMapPtr Finalize()
void NoteDescriptor(UntaggedPcDescriptors::Kind kind, int32_t pc_offset, const InstructionSource &source)
intptr_t GetNullCheckNameIndexAt(int32_t pc_offset)
CodeSourceMapReader(const CodeSourceMap &map, const Array &functions, const Function &root)
void DumpInlineIntervals(uword start)
void GetInlinedFunctionsAt(int32_t pc_offset, GrowableArray< const Function * > *function_stack, GrowableArray< TokenPosition > *token_positions)
void DumpSourcePositions(uword start)
NOT_IN_PRODUCT(void PrintJSONInlineIntervals(JSONObject *jsobj))
CompressedStackMapsPtr Finalize() const
void AddEntry(intptr_t pc_offset, BitmapBuilder *bitmap, intptr_t spill_slot_bit_count)
CompressedStackMapsBuilder(Zone *zone)
void AddDescriptor(UntaggedPcDescriptors::Kind kind, intptr_t pc_offset, intptr_t deopt_id, TokenPosition token_pos, intptr_t try_index, intptr_t yield_index)
PcDescriptorsPtr FinalizePcDescriptors(uword entry_point)
DescriptorList(Zone *zone, const GrowableArray< const Function * > *inline_id_to_function=nullptr)
void AddHandler(intptr_t try_index, intptr_t outer_try_index, intptr_t pc_offset, bool is_generated, const Array &handler_types, bool needs_stacktrace)
ExceptionHandlersPtr FinalizeExceptionHandlers(uword entry_point) const
void SetNeedsStackTrace(intptr_t try_index)
static bool ContainsCatchAllType(const Array &array)
ExceptionHandlerList(const Function &function)
static constexpr intptr_t kInvalidPcOffset
Dart_NativeFunction function
static int8_t data[kExtLength]
static constexpr intptr_t kInvalidTryIndex
SI auto map(std::index_sequence< I... >, Fn &&fn, const Args &... args) -> skvx::Vec< sizeof...(I), decltype(fn(args[0]...))>
static constexpr uint8_t kAdvancePC
static constexpr uint8_t kNullCheck
static uint8_t Read(ReadStream *stream, int32_t *arg1, int32_t *arg2=nullptr)
static void Write(BaseWriteStream *stream, uint8_t op, int32_t arg1=0, int32_t arg2=0)
static constexpr uint8_t kPopFunction
static constexpr uint8_t kPushFunction
static constexpr uint8_t kChangePosition
const Array * handler_types
const intptr_t inlining_id
InstructionSource(TokenPosition pos, intptr_t id)
const TokenPosition token_pos
InstructionSource(TokenPosition pos)