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

Unified Diff: runtime/vm/object.cc

Issue 10407019: Extend assembler with ability to produce comments for the generated code. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: address Srdjan comments Created 8 years, 7 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.cc
diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc
index 86bd0b75b5a41a80af1696a8b22783424d70eb19..7e66611bf7135c9044838073fb20180f94cd15b2 100644
--- a/runtime/vm/object.cc
+++ b/runtime/vm/object.cc
@@ -6072,11 +6072,67 @@ const char* ExceptionHandlers::ToCString() const {
}
+Code::Comments& Code::Comments::New(intptr_t count) {
+ Comments* comments;
+ if (count == 0) {
+ comments = new Comments(Array::Handle());
srdjan 2012/05/17 21:30:37 The other option would be to use Array::Empty() in
+ } else {
+ comments = new Comments(Array::Handle(
+ Array::New(count * kNumberOfEntries)));
+ }
+ return *comments;
+}
+
+
+intptr_t Code::Comments::Length() const {
+ return comments_.IsNull() ? 0 : (comments_.Length() / kNumberOfEntries);
+}
+
+
+intptr_t Code::Comments::PCOffsetAt(intptr_t idx) const {
+ return Smi::CheckedHandle(
+ comments_.At(idx * kNumberOfEntries + kPCOffsetEntry)).Value();
+}
+
+
+void Code::Comments::SetPCOffsetAt(intptr_t idx, intptr_t pc) {
+ comments_.SetAt(idx * kNumberOfEntries + kPCOffsetEntry,
+ Smi::Handle(Smi::New(pc)));
+}
+
+
+const String& Code::Comments::CommentAt(intptr_t idx) const {
+ return String::CheckedHandle(
+ comments_.At(idx * kNumberOfEntries + kCommentEntry));
+}
+
+
+void Code::Comments::SetCommentAt(intptr_t idx, const String& comment) {
+ comments_.SetAt(idx * kNumberOfEntries + kCommentEntry, comment);
+}
+
+
+Code::Comments::Comments(const Array& comments)
+ : comments_(comments) {
+}
+
+
void Code::set_stackmaps(const Array& maps) const {
StorePointer(&raw_ptr()->stackmaps_, maps.raw());
}
+const Code::Comments& Code::comments() const {
+ Comments* comments = new Code::Comments(Array::Handle(raw_ptr()->comments_));
+ return *comments;
+}
+
+
+void Code::set_comments(const Code::Comments& comments) const {
+ StorePointer(&raw_ptr()->comments_, comments.comments_.raw());
+}
+
+
RawCode* Code::New(int pointer_offsets_length) {
const Class& cls = Class::Handle(Object::code_class());
Code& result = Code::Handle();

Powered by Google App Engine
This is Rietveld 408576698