Skip to content

Commit

Permalink
[VM] Allow intrinsification of implicit field getters in checked/stro…
Browse files Browse the repository at this point in the history
…ng mode

Since implicit field getters have the receiver as the only argument
(on which don't have to perform any type checks), we can allow
intrinsification of implicit getters even in checked/strong mode.

Issue #31798

Change-Id: If08c6ee33818ab513a9dbf1457fede0eeb8c4404
Reviewed-on: https://dart-review.googlesource.com/34142
Reviewed-by: Vyacheslav Egorov <[email protected]>
Commit-Queue: Vyacheslav Egorov <[email protected]>
  • Loading branch information
mkustermann authored and [email protected] committed Jan 12, 2018
1 parent d48e4e6 commit fd16b58
Showing 1 changed file with 21 additions and 15 deletions.
36 changes: 21 additions & 15 deletions runtime/vm/compiler/backend/flow_graph_compiler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -984,12 +984,16 @@ void FlowGraphCompiler::FinalizeCodeSourceMap(const Code& code) {

// Returns 'true' if regular code generation should be skipped.
bool FlowGraphCompiler::TryIntrinsify() {
// Intrinsification skips arguments checks, therefore disable if in checked
// mode or strong mode.
if (FLAG_intrinsify && !isolate()->argument_type_checks()) {
if (FLAG_intrinsify) {
const Class& owner = Class::Handle(parsed_function().function().Owner());
String& name = String::Handle(parsed_function().function().name());

// Intrinsification skips arguments checks, therefore disable if in checked
// mode or strong mode.
//
// Though for implicit getters, which have only the receiver as parameter,
// there are no checks necessary in any case and we can therefore intrinsify
// them even in checked mode and strong mode.
if (parsed_function().function().kind() == RawFunction::kImplicitGetter) {
// TODO(27590) Store Field object inside RawFunction::data_ if possible.
name = Field::NameFromGetter(name);
Expand All @@ -1004,19 +1008,21 @@ bool FlowGraphCompiler::TryIntrinsify() {
return !isolate()->use_field_guards();
}
return false;
}
if (parsed_function().function().kind() == RawFunction::kImplicitSetter) {
// TODO(27590) Store Field object inside RawFunction::data_ if possible.
name = Field::NameFromSetter(name);
const Field& field = Field::Handle(owner.LookupFieldAllowPrivate(name));
ASSERT(!field.IsNull());

if (field.is_instance() &&
(FLAG_precompiled_mode || field.guarded_cid() == kDynamicCid)) {
GenerateInlinedSetter(field.Offset());
return !isolate()->use_field_guards();
} else if (parsed_function().function().kind() ==
RawFunction::kImplicitSetter) {
if (!isolate()->argument_type_checks()) {
// TODO(27590) Store Field object inside RawFunction::data_ if possible.
name = Field::NameFromSetter(name);
const Field& field = Field::Handle(owner.LookupFieldAllowPrivate(name));
ASSERT(!field.IsNull());

if (field.is_instance() &&
(FLAG_precompiled_mode || field.guarded_cid() == kDynamicCid)) {
GenerateInlinedSetter(field.Offset());
return !isolate()->use_field_guards();
}
return false;
}
return false;
}
}

Expand Down

0 comments on commit fd16b58

Please sign in to comment.