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

Unified Diff: src/unicode.h

Issue 700963002: Replace C++ bitfields with our own BitFields (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: fixed AST node field sizes; more scanner fixes; undid hydrogen.h/cc changes Created 6 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 | « src/scanner.cc ('k') | src/unicode-inl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/unicode.h
diff --git a/src/unicode.h b/src/unicode.h
index 1af6170fcaf4ba72aceb16d8b70733d9a33ddbb9..166681426ff9187ca068ce61cafc6ddcfc2b1ff0 100644
--- a/src/unicode.h
+++ b/src/unicode.h
@@ -7,6 +7,7 @@
#include <sys/types.h>
#include "src/globals.h"
+#include "src/utils.h"
/**
* \file
* Definitions and convenience functions for working with unicode.
@@ -28,16 +29,26 @@ class Predicate {
public:
inline Predicate() { }
inline bool get(uchar c);
+
private:
friend class Test;
bool CalculateValue(uchar c);
- struct CacheEntry {
- inline CacheEntry() : code_point_(0), value_(0) { }
+ class CacheEntry {
+ public:
+ inline CacheEntry()
+ : bit_field_(CodePointField::encode(0) | ValueField::encode(0)) {}
inline CacheEntry(uchar code_point, bool value)
- : code_point_(code_point),
- value_(value) { }
- uchar code_point_ : 21;
- bool value_ : 1;
+ : bit_field_(CodePointField::encode(code_point) |
+ ValueField::encode(value)) {}
+
+ uchar code_point() const { return CodePointField::decode(bit_field_); }
+ bool value() const { return ValueField::decode(bit_field_); }
+
+ private:
+ class CodePointField : public v8::internal::BitField<uchar, 0, 21> {};
+ class ValueField : public v8::internal::BitField<bool, 21, 1> {};
+
+ uint32_t bit_field_;
};
static const int kSize = size;
static const int kMask = kSize - 1;
« no previous file with comments | « src/scanner.cc ('k') | src/unicode-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698