14f6276945
Devirtualization optimization now adds metadata to kernel AST instead of transforming nodes to Direct* ones. The direct call metadata provides information about checking receiver for null, while Direct* kernel nodes do not support null checking. VM's kernel binary loader is extended to extract arbitrary metadata from kernel binaries and keep it for flow graph builder. Kernel flow graph builder is extended to take direct call metadata into account and generate CheckNull/StaticCall instructions for devirtualized PropertyGet, PropertySet and MethodInvocation nodes. Issue: https://github.com/dart-lang/sdk/issues/30480 Change-Id: I57f56fbf4a8981d33b1571c0d93105cf8ca71d76 Reviewed-on: https://dart-review.googlesource.com/12260 Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
35 lines
1.3 KiB
C++
35 lines
1.3 KiB
C++
// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
#include "vm/kernel.h"
|
|
#include "vm/compiler/frontend/kernel_binary_flowgraph.h"
|
|
|
|
#if !defined(DART_PRECOMPILED_RUNTIME)
|
|
namespace dart {
|
|
|
|
namespace kernel {
|
|
|
|
bool FieldHasFunctionLiteralInitializer(const Field& field,
|
|
TokenPosition* start,
|
|
TokenPosition* end) {
|
|
Zone* zone = Thread::Current()->zone();
|
|
const Script& script = Script::Handle(zone, field.Script());
|
|
|
|
TranslationHelper translation_helper(Thread::Current());
|
|
translation_helper.InitFromScript(script);
|
|
|
|
StreamingFlowGraphBuilder builder(&translation_helper, field.Script(), zone,
|
|
TypedData::Handle(zone, field.KernelData()),
|
|
field.KernelDataProgramOffset());
|
|
builder.SetOffset(field.kernel_offset());
|
|
kernel::FieldHelper field_helper(&builder);
|
|
field_helper.ReadUntilExcluding(kernel::FieldHelper::kEnd, true);
|
|
return field_helper.FieldHasFunctionLiteralInitializer(start, end);
|
|
}
|
|
|
|
} // namespace kernel
|
|
|
|
} // namespace dart
|
|
#endif // !defined(DART_PRECOMPILED_RUNTIME)
|