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

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

Issue 10540040: Inline setters, getters, various cleanups & restructuring. (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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/flow_graph_builder.h ('k') | runtime/vm/flow_graph_compiler_ia32.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/bit_vector.h" 8 #include "vm/bit_vector.h"
9 #include "vm/code_descriptors.h" 9 #include "vm/code_descriptors.h"
10 #include "vm/dart_entry.h" 10 #include "vm/dart_entry.h"
(...skipping 1733 matching lines...) Expand 10 before | Expand all | Expand 10 after
1744 arguments->Add(for_receiver.value()); 1744 arguments->Add(for_receiver.value());
1745 const String& name = 1745 const String& name =
1746 String::ZoneHandle(Field::GetterSymbol(node->field_name())); 1746 String::ZoneHandle(Field::GetterSymbol(node->field_name()));
1747 InstanceCallComp* call = new InstanceCallComp( 1747 InstanceCallComp* call = new InstanceCallComp(
1748 node->token_index(), owner()->try_index(), name, 1748 node->token_index(), owner()->try_index(), name,
1749 arguments, Array::ZoneHandle(), 1); 1749 arguments, Array::ZoneHandle(), 1);
1750 ReturnComputation(call); 1750 ReturnComputation(call);
1751 } 1751 }
1752 1752
1753 1753
1754 void EffectGraphVisitor::VisitInstanceSetterNode(InstanceSetterNode* node) { 1754 void EffectGraphVisitor::BuildInstanceSetterValues(
1755 InstanceSetterNode* node, Value** receiver, Value** value) {
1755 ValueGraphVisitor for_receiver(owner(), temp_index()); 1756 ValueGraphVisitor for_receiver(owner(), temp_index());
1756 node->receiver()->Visit(&for_receiver); 1757 node->receiver()->Visit(&for_receiver);
1757 Append(for_receiver); 1758 Append(for_receiver);
1758 ValueGraphVisitor for_value(owner(), for_receiver.temp_index()); 1759 ValueGraphVisitor for_value(owner(), for_receiver.temp_index());
1759 node->value()->Visit(&for_value); 1760 node->value()->Visit(&for_value);
1760 Append(for_value); 1761 Append(for_value);
1762 *receiver = for_receiver.value();
1763 *value = for_value.value();
1764 }
1765
1766
1767 void EffectGraphVisitor::VisitInstanceSetterNode(InstanceSetterNode* node) {
1768 Value *receiver, *value;
1769 BuildInstanceSetterValues(node, &receiver, &value);
1761 InstanceSetterComp* setter = 1770 InstanceSetterComp* setter =
1762 new InstanceSetterComp(node->token_index(), 1771 new InstanceSetterComp(node->token_index(),
1763 owner()->try_index(), 1772 owner()->try_index(),
1764 node->field_name(), 1773 node->field_name(),
1765 for_receiver.value(), 1774 receiver,
1766 for_value.value()); 1775 value);
1767 ReturnComputation(setter); 1776 ReturnComputation(setter);
1768 } 1777 }
1769 1778
1770 1779
1780 void ValueGraphVisitor::VisitInstanceSetterNode(InstanceSetterNode* node) {
1781 Value *receiver, *value;
1782 BuildInstanceSetterValues(node, &receiver, &value);
1783 BindInstr* store_local_instr = new BindInstr(
1784 BuildStoreLocal(*owner()->parsed_function().expression_temp_var(),
1785 value));
1786 AddInstruction(store_local_instr);
1787 UseVal* saved_value = new UseVal(store_local_instr);
1788 InstanceSetterComp* setter =
1789 new InstanceSetterComp(node->token_index(),
1790 owner()->try_index(),
1791 node->field_name(),
1792 receiver,
1793 saved_value);
1794 AddInstruction(new DoInstr(setter));
1795 ReturnComputation(
1796 BuildLoadLocal(*owner()->parsed_function().expression_temp_var()));
1797 }
1798
1799
1771 void EffectGraphVisitor::VisitStaticGetterNode(StaticGetterNode* node) { 1800 void EffectGraphVisitor::VisitStaticGetterNode(StaticGetterNode* node) {
1772 const String& getter_name = 1801 const String& getter_name =
1773 String::Handle(Field::GetterName(node->field_name())); 1802 String::Handle(Field::GetterName(node->field_name()));
1774 const Function& getter_function = 1803 const Function& getter_function =
1775 Function::ZoneHandle(node->cls().LookupStaticFunction(getter_name)); 1804 Function::ZoneHandle(node->cls().LookupStaticFunction(getter_name));
1776 ASSERT(!getter_function.IsNull()); 1805 ASSERT(!getter_function.IsNull());
1777 ZoneGrowableArray<Value*>* values = new ZoneGrowableArray<Value*>(); 1806 ZoneGrowableArray<Value*>* values = new ZoneGrowableArray<Value*>();
1778 StaticCallComp* call = new StaticCallComp(node->token_index(), 1807 StaticCallComp* call = new StaticCallComp(node->token_index(),
1779 owner()->try_index(), 1808 owner()->try_index(),
1780 getter_function, 1809 getter_function,
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
1847 Computation* store = BuildStoreLocal(node->local(), store_value); 1876 Computation* store = BuildStoreLocal(node->local(), store_value);
1848 ReturnComputation(store); 1877 ReturnComputation(store);
1849 } 1878 }
1850 1879
1851 1880
1852 void EffectGraphVisitor::VisitLoadInstanceFieldNode( 1881 void EffectGraphVisitor::VisitLoadInstanceFieldNode(
1853 LoadInstanceFieldNode* node) { 1882 LoadInstanceFieldNode* node) {
1854 ValueGraphVisitor for_instance(owner(), temp_index()); 1883 ValueGraphVisitor for_instance(owner(), temp_index());
1855 node->instance()->Visit(&for_instance); 1884 node->instance()->Visit(&for_instance);
1856 Append(for_instance); 1885 Append(for_instance);
1857 LoadInstanceFieldComp* load = 1886 LoadInstanceFieldComp* load = new LoadInstanceFieldComp(
1858 new LoadInstanceFieldComp(node, for_instance.value()); 1887 node->field(), for_instance.value(), NULL, NULL);
1859 ReturnComputation(load); 1888 ReturnComputation(load);
1860 } 1889 }
1861 1890
1862 1891
1863 void EffectGraphVisitor::VisitStoreInstanceFieldNode( 1892 void EffectGraphVisitor::VisitStoreInstanceFieldNode(
1864 StoreInstanceFieldNode* node) { 1893 StoreInstanceFieldNode* node) {
1865 ValueGraphVisitor for_instance(owner(), temp_index()); 1894 ValueGraphVisitor for_instance(owner(), temp_index());
1866 node->instance()->Visit(&for_instance); 1895 node->instance()->Visit(&for_instance);
1867 Append(for_instance); 1896 Append(for_instance);
1868 ValueGraphVisitor for_value(owner(), for_instance.temp_index()); 1897 ValueGraphVisitor for_value(owner(), for_instance.temp_index());
1869 node->value()->Visit(&for_value); 1898 node->value()->Visit(&for_value);
1870 Append(for_value); 1899 Append(for_value);
1871 Value* store_value = for_value.value(); 1900 Value* store_value = for_value.value();
1872 if (FLAG_enable_type_checks) { 1901 if (FLAG_enable_type_checks) {
1873 const AbstractType& type = AbstractType::ZoneHandle(node->field().type()); 1902 const AbstractType& type = AbstractType::ZoneHandle(node->field().type());
1874 const String& dst_name = String::ZoneHandle(node->field().name()); 1903 const String& dst_name = String::ZoneHandle(node->field().name());
1875 store_value = BuildAssignableValue(node->value()->token_index(), 1904 store_value = BuildAssignableValue(node->value()->token_index(),
1876 store_value, 1905 store_value,
1877 type, 1906 type,
1878 dst_name); 1907 dst_name);
1879 } 1908 }
1880 StoreInstanceFieldComp* store = 1909 StoreInstanceFieldComp* store = new StoreInstanceFieldComp(
1881 new StoreInstanceFieldComp(node, for_instance.value(), store_value); 1910 node->field(), for_instance.value(), store_value, NULL, NULL);
1882 ReturnComputation(store); 1911 ReturnComputation(store);
1883 } 1912 }
1884 1913
1885 1914
1915 // StoreInstanceFieldNode does not return result.
1916 void ValueGraphVisitor::VisitStoreInstanceFieldNode(
1917 StoreInstanceFieldNode* node) {
1918 UNIMPLEMENTED();
1919 }
1920
1921
1886 void EffectGraphVisitor::VisitLoadStaticFieldNode(LoadStaticFieldNode* node) { 1922 void EffectGraphVisitor::VisitLoadStaticFieldNode(LoadStaticFieldNode* node) {
1887 LoadStaticFieldComp* load = new LoadStaticFieldComp(node->field()); 1923 LoadStaticFieldComp* load = new LoadStaticFieldComp(node->field());
1888 ReturnComputation(load); 1924 ReturnComputation(load);
1889 } 1925 }
1890 1926
1891 1927
1892 void EffectGraphVisitor::VisitStoreStaticFieldNode(StoreStaticFieldNode* node) { 1928 void EffectGraphVisitor::VisitStoreStaticFieldNode(StoreStaticFieldNode* node) {
1893 ValueGraphVisitor for_value(owner(), temp_index()); 1929 ValueGraphVisitor for_value(owner(), temp_index());
1894 node->value()->Visit(&for_value); 1930 node->value()->Visit(&for_value);
1895 Append(for_value); 1931 Append(for_value);
(...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after
2451 char* chars = reinterpret_cast<char*>( 2487 char* chars = reinterpret_cast<char*>(
2452 Isolate::Current()->current_zone()->Allocate(len)); 2488 Isolate::Current()->current_zone()->Allocate(len));
2453 OS::SNPrint(chars, len, kFormat, function_name, reason); 2489 OS::SNPrint(chars, len, kFormat, function_name, reason);
2454 const Error& error = Error::Handle( 2490 const Error& error = Error::Handle(
2455 LanguageError::New(String::Handle(String::New(chars)))); 2491 LanguageError::New(String::Handle(String::New(chars))));
2456 Isolate::Current()->long_jump_base()->Jump(1, error); 2492 Isolate::Current()->long_jump_base()->Jump(1, error);
2457 } 2493 }
2458 2494
2459 2495
2460 } // namespace dart 2496 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_builder.h ('k') | runtime/vm/flow_graph_compiler_ia32.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698