| 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 "platform/assert.h" | 5 #include "platform/assert.h" |
| 6 #include "vm/assembler.h" | 6 #include "vm/assembler.h" |
| 7 #include "vm/bigint_operations.h" | 7 #include "vm/bigint_operations.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/isolate.h" | 11 #include "vm/isolate.h" |
| 11 #include "vm/object.h" | 12 #include "vm/object.h" |
| 12 #include "vm/object_store.h" | 13 #include "vm/object_store.h" |
| 13 #include "vm/simulator.h" | 14 #include "vm/simulator.h" |
| 14 #include "vm/symbols.h" | 15 #include "vm/symbols.h" |
| 15 #include "vm/unit_test.h" | 16 #include "vm/unit_test.h" |
| 16 | 17 |
| 17 namespace dart { | 18 namespace dart { |
| 18 | 19 |
| 19 static RawClass* CreateDummyClass(const String& class_name, | 20 static RawClass* CreateDummyClass(const String& class_name, |
| (...skipping 2468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2488 cls, | 2489 cls, |
| 2489 0); | 2490 0); |
| 2490 } | 2491 } |
| 2491 | 2492 |
| 2492 | 2493 |
| 2493 TEST_CASE(ICData) { | 2494 TEST_CASE(ICData) { |
| 2494 Function& function = Function::Handle(GetDummyTarget("Bern")); | 2495 Function& function = Function::Handle(GetDummyTarget("Bern")); |
| 2495 const intptr_t id = 12; | 2496 const intptr_t id = 12; |
| 2496 const intptr_t num_args_tested = 1; | 2497 const intptr_t num_args_tested = 1; |
| 2497 const String& target_name = String::Handle(String::New("Thun")); | 2498 const String& target_name = String::Handle(String::New("Thun")); |
| 2499 const Array& args_descriptor = |
| 2500 Array::ZoneHandle(ArgumentsDescriptor::New(1, Array::Handle())); |
| 2498 ICData& o1 = ICData::Handle(); | 2501 ICData& o1 = ICData::Handle(); |
| 2499 o1 = ICData::New(function, target_name, id, num_args_tested); | 2502 o1 = ICData::New(function, target_name, args_descriptor, id, num_args_tested); |
| 2500 EXPECT_EQ(1, o1.num_args_tested()); | 2503 EXPECT_EQ(1, o1.num_args_tested()); |
| 2501 EXPECT_EQ(id, o1.deopt_id()); | 2504 EXPECT_EQ(id, o1.deopt_id()); |
| 2502 EXPECT_EQ(function.raw(), o1.function()); | 2505 EXPECT_EQ(function.raw(), o1.function()); |
| 2503 EXPECT_EQ(0, o1.NumberOfChecks()); | 2506 EXPECT_EQ(0, o1.NumberOfChecks()); |
| 2504 EXPECT_EQ(target_name.raw(), o1.target_name()); | 2507 EXPECT_EQ(target_name.raw(), o1.target_name()); |
| 2508 EXPECT_EQ(args_descriptor.raw(), o1.arguments_descriptor()); |
| 2505 | 2509 |
| 2506 const Function& target1 = Function::Handle(GetDummyTarget("Thun")); | 2510 const Function& target1 = Function::Handle(GetDummyTarget("Thun")); |
| 2507 o1.AddReceiverCheck(kSmiCid, target1); | 2511 o1.AddReceiverCheck(kSmiCid, target1); |
| 2508 EXPECT_EQ(1, o1.NumberOfChecks()); | 2512 EXPECT_EQ(1, o1.NumberOfChecks()); |
| 2509 intptr_t test_class_id = -1; | 2513 intptr_t test_class_id = -1; |
| 2510 Function& test_target = Function::Handle(); | 2514 Function& test_target = Function::Handle(); |
| 2511 o1.GetOneClassCheckAt(0, &test_class_id, &test_target); | 2515 o1.GetOneClassCheckAt(0, &test_class_id, &test_target); |
| 2512 EXPECT_EQ(kSmiCid, test_class_id); | 2516 EXPECT_EQ(kSmiCid, test_class_id); |
| 2513 EXPECT_EQ(target1.raw(), test_target.raw()); | 2517 EXPECT_EQ(target1.raw(), test_target.raw()); |
| 2514 GrowableArray<intptr_t> test_class_ids; | 2518 GrowableArray<intptr_t> test_class_ids; |
| 2515 o1.GetCheckAt(0, &test_class_ids, &test_target); | 2519 o1.GetCheckAt(0, &test_class_ids, &test_target); |
| 2516 EXPECT_EQ(1, test_class_ids.length()); | 2520 EXPECT_EQ(1, test_class_ids.length()); |
| 2517 EXPECT_EQ(kSmiCid, test_class_ids[0]); | 2521 EXPECT_EQ(kSmiCid, test_class_ids[0]); |
| 2518 EXPECT_EQ(target1.raw(), test_target.raw()); | 2522 EXPECT_EQ(target1.raw(), test_target.raw()); |
| 2519 | 2523 |
| 2520 const Function& target2 = Function::Handle(GetDummyTarget("Thun")); | 2524 const Function& target2 = Function::Handle(GetDummyTarget("Thun")); |
| 2521 o1.AddReceiverCheck(kDoubleCid, target2); | 2525 o1.AddReceiverCheck(kDoubleCid, target2); |
| 2522 EXPECT_EQ(2, o1.NumberOfChecks()); | 2526 EXPECT_EQ(2, o1.NumberOfChecks()); |
| 2523 o1.GetOneClassCheckAt(1, &test_class_id, &test_target); | 2527 o1.GetOneClassCheckAt(1, &test_class_id, &test_target); |
| 2524 EXPECT_EQ(kDoubleCid, test_class_id); | 2528 EXPECT_EQ(kDoubleCid, test_class_id); |
| 2525 EXPECT_EQ(target2.raw(), test_target.raw()); | 2529 EXPECT_EQ(target2.raw(), test_target.raw()); |
| 2526 | 2530 |
| 2527 ICData& o2 = ICData::Handle(); | 2531 ICData& o2 = ICData::Handle(); |
| 2528 o2 = ICData::New(function, target_name, 57, 2); | 2532 o2 = ICData::New(function, target_name, args_descriptor, 57, 2); |
| 2529 EXPECT_EQ(2, o2.num_args_tested()); | 2533 EXPECT_EQ(2, o2.num_args_tested()); |
| 2530 EXPECT_EQ(57, o2.deopt_id()); | 2534 EXPECT_EQ(57, o2.deopt_id()); |
| 2531 EXPECT_EQ(function.raw(), o2.function()); | 2535 EXPECT_EQ(function.raw(), o2.function()); |
| 2532 EXPECT_EQ(0, o2.NumberOfChecks()); | 2536 EXPECT_EQ(0, o2.NumberOfChecks()); |
| 2533 GrowableArray<intptr_t> classes; | 2537 GrowableArray<intptr_t> classes; |
| 2534 classes.Add(kSmiCid); | 2538 classes.Add(kSmiCid); |
| 2535 classes.Add(kSmiCid); | 2539 classes.Add(kSmiCid); |
| 2536 o2.AddCheck(classes, target1); | 2540 o2.AddCheck(classes, target1); |
| 2537 EXPECT_EQ(1, o2.NumberOfChecks()); | 2541 EXPECT_EQ(1, o2.NumberOfChecks()); |
| 2538 o2.GetCheckAt(0, &test_class_ids, &test_target); | 2542 o2.GetCheckAt(0, &test_class_ids, &test_target); |
| (...skipping 786 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3325 const Function& test7 = Function::Handle(GetFunction(class_a, "test7")); | 3329 const Function& test7 = Function::Handle(GetFunction(class_a, "test7")); |
| 3326 EXPECT_EQ(test1.SourceFingerprint(), test2.SourceFingerprint()); | 3330 EXPECT_EQ(test1.SourceFingerprint(), test2.SourceFingerprint()); |
| 3327 EXPECT_NE(test1.SourceFingerprint(), test3.SourceFingerprint()); | 3331 EXPECT_NE(test1.SourceFingerprint(), test3.SourceFingerprint()); |
| 3328 EXPECT_NE(test3.SourceFingerprint(), test4.SourceFingerprint()); | 3332 EXPECT_NE(test3.SourceFingerprint(), test4.SourceFingerprint()); |
| 3329 EXPECT_NE(test4.SourceFingerprint(), test5.SourceFingerprint()); | 3333 EXPECT_NE(test4.SourceFingerprint(), test5.SourceFingerprint()); |
| 3330 EXPECT_NE(test5.SourceFingerprint(), test6.SourceFingerprint()); | 3334 EXPECT_NE(test5.SourceFingerprint(), test6.SourceFingerprint()); |
| 3331 EXPECT_EQ(test6.SourceFingerprint(), test7.SourceFingerprint()); | 3335 EXPECT_EQ(test6.SourceFingerprint(), test7.SourceFingerprint()); |
| 3332 } | 3336 } |
| 3333 | 3337 |
| 3334 } // namespace dart | 3338 } // namespace dart |
| OLD | NEW |