OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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/interpreter/interpreter.h" | 5 #include "src/interpreter/interpreter.h" |
6 | 6 |
7 #include <fstream> | 7 #include <fstream> |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "src/ast/prettyprinter.h" | 10 #include "src/ast/prettyprinter.h" |
(...skipping 977 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
988 Node* lhs = __ LoadRegister(reg_index); | 988 Node* lhs = __ LoadRegister(reg_index); |
989 Node* rhs = __ GetAccumulator(); | 989 Node* rhs = __ GetAccumulator(); |
990 Node* context = __ GetContext(); | 990 Node* context = __ GetContext(); |
991 Node* slot_index = __ BytecodeOperandIdx(1); | 991 Node* slot_index = __ BytecodeOperandIdx(1); |
992 Node* type_feedback_vector = __ LoadTypeFeedbackVector(); | 992 Node* type_feedback_vector = __ LoadTypeFeedbackVector(); |
993 | 993 |
994 // TODO(interpreter): the only reason this check is here is because we | 994 // TODO(interpreter): the only reason this check is here is because we |
995 // sometimes emit comparisons that shouldn't collect feedback (e.g. | 995 // sometimes emit comparisons that shouldn't collect feedback (e.g. |
996 // try-finally blocks and generators), and we could get rid of this by | 996 // try-finally blocks and generators), and we could get rid of this by |
997 // introducing Smi equality tests. | 997 // introducing Smi equality tests. |
998 Label skip_feedback_update(assembler); | 998 Label gather_type_feedback(assembler), do_compare(assembler); |
999 __ GotoIf(__ WordEqual(slot_index, __ IntPtrConstant(0)), | 999 __ Branch(__ WordEqual(slot_index, __ IntPtrConstant(0)), &do_compare, |
1000 &skip_feedback_update); | 1000 &gather_type_feedback); |
1001 | 1001 |
1002 Variable var_type_feedback(assembler, MachineRepresentation::kWord32); | 1002 __ Bind(&gather_type_feedback); |
1003 Label lhs_is_smi(assembler), lhs_is_not_smi(assembler), | 1003 { |
1004 gather_rhs_type(assembler), do_compare(assembler); | 1004 Variable var_type_feedback(assembler, MachineRepresentation::kWord32); |
1005 __ Branch(__ TaggedIsSmi(lhs), &lhs_is_smi, &lhs_is_not_smi); | 1005 Label lhs_is_not_smi(assembler), lhs_is_not_number(assembler), |
| 1006 lhs_is_not_string(assembler), gather_rhs_type(assembler), |
| 1007 update_feedback(assembler); |
1006 | 1008 |
1007 __ Bind(&lhs_is_smi); | 1009 __ GotoUnless(__ TaggedIsSmi(lhs), &lhs_is_not_smi); |
1008 var_type_feedback.Bind( | |
1009 __ Int32Constant(CompareOperationFeedback::kSignedSmall)); | |
1010 __ Goto(&gather_rhs_type); | |
1011 | 1010 |
1012 __ Bind(&lhs_is_not_smi); | 1011 var_type_feedback.Bind( |
1013 { | 1012 __ Int32Constant(CompareOperationFeedback::kSignedSmall)); |
1014 Label lhs_is_number(assembler), lhs_is_not_number(assembler); | |
1015 Node* lhs_map = __ LoadMap(lhs); | |
1016 __ Branch(__ WordEqual(lhs_map, __ HeapNumberMapConstant()), &lhs_is_number, | |
1017 &lhs_is_not_number); | |
1018 | |
1019 __ Bind(&lhs_is_number); | |
1020 var_type_feedback.Bind(__ Int32Constant(CompareOperationFeedback::kNumber)); | |
1021 __ Goto(&gather_rhs_type); | 1013 __ Goto(&gather_rhs_type); |
1022 | 1014 |
1023 __ Bind(&lhs_is_not_number); | 1015 __ Bind(&lhs_is_not_smi); |
1024 var_type_feedback.Bind(__ Int32Constant(CompareOperationFeedback::kAny)); | 1016 { |
1025 __ Goto(&do_compare); | 1017 Node* lhs_map = __ LoadMap(lhs); |
1026 } | 1018 __ GotoUnless(__ WordEqual(lhs_map, __ HeapNumberMapConstant()), |
| 1019 &lhs_is_not_number); |
1027 | 1020 |
1028 __ Bind(&gather_rhs_type); | 1021 var_type_feedback.Bind( |
1029 { | 1022 __ Int32Constant(CompareOperationFeedback::kNumber)); |
1030 Label rhs_is_smi(assembler); | 1023 __ Goto(&gather_rhs_type); |
1031 __ GotoIf(__ TaggedIsSmi(rhs), &rhs_is_smi); | |
1032 | 1024 |
1033 Node* rhs_map = __ LoadMap(rhs); | 1025 __ Bind(&lhs_is_not_number); |
1034 Node* rhs_type = | 1026 { |
1035 __ Select(__ WordEqual(rhs_map, __ HeapNumberMapConstant()), | 1027 Node* lhs_instance_type = __ LoadInstanceType(lhs); |
1036 __ Int32Constant(CompareOperationFeedback::kNumber), | 1028 Node* lhs_type = |
1037 __ Int32Constant(CompareOperationFeedback::kAny)); | 1029 __ Select(__ IsStringInstanceType(lhs_instance_type), |
1038 var_type_feedback.Bind(__ Word32Or(var_type_feedback.value(), rhs_type)); | 1030 __ Int32Constant(CompareOperationFeedback::kString), |
1039 __ Goto(&do_compare); | 1031 __ Int32Constant(CompareOperationFeedback::kAny)); |
1040 | 1032 |
1041 __ Bind(&rhs_is_smi); | 1033 var_type_feedback.Bind(lhs_type); |
1042 var_type_feedback.Bind( | 1034 __ Goto(&gather_rhs_type); |
1043 __ Word32Or(var_type_feedback.value(), | 1035 } |
1044 __ Int32Constant(CompareOperationFeedback::kSignedSmall))); | 1036 } |
1045 __ Goto(&do_compare); | 1037 |
| 1038 __ Bind(&gather_rhs_type); |
| 1039 { |
| 1040 Label rhs_is_not_smi(assembler), rhs_is_not_number(assembler); |
| 1041 |
| 1042 __ GotoUnless(__ TaggedIsSmi(rhs), &rhs_is_not_smi); |
| 1043 |
| 1044 var_type_feedback.Bind(__ Word32Or( |
| 1045 var_type_feedback.value(), |
| 1046 __ Int32Constant(CompareOperationFeedback::kSignedSmall))); |
| 1047 __ Goto(&update_feedback); |
| 1048 |
| 1049 __ Bind(&rhs_is_not_smi); |
| 1050 { |
| 1051 Node* rhs_map = __ LoadMap(rhs); |
| 1052 __ GotoUnless(__ WordEqual(rhs_map, __ HeapNumberMapConstant()), |
| 1053 &rhs_is_not_number); |
| 1054 |
| 1055 var_type_feedback.Bind( |
| 1056 __ Word32Or(var_type_feedback.value(), |
| 1057 __ Int32Constant(CompareOperationFeedback::kNumber))); |
| 1058 __ Goto(&update_feedback); |
| 1059 |
| 1060 __ Bind(&rhs_is_not_number); |
| 1061 { |
| 1062 Node* rhs_instance_type = __ LoadInstanceType(rhs); |
| 1063 Node* rhs_type = |
| 1064 __ Select(__ IsStringInstanceType(rhs_instance_type), |
| 1065 __ Int32Constant(CompareOperationFeedback::kString), |
| 1066 __ Int32Constant(CompareOperationFeedback::kAny)); |
| 1067 var_type_feedback.Bind( |
| 1068 __ Word32Or(var_type_feedback.value(), rhs_type)); |
| 1069 __ Goto(&update_feedback); |
| 1070 } |
| 1071 } |
| 1072 } |
| 1073 |
| 1074 __ Bind(&update_feedback); |
| 1075 { |
| 1076 __ UpdateFeedback(var_type_feedback.value(), type_feedback_vector, |
| 1077 slot_index); |
| 1078 __ Goto(&do_compare); |
| 1079 } |
1046 } | 1080 } |
1047 | 1081 |
1048 __ Bind(&do_compare); | 1082 __ Bind(&do_compare); |
1049 __ UpdateFeedback(var_type_feedback.value(), type_feedback_vector, | |
1050 slot_index); | |
1051 __ Goto(&skip_feedback_update); | |
1052 | |
1053 __ Bind(&skip_feedback_update); | |
1054 Node* result; | 1083 Node* result; |
1055 switch (compare_op) { | 1084 switch (compare_op) { |
1056 case Token::EQ: | 1085 case Token::EQ: |
1057 result = assembler->Equal(CodeStubAssembler::kDontNegateResult, lhs, rhs, | 1086 result = assembler->Equal(CodeStubAssembler::kDontNegateResult, lhs, rhs, |
1058 context); | 1087 context); |
1059 break; | 1088 break; |
1060 case Token::NE: | 1089 case Token::NE: |
1061 result = | 1090 result = |
1062 assembler->Equal(CodeStubAssembler::kNegateResult, lhs, rhs, context); | 1091 assembler->Equal(CodeStubAssembler::kNegateResult, lhs, rhs, context); |
1063 break; | 1092 break; |
(...skipping 1641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2705 __ StoreObjectField(generator, JSGeneratorObject::kContinuationOffset, | 2734 __ StoreObjectField(generator, JSGeneratorObject::kContinuationOffset, |
2706 __ SmiTag(new_state)); | 2735 __ SmiTag(new_state)); |
2707 __ SetAccumulator(old_state); | 2736 __ SetAccumulator(old_state); |
2708 | 2737 |
2709 __ Dispatch(); | 2738 __ Dispatch(); |
2710 } | 2739 } |
2711 | 2740 |
2712 } // namespace interpreter | 2741 } // namespace interpreter |
2713 } // namespace internal | 2742 } // namespace internal |
2714 } // namespace v8 | 2743 } // namespace v8 |
OLD | NEW |