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

Unified Diff: src/hydrogen-instructions.h

Issue 6964011: Refactor HCheckInstanceType to allow mask/tag tests. (Closed)
Patch Set: Created 9 years, 7 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 | « src/hydrogen.cc ('k') | src/hydrogen-instructions.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/hydrogen-instructions.h
diff --git a/src/hydrogen-instructions.h b/src/hydrogen-instructions.h
index 5a502e5cd116e2d54f8510d12f92d17158e021f3..f61c6bf5dfb802caab80f5096cd7543c8bb562f2 100644
--- a/src/hydrogen-instructions.h
+++ b/src/hydrogen-instructions.h
@@ -1757,19 +1757,19 @@ class HCheckFunction: public HUnaryOperation {
class HCheckInstanceType: public HUnaryOperation {
public:
- // Check that the instance type is in the range [first, last] where
- // both first and last are included.
- HCheckInstanceType(HValue* value, InstanceType first, InstanceType last)
- : HUnaryOperation(value), first_(first), last_(last) {
- ASSERT(first <= last);
- set_representation(Representation::Tagged());
- SetFlag(kUseGVN);
- if ((FIRST_STRING_TYPE < first && last <= LAST_STRING_TYPE) ||
- (FIRST_STRING_TYPE <= first && last < LAST_STRING_TYPE)) {
- // A particular string instance type can change because of GC or
- // externalization, but the value still remains a string.
- SetFlag(kDependsOnMaps);
- }
+ static HCheckInstanceType* NewIsJSObjectOrJSFunction(HValue* value);
+ static HCheckInstanceType* NewIsJSArray(HValue* value) {
+ return new HCheckInstanceType(value, JS_ARRAY_TYPE, JS_ARRAY_TYPE, 0, 0);
+ }
+ static HCheckInstanceType* NewIsString(HValue* value) {
+ return new HCheckInstanceType(value,
+ FIRST_TYPE, FIRST_TYPE,
+ kIsNotStringMask, kStringTag);
+ }
+ static HCheckInstanceType* NewIsSymbol(HValue* value) {
+ return new HCheckInstanceType(value,
+ FIRST_TYPE, FIRST_TYPE,
+ kIsSymbolMask, kSymbolTag);
}
virtual bool IsCheckInstruction() const { return true; }
@@ -1785,17 +1785,35 @@ class HCheckInstanceType: public HUnaryOperation {
virtual HValue* Canonicalize() {
if (!value()->type().IsUninitialized() &&
value()->type().IsString() &&
- first() == FIRST_STRING_TYPE &&
- last() == LAST_STRING_TYPE) {
+ !is_range() &&
+ mask() == kIsNotStringMask &&
+ tag() == kStringTag) {
return NULL;
}
return this;
}
- static HCheckInstanceType* NewIsJSObjectOrJSFunction(HValue* value);
+ bool is_range() const { return mask_ == 0; }
+
+ InstanceType first() const {
+ ASSERT(is_range());
+ return first_;
+ }
+
+ InstanceType last() {
+ ASSERT(is_range());
+ return last_;
+ }
+
+ uint8_t mask() const {
+ ASSERT(!is_range());
+ return mask_;
+ }
- InstanceType first() const { return first_; }
- InstanceType last() const { return last_; }
+ uint8_t tag() const {
+ ASSERT(!is_range());
+ return tag_;
+ }
DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType)
@@ -1805,12 +1823,33 @@ class HCheckInstanceType: public HUnaryOperation {
// with a larger range.
virtual bool DataEquals(HValue* other) {
HCheckInstanceType* b = HCheckInstanceType::cast(other);
- return (first_ == b->first()) && (last_ == b->last());
+ return first_ == b->first_ && last_ == b->last_ &&
+ mask_ == b->mask_ && tag_ == b->tag_;
}
private:
+ // Check that the instance type is in the range [first, last] where
Mads Ager (chromium) 2011/05/09 16:57:51 Comment needs updating.
+ // both first and last are included.
+ HCheckInstanceType(HValue* value,
+ InstanceType first, InstanceType last,
+ uint8_t mask, uint8_t tag)
+ : HUnaryOperation(value),
+ first_(first), last_(last),
+ mask_(mask), tag_(tag) {
+ ASSERT(first <= last);
+ set_representation(Representation::Tagged());
+ SetFlag(kUseGVN);
+ if (is_range() && first_ < FIRST_NONSTRING_TYPE) {
+ // A particular string instance type can change because of GC or
+ // externalization, but the value still remains a string.
+ SetFlag(kDependsOnMaps);
+ }
+ }
+
InstanceType first_;
InstanceType last_;
+ uint8_t mask_;
Mads Ager (chromium) 2011/05/09 16:57:51 I don't like this much. Create two types of instru
+ uint8_t tag_;
};
« no previous file with comments | « src/hydrogen.cc ('k') | src/hydrogen-instructions.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698