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

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

Issue 11441021: Pass handles not raw objects into methods. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years 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/dart_entry.h » ('j') | runtime/vm/dart_entry.cc » ('J')
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/code_generator.h" 5 #include "vm/code_generator.h"
6 6
7 #include "vm/assembler_macros.h" 7 #include "vm/assembler_macros.h"
8 #include "vm/ast.h" 8 #include "vm/ast.h"
9 #include "vm/bigint_operations.h" 9 #include "vm/bigint_operations.h"
10 #include "vm/code_patcher.h" 10 #include "vm/code_patcher.h"
(...skipping 656 matching lines...) Expand 10 before | Expand all | Expand 10 after
667 // Arg0: formal parameter index as Smi. 667 // Arg0: formal parameter index as Smi.
668 // Arg1: formal parameter name as Symbol. 668 // Arg1: formal parameter name as Symbol.
669 // Arg2: arguments descriptor array. 669 // Arg2: arguments descriptor array.
670 // Return value: true or false. 670 // Return value: true or false.
671 DEFINE_RUNTIME_ENTRY(ArgumentDefinitionTest, 3) { 671 DEFINE_RUNTIME_ENTRY(ArgumentDefinitionTest, 3) {
672 ASSERT(arguments.ArgCount() == 672 ASSERT(arguments.ArgCount() ==
673 kArgumentDefinitionTestRuntimeEntry.argument_count()); 673 kArgumentDefinitionTestRuntimeEntry.argument_count());
674 const Smi& param_index = Smi::CheckedHandle(arguments.ArgAt(0)); 674 const Smi& param_index = Smi::CheckedHandle(arguments.ArgAt(0));
675 const String& param_name = String::CheckedHandle(arguments.ArgAt(1)); 675 const String& param_name = String::CheckedHandle(arguments.ArgAt(1));
676 ASSERT(param_name.IsSymbol()); 676 ASSERT(param_name.IsSymbol());
677 ArgumentsDescriptor arg_desc(arguments.ArgAt(2)); 677 const Array& arg_desc_array = Array::CheckedHandle(arguments.ArgAt(2));
678 ArgumentsDescriptor arg_desc(arg_desc_array);
678 const intptr_t num_pos_args = arg_desc.PositionalCount(); 679 const intptr_t num_pos_args = arg_desc.PositionalCount();
679 // Check if the formal parameter is defined by a positional argument. 680 // Check if the formal parameter is defined by a positional argument.
680 bool is_defined = num_pos_args > param_index.Value(); 681 bool is_defined = num_pos_args > param_index.Value();
681 if (!is_defined) { 682 if (!is_defined) {
682 // Check if the formal parameter is defined by a named argument. 683 // Check if the formal parameter is defined by a named argument.
683 const intptr_t num_named_args = arg_desc.NamedCount(); 684 const intptr_t num_named_args = arg_desc.NamedCount();
684 String& arg_name = String::Handle(); 685 String& arg_name = String::Handle();
685 for (intptr_t i = 0; i < num_named_args; i++) { 686 for (intptr_t i = 0; i < num_named_args; i++) {
686 arg_name ^= arg_desc.NameAt(i); 687 arg_name = arg_desc.NameAt(i);
687 if (arg_name.raw() == param_name.raw()) { 688 if (arg_name.raw() == param_name.raw()) {
688 is_defined = true; 689 is_defined = true;
689 break; 690 break;
690 } 691 }
691 } 692 }
692 } 693 }
693 arguments.SetReturn(Bool::Handle(Bool::Get(is_defined))); 694 arguments.SetReturn(Bool::Handle(Bool::Get(is_defined)));
694 } 695 }
695 696
696 697
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
833 // Arg2: Arguments descriptor array. 834 // Arg2: Arguments descriptor array.
834 // Returns: RawCode object or NULL (method not found or not compileable). 835 // Returns: RawCode object or NULL (method not found or not compileable).
835 // This is called by the megamorphic stub when instance call does not need to be 836 // This is called by the megamorphic stub when instance call does not need to be
836 // patched. 837 // patched.
837 // Used by megamorphic lookup/no-such-method-handling. 838 // Used by megamorphic lookup/no-such-method-handling.
838 DEFINE_RUNTIME_ENTRY(ResolveCompileInstanceFunction, 3) { 839 DEFINE_RUNTIME_ENTRY(ResolveCompileInstanceFunction, 3) {
839 ASSERT(arguments.ArgCount() == 840 ASSERT(arguments.ArgCount() ==
840 kResolveCompileInstanceFunctionRuntimeEntry.argument_count()); 841 kResolveCompileInstanceFunctionRuntimeEntry.argument_count());
841 const Instance& receiver = Instance::CheckedHandle(arguments.ArgAt(0)); 842 const Instance& receiver = Instance::CheckedHandle(arguments.ArgAt(0));
842 const ICData& ic_data = ICData::CheckedHandle(arguments.ArgAt(1)); 843 const ICData& ic_data = ICData::CheckedHandle(arguments.ArgAt(1));
843 ArgumentsDescriptor arg_descriptor(arguments.ArgAt(2)); 844 const Array& arg_desc_array = Array::CheckedHandle(arguments.ArgAt(2));
845 ArgumentsDescriptor arg_descriptor(arg_desc_array);
844 const Code& code = 846 const Code& code =
845 Code::Handle(ResolveCompileInstanceCallTarget(receiver, 847 Code::Handle(ResolveCompileInstanceCallTarget(receiver,
846 ic_data, 848 ic_data,
847 arg_descriptor)); 849 arg_descriptor));
848 arguments.SetReturn(code); 850 arguments.SetReturn(code);
849 } 851 }
850 852
851 853
852 // Gets called from debug stub when code reaches a breakpoint. 854 // Gets called from debug stub when code reaches a breakpoint.
853 DEFINE_RUNTIME_ENTRY(BreakpointStaticHandler, 0) { 855 DEFINE_RUNTIME_ENTRY(BreakpointStaticHandler, 0) {
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
955 // Arg0: Receiver object. 957 // Arg0: Receiver object.
956 // Arg1: IC data object. 958 // Arg1: IC data object.
957 // Arg2: Arguments descriptor array. 959 // Arg2: Arguments descriptor array.
958 // Returns: target function with compiled code or null. 960 // Returns: target function with compiled code or null.
959 // Modifies the instance call to hold the updated IC data array. 961 // Modifies the instance call to hold the updated IC data array.
960 DEFINE_RUNTIME_ENTRY(InlineCacheMissHandlerOneArg, 3) { 962 DEFINE_RUNTIME_ENTRY(InlineCacheMissHandlerOneArg, 3) {
961 ASSERT(arguments.ArgCount() == 963 ASSERT(arguments.ArgCount() ==
962 kInlineCacheMissHandlerOneArgRuntimeEntry.argument_count()); 964 kInlineCacheMissHandlerOneArgRuntimeEntry.argument_count());
963 const Instance& receiver = Instance::CheckedHandle(arguments.ArgAt(0)); 965 const Instance& receiver = Instance::CheckedHandle(arguments.ArgAt(0));
964 const ICData& ic_data = ICData::CheckedHandle(arguments.ArgAt(1)); 966 const ICData& ic_data = ICData::CheckedHandle(arguments.ArgAt(1));
965 ArgumentsDescriptor arg_descriptor(arguments.ArgAt(2)); 967 const Array& arg_desc_array = Array::CheckedHandle(arguments.ArgAt(2));
968 ArgumentsDescriptor arg_descriptor(arg_desc_array);
966 GrowableArray<const Instance*> args(1); 969 GrowableArray<const Instance*> args(1);
967 args.Add(&receiver); 970 args.Add(&receiver);
968 const Function& result = 971 const Function& result =
969 Function::Handle(InlineCacheMissHandler(args, ic_data, arg_descriptor)); 972 Function::Handle(InlineCacheMissHandler(args, ic_data, arg_descriptor));
970 arguments.SetReturn(result); 973 arguments.SetReturn(result);
971 } 974 }
972 975
973 976
974 // Handles inline cache misses by updating the IC data array of the call 977 // Handles inline cache misses by updating the IC data array of the call
975 // site. 978 // site.
976 // Arg0: Receiver object. 979 // Arg0: Receiver object.
977 // Arg1: Argument after receiver. 980 // Arg1: Argument after receiver.
978 // Arg2: IC data object. 981 // Arg2: IC data object.
979 // Arg3: Arguments descriptor array. 982 // Arg3: Arguments descriptor array.
980 // Returns: target function with compiled code or null. 983 // Returns: target function with compiled code or null.
981 // Modifies the instance call to hold the updated IC data array. 984 // Modifies the instance call to hold the updated IC data array.
982 DEFINE_RUNTIME_ENTRY(InlineCacheMissHandlerTwoArgs, 4) { 985 DEFINE_RUNTIME_ENTRY(InlineCacheMissHandlerTwoArgs, 4) {
983 ASSERT(arguments.ArgCount() == 986 ASSERT(arguments.ArgCount() ==
984 kInlineCacheMissHandlerTwoArgsRuntimeEntry.argument_count()); 987 kInlineCacheMissHandlerTwoArgsRuntimeEntry.argument_count());
985 const Instance& receiver = Instance::CheckedHandle(arguments.ArgAt(0)); 988 const Instance& receiver = Instance::CheckedHandle(arguments.ArgAt(0));
986 const Instance& other = Instance::CheckedHandle(arguments.ArgAt(1)); 989 const Instance& other = Instance::CheckedHandle(arguments.ArgAt(1));
987 const ICData& ic_data = ICData::CheckedHandle(arguments.ArgAt(2)); 990 const ICData& ic_data = ICData::CheckedHandle(arguments.ArgAt(2));
988 ArgumentsDescriptor arg_descriptor(arguments.ArgAt(3)); 991 const Array& arg_desc_array = Array::CheckedHandle(arguments.ArgAt(3));
992 ArgumentsDescriptor arg_descriptor(arg_desc_array);
989 GrowableArray<const Instance*> args(2); 993 GrowableArray<const Instance*> args(2);
990 args.Add(&receiver); 994 args.Add(&receiver);
991 args.Add(&other); 995 args.Add(&other);
992 const Function& result = 996 const Function& result =
993 Function::Handle(InlineCacheMissHandler(args, ic_data, arg_descriptor)); 997 Function::Handle(InlineCacheMissHandler(args, ic_data, arg_descriptor));
994 arguments.SetReturn(result); 998 arguments.SetReturn(result);
995 } 999 }
996 1000
997 1001
998 // Handles inline cache misses by updating the IC data array of the call 1002 // Handles inline cache misses by updating the IC data array of the call
999 // site. 1003 // site.
1000 // Arg0: Receiver object. 1004 // Arg0: Receiver object.
1001 // Arg1: Argument after receiver. 1005 // Arg1: Argument after receiver.
1002 // Arg2: Second argument after receiver. 1006 // Arg2: Second argument after receiver.
1003 // Arg3: IC data object. 1007 // Arg3: IC data object.
1004 // Arg4: Arguments descriptor array. 1008 // Arg4: Arguments descriptor array.
1005 // Returns: target function with compiled code or null. 1009 // Returns: target function with compiled code or null.
1006 // Modifies the instance call to hold the updated IC data array. 1010 // Modifies the instance call to hold the updated IC data array.
1007 DEFINE_RUNTIME_ENTRY(InlineCacheMissHandlerThreeArgs, 5) { 1011 DEFINE_RUNTIME_ENTRY(InlineCacheMissHandlerThreeArgs, 5) {
1008 ASSERT(arguments.ArgCount() == 1012 ASSERT(arguments.ArgCount() ==
1009 kInlineCacheMissHandlerThreeArgsRuntimeEntry.argument_count()); 1013 kInlineCacheMissHandlerThreeArgsRuntimeEntry.argument_count());
1010 const Instance& receiver = Instance::CheckedHandle(arguments.ArgAt(0)); 1014 const Instance& receiver = Instance::CheckedHandle(arguments.ArgAt(0));
1011 const Instance& arg1 = Instance::CheckedHandle(arguments.ArgAt(1)); 1015 const Instance& arg1 = Instance::CheckedHandle(arguments.ArgAt(1));
1012 const Instance& arg2 = Instance::CheckedHandle(arguments.ArgAt(2)); 1016 const Instance& arg2 = Instance::CheckedHandle(arguments.ArgAt(2));
1013 const ICData& ic_data = ICData::CheckedHandle(arguments.ArgAt(3)); 1017 const ICData& ic_data = ICData::CheckedHandle(arguments.ArgAt(3));
1014 ArgumentsDescriptor arg_descriptor(arguments.ArgAt(4)); 1018 const Array& arg_desc_array = Array::CheckedHandle(arguments.ArgAt(4));
1019 ArgumentsDescriptor arg_descriptor(arg_desc_array);
1015 GrowableArray<const Instance*> args(3); 1020 GrowableArray<const Instance*> args(3);
1016 args.Add(&receiver); 1021 args.Add(&receiver);
1017 args.Add(&arg1); 1022 args.Add(&arg1);
1018 args.Add(&arg2); 1023 args.Add(&arg2);
1019 const Function& result = 1024 const Function& result =
1020 Function::Handle(InlineCacheMissHandler(args, ic_data, arg_descriptor)); 1025 Function::Handle(InlineCacheMissHandler(args, ic_data, arg_descriptor));
1021 arguments.SetReturn(result); 1026 arguments.SetReturn(result);
1022 } 1027 }
1023 1028
1024 1029
(...skipping 865 matching lines...) Expand 10 before | Expand all | Expand 10 after
1890 Isolate* isolate = Isolate::Current(); 1895 Isolate* isolate = Isolate::Current();
1891 StackZone zone(isolate); 1896 StackZone zone(isolate);
1892 HANDLESCOPE(isolate); 1897 HANDLESCOPE(isolate);
1893 const Bigint& big_left = Bigint::Handle(left); 1898 const Bigint& big_left = Bigint::Handle(left);
1894 const Bigint& big_right = Bigint::Handle(right); 1899 const Bigint& big_right = Bigint::Handle(right);
1895 return BigintOperations::Compare(big_left, big_right); 1900 return BigintOperations::Compare(big_left, big_right);
1896 } 1901 }
1897 END_LEAF_RUNTIME_ENTRY 1902 END_LEAF_RUNTIME_ENTRY
1898 1903
1899 } // namespace dart 1904 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/dart_entry.h » ('j') | runtime/vm/dart_entry.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698