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/ast.h" | 5 #include "src/ast/ast.h" |
6 | 6 |
7 #include <cmath> // For isfinite. | 7 #include <cmath> // For isfinite. |
8 | 8 |
9 #include "src/ast/compile-time-value.h" | 9 #include "src/ast/compile-time-value.h" |
10 #include "src/ast/prettyprinter.h" | 10 #include "src/ast/prettyprinter.h" |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 AssignVectorSlots(target(), spec, &slot_); | 262 AssignVectorSlots(target(), spec, &slot_); |
263 } | 263 } |
264 | 264 |
265 | 265 |
266 void CountOperation::AssignFeedbackVectorSlots(Isolate* isolate, | 266 void CountOperation::AssignFeedbackVectorSlots(Isolate* isolate, |
267 FeedbackVectorSpec* spec, | 267 FeedbackVectorSpec* spec, |
268 FeedbackVectorSlotCache* cache) { | 268 FeedbackVectorSlotCache* cache) { |
269 AssignVectorSlots(expression(), spec, &slot_); | 269 AssignVectorSlots(expression(), spec, &slot_); |
270 // Assign a slot to collect feedback about binary operations. Used only in | 270 // Assign a slot to collect feedback about binary operations. Used only in |
271 // ignition. Fullcodegen uses AstId to record type feedback. | 271 // ignition. Fullcodegen uses AstId to record type feedback. |
272 binary_operation_slot_ = spec->AddGeneralSlot(); | 272 binary_operation_slot_ = spec->AddInterpreterBinaryOpICSlot(); |
273 } | 273 } |
274 | 274 |
275 | 275 |
276 Token::Value Assignment::binary_op() const { | 276 Token::Value Assignment::binary_op() const { |
277 switch (op()) { | 277 switch (op()) { |
278 case Token::ASSIGN_BIT_OR: return Token::BIT_OR; | 278 case Token::ASSIGN_BIT_OR: return Token::BIT_OR; |
279 case Token::ASSIGN_BIT_XOR: return Token::BIT_XOR; | 279 case Token::ASSIGN_BIT_XOR: return Token::BIT_XOR; |
280 case Token::ASSIGN_BIT_AND: return Token::BIT_AND; | 280 case Token::ASSIGN_BIT_AND: return Token::BIT_AND; |
281 case Token::ASSIGN_SHL: return Token::SHL; | 281 case Token::ASSIGN_SHL: return Token::SHL; |
282 case Token::ASSIGN_SAR: return Token::SAR; | 282 case Token::ASSIGN_SAR: return Token::SAR; |
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
712 FeedbackVectorSlotCache* cache) { | 712 FeedbackVectorSlotCache* cache) { |
713 // Feedback vector slot is only used by interpreter for binary operations. | 713 // Feedback vector slot is only used by interpreter for binary operations. |
714 // Full-codegen uses AstId to record type feedback. | 714 // Full-codegen uses AstId to record type feedback. |
715 switch (op()) { | 715 switch (op()) { |
716 // Comma, logical_or and logical_and do not collect type feedback. | 716 // Comma, logical_or and logical_and do not collect type feedback. |
717 case Token::COMMA: | 717 case Token::COMMA: |
718 case Token::AND: | 718 case Token::AND: |
719 case Token::OR: | 719 case Token::OR: |
720 return; | 720 return; |
721 default: | 721 default: |
722 type_feedback_slot_ = spec->AddGeneralSlot(); | 722 type_feedback_slot_ = spec->AddInterpreterBinaryOpICSlot(); |
723 return; | 723 return; |
724 } | 724 } |
725 } | 725 } |
726 | 726 |
727 static bool IsTypeof(Expression* expr) { | 727 static bool IsTypeof(Expression* expr) { |
728 UnaryOperation* maybe_unary = expr->AsUnaryOperation(); | 728 UnaryOperation* maybe_unary = expr->AsUnaryOperation(); |
729 return maybe_unary != NULL && maybe_unary->op() == Token::TYPEOF; | 729 return maybe_unary != NULL && maybe_unary->op() == Token::TYPEOF; |
730 } | 730 } |
731 | 731 |
732 void CompareOperation::AssignFeedbackVectorSlots( | 732 void CompareOperation::AssignFeedbackVectorSlots( |
733 Isolate* isolate, FeedbackVectorSpec* spec, | 733 Isolate* isolate, FeedbackVectorSpec* spec, |
734 FeedbackVectorSlotCache* cache_) { | 734 FeedbackVectorSlotCache* cache_) { |
735 // Feedback vector slot is only used by interpreter for binary operations. | 735 // Feedback vector slot is only used by interpreter for binary operations. |
736 // Full-codegen uses AstId to record type feedback. | 736 // Full-codegen uses AstId to record type feedback. |
737 switch (op()) { | 737 switch (op()) { |
738 // instanceof and in do not collect type feedback. | 738 // instanceof and in do not collect type feedback. |
739 case Token::INSTANCEOF: | 739 case Token::INSTANCEOF: |
740 case Token::IN: | 740 case Token::IN: |
741 return; | 741 return; |
742 default: | 742 default: |
743 type_feedback_slot_ = spec->AddGeneralSlot(); | 743 type_feedback_slot_ = spec->AddInterpreterCompareICSlot(); |
744 } | 744 } |
745 } | 745 } |
746 | 746 |
747 // Check for the pattern: typeof <expression> equals <string literal>. | 747 // Check for the pattern: typeof <expression> equals <string literal>. |
748 static bool MatchLiteralCompareTypeof(Expression* left, | 748 static bool MatchLiteralCompareTypeof(Expression* left, |
749 Token::Value op, | 749 Token::Value op, |
750 Expression* right, | 750 Expression* right, |
751 Expression** expr, | 751 Expression** expr, |
752 Handle<String>* check) { | 752 Handle<String>* check) { |
753 if (IsTypeof(left) && right->IsStringLiteral() && Token::IsEqualityOp(op)) { | 753 if (IsTypeof(left) && right->IsStringLiteral() && Token::IsEqualityOp(op)) { |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
940 CaseClause::CaseClause(Expression* label, ZoneList<Statement*>* statements, | 940 CaseClause::CaseClause(Expression* label, ZoneList<Statement*>* statements, |
941 int pos) | 941 int pos) |
942 : Expression(pos, kCaseClause), | 942 : Expression(pos, kCaseClause), |
943 label_(label), | 943 label_(label), |
944 statements_(statements), | 944 statements_(statements), |
945 compare_type_(AstType::None()) {} | 945 compare_type_(AstType::None()) {} |
946 | 946 |
947 void CaseClause::AssignFeedbackVectorSlots(Isolate* isolate, | 947 void CaseClause::AssignFeedbackVectorSlots(Isolate* isolate, |
948 FeedbackVectorSpec* spec, | 948 FeedbackVectorSpec* spec, |
949 FeedbackVectorSlotCache* cache) { | 949 FeedbackVectorSlotCache* cache) { |
950 type_feedback_slot_ = spec->AddGeneralSlot(); | 950 type_feedback_slot_ = spec->AddInterpreterCompareICSlot(); |
951 } | 951 } |
952 | 952 |
953 uint32_t Literal::Hash() { | 953 uint32_t Literal::Hash() { |
954 return raw_value()->IsString() | 954 return raw_value()->IsString() |
955 ? raw_value()->AsString()->hash() | 955 ? raw_value()->AsString()->hash() |
956 : ComputeLongHash(double_to_uint64(raw_value()->AsNumber())); | 956 : ComputeLongHash(double_to_uint64(raw_value()->AsNumber())); |
957 } | 957 } |
958 | 958 |
959 | 959 |
960 // static | 960 // static |
961 bool Literal::Match(void* literal1, void* literal2) { | 961 bool Literal::Match(void* literal1, void* literal2) { |
962 const AstValue* x = static_cast<Literal*>(literal1)->raw_value(); | 962 const AstValue* x = static_cast<Literal*>(literal1)->raw_value(); |
963 const AstValue* y = static_cast<Literal*>(literal2)->raw_value(); | 963 const AstValue* y = static_cast<Literal*>(literal2)->raw_value(); |
964 return (x->IsString() && y->IsString() && x->AsString() == y->AsString()) || | 964 return (x->IsString() && y->IsString() && x->AsString() == y->AsString()) || |
965 (x->IsNumber() && y->IsNumber() && x->AsNumber() == y->AsNumber()); | 965 (x->IsNumber() && y->IsNumber() && x->AsNumber() == y->AsNumber()); |
966 } | 966 } |
967 | 967 |
968 } // namespace internal | 968 } // namespace internal |
969 } // namespace v8 | 969 } // namespace v8 |
OLD | NEW |