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

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

Issue 2111923002: [interpreter] Introduce binary op bytecodes for Smi operand. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Tweak a name. Created 4 years, 5 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
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 8
9 #include "src/ast/prettyprinter.h" 9 #include "src/ast/prettyprinter.h"
10 #include "src/code-factory.h" 10 #include "src/code-factory.h"
(...skipping 818 matching lines...) Expand 10 before | Expand all | Expand 10 after
829 // ShiftRightLogical <src> 829 // ShiftRightLogical <src>
830 // 830 //
831 // Right Shifts register <src> by the count specified in the accumulator. 831 // Right Shifts register <src> by the count specified in the accumulator.
832 // Result is zero-filled. The accumulator and register <src> are converted to 832 // Result is zero-filled. The accumulator and register <src> are converted to
833 // uint32 before the operation 5 lsb bits from the accumulator are used as 833 // uint32 before the operation 5 lsb bits from the accumulator are used as
834 // count i.e. <src> << (accumulator & 0x1F). 834 // count i.e. <src> << (accumulator & 0x1F).
835 void Interpreter::DoShiftRightLogical(InterpreterAssembler* assembler) { 835 void Interpreter::DoShiftRightLogical(InterpreterAssembler* assembler) {
836 DoBinaryOp<ShiftRightLogicalStub>(assembler); 836 DoBinaryOp<ShiftRightLogicalStub>(assembler);
837 } 837 }
838 838
839 template <class Generator>
840 void Interpreter::DoBinaryOpWithImmediate(InterpreterAssembler* assembler) {
841 Node* reg_index = __ BytecodeOperandReg(1);
842 Node* lhs = __ LoadRegister(reg_index);
843 Node* raw_int = __ BytecodeOperandImm(0);
844 Node* rhs = __ SmiTag(raw_int);
845 Node* context = __ GetContext();
846 Node* result = Generator::Generate(assembler, lhs, rhs, context);
847 __ SetAccumulator(result);
848 __ Dispatch();
849 }
850
851 void Interpreter::DoAddSmi(InterpreterAssembler* assembler) {
852 DoBinaryOpWithImmediate<AddSmiStub>(assembler);
853 }
854
855 void Interpreter::DoSubSmi(InterpreterAssembler* assembler) {
856 DoBinaryOpWithImmediate<SubtractSmiStub>(assembler);
857 }
858
859 void Interpreter::DoBitwiseOrSmi(InterpreterAssembler* assembler) {
860 DoBinaryOpWithImmediate<BitwiseOrSmiStub>(assembler);
861 }
862
863 void Interpreter::DoBitwiseAndSmi(InterpreterAssembler* assembler) {
864 DoBinaryOpWithImmediate<BitwiseAndSmiStub>(assembler);
865 }
866
867 void Interpreter::DoShiftLeftSmi(InterpreterAssembler* assembler) {
868 DoBinaryOpWithImmediate<ShiftLeftSmiStub>(assembler);
869 }
870
871 void Interpreter::DoShiftRightSmi(InterpreterAssembler* assembler) {
872 DoBinaryOpWithImmediate<ShiftRightSmiStub>(assembler);
873 }
874
839 void Interpreter::DoUnaryOp(Callable callable, 875 void Interpreter::DoUnaryOp(Callable callable,
840 InterpreterAssembler* assembler) { 876 InterpreterAssembler* assembler) {
841 Node* target = __ HeapConstant(callable.code()); 877 Node* target = __ HeapConstant(callable.code());
842 Node* accumulator = __ GetAccumulator(); 878 Node* accumulator = __ GetAccumulator();
843 Node* context = __ GetContext(); 879 Node* context = __ GetContext();
844 Node* result = 880 Node* result =
845 __ CallStub(callable.descriptor(), target, context, accumulator); 881 __ CallStub(callable.descriptor(), target, context, accumulator);
846 __ SetAccumulator(result); 882 __ SetAccumulator(result);
847 __ Dispatch(); 883 __ Dispatch();
848 } 884 }
(...skipping 1007 matching lines...) Expand 10 before | Expand all | Expand 10 after
1856 __ StoreObjectField(generator, JSGeneratorObject::kContinuationOffset, 1892 __ StoreObjectField(generator, JSGeneratorObject::kContinuationOffset,
1857 __ SmiTag(new_state)); 1893 __ SmiTag(new_state));
1858 __ SetAccumulator(old_state); 1894 __ SetAccumulator(old_state);
1859 1895
1860 __ Dispatch(); 1896 __ Dispatch();
1861 } 1897 }
1862 1898
1863 } // namespace interpreter 1899 } // namespace interpreter
1864 } // namespace internal 1900 } // namespace internal
1865 } // namespace v8 1901 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698