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

Side by Side Diff: runtime/vm/flow_graph_builder.cc

Issue 1222863003: Make frequent type checks (instanceof) faster by adding dedicated instanceof methods; improves dart… (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: flag Created 5 years, 5 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 unified diff | Download patch
« no previous file with comments | « runtime/vm/bootstrap_natives.h ('k') | runtime/vm/flow_graph_optimizer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/flow_graph_builder.h" 5 #include "vm/flow_graph_builder.h"
6 6
7 #include "lib/invocation_mirror.h" 7 #include "lib/invocation_mirror.h"
8 #include "vm/ast_printer.h" 8 #include "vm/ast_printer.h"
9 #include "vm/bit_vector.h" 9 #include "vm/bit_vector.h"
10 #include "vm/class_finalizer.h" 10 #include "vm/class_finalizer.h"
(...skipping 1793 matching lines...) Expand 10 before | Expand all | Expand 10 after
1804 // Must evaluate left side. 1804 // Must evaluate left side.
1805 EffectGraphVisitor for_left_value(owner()); 1805 EffectGraphVisitor for_left_value(owner());
1806 node->left()->Visit(&for_left_value); 1806 node->left()->Visit(&for_left_value);
1807 Append(for_left_value); 1807 Append(for_left_value);
1808 ReturnDefinition(new(Z) ConstantInstr(Bool::Get(!negate_result))); 1808 ReturnDefinition(new(Z) ConstantInstr(Bool::Get(!negate_result)));
1809 return; 1809 return;
1810 } 1810 }
1811 ValueGraphVisitor for_left_value(owner()); 1811 ValueGraphVisitor for_left_value(owner());
1812 node->left()->Visit(&for_left_value); 1812 node->left()->Visit(&for_left_value);
1813 Append(for_left_value); 1813 Append(for_left_value);
1814
1815 if (!FLAG_warn_on_javascript_compatibility) {
1816 if (type.IsNumberType() || type.IsIntType() || type.IsDoubleType() ||
1817 type.IsSmiType() || type.IsStringType()) {
1818 String& method_name = String::ZoneHandle(Z);
1819 if (type.IsNumberType()) {
1820 method_name = Symbols::_instanceOfNum().raw();
1821 } else if (type.IsIntType()) {
1822 method_name = Symbols::_instanceOfInt().raw();
1823 } else if (type.IsDoubleType()) {
1824 method_name = Symbols::_instanceOfDouble().raw();
1825 } else if (type.IsSmiType()) {
1826 method_name = Symbols::_instanceOfSmi().raw();
1827 } else if (type.IsStringType()) {
1828 method_name = Symbols::_instanceOfString().raw();
1829 }
1830 ASSERT(!method_name.IsNull());
1831 PushArgumentInstr* push_left = PushArgument(for_left_value.value());
1832 ZoneGrowableArray<PushArgumentInstr*>* arguments =
1833 new(Z) ZoneGrowableArray<PushArgumentInstr*>(2);
1834 arguments->Add(push_left);
1835 const Bool& negate = Bool::Get(node->kind() == Token::kISNOT);
1836 Value* negate_arg = Bind(new(Z) ConstantInstr(negate));
1837 arguments->Add(PushArgument(negate_arg));
1838 const intptr_t kNumArgsChecked = 1;
1839 InstanceCallInstr* call = new(Z) InstanceCallInstr(
1840 node->token_pos(),
1841 Library::PrivateCoreLibName(method_name),
1842 node->kind(),
1843 arguments,
1844 Object::null_array(), // No argument names.
1845 kNumArgsChecked,
1846 owner()->ic_data_array());
1847 ReturnDefinition(call);
1848 return;
1849 }
1850 }
1851
1814 PushArgumentInstr* push_left = PushArgument(for_left_value.value()); 1852 PushArgumentInstr* push_left = PushArgument(for_left_value.value());
1815 PushArgumentInstr* push_instantiator = NULL; 1853 PushArgumentInstr* push_instantiator = NULL;
1816 PushArgumentInstr* push_type_args = NULL; 1854 PushArgumentInstr* push_type_args = NULL;
1817 if (type.IsInstantiated()) { 1855 if (type.IsInstantiated()) {
1818 push_instantiator = PushArgument(BuildNullValue()); 1856 push_instantiator = PushArgument(BuildNullValue());
1819 push_type_args = PushArgument(BuildNullValue()); 1857 push_type_args = PushArgument(BuildNullValue());
1820 } else { 1858 } else {
1821 BuildTypecheckPushArguments(node->token_pos(), 1859 BuildTypecheckPushArguments(node->token_pos(),
1822 &push_instantiator, 1860 &push_instantiator,
1823 &push_type_args); 1861 &push_type_args);
1824 } 1862 }
1825 ZoneGrowableArray<PushArgumentInstr*>* arguments = 1863 ZoneGrowableArray<PushArgumentInstr*>* arguments =
1826 new(Z) ZoneGrowableArray<PushArgumentInstr*>(5); 1864 new(Z) ZoneGrowableArray<PushArgumentInstr*>(5);
1827 arguments->Add(push_left); 1865 arguments->Add(push_left);
1828 arguments->Add(push_instantiator); 1866 arguments->Add(push_instantiator);
1829 arguments->Add(push_type_args); 1867 arguments->Add(push_type_args);
1830 ASSERT(!node->right()->AsTypeNode()->type().IsNull()); 1868 ASSERT(!node->right()->AsTypeNode()->type().IsNull());
1831 Value* type_arg = Bind( 1869 Value* type_const = Bind(new(Z) ConstantInstr(type));
1832 new(Z) ConstantInstr(node->right()->AsTypeNode()->type())); 1870 arguments->Add(PushArgument(type_const));
1833 arguments->Add(PushArgument(type_arg));
1834 const Bool& negate = Bool::Get(node->kind() == Token::kISNOT); 1871 const Bool& negate = Bool::Get(node->kind() == Token::kISNOT);
1835 Value* negate_arg = Bind(new(Z) ConstantInstr(negate)); 1872 Value* negate_arg = Bind(new(Z) ConstantInstr(negate));
1836 arguments->Add(PushArgument(negate_arg)); 1873 arguments->Add(PushArgument(negate_arg));
1837 const intptr_t kNumArgsChecked = 1; 1874 const intptr_t kNumArgsChecked = 1;
1838 InstanceCallInstr* call = new(Z) InstanceCallInstr( 1875 InstanceCallInstr* call = new(Z) InstanceCallInstr(
1839 node->token_pos(), 1876 node->token_pos(),
1840 Library::PrivateCoreLibName(Symbols::_instanceOf()), 1877 Library::PrivateCoreLibName(Symbols::_instanceOf()),
1841 node->kind(), 1878 node->kind(),
1842 arguments, 1879 arguments,
1843 Object::null_array(), // No argument names. 1880 Object::null_array(), // No argument names.
(...skipping 2921 matching lines...) Expand 10 before | Expand all | Expand 10 after
4765 Report::MessageF(Report::kBailout, 4802 Report::MessageF(Report::kBailout,
4766 Script::Handle(function.script()), 4803 Script::Handle(function.script()),
4767 function.token_pos(), 4804 function.token_pos(),
4768 "FlowGraphBuilder Bailout: %s %s", 4805 "FlowGraphBuilder Bailout: %s %s",
4769 String::Handle(function.name()).ToCString(), 4806 String::Handle(function.name()).ToCString(),
4770 reason); 4807 reason);
4771 UNREACHABLE(); 4808 UNREACHABLE();
4772 } 4809 }
4773 4810
4774 } // namespace dart 4811 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/bootstrap_natives.h ('k') | runtime/vm/flow_graph_optimizer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698