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

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

Issue 2064693003: Remember inside an ICData if it is for a static call or an instance call (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 6 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
« no previous file with comments | « runtime/vm/object_reload.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/class_finalizer.h" 8 #include "vm/class_finalizer.h"
9 #include "vm/dart_api_impl.h" 9 #include "vm/dart_api_impl.h"
10 #include "vm/dart_entry.h" 10 #include "vm/dart_entry.h"
(...skipping 3020 matching lines...) Expand 10 before | Expand all | Expand 10 after
3031 3031
3032 3032
3033 VM_TEST_CASE(ICData) { 3033 VM_TEST_CASE(ICData) {
3034 Function& function = Function::Handle(GetDummyTarget("Bern")); 3034 Function& function = Function::Handle(GetDummyTarget("Bern"));
3035 const intptr_t id = 12; 3035 const intptr_t id = 12;
3036 const intptr_t num_args_tested = 1; 3036 const intptr_t num_args_tested = 1;
3037 const String& target_name = String::Handle(Symbols::New(thread, "Thun")); 3037 const String& target_name = String::Handle(Symbols::New(thread, "Thun"));
3038 const Array& args_descriptor = 3038 const Array& args_descriptor =
3039 Array::Handle(ArgumentsDescriptor::New(1, Object::null_array())); 3039 Array::Handle(ArgumentsDescriptor::New(1, Object::null_array()));
3040 ICData& o1 = ICData::Handle(); 3040 ICData& o1 = ICData::Handle();
3041 o1 = ICData::New(function, target_name, args_descriptor, id, num_args_tested); 3041 o1 = ICData::New(function, target_name, args_descriptor, id,
3042 num_args_tested, false);
3042 EXPECT_EQ(1, o1.NumArgsTested()); 3043 EXPECT_EQ(1, o1.NumArgsTested());
3043 EXPECT_EQ(id, o1.deopt_id()); 3044 EXPECT_EQ(id, o1.deopt_id());
3044 EXPECT_EQ(function.raw(), o1.Owner()); 3045 EXPECT_EQ(function.raw(), o1.Owner());
3045 EXPECT_EQ(0, o1.NumberOfChecks()); 3046 EXPECT_EQ(0, o1.NumberOfChecks());
3046 EXPECT_EQ(target_name.raw(), o1.target_name()); 3047 EXPECT_EQ(target_name.raw(), o1.target_name());
3047 EXPECT_EQ(args_descriptor.raw(), o1.arguments_descriptor()); 3048 EXPECT_EQ(args_descriptor.raw(), o1.arguments_descriptor());
3048 3049
3049 const Function& target1 = Function::Handle(GetDummyTarget("Thun")); 3050 const Function& target1 = Function::Handle(GetDummyTarget("Thun"));
3050 o1.AddReceiverCheck(kSmiCid, target1); 3051 o1.AddReceiverCheck(kSmiCid, target1);
3051 EXPECT_EQ(1, o1.NumberOfChecks()); 3052 EXPECT_EQ(1, o1.NumberOfChecks());
(...skipping 18 matching lines...) Expand all
3070 EXPECT_EQ(kDoubleCid, test_class_id); 3071 EXPECT_EQ(kDoubleCid, test_class_id);
3071 EXPECT_EQ(target2.raw(), test_target.raw()); 3072 EXPECT_EQ(target2.raw(), test_target.raw());
3072 EXPECT_EQ(kDoubleCid, o1.GetCidAt(1)); 3073 EXPECT_EQ(kDoubleCid, o1.GetCidAt(1));
3073 3074
3074 o1.AddReceiverCheck(kMintCid, target2); 3075 o1.AddReceiverCheck(kMintCid, target2);
3075 EXPECT_EQ(3, o1.NumberOfUsedChecks()); 3076 EXPECT_EQ(3, o1.NumberOfUsedChecks());
3076 o1.SetCountAt(o1.NumberOfChecks() - 1, 0); 3077 o1.SetCountAt(o1.NumberOfChecks() - 1, 0);
3077 EXPECT_EQ(2, o1.NumberOfUsedChecks()); 3078 EXPECT_EQ(2, o1.NumberOfUsedChecks());
3078 3079
3079 ICData& o2 = ICData::Handle(); 3080 ICData& o2 = ICData::Handle();
3080 o2 = ICData::New(function, target_name, args_descriptor, 57, 2); 3081 o2 = ICData::New(function, target_name, args_descriptor, 57, 2, false);
3081 EXPECT_EQ(2, o2.NumArgsTested()); 3082 EXPECT_EQ(2, o2.NumArgsTested());
3082 EXPECT_EQ(57, o2.deopt_id()); 3083 EXPECT_EQ(57, o2.deopt_id());
3083 EXPECT_EQ(function.raw(), o2.Owner()); 3084 EXPECT_EQ(function.raw(), o2.Owner());
3084 EXPECT_EQ(0, o2.NumberOfChecks()); 3085 EXPECT_EQ(0, o2.NumberOfChecks());
3085 GrowableArray<intptr_t> classes; 3086 GrowableArray<intptr_t> classes;
3086 classes.Add(kSmiCid); 3087 classes.Add(kSmiCid);
3087 classes.Add(kSmiCid); 3088 classes.Add(kSmiCid);
3088 o2.AddCheck(classes, target1); 3089 o2.AddCheck(classes, target1);
3089 EXPECT_EQ(1, o2.NumberOfChecks()); 3090 EXPECT_EQ(1, o2.NumberOfChecks());
3090 o2.GetCheckAt(0, &test_class_ids, &test_target); 3091 o2.GetCheckAt(0, &test_class_ids, &test_target);
3091 EXPECT_EQ(2, test_class_ids.length()); 3092 EXPECT_EQ(2, test_class_ids.length());
3092 EXPECT_EQ(kSmiCid, test_class_ids[0]); 3093 EXPECT_EQ(kSmiCid, test_class_ids[0]);
3093 EXPECT_EQ(kSmiCid, test_class_ids[1]); 3094 EXPECT_EQ(kSmiCid, test_class_ids[1]);
3094 EXPECT_EQ(target1.raw(), test_target.raw()); 3095 EXPECT_EQ(target1.raw(), test_target.raw());
3095 3096
3096 // Check ICData for unoptimized static calls. 3097 // Check ICData for unoptimized static calls.
3097 const intptr_t kNumArgsChecked = 0; 3098 const intptr_t kNumArgsChecked = 0;
3098 const ICData& scall_icdata = ICData::Handle( 3099 const ICData& scall_icdata = ICData::Handle(
3099 ICData::New(function, target_name, args_descriptor, 57, kNumArgsChecked)); 3100 ICData::New(function, target_name, args_descriptor, 57,
3101 kNumArgsChecked, false));
3100 scall_icdata.AddTarget(target1); 3102 scall_icdata.AddTarget(target1);
3101 EXPECT_EQ(target1.raw(), scall_icdata.GetTargetAt(0)); 3103 EXPECT_EQ(target1.raw(), scall_icdata.GetTargetAt(0));
3102 } 3104 }
3103 3105
3104 3106
3105 VM_TEST_CASE(SubtypeTestCache) { 3107 VM_TEST_CASE(SubtypeTestCache) {
3106 String& class_name = String::Handle(Symbols::New(thread, "EmptyClass")); 3108 String& class_name = String::Handle(Symbols::New(thread, "EmptyClass"));
3107 Script& script = Script::Handle(); 3109 Script& script = Script::Handle();
3108 const Class& empty_class = 3110 const Class& empty_class =
3109 Class::Handle(CreateDummyClass(class_name, script)); 3111 Class::Handle(CreateDummyClass(class_name, script));
(...skipping 1607 matching lines...) Expand 10 before | Expand all | Expand 10 after
4717 String& test = String::Handle(); 4719 String& test = String::Handle();
4718 String& result = String::Handle(); 4720 String& result = String::Handle();
4719 for (size_t i = 0; i < ARRAY_SIZE(tests); i++) { 4721 for (size_t i = 0; i < ARRAY_SIZE(tests); i++) {
4720 test = String::New(tests[i].in); 4722 test = String::New(tests[i].in);
4721 result = String::ScrubName(test); 4723 result = String::ScrubName(test);
4722 EXPECT_STREQ(tests[i].out, result.ToCString()); 4724 EXPECT_STREQ(tests[i].out, result.ToCString());
4723 } 4725 }
4724 } 4726 }
4725 4727
4726 } // namespace dart 4728 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object_reload.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698