| 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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 variable_feedback_slot_ = spec->AddLoadICSlot(); | 113 variable_feedback_slot_ = spec->AddLoadICSlot(); |
| 114 if (var()->IsUnallocated()) { | 114 if (var()->IsUnallocated()) { |
| 115 cache->Put(var(), variable_feedback_slot_); | 115 cache->Put(var(), variable_feedback_slot_); |
| 116 } | 116 } |
| 117 } | 117 } |
| 118 } | 118 } |
| 119 | 119 |
| 120 | 120 |
| 121 static void AssignVectorSlots(Expression* expr, FeedbackVectorSpec* spec, | 121 static void AssignVectorSlots(Expression* expr, FeedbackVectorSpec* spec, |
| 122 FeedbackVectorSlot* out_slot) { | 122 FeedbackVectorSlot* out_slot) { |
| 123 if (FLAG_vector_stores) { | 123 Property* property = expr->AsProperty(); |
| 124 Property* property = expr->AsProperty(); | 124 LhsKind assign_type = Property::GetAssignType(property); |
| 125 LhsKind assign_type = Property::GetAssignType(property); | 125 if ((assign_type == VARIABLE && |
| 126 if ((assign_type == VARIABLE && | 126 expr->AsVariableProxy()->var()->IsUnallocated()) || |
| 127 expr->AsVariableProxy()->var()->IsUnallocated()) || | 127 assign_type == NAMED_PROPERTY || assign_type == KEYED_PROPERTY) { |
| 128 assign_type == NAMED_PROPERTY || assign_type == KEYED_PROPERTY) { | 128 // TODO(ishell): consider using ICSlotCache for variables here. |
| 129 // TODO(ishell): consider using ICSlotCache for variables here. | 129 FeedbackVectorSlotKind kind = assign_type == KEYED_PROPERTY |
| 130 FeedbackVectorSlotKind kind = assign_type == KEYED_PROPERTY | 130 ? FeedbackVectorSlotKind::KEYED_STORE_IC |
| 131 ? FeedbackVectorSlotKind::KEYED_STORE_IC | 131 : FeedbackVectorSlotKind::STORE_IC; |
| 132 : FeedbackVectorSlotKind::STORE_IC; | 132 *out_slot = spec->AddSlot(kind); |
| 133 *out_slot = spec->AddSlot(kind); | |
| 134 } | |
| 135 } | 133 } |
| 136 } | 134 } |
| 137 | 135 |
| 138 | 136 |
| 139 void ForEachStatement::AssignFeedbackVectorSlots( | 137 void ForEachStatement::AssignFeedbackVectorSlots( |
| 140 Isolate* isolate, FeedbackVectorSpec* spec, | 138 Isolate* isolate, FeedbackVectorSpec* spec, |
| 141 FeedbackVectorSlotCache* cache) { | 139 FeedbackVectorSlotCache* cache) { |
| 142 AssignVectorSlots(each(), spec, &each_slot_); | 140 AssignVectorSlots(each(), spec, &each_slot_); |
| 143 } | 141 } |
| 144 | 142 |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 kind_ = CONSTANT; | 247 kind_ = CONSTANT; |
| 250 } else { | 248 } else { |
| 251 kind_ = COMPUTED; | 249 kind_ = COMPUTED; |
| 252 } | 250 } |
| 253 } | 251 } |
| 254 | 252 |
| 255 | 253 |
| 256 void ClassLiteral::AssignFeedbackVectorSlots(Isolate* isolate, | 254 void ClassLiteral::AssignFeedbackVectorSlots(Isolate* isolate, |
| 257 FeedbackVectorSpec* spec, | 255 FeedbackVectorSpec* spec, |
| 258 FeedbackVectorSlotCache* cache) { | 256 FeedbackVectorSlotCache* cache) { |
| 259 if (!FLAG_vector_stores) return; | |
| 260 | |
| 261 // This logic that computes the number of slots needed for vector store | 257 // This logic that computes the number of slots needed for vector store |
| 262 // ICs must mirror FullCodeGenerator::VisitClassLiteral. | 258 // ICs must mirror FullCodeGenerator::VisitClassLiteral. |
| 263 if (NeedsProxySlot()) { | 259 if (NeedsProxySlot()) { |
| 264 slot_ = spec->AddStoreICSlot(); | 260 slot_ = spec->AddStoreICSlot(); |
| 265 } | 261 } |
| 266 | 262 |
| 267 for (int i = 0; i < properties()->length(); i++) { | 263 for (int i = 0; i < properties()->length(); i++) { |
| 268 ObjectLiteral::Property* property = properties()->at(i); | 264 ObjectLiteral::Property* property = properties()->at(i); |
| 269 Expression* value = property->value(); | 265 Expression* value = property->value(); |
| 270 if (FunctionLiteral::NeedsHomeObject(value)) { | 266 if (FunctionLiteral::NeedsHomeObject(value)) { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 287 | 283 |
| 288 | 284 |
| 289 bool ObjectLiteral::Property::emit_store() { | 285 bool ObjectLiteral::Property::emit_store() { |
| 290 return emit_store_; | 286 return emit_store_; |
| 291 } | 287 } |
| 292 | 288 |
| 293 | 289 |
| 294 void ObjectLiteral::AssignFeedbackVectorSlots(Isolate* isolate, | 290 void ObjectLiteral::AssignFeedbackVectorSlots(Isolate* isolate, |
| 295 FeedbackVectorSpec* spec, | 291 FeedbackVectorSpec* spec, |
| 296 FeedbackVectorSlotCache* cache) { | 292 FeedbackVectorSlotCache* cache) { |
| 297 if (!FLAG_vector_stores) return; | |
| 298 | |
| 299 // This logic that computes the number of slots needed for vector store | 293 // This logic that computes the number of slots needed for vector store |
| 300 // ics must mirror FullCodeGenerator::VisitObjectLiteral. | 294 // ics must mirror FullCodeGenerator::VisitObjectLiteral. |
| 301 int property_index = 0; | 295 int property_index = 0; |
| 302 for (; property_index < properties()->length(); property_index++) { | 296 for (; property_index < properties()->length(); property_index++) { |
| 303 ObjectLiteral::Property* property = properties()->at(property_index); | 297 ObjectLiteral::Property* property = properties()->at(property_index); |
| 304 if (property->is_computed_name()) break; | 298 if (property->is_computed_name()) break; |
| 305 if (property->IsCompileTimeValue()) continue; | 299 if (property->IsCompileTimeValue()) continue; |
| 306 | 300 |
| 307 Literal* key = property->key()->AsLiteral(); | 301 Literal* key = property->key()->AsLiteral(); |
| 308 Expression* value = property->value(); | 302 Expression* value = property->value(); |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 543 | 537 |
| 544 constant_elements_ = literals; | 538 constant_elements_ = literals; |
| 545 set_is_simple(is_simple); | 539 set_is_simple(is_simple); |
| 546 set_depth(depth_acc); | 540 set_depth(depth_acc); |
| 547 } | 541 } |
| 548 | 542 |
| 549 | 543 |
| 550 void ArrayLiteral::AssignFeedbackVectorSlots(Isolate* isolate, | 544 void ArrayLiteral::AssignFeedbackVectorSlots(Isolate* isolate, |
| 551 FeedbackVectorSpec* spec, | 545 FeedbackVectorSpec* spec, |
| 552 FeedbackVectorSlotCache* cache) { | 546 FeedbackVectorSlotCache* cache) { |
| 553 if (!FLAG_vector_stores) return; | |
| 554 | |
| 555 // This logic that computes the number of slots needed for vector store | 547 // This logic that computes the number of slots needed for vector store |
| 556 // ics must mirror FullCodeGenerator::VisitArrayLiteral. | 548 // ics must mirror FullCodeGenerator::VisitArrayLiteral. |
| 557 int array_index = 0; | 549 int array_index = 0; |
| 558 for (; array_index < values()->length(); array_index++) { | 550 for (; array_index < values()->length(); array_index++) { |
| 559 Expression* subexpr = values()->at(array_index); | 551 Expression* subexpr = values()->at(array_index); |
| 560 if (subexpr->IsSpread()) break; | 552 if (subexpr->IsSpread()) break; |
| 561 if (CompileTimeValue::IsCompileTimeValue(subexpr)) continue; | 553 if (CompileTimeValue::IsCompileTimeValue(subexpr)) continue; |
| 562 | 554 |
| 563 // We'll reuse the same literal slot for all of the non-constant | 555 // We'll reuse the same literal slot for all of the non-constant |
| 564 // subexpressions that use a keyed store IC. | 556 // subexpressions that use a keyed store IC. |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 714 void Expression::RecordToBooleanTypeFeedback(TypeFeedbackOracle* oracle) { | 706 void Expression::RecordToBooleanTypeFeedback(TypeFeedbackOracle* oracle) { |
| 715 set_to_boolean_types(oracle->ToBooleanTypes(test_id())); | 707 set_to_boolean_types(oracle->ToBooleanTypes(test_id())); |
| 716 } | 708 } |
| 717 | 709 |
| 718 | 710 |
| 719 bool Call::IsUsingCallFeedbackICSlot(Isolate* isolate) const { | 711 bool Call::IsUsingCallFeedbackICSlot(Isolate* isolate) const { |
| 720 CallType call_type = GetCallType(isolate); | 712 CallType call_type = GetCallType(isolate); |
| 721 if (call_type == POSSIBLY_EVAL_CALL) { | 713 if (call_type == POSSIBLY_EVAL_CALL) { |
| 722 return false; | 714 return false; |
| 723 } | 715 } |
| 724 if (call_type == SUPER_CALL && !FLAG_vector_stores) { | |
| 725 return false; | |
| 726 } | |
| 727 return true; | 716 return true; |
| 728 } | 717 } |
| 729 | 718 |
| 730 | 719 |
| 731 bool Call::IsUsingCallFeedbackSlot(Isolate* isolate) const { | 720 bool Call::IsUsingCallFeedbackSlot(Isolate* isolate) const { |
| 732 // SuperConstructorCall uses a CallConstructStub, which wants | 721 // SuperConstructorCall uses a CallConstructStub, which wants |
| 733 // a Slot, in addition to any IC slots requested elsewhere. | 722 // a Slot, in addition to any IC slots requested elsewhere. |
| 734 return GetCallType(isolate) == SUPER_CALL; | 723 return GetCallType(isolate) == SUPER_CALL; |
| 735 } | 724 } |
| 736 | 725 |
| (...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1152 bool Literal::Match(void* literal1, void* literal2) { | 1141 bool Literal::Match(void* literal1, void* literal2) { |
| 1153 const AstValue* x = static_cast<Literal*>(literal1)->raw_value(); | 1142 const AstValue* x = static_cast<Literal*>(literal1)->raw_value(); |
| 1154 const AstValue* y = static_cast<Literal*>(literal2)->raw_value(); | 1143 const AstValue* y = static_cast<Literal*>(literal2)->raw_value(); |
| 1155 return (x->IsString() && y->IsString() && x->AsString() == y->AsString()) || | 1144 return (x->IsString() && y->IsString() && x->AsString() == y->AsString()) || |
| 1156 (x->IsNumber() && y->IsNumber() && x->AsNumber() == y->AsNumber()); | 1145 (x->IsNumber() && y->IsNumber() && x->AsNumber() == y->AsNumber()); |
| 1157 } | 1146 } |
| 1158 | 1147 |
| 1159 | 1148 |
| 1160 } // namespace internal | 1149 } // namespace internal |
| 1161 } // namespace v8 | 1150 } // namespace v8 |
| OLD | NEW |