| 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/isolate.h" | 8 #include "vm/isolate.h" |
| 9 #include "vm/object.h" | 9 #include "vm/object.h" |
| 10 #include "vm/object_store.h" | 10 #include "vm/object_store.h" |
| (...skipping 2399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2410 int count = 0; | 2410 int count = 0; |
| 2411 Class& cls = Class::Handle(); | 2411 Class& cls = Class::Handle(); |
| 2412 while (iterator.HasNext()) { | 2412 while (iterator.HasNext()) { |
| 2413 cls = iterator.GetNextClass(); | 2413 cls = iterator.GetNextClass(); |
| 2414 ASSERT((cls.raw() == ae66.raw()) || (cls.raw() == re44.raw())); | 2414 ASSERT((cls.raw() == ae66.raw()) || (cls.raw() == re44.raw())); |
| 2415 count++; | 2415 count++; |
| 2416 } | 2416 } |
| 2417 ASSERT(count == 2); | 2417 ASSERT(count == 2); |
| 2418 } | 2418 } |
| 2419 | 2419 |
| 2420 |
| 2421 static RawFunction* GetDummyTarget(const char* name) { |
| 2422 const String& function_name = String::Handle(String::NewSymbol(name)); |
| 2423 const bool is_static = false; |
| 2424 const bool is_const = false; |
| 2425 return Function::New(function_name, |
| 2426 RawFunction::kFunction, |
| 2427 is_static, |
| 2428 is_const, |
| 2429 0); |
| 2430 } |
| 2431 |
| 2432 |
| 2433 TEST_CASE(ICData) { |
| 2434 Function& function = Function::Handle(GetDummyTarget("Bern")); |
| 2435 const intptr_t id = 12; |
| 2436 const intptr_t num_args_tested = 1; |
| 2437 const String& target_name = String::Handle(String::New("Thun")); |
| 2438 ICData& o1 = ICData::Handle(); |
| 2439 o1 = ICData::New(function, target_name, id, num_args_tested); |
| 2440 EXPECT_EQ(1, o1.num_args_tested()); |
| 2441 EXPECT_EQ(id, o1.id()); |
| 2442 EXPECT_EQ(function.raw(), o1.function()); |
| 2443 EXPECT_EQ(0, o1.NumberOfChecks()); |
| 2444 EXPECT_EQ(target_name.raw(), o1.target_name()); |
| 2445 |
| 2446 const Function& target1 = Function::Handle(GetDummyTarget("Thun")); |
| 2447 GrowableArray<const Class*> classes; |
| 2448 ObjectStore* object_store = Isolate::Current()->object_store(); |
| 2449 const Class& smi_class = Class::ZoneHandle(object_store->smi_class()); |
| 2450 classes.Add(&smi_class); |
| 2451 o1.AddCheck(classes, target1); |
| 2452 EXPECT_EQ(1, o1.NumberOfChecks()); |
| 2453 Class& test_class = Class::Handle(); |
| 2454 Function& test_target = Function::Handle(); |
| 2455 o1.GetOneClassCheckAt(0, &test_class, &test_target); |
| 2456 EXPECT_EQ(smi_class.raw(), test_class.raw()); |
| 2457 EXPECT_EQ(target1.raw(), test_target.raw()); |
| 2458 GrowableArray<const Class*> test_classes; |
| 2459 o1.GetCheckAt(0, &test_classes, &test_target); |
| 2460 EXPECT_EQ(1, test_classes.length()); |
| 2461 EXPECT_EQ(smi_class.raw(), test_classes[0]->raw()); |
| 2462 EXPECT_EQ(target1.raw(), test_target.raw()); |
| 2463 |
| 2464 classes.Clear(); |
| 2465 const Function& target2 = Function::Handle(GetDummyTarget("Thun")); |
| 2466 const Class& double_class = Class::ZoneHandle(object_store->double_class()); |
| 2467 classes.Add(&double_class); |
| 2468 o1.AddCheck(classes, target2); |
| 2469 EXPECT_EQ(2, o1.NumberOfChecks()); |
| 2470 o1.GetOneClassCheckAt(1, &test_class, &test_target); |
| 2471 EXPECT_EQ(double_class.raw(), test_class.raw()); |
| 2472 EXPECT_EQ(target2.raw(), test_target.raw()); |
| 2473 |
| 2474 ICData& o2 = ICData::Handle(); |
| 2475 o2 = ICData::New(function, target_name, 57, 2); |
| 2476 EXPECT_EQ(2, o2.num_args_tested()); |
| 2477 EXPECT_EQ(57, o2.id()); |
| 2478 EXPECT_EQ(function.raw(), o2.function()); |
| 2479 EXPECT_EQ(0, o2.NumberOfChecks()); |
| 2480 classes.Clear(); |
| 2481 classes.Add(&smi_class); |
| 2482 classes.Add(&smi_class); |
| 2483 o2.AddCheck(classes, target1); |
| 2484 EXPECT_EQ(1, o2.NumberOfChecks()); |
| 2485 o2.GetCheckAt(0, &test_classes, &test_target); |
| 2486 EXPECT_EQ(2, test_classes.length()); |
| 2487 EXPECT_EQ(smi_class.raw(), test_classes[0]->raw()); |
| 2488 EXPECT_EQ(smi_class.raw(), test_classes[1]->raw()); |
| 2489 EXPECT_EQ(target1.raw(), test_target.raw()); |
| 2490 } |
| 2491 |
| 2492 |
| 2420 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). | 2493 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). |
| 2421 | 2494 |
| 2422 } // namespace dart | 2495 } // namespace dart |
| OLD | NEW |