OLD | NEW |
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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 IdGen* id_gen) | 63 IdGen* id_gen) |
64 : Expression(zone, position, 0, id_gen), | 64 : Expression(zone, position, 0, id_gen), |
65 raw_name_(var->raw_name()), | |
66 interface_(var->interface()), | |
67 variable_feedback_slot_(FeedbackVectorSlot::Invalid()), | |
68 is_this_(var->is_this()), | 65 is_this_(var->is_this()), |
69 is_assigned_(false), | 66 is_assigned_(false), |
70 is_resolved_(false) { | 67 is_resolved_(false), |
| 68 variable_feedback_slot_(FeedbackVectorSlot::Invalid()), |
| 69 raw_name_(var->raw_name()), |
| 70 interface_(var->interface()) { |
71 BindTo(var); | 71 BindTo(var); |
72 } | 72 } |
73 | 73 |
74 | 74 |
75 VariableProxy::VariableProxy(Zone* zone, const AstRawString* name, bool is_this, | 75 VariableProxy::VariableProxy(Zone* zone, const AstRawString* name, bool is_this, |
76 Interface* interface, int position, IdGen* id_gen) | 76 Interface* interface, int position, IdGen* id_gen) |
77 : Expression(zone, position, 0, id_gen), | 77 : Expression(zone, position, 0, id_gen), |
78 raw_name_(name), | |
79 interface_(interface), | |
80 variable_feedback_slot_(FeedbackVectorSlot::Invalid()), | |
81 is_this_(is_this), | 78 is_this_(is_this), |
82 is_assigned_(false), | 79 is_assigned_(false), |
83 is_resolved_(false) {} | 80 is_resolved_(false), |
| 81 variable_feedback_slot_(FeedbackVectorSlot::Invalid()), |
| 82 raw_name_(name), |
| 83 interface_(interface) {} |
84 | 84 |
85 | 85 |
86 void VariableProxy::BindTo(Variable* var) { | 86 void VariableProxy::BindTo(Variable* var) { |
87 DCHECK(!FLAG_harmony_modules || interface_->IsUnified(var->interface())); | 87 DCHECK(!FLAG_harmony_modules || interface_->IsUnified(var->interface())); |
88 DCHECK((is_this() && var->is_this()) || raw_name() == var->raw_name()); | 88 DCHECK((is_this() && var->is_this()) || raw_name() == var->raw_name()); |
89 // Ideally CONST-ness should match. However, this is very hard to achieve | 89 // Ideally CONST-ness should match. However, this is very hard to achieve |
90 // because we don't know the exact semantics of conflicting (const and | 90 // because we don't know the exact semantics of conflicting (const and |
91 // non-const) multiple variable declarations, const vars introduced via | 91 // non-const) multiple variable declarations, const vars introduced via |
92 // eval() etc. Const-ness and variable declarations are a complete mess | 92 // eval() etc. Const-ness and variable declarations are a complete mess |
93 // in JS. Sigh... | 93 // in JS. Sigh... |
94 set_var(var); | 94 set_var(var); |
95 set_is_resolved(); | 95 set_is_resolved(); |
96 var->set_is_used(); | 96 var->set_is_used(); |
97 } | 97 } |
98 | 98 |
99 | 99 |
100 Assignment::Assignment(Zone* zone, Token::Value op, Expression* target, | 100 Assignment::Assignment(Zone* zone, Token::Value op, Expression* target, |
101 Expression* value, int pos, IdGen* id_gen) | 101 Expression* value, int pos, IdGen* id_gen) |
102 : Expression(zone, pos, num_ids(), id_gen), | 102 : Expression(zone, pos, num_ids(), id_gen), |
| 103 is_uninitialized_(false), |
| 104 store_mode_(STANDARD_STORE), |
103 op_(op), | 105 op_(op), |
104 target_(target), | 106 target_(target), |
105 value_(value), | 107 value_(value), |
106 binary_operation_(NULL), | 108 binary_operation_(NULL) {} |
107 is_uninitialized_(false), | |
108 store_mode_(STANDARD_STORE) {} | |
109 | 109 |
110 | 110 |
111 Token::Value Assignment::binary_op() const { | 111 Token::Value Assignment::binary_op() const { |
112 switch (op_) { | 112 switch (op_) { |
113 case Token::ASSIGN_BIT_OR: return Token::BIT_OR; | 113 case Token::ASSIGN_BIT_OR: return Token::BIT_OR; |
114 case Token::ASSIGN_BIT_XOR: return Token::BIT_XOR; | 114 case Token::ASSIGN_BIT_XOR: return Token::BIT_XOR; |
115 case Token::ASSIGN_BIT_AND: return Token::BIT_AND; | 115 case Token::ASSIGN_BIT_AND: return Token::BIT_AND; |
116 case Token::ASSIGN_SHL: return Token::SHL; | 116 case Token::ASSIGN_SHL: return Token::SHL; |
117 case Token::ASSIGN_SAR: return Token::SAR; | 117 case Token::ASSIGN_SAR: return Token::SAR; |
118 case Token::ASSIGN_SHR: return Token::SHR; | 118 case Token::ASSIGN_SHR: return Token::SHR; |
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
427 // TODO(olivf) If this Operation is used in a test context, then the right | 427 // TODO(olivf) If this Operation is used in a test context, then the right |
428 // hand side has a ToBoolean stub and we want to collect the type information. | 428 // hand side has a ToBoolean stub and we want to collect the type information. |
429 // However the GraphBuilder expects it to be on the instruction corresponding | 429 // However the GraphBuilder expects it to be on the instruction corresponding |
430 // to the TestContext, therefore we have to store it here and not on the | 430 // to the TestContext, therefore we have to store it here and not on the |
431 // right hand operand. | 431 // right hand operand. |
432 set_to_boolean_types(oracle->ToBooleanTypes(right()->test_id())); | 432 set_to_boolean_types(oracle->ToBooleanTypes(right()->test_id())); |
433 } | 433 } |
434 | 434 |
435 | 435 |
436 bool BinaryOperation::ResultOverwriteAllowed() const { | 436 bool BinaryOperation::ResultOverwriteAllowed() const { |
437 switch (op_) { | 437 switch (op()) { |
438 case Token::COMMA: | 438 case Token::COMMA: |
439 case Token::OR: | 439 case Token::OR: |
440 case Token::AND: | 440 case Token::AND: |
441 return false; | 441 return false; |
442 case Token::BIT_OR: | 442 case Token::BIT_OR: |
443 case Token::BIT_XOR: | 443 case Token::BIT_XOR: |
444 case Token::BIT_AND: | 444 case Token::BIT_AND: |
445 case Token::SHL: | 445 case Token::SHL: |
446 case Token::SAR: | 446 case Token::SAR: |
447 case Token::SHR: | 447 case Token::SHR: |
(...skipping 694 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1142 // static | 1142 // static |
1143 bool Literal::Match(void* literal1, void* literal2) { | 1143 bool Literal::Match(void* literal1, void* literal2) { |
1144 const AstValue* x = static_cast<Literal*>(literal1)->raw_value(); | 1144 const AstValue* x = static_cast<Literal*>(literal1)->raw_value(); |
1145 const AstValue* y = static_cast<Literal*>(literal2)->raw_value(); | 1145 const AstValue* y = static_cast<Literal*>(literal2)->raw_value(); |
1146 return (x->IsString() && y->IsString() && *x->AsString() == *y->AsString()) || | 1146 return (x->IsString() && y->IsString() && *x->AsString() == *y->AsString()) || |
1147 (x->IsNumber() && y->IsNumber() && x->AsNumber() == y->AsNumber()); | 1147 (x->IsNumber() && y->IsNumber() && x->AsNumber() == y->AsNumber()); |
1148 } | 1148 } |
1149 | 1149 |
1150 | 1150 |
1151 } } // namespace v8::internal | 1151 } } // namespace v8::internal |
OLD | NEW |