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

Side by Side Diff: src/ast.cc

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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/ast.h ('k') | src/heap-snapshot-generator.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/ast.h" 5 #include "src/ast.h"
6 6
7 #include <cmath> // For isfinite. 7 #include <cmath> // For isfinite.
8 #include "src/builtins.h" 8 #include "src/builtins.h"
9 #include "src/code-stubs.h" 9 #include "src/code-stubs.h"
10 #include "src/contexts.h" 10 #include "src/contexts.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 Variable* var = var_proxy->var(); 54 Variable* var = var_proxy->var();
55 // The global identifier "undefined" is immutable. Everything 55 // The global identifier "undefined" is immutable. Everything
56 // else could be reassigned. 56 // else could be reassigned.
57 return var != NULL && var->location() == Variable::UNALLOCATED && 57 return var != NULL && var->location() == Variable::UNALLOCATED &&
58 var_proxy->raw_name()->IsOneByteEqualTo("undefined"); 58 var_proxy->raw_name()->IsOneByteEqualTo("undefined");
59 } 59 }
60 60
61 61
62 VariableProxy::VariableProxy(Zone* zone, Variable* var, int position) 62 VariableProxy::VariableProxy(Zone* zone, Variable* var, int position)
63 : Expression(zone, position), 63 : Expression(zone, position),
64 is_this_(var->is_this()), 64 bit_field_(IsThisField::encode(var->is_this()) |
65 is_assigned_(false), 65 IsAssignedField::encode(false) |
66 is_resolved_(false), 66 IsResolvedField::encode(false)),
67 variable_feedback_slot_(FeedbackVectorICSlot::Invalid()), 67 variable_feedback_slot_(FeedbackVectorICSlot::Invalid()),
68 raw_name_(var->raw_name()), 68 raw_name_(var->raw_name()),
69 interface_(var->interface()) { 69 interface_(var->interface()) {
70 BindTo(var); 70 BindTo(var);
71 } 71 }
72 72
73 73
74 VariableProxy::VariableProxy(Zone* zone, const AstRawString* name, bool is_this, 74 VariableProxy::VariableProxy(Zone* zone, const AstRawString* name, bool is_this,
75 Interface* interface, int position) 75 Interface* interface, int position)
76 : Expression(zone, position), 76 : Expression(zone, position),
77 is_this_(is_this), 77 bit_field_(IsThisField::encode(is_this) | IsAssignedField::encode(false) |
78 is_assigned_(false), 78 IsResolvedField::encode(false)),
79 is_resolved_(false),
80 variable_feedback_slot_(FeedbackVectorICSlot::Invalid()), 79 variable_feedback_slot_(FeedbackVectorICSlot::Invalid()),
81 raw_name_(name), 80 raw_name_(name),
82 interface_(interface) {} 81 interface_(interface) {}
83 82
84 83
85 void VariableProxy::BindTo(Variable* var) { 84 void VariableProxy::BindTo(Variable* var) {
86 DCHECK(!FLAG_harmony_modules || interface_->IsUnified(var->interface())); 85 DCHECK(!FLAG_harmony_modules || interface_->IsUnified(var->interface()));
87 DCHECK((is_this() && var->is_this()) || raw_name() == var->raw_name()); 86 DCHECK((is_this() && var->is_this()) || raw_name() == var->raw_name());
88 // Ideally CONST-ness should match. However, this is very hard to achieve 87 // Ideally CONST-ness should match. However, this is very hard to achieve
89 // because we don't know the exact semantics of conflicting (const and 88 // because we don't know the exact semantics of conflicting (const and
90 // non-const) multiple variable declarations, const vars introduced via 89 // non-const) multiple variable declarations, const vars introduced via
91 // eval() etc. Const-ness and variable declarations are a complete mess 90 // eval() etc. Const-ness and variable declarations are a complete mess
92 // in JS. Sigh... 91 // in JS. Sigh...
93 set_var(var); 92 set_var(var);
94 set_is_resolved(); 93 set_is_resolved();
95 var->set_is_used(); 94 var->set_is_used();
96 } 95 }
97 96
98 97
99 Assignment::Assignment(Zone* zone, Token::Value op, Expression* target, 98 Assignment::Assignment(Zone* zone, Token::Value op, Expression* target,
100 Expression* value, int pos) 99 Expression* value, int pos)
101 : Expression(zone, pos), 100 : Expression(zone, pos),
102 is_uninitialized_(false), 101 bit_field_(IsUninitializedField::encode(false) |
103 key_type_(ELEMENT), 102 KeyTypeField::encode(ELEMENT) |
104 store_mode_(STANDARD_STORE), 103 StoreModeField::encode(STANDARD_STORE) |
105 op_(op), 104 TokenField::encode(op)),
106 target_(target), 105 target_(target),
107 value_(value), 106 value_(value),
108 binary_operation_(NULL) {} 107 binary_operation_(NULL) {}
109 108
110 109
111 Token::Value Assignment::binary_op() const { 110 Token::Value Assignment::binary_op() const {
112 switch (op_) { 111 switch (op()) {
113 case Token::ASSIGN_BIT_OR: return Token::BIT_OR; 112 case Token::ASSIGN_BIT_OR: return Token::BIT_OR;
114 case Token::ASSIGN_BIT_XOR: return Token::BIT_XOR; 113 case Token::ASSIGN_BIT_XOR: return Token::BIT_XOR;
115 case Token::ASSIGN_BIT_AND: return Token::BIT_AND; 114 case Token::ASSIGN_BIT_AND: return Token::BIT_AND;
116 case Token::ASSIGN_SHL: return Token::SHL; 115 case Token::ASSIGN_SHL: return Token::SHL;
117 case Token::ASSIGN_SAR: return Token::SAR; 116 case Token::ASSIGN_SAR: return Token::SAR;
118 case Token::ASSIGN_SHR: return Token::SHR; 117 case Token::ASSIGN_SHR: return Token::SHR;
119 case Token::ASSIGN_ADD: return Token::ADD; 118 case Token::ASSIGN_ADD: return Token::ADD;
120 case Token::ASSIGN_SUB: return Token::SUB; 119 case Token::ASSIGN_SUB: return Token::SUB;
121 case Token::ASSIGN_MUL: return Token::MUL; 120 case Token::ASSIGN_MUL: return Token::MUL;
122 case Token::ASSIGN_DIV: return Token::DIV; 121 case Token::ASSIGN_DIV: return Token::DIV;
(...skipping 1011 matching lines...) Expand 10 before | Expand all | Expand 10 after
1134 // static 1133 // static
1135 bool Literal::Match(void* literal1, void* literal2) { 1134 bool Literal::Match(void* literal1, void* literal2) {
1136 const AstValue* x = static_cast<Literal*>(literal1)->raw_value(); 1135 const AstValue* x = static_cast<Literal*>(literal1)->raw_value();
1137 const AstValue* y = static_cast<Literal*>(literal2)->raw_value(); 1136 const AstValue* y = static_cast<Literal*>(literal2)->raw_value();
1138 return (x->IsString() && y->IsString() && *x->AsString() == *y->AsString()) || 1137 return (x->IsString() && y->IsString() && *x->AsString() == *y->AsString()) ||
1139 (x->IsNumber() && y->IsNumber() && x->AsNumber() == y->AsNumber()); 1138 (x->IsNumber() && y->IsNumber() && x->AsNumber() == y->AsNumber());
1140 } 1139 }
1141 1140
1142 1141
1143 } } // namespace v8::internal 1142 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/ast.h ('k') | src/heap-snapshot-generator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698