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

Unified Diff: runtime/vm/raw_object.h

Issue 333773006: Removes open arrays (e.g. data[0]) from raw objects. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 6 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
« no previous file with comments | « runtime/vm/object.cc ('k') | runtime/vm/raw_object.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/raw_object.h
===================================================================
--- runtime/vm/raw_object.h (revision 37367)
+++ runtime/vm/raw_object.h (working copy)
@@ -558,9 +558,13 @@
RawSmi* length_;
// Variable length data follows here.
- RawAbstractType* types_[0];
+ RawAbstractType** types() {
+ const uword address_of_length = reinterpret_cast<uword>(&length_);
+ return reinterpret_cast<RawAbstractType**>(
+ address_of_length + sizeof(length_));
+ }
RawObject** to(intptr_t length) {
- return reinterpret_cast<RawObject**>(&ptr()->types_[length - 1]);
+ return reinterpret_cast<RawObject**>(&ptr()->types()[length - 1]);
}
friend class SnapshotReader;
@@ -853,10 +857,12 @@
intptr_t patch_code_pc_offset_;
intptr_t lazy_deopt_pc_offset_;
- intptr_t dummy_alignment_;
-
// Variable length data follows here.
- int32_t data_[0];
+ int32_t* data() {
+ uword address_of_lazy = reinterpret_cast<uword>(&lazy_deopt_pc_offset_);
Ivan Posva 2014/06/16 23:02:13 As discussed this pattern looks a bit fragile from
zra 2014/06/17 17:24:08 Changed to: const uword result = reinterpret_cast
+ return reinterpret_cast<int32_t*>(
+ address_of_lazy + sizeof(lazy_deopt_pc_offset_));
+ }
friend class StackFrame;
friend class MarkingVisitor;
@@ -878,7 +884,10 @@
intptr_t size_;
// Variable length data follows here.
- uint8_t data_[0];
+ uint8_t* data() {
+ const uword address_of_size = reinterpret_cast<uword>(&size_);
+ return reinterpret_cast<uint8_t*>(address_of_size + sizeof(size_));
+ }
// Private helper function used while visiting stack frames. The
// code which iterates over dart frames is also called during GC and
@@ -899,7 +908,10 @@
intptr_t length_; // Number of descriptors.
// Variable length data follows here.
- intptr_t data_[0];
+ intptr_t* data() {
+ const uword address_of_length = reinterpret_cast<uword>(&length_);
+ return reinterpret_cast<intptr_t*>(address_of_length + sizeof(length_));
+ }
friend class Object;
};
@@ -923,7 +935,10 @@
uword pc_; // PC corresponding to this stack map representation.
// Variable length data follows here (bitmap of the stack layout).
- uint8_t data_[0];
+ uint8_t* data() {
+ const uword address_of_pc = reinterpret_cast<uword>(&pc_);
+ return reinterpret_cast<uint8_t*>(address_of_pc + sizeof(pc_));
+ }
};
@@ -950,7 +965,11 @@
intptr_t length_; // Number of descriptors.
RawArray* names_; // Array of [length_] variable names.
- VarInfo data_[0]; // Variable info with [length_] entries.
+ // Variable info with [length_] entries.
+ VarInfo* data() {
+ const uword address_of_names = reinterpret_cast<uword>(&names_);
+ return reinterpret_cast<VarInfo*>(address_of_names + sizeof(names_));
+ }
};
@@ -964,6 +983,7 @@
int8_t needs_stacktrace; // True if a stacktrace is needed.
int8_t has_catch_all; // Catches all exceptions.
};
+
private:
RAW_HEAP_OBJECT_IMPLEMENTATION(ExceptionHandlers);
@@ -975,7 +995,11 @@
RawArray* handled_types_data_;
// Exception handler info of length [length_].
- HandlerInfo data_[0];
+ HandlerInfo* data() {
+ const uword address_of_htd = reinterpret_cast<uword>(&handled_types_data_);
+ return reinterpret_cast<HandlerInfo*>(
+ address_of_htd + sizeof(handled_types_data_));
+ }
};
@@ -987,7 +1011,10 @@
RawSmi* length_; // Number of deoptimization commands
// Variable length data follows here.
- intptr_t data_[0];
+ intptr_t* data() {
+ const uword address_of_length = reinterpret_cast<uword>(&length_);
+ return reinterpret_cast<intptr_t*>(address_of_length + sizeof(length_));
+ }
};
@@ -1001,9 +1028,13 @@
RawContext* parent_;
// Variable length data follows here.
- RawInstance* data_[0];
+ RawInstance** data() {
+ const uword address_of_parent = reinterpret_cast<uword>(&parent_);
+ return reinterpret_cast<RawInstance**>(
+ address_of_parent + sizeof(parent_));
+ }
RawObject** to(intptr_t num_vars) {
- return reinterpret_cast<RawObject**>(&ptr()->data_[num_vars - 1]);
+ return reinterpret_cast<RawObject**>(&ptr()->data()[num_vars - 1]);
}
friend class SnapshotReader;
@@ -1031,11 +1062,17 @@
intptr_t num_variables_;
// Variable length data follows here.
- RawObject** from() { return reinterpret_cast<RawObject**>(&ptr()->data_[0]); }
- RawObject* data_[0];
+ RawObject** from() {
+ return reinterpret_cast<RawObject**>(&ptr()->data()[0]);
+ }
+ RawObject** data() {
+ const uword address_of_nv = reinterpret_cast<uword>(&num_variables_);
+ return reinterpret_cast<RawObject**>(
+ address_of_nv + sizeof(num_variables_));
+ }
RawObject** to(intptr_t num_vars) {
- intptr_t data_length = num_vars * (sizeof(VariableDesc)/kWordSize);
- return reinterpret_cast<RawObject**>(&ptr()->data_[data_length - 1]);
+ const intptr_t data_length = num_vars * (sizeof(VariableDesc)/kWordSize);
+ return reinterpret_cast<RawObject**>(&ptr()->data()[data_length - 1]);
}
};
@@ -1304,7 +1341,11 @@
// A sequence of Chunks (typedef in Bignum) representing bignum digits.
// Bignum::Chunk chunks_[Utils::Abs(signed_length_)];
- uint8_t data_[0];
+ uint8_t* data() {
+ const uword address_of_length = reinterpret_cast<uword>(&signed_length_);
+ return reinterpret_cast<uint8_t*>(
+ address_of_length + sizeof(signed_length_));
+ }
friend class SnapshotReader;
};
@@ -1335,7 +1376,10 @@
RAW_HEAP_OBJECT_IMPLEMENTATION(OneByteString);
// Variable length data follows here.
- uint8_t data_[0];
+ uint8_t* data() {
+ const uword address_of_hash = reinterpret_cast<uword>(&hash_);
+ return reinterpret_cast<uint8_t*>(address_of_hash + sizeof(hash_));
+ }
friend class ApiMessageReader;
friend class SnapshotReader;
@@ -1346,7 +1390,10 @@
RAW_HEAP_OBJECT_IMPLEMENTATION(TwoByteString);
// Variable length data follows here.
- uint16_t data_[0];
+ uint16_t* data() {
+ const uword address_of_hash = reinterpret_cast<uword>(&hash_);
+ return reinterpret_cast<uint16_t*>(address_of_hash + sizeof(hash_));
+ }
friend class SnapshotReader;
};
@@ -1410,7 +1457,7 @@
// Variable length data follows here.
RawObject** data() {
uword address_of_length = reinterpret_cast<uword>(&length_);
- return reinterpret_cast<RawObject**>(address_of_length + kWordSize);
+ return reinterpret_cast<RawObject**>(address_of_length + sizeof(length_));
}
RawObject** to(intptr_t length) {
return reinterpret_cast<RawObject**>(&ptr()->data()[length - 1]);
@@ -1508,11 +1555,13 @@
protected:
RawObject** from() { return reinterpret_cast<RawObject**>(&ptr()->length_); }
RawSmi* length_;
+ // Variable length data follows here.
+ uint8_t* data() {
+ uword address_of_length = reinterpret_cast<uword>(&length_);
+ return reinterpret_cast<uint8_t*>(address_of_length + sizeof(length_));
+ }
RawObject** to() { return reinterpret_cast<RawObject**>(&ptr()->length_); }
- // Variable length data follows here.
- uint8_t data_[0];
-
friend class Api;
friend class Object;
friend class Instance;
@@ -1602,7 +1651,10 @@
intptr_t flags_; // Represents global/local, case insensitive, multiline.
// Variable length data follows here.
- uint8_t data_[0];
+ uint8_t* data() {
+ const uword address_of_flags = reinterpret_cast<uword>(&flags_);
+ return reinterpret_cast<uint8_t*>(address_of_flags + sizeof(flags_));
+ }
};
« no previous file with comments | « runtime/vm/object.cc ('k') | runtime/vm/raw_object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698