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

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 37317)
+++ runtime/vm/raw_object.h (working copy)
@@ -558,9 +558,12 @@
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 + kWordSize);
Florian Schneider 2014/06/16 08:27:26 Can't you just use sizeof(RawTypeArguments::length
zra 2014/06/16 14:22:52 Not sure what you mean.
Florian Schneider 2014/06/16 14:46:24 return reinterpret_cast<RawAbstractType**>(address
zra 2014/06/16 17:00:15 Yah, that makes sense. Done here and elsewhere.
+ }
RawObject** to(intptr_t length) {
- return reinterpret_cast<RawObject**>(&ptr()->types_[length - 1]);
+ return reinterpret_cast<RawObject**>(&ptr()->types()[length - 1]);
}
friend class SnapshotReader;
@@ -852,10 +855,11 @@
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_);
+ return reinterpret_cast<int32_t*>(address_of_lazy + kWordSize);
+ }
friend class StackFrame;
friend class MarkingVisitor;
@@ -877,7 +881,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 + kWordSize);
+ }
// Private helper function used while visiting stack frames. The
// code which iterates over dart frames is also called during GC and
@@ -898,7 +905,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 + kWordSize);
+ }
friend class Object;
};
@@ -922,7 +932,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 + kWordSize);
+ }
};
@@ -949,7 +962,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 + kWordSize);
+ }
};
@@ -963,6 +980,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);
@@ -974,7 +992,10 @@
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 + kWordSize);
+ }
};
@@ -986,7 +1007,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 + kWordSize);
+ }
};
@@ -1000,9 +1024,12 @@
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 + kWordSize);
+ }
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;
@@ -1030,11 +1057,16 @@
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 + kWordSize);
+ }
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]);
}
};
@@ -1302,7 +1334,10 @@
// 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 + kWordSize);
+ }
friend class SnapshotReader;
};
@@ -1333,7 +1368,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 + kWordSize);
+ }
friend class ApiMessageReader;
friend class SnapshotReader;
@@ -1344,7 +1382,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 + kWordSize);
+ }
friend class SnapshotReader;
};
@@ -1506,11 +1547,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 + kWordSize);
+ }
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;
@@ -1600,7 +1643,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 + kWordSize);
+ }
};
« 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