| 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/code_patcher.h" | 9 #include "vm/code_patcher.h" |
| 10 #include "vm/compiler.h" | 10 #include "vm/compiler.h" |
| (...skipping 860 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 871 } | 871 } |
| 872 // Do not add an entry twice! | 872 // Do not add an entry twice! |
| 873 ASSERT(!matches); | 873 ASSERT(!matches); |
| 874 } | 874 } |
| 875 #endif // DEBUG | 875 #endif // DEBUG |
| 876 | 876 |
| 877 if (args.length() == 1) { | 877 if (args.length() == 1) { |
| 878 ic_data.AddReceiverCheck(Class::Handle(args[0]->clazz()).id(), | 878 ic_data.AddReceiverCheck(Class::Handle(args[0]->clazz()).id(), |
| 879 target_function); | 879 target_function); |
| 880 } else { | 880 } else { |
| 881 GrowableArray<intptr_t> class_ids; | 881 GrowableArray<intptr_t> class_ids(args.length()); |
| 882 ASSERT(ic_data.num_args_tested() == args.length()); | 882 ASSERT(ic_data.num_args_tested() == args.length()); |
| 883 for (intptr_t i = 0; i < args.length(); i++) { | 883 for (intptr_t i = 0; i < args.length(); i++) { |
| 884 class_ids.Add(Class::Handle(args[i]->clazz()).id()); | 884 class_ids.Add(Class::Handle(args[i]->clazz()).id()); |
| 885 } | 885 } |
| 886 ic_data.AddCheck(class_ids, target_function); | 886 ic_data.AddCheck(class_ids, target_function); |
| 887 } | 887 } |
| 888 if (FLAG_trace_ic) { | 888 if (FLAG_trace_ic) { |
| 889 OS::Print("InlineCacheMissHandler %d call at 0x%x' " | 889 OS::Print("InlineCacheMissHandler %d call at 0x%x' " |
| 890 "adding <%s> id:%d -> <%s>\n", | 890 "adding <%s> id:%d -> <%s>\n", |
| 891 args.length(), | 891 args.length(), |
| 892 caller_frame->pc(), | 892 caller_frame->pc(), |
| 893 Class::Handle(receiver.clazz()).ToCString(), | 893 Class::Handle(receiver.clazz()).ToCString(), |
| 894 Class::Handle(receiver.clazz()).id(), | 894 Class::Handle(receiver.clazz()).id(), |
| 895 target_function.ToCString()); | 895 target_function.ToCString()); |
| 896 } | 896 } |
| 897 return target_function.raw(); | 897 return target_function.raw(); |
| 898 } | 898 } |
| 899 | 899 |
| 900 | 900 |
| 901 // Handles inline cache misses by updating the IC data array of the call | 901 // Handles inline cache misses by updating the IC data array of the call |
| 902 // site. | 902 // site. |
| 903 // Arg0: Receiver object. | 903 // Arg0: Receiver object. |
| 904 // Returns: target function with compiled code or null. | 904 // Returns: target function with compiled code or null. |
| 905 // Modifies the instance call to hold the updated IC data array. | 905 // Modifies the instance call to hold the updated IC data array. |
| 906 DEFINE_RUNTIME_ENTRY(InlineCacheMissHandlerOneArg, 1) { | 906 DEFINE_RUNTIME_ENTRY(InlineCacheMissHandlerOneArg, 1) { |
| 907 ASSERT(arguments.Count() == | 907 ASSERT(arguments.Count() == |
| 908 kInlineCacheMissHandlerOneArgRuntimeEntry.argument_count()); | 908 kInlineCacheMissHandlerOneArgRuntimeEntry.argument_count()); |
| 909 const Instance& receiver = Instance::CheckedHandle(arguments.At(0)); | 909 const Instance& receiver = Instance::CheckedHandle(arguments.At(0)); |
| 910 GrowableArray<const Instance*> args; | 910 GrowableArray<const Instance*> args(1); |
| 911 args.Add(&receiver); | 911 args.Add(&receiver); |
| 912 const Function& result = | 912 const Function& result = |
| 913 Function::Handle(InlineCacheMissHandler(isolate, args)); | 913 Function::Handle(InlineCacheMissHandler(isolate, args)); |
| 914 arguments.SetReturn(result); | 914 arguments.SetReturn(result); |
| 915 } | 915 } |
| 916 | 916 |
| 917 | 917 |
| 918 // Handles inline cache misses by updating the IC data array of the call | 918 // Handles inline cache misses by updating the IC data array of the call |
| 919 // site. | 919 // site. |
| 920 // Arg0: Receiver object. | 920 // Arg0: Receiver object. |
| 921 // Arg1: Argument after receiver. | 921 // Arg1: Argument after receiver. |
| 922 // Returns: target function with compiled code or null. | 922 // Returns: target function with compiled code or null. |
| 923 // Modifies the instance call to hold the updated IC data array. | 923 // Modifies the instance call to hold the updated IC data array. |
| 924 DEFINE_RUNTIME_ENTRY(InlineCacheMissHandlerTwoArgs, 2) { | 924 DEFINE_RUNTIME_ENTRY(InlineCacheMissHandlerTwoArgs, 2) { |
| 925 ASSERT(arguments.Count() == | 925 ASSERT(arguments.Count() == |
| 926 kInlineCacheMissHandlerTwoArgsRuntimeEntry.argument_count()); | 926 kInlineCacheMissHandlerTwoArgsRuntimeEntry.argument_count()); |
| 927 const Instance& receiver = Instance::CheckedHandle(arguments.At(0)); | 927 const Instance& receiver = Instance::CheckedHandle(arguments.At(0)); |
| 928 const Instance& other = Instance::CheckedHandle(arguments.At(1)); | 928 const Instance& other = Instance::CheckedHandle(arguments.At(1)); |
| 929 GrowableArray<const Instance*> args; | 929 GrowableArray<const Instance*> args(2); |
| 930 args.Add(&receiver); | 930 args.Add(&receiver); |
| 931 args.Add(&other); | 931 args.Add(&other); |
| 932 const Function& result = | 932 const Function& result = |
| 933 Function::Handle(InlineCacheMissHandler(isolate, args)); | 933 Function::Handle(InlineCacheMissHandler(isolate, args)); |
| 934 arguments.SetReturn(result); | 934 arguments.SetReturn(result); |
| 935 } | 935 } |
| 936 | 936 |
| 937 | 937 |
| 938 static RawFunction* LookupDynamicFunction(Isolate* isolate, | 938 static RawFunction* LookupDynamicFunction(Isolate* isolate, |
| 939 const Class& in_cls, | 939 const Class& in_cls, |
| (...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1607 function.set_usage_counter(0); | 1607 function.set_usage_counter(0); |
| 1608 function.set_deoptimization_counter(function.deoptimization_counter() + 1); | 1608 function.set_deoptimization_counter(function.deoptimization_counter() + 1); |
| 1609 | 1609 |
| 1610 if (function.HasOptimizedCode()) { | 1610 if (function.HasOptimizedCode()) { |
| 1611 function.SwitchToUnoptimizedCode(); | 1611 function.SwitchToUnoptimizedCode(); |
| 1612 } | 1612 } |
| 1613 } | 1613 } |
| 1614 END_LEAF_RUNTIME_ENTRY | 1614 END_LEAF_RUNTIME_ENTRY |
| 1615 | 1615 |
| 1616 } // namespace dart | 1616 } // namespace dart |
| OLD | NEW |