Files
sdk/runtime/vm/method_recognizer.cc
T
fschneider@google.com 4983823977 VM: Improve performance of method recognizer and unify the it with the intrinsifier.
The method recognizer is now in a separate file and the intrinsifier uses the
same infrastructure. Each function is marked at initialization time, so that
recognizing a method is a fast operation (reading a field from the Function object)

I cleaned the symbol table from unused symbols since I had to regenerate the
binary snapshot in the repository anyway for this change.

I had to rename the methods that are duplicated between the recognized method list
and the intrinsics list to match the naming convention used by the method recognizer.
I left the other intrinsics unchanged for now. They will be renamed in a future CL.

R=srdjan@google.com

Review URL: https://codereview.chromium.org//468793004

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@39444 260f80e4-7a28-3924-810f-c04153c831b5
2014-08-21 10:21:09 +00:00

83 lines
3.1 KiB
C++

// Copyright (c) 2014, 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/method_recognizer.h"
#include "vm/object.h"
#include "vm/symbols.h"
namespace dart {
MethodRecognizer::Kind MethodRecognizer::RecognizeKind(
const Function& function) {
return function.recognized_kind();
}
bool MethodRecognizer::AlwaysInline(const Function& function) {
return function.always_inline();
}
bool MethodRecognizer::PolymorphicTarget(const Function& function) {
return function.is_polymorphic_target();
}
const char* MethodRecognizer::KindToCString(Kind kind) {
#define KIND_TO_STRING(class_name, function_name, enum_name, fp) \
if (kind == k##enum_name) return #enum_name;
RECOGNIZED_LIST(KIND_TO_STRING)
#undef KIND_TO_STRING
return "?";
}
void MethodRecognizer::InitializeState() {
GrowableArray<Library*> libs(3);
libs.Add(&Library::ZoneHandle(Library::CoreLibrary()));
libs.Add(&Library::ZoneHandle(Library::MathLibrary()));
libs.Add(&Library::ZoneHandle(Library::TypedDataLibrary()));
libs.Add(&Library::ZoneHandle(Library::InternalLibrary()));
libs.Add(&Library::ZoneHandle(Library::ProfilerLibrary()));
Function& func = Function::Handle();
#define SET_RECOGNIZED_KIND(class_name, function_name, enum_name, fp) \
func = Library::GetFunction(libs, #class_name, #function_name); \
if (func.IsNull()) { \
OS::PrintErr("Missing %s::%s\n", #class_name, #function_name); \
UNREACHABLE(); \
} \
ASSERT(func.CheckSourceFingerprint(fp)); \
func.set_recognized_kind(k##enum_name);
RECOGNIZED_LIST(SET_RECOGNIZED_KIND);
#define SET_FUNCTION_BIT(class_name, function_name, dest, fp, setter_name) \
func = Library::GetFunction(libs, #class_name, #function_name); \
if (func.IsNull()) { \
OS::PrintErr("Missing %s::%s\n", #class_name, #function_name); \
UNREACHABLE(); \
} \
ASSERT(func.CheckSourceFingerprint(fp)); \
func.setter_name(true);
#define SET_IS_ALWAYS_INLINE(class_name, function_name, dest, fp) \
SET_FUNCTION_BIT(class_name, function_name, dest, fp, set_always_inline)
#define SET_IS_POLYMORPHIC_TARGET(class_name, function_name, dest, fp) \
SET_FUNCTION_BIT(class_name, function_name, dest, fp, \
set_is_polymorphic_target)
INLINE_WHITE_LIST(SET_IS_ALWAYS_INLINE);
POLYMORPHIC_TARGET_LIST(SET_IS_POLYMORPHIC_TARGET);
#undef SET_RECOGNIZED_KIND
#undef SET_IS_ALWAYS_INLINE
#undef SET_IS_POLYMORPHIC_TARGET
#undef SET_FUNCTION_BIT
}
} // namespace dart