Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(44)

Side by Side Diff: src/interpreter/interpreter.cc

Issue 2235133003: [interpreter] Collect type feedback from bitwise binary ops handlers. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Update. Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/compiler/bytecode-graph-builder.cc ('k') | src/interpreter/interpreter-assembler.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 797 matching lines...) Expand 10 before | Expand all | Expand 10 after
808 // 808 //
809 // Modulo register <src> by accumulator. 809 // Modulo register <src> by accumulator.
810 void Interpreter::DoMod(InterpreterAssembler* assembler) { 810 void Interpreter::DoMod(InterpreterAssembler* assembler) {
811 DoBinaryOpWithFeedback<ModulusWithFeedbackStub>(assembler); 811 DoBinaryOpWithFeedback<ModulusWithFeedbackStub>(assembler);
812 } 812 }
813 813
814 // BitwiseOr <src> 814 // BitwiseOr <src>
815 // 815 //
816 // BitwiseOr register <src> to accumulator. 816 // BitwiseOr register <src> to accumulator.
817 void Interpreter::DoBitwiseOr(InterpreterAssembler* assembler) { 817 void Interpreter::DoBitwiseOr(InterpreterAssembler* assembler) {
818 DoBinaryOp<BitwiseOrStub>(assembler); 818 typedef InterpreterAssembler::Label Label;
819 typedef InterpreterAssembler::Variable Variable;
rmcilroy 2016/08/11 13:31:07 Typedefs are unecessary here
epertoso 2016/08/11 14:03:11 Done.
820
821 Node* reg_index = __ BytecodeOperandReg(0);
822 Node* lhs = __ LoadRegister(reg_index);
823 Node* rhs = __ GetAccumulator();
824 Node* context = __ GetContext();
825 Node* slot_index = __ BytecodeOperandIdx(1);
826 Node* type_feedback_vector = __ LoadTypeFeedbackVector();
827
828 Variable var_lhs_type_feedback(assembler, MachineRepresentation::kWord32),
829 var_rhs_type_feedback(assembler, MachineRepresentation::kWord32);
830 Node* lhs_value = __ TruncateTaggedToWord32WithFeedback(
831 context, lhs, &var_lhs_type_feedback);
832 Node* rhs_value = __ TruncateTaggedToWord32WithFeedback(
833 context, rhs, &var_rhs_type_feedback);
834 Node* value = __ Word32Or(lhs_value, rhs_value);
835 Node* result = __ ChangeInt32ToTagged(value);
836
837 Node* result_type =
838 __ Select(__ WordIsSmi(result),
839 __ Int32Constant(BinaryOperationFeedback::kSignedSmall),
840 __ Int32Constant(BinaryOperationFeedback::kNumber));
841
842 if (FLAG_debug_code) {
843 Label ok(assembler);
844 __ GotoIf(__ WordIsSmi(result), &ok);
845 Node* result_map = __ LoadMap(result);
846 __ AbortIfWordNotEqual(result_map, __ HeapNumberMapConstant(),
847 kExpectedHeapNumber);
848 __ Bind(&ok);
849 }
850
851 Node* input_feedback =
852 __ Word32Or(var_lhs_type_feedback.value(), var_rhs_type_feedback.value());
853 __ UpdateFeedback(__ Word32Or(result_type, input_feedback),
854 type_feedback_vector, slot_index);
855 __ SetAccumulator(result);
856 __ Dispatch();
rmcilroy 2016/08/11 13:31:07 Could we share all the code in a single helper whi
epertoso 2016/08/11 14:03:11 Done.
819 } 857 }
820 858
821 // BitwiseXor <src> 859 // BitwiseXor <src>
822 // 860 //
823 // BitwiseXor register <src> to accumulator. 861 // BitwiseXor register <src> to accumulator.
824 void Interpreter::DoBitwiseXor(InterpreterAssembler* assembler) { 862 void Interpreter::DoBitwiseXor(InterpreterAssembler* assembler) {
825 DoBinaryOp<BitwiseXorStub>(assembler); 863 typedef InterpreterAssembler::Label Label;
864 typedef InterpreterAssembler::Variable Variable;
865
866 Node* reg_index = __ BytecodeOperandReg(0);
867 Node* lhs = __ LoadRegister(reg_index);
868 Node* rhs = __ GetAccumulator();
869 Node* context = __ GetContext();
870 Node* slot_index = __ BytecodeOperandIdx(1);
871 Node* type_feedback_vector = __ LoadTypeFeedbackVector();
872
873 Variable var_lhs_type_feedback(assembler, MachineRepresentation::kWord32),
874 var_rhs_type_feedback(assembler, MachineRepresentation::kWord32);
875 Node* lhs_value = __ TruncateTaggedToWord32WithFeedback(
876 context, lhs, &var_lhs_type_feedback);
877 Node* rhs_value = __ TruncateTaggedToWord32WithFeedback(
878 context, rhs, &var_rhs_type_feedback);
879 Node* value = __ Word32Xor(lhs_value, rhs_value);
880 Node* result = __ ChangeInt32ToTagged(value);
881
882 Node* result_type =
883 __ Select(__ WordIsSmi(result),
884 __ Int32Constant(BinaryOperationFeedback::kSignedSmall),
885 __ Int32Constant(BinaryOperationFeedback::kNumber));
886
887 if (FLAG_debug_code) {
888 Label ok(assembler);
889 __ GotoIf(__ WordIsSmi(result), &ok);
890 Node* result_map = __ LoadMap(result);
891 __ AbortIfWordNotEqual(result_map, __ HeapNumberMapConstant(),
892 kExpectedHeapNumber);
893 __ Bind(&ok);
894 }
895
896 Node* input_feedback =
897 __ Word32Or(var_lhs_type_feedback.value(), var_rhs_type_feedback.value());
898 __ UpdateFeedback(__ Word32Or(result_type, input_feedback),
899 type_feedback_vector, slot_index);
900 __ SetAccumulator(result);
901 __ Dispatch();
826 } 902 }
827 903
828 // BitwiseAnd <src> 904 // BitwiseAnd <src>
829 // 905 //
830 // BitwiseAnd register <src> to accumulator. 906 // BitwiseAnd register <src> to accumulator.
831 void Interpreter::DoBitwiseAnd(InterpreterAssembler* assembler) { 907 void Interpreter::DoBitwiseAnd(InterpreterAssembler* assembler) {
832 DoBinaryOp<BitwiseAndStub>(assembler); 908 typedef InterpreterAssembler::Label Label;
909 typedef InterpreterAssembler::Variable Variable;
910
911 Node* reg_index = __ BytecodeOperandReg(0);
912 Node* lhs = __ LoadRegister(reg_index);
913 Node* rhs = __ GetAccumulator();
914 Node* context = __ GetContext();
915 Node* slot_index = __ BytecodeOperandIdx(1);
916 Node* type_feedback_vector = __ LoadTypeFeedbackVector();
917
918 Variable var_lhs_type_feedback(assembler, MachineRepresentation::kWord32),
919 var_rhs_type_feedback(assembler, MachineRepresentation::kWord32);
920 Node* lhs_value = __ TruncateTaggedToWord32WithFeedback(
921 context, lhs, &var_lhs_type_feedback);
922 Node* rhs_value = __ TruncateTaggedToWord32WithFeedback(
923 context, rhs, &var_rhs_type_feedback);
924 Node* value = __ Word32And(lhs_value, rhs_value);
925 Node* result = __ ChangeInt32ToTagged(value);
926
927 Node* result_type =
928 __ Select(__ WordIsSmi(result),
929 __ Int32Constant(BinaryOperationFeedback::kSignedSmall),
930 __ Int32Constant(BinaryOperationFeedback::kNumber));
931
932 if (FLAG_debug_code) {
933 Label ok(assembler);
934 __ GotoIf(__ WordIsSmi(result), &ok);
935 Node* result_map = __ LoadMap(result);
936 __ AbortIfWordNotEqual(result_map, __ HeapNumberMapConstant(),
937 kExpectedHeapNumber);
938 __ Bind(&ok);
939 }
940
941 Node* input_feedback =
942 __ Word32Or(var_lhs_type_feedback.value(), var_rhs_type_feedback.value());
943 __ UpdateFeedback(__ Word32Or(result_type, input_feedback),
944 type_feedback_vector, slot_index);
945 __ SetAccumulator(result);
946 __ Dispatch();
833 } 947 }
834 948
835 // ShiftLeft <src> 949 // ShiftLeft <src>
836 // 950 //
837 // Left shifts register <src> by the count specified in the accumulator. 951 // Left shifts register <src> by the count specified in the accumulator.
838 // Register <src> is converted to an int32 and the accumulator to uint32 952 // Register <src> is converted to an int32 and the accumulator to uint32
839 // before the operation. 5 lsb bits from the accumulator are used as count 953 // before the operation. 5 lsb bits from the accumulator are used as count
840 // i.e. <src> << (accumulator & 0x1F). 954 // i.e. <src> << (accumulator & 0x1F).
841 void Interpreter::DoShiftLeft(InterpreterAssembler* assembler) { 955 void Interpreter::DoShiftLeft(InterpreterAssembler* assembler) {
842 DoBinaryOp<ShiftLeftStub>(assembler); 956 typedef InterpreterAssembler::Variable Variable;
957
958 Node* reg_index = __ BytecodeOperandReg(0);
959 Node* lhs = __ LoadRegister(reg_index);
960 Node* rhs = __ GetAccumulator();
961 Node* context = __ GetContext();
962 Node* slot_index = __ BytecodeOperandIdx(1);
963 Node* type_feedback_vector = __ LoadTypeFeedbackVector();
964
965 Variable var_lhs_type_feedback(assembler, MachineRepresentation::kWord32),
966 var_rhs_type_feedback(assembler, MachineRepresentation::kWord32);
967 Node* lhs_value = __ TruncateTaggedToWord32WithFeedback(
968 context, lhs, &var_lhs_type_feedback);
969 Node* rhs_value = __ TruncateTaggedToWord32WithFeedback(
970 context, rhs, &var_rhs_type_feedback);
971 Node* shift_count = __ Word32And(rhs_value, __ Int32Constant(0x1f));
972 Node* value = __ Word32Shl(lhs_value, shift_count);
973 Node* result = __ ChangeInt32ToTagged(value);
974
975 Node* result_type =
976 __ Select(__ WordIsSmi(result),
977 __ Int32Constant(BinaryOperationFeedback::kSignedSmall),
978 __ Int32Constant(BinaryOperationFeedback::kNumber));
979
980 if (FLAG_debug_code) {
981 InterpreterAssembler::Label ok(assembler);
982 __ GotoIf(__ WordIsSmi(result), &ok);
983 Node* result_map = __ LoadMap(result);
984 __ AbortIfWordNotEqual(result_map, __ HeapNumberMapConstant(),
985 kExpectedHeapNumber);
986 __ Bind(&ok);
987 }
988
989 Node* input_feedback =
990 __ Word32Or(var_lhs_type_feedback.value(), var_rhs_type_feedback.value());
991 __ UpdateFeedback(__ Word32Or(result_type, input_feedback),
992 type_feedback_vector, slot_index);
993 __ SetAccumulator(result);
994 __ Dispatch();
843 } 995 }
844 996
845 // ShiftRight <src> 997 // ShiftRight <src>
846 // 998 //
847 // Right shifts register <src> by the count specified in the accumulator. 999 // Right shifts register <src> by the count specified in the accumulator.
848 // Result is sign extended. Register <src> is converted to an int32 and the 1000 // Result is sign extended. Register <src> is converted to an int32 and the
849 // accumulator to uint32 before the operation. 5 lsb bits from the accumulator 1001 // accumulator to uint32 before the operation. 5 lsb bits from the accumulator
850 // are used as count i.e. <src> >> (accumulator & 0x1F). 1002 // are used as count i.e. <src> >> (accumulator & 0x1F).
851 void Interpreter::DoShiftRight(InterpreterAssembler* assembler) { 1003 void Interpreter::DoShiftRight(InterpreterAssembler* assembler) {
852 DoBinaryOp<ShiftRightStub>(assembler); 1004 typedef InterpreterAssembler::Variable Variable;
1005
1006 Node* reg_index = __ BytecodeOperandReg(0);
1007 Node* lhs = __ LoadRegister(reg_index);
1008 Node* rhs = __ GetAccumulator();
1009 Node* context = __ GetContext();
1010 Node* slot_index = __ BytecodeOperandIdx(1);
1011 Node* type_feedback_vector = __ LoadTypeFeedbackVector();
1012
1013 Variable var_lhs_type_feedback(assembler, MachineRepresentation::kWord32),
1014 var_rhs_type_feedback(assembler, MachineRepresentation::kWord32);
1015 Node* lhs_value = __ TruncateTaggedToWord32WithFeedback(
1016 context, lhs, &var_lhs_type_feedback);
1017 Node* rhs_value = __ TruncateTaggedToWord32WithFeedback(
1018 context, rhs, &var_rhs_type_feedback);
1019 Node* shift_count = __ Word32And(rhs_value, __ Int32Constant(0x1f));
1020 Node* value = __ Word32Sar(lhs_value, shift_count);
1021 Node* result = __ ChangeInt32ToTagged(value);
1022
1023 Node* result_type =
1024 __ Select(__ WordIsSmi(result),
1025 __ Int32Constant(BinaryOperationFeedback::kSignedSmall),
1026 __ Int32Constant(BinaryOperationFeedback::kNumber));
1027
1028 if (FLAG_debug_code) {
1029 InterpreterAssembler::Label ok(assembler);
1030 __ GotoIf(__ WordIsSmi(result), &ok);
1031 Node* result_map = __ LoadMap(result);
1032 __ AbortIfWordNotEqual(result_map, __ HeapNumberMapConstant(),
1033 kExpectedHeapNumber);
1034 __ Bind(&ok);
1035 }
1036
1037 Node* input_feedback =
1038 __ Word32Or(var_lhs_type_feedback.value(), var_rhs_type_feedback.value());
1039 __ UpdateFeedback(__ Word32Or(result_type, input_feedback),
1040 type_feedback_vector, slot_index);
1041 __ SetAccumulator(result);
1042 __ Dispatch();
853 } 1043 }
854 1044
855 // ShiftRightLogical <src> 1045 // ShiftRightLogical <src>
856 // 1046 //
857 // Right Shifts register <src> by the count specified in the accumulator. 1047 // Right Shifts register <src> by the count specified in the accumulator.
858 // Result is zero-filled. The accumulator and register <src> are converted to 1048 // Result is zero-filled. The accumulator and register <src> are converted to
859 // uint32 before the operation 5 lsb bits from the accumulator are used as 1049 // uint32 before the operation 5 lsb bits from the accumulator are used as
860 // count i.e. <src> << (accumulator & 0x1F). 1050 // count i.e. <src> << (accumulator & 0x1F).
861 void Interpreter::DoShiftRightLogical(InterpreterAssembler* assembler) { 1051 void Interpreter::DoShiftRightLogical(InterpreterAssembler* assembler) {
862 DoBinaryOp<ShiftRightLogicalStub>(assembler); 1052 typedef InterpreterAssembler::Variable Variable;
1053
1054 Node* reg_index = __ BytecodeOperandReg(0);
1055 Node* lhs = __ LoadRegister(reg_index);
1056 Node* rhs = __ GetAccumulator();
1057 Node* context = __ GetContext();
1058 Node* slot_index = __ BytecodeOperandIdx(1);
1059 Node* type_feedback_vector = __ LoadTypeFeedbackVector();
1060
1061 Variable var_lhs_type_feedback(assembler, MachineRepresentation::kWord32),
1062 var_rhs_type_feedback(assembler, MachineRepresentation::kWord32);
1063 Node* lhs_value = __ TruncateTaggedToWord32WithFeedback(
1064 context, lhs, &var_lhs_type_feedback);
1065 Node* rhs_value = __ TruncateTaggedToWord32WithFeedback(
1066 context, rhs, &var_rhs_type_feedback);
1067 Node* shift_count = __ Word32And(rhs_value, __ Int32Constant(0x1f));
1068 Node* value = __ Word32Shr(lhs_value, shift_count);
1069 Node* result = __ ChangeUint32ToTagged(value);
1070
1071 Node* result_type =
1072 __ Select(__ WordIsSmi(result),
1073 __ Int32Constant(BinaryOperationFeedback::kSignedSmall),
1074 __ Int32Constant(BinaryOperationFeedback::kNumber));
1075
1076 if (FLAG_debug_code) {
1077 InterpreterAssembler::Label ok(assembler);
1078 __ GotoIf(__ WordIsSmi(result), &ok);
1079 Node* result_map = __ LoadMap(result);
1080 __ AbortIfWordNotEqual(result_map, __ HeapNumberMapConstant(),
1081 kExpectedHeapNumber);
1082 __ Bind(&ok);
1083 }
1084
1085 Node* input_feedback =
1086 __ Word32Or(var_lhs_type_feedback.value(), var_rhs_type_feedback.value());
1087 __ UpdateFeedback(__ Word32Or(result_type, input_feedback),
1088 type_feedback_vector, slot_index);
1089 __ SetAccumulator(result);
1090 __ Dispatch();
863 } 1091 }
864 1092
865 // AddSmi <imm> <reg> 1093 // AddSmi <imm> <reg>
866 // 1094 //
867 // Adds an immediate value <imm> to register <reg>. For this 1095 // Adds an immediate value <imm> to register <reg>. For this
868 // operation <reg> is the lhs operand and <imm> is the <rhs> operand. 1096 // operation <reg> is the lhs operand and <imm> is the <rhs> operand.
869 void Interpreter::DoAddSmi(InterpreterAssembler* assembler) { 1097 void Interpreter::DoAddSmi(InterpreterAssembler* assembler) {
870 Variable var_result(assembler, MachineRepresentation::kTagged); 1098 Variable var_result(assembler, MachineRepresentation::kTagged);
871 Label fastpath(assembler), slowpath(assembler, Label::kDeferred), 1099 Label fastpath(assembler), slowpath(assembler, Label::kDeferred),
872 end(assembler); 1100 end(assembler);
(...skipping 1290 matching lines...) Expand 10 before | Expand all | Expand 10 after
2163 __ StoreObjectField(generator, JSGeneratorObject::kContinuationOffset, 2391 __ StoreObjectField(generator, JSGeneratorObject::kContinuationOffset,
2164 __ SmiTag(new_state)); 2392 __ SmiTag(new_state));
2165 __ SetAccumulator(old_state); 2393 __ SetAccumulator(old_state);
2166 2394
2167 __ Dispatch(); 2395 __ Dispatch();
2168 } 2396 }
2169 2397
2170 } // namespace interpreter 2398 } // namespace interpreter
2171 } // namespace internal 2399 } // namespace internal
2172 } // namespace v8 2400 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/bytecode-graph-builder.cc ('k') | src/interpreter/interpreter-assembler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698