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

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

Issue 10832150: Get rid of ast node ids. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 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
« no previous file with comments | « runtime/vm/object.cc ('k') | runtime/vm/parser.h » ('j') | 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/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 2518 matching lines...) Expand 10 before | Expand all | Expand 10 after
2529 GenerateIncrement(&_assembler_); 2529 GenerateIncrement(&_assembler_);
2530 Code& code = Code::Handle(Code::FinalizeCode( 2530 Code& code = Code::Handle(Code::FinalizeCode(
2531 *CreateFunction("Test_Code"), &_assembler_)); 2531 *CreateFunction("Test_Code"), &_assembler_));
2532 code.set_pc_descriptors(descriptors); 2532 code.set_pc_descriptors(descriptors);
2533 2533
2534 // Verify the PcDescriptor entries by accessing them. 2534 // Verify the PcDescriptor entries by accessing them.
2535 const PcDescriptors& pc_descs = PcDescriptors::Handle(code.pc_descriptors()); 2535 const PcDescriptors& pc_descs = PcDescriptors::Handle(code.pc_descriptors());
2536 EXPECT_EQ(kNumEntries, pc_descs.Length()); 2536 EXPECT_EQ(kNumEntries, pc_descs.Length());
2537 EXPECT_EQ(1, pc_descs.TryIndex(0)); 2537 EXPECT_EQ(1, pc_descs.TryIndex(0));
2538 EXPECT_EQ(static_cast<uword>(10), pc_descs.PC(0)); 2538 EXPECT_EQ(static_cast<uword>(10), pc_descs.PC(0));
2539 EXPECT_EQ(1, pc_descs.NodeId(0)); 2539 EXPECT_EQ(1, pc_descs.DeoptId(0));
2540 EXPECT_EQ(20, pc_descs.TokenIndex(0)); 2540 EXPECT_EQ(20, pc_descs.TokenPos(0));
2541 EXPECT_EQ(3, pc_descs.TryIndex(5)); 2541 EXPECT_EQ(3, pc_descs.TryIndex(5));
2542 EXPECT_EQ(static_cast<uword>(80), pc_descs.PC(5)); 2542 EXPECT_EQ(static_cast<uword>(80), pc_descs.PC(5));
2543 EXPECT_EQ(150, pc_descs.TokenIndex(5)); 2543 EXPECT_EQ(150, pc_descs.TokenPos(5));
2544 EXPECT_EQ(PcDescriptors::kOther, pc_descs.DescriptorKind(0)); 2544 EXPECT_EQ(PcDescriptors::kOther, pc_descs.DescriptorKind(0));
2545 EXPECT_EQ(PcDescriptors::kDeopt, pc_descs.DescriptorKind(1)); 2545 EXPECT_EQ(PcDescriptors::kDeopt, pc_descs.DescriptorKind(1));
2546 } 2546 }
2547 2547
2548 2548
2549 static RawClass* CreateTestClass(const char* name) { 2549 static RawClass* CreateTestClass(const char* name) {
2550 const String& class_name = String::Handle(Symbols::New(name)); 2550 const String& class_name = String::Handle(Symbols::New(name));
2551 const Class& cls = Class::Handle( 2551 const Class& cls = Class::Handle(
2552 Class::New(class_name, Script::Handle(), Scanner::kDummyTokenIndex)); 2552 Class::New(class_name, Script::Handle(), Scanner::kDummyTokenIndex));
2553 return cls.raw(); 2553 return cls.raw();
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
2606 2606
2607 2607
2608 TEST_CASE(ICData) { 2608 TEST_CASE(ICData) {
2609 Function& function = Function::Handle(GetDummyTarget("Bern")); 2609 Function& function = Function::Handle(GetDummyTarget("Bern"));
2610 const intptr_t id = 12; 2610 const intptr_t id = 12;
2611 const intptr_t num_args_tested = 1; 2611 const intptr_t num_args_tested = 1;
2612 const String& target_name = String::Handle(String::New("Thun")); 2612 const String& target_name = String::Handle(String::New("Thun"));
2613 ICData& o1 = ICData::Handle(); 2613 ICData& o1 = ICData::Handle();
2614 o1 = ICData::New(function, target_name, id, num_args_tested); 2614 o1 = ICData::New(function, target_name, id, num_args_tested);
2615 EXPECT_EQ(1, o1.num_args_tested()); 2615 EXPECT_EQ(1, o1.num_args_tested());
2616 EXPECT_EQ(id, o1.id()); 2616 EXPECT_EQ(id, o1.deopt_id());
2617 EXPECT_EQ(function.raw(), o1.function()); 2617 EXPECT_EQ(function.raw(), o1.function());
2618 EXPECT_EQ(0, o1.NumberOfChecks()); 2618 EXPECT_EQ(0, o1.NumberOfChecks());
2619 EXPECT_EQ(target_name.raw(), o1.target_name()); 2619 EXPECT_EQ(target_name.raw(), o1.target_name());
2620 2620
2621 const Function& target1 = Function::Handle(GetDummyTarget("Thun")); 2621 const Function& target1 = Function::Handle(GetDummyTarget("Thun"));
2622 o1.AddReceiverCheck(kSmi, target1); 2622 o1.AddReceiverCheck(kSmi, target1);
2623 EXPECT_EQ(1, o1.NumberOfChecks()); 2623 EXPECT_EQ(1, o1.NumberOfChecks());
2624 intptr_t test_class_id = -1; 2624 intptr_t test_class_id = -1;
2625 Function& test_target = Function::Handle(); 2625 Function& test_target = Function::Handle();
2626 o1.GetOneClassCheckAt(0, &test_class_id, &test_target); 2626 o1.GetOneClassCheckAt(0, &test_class_id, &test_target);
2627 EXPECT_EQ(kSmi, test_class_id); 2627 EXPECT_EQ(kSmi, test_class_id);
2628 EXPECT_EQ(target1.raw(), test_target.raw()); 2628 EXPECT_EQ(target1.raw(), test_target.raw());
2629 GrowableArray<intptr_t> test_class_ids; 2629 GrowableArray<intptr_t> test_class_ids;
2630 o1.GetCheckAt(0, &test_class_ids, &test_target); 2630 o1.GetCheckAt(0, &test_class_ids, &test_target);
2631 EXPECT_EQ(1, test_class_ids.length()); 2631 EXPECT_EQ(1, test_class_ids.length());
2632 EXPECT_EQ(kSmi, test_class_ids[0]); 2632 EXPECT_EQ(kSmi, test_class_ids[0]);
2633 EXPECT_EQ(target1.raw(), test_target.raw()); 2633 EXPECT_EQ(target1.raw(), test_target.raw());
2634 2634
2635 const Function& target2 = Function::Handle(GetDummyTarget("Thun")); 2635 const Function& target2 = Function::Handle(GetDummyTarget("Thun"));
2636 o1.AddReceiverCheck(kDouble, target2); 2636 o1.AddReceiverCheck(kDouble, target2);
2637 EXPECT_EQ(2, o1.NumberOfChecks()); 2637 EXPECT_EQ(2, o1.NumberOfChecks());
2638 o1.GetOneClassCheckAt(1, &test_class_id, &test_target); 2638 o1.GetOneClassCheckAt(1, &test_class_id, &test_target);
2639 EXPECT_EQ(kDouble, test_class_id); 2639 EXPECT_EQ(kDouble, test_class_id);
2640 EXPECT_EQ(target2.raw(), test_target.raw()); 2640 EXPECT_EQ(target2.raw(), test_target.raw());
2641 2641
2642 ICData& o2 = ICData::Handle(); 2642 ICData& o2 = ICData::Handle();
2643 o2 = ICData::New(function, target_name, 57, 2); 2643 o2 = ICData::New(function, target_name, 57, 2);
2644 EXPECT_EQ(2, o2.num_args_tested()); 2644 EXPECT_EQ(2, o2.num_args_tested());
2645 EXPECT_EQ(57, o2.id()); 2645 EXPECT_EQ(57, o2.deopt_id());
2646 EXPECT_EQ(function.raw(), o2.function()); 2646 EXPECT_EQ(function.raw(), o2.function());
2647 EXPECT_EQ(0, o2.NumberOfChecks()); 2647 EXPECT_EQ(0, o2.NumberOfChecks());
2648 GrowableArray<intptr_t> classes; 2648 GrowableArray<intptr_t> classes;
2649 classes.Add(kSmi); 2649 classes.Add(kSmi);
2650 classes.Add(kSmi); 2650 classes.Add(kSmi);
2651 o2.AddCheck(classes, target1); 2651 o2.AddCheck(classes, target1);
2652 EXPECT_EQ(1, o2.NumberOfChecks()); 2652 EXPECT_EQ(1, o2.NumberOfChecks());
2653 o2.GetCheckAt(0, &test_class_ids, &test_target); 2653 o2.GetCheckAt(0, &test_class_ids, &test_target);
2654 EXPECT_EQ(2, test_class_ids.length()); 2654 EXPECT_EQ(2, test_class_ids.length());
2655 EXPECT_EQ(kSmi, test_class_ids[0]); 2655 EXPECT_EQ(kSmi, test_class_ids[0]);
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
2804 2804
2805 2805
2806 TEST_CASE(ArrayNew_Overflow_Crash) { 2806 TEST_CASE(ArrayNew_Overflow_Crash) {
2807 Array::Handle(Array::New(Array::kMaxElements + 1)); 2807 Array::Handle(Array::New(Array::kMaxElements + 1));
2808 } 2808 }
2809 2809
2810 2810
2811 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). 2811 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64).
2812 2812
2813 } // namespace dart 2813 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object.cc ('k') | runtime/vm/parser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698