Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 for (intptr_t i = 0; i < num_named_args; i++) { | 685 for (intptr_t i = 0; i < num_named_args; i++) { |
| 686 arg_name ^= arg_desc.NameAt(i); | 686 if (arg_desc.NameAt(i) == param_name.raw()) { |
| 687 if (arg_name.raw() == param_name.raw()) { | |
| 688 is_defined = true; | 687 is_defined = true; |
| 689 break; | 688 break; |
| 690 } | 689 } |
| 691 } | 690 } |
| 692 } | 691 } |
| 693 arguments.SetReturn(Bool::Handle(Bool::Get(is_defined))); | 692 arguments.SetReturn(Bool::Handle(Bool::Get(is_defined))); |
| 694 } | 693 } |
| 695 | 694 |
| 696 | 695 |
| 697 // Report that the type of the given object is not bool in conditional context. | 696 // Report that the type of the given object is not bool in conditional context. |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 833 // Arg2: Arguments descriptor array. | 832 // Arg2: Arguments descriptor array. |
| 834 // Returns: RawCode object or NULL (method not found or not compileable). | 833 // 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 | 834 // This is called by the megamorphic stub when instance call does not need to be |
| 836 // patched. | 835 // patched. |
| 837 // Used by megamorphic lookup/no-such-method-handling. | 836 // Used by megamorphic lookup/no-such-method-handling. |
| 838 DEFINE_RUNTIME_ENTRY(ResolveCompileInstanceFunction, 3) { | 837 DEFINE_RUNTIME_ENTRY(ResolveCompileInstanceFunction, 3) { |
| 839 ASSERT(arguments.ArgCount() == | 838 ASSERT(arguments.ArgCount() == |
| 840 kResolveCompileInstanceFunctionRuntimeEntry.argument_count()); | 839 kResolveCompileInstanceFunctionRuntimeEntry.argument_count()); |
| 841 const Instance& receiver = Instance::CheckedHandle(arguments.ArgAt(0)); | 840 const Instance& receiver = Instance::CheckedHandle(arguments.ArgAt(0)); |
| 842 const ICData& ic_data = ICData::CheckedHandle(arguments.ArgAt(1)); | 841 const ICData& ic_data = ICData::CheckedHandle(arguments.ArgAt(1)); |
| 843 ArgumentsDescriptor arg_descriptor(arguments.ArgAt(2)); | 842 const Array& arg_desc_array = Array::CheckedHandle(arguments.ArgAt(2)); |
| 843 ArgumentsDescriptor arg_descriptor(arg_desc_array); | |
|
Kevin Millikin (Google)
2012/12/06 10:36:28
I was trying to avoid this API, which I still thin
| |
| 844 const Code& code = | 844 const Code& code = |
| 845 Code::Handle(ResolveCompileInstanceCallTarget(receiver, | 845 Code::Handle(ResolveCompileInstanceCallTarget(receiver, |
| 846 ic_data, | 846 ic_data, |
| 847 arg_descriptor)); | 847 arg_descriptor)); |
| 848 arguments.SetReturn(code); | 848 arguments.SetReturn(code); |
| 849 } | 849 } |
| 850 | 850 |
| 851 | 851 |
| 852 // Gets called from debug stub when code reaches a breakpoint. | 852 // Gets called from debug stub when code reaches a breakpoint. |
| 853 DEFINE_RUNTIME_ENTRY(BreakpointStaticHandler, 0) { | 853 DEFINE_RUNTIME_ENTRY(BreakpointStaticHandler, 0) { |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 955 // Arg0: Receiver object. | 955 // Arg0: Receiver object. |
| 956 // Arg1: IC data object. | 956 // Arg1: IC data object. |
| 957 // Arg2: Arguments descriptor array. | 957 // Arg2: Arguments descriptor array. |
| 958 // Returns: target function with compiled code or null. | 958 // Returns: target function with compiled code or null. |
| 959 // Modifies the instance call to hold the updated IC data array. | 959 // Modifies the instance call to hold the updated IC data array. |
| 960 DEFINE_RUNTIME_ENTRY(InlineCacheMissHandlerOneArg, 3) { | 960 DEFINE_RUNTIME_ENTRY(InlineCacheMissHandlerOneArg, 3) { |
| 961 ASSERT(arguments.ArgCount() == | 961 ASSERT(arguments.ArgCount() == |
| 962 kInlineCacheMissHandlerOneArgRuntimeEntry.argument_count()); | 962 kInlineCacheMissHandlerOneArgRuntimeEntry.argument_count()); |
| 963 const Instance& receiver = Instance::CheckedHandle(arguments.ArgAt(0)); | 963 const Instance& receiver = Instance::CheckedHandle(arguments.ArgAt(0)); |
| 964 const ICData& ic_data = ICData::CheckedHandle(arguments.ArgAt(1)); | 964 const ICData& ic_data = ICData::CheckedHandle(arguments.ArgAt(1)); |
| 965 ArgumentsDescriptor arg_descriptor(arguments.ArgAt(2)); | 965 const Array& arg_desc_array = Array::CheckedHandle(arguments.ArgAt(2)); |
| 966 ArgumentsDescriptor arg_descriptor(arg_desc_array); | |
| 966 GrowableArray<const Instance*> args(1); | 967 GrowableArray<const Instance*> args(1); |
| 967 args.Add(&receiver); | 968 args.Add(&receiver); |
| 968 const Function& result = | 969 const Function& result = |
| 969 Function::Handle(InlineCacheMissHandler(args, ic_data, arg_descriptor)); | 970 Function::Handle(InlineCacheMissHandler(args, ic_data, arg_descriptor)); |
| 970 arguments.SetReturn(result); | 971 arguments.SetReturn(result); |
| 971 } | 972 } |
| 972 | 973 |
| 973 | 974 |
| 974 // Handles inline cache misses by updating the IC data array of the call | 975 // Handles inline cache misses by updating the IC data array of the call |
| 975 // site. | 976 // site. |
| 976 // Arg0: Receiver object. | 977 // Arg0: Receiver object. |
| 977 // Arg1: Argument after receiver. | 978 // Arg1: Argument after receiver. |
| 978 // Arg2: IC data object. | 979 // Arg2: IC data object. |
| 979 // Arg3: Arguments descriptor array. | 980 // Arg3: Arguments descriptor array. |
| 980 // Returns: target function with compiled code or null. | 981 // Returns: target function with compiled code or null. |
| 981 // Modifies the instance call to hold the updated IC data array. | 982 // Modifies the instance call to hold the updated IC data array. |
| 982 DEFINE_RUNTIME_ENTRY(InlineCacheMissHandlerTwoArgs, 4) { | 983 DEFINE_RUNTIME_ENTRY(InlineCacheMissHandlerTwoArgs, 4) { |
| 983 ASSERT(arguments.ArgCount() == | 984 ASSERT(arguments.ArgCount() == |
| 984 kInlineCacheMissHandlerTwoArgsRuntimeEntry.argument_count()); | 985 kInlineCacheMissHandlerTwoArgsRuntimeEntry.argument_count()); |
| 985 const Instance& receiver = Instance::CheckedHandle(arguments.ArgAt(0)); | 986 const Instance& receiver = Instance::CheckedHandle(arguments.ArgAt(0)); |
| 986 const Instance& other = Instance::CheckedHandle(arguments.ArgAt(1)); | 987 const Instance& other = Instance::CheckedHandle(arguments.ArgAt(1)); |
| 987 const ICData& ic_data = ICData::CheckedHandle(arguments.ArgAt(2)); | 988 const ICData& ic_data = ICData::CheckedHandle(arguments.ArgAt(2)); |
| 988 ArgumentsDescriptor arg_descriptor(arguments.ArgAt(3)); | 989 const Array& arg_desc_array = Array::CheckedHandle(arguments.ArgAt(3)); |
| 990 ArgumentsDescriptor arg_descriptor(arg_desc_array); | |
| 989 GrowableArray<const Instance*> args(2); | 991 GrowableArray<const Instance*> args(2); |
| 990 args.Add(&receiver); | 992 args.Add(&receiver); |
| 991 args.Add(&other); | 993 args.Add(&other); |
| 992 const Function& result = | 994 const Function& result = |
| 993 Function::Handle(InlineCacheMissHandler(args, ic_data, arg_descriptor)); | 995 Function::Handle(InlineCacheMissHandler(args, ic_data, arg_descriptor)); |
| 994 arguments.SetReturn(result); | 996 arguments.SetReturn(result); |
| 995 } | 997 } |
| 996 | 998 |
| 997 | 999 |
| 998 // Handles inline cache misses by updating the IC data array of the call | 1000 // Handles inline cache misses by updating the IC data array of the call |
| 999 // site. | 1001 // site. |
| 1000 // Arg0: Receiver object. | 1002 // Arg0: Receiver object. |
| 1001 // Arg1: Argument after receiver. | 1003 // Arg1: Argument after receiver. |
| 1002 // Arg2: Second argument after receiver. | 1004 // Arg2: Second argument after receiver. |
| 1003 // Arg3: IC data object. | 1005 // Arg3: IC data object. |
| 1004 // Arg4: Arguments descriptor array. | 1006 // Arg4: Arguments descriptor array. |
| 1005 // Returns: target function with compiled code or null. | 1007 // Returns: target function with compiled code or null. |
| 1006 // Modifies the instance call to hold the updated IC data array. | 1008 // Modifies the instance call to hold the updated IC data array. |
| 1007 DEFINE_RUNTIME_ENTRY(InlineCacheMissHandlerThreeArgs, 5) { | 1009 DEFINE_RUNTIME_ENTRY(InlineCacheMissHandlerThreeArgs, 5) { |
| 1008 ASSERT(arguments.ArgCount() == | 1010 ASSERT(arguments.ArgCount() == |
| 1009 kInlineCacheMissHandlerThreeArgsRuntimeEntry.argument_count()); | 1011 kInlineCacheMissHandlerThreeArgsRuntimeEntry.argument_count()); |
| 1010 const Instance& receiver = Instance::CheckedHandle(arguments.ArgAt(0)); | 1012 const Instance& receiver = Instance::CheckedHandle(arguments.ArgAt(0)); |
| 1011 const Instance& arg1 = Instance::CheckedHandle(arguments.ArgAt(1)); | 1013 const Instance& arg1 = Instance::CheckedHandle(arguments.ArgAt(1)); |
| 1012 const Instance& arg2 = Instance::CheckedHandle(arguments.ArgAt(2)); | 1014 const Instance& arg2 = Instance::CheckedHandle(arguments.ArgAt(2)); |
| 1013 const ICData& ic_data = ICData::CheckedHandle(arguments.ArgAt(3)); | 1015 const ICData& ic_data = ICData::CheckedHandle(arguments.ArgAt(3)); |
| 1014 ArgumentsDescriptor arg_descriptor(arguments.ArgAt(4)); | 1016 const Array& arg_desc_array = Array::CheckedHandle(arguments.ArgAt(4)); |
| 1017 ArgumentsDescriptor arg_descriptor(arg_desc_array); | |
| 1015 GrowableArray<const Instance*> args(3); | 1018 GrowableArray<const Instance*> args(3); |
| 1016 args.Add(&receiver); | 1019 args.Add(&receiver); |
| 1017 args.Add(&arg1); | 1020 args.Add(&arg1); |
| 1018 args.Add(&arg2); | 1021 args.Add(&arg2); |
| 1019 const Function& result = | 1022 const Function& result = |
| 1020 Function::Handle(InlineCacheMissHandler(args, ic_data, arg_descriptor)); | 1023 Function::Handle(InlineCacheMissHandler(args, ic_data, arg_descriptor)); |
| 1021 arguments.SetReturn(result); | 1024 arguments.SetReturn(result); |
| 1022 } | 1025 } |
| 1023 | 1026 |
| 1024 | 1027 |
| (...skipping 865 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1890 Isolate* isolate = Isolate::Current(); | 1893 Isolate* isolate = Isolate::Current(); |
| 1891 StackZone zone(isolate); | 1894 StackZone zone(isolate); |
| 1892 HANDLESCOPE(isolate); | 1895 HANDLESCOPE(isolate); |
| 1893 const Bigint& big_left = Bigint::Handle(left); | 1896 const Bigint& big_left = Bigint::Handle(left); |
| 1894 const Bigint& big_right = Bigint::Handle(right); | 1897 const Bigint& big_right = Bigint::Handle(right); |
| 1895 return BigintOperations::Compare(big_left, big_right); | 1898 return BigintOperations::Compare(big_left, big_right); |
| 1896 } | 1899 } |
| 1897 END_LEAF_RUNTIME_ENTRY | 1900 END_LEAF_RUNTIME_ENTRY |
| 1898 | 1901 |
| 1899 } // namespace dart | 1902 } // namespace dart |
| OLD | NEW |