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

Unified Diff: runtime/vm/raw_object.h

Issue 10796004: Consolidate a few fields in RawFunction using bitfields. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 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
« no previous file with comments | « runtime/vm/parser.cc ('k') | runtime/vm/raw_object_snapshot.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 10086)
+++ runtime/vm/raw_object.h (working copy)
@@ -542,18 +542,85 @@
kRegularFunction,
kClosureFunction,
kSignatureFunction, // represents a signature only without actual code.
- kGetterFunction, // represents getter functions e.g: get foo() { .. }.
- kSetterFunction, // represents setter functions e.g: set foo(..) { .. }.
- kAbstract,
+ kGetterFunction, // represents getter functions e.g: get foo() { .. }.
+ kSetterFunction, // represents setter functions e.g: set foo(..) { .. }.
kConstructor,
- kImplicitGetter, // represents an implicit getter for fields.
- kImplicitSetter, // represents an implicit setter for fields.
+ kImplicitGetter, // represents an implicit getter for fields.
+ kImplicitSetter, // represents an implicit setter for fields.
kConstImplicitGetter, // represents an implicit const getter for fields.
};
private:
RAW_HEAP_OBJECT_IMPLEMENTATION(Function);
+ enum KindTagBits {
+ kStaticBit = 1,
+ kConstBit = 2,
+ kOptimizableBit = 3,
+ kNativeBit = 4,
+ kAbstractBit = 5,
+ kExternalBit = 5,
+ kKindTagBit = 6,
+ kKindTagSize = 4,
+ };
+ class StaticBit : public BitField<bool, kStaticBit, 1> {};
+ class ConstBit : public BitField<bool, kConstBit, 1> {};
+ class OptimizableBit : public BitField<bool, kOptimizableBit, 1> {};
+ class NativeBit : public BitField<bool, kNativeBit, 1> {};
+ class AbstractBit : public BitField<bool, kAbstractBit, 1> {};
+ class ExternalBit : public BitField<bool, kExternalBit, 1> {};
+ class KindBits : public BitField<Kind, kKindTagBit, kKindTagSize> {};
+
+ bool IsStatic() const {
+ return StaticBit::decode(ptr()->kind_tag_);
+ }
+ void SetIsStatic(bool value) {
+ uword bits = ptr()->kind_tag_;
+ ptr()->kind_tag_ = StaticBit::update(value, bits);
+ }
+ bool IsConst() const {
+ return ConstBit::decode(ptr()->kind_tag_);
+ }
+ void SetIsConst(bool value) {
+ uword bits = ptr()->kind_tag_;
+ ptr()->kind_tag_ = ConstBit::update(value, bits);
+ }
+ bool IsOptimizable() const {
+ return OptimizableBit::decode(ptr()->kind_tag_);
+ }
+ void SetIsOptimizable(bool value) {
+ uword bits = ptr()->kind_tag_;
+ ptr()->kind_tag_ = OptimizableBit::update(value, bits);
+ }
+ bool IsNative() const {
+ return NativeBit::decode(ptr()->kind_tag_);
+ }
+ void SetIsNative(bool value) {
+ uword bits = ptr()->kind_tag_;
+ ptr()->kind_tag_ = NativeBit::update(value, bits);
+ }
+ bool IsAbstract() const {
+ return AbstractBit::decode(ptr()->kind_tag_);
+ }
+ void SetIsAbstract(bool value) {
+ uword bits = ptr()->kind_tag_;
+ ptr()->kind_tag_ = AbstractBit::update(value, bits);
+ }
+ bool IsExternal() const {
+ return ExternalBit::decode(ptr()->kind_tag_);
+ }
+ void SetIsExternal(bool value) {
+ uword bits = ptr()->kind_tag_;
+ ptr()->kind_tag_ = ExternalBit::update(value, bits);
+ }
+ Kind GetKind() const {
+ return KindBits::decode(ptr()->kind_tag_);
+ }
+ void SetKind(Kind value) {
+ uword bits = ptr()->kind_tag_;
+ ptr()->kind_tag_ = KindBits::update(value, bits);
+ }
+
RawObject** from() { return reinterpret_cast<RawObject**>(&ptr()->name_); }
RawString* name_;
RawClass* owner_;
@@ -577,12 +644,7 @@
intptr_t num_optional_parameters_;
intptr_t usage_counter_; // Incremented while function is running.
intptr_t deoptimization_counter_;
- Kind kind_;
- bool is_static_;
- bool is_const_;
- bool is_optimizable_;
- bool is_native_;
- bool is_external_;
+ intptr_t kind_tag_;
};
« no previous file with comments | « runtime/vm/parser.cc ('k') | runtime/vm/raw_object_snapshot.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698