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

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
Index: runtime/vm/raw_object.h
===================================================================
--- runtime/vm/raw_object.h (revision 9727)
+++ runtime/vm/raw_object.h (working copy)
@@ -542,18 +542,76 @@
kFunction,
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,
+ 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 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);
+ }
+ 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,11 +635,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_;
+ intptr_t kind_tag_;
};

Powered by Google App Engine
This is Rietveld 408576698