OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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/kernel_binary_flowgraph.h" | 5 #include "vm/kernel_binary_flowgraph.h" |
6 | 6 |
7 #include "vm/longjump.h" | 7 #include "vm/longjump.h" |
8 #include "vm/object_store.h" | 8 #include "vm/object_store.h" |
9 | 9 |
10 #if !defined(DART_PRECOMPILED_RUNTIME) | 10 #if !defined(DART_PRECOMPILED_RUNTIME) |
(...skipping 977 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
988 false); // read ith expression. | 988 false); // read ith expression. |
989 arguments.SetAt(pos++, result_); | 989 arguments.SetAt(pos++, result_); |
990 } | 990 } |
991 | 991 |
992 return RunFunction(function, arguments, names); | 992 return RunFunction(function, arguments, names); |
993 } | 993 } |
994 | 994 |
995 const Object& StreamingConstantEvaluator::RunFunction(const Function& function, | 995 const Object& StreamingConstantEvaluator::RunFunction(const Function& function, |
996 const Array& arguments, | 996 const Array& arguments, |
997 const Array& names) { | 997 const Array& names) { |
998 const Array& args_descriptor = | 998 // We do not support generic methods yet. |
999 Array::Handle(Z, ArgumentsDescriptor::New(arguments.Length(), names)); | 999 const int kTypeArgsLen = 0; |
| 1000 const Array& args_descriptor = Array::Handle( |
| 1001 Z, ArgumentsDescriptor::New(kTypeArgsLen, arguments.Length(), names)); |
1000 const Object& result = Object::Handle( | 1002 const Object& result = Object::Handle( |
1001 Z, DartEntry::InvokeFunction(function, arguments, args_descriptor)); | 1003 Z, DartEntry::InvokeFunction(function, arguments, args_descriptor)); |
1002 if (result.IsError()) { | 1004 if (result.IsError()) { |
1003 H.ReportError(Error::Cast(result), "error evaluating constant constructor"); | 1005 H.ReportError(Error::Cast(result), "error evaluating constant constructor"); |
1004 } | 1006 } |
1005 return result; | 1007 return result; |
1006 } | 1008 } |
1007 | 1009 |
1008 RawObject* StreamingConstantEvaluator::EvaluateConstConstructorCall( | 1010 RawObject* StreamingConstantEvaluator::EvaluateConstConstructorCall( |
1009 const dart::Class& type_class, | 1011 const dart::Class& type_class, |
1010 const TypeArguments& type_arguments, | 1012 const TypeArguments& type_arguments, |
1011 const Function& constructor, | 1013 const Function& constructor, |
1012 const Object& argument) { | 1014 const Object& argument) { |
1013 // Factories have one extra argument: the type arguments. | 1015 // Factories have one extra argument: the type arguments. |
1014 // Constructors have 1 extra arguments: receiver. | 1016 // Constructors have 1 extra arguments: receiver. |
| 1017 const int kTypeArgsLen = 0; |
1015 const int kNumArgs = 1; | 1018 const int kNumArgs = 1; |
1016 const int kNumExtraArgs = 1; | 1019 const int kNumExtraArgs = 1; |
1017 const int num_arguments = kNumArgs + kNumExtraArgs; | 1020 const int num_arguments = kNumArgs + kNumExtraArgs; |
1018 const Array& arg_values = | 1021 const Array& arg_values = |
1019 Array::Handle(Z, Array::New(num_arguments, Heap::kOld)); | 1022 Array::Handle(Z, Array::New(num_arguments, Heap::kOld)); |
1020 Instance& instance = Instance::Handle(Z); | 1023 Instance& instance = Instance::Handle(Z); |
1021 if (!constructor.IsFactory()) { | 1024 if (!constructor.IsFactory()) { |
1022 instance = Instance::New(type_class, Heap::kOld); | 1025 instance = Instance::New(type_class, Heap::kOld); |
1023 if (!type_arguments.IsNull()) { | 1026 if (!type_arguments.IsNull()) { |
1024 ASSERT(type_arguments.IsInstantiated()); | 1027 ASSERT(type_arguments.IsInstantiated()); |
1025 instance.SetTypeArguments( | 1028 instance.SetTypeArguments( |
1026 TypeArguments::Handle(Z, type_arguments.Canonicalize())); | 1029 TypeArguments::Handle(Z, type_arguments.Canonicalize())); |
1027 } | 1030 } |
1028 arg_values.SetAt(0, instance); | 1031 arg_values.SetAt(0, instance); |
1029 } else { | 1032 } else { |
1030 // Prepend type_arguments to list of arguments to factory. | 1033 // Prepend type_arguments to list of arguments to factory. |
1031 ASSERT(type_arguments.IsZoneHandle()); | 1034 ASSERT(type_arguments.IsZoneHandle()); |
1032 arg_values.SetAt(0, type_arguments); | 1035 arg_values.SetAt(0, type_arguments); |
1033 } | 1036 } |
1034 arg_values.SetAt((0 + kNumExtraArgs), argument); | 1037 arg_values.SetAt((0 + kNumExtraArgs), argument); |
1035 const Array& args_descriptor = Array::Handle( | 1038 const Array& args_descriptor = |
1036 Z, ArgumentsDescriptor::New(num_arguments, Object::empty_array())); | 1039 Array::Handle(Z, ArgumentsDescriptor::New(kTypeArgsLen, num_arguments, |
| 1040 Object::empty_array())); |
1037 const Object& result = Object::Handle( | 1041 const Object& result = Object::Handle( |
1038 Z, DartEntry::InvokeFunction(constructor, arg_values, args_descriptor)); | 1042 Z, DartEntry::InvokeFunction(constructor, arg_values, args_descriptor)); |
1039 ASSERT(!result.IsError()); | 1043 ASSERT(!result.IsError()); |
1040 if (constructor.IsFactory()) { | 1044 if (constructor.IsFactory()) { |
1041 // The factory method returns the allocated object. | 1045 // The factory method returns the allocated object. |
1042 instance ^= result.raw(); | 1046 instance ^= result.raw(); |
1043 } | 1047 } |
1044 return H.Canonicalize(instance); | 1048 return H.Canonicalize(instance); |
1045 } | 1049 } |
1046 | 1050 |
(...skipping 1728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2775 // TODO(28109) Support generic methods in the VM or reify them away. | 2779 // TODO(28109) Support generic methods in the VM or reify them away. |
2776 } | 2780 } |
2777 | 2781 |
2778 bool special_case_identical = | 2782 bool special_case_identical = |
2779 klass.IsTopLevel() && (klass.library() == dart::Library::CoreLibrary()) && | 2783 klass.IsTopLevel() && (klass.library() == dart::Library::CoreLibrary()) && |
2780 (target.name() == Symbols::Identical().raw()); | 2784 (target.name() == Symbols::Identical().raw()); |
2781 | 2785 |
2782 Array& argument_names = Array::ZoneHandle(Z); | 2786 Array& argument_names = Array::ZoneHandle(Z); |
2783 instructions += BuildArguments(&argument_names, NULL, | 2787 instructions += BuildArguments(&argument_names, NULL, |
2784 special_case_identical); // read arguments. | 2788 special_case_identical); // read arguments. |
2785 ASSERT(target.AreValidArguments(argument_count, argument_names, NULL)); | 2789 const int kTypeArgsLen = 0; |
| 2790 ASSERT(target.AreValidArguments(kTypeArgsLen, argument_count, argument_names, |
| 2791 NULL)); |
2786 | 2792 |
2787 // Special case identical(x, y) call. | 2793 // Special case identical(x, y) call. |
2788 // TODO(27590) consider moving this into the inliner and force inline it | 2794 // TODO(27590) consider moving this into the inliner and force inline it |
2789 // there. | 2795 // there. |
2790 if (special_case_identical) { | 2796 if (special_case_identical) { |
2791 ASSERT(argument_count == 2); | 2797 ASSERT(argument_count == 2); |
2792 instructions += StrictCompare(Token::kEQ_STRICT, /*number_check=*/true); | 2798 instructions += StrictCompare(Token::kEQ_STRICT, /*number_check=*/true); |
2793 } else { | 2799 } else { |
2794 instructions += | 2800 instructions += |
2795 StaticCall(position, target, argument_count, argument_names); | 2801 StaticCall(position, target, argument_count, argument_names); |
(...skipping 1515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4311 } | 4317 } |
4312 instructions += StoreLocal(position, variable); | 4318 instructions += StoreLocal(position, variable); |
4313 instructions += Drop(); | 4319 instructions += Drop(); |
4314 return instructions; | 4320 return instructions; |
4315 } | 4321 } |
4316 | 4322 |
4317 } // namespace kernel | 4323 } // namespace kernel |
4318 } // namespace dart | 4324 } // namespace dart |
4319 | 4325 |
4320 #endif // !defined(DART_PRECOMPILED_RUNTIME) | 4326 #endif // !defined(DART_PRECOMPILED_RUNTIME) |
OLD | NEW |