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 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "src/ast/prettyprinter.h" | 10 #include "src/ast/prettyprinter.h" |
(...skipping 1004 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1015 } | 1015 } |
1016 | 1016 |
1017 Node* Interpreter::BuildUnaryOp(Callable callable, | 1017 Node* Interpreter::BuildUnaryOp(Callable callable, |
1018 InterpreterAssembler* assembler) { | 1018 InterpreterAssembler* assembler) { |
1019 Node* target = __ HeapConstant(callable.code()); | 1019 Node* target = __ HeapConstant(callable.code()); |
1020 Node* accumulator = __ GetAccumulator(); | 1020 Node* accumulator = __ GetAccumulator(); |
1021 Node* context = __ GetContext(); | 1021 Node* context = __ GetContext(); |
1022 return __ CallStub(callable.descriptor(), target, context, accumulator); | 1022 return __ CallStub(callable.descriptor(), target, context, accumulator); |
1023 } | 1023 } |
1024 | 1024 |
1025 void Interpreter::DoUnaryOp(Callable callable, | |
1026 InterpreterAssembler* assembler) { | |
1027 Node* result = BuildUnaryOp(callable, assembler); | |
1028 __ SetAccumulator(result); | |
1029 __ Dispatch(); | |
1030 } | |
1031 | |
1032 template <class Generator> | 1025 template <class Generator> |
1033 void Interpreter::DoUnaryOp(InterpreterAssembler* assembler) { | 1026 void Interpreter::DoUnaryOp(InterpreterAssembler* assembler) { |
1034 Node* value = __ GetAccumulator(); | 1027 Node* value = __ GetAccumulator(); |
1035 Node* context = __ GetContext(); | 1028 Node* context = __ GetContext(); |
1036 Node* result = Generator::Generate(assembler, value, context); | 1029 Node* result = Generator::Generate(assembler, value, context); |
1037 __ SetAccumulator(result); | 1030 __ SetAccumulator(result); |
1038 __ Dispatch(); | 1031 __ Dispatch(); |
1039 } | 1032 } |
1040 | 1033 |
1041 // ToName | 1034 // ToName |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1134 __ Bind(&end); | 1127 __ Bind(&end); |
1135 __ SetAccumulator(result.value()); | 1128 __ SetAccumulator(result.value()); |
1136 __ Dispatch(); | 1129 __ Dispatch(); |
1137 } | 1130 } |
1138 | 1131 |
1139 // TypeOf | 1132 // TypeOf |
1140 // | 1133 // |
1141 // Load the accumulator with the string representating type of the | 1134 // Load the accumulator with the string representating type of the |
1142 // object in the accumulator. | 1135 // object in the accumulator. |
1143 void Interpreter::DoTypeOf(InterpreterAssembler* assembler) { | 1136 void Interpreter::DoTypeOf(InterpreterAssembler* assembler) { |
1144 DoUnaryOp(CodeFactory::Typeof(isolate_), assembler); | 1137 DoUnaryOp<TypeofStub>(assembler); |
1145 } | 1138 } |
1146 | 1139 |
1147 void Interpreter::DoDelete(Runtime::FunctionId function_id, | 1140 void Interpreter::DoDelete(Runtime::FunctionId function_id, |
1148 InterpreterAssembler* assembler) { | 1141 InterpreterAssembler* assembler) { |
1149 Node* reg_index = __ BytecodeOperandReg(0); | 1142 Node* reg_index = __ BytecodeOperandReg(0); |
1150 Node* object = __ LoadRegister(reg_index); | 1143 Node* object = __ LoadRegister(reg_index); |
1151 Node* key = __ GetAccumulator(); | 1144 Node* key = __ GetAccumulator(); |
1152 Node* context = __ GetContext(); | 1145 Node* context = __ GetContext(); |
1153 Node* result = __ CallRuntime(function_id, context, object, key); | 1146 Node* result = __ CallRuntime(function_id, context, object, key); |
1154 __ SetAccumulator(result); | 1147 __ SetAccumulator(result); |
(...skipping 1020 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2175 __ StoreObjectField(generator, JSGeneratorObject::kContinuationOffset, | 2168 __ StoreObjectField(generator, JSGeneratorObject::kContinuationOffset, |
2176 __ SmiTag(new_state)); | 2169 __ SmiTag(new_state)); |
2177 __ SetAccumulator(old_state); | 2170 __ SetAccumulator(old_state); |
2178 | 2171 |
2179 __ Dispatch(); | 2172 __ Dispatch(); |
2180 } | 2173 } |
2181 | 2174 |
2182 } // namespace interpreter | 2175 } // namespace interpreter |
2183 } // namespace internal | 2176 } // namespace internal |
2184 } // namespace v8 | 2177 } // namespace v8 |
OLD | NEW |