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 // TODO(zra): Remove when tests are ready to enable. | 5 // TODO(zra): Remove when tests are ready to enable. |
6 #include "platform/globals.h" | 6 #include "platform/globals.h" |
7 | 7 |
8 #include "vm/assembler.h" | 8 #include "vm/assembler.h" |
9 #include "vm/bigint_operations.h" | 9 #include "vm/bigint_operations.h" |
10 #include "vm/class_finalizer.h" | 10 #include "vm/class_finalizer.h" |
(...skipping 2684 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2695 EXPECT(!handlers.NeedsStacktrace(3)); | 2695 EXPECT(!handlers.NeedsStacktrace(3)); |
2696 EXPECT(handlers.HasCatchAll(3)); | 2696 EXPECT(handlers.HasCatchAll(3)); |
2697 } | 2697 } |
2698 | 2698 |
2699 | 2699 |
2700 TEST_CASE(PcDescriptors) { | 2700 TEST_CASE(PcDescriptors) { |
2701 const int kNumEntries = 6; | 2701 const int kNumEntries = 6; |
2702 // Add PcDescriptors to the code. | 2702 // Add PcDescriptors to the code. |
2703 PcDescriptors& descriptors = PcDescriptors::Handle(); | 2703 PcDescriptors& descriptors = PcDescriptors::Handle(); |
2704 descriptors ^= PcDescriptors::New(kNumEntries); | 2704 descriptors ^= PcDescriptors::New(kNumEntries); |
2705 descriptors.AddDescriptor(0, 10, PcDescriptors::kOther, 1, 20, 1); | 2705 descriptors.AddDescriptor(0, 10, RawPcDescriptors::kOther, 1, 20, 1); |
2706 descriptors.AddDescriptor(1, 20, PcDescriptors::kDeopt, 2, 30, 0); | 2706 descriptors.AddDescriptor(1, 20, RawPcDescriptors::kDeopt, 2, 30, 0); |
2707 descriptors.AddDescriptor(2, 30, PcDescriptors::kOther, 3, 40, 1); | 2707 descriptors.AddDescriptor(2, 30, RawPcDescriptors::kOther, 3, 40, 1); |
2708 descriptors.AddDescriptor(3, 10, PcDescriptors::kOther, 4, 40, 2); | 2708 descriptors.AddDescriptor(3, 10, RawPcDescriptors::kOther, 4, 40, 2); |
2709 descriptors.AddDescriptor(4, 10, PcDescriptors::kOther, 5, 80, 3); | 2709 descriptors.AddDescriptor(4, 10, RawPcDescriptors::kOther, 5, 80, 3); |
2710 descriptors.AddDescriptor(5, 80, PcDescriptors::kOther, 6, 150, 3); | 2710 descriptors.AddDescriptor(5, 80, RawPcDescriptors::kOther, 6, 150, 3); |
2711 | 2711 |
2712 extern void GenerateIncrement(Assembler* assembler); | 2712 extern void GenerateIncrement(Assembler* assembler); |
2713 Assembler _assembler_; | 2713 Assembler _assembler_; |
2714 GenerateIncrement(&_assembler_); | 2714 GenerateIncrement(&_assembler_); |
2715 Code& code = Code::Handle(Code::FinalizeCode( | 2715 Code& code = Code::Handle(Code::FinalizeCode( |
2716 *CreateFunction("Test_Code"), &_assembler_)); | 2716 *CreateFunction("Test_Code"), &_assembler_)); |
2717 code.set_pc_descriptors(descriptors); | 2717 code.set_pc_descriptors(descriptors); |
2718 | 2718 |
2719 // Verify the PcDescriptor entries by accessing them. | 2719 // Verify the PcDescriptor entries by accessing them. |
2720 const PcDescriptors& pc_descs = PcDescriptors::Handle(code.pc_descriptors()); | 2720 const PcDescriptors& pc_descs = PcDescriptors::Handle(code.pc_descriptors()); |
2721 EXPECT_EQ(kNumEntries, pc_descs.Length()); | 2721 PcDescriptors::Iterator iter(pc_descs); |
2722 EXPECT_EQ(1, pc_descs.TryIndex(0)); | 2722 const RawPcDescriptors::PcDescriptorRec& rec0 = iter.Next(); |
2723 EXPECT_EQ(static_cast<uword>(10), pc_descs.PC(0)); | 2723 const RawPcDescriptors::PcDescriptorRec& rec1 = iter.Next(); |
2724 EXPECT_EQ(1, pc_descs.DeoptId(0)); | 2724 const RawPcDescriptors::PcDescriptorRec& rec2 = iter.Next(); |
2725 EXPECT_EQ(20, pc_descs.TokenPos(0)); | 2725 const RawPcDescriptors::PcDescriptorRec& rec3 = iter.Next(); |
2726 EXPECT_EQ(3, pc_descs.TryIndex(5)); | 2726 const RawPcDescriptors::PcDescriptorRec& rec4 = iter.Next(); |
2727 EXPECT_EQ(static_cast<uword>(80), pc_descs.PC(5)); | 2727 const RawPcDescriptors::PcDescriptorRec& rec5 = iter.Next(); |
2728 EXPECT_EQ(150, pc_descs.TokenPos(5)); | 2728 ASSERT(!iter.HasNext()); |
2729 EXPECT_EQ(PcDescriptors::kOther, pc_descs.DescriptorKind(0)); | 2729 |
2730 EXPECT_EQ(PcDescriptors::kDeopt, pc_descs.DescriptorKind(1)); | 2730 EXPECT_EQ(1, rec0.try_index); |
| 2731 EXPECT_EQ(static_cast<uword>(10), rec0.pc); |
| 2732 EXPECT_EQ(1, rec0.deopt_id); |
| 2733 EXPECT_EQ(20, rec0.token_pos); |
| 2734 |
| 2735 EXPECT_EQ(3, rec5.try_index); |
| 2736 EXPECT_EQ(static_cast<uword>(80), rec5.pc); |
| 2737 EXPECT_EQ(150, rec5.token_pos); |
| 2738 EXPECT_EQ(RawPcDescriptors::kOther, rec0.kind()); |
| 2739 EXPECT_EQ(RawPcDescriptors::kDeopt, rec1.kind()); |
| 2740 |
| 2741 EXPECT_EQ(30, rec1.token_pos); |
| 2742 EXPECT_EQ(40, rec2.token_pos); |
| 2743 EXPECT_EQ(40, rec3.token_pos); |
| 2744 EXPECT_EQ(80, rec4.token_pos); |
2731 } | 2745 } |
2732 | 2746 |
2733 | 2747 |
2734 static RawClass* CreateTestClass(const char* name) { | 2748 static RawClass* CreateTestClass(const char* name) { |
2735 const String& class_name = String::Handle(Symbols::New(name)); | 2749 const String& class_name = String::Handle(Symbols::New(name)); |
2736 const Class& cls = Class::Handle( | 2750 const Class& cls = Class::Handle( |
2737 CreateDummyClass(class_name, Script::Handle())); | 2751 CreateDummyClass(class_name, Script::Handle())); |
2738 return cls.raw(); | 2752 return cls.raw(); |
2739 } | 2753 } |
2740 | 2754 |
(...skipping 1366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4107 EXPECT_VALID(h_result); | 4121 EXPECT_VALID(h_result); |
4108 Integer& result = Integer::Handle(); | 4122 Integer& result = Integer::Handle(); |
4109 result ^= Api::UnwrapHandle(h_result); | 4123 result ^= Api::UnwrapHandle(h_result); |
4110 String& foo = String::Handle(String::New("foo")); | 4124 String& foo = String::Handle(String::New("foo")); |
4111 Integer& expected = Integer::Handle(); | 4125 Integer& expected = Integer::Handle(); |
4112 expected ^= foo.HashCode(); | 4126 expected ^= foo.HashCode(); |
4113 EXPECT(result.IsIdenticalTo(expected)); | 4127 EXPECT(result.IsIdenticalTo(expected)); |
4114 } | 4128 } |
4115 | 4129 |
4116 } // namespace dart | 4130 } // namespace dart |
OLD | NEW |