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

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

Issue 403643002: One more iteration of PcDescriptor iterator improvement: do not copy record but access individual … (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 5 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/raw_object.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/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 2728 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 PcDescriptors::Iterator iter(pc_descs, RawPcDescriptors::kAnyKind); 2748 PcDescriptors::Iterator iter(pc_descs, RawPcDescriptors::kAnyKind);
2749 RawPcDescriptors::PcDescriptorRec rec0;
2750 RawPcDescriptors::PcDescriptorRec rec1;
2751 RawPcDescriptors::PcDescriptorRec rec2;
2752 RawPcDescriptors::PcDescriptorRec rec3;
2753 RawPcDescriptors::PcDescriptorRec rec4;
2754 RawPcDescriptors::PcDescriptorRec rec5;
2755 iter.NextRec(&rec0);
2756 iter.NextRec(&rec1);
2757 iter.NextRec(&rec2);
2758 iter.NextRec(&rec3);
2759 iter.NextRec(&rec4);
2760 iter.NextRec(&rec5);
2761 ASSERT(!iter.HasNext());
2762 2749
2763 EXPECT_EQ(1, rec0.try_index()); 2750 EXPECT_EQ(true, iter.MoveNext());
2764 EXPECT_EQ(static_cast<uword>(10), rec0.pc()); 2751 EXPECT_EQ(20, iter.TokenPos());
2765 EXPECT_EQ(1, rec0.deopt_id()); 2752 EXPECT_EQ(1, iter.TryIndex());
2766 EXPECT_EQ(20, rec0.token_pos()); 2753 EXPECT_EQ(static_cast<uword>(10), iter.Pc());
2754 EXPECT_EQ(1, iter.DeoptId());
2755 EXPECT_EQ(RawPcDescriptors::kOther, iter.Kind());
2767 2756
2768 EXPECT_EQ(3, rec5.try_index()); 2757 EXPECT_EQ(true, iter.MoveNext());
2769 EXPECT_EQ(static_cast<uword>(80), rec5.pc()); 2758 EXPECT_EQ(30, iter.TokenPos());
2770 EXPECT_EQ(150, rec5.token_pos()); 2759 EXPECT_EQ(RawPcDescriptors::kDeopt, iter.Kind());
2771 EXPECT_EQ(RawPcDescriptors::kOther, rec0.kind());
2772 EXPECT_EQ(RawPcDescriptors::kDeopt, rec1.kind());
2773 2760
2774 EXPECT_EQ(30, rec1.token_pos()); 2761 EXPECT_EQ(true, iter.MoveNext());
2775 EXPECT_EQ(40, rec2.token_pos()); 2762 EXPECT_EQ(40, iter.TokenPos());
2776 EXPECT_EQ(40, rec3.token_pos()); 2763
2777 EXPECT_EQ(80, rec4.token_pos()); 2764 EXPECT_EQ(true, iter.MoveNext());
2765 EXPECT_EQ(40, iter.TokenPos());
2766
2767 EXPECT_EQ(true, iter.MoveNext());
2768 EXPECT_EQ(80, iter.TokenPos());
2769
2770 EXPECT_EQ(true, iter.MoveNext());
2771 EXPECT_EQ(150, iter.TokenPos());
2772
2773 EXPECT_EQ(3, iter.TryIndex());
2774 EXPECT_EQ(static_cast<uword>(80), iter.Pc());
2775 EXPECT_EQ(150, iter.TokenPos());
2776 EXPECT_EQ(RawPcDescriptors::kOther, iter.Kind());
2777
2778 EXPECT_EQ(false, iter.MoveNext());
2778 } 2779 }
2779 2780
2780 2781
2781 TEST_CASE(PcDescriptorsCompressed) { 2782 TEST_CASE(PcDescriptorsCompressed) {
2782 const int kNumEntries = 6; 2783 const int kNumEntries = 6;
2783 // Add PcDescriptors to the code. 2784 // Add PcDescriptors to the code.
2784 PcDescriptors& descriptors = PcDescriptors::Handle(); 2785 PcDescriptors& descriptors = PcDescriptors::Handle();
2785 // PcDescritpors have no try-index. 2786 // PcDescritpors have no try-index.
2786 descriptors ^= PcDescriptors::New(kNumEntries, false); 2787 descriptors ^= PcDescriptors::New(kNumEntries, false);
2787 descriptors.AddDescriptor(0, 10, RawPcDescriptors::kOther, 1, 20, -1); 2788 descriptors.AddDescriptor(0, 10, RawPcDescriptors::kOther, 1, 20, -1);
2788 descriptors.AddDescriptor(1, 20, RawPcDescriptors::kDeopt, 2, 30, -1); 2789 descriptors.AddDescriptor(1, 20, RawPcDescriptors::kDeopt, 2, 30, -1);
2789 descriptors.AddDescriptor(2, 30, RawPcDescriptors::kOther, 3, 40, -1); 2790 descriptors.AddDescriptor(2, 30, RawPcDescriptors::kOther, 3, 40, -1);
2790 descriptors.AddDescriptor(3, 10, RawPcDescriptors::kOther, 4, 40, -1); 2791 descriptors.AddDescriptor(3, 10, RawPcDescriptors::kOther, 4, 40, -1);
2791 descriptors.AddDescriptor(4, 10, RawPcDescriptors::kOther, 5, 80, -1); 2792 descriptors.AddDescriptor(4, 10, RawPcDescriptors::kOther, 5, 80, -1);
2792 descriptors.AddDescriptor(5, 80, RawPcDescriptors::kOther, 6, 150, -1); 2793 descriptors.AddDescriptor(5, 80, RawPcDescriptors::kOther, 6, 150, -1);
2793 2794
2794 extern void GenerateIncrement(Assembler* assembler); 2795 extern void GenerateIncrement(Assembler* assembler);
2795 Assembler _assembler_; 2796 Assembler _assembler_;
2796 GenerateIncrement(&_assembler_); 2797 GenerateIncrement(&_assembler_);
2797 Code& code = Code::Handle(Code::FinalizeCode( 2798 Code& code = Code::Handle(Code::FinalizeCode(
2798 *CreateFunction("Test_Code"), &_assembler_)); 2799 *CreateFunction("Test_Code"), &_assembler_));
2799 code.set_pc_descriptors(descriptors); 2800 code.set_pc_descriptors(descriptors);
2800 2801
2801 // Verify the PcDescriptor entries by accessing them. 2802 // Verify the PcDescriptor entries by accessing them.
2802 const PcDescriptors& pc_descs = PcDescriptors::Handle(code.pc_descriptors()); 2803 const PcDescriptors& pc_descs = PcDescriptors::Handle(code.pc_descriptors());
2803 PcDescriptors::Iterator iter(pc_descs, RawPcDescriptors::kAnyKind); 2804 PcDescriptors::Iterator iter(pc_descs, RawPcDescriptors::kAnyKind);
2804 RawPcDescriptors::PcDescriptorRec rec0;
2805 RawPcDescriptors::PcDescriptorRec rec1;
2806 RawPcDescriptors::PcDescriptorRec rec2;
2807 RawPcDescriptors::PcDescriptorRec rec3;
2808 RawPcDescriptors::PcDescriptorRec rec4;
2809 RawPcDescriptors::PcDescriptorRec rec5;
2810 iter.NextRec(&rec0);
2811 iter.NextRec(&rec1);
2812 iter.NextRec(&rec2);
2813 iter.NextRec(&rec3);
2814 iter.NextRec(&rec4);
2815 iter.NextRec(&rec5);
2816 ASSERT(!iter.HasNext());
2817 2805
2818 EXPECT_EQ(-1, rec0.try_index()); 2806 EXPECT_EQ(true, iter.MoveNext());
2819 EXPECT_EQ(static_cast<uword>(10), rec0.pc()); 2807 EXPECT_EQ(static_cast<uword>(10), iter.Pc());
2820 EXPECT_EQ(1, rec0.deopt_id()); 2808 EXPECT_EQ(-1, iter.TryIndex());
2821 EXPECT_EQ(20, rec0.token_pos()); 2809 EXPECT_EQ(1, iter.DeoptId());
2810 EXPECT_EQ(20, iter.TokenPos());
2822 2811
2823 EXPECT_EQ(-1, rec5.try_index()); 2812 EXPECT_EQ(true, iter.MoveNext());
2824 EXPECT_EQ(static_cast<uword>(80), rec5.pc()); 2813 EXPECT_EQ(true, iter.MoveNext());
2825 EXPECT_EQ(150, rec5.token_pos()); 2814 EXPECT_EQ(true, iter.MoveNext());
2826 EXPECT_EQ(RawPcDescriptors::kOther, rec0.kind()); 2815 EXPECT_EQ(true, iter.MoveNext());
2827 EXPECT_EQ(RawPcDescriptors::kDeopt, rec1.kind()); 2816 EXPECT_EQ(true, iter.MoveNext());
2828 2817
2829 EXPECT_EQ(30, rec1.token_pos()); 2818 EXPECT_EQ(-1, iter.TryIndex());
2830 EXPECT_EQ(40, rec2.token_pos()); 2819 EXPECT_EQ(static_cast<uword>(80), iter.Pc());
2831 EXPECT_EQ(40, rec3.token_pos()); 2820 EXPECT_EQ(150, iter.TokenPos());
2832 EXPECT_EQ(80, rec4.token_pos()); 2821
2822 EXPECT_EQ(false, iter.MoveNext());
2833 } 2823 }
2834 2824
2835 2825
2836 2826
2837 static RawClass* CreateTestClass(const char* name) { 2827 static RawClass* CreateTestClass(const char* name) {
2838 const String& class_name = String::Handle(Symbols::New(name)); 2828 const String& class_name = String::Handle(Symbols::New(name));
2839 const Class& cls = Class::Handle( 2829 const Class& cls = Class::Handle(
2840 CreateDummyClass(class_name, Script::Handle())); 2830 CreateDummyClass(class_name, Script::Handle()));
2841 return cls.raw(); 2831 return cls.raw();
2842 } 2832 }
(...skipping 1367 matching lines...) Expand 10 before | Expand all | Expand 10 after
4210 EXPECT_VALID(h_result); 4200 EXPECT_VALID(h_result);
4211 Integer& result = Integer::Handle(); 4201 Integer& result = Integer::Handle();
4212 result ^= Api::UnwrapHandle(h_result); 4202 result ^= Api::UnwrapHandle(h_result);
4213 String& foo = String::Handle(String::New("foo")); 4203 String& foo = String::Handle(String::New("foo"));
4214 Integer& expected = Integer::Handle(); 4204 Integer& expected = Integer::Handle();
4215 expected ^= foo.HashCode(); 4205 expected ^= foo.HashCode();
4216 EXPECT(result.IsIdenticalTo(expected)); 4206 EXPECT(result.IsIdenticalTo(expected));
4217 } 4207 }
4218 4208
4219 } // namespace dart 4209 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object.cc ('k') | runtime/vm/raw_object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698