Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(330)

Side by Side Diff: runtime/vm/object_test.cc

Issue 436643002: Faster IC stubs by specializing them for Binary Smi operations (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "platform/globals.h" 5 #include "platform/globals.h"
6 6
7 #include "vm/assembler.h" 7 #include "vm/assembler.h"
8 #include "vm/bigint_operations.h" 8 #include "vm/bigint_operations.h"
9 #include "vm/class_finalizer.h" 9 #include "vm/class_finalizer.h"
10 #include "vm/dart_api_impl.h" 10 #include "vm/dart_api_impl.h"
(...skipping 2916 matching lines...) Expand 10 before | Expand all | Expand 10 after
2927 is_native, 2927 is_native,
2928 cls, 2928 cls,
2929 0); 2929 0);
2930 } 2930 }
2931 2931
2932 2932
2933 TEST_CASE(ICData) { 2933 TEST_CASE(ICData) {
2934 Function& function = Function::Handle(GetDummyTarget("Bern")); 2934 Function& function = Function::Handle(GetDummyTarget("Bern"));
2935 const intptr_t id = 12; 2935 const intptr_t id = 12;
2936 const intptr_t num_args_tested = 1; 2936 const intptr_t num_args_tested = 1;
2937 const String& target_name = String::Handle(String::New("Thun")); 2937 const String& target_name = String::Handle(Symbols::New("Thun"));
2938 const Array& args_descriptor = 2938 const Array& args_descriptor =
2939 Array::Handle(ArgumentsDescriptor::New(1, Object::null_array())); 2939 Array::Handle(ArgumentsDescriptor::New(1, Object::null_array()));
2940 ICData& o1 = ICData::Handle(); 2940 ICData& o1 = ICData::Handle();
2941 o1 = ICData::New(function, target_name, args_descriptor, id, num_args_tested); 2941 o1 = ICData::New(function, target_name, args_descriptor, id, num_args_tested);
2942 EXPECT_EQ(1, o1.NumArgsTested()); 2942 EXPECT_EQ(1, o1.NumArgsTested());
2943 EXPECT_EQ(id, o1.deopt_id()); 2943 EXPECT_EQ(id, o1.deopt_id());
2944 EXPECT_EQ(function.raw(), o1.owner()); 2944 EXPECT_EQ(function.raw(), o1.owner());
2945 EXPECT_EQ(0, o1.NumberOfChecks()); 2945 EXPECT_EQ(0, o1.NumberOfChecks());
2946 EXPECT_EQ(target_name.raw(), o1.target_name()); 2946 EXPECT_EQ(target_name.raw(), o1.target_name());
2947 EXPECT_EQ(args_descriptor.raw(), o1.arguments_descriptor()); 2947 EXPECT_EQ(args_descriptor.raw(), o1.arguments_descriptor());
2948 2948
2949 const Function& target1 = Function::Handle(GetDummyTarget("Thun")); 2949 const Function& target1 = Function::Handle(GetDummyTarget("Thun"));
2950 o1.AddReceiverCheck(kSmiCid, target1); 2950 o1.AddReceiverCheck(kSmiCid, target1);
2951 EXPECT_EQ(1, o1.NumberOfChecks()); 2951 EXPECT_EQ(1, o1.NumberOfChecks());
2952 EXPECT_EQ(1, o1.NumberOfUsedChecks());
2952 intptr_t test_class_id = -1; 2953 intptr_t test_class_id = -1;
2953 Function& test_target = Function::Handle(); 2954 Function& test_target = Function::Handle();
2954 o1.GetOneClassCheckAt(0, &test_class_id, &test_target); 2955 o1.GetOneClassCheckAt(0, &test_class_id, &test_target);
2955 EXPECT_EQ(kSmiCid, test_class_id); 2956 EXPECT_EQ(kSmiCid, test_class_id);
2956 EXPECT_EQ(target1.raw(), test_target.raw()); 2957 EXPECT_EQ(target1.raw(), test_target.raw());
2957 EXPECT_EQ(kSmiCid, o1.GetCidAt(0)); 2958 EXPECT_EQ(kSmiCid, o1.GetCidAt(0));
2958 GrowableArray<intptr_t> test_class_ids; 2959 GrowableArray<intptr_t> test_class_ids;
2959 o1.GetCheckAt(0, &test_class_ids, &test_target); 2960 o1.GetCheckAt(0, &test_class_ids, &test_target);
2960 EXPECT_EQ(1, test_class_ids.length()); 2961 EXPECT_EQ(1, test_class_ids.length());
2961 EXPECT_EQ(kSmiCid, test_class_ids[0]); 2962 EXPECT_EQ(kSmiCid, test_class_ids[0]);
2962 EXPECT_EQ(target1.raw(), test_target.raw()); 2963 EXPECT_EQ(target1.raw(), test_target.raw());
2963 2964
2964 const Function& target2 = Function::Handle(GetDummyTarget("Thun")); 2965 const Function& target2 = Function::Handle(GetDummyTarget("Thun"));
2965 o1.AddReceiverCheck(kDoubleCid, target2); 2966 o1.AddReceiverCheck(kDoubleCid, target2);
2966 EXPECT_EQ(2, o1.NumberOfChecks()); 2967 EXPECT_EQ(2, o1.NumberOfChecks());
2968 EXPECT_EQ(2, o1.NumberOfUsedChecks());
2967 o1.GetOneClassCheckAt(1, &test_class_id, &test_target); 2969 o1.GetOneClassCheckAt(1, &test_class_id, &test_target);
2968 EXPECT_EQ(kDoubleCid, test_class_id); 2970 EXPECT_EQ(kDoubleCid, test_class_id);
2969 EXPECT_EQ(target2.raw(), test_target.raw()); 2971 EXPECT_EQ(target2.raw(), test_target.raw());
2970 EXPECT_EQ(kDoubleCid, o1.GetCidAt(1)); 2972 EXPECT_EQ(kDoubleCid, o1.GetCidAt(1));
2971 2973
2974 o1.AddReceiverCheck(kMintCid, target2);
2975 EXPECT_EQ(3, o1.NumberOfUsedChecks());
2976 o1.SetCountAt(o1.NumberOfChecks() - 1, 0);
2977 EXPECT_EQ(2, o1.NumberOfUsedChecks());
2978
2972 ICData& o2 = ICData::Handle(); 2979 ICData& o2 = ICData::Handle();
2973 o2 = ICData::New(function, target_name, args_descriptor, 57, 2); 2980 o2 = ICData::New(function, target_name, args_descriptor, 57, 2);
2974 EXPECT_EQ(2, o2.NumArgsTested()); 2981 EXPECT_EQ(2, o2.NumArgsTested());
2975 EXPECT_EQ(57, o2.deopt_id()); 2982 EXPECT_EQ(57, o2.deopt_id());
2976 EXPECT_EQ(function.raw(), o2.owner()); 2983 EXPECT_EQ(function.raw(), o2.owner());
2977 EXPECT_EQ(0, o2.NumberOfChecks()); 2984 EXPECT_EQ(0, o2.NumberOfChecks());
2978 GrowableArray<intptr_t> classes; 2985 GrowableArray<intptr_t> classes;
2979 classes.Add(kSmiCid); 2986 classes.Add(kSmiCid);
2980 classes.Add(kSmiCid); 2987 classes.Add(kSmiCid);
2981 o2.AddCheck(classes, target1); 2988 o2.AddCheck(classes, target1);
(...skipping 1263 matching lines...) Expand 10 before | Expand all | Expand 10 after
4245 EXPECT_VALID(h_result); 4252 EXPECT_VALID(h_result);
4246 Integer& result = Integer::Handle(); 4253 Integer& result = Integer::Handle();
4247 result ^= Api::UnwrapHandle(h_result); 4254 result ^= Api::UnwrapHandle(h_result);
4248 String& foo = String::Handle(String::New("foo")); 4255 String& foo = String::Handle(String::New("foo"));
4249 Integer& expected = Integer::Handle(); 4256 Integer& expected = Integer::Handle();
4250 expected ^= foo.HashCode(); 4257 expected ^= foo.HashCode();
4251 EXPECT(result.IsIdenticalTo(expected)); 4258 EXPECT(result.IsIdenticalTo(expected));
4252 } 4259 }
4253 4260
4254 } // namespace dart 4261 } // namespace dart
OLDNEW
« runtime/vm/object.cc ('K') | « runtime/vm/object.cc ('k') | runtime/vm/stub_code.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698