| 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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 | 83 |
| 84 | 84 |
| 85 void VariableProxy::BindTo(Variable* var) { | 85 void VariableProxy::BindTo(Variable* var) { |
| 86 DCHECK((is_this() && var->is_this()) || raw_name() == var->raw_name()); | 86 DCHECK((is_this() && var->is_this()) || raw_name() == var->raw_name()); |
| 87 set_var(var); | 87 set_var(var); |
| 88 set_is_resolved(); | 88 set_is_resolved(); |
| 89 var->set_is_used(); | 89 var->set_is_used(); |
| 90 } | 90 } |
| 91 | 91 |
| 92 | 92 |
| 93 void VariableProxy::SetFirstFeedbackICSlot(FeedbackVectorICSlot slot, |
| 94 ICSlotCache* cache) { |
| 95 variable_feedback_slot_ = slot; |
| 96 if (var()->IsUnallocated()) { |
| 97 cache->Add(VariableICSlotPair(var(), slot)); |
| 98 } |
| 99 } |
| 100 |
| 101 |
| 102 FeedbackVectorRequirements VariableProxy::ComputeFeedbackRequirements( |
| 103 Isolate* isolate, const ICSlotCache* cache) { |
| 104 if (UsesVariableFeedbackSlot()) { |
| 105 // VariableProxies that point to the same Variable within a function can |
| 106 // make their loads from the same IC slot. |
| 107 if (var()->IsUnallocated()) { |
| 108 for (int i = 0; i < cache->length(); i++) { |
| 109 VariableICSlotPair& pair = cache->at(i); |
| 110 if (pair.variable() == var()) { |
| 111 variable_feedback_slot_ = pair.slot(); |
| 112 return FeedbackVectorRequirements(0, 0); |
| 113 } |
| 114 } |
| 115 } |
| 116 return FeedbackVectorRequirements(0, 1); |
| 117 } |
| 118 return FeedbackVectorRequirements(0, 0); |
| 119 } |
| 120 |
| 121 |
| 93 Assignment::Assignment(Zone* zone, Token::Value op, Expression* target, | 122 Assignment::Assignment(Zone* zone, Token::Value op, Expression* target, |
| 94 Expression* value, int pos) | 123 Expression* value, int pos) |
| 95 : Expression(zone, pos), | 124 : Expression(zone, pos), |
| 96 bit_field_(IsUninitializedField::encode(false) | | 125 bit_field_(IsUninitializedField::encode(false) | |
| 97 KeyTypeField::encode(ELEMENT) | | 126 KeyTypeField::encode(ELEMENT) | |
| 98 StoreModeField::encode(STANDARD_STORE) | | 127 StoreModeField::encode(STANDARD_STORE) | |
| 99 TokenField::encode(op)), | 128 TokenField::encode(op)), |
| 100 target_(target), | 129 target_(target), |
| 101 value_(value), | 130 value_(value), |
| 102 binary_operation_(NULL) {} | 131 binary_operation_(NULL) {} |
| (...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 557 } | 586 } |
| 558 | 587 |
| 559 | 588 |
| 560 bool Call::IsUsingCallFeedbackSlot(Isolate* isolate) const { | 589 bool Call::IsUsingCallFeedbackSlot(Isolate* isolate) const { |
| 561 // SuperConstructorCall uses a CallConstructStub, which wants | 590 // SuperConstructorCall uses a CallConstructStub, which wants |
| 562 // a Slot, not an IC slot. | 591 // a Slot, not an IC slot. |
| 563 return GetCallType(isolate) == SUPER_CALL; | 592 return GetCallType(isolate) == SUPER_CALL; |
| 564 } | 593 } |
| 565 | 594 |
| 566 | 595 |
| 567 FeedbackVectorRequirements Call::ComputeFeedbackRequirements(Isolate* isolate) { | 596 FeedbackVectorRequirements Call::ComputeFeedbackRequirements( |
| 597 Isolate* isolate, const ICSlotCache* cache) { |
| 568 int ic_slots = IsUsingCallFeedbackICSlot(isolate) ? 1 : 0; | 598 int ic_slots = IsUsingCallFeedbackICSlot(isolate) ? 1 : 0; |
| 569 int slots = IsUsingCallFeedbackSlot(isolate) ? 1 : 0; | 599 int slots = IsUsingCallFeedbackSlot(isolate) ? 1 : 0; |
| 570 // A Call uses either a slot or an IC slot. | 600 // A Call uses either a slot or an IC slot. |
| 571 DCHECK((ic_slots & slots) == 0); | 601 DCHECK((ic_slots & slots) == 0); |
| 572 return FeedbackVectorRequirements(slots, ic_slots); | 602 return FeedbackVectorRequirements(slots, ic_slots); |
| 573 } | 603 } |
| 574 | 604 |
| 575 | 605 |
| 576 Call::CallType Call::GetCallType(Isolate* isolate) const { | 606 Call::CallType Call::GetCallType(Isolate* isolate) const { |
| 577 VariableProxy* proxy = expression()->AsVariableProxy(); | 607 VariableProxy* proxy = expression()->AsVariableProxy(); |
| (...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 989 // static | 1019 // static |
| 990 bool Literal::Match(void* literal1, void* literal2) { | 1020 bool Literal::Match(void* literal1, void* literal2) { |
| 991 const AstValue* x = static_cast<Literal*>(literal1)->raw_value(); | 1021 const AstValue* x = static_cast<Literal*>(literal1)->raw_value(); |
| 992 const AstValue* y = static_cast<Literal*>(literal2)->raw_value(); | 1022 const AstValue* y = static_cast<Literal*>(literal2)->raw_value(); |
| 993 return (x->IsString() && y->IsString() && *x->AsString() == *y->AsString()) || | 1023 return (x->IsString() && y->IsString() && *x->AsString() == *y->AsString()) || |
| 994 (x->IsNumber() && y->IsNumber() && x->AsNumber() == y->AsNumber()); | 1024 (x->IsNumber() && y->IsNumber() && x->AsNumber() == y->AsNumber()); |
| 995 } | 1025 } |
| 996 | 1026 |
| 997 | 1027 |
| 998 } } // namespace v8::internal | 1028 } } // namespace v8::internal |
| OLD | NEW |