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 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 } else if (value_->AsMaterializedLiteral() != NULL) { | 287 } else if (value_->AsMaterializedLiteral() != NULL) { |
288 kind_ = MATERIALIZED_LITERAL; | 288 kind_ = MATERIALIZED_LITERAL; |
289 } else if (value_->IsLiteral()) { | 289 } else if (value_->IsLiteral()) { |
290 kind_ = CONSTANT; | 290 kind_ = CONSTANT; |
291 } else { | 291 } else { |
292 kind_ = COMPUTED; | 292 kind_ = COMPUTED; |
293 } | 293 } |
294 } | 294 } |
295 | 295 |
296 | 296 |
| 297 FeedbackVectorRequirements ClassLiteral::ComputeFeedbackRequirements( |
| 298 Isolate* isolate, const ICSlotCache* cache) { |
| 299 if (!FLAG_vector_stores) return FeedbackVectorRequirements(0, 0); |
| 300 |
| 301 // This logic that computes the number of slots needed for vector store |
| 302 // ICs must mirror FullCodeGenerator::VisitClassLiteral. |
| 303 int ic_slots = 0; |
| 304 for (int i = 0; i < properties()->length(); i++) { |
| 305 ObjectLiteral::Property* property = properties()->at(i); |
| 306 |
| 307 Expression* value = property->value(); |
| 308 if (FunctionLiteral::NeedsHomeObject(value)) ic_slots++; |
| 309 } |
| 310 |
| 311 #ifdef DEBUG |
| 312 // FullCodeGenerator::VisitClassLiteral verifies that it consumes slot_count_ |
| 313 // slots. |
| 314 slot_count_ = ic_slots; |
| 315 #endif |
| 316 return FeedbackVectorRequirements(0, ic_slots); |
| 317 } |
| 318 |
| 319 |
| 320 FeedbackVectorICSlot ClassLiteral::SlotForHomeObject(Expression* value, |
| 321 int* slot_index) const { |
| 322 if (FLAG_vector_stores && FunctionLiteral::NeedsHomeObject(value)) { |
| 323 DCHECK(slot_index != NULL && *slot_index >= 0 && *slot_index < slot_count_); |
| 324 FeedbackVectorICSlot slot = GetNthSlot(*slot_index); |
| 325 *slot_index += 1; |
| 326 return slot; |
| 327 } |
| 328 return FeedbackVectorICSlot::Invalid(); |
| 329 } |
| 330 |
| 331 |
297 bool ObjectLiteral::Property::IsCompileTimeValue() { | 332 bool ObjectLiteral::Property::IsCompileTimeValue() { |
298 return kind_ == CONSTANT || | 333 return kind_ == CONSTANT || |
299 (kind_ == MATERIALIZED_LITERAL && | 334 (kind_ == MATERIALIZED_LITERAL && |
300 CompileTimeValue::IsCompileTimeValue(value_)); | 335 CompileTimeValue::IsCompileTimeValue(value_)); |
301 } | 336 } |
302 | 337 |
303 | 338 |
304 void ObjectLiteral::Property::set_emit_store(bool emit_store) { | 339 void ObjectLiteral::Property::set_emit_store(bool emit_store) { |
305 emit_store_ = emit_store; | 340 emit_store_ = emit_store; |
306 } | 341 } |
(...skipping 814 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1121 bool Literal::Match(void* literal1, void* literal2) { | 1156 bool Literal::Match(void* literal1, void* literal2) { |
1122 const AstValue* x = static_cast<Literal*>(literal1)->raw_value(); | 1157 const AstValue* x = static_cast<Literal*>(literal1)->raw_value(); |
1123 const AstValue* y = static_cast<Literal*>(literal2)->raw_value(); | 1158 const AstValue* y = static_cast<Literal*>(literal2)->raw_value(); |
1124 return (x->IsString() && y->IsString() && x->AsString() == y->AsString()) || | 1159 return (x->IsString() && y->IsString() && x->AsString() == y->AsString()) || |
1125 (x->IsNumber() && y->IsNumber() && x->AsNumber() == y->AsNumber()); | 1160 (x->IsNumber() && y->IsNumber() && x->AsNumber() == y->AsNumber()); |
1126 } | 1161 } |
1127 | 1162 |
1128 | 1163 |
1129 } // namespace internal | 1164 } // namespace internal |
1130 } // namespace v8 | 1165 } // namespace v8 |
OLD | NEW |