Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1892)

Unified Diff: runtime/vm/intermediate_language.cc

Issue 10542167: Inline Math.sqrt in new compilers. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: runtime/vm/intermediate_language.cc
===================================================================
--- runtime/vm/intermediate_language.cc (revision 8696)
+++ runtime/vm/intermediate_language.cc (working copy)
@@ -15,6 +15,42 @@
namespace dart {
+MethodRecognizer::Kind MethodRecognizer::RecognizeKind(
+ const Function& function) {
+ // Only core library methods can be recognized.
+ const Library& core_lib = Library::Handle(Library::CoreLibrary());
+ const Library& core_impl_lib = Library::Handle(Library::CoreImplLibrary());
+ const Class& function_class = Class::Handle(function.owner());
+ if ((function_class.library() != core_lib.raw()) &&
+ (function_class.library() != core_impl_lib.raw())) {
+ return kUnknown;
+ }
+ const String& recognize_name = String::Handle(function.name());
+ const String& recognize_class = String::Handle(function_class.Name());
+ String& test_function_name = String::Handle();
+ String& test_class_name = String::Handle();
+#define RECOGNIZE_FUNCTION(class_name, function_name, enum_name) \
+ test_function_name = String::NewSymbol(#function_name); \
+ test_class_name = String::NewSymbol(#class_name); \
+ if (recognize_name.Equals(test_function_name) && \
+ recognize_class.Equals(test_class_name)) { \
+ return k##enum_name; \
+ }
+RECOGNIZED_LIST(RECOGNIZE_FUNCTION)
+#undef RECOGNIZE_FUNCTION
+ return kUnknown;
+}
+
+
+const char* MethodRecognizer::KindToCString(Kind kind) {
+#define KIND_TO_STRING(class_name, function_name, enum_name) \
+ if (kind == k##enum_name) return #enum_name;
+RECOGNIZED_LIST(KIND_TO_STRING)
+#undef KIND_TO_STRING
+ return "?";
+}
+
+
// ==== Support for visiting flow graphs.
#define DEFINE_ACCEPT(ShortName, ClassName) \
void ClassName::Accept(FlowGraphVisitor* visitor) { \
@@ -37,7 +73,7 @@
#undef DEFINE_ACCEPT
-// Truee iff. the v2 is above v1 on stack, or one of them is constant.
+// True iff. the v2 is above v1 on stack, or one of them is constant.
static bool VerifyValues(Value* v1, Value* v2) {
ASSERT(v1->IsUse() && v2->IsUse());
return (v1->AsUse()->definition()->temp_index() + 1) ==
@@ -1005,12 +1041,17 @@
void StaticCallComp::EmitNativeCode(FlowGraphCompiler* compiler) {
ASSERT(VerifyCallComputation(this));
+ Label done;
+ if (recognized() == MethodRecognizer::kMathSqrt) {
+ compiler->GenerateInlinedMathSqrt(&done);
srdjan 2012/06/14 23:30:08 Add comment that it fall throughs to static call.
regis 2012/06/15 00:33:59 Done.
+ }
compiler->GenerateStaticCall(cid(),
token_index(),
try_index(),
function(),
ArgumentCount(),
argument_names());
+ __ Bind(&done);
}

Powered by Google App Engine
This is Rietveld 408576698