| 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/globals.h" | 5 #include "platform/globals.h" |
| 6 | 6 |
| 7 #include "vm/assembler.h" | 7 #include "vm/assembler.h" |
| 8 #include "vm/bigint_operations.h" | 8 #include "vm/bigint_operations.h" |
| 9 #include "vm/class_finalizer.h" | 9 #include "vm/class_finalizer.h" |
| 10 #include "vm/dart_api_impl.h" | 10 #include "vm/dart_api_impl.h" |
| (...skipping 2711 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2722 EXPECT(!handlers.NeedsStacktrace(3)); | 2722 EXPECT(!handlers.NeedsStacktrace(3)); |
| 2723 EXPECT(handlers.HasCatchAll(3)); | 2723 EXPECT(handlers.HasCatchAll(3)); |
| 2724 } | 2724 } |
| 2725 | 2725 |
| 2726 | 2726 |
| 2727 TEST_CASE(PcDescriptors) { | 2727 TEST_CASE(PcDescriptors) { |
| 2728 const int kNumEntries = 6; | 2728 const int kNumEntries = 6; |
| 2729 // Add PcDescriptors to the code. | 2729 // Add PcDescriptors to the code. |
| 2730 PcDescriptors& descriptors = PcDescriptors::Handle(); | 2730 PcDescriptors& descriptors = PcDescriptors::Handle(); |
| 2731 descriptors ^= PcDescriptors::New(kNumEntries); | 2731 descriptors ^= PcDescriptors::New(kNumEntries); |
| 2732 descriptors.AddDescriptor(0, 10, PcDescriptors::kOther, 1, 20, 1); | 2732 descriptors.AddDescriptor(0, 10, RawPcDescriptors::kOther, 1, 20, 1); |
| 2733 descriptors.AddDescriptor(1, 20, PcDescriptors::kDeopt, 2, 30, 0); | 2733 descriptors.AddDescriptor(1, 20, RawPcDescriptors::kDeopt, 2, 30, 0); |
| 2734 descriptors.AddDescriptor(2, 30, PcDescriptors::kOther, 3, 40, 1); | 2734 descriptors.AddDescriptor(2, 30, RawPcDescriptors::kOther, 3, 40, 1); |
| 2735 descriptors.AddDescriptor(3, 10, PcDescriptors::kOther, 4, 40, 2); | 2735 descriptors.AddDescriptor(3, 10, RawPcDescriptors::kOther, 4, 40, 2); |
| 2736 descriptors.AddDescriptor(4, 10, PcDescriptors::kOther, 5, 80, 3); | 2736 descriptors.AddDescriptor(4, 10, RawPcDescriptors::kOther, 5, 80, 3); |
| 2737 descriptors.AddDescriptor(5, 80, PcDescriptors::kOther, 6, 150, 3); | 2737 descriptors.AddDescriptor(5, 80, RawPcDescriptors::kOther, 6, 150, 3); |
| 2738 | 2738 |
| 2739 extern void GenerateIncrement(Assembler* assembler); | 2739 extern void GenerateIncrement(Assembler* assembler); |
| 2740 Assembler _assembler_; | 2740 Assembler _assembler_; |
| 2741 GenerateIncrement(&_assembler_); | 2741 GenerateIncrement(&_assembler_); |
| 2742 Code& code = Code::Handle(Code::FinalizeCode( | 2742 Code& code = Code::Handle(Code::FinalizeCode( |
| 2743 *CreateFunction("Test_Code"), &_assembler_)); | 2743 *CreateFunction("Test_Code"), &_assembler_)); |
| 2744 code.set_pc_descriptors(descriptors); | 2744 code.set_pc_descriptors(descriptors); |
| 2745 | 2745 |
| 2746 // Verify the PcDescriptor entries by accessing them. | 2746 // Verify the PcDescriptor entries by accessing them. |
| 2747 const PcDescriptors& pc_descs = PcDescriptors::Handle(code.pc_descriptors()); | 2747 const PcDescriptors& pc_descs = PcDescriptors::Handle(code.pc_descriptors()); |
| 2748 EXPECT_EQ(kNumEntries, pc_descs.Length()); | 2748 PcDescriptors::Iterator iter(pc_descs); |
| 2749 EXPECT_EQ(1, pc_descs.TryIndex(0)); | 2749 const RawPcDescriptors::PcDescriptorRec& rec0 = iter.Next(); |
| 2750 EXPECT_EQ(static_cast<uword>(10), pc_descs.PC(0)); | 2750 const RawPcDescriptors::PcDescriptorRec& rec1 = iter.Next(); |
| 2751 EXPECT_EQ(1, pc_descs.DeoptId(0)); | 2751 const RawPcDescriptors::PcDescriptorRec& rec2 = iter.Next(); |
| 2752 EXPECT_EQ(20, pc_descs.TokenPos(0)); | 2752 const RawPcDescriptors::PcDescriptorRec& rec3 = iter.Next(); |
| 2753 EXPECT_EQ(3, pc_descs.TryIndex(5)); | 2753 const RawPcDescriptors::PcDescriptorRec& rec4 = iter.Next(); |
| 2754 EXPECT_EQ(static_cast<uword>(80), pc_descs.PC(5)); | 2754 const RawPcDescriptors::PcDescriptorRec& rec5 = iter.Next(); |
| 2755 EXPECT_EQ(150, pc_descs.TokenPos(5)); | 2755 ASSERT(!iter.HasNext()); |
| 2756 EXPECT_EQ(PcDescriptors::kOther, pc_descs.DescriptorKind(0)); | 2756 |
| 2757 EXPECT_EQ(PcDescriptors::kDeopt, pc_descs.DescriptorKind(1)); | 2757 EXPECT_EQ(1, rec0.try_index); |
| 2758 EXPECT_EQ(static_cast<uword>(10), rec0.pc); |
| 2759 EXPECT_EQ(1, rec0.deopt_id); |
| 2760 EXPECT_EQ(20, rec0.token_pos); |
| 2761 |
| 2762 EXPECT_EQ(3, rec5.try_index); |
| 2763 EXPECT_EQ(static_cast<uword>(80), rec5.pc); |
| 2764 EXPECT_EQ(150, rec5.token_pos); |
| 2765 EXPECT_EQ(RawPcDescriptors::kOther, rec0.kind()); |
| 2766 EXPECT_EQ(RawPcDescriptors::kDeopt, rec1.kind()); |
| 2767 |
| 2768 EXPECT_EQ(30, rec1.token_pos); |
| 2769 EXPECT_EQ(40, rec2.token_pos); |
| 2770 EXPECT_EQ(40, rec3.token_pos); |
| 2771 EXPECT_EQ(80, rec4.token_pos); |
| 2758 } | 2772 } |
| 2759 | 2773 |
| 2760 | 2774 |
| 2761 static RawClass* CreateTestClass(const char* name) { | 2775 static RawClass* CreateTestClass(const char* name) { |
| 2762 const String& class_name = String::Handle(Symbols::New(name)); | 2776 const String& class_name = String::Handle(Symbols::New(name)); |
| 2763 const Class& cls = Class::Handle( | 2777 const Class& cls = Class::Handle( |
| 2764 CreateDummyClass(class_name, Script::Handle())); | 2778 CreateDummyClass(class_name, Script::Handle())); |
| 2765 return cls.raw(); | 2779 return cls.raw(); |
| 2766 } | 2780 } |
| 2767 | 2781 |
| (...skipping 1366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4134 EXPECT_VALID(h_result); | 4148 EXPECT_VALID(h_result); |
| 4135 Integer& result = Integer::Handle(); | 4149 Integer& result = Integer::Handle(); |
| 4136 result ^= Api::UnwrapHandle(h_result); | 4150 result ^= Api::UnwrapHandle(h_result); |
| 4137 String& foo = String::Handle(String::New("foo")); | 4151 String& foo = String::Handle(String::New("foo")); |
| 4138 Integer& expected = Integer::Handle(); | 4152 Integer& expected = Integer::Handle(); |
| 4139 expected ^= foo.HashCode(); | 4153 expected ^= foo.HashCode(); |
| 4140 EXPECT(result.IsIdenticalTo(expected)); | 4154 EXPECT(result.IsIdenticalTo(expected)); |
| 4141 } | 4155 } |
| 4142 | 4156 |
| 4143 } // namespace dart | 4157 } // namespace dart |
| OLD | NEW |