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

Side by Side Diff: src/ast.cc

Issue 629983002: Squeeze the layout of variable proxy nodes. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 2 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
« no previous file with comments | « src/ast.h ('k') | src/parser.cc » ('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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
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, id_gen), 64 : Expression(zone, position, id_gen),
65 name_(var->raw_name()), 65 raw_name_(var->raw_name()),
66 var_(NULL), // Will be set by the call to BindTo. 66 interface_(var->interface()),
67 variable_feedback_slot_(kInvalidFeedbackSlot),
67 is_this_(var->is_this()), 68 is_this_(var->is_this()),
68 is_assigned_(false), 69 is_assigned_(false),
69 interface_(var->interface()), 70 is_resolved_(false) {
70 variable_feedback_slot_(kInvalidFeedbackSlot) {
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, id_gen), 77 : Expression(zone, position, id_gen),
78 name_(name), 78 raw_name_(name),
79 var_(NULL), 79 interface_(interface),
80 variable_feedback_slot_(kInvalidFeedbackSlot),
80 is_this_(is_this), 81 is_this_(is_this),
81 is_assigned_(false), 82 is_assigned_(false),
82 interface_(interface), 83 is_resolved_(false) {}
83 variable_feedback_slot_(kInvalidFeedbackSlot) {}
84 84
85 85
86 void VariableProxy::BindTo(Variable* var) { 86 void VariableProxy::BindTo(Variable* var) {
87 DCHECK(var_ == NULL); // must be bound only once
88 DCHECK(var != NULL); // must bind
89 DCHECK(!FLAG_harmony_modules || interface_->IsUnified(var->interface())); 87 DCHECK(!FLAG_harmony_modules || interface_->IsUnified(var->interface()));
90 DCHECK((is_this() && var->is_this()) || name_ == var->raw_name()); 88 DCHECK((is_this() && var->is_this()) || raw_name() == var->raw_name());
91 // 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
92 // 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
93 // non-const) multiple variable declarations, const vars introduced via 91 // non-const) multiple variable declarations, const vars introduced via
94 // eval() etc. Const-ness and variable declarations are a complete mess 92 // eval() etc. Const-ness and variable declarations are a complete mess
95 // in JS. Sigh... 93 // in JS. Sigh...
96 var_ = var; 94 set_var(var);
95 set_is_resolved();
97 var->set_is_used(); 96 var->set_is_used();
98 } 97 }
99 98
100 99
101 Assignment::Assignment(Zone* zone, Token::Value op, Expression* target, 100 Assignment::Assignment(Zone* zone, Token::Value op, Expression* target,
102 Expression* value, int pos, IdGen* id_gen) 101 Expression* value, int pos, IdGen* id_gen)
103 : Expression(zone, pos, id_gen), 102 : Expression(zone, pos, id_gen),
104 op_(op), 103 op_(op),
105 target_(target), 104 target_(target),
106 value_(value), 105 value_(value),
(...skipping 1029 matching lines...) Expand 10 before | Expand all | Expand 10 after
1136 // static 1135 // static
1137 bool Literal::Match(void* literal1, void* literal2) { 1136 bool Literal::Match(void* literal1, void* literal2) {
1138 const AstValue* x = static_cast<Literal*>(literal1)->raw_value(); 1137 const AstValue* x = static_cast<Literal*>(literal1)->raw_value();
1139 const AstValue* y = static_cast<Literal*>(literal2)->raw_value(); 1138 const AstValue* y = static_cast<Literal*>(literal2)->raw_value();
1140 return (x->IsString() && y->IsString() && *x->AsString() == *y->AsString()) || 1139 return (x->IsString() && y->IsString() && *x->AsString() == *y->AsString()) ||
1141 (x->IsNumber() && y->IsNumber() && x->AsNumber() == y->AsNumber()); 1140 (x->IsNumber() && y->IsNumber() && x->AsNumber() == y->AsNumber());
1142 } 1141 }
1143 1142
1144 1143
1145 } } // namespace v8::internal 1144 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/ast.h ('k') | src/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698