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

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

Issue 2165953002: [interpreter] Add a register operand to ToNumber (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: comments 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 979 matching lines...) Expand 10 before | Expand all | Expand 10 after
990 Node* context = __ GetContext(); 990 Node* context = __ GetContext();
991 Node* lhs_value = __ TruncateTaggedToWord32(context, left); 991 Node* lhs_value = __ TruncateTaggedToWord32(context, left);
992 Node* rhs_value = __ SmiToWord32(right); 992 Node* rhs_value = __ SmiToWord32(right);
993 Node* shift_count = __ Word32And(rhs_value, __ Int32Constant(0x1f)); 993 Node* shift_count = __ Word32And(rhs_value, __ Int32Constant(0x1f));
994 Node* value = __ Word32Sar(lhs_value, shift_count); 994 Node* value = __ Word32Sar(lhs_value, shift_count);
995 Node* result = __ ChangeInt32ToTagged(value); 995 Node* result = __ ChangeInt32ToTagged(value);
996 __ SetAccumulator(result); 996 __ SetAccumulator(result);
997 __ Dispatch(); 997 __ Dispatch();
998 } 998 }
999 999
1000 Node* Interpreter::BuildUnaryOp(Callable callable,
1001 InterpreterAssembler* assembler) {
1002 Node* target = __ HeapConstant(callable.code());
1003 Node* accumulator = __ GetAccumulator();
1004 Node* context = __ GetContext();
1005 return __ CallStub(callable.descriptor(), target, context, accumulator);
1006 }
1007
1000 void Interpreter::DoUnaryOp(Callable callable, 1008 void Interpreter::DoUnaryOp(Callable callable,
1001 InterpreterAssembler* assembler) { 1009 InterpreterAssembler* assembler) {
1002 Node* target = __ HeapConstant(callable.code()); 1010 Node* result = BuildUnaryOp(callable, assembler);
1003 Node* accumulator = __ GetAccumulator();
1004 Node* context = __ GetContext();
1005 Node* result =
1006 __ CallStub(callable.descriptor(), target, context, accumulator);
1007 __ SetAccumulator(result); 1011 __ SetAccumulator(result);
1008 __ Dispatch(); 1012 __ Dispatch();
1009 } 1013 }
1010 1014
1011 template <class Generator> 1015 template <class Generator>
1012 void Interpreter::DoUnaryOp(InterpreterAssembler* assembler) { 1016 void Interpreter::DoUnaryOp(InterpreterAssembler* assembler) {
1013 Node* value = __ GetAccumulator(); 1017 Node* value = __ GetAccumulator();
1014 Node* context = __ GetContext(); 1018 Node* context = __ GetContext();
1015 Node* result = Generator::Generate(assembler, value, context); 1019 Node* result = Generator::Generate(assembler, value, context);
1016 __ SetAccumulator(result); 1020 __ SetAccumulator(result);
1017 __ Dispatch(); 1021 __ Dispatch();
1018 } 1022 }
1019 1023
1020 // ToName 1024 // ToName
1021 // 1025 //
1022 // Cast the object referenced by the accumulator to a name. 1026 // Cast the object referenced by the accumulator to a name.
1023 void Interpreter::DoToName(InterpreterAssembler* assembler) { 1027 void Interpreter::DoToName(InterpreterAssembler* assembler) {
1024 DoUnaryOp(CodeFactory::ToName(isolate_), assembler); 1028 DoUnaryOp(CodeFactory::ToName(isolate_), assembler);
1025 } 1029 }
1026 1030
1027 // ToNumber 1031 // ToNumber
1028 // 1032 //
1029 // Cast the object referenced by the accumulator to a number. 1033 // Cast the object referenced by the accumulator to a number.
1030 void Interpreter::DoToNumber(InterpreterAssembler* assembler) { 1034 void Interpreter::DoToNumber(InterpreterAssembler* assembler) {
1031 DoUnaryOp(CodeFactory::ToNumber(isolate_), assembler); 1035 Node* result = BuildUnaryOp(CodeFactory::ToNumber(isolate_), assembler);
1036 __ StoreRegister(result, __ BytecodeOperandReg(0));
1037 __ Dispatch();
1032 } 1038 }
1033 1039
1034 // ToObject 1040 // ToObject
1035 // 1041 //
1036 // Cast the object referenced by the accumulator to a JSObject. 1042 // Cast the object referenced by the accumulator to a JSObject.
1037 void Interpreter::DoToObject(InterpreterAssembler* assembler) { 1043 void Interpreter::DoToObject(InterpreterAssembler* assembler) {
1038 DoUnaryOp(CodeFactory::ToObject(isolate_), assembler); 1044 DoUnaryOp(CodeFactory::ToObject(isolate_), assembler);
1039 } 1045 }
1040 1046
1041 // Inc 1047 // Inc
(...skipping 1078 matching lines...) Expand 10 before | Expand all | Expand 10 after
2120 __ StoreObjectField(generator, JSGeneratorObject::kContinuationOffset, 2126 __ StoreObjectField(generator, JSGeneratorObject::kContinuationOffset,
2121 __ SmiTag(new_state)); 2127 __ SmiTag(new_state));
2122 __ SetAccumulator(old_state); 2128 __ SetAccumulator(old_state);
2123 2129
2124 __ Dispatch(); 2130 __ Dispatch();
2125 } 2131 }
2126 2132
2127 } // namespace interpreter 2133 } // namespace interpreter
2128 } // namespace internal 2134 } // namespace internal
2129 } // namespace v8 2135 } // namespace v8
OLDNEW
« no previous file with comments | « src/interpreter/interpreter.h ('k') | test/cctest/interpreter/bytecode_expectations/AssignmentsInBinaryExpression.golden » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698