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

Unified Diff: src/ast.h

Issue 668256: Add AST analysis that flags expressions that will have ToInt32 applied to the... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 10 years, 9 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 | « no previous file | src/flag-definitions.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ast.h
===================================================================
--- src/ast.h (revision 4055)
+++ src/ast.h (working copy)
@@ -237,27 +237,19 @@
// side-effect free compiler.
bool side_effect_free() { return SideEffectFreeField::decode(bitfields_); }
void set_side_effect_free(bool is_side_effect_free) {
- bitfields_ = (bitfields_ & ~SideEffectFreeField::mask()) |
- SideEffectFreeField::encode(is_side_effect_free);
+ bitfields_ &= ~SideEffectFreeField::mask();
+ bitfields_ |= SideEffectFreeField::encode(is_side_effect_free);
}
- // The number of unary and binary operations contained in the expression
- // rooted at this node. Valid only if side_effect_free() is true.
- int expression_size() { return ExpressionSizeField::decode(bitfields_); }
- void set_expression_size(int expression_size) {
- bitfields_ = (bitfields_ & ~ExpressionSizeField::mask()) |
- ExpressionSizeField::encode(Min(expression_size, ExpressionSizeMax));
+ // Will ToInt32 ECMA 262-3 9.5) or ToUunt32 (ECMA 262-3 9.6)
+ // be applied to the value of this expression?
+ // If so, we may be able to optimize the calculation of the value.
+ bool to_int32() { return ToInt32Field::decode(bitfields_); }
+ void set_to_int32(bool to_int32) {
+ bitfields_ &= ~ToInt32Field::mask();
+ bitfields_ |= ToInt32Field::encode(to_int32);
}
- // The number of expression stack slots needed to compute the expression
- // rooted at this node. Does not count the slot needed by the value
- // computed by this expression. Valid only if side_effect_free() is true.
- int stack_height() { return StackHeightField::decode(bitfields_); }
- void set_stack_height(int stack_height) {
- bitfields_ &= ~StackHeightField::mask();
- bitfields_ |=
- StackHeightField::encode(Min(stack_height, StackHeightMax));
- }
private:
uint32_t bitfields_;
@@ -266,30 +258,9 @@
DefinitionInfo* def_;
ZoneList<DefinitionInfo*>* defined_vars_;
- static const int SideEffectFreeFieldStart = 0;
- static const int SideEffectFreeFieldLength = 1;
- class SideEffectFreeField: public BitField<bool,
- SideEffectFreeFieldStart,
- SideEffectFreeFieldLength> {
- };
-
- static const int ExpressionSizeFieldStart =
- SideEffectFreeFieldStart + SideEffectFreeFieldLength;
- static const int ExpressionSizeFieldLength = 5;
- static const int ExpressionSizeMax = (1 << ExpressionSizeFieldLength) - 1;
- class ExpressionSizeField: public BitField<int,
- ExpressionSizeFieldStart,
- ExpressionSizeFieldLength> {
- };
-
- static const int StackHeightFieldStart =
- ExpressionSizeFieldStart + ExpressionSizeFieldLength;
- static const int StackHeightFieldLength = 5;
- static const int StackHeightMax = (1 << StackHeightFieldLength) - 1;
- class StackHeightField: public BitField<int,
- StackHeightFieldStart,
- StackHeightFieldLength> {
- };
+ // Using template BitField<type, start, size>.
+ class SideEffectFreeField : public BitField<bool, 0, 1> {};
+ class ToInt32Field : public BitField<bool, 1, 1> {};
};
« no previous file with comments | « no previous file | src/flag-definitions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698