mirror of
https://github.com/dart-lang/sdk
synced 2024-11-02 08:20:31 +00:00
[ Service / AOT ] Include line numbers for Functions in AOT snapshots
Fixes https://github.com/dart-lang/sdk/issues/48839 TEST=Checked CPU profile for Flutter Gallery in profile mode Change-Id: I83f372aebd77b93b459720ceb2dd9e5fa05b4475 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/245200 Commit-Queue: Ben Konyi <bkonyi@google.com> Reviewed-by: Ryan Macnak <rmacnak@google.com>
This commit is contained in:
parent
aa0d0c56cb
commit
4e688b1a59
8 changed files with 73 additions and 13 deletions
|
@ -1027,12 +1027,33 @@ class FunctionSerializationCluster : public SerializationCluster {
|
|||
if (kind != Snapshot::kFullAOT) {
|
||||
NOT_IN_PRECOMPILED(
|
||||
WriteCompressedField(func, positional_parameter_names));
|
||||
}
|
||||
|
||||
#if defined(DART_PRECOMPILER) && !defined(PRODUCT)
|
||||
TokenPosition token_pos = func->untag()->token_pos_;
|
||||
if (kind == Snapshot::kFullAOT) {
|
||||
// We use then token_pos property to store the line number
|
||||
// in AOT snapshots.
|
||||
intptr_t line = -1;
|
||||
const Function& function = Function::Handle(func);
|
||||
const Script& script = Script::Handle(function.script());
|
||||
if (!script.IsNull()) {
|
||||
script.GetTokenLocation(token_pos, &line, nullptr);
|
||||
}
|
||||
token_pos = line == -1 ? TokenPosition::kNoSource
|
||||
: TokenPosition::Deserialize(line);
|
||||
}
|
||||
s->WriteTokenPosition(token_pos);
|
||||
#else
|
||||
if (kind != Snapshot::kFullAOT) {
|
||||
s->WriteTokenPosition(func->untag()->token_pos_);
|
||||
}
|
||||
#endif
|
||||
if (kind != Snapshot::kFullAOT) {
|
||||
s->WriteTokenPosition(func->untag()->end_token_pos_);
|
||||
s->Write<uint32_t>(func->untag()->kernel_offset_);
|
||||
s->Write<uint32_t>(func->untag()->packed_fields_);
|
||||
}
|
||||
|
||||
s->Write<uint32_t>(func->untag()->kind_tag_);
|
||||
}
|
||||
}
|
||||
|
@ -1188,12 +1209,18 @@ class FunctionDeserializationCluster : public DeserializationCluster {
|
|||
ASSERT(kind != Snapshot::kFullAOT);
|
||||
func->untag()->positional_parameter_names_ =
|
||||
static_cast<ArrayPtr>(d.ReadRef());
|
||||
#endif
|
||||
#if !defined(DART_PRECOMPILED_RUNTIME) || \
|
||||
(defined(DART_PRECOMPILED_RUNTIME) && !defined(PRODUCT))
|
||||
func->untag()->token_pos_ = d.ReadTokenPosition();
|
||||
#endif
|
||||
#if !defined(DART_PRECOMPILED_RUNTIME)
|
||||
func->untag()->end_token_pos_ = d.ReadTokenPosition();
|
||||
func->untag()->kernel_offset_ = d.Read<uint32_t>();
|
||||
func->untag()->unboxed_parameters_info_.Reset();
|
||||
func->untag()->packed_fields_ = d.Read<uint32_t>();
|
||||
#endif
|
||||
|
||||
func->untag()->kind_tag_ = d.Read<uint32_t>();
|
||||
#if !defined(DART_PRECOMPILED_RUNTIME)
|
||||
func->untag()->usage_counter_ = 0;
|
||||
|
|
|
@ -10102,7 +10102,7 @@ static constexpr dart::compiler::target::word AOT_Function_code_offset = 32;
|
|||
static constexpr dart::compiler::target::word AOT_Function_data_offset = 24;
|
||||
static constexpr dart::compiler::target::word
|
||||
AOT_Function_entry_point_offset[] = {4, 8};
|
||||
static constexpr dart::compiler::target::word AOT_Function_kind_tag_offset = 36;
|
||||
static constexpr dart::compiler::target::word AOT_Function_kind_tag_offset = 40;
|
||||
static constexpr dart::compiler::target::word AOT_Function_signature_offset =
|
||||
20;
|
||||
static constexpr dart::compiler::target::word
|
||||
|
@ -10563,7 +10563,7 @@ static constexpr dart::compiler::target::word AOT_NativeFinalizer_InstanceSize =
|
|||
24;
|
||||
static constexpr dart::compiler::target::word AOT_Float32x4_InstanceSize = 24;
|
||||
static constexpr dart::compiler::target::word AOT_Float64x2_InstanceSize = 24;
|
||||
static constexpr dart::compiler::target::word AOT_Function_InstanceSize = 40;
|
||||
static constexpr dart::compiler::target::word AOT_Function_InstanceSize = 44;
|
||||
static constexpr dart::compiler::target::word AOT_FunctionType_InstanceSize =
|
||||
40;
|
||||
static constexpr dart::compiler::target::word AOT_FutureOr_InstanceSize = 8;
|
||||
|
@ -10798,7 +10798,7 @@ static constexpr dart::compiler::target::word AOT_Function_code_offset = 64;
|
|||
static constexpr dart::compiler::target::word AOT_Function_data_offset = 48;
|
||||
static constexpr dart::compiler::target::word
|
||||
AOT_Function_entry_point_offset[] = {8, 16};
|
||||
static constexpr dart::compiler::target::word AOT_Function_kind_tag_offset = 72;
|
||||
static constexpr dart::compiler::target::word AOT_Function_kind_tag_offset = 76;
|
||||
static constexpr dart::compiler::target::word AOT_Function_signature_offset =
|
||||
40;
|
||||
static constexpr dart::compiler::target::word
|
||||
|
@ -11500,7 +11500,7 @@ static constexpr dart::compiler::target::word AOT_Function_code_offset = 64;
|
|||
static constexpr dart::compiler::target::word AOT_Function_data_offset = 48;
|
||||
static constexpr dart::compiler::target::word
|
||||
AOT_Function_entry_point_offset[] = {8, 16};
|
||||
static constexpr dart::compiler::target::word AOT_Function_kind_tag_offset = 72;
|
||||
static constexpr dart::compiler::target::word AOT_Function_kind_tag_offset = 76;
|
||||
static constexpr dart::compiler::target::word AOT_Function_signature_offset =
|
||||
40;
|
||||
static constexpr dart::compiler::target::word
|
||||
|
@ -12199,7 +12199,7 @@ static constexpr dart::compiler::target::word AOT_Function_code_offset = 44;
|
|||
static constexpr dart::compiler::target::word AOT_Function_data_offset = 36;
|
||||
static constexpr dart::compiler::target::word
|
||||
AOT_Function_entry_point_offset[] = {8, 16};
|
||||
static constexpr dart::compiler::target::word AOT_Function_kind_tag_offset = 48;
|
||||
static constexpr dart::compiler::target::word AOT_Function_kind_tag_offset = 52;
|
||||
static constexpr dart::compiler::target::word AOT_Function_signature_offset =
|
||||
32;
|
||||
static constexpr dart::compiler::target::word
|
||||
|
@ -12897,7 +12897,7 @@ static constexpr dart::compiler::target::word AOT_Function_code_offset = 44;
|
|||
static constexpr dart::compiler::target::word AOT_Function_data_offset = 36;
|
||||
static constexpr dart::compiler::target::word
|
||||
AOT_Function_entry_point_offset[] = {8, 16};
|
||||
static constexpr dart::compiler::target::word AOT_Function_kind_tag_offset = 48;
|
||||
static constexpr dart::compiler::target::word AOT_Function_kind_tag_offset = 52;
|
||||
static constexpr dart::compiler::target::word AOT_Function_signature_offset =
|
||||
32;
|
||||
static constexpr dart::compiler::target::word
|
||||
|
@ -13596,7 +13596,7 @@ static constexpr dart::compiler::target::word AOT_Function_code_offset = 32;
|
|||
static constexpr dart::compiler::target::word AOT_Function_data_offset = 24;
|
||||
static constexpr dart::compiler::target::word
|
||||
AOT_Function_entry_point_offset[] = {4, 8};
|
||||
static constexpr dart::compiler::target::word AOT_Function_kind_tag_offset = 36;
|
||||
static constexpr dart::compiler::target::word AOT_Function_kind_tag_offset = 40;
|
||||
static constexpr dart::compiler::target::word AOT_Function_signature_offset =
|
||||
20;
|
||||
static constexpr dart::compiler::target::word
|
||||
|
@ -14059,7 +14059,7 @@ static constexpr dart::compiler::target::word AOT_NativeFinalizer_InstanceSize =
|
|||
24;
|
||||
static constexpr dart::compiler::target::word AOT_Float32x4_InstanceSize = 24;
|
||||
static constexpr dart::compiler::target::word AOT_Float64x2_InstanceSize = 24;
|
||||
static constexpr dart::compiler::target::word AOT_Function_InstanceSize = 40;
|
||||
static constexpr dart::compiler::target::word AOT_Function_InstanceSize = 44;
|
||||
static constexpr dart::compiler::target::word AOT_FunctionType_InstanceSize =
|
||||
40;
|
||||
static constexpr dart::compiler::target::word AOT_FutureOr_InstanceSize = 8;
|
||||
|
@ -14294,7 +14294,7 @@ static constexpr dart::compiler::target::word AOT_Function_code_offset = 64;
|
|||
static constexpr dart::compiler::target::word AOT_Function_data_offset = 48;
|
||||
static constexpr dart::compiler::target::word
|
||||
AOT_Function_entry_point_offset[] = {8, 16};
|
||||
static constexpr dart::compiler::target::word AOT_Function_kind_tag_offset = 72;
|
||||
static constexpr dart::compiler::target::word AOT_Function_kind_tag_offset = 76;
|
||||
static constexpr dart::compiler::target::word AOT_Function_signature_offset =
|
||||
40;
|
||||
static constexpr dart::compiler::target::word
|
||||
|
|
|
@ -542,6 +542,16 @@ void JSONObject::AddLocation(const BreakpointLocation* bpt_loc) const {
|
|||
AddLocation(script, token_pos);
|
||||
}
|
||||
|
||||
void JSONObject::AddLocationLine(const Script& script, intptr_t line) const {
|
||||
JSONObject location(this, "location");
|
||||
location.AddProperty("type", "SourceLocation");
|
||||
location.AddProperty("script", script);
|
||||
location.AddProperty("tokenPos", TokenPosition::kNoSource);
|
||||
if (line > 0) {
|
||||
location.AddProperty("line", line);
|
||||
}
|
||||
}
|
||||
|
||||
void JSONObject::AddUnresolvedLocation(
|
||||
const BreakpointLocation* bpt_loc) const {
|
||||
ASSERT(!bpt_loc->IsResolved());
|
||||
|
|
|
@ -376,6 +376,7 @@ class JSONObject : public ValueObject {
|
|||
TokenPosition end_token_pos = TokenPosition::kNoSource) const;
|
||||
|
||||
void AddLocation(const BreakpointLocation* bpt_loc) const;
|
||||
void AddLocationLine(const Script& script, intptr_t line) const;
|
||||
|
||||
void AddUnresolvedLocation(const BreakpointLocation* bpt_loc) const;
|
||||
|
||||
|
|
|
@ -9693,7 +9693,7 @@ ScriptPtr Function::script() const {
|
|||
}
|
||||
if (IsImplicitGetterOrSetter()) {
|
||||
const auto& field = Field::Handle(accessor_field());
|
||||
return field.Script();
|
||||
return field.IsNull() ? Script::null() : field.Script();
|
||||
}
|
||||
Object& data = Object::Handle(this->data());
|
||||
if (data.IsArray()) {
|
||||
|
@ -9716,9 +9716,7 @@ ScriptPtr Function::script() const {
|
|||
}
|
||||
if (IsClosureFunction()) {
|
||||
const Function& function = Function::Handle(parent_function());
|
||||
#if defined(DART_PRECOMPILED_RUNTIME)
|
||||
if (function.IsNull()) return Script::null();
|
||||
#endif
|
||||
return function.script();
|
||||
}
|
||||
ASSERT(obj.IsClass());
|
||||
|
|
|
@ -3138,6 +3138,17 @@ class Function : public Object {
|
|||
#endif
|
||||
}
|
||||
|
||||
#if !defined(PRODUCT) && \
|
||||
(defined(DART_PRECOMPILER) || defined(DART_PRECOMPILED_RUNTIME))
|
||||
int32_t line() const {
|
||||
return untag()->token_pos_.Serialize();
|
||||
}
|
||||
|
||||
void set_line(int32_t line) const {
|
||||
StoreNonPointer(&untag()->token_pos_, TokenPosition::Deserialize(line));
|
||||
}
|
||||
#endif
|
||||
|
||||
// Returns the size of the source for this function.
|
||||
intptr_t SourceSize() const;
|
||||
|
||||
|
|
|
@ -346,7 +346,13 @@ void Function::PrintJSONImpl(JSONStream* stream, bool ref) const {
|
|||
|
||||
const Script& script = Script::Handle(this->script());
|
||||
if (!script.IsNull()) {
|
||||
#if defined(DART_PRECOMPILED_RUNTIME)
|
||||
// Token position information is stripped in AOT snapshots, but the line
|
||||
// number is still included.
|
||||
jsobj.AddLocationLine(script, line());
|
||||
#else
|
||||
jsobj.AddLocation(script, token_pos(), end_token_pos());
|
||||
#endif // defined(DART_PRECOMPILED_RUNTIME)
|
||||
}
|
||||
|
||||
if (ref) {
|
||||
|
|
|
@ -1325,7 +1325,14 @@ class UntaggedFunction : public UntaggedObject {
|
|||
VISIT_TO(unoptimized_code);
|
||||
|
||||
UnboxedParameterBitmap unboxed_parameters_info_;
|
||||
#endif
|
||||
|
||||
#if !defined(DART_PRECOMPILED_RUNTIME) || \
|
||||
(defined(DART_PRECOMPILED_RUNTIME) && !defined(PRODUCT))
|
||||
TokenPosition token_pos_;
|
||||
#endif
|
||||
|
||||
#if !defined(DART_PRECOMPILED_RUNTIME)
|
||||
TokenPosition end_token_pos_;
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Reference in a new issue