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

Side by Side Diff: src/ast.cc

Issue 490173002: Take ast node id counting away from Isolate. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: . Created 6 years, 4 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 unified diff | Download patch | Annotate | Revision Log
« src/ast.h ('K') | « src/ast.h ('k') | src/compiler.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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 const VariableProxy* var_proxy = AsVariableProxy(); 52 const VariableProxy* var_proxy = AsVariableProxy();
53 if (var_proxy == NULL) return false; 53 if (var_proxy == NULL) return false;
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 int* id_counter)
64 : Expression(zone, position, id_counter),
64 name_(var->raw_name()), 65 name_(var->raw_name()),
65 var_(NULL), // Will be set by the call to BindTo. 66 var_(NULL), // Will be set by the call to BindTo.
66 is_this_(var->is_this()), 67 is_this_(var->is_this()),
67 is_assigned_(false), 68 is_assigned_(false),
68 interface_(var->interface()), 69 interface_(var->interface()),
69 variable_feedback_slot_(kInvalidFeedbackSlot) { 70 variable_feedback_slot_(kInvalidFeedbackSlot) {
70 BindTo(var); 71 BindTo(var);
71 } 72 }
72 73
73 74
74 VariableProxy::VariableProxy(Zone* zone, 75 VariableProxy::VariableProxy(Zone* zone, const AstRawString* name, bool is_this,
75 const AstRawString* name, 76 Interface* interface, int position,
76 bool is_this, 77 int* id_counter)
77 Interface* interface, 78 : Expression(zone, position, id_counter),
78 int position)
79 : Expression(zone, position),
80 name_(name), 79 name_(name),
81 var_(NULL), 80 var_(NULL),
82 is_this_(is_this), 81 is_this_(is_this),
83 is_assigned_(false), 82 is_assigned_(false),
84 interface_(interface), 83 interface_(interface),
85 variable_feedback_slot_(kInvalidFeedbackSlot) { 84 variable_feedback_slot_(kInvalidFeedbackSlot) {}
86 }
87 85
88 86
89 void VariableProxy::BindTo(Variable* var) { 87 void VariableProxy::BindTo(Variable* var) {
90 DCHECK(var_ == NULL); // must be bound only once 88 DCHECK(var_ == NULL); // must be bound only once
91 DCHECK(var != NULL); // must bind 89 DCHECK(var != NULL); // must bind
92 DCHECK(!FLAG_harmony_modules || interface_->IsUnified(var->interface())); 90 DCHECK(!FLAG_harmony_modules || interface_->IsUnified(var->interface()));
93 DCHECK((is_this() && var->is_this()) || name_ == var->raw_name()); 91 DCHECK((is_this() && var->is_this()) || name_ == var->raw_name());
94 // Ideally CONST-ness should match. However, this is very hard to achieve 92 // Ideally CONST-ness should match. However, this is very hard to achieve
95 // because we don't know the exact semantics of conflicting (const and 93 // because we don't know the exact semantics of conflicting (const and
96 // non-const) multiple variable declarations, const vars introduced via 94 // non-const) multiple variable declarations, const vars introduced via
97 // eval() etc. Const-ness and variable declarations are a complete mess 95 // eval() etc. Const-ness and variable declarations are a complete mess
98 // in JS. Sigh... 96 // in JS. Sigh...
99 var_ = var; 97 var_ = var;
100 var->set_is_used(); 98 var->set_is_used();
101 } 99 }
102 100
103 101
104 Assignment::Assignment(Zone* zone, 102 Assignment::Assignment(Zone* zone, Token::Value op, Expression* target,
105 Token::Value op, 103 Expression* value, int pos, int* id_counter)
106 Expression* target, 104 : Expression(zone, pos, id_counter),
107 Expression* value,
108 int pos)
109 : Expression(zone, pos),
110 op_(op), 105 op_(op),
111 target_(target), 106 target_(target),
112 value_(value), 107 value_(value),
113 binary_operation_(NULL), 108 binary_operation_(NULL),
114 assignment_id_(GetNextId(zone)), 109 assignment_id_(GetNextId(id_counter)),
115 is_uninitialized_(false), 110 is_uninitialized_(false),
116 store_mode_(STANDARD_STORE) { } 111 store_mode_(STANDARD_STORE) {}
117 112
118 113
119 Token::Value Assignment::binary_op() const { 114 Token::Value Assignment::binary_op() const {
120 switch (op_) { 115 switch (op_) {
121 case Token::ASSIGN_BIT_OR: return Token::BIT_OR; 116 case Token::ASSIGN_BIT_OR: return Token::BIT_OR;
122 case Token::ASSIGN_BIT_XOR: return Token::BIT_XOR; 117 case Token::ASSIGN_BIT_XOR: return Token::BIT_XOR;
123 case Token::ASSIGN_BIT_AND: return Token::BIT_AND; 118 case Token::ASSIGN_BIT_AND: return Token::BIT_AND;
124 case Token::ASSIGN_SHL: return Token::SHL; 119 case Token::ASSIGN_SHL: return Token::SHL;
125 case Token::ASSIGN_SAR: return Token::SAR; 120 case Token::ASSIGN_SAR: return Token::SAR;
126 case Token::ASSIGN_SHR: return Token::SHR; 121 case Token::ASSIGN_SHR: return Token::SHR;
(...skipping 859 matching lines...) Expand 10 before | Expand all | Expand 10 after
986 for (int i = 0; i < nodes->length(); i++) { 981 for (int i = 0; i < nodes->length(); i++) {
987 RegExpTree* node = nodes->at(i); 982 RegExpTree* node = nodes->at(i);
988 int node_min_match = node->min_match(); 983 int node_min_match = node->min_match();
989 min_match_ = IncreaseBy(min_match_, node_min_match); 984 min_match_ = IncreaseBy(min_match_, node_min_match);
990 int node_max_match = node->max_match(); 985 int node_max_match = node->max_match();
991 max_match_ = IncreaseBy(max_match_, node_max_match); 986 max_match_ = IncreaseBy(max_match_, node_max_match);
992 } 987 }
993 } 988 }
994 989
995 990
996 CaseClause::CaseClause(Zone* zone, 991 CaseClause::CaseClause(Zone* zone, Expression* label,
997 Expression* label, 992 ZoneList<Statement*>* statements, int pos,
998 ZoneList<Statement*>* statements, 993 int* id_counter)
999 int pos) 994 : Expression(zone, pos, id_counter),
1000 : Expression(zone, pos),
1001 label_(label), 995 label_(label),
1002 statements_(statements), 996 statements_(statements),
1003 compare_type_(Type::None(zone)), 997 compare_type_(Type::None(zone)),
1004 compare_id_(AstNode::GetNextId(zone)), 998 compare_id_(AstNode::GetNextId(id_counter)),
1005 entry_id_(AstNode::GetNextId(zone)) { 999 entry_id_(AstNode::GetNextId(id_counter)) {}
1006 }
1007 1000
1008 1001
1009 #define REGULAR_NODE(NodeType) \ 1002 #define REGULAR_NODE(NodeType) \
1010 void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \ 1003 void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \
1011 increase_node_count(); \ 1004 increase_node_count(); \
1012 } 1005 }
1013 #define REGULAR_NODE_WITH_FEEDBACK_SLOTS(NodeType) \ 1006 #define REGULAR_NODE_WITH_FEEDBACK_SLOTS(NodeType) \
1014 void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \ 1007 void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \
1015 increase_node_count(); \ 1008 increase_node_count(); \
1016 add_slot_node(node); \ 1009 add_slot_node(node); \
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
1135 SNPrintF(buffer, "%d", Smi::cast(*value())->value()); 1128 SNPrintF(buffer, "%d", Smi::cast(*value())->value());
1136 str = arr; 1129 str = arr;
1137 } else { 1130 } else {
1138 str = DoubleToCString(value()->Number(), buffer); 1131 str = DoubleToCString(value()->Number(), buffer);
1139 } 1132 }
1140 return isolate_->factory()->NewStringFromAsciiChecked(str); 1133 return isolate_->factory()->NewStringFromAsciiChecked(str);
1141 } 1134 }
1142 1135
1143 1136
1144 } } // namespace v8::internal 1137 } } // namespace v8::internal
OLDNEW
« src/ast.h ('K') | « src/ast.h ('k') | src/compiler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698