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

Unified Diff: runtime/vm/object_test.cc

Issue 356923006: Iterate over PcDescriptors only via iterators, not via an index. (preparation for more compression … (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 side-by-side diff with in-line comments
Download patch
Index: runtime/vm/object_test.cc
===================================================================
--- runtime/vm/object_test.cc (revision 38030)
+++ runtime/vm/object_test.cc (working copy)
@@ -2729,12 +2729,12 @@
// Add PcDescriptors to the code.
PcDescriptors& descriptors = PcDescriptors::Handle();
descriptors ^= PcDescriptors::New(kNumEntries);
- descriptors.AddDescriptor(0, 10, PcDescriptors::kOther, 1, 20, 1);
- descriptors.AddDescriptor(1, 20, PcDescriptors::kDeopt, 2, 30, 0);
- descriptors.AddDescriptor(2, 30, PcDescriptors::kOther, 3, 40, 1);
- descriptors.AddDescriptor(3, 10, PcDescriptors::kOther, 4, 40, 2);
- descriptors.AddDescriptor(4, 10, PcDescriptors::kOther, 5, 80, 3);
- descriptors.AddDescriptor(5, 80, PcDescriptors::kOther, 6, 150, 3);
+ descriptors.AddDescriptor(0, 10, RawPcDescriptors::kOther, 1, 20, 1);
+ descriptors.AddDescriptor(1, 20, RawPcDescriptors::kDeopt, 2, 30, 0);
+ descriptors.AddDescriptor(2, 30, RawPcDescriptors::kOther, 3, 40, 1);
+ descriptors.AddDescriptor(3, 10, RawPcDescriptors::kOther, 4, 40, 2);
+ descriptors.AddDescriptor(4, 10, RawPcDescriptors::kOther, 5, 80, 3);
+ descriptors.AddDescriptor(5, 80, RawPcDescriptors::kOther, 6, 150, 3);
extern void GenerateIncrement(Assembler* assembler);
Assembler _assembler_;
@@ -2745,16 +2745,30 @@
// Verify the PcDescriptor entries by accessing them.
const PcDescriptors& pc_descs = PcDescriptors::Handle(code.pc_descriptors());
- EXPECT_EQ(kNumEntries, pc_descs.Length());
- EXPECT_EQ(1, pc_descs.TryIndex(0));
- EXPECT_EQ(static_cast<uword>(10), pc_descs.PC(0));
- EXPECT_EQ(1, pc_descs.DeoptId(0));
- EXPECT_EQ(20, pc_descs.TokenPos(0));
- EXPECT_EQ(3, pc_descs.TryIndex(5));
- EXPECT_EQ(static_cast<uword>(80), pc_descs.PC(5));
- EXPECT_EQ(150, pc_descs.TokenPos(5));
- EXPECT_EQ(PcDescriptors::kOther, pc_descs.DescriptorKind(0));
- EXPECT_EQ(PcDescriptors::kDeopt, pc_descs.DescriptorKind(1));
+ PcDescriptors::Iterator iter(pc_descs);
+ const RawPcDescriptors::PcDescriptorRec& rec0 = iter.Next();
+ const RawPcDescriptors::PcDescriptorRec& rec1 = iter.Next();
+ const RawPcDescriptors::PcDescriptorRec& rec2 = iter.Next();
+ const RawPcDescriptors::PcDescriptorRec& rec3 = iter.Next();
+ const RawPcDescriptors::PcDescriptorRec& rec4 = iter.Next();
+ const RawPcDescriptors::PcDescriptorRec& rec5 = iter.Next();
+ ASSERT(!iter.HasNext());
+
+ EXPECT_EQ(1, rec0.try_index);
+ EXPECT_EQ(static_cast<uword>(10), rec0.pc);
+ EXPECT_EQ(1, rec0.deopt_id);
+ EXPECT_EQ(20, rec0.token_pos);
+
+ EXPECT_EQ(3, rec5.try_index);
+ EXPECT_EQ(static_cast<uword>(80), rec5.pc);
+ EXPECT_EQ(150, rec5.token_pos);
+ EXPECT_EQ(RawPcDescriptors::kOther, rec0.kind());
+ EXPECT_EQ(RawPcDescriptors::kDeopt, rec1.kind());
+
+ EXPECT_EQ(30, rec1.token_pos);
+ EXPECT_EQ(40, rec2.token_pos);
+ EXPECT_EQ(40, rec3.token_pos);
+ EXPECT_EQ(80, rec4.token_pos);
}
« runtime/vm/debugger.cc ('K') | « 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