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

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

Issue 12090010: Added result cids to some natives (byte array _new). (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | runtime/vm/symbols.h » ('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 "vm/ast_printer.h" 7 #include "vm/ast_printer.h"
8 #include "vm/code_descriptors.h" 8 #include "vm/code_descriptors.h"
9 #include "vm/dart_entry.h" 9 #include "vm/dart_entry.h"
10 #include "vm/flags.h" 10 #include "vm/flags.h"
(...skipping 1768 matching lines...) Expand 10 before | Expand all | Expand 10 after
1779 1779
1780 BuildPushArguments(*node->arguments(), arguments); 1780 BuildPushArguments(*node->arguments(), arguments);
1781 InstanceCallInstr* call = new InstanceCallInstr( 1781 InstanceCallInstr* call = new InstanceCallInstr(
1782 node->token_pos(), 1782 node->token_pos(),
1783 node->function_name(), Token::kILLEGAL, arguments, 1783 node->function_name(), Token::kILLEGAL, arguments,
1784 node->arguments()->names(), 1); 1784 node->arguments()->names(), 1);
1785 ReturnDefinition(call); 1785 ReturnDefinition(call);
1786 } 1786 }
1787 1787
1788 1788
1789 static intptr_t GetResultCidOfNative(const Function& function) {
1790 const Class& function_class = Class::Handle(function.Owner());
1791 if (function_class.library() == Library::ScalarlistLibrary()) {
1792 const String& function_name = String::Handle(function.name());
1793 if (!String::EqualsIgnoringPrivateKey(function_name, Symbols::_New())) {
1794 return kDynamicCid;
1795 }
1796 switch (function_class.id()) {
1797 case kInt8ArrayCid:
1798 case kUint8ArrayCid:
1799 case kUint8ClampedArrayCid:
1800 case kInt16ArrayCid:
1801 case kUint16ArrayCid:
1802 case kInt32ArrayCid:
1803 case kUint32ArrayCid:
1804 case kInt64ArrayCid:
1805 case kUint64ArrayCid:
1806 case kFloat32ArrayCid:
1807 case kFloat64ArrayCid:
1808 return function_class.id();
1809 default:
1810 return kDynamicCid; // Unknown.
1811 }
1812 }
1813 return kDynamicCid;
1814 }
1815
1816
1789 // <Expression> ::= StaticCall { function: Function 1817 // <Expression> ::= StaticCall { function: Function
1790 // arguments: <ArgumentList> } 1818 // arguments: <ArgumentList> }
1791 void EffectGraphVisitor::VisitStaticCallNode(StaticCallNode* node) { 1819 void EffectGraphVisitor::VisitStaticCallNode(StaticCallNode* node) {
1792 if (node->function().name() == Symbols::Identical().raw()) { 1820 if (node->function().name() == Symbols::Identical().raw()) {
1793 // Attempt to replace top level defined 'identical' from the core 1821 // Attempt to replace top level defined 'identical' from the core
1794 // library with strict equal early on. 1822 // library with strict equal early on.
1795 // TODO(hausner): Evaluate if this can happen at AST building time. 1823 // TODO(hausner): Evaluate if this can happen at AST building time.
1796 const Class& cls = Class::Handle(node->function().Owner()); 1824 const Class& cls = Class::Handle(node->function().Owner());
1797 if (cls.IsTopLevel()) { 1825 if (cls.IsTopLevel()) {
1798 const Library& core_lib = Library::Handle(Library::CoreLibrary()); 1826 const Library& core_lib = Library::Handle(Library::CoreLibrary());
(...skipping 15 matching lines...) Expand all
1814 } 1842 }
1815 } 1843 }
1816 ZoneGrowableArray<PushArgumentInstr*>* arguments = 1844 ZoneGrowableArray<PushArgumentInstr*>* arguments =
1817 new ZoneGrowableArray<PushArgumentInstr*>(node->arguments()->length()); 1845 new ZoneGrowableArray<PushArgumentInstr*>(node->arguments()->length());
1818 BuildPushArguments(*node->arguments(), arguments); 1846 BuildPushArguments(*node->arguments(), arguments);
1819 StaticCallInstr* call = 1847 StaticCallInstr* call =
1820 new StaticCallInstr(node->token_pos(), 1848 new StaticCallInstr(node->token_pos(),
1821 node->function(), 1849 node->function(),
1822 node->arguments()->names(), 1850 node->arguments()->names(),
1823 arguments); 1851 arguments);
1852 if (node->function().is_native()) {
1853 const intptr_t result_cid = GetResultCidOfNative(node->function());
1854 call->set_result_cid(result_cid);
1855 }
1824 ReturnDefinition(call); 1856 ReturnDefinition(call);
1825 } 1857 }
1826 1858
1827 1859
1828 ClosureCallInstr* EffectGraphVisitor::BuildClosureCall( 1860 ClosureCallInstr* EffectGraphVisitor::BuildClosureCall(
1829 ClosureCallNode* node) { 1861 ClosureCallNode* node) {
1830 ValueGraphVisitor for_closure(owner(), temp_index()); 1862 ValueGraphVisitor for_closure(owner(), temp_index());
1831 node->closure()->Visit(&for_closure); 1863 node->closure()->Visit(&for_closure);
1832 Append(for_closure); 1864 Append(for_closure);
1833 PushArgumentInstr* push_closure = PushArgument(for_closure.value()); 1865 PushArgumentInstr* push_closure = PushArgument(for_closure.value());
(...skipping 1363 matching lines...) Expand 10 before | Expand all | Expand 10 after
3197 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1; 3229 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1;
3198 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); 3230 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len);
3199 OS::SNPrint(chars, len, kFormat, function_name, reason); 3231 OS::SNPrint(chars, len, kFormat, function_name, reason);
3200 const Error& error = Error::Handle( 3232 const Error& error = Error::Handle(
3201 LanguageError::New(String::Handle(String::New(chars)))); 3233 LanguageError::New(String::Handle(String::New(chars))));
3202 Isolate::Current()->long_jump_base()->Jump(1, error); 3234 Isolate::Current()->long_jump_base()->Jump(1, error);
3203 } 3235 }
3204 3236
3205 3237
3206 } // namespace dart 3238 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/symbols.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698