Chromium Code Reviews| 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 | 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 Loading... | |
| 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 void Interpreter::DoUnaryOp(Callable callable, | 1000 void Interpreter::DoUnaryOp(Callable callable, InterpreterAssembler* assembler, |
| 1001 InterpreterAssembler* assembler) { | 1001 Bytecode bytecode) { |
| 1002 Node* target = __ HeapConstant(callable.code()); | 1002 Node* target = __ HeapConstant(callable.code()); |
| 1003 Node* accumulator = __ GetAccumulator(); | 1003 Node* accumulator = __ GetAccumulator(); |
| 1004 Node* context = __ GetContext(); | 1004 Node* context = __ GetContext(); |
| 1005 Node* result = | 1005 Node* result = |
| 1006 __ CallStub(callable.descriptor(), target, context, accumulator); | 1006 __ CallStub(callable.descriptor(), target, context, accumulator); |
| 1007 __ SetAccumulator(result); | 1007 if (Bytecodes::NumberOfOperands(bytecode) == 1 && |
|
rmcilroy
2016/07/21 09:31:48
Let's not do this in an if here. Split out BuildUn
klaasb
2016/07/21 10:55:19
Done.
| |
| 1008 Bytecodes::GetOperandType(bytecode, 0) == OperandType::kRegOut) { | |
| 1009 __ StoreRegister(result, __ BytecodeOperandReg(0)); | |
| 1010 } else { | |
| 1011 __ SetAccumulator(result); | |
| 1012 } | |
| 1008 __ Dispatch(); | 1013 __ Dispatch(); |
| 1009 } | 1014 } |
| 1010 | 1015 |
| 1011 template <class Generator> | 1016 template <class Generator> |
| 1012 void Interpreter::DoUnaryOp(InterpreterAssembler* assembler) { | 1017 void Interpreter::DoUnaryOp(InterpreterAssembler* assembler) { |
| 1013 Node* value = __ GetAccumulator(); | 1018 Node* value = __ GetAccumulator(); |
| 1014 Node* context = __ GetContext(); | 1019 Node* context = __ GetContext(); |
| 1015 Node* result = Generator::Generate(assembler, value, context); | 1020 Node* result = Generator::Generate(assembler, value, context); |
| 1016 __ SetAccumulator(result); | 1021 __ SetAccumulator(result); |
| 1017 __ Dispatch(); | 1022 __ Dispatch(); |
| 1018 } | 1023 } |
| 1019 | 1024 |
| 1020 // ToName | 1025 // ToName |
| 1021 // | 1026 // |
| 1022 // Cast the object referenced by the accumulator to a name. | 1027 // Cast the object referenced by the accumulator to a name. |
| 1023 void Interpreter::DoToName(InterpreterAssembler* assembler) { | 1028 void Interpreter::DoToName(InterpreterAssembler* assembler) { |
| 1024 DoUnaryOp(CodeFactory::ToName(isolate_), assembler); | 1029 DoUnaryOp(CodeFactory::ToName(isolate_), assembler, Bytecode::kToName); |
| 1025 } | 1030 } |
| 1026 | 1031 |
| 1027 // ToNumber | 1032 // ToNumber |
| 1028 // | 1033 // |
| 1029 // Cast the object referenced by the accumulator to a number. | 1034 // Cast the object referenced by the accumulator to a number. |
| 1030 void Interpreter::DoToNumber(InterpreterAssembler* assembler) { | 1035 void Interpreter::DoToNumber(InterpreterAssembler* assembler) { |
| 1031 DoUnaryOp(CodeFactory::ToNumber(isolate_), assembler); | 1036 DoUnaryOp(CodeFactory::ToNumber(isolate_), assembler, Bytecode::kToNumber); |
| 1032 } | 1037 } |
| 1033 | 1038 |
| 1034 // ToObject | 1039 // ToObject |
| 1035 // | 1040 // |
| 1036 // Cast the object referenced by the accumulator to a JSObject. | 1041 // Cast the object referenced by the accumulator to a JSObject. |
| 1037 void Interpreter::DoToObject(InterpreterAssembler* assembler) { | 1042 void Interpreter::DoToObject(InterpreterAssembler* assembler) { |
| 1038 DoUnaryOp(CodeFactory::ToObject(isolate_), assembler); | 1043 DoUnaryOp(CodeFactory::ToObject(isolate_), assembler, Bytecode::kToObject); |
| 1039 } | 1044 } |
| 1040 | 1045 |
| 1041 // Inc | 1046 // Inc |
| 1042 // | 1047 // |
| 1043 // Increments value in the accumulator by one. | 1048 // Increments value in the accumulator by one. |
| 1044 void Interpreter::DoInc(InterpreterAssembler* assembler) { | 1049 void Interpreter::DoInc(InterpreterAssembler* assembler) { |
| 1045 DoUnaryOp<IncStub>(assembler); | 1050 DoUnaryOp<IncStub>(assembler); |
| 1046 } | 1051 } |
| 1047 | 1052 |
| 1048 // Dec | 1053 // Dec |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1107 __ Bind(&end); | 1112 __ Bind(&end); |
| 1108 __ SetAccumulator(result.value()); | 1113 __ SetAccumulator(result.value()); |
| 1109 __ Dispatch(); | 1114 __ Dispatch(); |
| 1110 } | 1115 } |
| 1111 | 1116 |
| 1112 // TypeOf | 1117 // TypeOf |
| 1113 // | 1118 // |
| 1114 // Load the accumulator with the string representating type of the | 1119 // Load the accumulator with the string representating type of the |
| 1115 // object in the accumulator. | 1120 // object in the accumulator. |
| 1116 void Interpreter::DoTypeOf(InterpreterAssembler* assembler) { | 1121 void Interpreter::DoTypeOf(InterpreterAssembler* assembler) { |
| 1117 DoUnaryOp(CodeFactory::Typeof(isolate_), assembler); | 1122 DoUnaryOp(CodeFactory::Typeof(isolate_), assembler, Bytecode::kTypeOf); |
| 1118 } | 1123 } |
| 1119 | 1124 |
| 1120 void Interpreter::DoDelete(Runtime::FunctionId function_id, | 1125 void Interpreter::DoDelete(Runtime::FunctionId function_id, |
| 1121 InterpreterAssembler* assembler) { | 1126 InterpreterAssembler* assembler) { |
| 1122 Node* reg_index = __ BytecodeOperandReg(0); | 1127 Node* reg_index = __ BytecodeOperandReg(0); |
| 1123 Node* object = __ LoadRegister(reg_index); | 1128 Node* object = __ LoadRegister(reg_index); |
| 1124 Node* key = __ GetAccumulator(); | 1129 Node* key = __ GetAccumulator(); |
| 1125 Node* context = __ GetContext(); | 1130 Node* context = __ GetContext(); |
| 1126 Node* result = __ CallRuntime(function_id, context, object, key); | 1131 Node* result = __ CallRuntime(function_id, context, object, key); |
| 1127 __ SetAccumulator(result); | 1132 __ SetAccumulator(result); |
| (...skipping 992 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2120 __ StoreObjectField(generator, JSGeneratorObject::kContinuationOffset, | 2125 __ StoreObjectField(generator, JSGeneratorObject::kContinuationOffset, |
| 2121 __ SmiTag(new_state)); | 2126 __ SmiTag(new_state)); |
| 2122 __ SetAccumulator(old_state); | 2127 __ SetAccumulator(old_state); |
| 2123 | 2128 |
| 2124 __ Dispatch(); | 2129 __ Dispatch(); |
| 2125 } | 2130 } |
| 2126 | 2131 |
| 2127 } // namespace interpreter | 2132 } // namespace interpreter |
| 2128 } // namespace internal | 2133 } // namespace internal |
| 2129 } // namespace v8 | 2134 } // namespace v8 |
| OLD | NEW |