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

Unified Diff: runtime/vm/object.h

Issue 56033002: Compute next field offset correctly. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 1 month 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/freelist.h ('k') | runtime/vm/object.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/object.h
===================================================================
--- runtime/vm/object.h (revision 29769)
+++ runtime/vm/object.h (working copy)
@@ -528,6 +528,11 @@
RawObject* raw_; // The raw object reference.
private:
+ static intptr_t NextFieldOffset() {
+ // Indicates this class cannot be extended by dart code.
+ return -1;
Ivan Posva 2013/11/02 00:25:55 How about -kWordSize and then the scaling becomes
siva 2013/11/02 03:45:00 Done.
+ }
+
static void InitializeObject(uword address, intptr_t id, intptr_t size);
static void RegisterClass(const Class& cls,
@@ -648,14 +653,22 @@
}
intptr_t next_field_offset() const {
+ if (raw_ptr()->next_field_offset_in_words_ == -1) {
Ivan Posva 2013/11/02 00:25:55 I think we can remove this test and just return a
siva 2013/11/02 03:45:00 Done.
+ return -1;
+ }
return raw_ptr()->next_field_offset_in_words_ * kWordSize;
}
void set_next_field_offset(intptr_t value_in_bytes) const {
- ASSERT(kWordSize != 0);
- set_next_field_offset_in_words(value_in_bytes / kWordSize);
+ if (value_in_bytes == -1) {
Ivan Posva 2013/11/02 00:25:55 I would think this test can go too.
siva 2013/11/02 03:45:00 Done.
+ set_next_field_offset_in_words(-1);
+ } else {
+ ASSERT(kWordSize != 0);
+ set_next_field_offset_in_words(value_in_bytes / kWordSize);
+ }
}
void set_next_field_offset_in_words(intptr_t value) const {
- ASSERT((Utils::IsAligned((value * kWordSize), kObjectAlignment) &&
+ ASSERT((value == -1) ||
+ (Utils::IsAligned((value * kWordSize), kObjectAlignment) &&
(value == raw_ptr()->instance_size_in_words_)) ||
(!Utils::IsAligned((value * kWordSize), kObjectAlignment) &&
((value + 1) == raw_ptr()->instance_size_in_words_)));
@@ -1083,6 +1096,11 @@
RawFunction* CreateInvocationDispatcher(const String& target_name,
const Array& args_desc,
RawFunction::Kind kind) const;
+
+ static intptr_t NextFieldOffset() {
+ // Indicates this class cannot be extended by dart code.
+ return -1;
+ }
void CalculateFieldOffsets() const;
// Initial value for the cached number of type arguments.
@@ -1144,6 +1162,7 @@
static intptr_t InstanceSize() {
return RoundedAllocationSize(sizeof(RawUnresolvedClass));
}
+
static RawUnresolvedClass* New(const LibraryPrefix& library_prefix,
const String& ident,
intptr_t token_pos);
@@ -1153,6 +1172,10 @@
void set_ident(const String& ident) const;
void set_token_pos(intptr_t token_pos) const;
+ static intptr_t NextFieldOffset() {
+ // Indicates this class cannot be extended by dart code.
+ return -1;
+ }
Ivan Posva 2013/11/02 00:25:55 Empty line here and other places.
siva 2013/11/02 03:45:00 Done.
static RawUnresolvedClass* New();
FINAL_HEAP_OBJECT_IMPLEMENTATION(UnresolvedClass, Object);
@@ -1322,6 +1345,11 @@
RawAbstractType** TypeAddr(intptr_t index) const;
void SetLength(intptr_t value) const;
+ static intptr_t NextFieldOffset() {
+ // Indicates this class cannot be extended by dart code.
+ return -1;
+ }
+
FINAL_HEAP_OBJECT_IMPLEMENTATION(TypeArguments, AbstractTypeArguments);
friend class Class;
};
@@ -1384,6 +1412,11 @@
const AbstractTypeArguments& value) const;
void set_instantiator_type_arguments(
const AbstractTypeArguments& value) const;
+
+ static intptr_t NextFieldOffset() {
+ // Indicates this class cannot be extended by dart code.
+ return -1;
+ }
static RawInstantiatedTypeArguments* New();
FINAL_HEAP_OBJECT_IMPLEMENTATION(InstantiatedTypeArguments,
@@ -1408,6 +1441,11 @@
private:
void set_patched_class(const Class& value) const;
void set_source_class(const Class& value) const;
+
+ static intptr_t NextFieldOffset() {
+ // Indicates this class cannot be extended by dart code.
+ return -1;
+ }
static RawPatchClass* New();
FINAL_HEAP_OBJECT_IMPLEMENTATION(PatchClass, Object);
@@ -1856,7 +1894,6 @@
return kind() == RawFunction::kSignatureFunction;
}
-
static intptr_t InstanceSize() {
return RoundedAllocationSize(sizeof(RawFunction));
}
@@ -1946,6 +1983,11 @@
void set_num_optional_parameters(intptr_t value) const; // Encoded value.
void set_kind_tag(intptr_t value) const;
void set_data(const Object& value) const;
+
+ static intptr_t NextFieldOffset() {
+ // Indicates this class cannot be extended by dart code.
+ return -1;
+ }
static RawFunction* New();
void BuildSignatureParameters(bool instantiate,
@@ -2007,6 +2049,10 @@
}
void set_closure_allocation_stub(const Code& value) const;
+ static intptr_t NextFieldOffset() {
+ // Indicates this class cannot be extended by dart code.
+ return -1;
+ }
static RawClosureData* New();
FINAL_HEAP_OBJECT_IMPLEMENTATION(ClosureData, Object);
@@ -2035,6 +2081,10 @@
RawFunction* target() const { return raw_ptr()->target_; }
void set_target(const Function& value) const;
+ static intptr_t NextFieldOffset() {
+ // Indicates this class cannot be extended by dart code.
+ return -1;
+ }
static RawRedirectionData* New();
FINAL_HEAP_OBJECT_IMPLEMENTATION(RedirectionData, Object);
@@ -2212,6 +2262,11 @@
void set_kind_bits(intptr_t value) const {
raw_ptr()->kind_bits_ = static_cast<uint8_t>(value);
}
+
+ static intptr_t NextFieldOffset() {
+ // Indicates this class cannot be extended by dart code.
+ return -1;
+ }
static RawField* New();
FINAL_HEAP_OBJECT_IMPLEMENTATION(Field, Object);
@@ -2238,6 +2293,11 @@
void set_literal(const String& literal) const;
void set_value(const Object& value) const;
+ static intptr_t NextFieldOffset() {
+ // Indicates this class cannot be extended by dart code.
+ return -1;
+ }
+
FINAL_HEAP_OBJECT_IMPLEMENTATION(LiteralToken, Object);
friend class Class;
};
@@ -2321,6 +2381,10 @@
private:
void SetPrivateKey(const String& value) const;
+ static intptr_t NextFieldOffset() {
+ // Indicates this class cannot be extended by dart code.
+ return -1;
+ }
static RawTokenStream* New();
static void DataFinalizer(Dart_WeakPersistentHandle handle, void *peer);
@@ -2378,6 +2442,11 @@
void set_source(const String& value) const;
void set_kind(RawScript::Kind value) const;
void set_tokens(const TokenStream& value) const;
+
+ static intptr_t NextFieldOffset() {
+ // Indicates this class cannot be extended by dart code.
+ return -1;
+ }
static RawScript* New();
FINAL_HEAP_OBJECT_IMPLEMENTATION(Script, Object);
@@ -2592,6 +2661,11 @@
private:
static const int kInitialImportsCapacity = 4;
static const int kImportsCapacityIncrement = 8;
+
+ static intptr_t NextFieldOffset() {
+ // Indicates this class cannot be extended by dart code.
+ return -1;
+ }
static RawLibrary* New();
void set_num_imports(intptr_t value) const {
@@ -2654,6 +2728,11 @@
void set_name(const String& value) const;
void set_imports(const Array& value) const;
void set_num_imports(intptr_t value) const;
+
+ static intptr_t NextFieldOffset() {
+ // Indicates this class cannot be extended by dart code.
+ return -1;
+ }
static RawLibraryPrefix* New();
FINAL_HEAP_OBJECT_IMPLEMENTATION(LibraryPrefix, Object);
@@ -2679,7 +2758,12 @@
static RawNamespace* New(const Library& library,
const Array& show_names,
const Array& hide_names);
+
private:
+ static intptr_t NextFieldOffset() {
+ // Indicates this class cannot be extended by dart code.
+ return -1;
+ }
static RawNamespace* New();
FINAL_HEAP_OBJECT_IMPLEMENTATION(Namespace, Object);
@@ -2742,6 +2826,10 @@
StorePointer(&raw_ptr()->object_pool_, object_pool);
}
+ static intptr_t NextFieldOffset() {
+ // Indicates this class cannot be extended by dart code.
+ return -1;
+ }
// New is a private method as RawInstruction and RawCode objects should
// only be created using the Code::FinalizeCode method. This method creates
// the RawInstruction and RawCode objects, sets up the pointer offsets
@@ -2784,6 +2872,10 @@
static RawLocalVarDescriptors* New(intptr_t num_variables);
private:
+ static intptr_t NextFieldOffset() {
+ // Indicates this class cannot be extended by dart code.
+ return -1;
+ }
FINAL_HEAP_OBJECT_IMPLEMENTATION(LocalVarDescriptors, Object);
friend class Class;
};
@@ -2885,6 +2977,11 @@
return reinterpret_cast<RawSmi**>(EntryAddr(index, entry_offset));
}
+ static intptr_t NextFieldOffset() {
+ // Indicates this class cannot be extended by dart code.
+ return -1;
+ }
+
FINAL_HEAP_OBJECT_IMPLEMENTATION(PcDescriptors, Object);
friend class Class;
};
@@ -2938,6 +3035,11 @@
bool GetBit(intptr_t bit_index) const;
void SetBit(intptr_t bit_index, bool value) const;
+ static intptr_t NextFieldOffset() {
+ // Indicates this class cannot be extended by dart code.
+ return -1;
+ }
+
FINAL_HEAP_OBJECT_IMPLEMENTATION(Stackmap, Object);
friend class BitmapBuilder;
friend class Class;
@@ -2988,6 +3090,12 @@
static const intptr_t kMaxHandlers = 1024 * 1024;
void set_handled_types_data(const Array& value) const;
+
+ static intptr_t NextFieldOffset() {
+ // Indicates this class cannot be extended by dart code.
+ return -1;
+ }
+
FINAL_HEAP_OBJECT_IMPLEMENTATION(ExceptionHandlers, Object);
friend class Class;
};
@@ -3073,6 +3181,11 @@
void SetLength(intptr_t value) const;
+ static intptr_t NextFieldOffset() {
+ // Indicates this class cannot be extended by dart code.
+ return -1;
+ }
+
FINAL_HEAP_OBJECT_IMPLEMENTATION(DeoptInfo, Object);
friend class Class;
};
@@ -3319,6 +3432,11 @@
intptr_t BinarySearchInSCallTable(uword pc) const;
+ static intptr_t NextFieldOffset() {
+ // Indicates this class cannot be extended by dart code.
+ return -1;
+ }
+
// New is a private method as RawInstruction and RawCode objects should
// only be created using the Code::FinalizeCode method. This method creates
// the RawInstruction and RawCode objects, sets up the pointer offsets
@@ -3386,6 +3504,11 @@
raw_ptr()->num_variables_ = num_variables;
}
+ static intptr_t NextFieldOffset() {
+ // Indicates this class cannot be extended by dart code.
+ return -1;
+ }
+
FINAL_HEAP_OBJECT_IMPLEMENTATION(Context, Object);
friend class Class;
};
@@ -3458,6 +3581,11 @@
return reinterpret_cast<RawContextScope::VariableDesc*>(raw_addr);
}
+ static intptr_t NextFieldOffset() {
+ // Indicates this class cannot be extended by dart code.
+ return -1;
+ }
+
FINAL_HEAP_OBJECT_IMPLEMENTATION(ContextScope, Object);
friend class Class;
};
@@ -3615,6 +3743,11 @@
intptr_t TestEntryLength() const;
void WriteSentinel(const Array& data) const;
+ static intptr_t NextFieldOffset() {
+ // Indicates this class cannot be extended by dart code.
+ return -1;
+ }
+
FINAL_HEAP_OBJECT_IMPLEMENTATION(ICData, Object);
friend class Class;
};
@@ -3669,6 +3802,11 @@
static inline RawObject* GetTargetFunction(const Array& array,
intptr_t index);
+ static intptr_t NextFieldOffset() {
+ // Indicates this class cannot be extended by dart code.
+ return -1;
+ }
+
FINAL_HEAP_OBJECT_IMPLEMENTATION(MegamorphicCache, Object);
};
@@ -3713,6 +3851,11 @@
intptr_t TestEntryLength() const;
+ static intptr_t NextFieldOffset() {
+ // Indicates this class cannot be extended by dart code.
+ return -1;
+ }
+
FINAL_HEAP_OBJECT_IMPLEMENTATION(SubtypeTestCache, Object);
friend class Class;
};
@@ -3745,6 +3888,11 @@
private:
void set_message(const String& message) const;
+
+ static intptr_t NextFieldOffset() {
+ // Indicates this class cannot be extended by dart code.
+ return -1;
+ }
static RawApiError* New();
FINAL_HEAP_OBJECT_IMPLEMENTATION(ApiError, Error);
@@ -3770,6 +3918,11 @@
private:
void set_message(const String& message) const;
+
+ static intptr_t NextFieldOffset() {
+ // Indicates this class cannot be extended by dart code.
+ return -1;
+ }
static RawLanguageError* New();
FINAL_HEAP_OBJECT_IMPLEMENTATION(LanguageError, Error);
@@ -3803,6 +3956,11 @@
void set_exception(const Instance& exception) const;
void set_stacktrace(const Instance& stacktrace) const;
+ static intptr_t NextFieldOffset() {
+ // Indicates this class cannot be extended by dart code.
+ return -1;
+ }
+
FINAL_HEAP_OBJECT_IMPLEMENTATION(UnhandledException, Error);
friend class Class;
};
@@ -3827,6 +3985,11 @@
private:
void set_message(const String& message) const;
+ static intptr_t NextFieldOffset() {
+ // Indicates this class cannot be extended by dart code.
+ return -1;
+ }
+
FINAL_HEAP_OBJECT_IMPLEMENTATION(UnwindError, Error);
friend class Class;
};
@@ -3913,10 +4076,16 @@
}
bool IsValidFieldOffset(int offset) const;
+ static intptr_t NextFieldOffset() {
+ return sizeof(RawInstance);
+ }
+
// TODO(iposva): Determine if this gets in the way of Smi.
HEAP_OBJECT_IMPLEMENTATION(Instance, Object);
friend class Class;
friend class Closure;
+ friend class SnapshotWriter;
+ friend class StubCode;
friend class TypedDataView;
};
@@ -4156,6 +4325,10 @@
void set_token_pos(intptr_t token_pos) const;
void set_type_state(int8_t state) const;
+ static intptr_t NextFieldOffset() {
+ // Indicates this class cannot be extended by dart code.
+ return -1;
+ }
Ivan Posva 2013/11/02 00:25:55 Doesn't this correspond to the Dart class Type, wh
siva 2013/11/02 03:45:00 Done.
static RawType* New(Heap::Space space = Heap::kOld);
FINAL_HEAP_OBJECT_IMPLEMENTATION(Type, AbstractType);
@@ -4225,6 +4398,11 @@
void set_name(const String& value) const;
void set_token_pos(intptr_t token_pos) const;
void set_type_state(int8_t state) const;
+
+ static intptr_t NextFieldOffset() {
+ // Indicates this class cannot be extended by dart code.
+ return -1;
+ }
static RawTypeParameter* New();
FINAL_HEAP_OBJECT_IMPLEMENTATION(TypeParameter, AbstractType);
@@ -4301,6 +4479,10 @@
}
void set_is_being_checked(bool value) const;
+ static intptr_t NextFieldOffset() {
+ // Indicates this class cannot be extended by dart code.
+ return -1;
+ }
static RawBoundedType* New();
FINAL_HEAP_OBJECT_IMPLEMENTATION(BoundedType, AbstractType);
@@ -4352,6 +4534,10 @@
RawArray* mixin_types() const { return raw_ptr()->mixin_types_; }
void set_mixin_types(const Array& value) const;
+ static intptr_t NextFieldOffset() {
+ // Indicates this class cannot be extended by dart code.
+ return -1;
+ }
static RawMixinAppType* New();
FINAL_HEAP_OBJECT_IMPLEMENTATION(MixinAppType, AbstractType);
@@ -4478,6 +4664,10 @@
}
private:
+ static intptr_t NextFieldOffset() {
+ // Indicates this class cannot be extended by dart code.
+ return -1;
+ }
static intptr_t ValueFromRaw(uword raw_value) {
intptr_t value = raw_value;
ASSERT((value & kSmiTagMask) == kSmiTag);
@@ -4536,6 +4726,11 @@
private:
void set_value(int64_t value) const;
+ static intptr_t NextFieldOffset() {
+ // Indicates this class cannot be extended by dart code.
+ return -1;
+ }
+
FINAL_HEAP_OBJECT_IMPLEMENTATION(Mint, Integer);
friend class Class;
};
@@ -4619,6 +4814,10 @@
return &(reinterpret_cast<Chunk*>(digits_start)[index]);
}
+ static intptr_t NextFieldOffset() {
+ // Indicates this class cannot be extended by dart code.
+ return -1;
+ }
static RawBigint* Allocate(intptr_t length, Heap::Space space = Heap::kNew);
FINAL_HEAP_OBJECT_IMPLEMENTATION(Bigint, Integer);
@@ -4659,6 +4858,11 @@
private:
void set_value(double value) const;
+ static intptr_t NextFieldOffset() {
+ // Indicates this class cannot be extended by dart code.
+ return -1;
+ }
+
FINAL_HEAP_OBJECT_IMPLEMENTATION(Double, Number);
friend class Class;
};
@@ -5041,6 +5245,11 @@
intptr_t tags,
Snapshot::Kind kind);
+ static intptr_t NextFieldOffset() {
+ // Indicates this class cannot be extended by dart code.
+ return -1;
+ }
+
friend class Class;
friend class String;
friend class ExternalOneByteString;
@@ -5133,6 +5342,11 @@
intptr_t tags,
Snapshot::Kind kind);
+ static intptr_t NextFieldOffset() {
+ // Indicates this class cannot be extended by dart code.
+ return -1;
+ }
+
friend class Class;
friend class String;
friend class SnapshotReader;
@@ -5201,6 +5415,11 @@
intptr_t tags,
Snapshot::Kind kind);
+ static intptr_t NextFieldOffset() {
+ // Indicates this class cannot be extended by dart code.
+ return -1;
+ }
+
friend class Class;
friend class String;
friend class SnapshotReader;
@@ -5267,6 +5486,11 @@
intptr_t tags,
Snapshot::Kind kind);
+ static intptr_t NextFieldOffset() {
+ // Indicates this class cannot be extended by dart code.
+ return -1;
+ }
+
friend class Class;
friend class String;
friend class SnapshotReader;
@@ -5299,6 +5523,10 @@
private:
void set_value(bool value) const { raw_ptr()->value_ = value; }
+ static intptr_t NextFieldOffset() {
+ // Indicates this class cannot be extended by dart code.
+ return -1;
+ }
// New should only be called to initialize the two legal bool values.
static RawBool* New(bool value);
@@ -5408,6 +5636,11 @@
raw_ptr()->length_ = Smi::New(value);
}
+ static intptr_t NextFieldOffset() {
+ // Indicates this class cannot be extended by dart code.
+ return -1;
+ }
+
FINAL_HEAP_OBJECT_IMPLEMENTATION(Array, Instance);
friend class Class;
friend class ImmutableArray;
@@ -5436,6 +5669,10 @@
}
private:
+ static intptr_t NextFieldOffset() {
+ // Indicates this class cannot be extended by dart code.
+ return -1;
+ }
static RawImmutableArray* raw(const Array& array) {
return reinterpret_cast<RawImmutableArray*>(array.raw());
}
@@ -5552,6 +5789,10 @@
}
}
+ static intptr_t NextFieldOffset() {
+ return sizeof(RawGrowableObjectArray);
+ }
+
static const int kDefaultInitialCapacity = 4;
FINAL_HEAP_OBJECT_IMPLEMENTATION(GrowableObjectArray, Instance);
@@ -5589,6 +5830,10 @@
}
private:
+ static intptr_t NextFieldOffset() {
+ // Indicates this class cannot be extended by dart code.
+ return -1;
+ }
FINAL_HEAP_OBJECT_IMPLEMENTATION(Float32x4, Instance);
friend class Class;
};
@@ -5623,6 +5868,10 @@
}
private:
+ static intptr_t NextFieldOffset() {
+ // Indicates this class cannot be extended by dart code.
+ return -1;
+ }
FINAL_HEAP_OBJECT_IMPLEMENTATION(Uint32x4, Instance);
friend class Class;
};
@@ -5750,6 +5999,10 @@
}
private:
+ static intptr_t NextFieldOffset() {
+ // Indicates this class cannot be extended by dart code.
+ return -1;
+ }
static const intptr_t element_size[];
FINAL_HEAP_OBJECT_IMPLEMENTATION(TypedData, Instance);
@@ -5869,6 +6122,11 @@
}
private:
+ static intptr_t NextFieldOffset() {
+ // Indicates this class cannot be extended by dart code.
+ return -1;
+ }
+
FINAL_HEAP_OBJECT_IMPLEMENTATION(ExternalTypedData, Instance);
friend class Class;
};
@@ -5907,7 +6165,7 @@
}
static intptr_t NumberOfFields() {
- return (kLengthOffset - kTypeArguments);
+ return kLengthOffset;
}
static intptr_t data_offset() {
@@ -5931,10 +6189,9 @@
private:
enum {
- kTypeArguments = 1,
- kDataOffset = 2,
- kOffsetInBytesOffset = 3,
- kLengthOffset = 4,
+ kDataOffset = 1,
+ kOffsetInBytesOffset = 2,
+ kLengthOffset = 3,
};
};
@@ -6007,6 +6264,10 @@
const Context& value) {
closure.StorePointer(ContextAddr(closure), value.raw());
}
+ static intptr_t NextFieldOffset() {
+ // Indicates this class cannot be extended by dart code.
+ return -1;
+ }
friend class Class;
};
@@ -6049,6 +6310,11 @@
void set_catch_pc_offset_array(const Array& pc_offset_array) const;
bool expand_inlined() const;
+ static intptr_t NextFieldOffset() {
+ // Indicates this class cannot be extended by dart code.
+ return -1;
+ }
+
FINAL_HEAP_OBJECT_IMPLEMENTATION(Stacktrace, Instance);
friend class Class;
};
@@ -6129,6 +6395,11 @@
raw_ptr()->data_length_ = Smi::New(value);
}
+ static intptr_t NextFieldOffset() {
+ // Indicates this class cannot be extended by dart code.
+ return -1;
+ }
+
FINAL_HEAP_OBJECT_IMPLEMENTATION(JSRegExp, Instance);
friend class Class;
};
@@ -6164,6 +6435,10 @@
}
private:
+ static intptr_t NextFieldOffset() {
+ return sizeof(RawWeakProperty);
+ }
+
FINAL_HEAP_OBJECT_IMPLEMENTATION(WeakProperty, Instance);
friend class Class;
};
@@ -6199,6 +6474,11 @@
}
private:
+ static intptr_t NextFieldOffset() {
+ // Indicates this class cannot be extended by dart code.
+ return -1;
+ }
+
FINAL_HEAP_OBJECT_IMPLEMENTATION(MirrorReference, Instance);
friend class Class;
};
« no previous file with comments | « runtime/vm/freelist.h ('k') | runtime/vm/object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698