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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 set_var(var); | 89 set_var(var); |
90 set_is_resolved(); | 90 set_is_resolved(); |
91 var->set_is_used(); | 91 var->set_is_used(); |
92 } | 92 } |
93 | 93 |
94 | 94 |
95 void VariableProxy::SetFirstFeedbackICSlot(FeedbackVectorICSlot slot, | 95 void VariableProxy::SetFirstFeedbackICSlot(FeedbackVectorICSlot slot, |
96 ICSlotCache* cache) { | 96 ICSlotCache* cache) { |
97 variable_feedback_slot_ = slot; | 97 variable_feedback_slot_ = slot; |
98 if (var()->IsUnallocatedOrGlobalSlot()) { | 98 if (var()->IsUnallocated()) { |
99 cache->Add(VariableICSlotPair(var(), slot)); | 99 cache->Add(VariableICSlotPair(var(), slot)); |
100 } | 100 } |
101 } | 101 } |
102 | 102 |
103 | 103 |
104 FeedbackVectorRequirements VariableProxy::ComputeFeedbackRequirements( | 104 FeedbackVectorRequirements VariableProxy::ComputeFeedbackRequirements( |
105 Isolate* isolate, const ICSlotCache* cache) { | 105 Isolate* isolate, const ICSlotCache* cache) { |
106 if (UsesVariableFeedbackSlot()) { | 106 if (UsesVariableFeedbackSlot()) { |
107 // VariableProxies that point to the same Variable within a function can | 107 // VariableProxies that point to the same Variable within a function can |
108 // make their loads from the same IC slot. | 108 // make their loads from the same IC slot. |
109 if (var()->IsUnallocatedOrGlobalSlot()) { | 109 if (var()->IsUnallocated()) { |
110 for (int i = 0; i < cache->length(); i++) { | 110 for (int i = 0; i < cache->length(); i++) { |
111 VariableICSlotPair& pair = cache->at(i); | 111 VariableICSlotPair& pair = cache->at(i); |
112 if (pair.variable() == var()) { | 112 if (pair.variable() == var()) { |
113 variable_feedback_slot_ = pair.slot(); | 113 variable_feedback_slot_ = pair.slot(); |
114 return FeedbackVectorRequirements(0, 0); | 114 return FeedbackVectorRequirements(0, 0); |
115 } | 115 } |
116 } | 116 } |
117 } | 117 } |
118 return FeedbackVectorRequirements(0, 1); | 118 return FeedbackVectorRequirements(0, 1); |
119 } | 119 } |
120 return FeedbackVectorRequirements(0, 0); | 120 return FeedbackVectorRequirements(0, 0); |
121 } | 121 } |
122 | 122 |
123 | 123 |
124 static int GetStoreICSlots(Expression* expr) { | 124 static int GetStoreICSlots(Expression* expr) { |
125 int ic_slots = 0; | 125 int ic_slots = 0; |
126 if (FLAG_vector_stores) { | 126 if (FLAG_vector_stores) { |
127 Property* property = expr->AsProperty(); | 127 Property* property = expr->AsProperty(); |
128 LhsKind assign_type = Property::GetAssignType(property); | 128 LhsKind assign_type = Property::GetAssignType(property); |
129 if ((assign_type == VARIABLE && | 129 if ((assign_type == VARIABLE && |
130 expr->AsVariableProxy()->var()->IsUnallocatedOrGlobalSlot()) || | 130 expr->AsVariableProxy()->var()->IsUnallocated()) || |
131 assign_type == NAMED_PROPERTY || assign_type == KEYED_PROPERTY) { | 131 assign_type == NAMED_PROPERTY || assign_type == KEYED_PROPERTY) { |
132 ic_slots++; | 132 ic_slots++; |
133 } | 133 } |
134 } | 134 } |
135 return ic_slots; | 135 return ic_slots; |
136 } | 136 } |
137 | 137 |
138 | 138 |
139 static Code::Kind GetStoreICKind(Expression* expr) { | 139 static Code::Kind GetStoreICKind(Expression* expr) { |
140 LhsKind assign_type = Property::GetAssignType(expr->AsProperty()); | 140 LhsKind assign_type = Property::GetAssignType(expr->AsProperty()); |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 // This logic that computes the number of slots needed for vector store | 282 // This logic that computes the number of slots needed for vector store |
283 // ICs must mirror FullCodeGenerator::VisitClassLiteral. | 283 // ICs must mirror FullCodeGenerator::VisitClassLiteral. |
284 int ic_slots = 0; | 284 int ic_slots = 0; |
285 for (int i = 0; i < properties()->length(); i++) { | 285 for (int i = 0; i < properties()->length(); i++) { |
286 ObjectLiteral::Property* property = properties()->at(i); | 286 ObjectLiteral::Property* property = properties()->at(i); |
287 | 287 |
288 Expression* value = property->value(); | 288 Expression* value = property->value(); |
289 if (FunctionLiteral::NeedsHomeObject(value)) ic_slots++; | 289 if (FunctionLiteral::NeedsHomeObject(value)) ic_slots++; |
290 } | 290 } |
291 | 291 |
292 if (scope() != NULL && | 292 if (scope() != NULL && class_variable_proxy()->var()->IsUnallocated()) { |
293 class_variable_proxy()->var()->IsUnallocatedOrGlobalSlot()) { | |
294 ic_slots++; | 293 ic_slots++; |
295 } | 294 } |
296 | 295 |
297 #ifdef DEBUG | 296 #ifdef DEBUG |
298 // FullCodeGenerator::VisitClassLiteral verifies that it consumes slot_count_ | 297 // FullCodeGenerator::VisitClassLiteral verifies that it consumes slot_count_ |
299 // slots. | 298 // slots. |
300 slot_count_ = ic_slots; | 299 slot_count_ = ic_slots; |
301 #endif | 300 #endif |
302 return FeedbackVectorRequirements(0, ic_slots); | 301 return FeedbackVectorRequirements(0, ic_slots); |
303 } | 302 } |
(...skipping 842 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1146 bool Literal::Match(void* literal1, void* literal2) { | 1145 bool Literal::Match(void* literal1, void* literal2) { |
1147 const AstValue* x = static_cast<Literal*>(literal1)->raw_value(); | 1146 const AstValue* x = static_cast<Literal*>(literal1)->raw_value(); |
1148 const AstValue* y = static_cast<Literal*>(literal2)->raw_value(); | 1147 const AstValue* y = static_cast<Literal*>(literal2)->raw_value(); |
1149 return (x->IsString() && y->IsString() && x->AsString() == y->AsString()) || | 1148 return (x->IsString() && y->IsString() && x->AsString() == y->AsString()) || |
1150 (x->IsNumber() && y->IsNumber() && x->AsNumber() == y->AsNumber()); | 1149 (x->IsNumber() && y->IsNumber() && x->AsNumber() == y->AsNumber()); |
1151 } | 1150 } |
1152 | 1151 |
1153 | 1152 |
1154 } // namespace internal | 1153 } // namespace internal |
1155 } // namespace v8 | 1154 } // namespace v8 |
OLD | NEW |