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

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: Fixed mapping kSignedSmall -> kSigned32 to kSignedSmall -> kSignedSmall. 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/interpreter/interpreter.h ('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 793 matching lines...) Expand 10 before | Expand all | Expand 10 after
804 DoBinaryOpWithFeedback<DivideWithFeedbackStub>(assembler); 804 DoBinaryOpWithFeedback<DivideWithFeedbackStub>(assembler);
805 } 805 }
806 806
807 // Mod <src> 807 // Mod <src>
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 void Interpreter::DoBitwiseBinaryOp(Token::Value bitwise_op,
815 InterpreterAssembler* assembler) {
816 Node* reg_index = __ BytecodeOperandReg(0);
817 Node* lhs = __ LoadRegister(reg_index);
818 Node* rhs = __ GetAccumulator();
819 Node* context = __ GetContext();
820 Node* slot_index = __ BytecodeOperandIdx(1);
821 Node* type_feedback_vector = __ LoadTypeFeedbackVector();
822
823 Variable var_lhs_type_feedback(assembler, MachineRepresentation::kWord32),
824 var_rhs_type_feedback(assembler, MachineRepresentation::kWord32);
825 Node* lhs_value = __ TruncateTaggedToWord32WithFeedback(
826 context, lhs, &var_lhs_type_feedback);
827 Node* rhs_value = __ TruncateTaggedToWord32WithFeedback(
828 context, rhs, &var_rhs_type_feedback);
829 Node* result = nullptr;
830
831 switch (bitwise_op) {
832 case Token::BIT_OR: {
833 Node* value = __ Word32Or(lhs_value, rhs_value);
834 result = __ ChangeInt32ToTagged(value);
835 } break;
836 case Token::BIT_AND: {
837 Node* value = __ Word32And(lhs_value, rhs_value);
838 result = __ ChangeInt32ToTagged(value);
839 } break;
840 case Token::BIT_XOR: {
841 Node* value = __ Word32Xor(lhs_value, rhs_value);
842 result = __ ChangeInt32ToTagged(value);
843 } break;
844 case Token::SHL: {
845 Node* value = __ Word32Shl(
846 lhs_value, __ Word32And(rhs_value, __ Int32Constant(0x1f)));
847 result = __ ChangeInt32ToTagged(value);
848 } break;
849 case Token::SHR: {
850 Node* value = __ Word32Shr(
851 lhs_value, __ Word32And(rhs_value, __ Int32Constant(0x1f)));
852 result = __ ChangeUint32ToTagged(value);
853 } break;
854 case Token::SAR: {
855 Node* value = __ Word32Sar(
856 lhs_value, __ Word32And(rhs_value, __ Int32Constant(0x1f)));
857 result = __ ChangeInt32ToTagged(value);
858 } break;
859 default:
860 UNREACHABLE();
861 }
862
863 Node* result_type =
864 __ Select(__ WordIsSmi(result),
865 __ Int32Constant(BinaryOperationFeedback::kSignedSmall),
866 __ Int32Constant(BinaryOperationFeedback::kNumber));
867
868 if (FLAG_debug_code) {
869 Label ok(assembler);
870 __ GotoIf(__ WordIsSmi(result), &ok);
871 Node* result_map = __ LoadMap(result);
872 __ AbortIfWordNotEqual(result_map, __ HeapNumberMapConstant(),
873 kExpectedHeapNumber);
874 __ Goto(&ok);
875 __ Bind(&ok);
876 }
877
878 Node* input_feedback =
879 __ Word32Or(var_lhs_type_feedback.value(), var_rhs_type_feedback.value());
880 __ UpdateFeedback(__ Word32Or(result_type, input_feedback),
881 type_feedback_vector, slot_index);
882 __ SetAccumulator(result);
883 __ Dispatch();
884 }
885
814 // BitwiseOr <src> 886 // BitwiseOr <src>
815 // 887 //
816 // BitwiseOr register <src> to accumulator. 888 // BitwiseOr register <src> to accumulator.
817 void Interpreter::DoBitwiseOr(InterpreterAssembler* assembler) { 889 void Interpreter::DoBitwiseOr(InterpreterAssembler* assembler) {
818 DoBinaryOp<BitwiseOrStub>(assembler); 890 DoBitwiseBinaryOp(Token::BIT_OR, assembler);
819 } 891 }
820 892
821 // BitwiseXor <src> 893 // BitwiseXor <src>
822 // 894 //
823 // BitwiseXor register <src> to accumulator. 895 // BitwiseXor register <src> to accumulator.
824 void Interpreter::DoBitwiseXor(InterpreterAssembler* assembler) { 896 void Interpreter::DoBitwiseXor(InterpreterAssembler* assembler) {
825 DoBinaryOp<BitwiseXorStub>(assembler); 897 DoBitwiseBinaryOp(Token::BIT_XOR, assembler);
826 } 898 }
827 899
828 // BitwiseAnd <src> 900 // BitwiseAnd <src>
829 // 901 //
830 // BitwiseAnd register <src> to accumulator. 902 // BitwiseAnd register <src> to accumulator.
831 void Interpreter::DoBitwiseAnd(InterpreterAssembler* assembler) { 903 void Interpreter::DoBitwiseAnd(InterpreterAssembler* assembler) {
832 DoBinaryOp<BitwiseAndStub>(assembler); 904 DoBitwiseBinaryOp(Token::BIT_AND, assembler);
833 } 905 }
834 906
835 // ShiftLeft <src> 907 // ShiftLeft <src>
836 // 908 //
837 // Left shifts register <src> by the count specified in the accumulator. 909 // Left shifts register <src> by the count specified in the accumulator.
838 // Register <src> is converted to an int32 and the accumulator to uint32 910 // 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 911 // before the operation. 5 lsb bits from the accumulator are used as count
840 // i.e. <src> << (accumulator & 0x1F). 912 // i.e. <src> << (accumulator & 0x1F).
841 void Interpreter::DoShiftLeft(InterpreterAssembler* assembler) { 913 void Interpreter::DoShiftLeft(InterpreterAssembler* assembler) {
842 DoBinaryOp<ShiftLeftStub>(assembler); 914 DoBitwiseBinaryOp(Token::SHL, assembler);
843 } 915 }
844 916
845 // ShiftRight <src> 917 // ShiftRight <src>
846 // 918 //
847 // Right shifts register <src> by the count specified in the accumulator. 919 // 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 920 // 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 921 // accumulator to uint32 before the operation. 5 lsb bits from the accumulator
850 // are used as count i.e. <src> >> (accumulator & 0x1F). 922 // are used as count i.e. <src> >> (accumulator & 0x1F).
851 void Interpreter::DoShiftRight(InterpreterAssembler* assembler) { 923 void Interpreter::DoShiftRight(InterpreterAssembler* assembler) {
852 DoBinaryOp<ShiftRightStub>(assembler); 924 DoBitwiseBinaryOp(Token::SAR, assembler);
853 } 925 }
854 926
855 // ShiftRightLogical <src> 927 // ShiftRightLogical <src>
856 // 928 //
857 // Right Shifts register <src> by the count specified in the accumulator. 929 // Right Shifts register <src> by the count specified in the accumulator.
858 // Result is zero-filled. The accumulator and register <src> are converted to 930 // 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 931 // uint32 before the operation 5 lsb bits from the accumulator are used as
860 // count i.e. <src> << (accumulator & 0x1F). 932 // count i.e. <src> << (accumulator & 0x1F).
861 void Interpreter::DoShiftRightLogical(InterpreterAssembler* assembler) { 933 void Interpreter::DoShiftRightLogical(InterpreterAssembler* assembler) {
862 DoBinaryOp<ShiftRightLogicalStub>(assembler); 934 DoBitwiseBinaryOp(Token::SHR, assembler);
863 } 935 }
864 936
865 // AddSmi <imm> <reg> 937 // AddSmi <imm> <reg>
866 // 938 //
867 // Adds an immediate value <imm> to register <reg>. For this 939 // Adds an immediate value <imm> to register <reg>. For this
868 // operation <reg> is the lhs operand and <imm> is the <rhs> operand. 940 // operation <reg> is the lhs operand and <imm> is the <rhs> operand.
869 void Interpreter::DoAddSmi(InterpreterAssembler* assembler) { 941 void Interpreter::DoAddSmi(InterpreterAssembler* assembler) {
870 Variable var_result(assembler, MachineRepresentation::kTagged); 942 Variable var_result(assembler, MachineRepresentation::kTagged);
871 Label fastpath(assembler), slowpath(assembler, Label::kDeferred), 943 Label fastpath(assembler), slowpath(assembler, Label::kDeferred),
872 end(assembler); 944 end(assembler);
(...skipping 1290 matching lines...) Expand 10 before | Expand all | Expand 10 after
2163 __ StoreObjectField(generator, JSGeneratorObject::kContinuationOffset, 2235 __ StoreObjectField(generator, JSGeneratorObject::kContinuationOffset,
2164 __ SmiTag(new_state)); 2236 __ SmiTag(new_state));
2165 __ SetAccumulator(old_state); 2237 __ SetAccumulator(old_state);
2166 2238
2167 __ Dispatch(); 2239 __ Dispatch();
2168 } 2240 }
2169 2241
2170 } // namespace interpreter 2242 } // namespace interpreter
2171 } // namespace internal 2243 } // namespace internal
2172 } // namespace v8 2244 } // namespace v8
OLDNEW
« no previous file with comments | « src/interpreter/interpreter.h ('k') | src/interpreter/interpreter-assembler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698