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 993 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1004 GrowableArray<const Instance*> args(3); | 1004 GrowableArray<const Instance*> args(3); |
1005 args.Add(&receiver); | 1005 args.Add(&receiver); |
1006 args.Add(&arg1); | 1006 args.Add(&arg1); |
1007 args.Add(&arg2); | 1007 args.Add(&arg2); |
1008 const Function& result = | 1008 const Function& result = |
1009 Function::Handle(InlineCacheMissHandler(isolate, args)); | 1009 Function::Handle(InlineCacheMissHandler(isolate, args)); |
1010 arguments.SetReturn(result); | 1010 arguments.SetReturn(result); |
1011 } | 1011 } |
1012 | 1012 |
1013 | 1013 |
1014 // Arg0: Receiver's class ID. | |
srdjan
2012/12/03 19:10:46
This seems to be receiver not cid. Arg1 is ICData
Kevin Millikin (Google)
2012/12/06 14:03:11
Comment is fixed.
| |
1015 // Arg1: Megamorphic cache. | |
1016 // Arg2: Arguments descriptor. | |
1017 // Arg3: IC data. | |
srdjan
2012/12/03 19:10:46
Describe results (target not found vs found).
| |
1018 DEFINE_RUNTIME_ENTRY(MegamorphicCacheMissHandler, 3) { | |
1019 ASSERT(arguments.ArgCount() == | |
1020 kMegamorphicCacheMissHandlerRuntimeEntry.argument_count()); | |
1021 const Instance& receiver = | |
1022 Instance::CheckedHandle(isolate, arguments.ArgAt(0)); | |
1023 const ICData& ic_data = ICData::CheckedHandle(isolate, arguments.ArgAt(1)); | |
1024 const Array& descriptor = Array::CheckedHandle(isolate, arguments.ArgAt(2)); | |
1025 const String& name = String::Handle(isolate, ic_data.target_name()); | |
1026 const MegamorphicCache& cache = MegamorphicCache::Handle(isolate, | |
1027 isolate->megamorphic_cache_table()->Lookup(name, descriptor)); | |
1028 Class& cls = Class::Handle(isolate, receiver.clazz()); | |
1029 if (cls.IsNullClass()) { | |
Vyacheslav Egorov (Google)
2012/12/03 14:55:22
Please add a comment.
Kevin Millikin (Google)
2012/12/06 14:03:11
The comment at the site I took this from said "For
| |
1030 cls = isolate->object_store()->object_class(); | |
1031 } | |
1032 ASSERT(!cls.IsNull()); | |
1033 intptr_t arg_count = | |
1034 Smi::Cast(Object::Handle(isolate, descriptor.At(0))).Value(); | |
Vyacheslav Egorov (Google)
2012/12/03 14:55:22
I know that this is not your code but I really don
Kevin Millikin (Google)
2012/12/06 14:03:11
I have fixed this in another change.
| |
1035 intptr_t named_arg_count = | |
1036 arg_count - Smi::Cast(Object::Handle(isolate, descriptor.At(1))).Value(); | |
1037 const Function& target = Function::Handle(isolate, | |
1038 Resolver::ResolveDynamicForReceiverClass(cls, | |
1039 name, | |
1040 arg_count, | |
1041 named_arg_count)); | |
1042 | |
1043 Instructions& instructions = Instructions::Handle(isolate); | |
1044 if (!target.IsNull()) { | |
1045 if (!target.HasCode()) { | |
1046 const Error& error = | |
1047 Error::Handle(isolate, Compiler::CompileFunction(target)); | |
1048 if (!error.IsNull()) Exceptions::PropagateError(error); | |
1049 } | |
1050 ASSERT(target.HasCode()); | |
1051 instructions = Code::Handle(isolate, target.CurrentCode()).instructions(); | |
1052 } | |
1053 arguments.SetReturn(instructions); | |
1054 if (instructions.IsNull()) return; | |
srdjan
2012/12/03 19:10:46
Would the code above be simpler if changed to:
ar
Kevin Millikin (Google)
2012/12/06 14:03:11
Possibly. I think we can sort out the code duplic
| |
1055 | |
1056 cache.EnsureCapacity(); | |
1057 const Smi& class_id = Smi::Handle(isolate, Smi::New(cls.id())); | |
1058 cache.Insert(class_id, target); | |
1059 return; | |
srdjan
2012/12/03 19:10:46
I also think that using isolate here explicitly ma
Kevin Millikin (Google)
2012/12/06 14:03:11
Removed.
| |
1060 } | |
srdjan
2012/12/03 19:10:46
Could you also add tracing flag and code to be abl
Kevin Millikin (Google)
2012/12/06 14:03:11
I just printed something for --trace-ic and --trac
| |
1061 | |
1062 | |
1014 // Updates IC data for two arguments. Used by the equality operation when | 1063 // Updates IC data for two arguments. Used by the equality operation when |
1015 // the control flow bypasses regular inline cache (null arguments). | 1064 // the control flow bypasses regular inline cache (null arguments). |
1016 // Arg0: Receiver object. | 1065 // Arg0: Receiver object. |
1017 // Arg1: Argument after receiver. | 1066 // Arg1: Argument after receiver. |
1018 // Arg2: Target's name. | 1067 // Arg2: Target's name. |
1019 // Arg3: ICData. | 1068 // Arg3: ICData. |
1020 DEFINE_RUNTIME_ENTRY(UpdateICDataTwoArgs, 4) { | 1069 DEFINE_RUNTIME_ENTRY(UpdateICDataTwoArgs, 4) { |
1021 ASSERT(arguments.ArgCount() == | 1070 ASSERT(arguments.ArgCount() == |
1022 kUpdateICDataTwoArgsRuntimeEntry.argument_count()); | 1071 kUpdateICDataTwoArgsRuntimeEntry.argument_count()); |
1023 const Instance& receiver = Instance::CheckedHandle(arguments.ArgAt(0)); | 1072 const Instance& receiver = Instance::CheckedHandle(arguments.ArgAt(0)); |
(...skipping 855 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1879 Isolate* isolate = Isolate::Current(); | 1928 Isolate* isolate = Isolate::Current(); |
1880 StackZone zone(isolate); | 1929 StackZone zone(isolate); |
1881 HANDLESCOPE(isolate); | 1930 HANDLESCOPE(isolate); |
1882 const Bigint& big_left = Bigint::Handle(left); | 1931 const Bigint& big_left = Bigint::Handle(left); |
1883 const Bigint& big_right = Bigint::Handle(right); | 1932 const Bigint& big_right = Bigint::Handle(right); |
1884 return BigintOperations::Compare(big_left, big_right); | 1933 return BigintOperations::Compare(big_left, big_right); |
1885 } | 1934 } |
1886 END_LEAF_RUNTIME_ENTRY | 1935 END_LEAF_RUNTIME_ENTRY |
1887 | 1936 |
1888 } // namespace dart | 1937 } // namespace dart |
OLD | NEW |