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/code_patcher.h" | 9 #include "vm/code_patcher.h" |
| 10 #include "vm/compiler.h" | 10 #include "vm/compiler.h" |
| (...skipping 878 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 889 return Function::null(); | 889 return Function::null(); |
| 890 } | 890 } |
| 891 const Function& target_function = | 891 const Function& target_function = |
| 892 Function::Handle(target_code.function()); | 892 Function::Handle(target_code.function()); |
| 893 ASSERT(!target_function.IsNull()); | 893 ASSERT(!target_function.IsNull()); |
| 894 DartFrameIterator iterator; | 894 DartFrameIterator iterator; |
| 895 StackFrame* caller_frame = iterator.NextFrame(); | 895 StackFrame* caller_frame = iterator.NextFrame(); |
| 896 ASSERT(caller_frame != NULL); | 896 ASSERT(caller_frame != NULL); |
| 897 ICData& ic_data = ICData::Handle( | 897 ICData& ic_data = ICData::Handle( |
| 898 CodePatcher::GetInstanceCallIcDataAt(caller_frame->pc())); | 898 CodePatcher::GetInstanceCallIcDataAt(caller_frame->pc())); |
| 899 #if defined(DEBUG) | |
| 900 for (intptr_t i = 0; i < ic_data.NumberOfChecks(); i++) { | |
| 901 GrowableArray<intptr_t> class_ids; | |
| 902 Function& target = Function::Handle(); | |
| 903 ic_data.GetCheckAt(i, &class_ids, &target); | |
| 904 bool matches = true; | |
| 905 for (intptr_t k = 0; k < class_ids.length(); k++) { | |
| 906 if (class_ids[k] != Class::Handle(args[k]->clazz()).id()) { | |
| 907 matches = false; | |
| 908 break; | |
| 909 } | |
| 910 } | |
| 911 // Do not add an entry twice! | |
| 912 ASSERT(!matches); | |
| 913 } | |
| 914 #endif // DEBUG | |
| 915 | |
| 916 if (args.length() == 1) { | 899 if (args.length() == 1) { |
| 917 ic_data.AddReceiverCheck(Class::Handle(args[0]->clazz()).id(), | 900 ic_data.AddReceiverCheck(Class::Handle(args[0]->clazz()).id(), |
| 918 target_function); | 901 target_function); |
| 919 } else { | 902 } else { |
| 920 GrowableArray<intptr_t> class_ids(args.length()); | 903 GrowableArray<intptr_t> class_ids(args.length()); |
| 921 ASSERT(ic_data.num_args_tested() == args.length()); | 904 ASSERT(ic_data.num_args_tested() == args.length()); |
| 922 for (intptr_t i = 0; i < args.length(); i++) { | 905 for (intptr_t i = 0; i < args.length(); i++) { |
| 923 class_ids.Add(Class::Handle(args[i]->clazz()).id()); | 906 class_ids.Add(Class::Handle(args[i]->clazz()).id()); |
| 924 } | 907 } |
| 925 ic_data.AddCheck(class_ids, target_function); | 908 ic_data.AddCheck(class_ids, target_function); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 998 GrowableArray<const Instance*> args(3); | 981 GrowableArray<const Instance*> args(3); |
| 999 args.Add(&receiver); | 982 args.Add(&receiver); |
| 1000 args.Add(&arg1); | 983 args.Add(&arg1); |
| 1001 args.Add(&arg2); | 984 args.Add(&arg2); |
| 1002 const Function& result = | 985 const Function& result = |
| 1003 Function::Handle(InlineCacheMissHandler(isolate, args)); | 986 Function::Handle(InlineCacheMissHandler(isolate, args)); |
| 1004 arguments.SetReturn(result); | 987 arguments.SetReturn(result); |
| 1005 } | 988 } |
| 1006 | 989 |
| 1007 | 990 |
| 991 // Updates IC data for two arguments. Used by the equality operation when | |
| 992 // teh control flow bypasses regular inline cache (null arguments). | |
|
Florian Schneider
2012/10/05 09:17:35
s/teh/the/ :)
srdjan
2012/10/09 18:06:03
Done.
| |
| 993 // Arg0: Receiver object. | |
| 994 // Arg1: Argument after receiver. | |
| 995 // Arg2: Target's name. | |
| 996 // Arg3: ICData. | |
| 997 DEFINE_RUNTIME_ENTRY(UpdateICDataTwoArgs, 4) { | |
| 998 ASSERT(arguments.Count() == | |
| 999 kUpdateICDataTwoArgsRuntimeEntry.argument_count()); | |
| 1000 const Instance& receiver = Instance::CheckedHandle(arguments.At(0)); | |
| 1001 const Instance& arg1 = Instance::CheckedHandle(arguments.At(1)); | |
| 1002 const String& target_name = String::CheckedHandle(arguments.At(2)); | |
| 1003 const ICData& ic_data = ICData::CheckedHandle(arguments.At(3)); | |
| 1004 GrowableArray<const Instance*> args(2); | |
| 1005 args.Add(&receiver); | |
| 1006 args.Add(&arg1); | |
| 1007 const intptr_t kNumArguments = 2; | |
| 1008 const intptr_t kNumNamedArguments = 0; | |
| 1009 Function& target_function = Function::Handle(); | |
| 1010 target_function = Resolver::ResolveDynamic(receiver, | |
| 1011 target_name, | |
| 1012 kNumArguments, | |
| 1013 kNumNamedArguments); | |
| 1014 ASSERT(!target_function.IsNull()); | |
| 1015 GrowableArray<intptr_t> class_ids(kNumArguments); | |
| 1016 ASSERT(ic_data.num_args_tested() == kNumArguments); | |
| 1017 class_ids.Add(Class::Handle(receiver.clazz()).id()); | |
| 1018 class_ids.Add(Class::Handle(arg1.clazz()).id()); | |
| 1019 ic_data.AddCheck(class_ids, target_function); | |
| 1020 } | |
| 1021 | |
| 1022 | |
| 1008 static RawFunction* LookupDynamicFunction(Isolate* isolate, | 1023 static RawFunction* LookupDynamicFunction(Isolate* isolate, |
| 1009 const Class& in_cls, | 1024 const Class& in_cls, |
| 1010 const String& name) { | 1025 const String& name) { |
| 1011 Class& cls = Class::Handle(); | 1026 Class& cls = Class::Handle(); |
| 1012 // For lookups treat null as an instance of class Object. | 1027 // For lookups treat null as an instance of class Object. |
| 1013 if (in_cls.IsNullClass()) { | 1028 if (in_cls.IsNullClass()) { |
| 1014 cls = isolate->object_store()->object_class(); | 1029 cls = isolate->object_store()->object_class(); |
| 1015 } else { | 1030 } else { |
| 1016 cls = in_cls.raw(); | 1031 cls = in_cls.raw(); |
| 1017 } | 1032 } |
| (...skipping 719 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1737 intptr_t line, column; | 1752 intptr_t line, column; |
| 1738 script.GetTokenLocation(token_pos, &line, &column); | 1753 script.GetTokenLocation(token_pos, &line, &column); |
| 1739 String& line_string = String::Handle(script.GetLine(line)); | 1754 String& line_string = String::Handle(script.GetLine(line)); |
| 1740 OS::Print(" Function: %s\n", top_function.ToFullyQualifiedCString()); | 1755 OS::Print(" Function: %s\n", top_function.ToFullyQualifiedCString()); |
| 1741 OS::Print(" Line %"Pd": '%s'\n", line, line_string.ToCString()); | 1756 OS::Print(" Line %"Pd": '%s'\n", line, line_string.ToCString()); |
| 1742 } | 1757 } |
| 1743 } | 1758 } |
| 1744 | 1759 |
| 1745 | 1760 |
| 1746 } // namespace dart | 1761 } // namespace dart |
| OLD | NEW |