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 "src/code-factory.h" | 7 #include "src/code-factory.h" |
8 #include "src/compiler.h" | 8 #include "src/compiler.h" |
9 #include "src/compiler/interpreter-assembler.h" | 9 #include "src/compiler/interpreter-assembler.h" |
10 #include "src/factory.h" | 10 #include "src/factory.h" |
(...skipping 829 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
840 // | 840 // |
841 // Cast the object referenced by the accumulator to a number. | 841 // Cast the object referenced by the accumulator to a number. |
842 void Interpreter::DoToNumber(compiler::InterpreterAssembler* assembler) { | 842 void Interpreter::DoToNumber(compiler::InterpreterAssembler* assembler) { |
843 Node* accumulator = __ GetAccumulator(); | 843 Node* accumulator = __ GetAccumulator(); |
844 Node* result = __ CallRuntime(Runtime::kToNumber, accumulator); | 844 Node* result = __ CallRuntime(Runtime::kToNumber, accumulator); |
845 __ SetAccumulator(result); | 845 __ SetAccumulator(result); |
846 __ Dispatch(); | 846 __ Dispatch(); |
847 } | 847 } |
848 | 848 |
849 | 849 |
| 850 // ToObject |
| 851 // |
| 852 // Cast the object referenced by the accumulator to a JSObject. |
| 853 void Interpreter::DoToObject(compiler::InterpreterAssembler* assembler) { |
| 854 Node* accumulator = __ GetAccumulator(); |
| 855 Node* result = __ CallRuntime(Runtime::kToObject, accumulator); |
| 856 __ SetAccumulator(result); |
| 857 __ Dispatch(); |
| 858 } |
| 859 |
| 860 |
850 // Jump <imm8> | 861 // Jump <imm8> |
851 // | 862 // |
852 // Jump by number of bytes represented by the immediate operand |imm8|. | 863 // Jump by number of bytes represented by the immediate operand |imm8|. |
853 void Interpreter::DoJump(compiler::InterpreterAssembler* assembler) { | 864 void Interpreter::DoJump(compiler::InterpreterAssembler* assembler) { |
854 Node* relative_jump = __ BytecodeOperandImm8(0); | 865 Node* relative_jump = __ BytecodeOperandImm8(0); |
855 __ Jump(relative_jump); | 866 __ Jump(relative_jump); |
856 } | 867 } |
857 | 868 |
858 | 869 |
859 // JumpConstant <idx> | 870 // JumpConstant <idx> |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
980 Node* to_boolean_value = | 991 Node* to_boolean_value = |
981 __ CallRuntime(Runtime::kInterpreterToBoolean, accumulator); | 992 __ CallRuntime(Runtime::kInterpreterToBoolean, accumulator); |
982 Node* index = __ BytecodeOperandIdx8(0); | 993 Node* index = __ BytecodeOperandIdx8(0); |
983 Node* constant = __ LoadConstantPoolEntry(index); | 994 Node* constant = __ LoadConstantPoolEntry(index); |
984 Node* relative_jump = __ SmiUntag(constant); | 995 Node* relative_jump = __ SmiUntag(constant); |
985 Node* false_value = __ BooleanConstant(false); | 996 Node* false_value = __ BooleanConstant(false); |
986 __ JumpIfWordEqual(to_boolean_value, false_value, relative_jump); | 997 __ JumpIfWordEqual(to_boolean_value, false_value, relative_jump); |
987 } | 998 } |
988 | 999 |
989 | 1000 |
| 1001 // JumpIfNull <imm8> |
| 1002 // |
| 1003 // Jump by number of bytes represented by an immediate operand if the object |
| 1004 // referenced by the accumulator is the null constant. |
| 1005 void Interpreter::DoJumpIfNull(compiler::InterpreterAssembler* assembler) { |
| 1006 Node* accumulator = __ GetAccumulator(); |
| 1007 Node* null_value = __ HeapConstant(isolate_->factory()->null_value()); |
| 1008 Node* relative_jump = __ BytecodeOperandImm8(0); |
| 1009 __ JumpIfWordEqual(accumulator, null_value, relative_jump); |
| 1010 } |
| 1011 |
| 1012 |
| 1013 // JumpIfNullConstant <idx> |
| 1014 // |
| 1015 // Jump by number of bytes in the Smi in the |idx| entry in the constant pool |
| 1016 // if the object referenced by the accumulator is the null constant. |
| 1017 void Interpreter::DoJumpIfNullConstant( |
| 1018 compiler::InterpreterAssembler* assembler) { |
| 1019 Node* accumulator = __ GetAccumulator(); |
| 1020 Node* null_value = __ HeapConstant(isolate_->factory()->null_value()); |
| 1021 Node* index = __ BytecodeOperandIdx8(0); |
| 1022 Node* constant = __ LoadConstantPoolEntry(index); |
| 1023 Node* relative_jump = __ SmiUntag(constant); |
| 1024 __ JumpIfWordEqual(accumulator, null_value, relative_jump); |
| 1025 } |
| 1026 |
| 1027 |
| 1028 // JumpIfUndefined <imm8> |
| 1029 // |
| 1030 // Jump by number of bytes represented by an immediate operand if the object |
| 1031 // referenced by the accumulator is the undefined constant. |
| 1032 void Interpreter::DoJumpIfUndefined(compiler::InterpreterAssembler* assembler) { |
| 1033 Node* accumulator = __ GetAccumulator(); |
| 1034 Node* undefined_value = |
| 1035 __ HeapConstant(isolate_->factory()->undefined_value()); |
| 1036 Node* relative_jump = __ BytecodeOperandImm8(0); |
| 1037 __ JumpIfWordEqual(accumulator, undefined_value, relative_jump); |
| 1038 } |
| 1039 |
| 1040 |
| 1041 // JumpIfUndefinedConstant <idx> |
| 1042 // |
| 1043 // Jump by number of bytes in the Smi in the |idx| entry in the constant pool |
| 1044 // if the object referenced by the accumulator is the undefined constant. |
| 1045 void Interpreter::DoJumpIfUndefinedConstant( |
| 1046 compiler::InterpreterAssembler* assembler) { |
| 1047 Node* accumulator = __ GetAccumulator(); |
| 1048 Node* undefined_value = |
| 1049 __ HeapConstant(isolate_->factory()->undefined_value()); |
| 1050 Node* index = __ BytecodeOperandIdx8(0); |
| 1051 Node* constant = __ LoadConstantPoolEntry(index); |
| 1052 Node* relative_jump = __ SmiUntag(constant); |
| 1053 __ JumpIfWordEqual(accumulator, undefined_value, relative_jump); |
| 1054 } |
| 1055 |
| 1056 |
990 // CreateRegExpLiteral <idx> <flags_reg> | 1057 // CreateRegExpLiteral <idx> <flags_reg> |
991 // | 1058 // |
992 // Creates a regular expression literal for literal index <idx> with flags held | 1059 // Creates a regular expression literal for literal index <idx> with flags held |
993 // in <flags_reg> and the pattern in the accumulator. | 1060 // in <flags_reg> and the pattern in the accumulator. |
994 void Interpreter::DoCreateRegExpLiteral( | 1061 void Interpreter::DoCreateRegExpLiteral( |
995 compiler::InterpreterAssembler* assembler) { | 1062 compiler::InterpreterAssembler* assembler) { |
996 Node* pattern = __ GetAccumulator(); | 1063 Node* pattern = __ GetAccumulator(); |
997 Node* literal_index_raw = __ BytecodeOperandIdx8(0); | 1064 Node* literal_index_raw = __ BytecodeOperandIdx8(0); |
998 Node* literal_index = __ SmiTag(literal_index_raw); | 1065 Node* literal_index = __ SmiTag(literal_index_raw); |
999 Node* flags_reg = __ BytecodeOperandReg8(1); | 1066 Node* flags_reg = __ BytecodeOperandReg8(1); |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1098 | 1165 |
1099 | 1166 |
1100 // Return | 1167 // Return |
1101 // | 1168 // |
1102 // Return the value in the accumulator. | 1169 // Return the value in the accumulator. |
1103 void Interpreter::DoReturn(compiler::InterpreterAssembler* assembler) { | 1170 void Interpreter::DoReturn(compiler::InterpreterAssembler* assembler) { |
1104 __ Return(); | 1171 __ Return(); |
1105 } | 1172 } |
1106 | 1173 |
1107 | 1174 |
| 1175 // ForInPrepare <receiver> |
| 1176 // |
| 1177 // Returns state for for..in loop execution based on the |receiver| and |
| 1178 // the property names in the accumulator. |
| 1179 void Interpreter::DoForInPrepare(compiler::InterpreterAssembler* assembler) { |
| 1180 Node* receiver_reg = __ BytecodeOperandReg8(0); |
| 1181 Node* receiver = __ LoadRegister(receiver_reg); |
| 1182 Node* property_names = __ GetAccumulator(); |
| 1183 Node* result = __ CallRuntime(Runtime::kInterpreterForInPrepare, receiver, |
| 1184 property_names); |
| 1185 __ SetAccumulator(result); |
| 1186 __ Dispatch(); |
| 1187 } |
| 1188 |
| 1189 |
| 1190 // ForInNext <for_in_state> <index> |
| 1191 // |
| 1192 // Returns the next key in a for..in loop. The state associated with the |
| 1193 // iteration is contained in |for_in_state| and |index| is the current |
| 1194 // zero-based iteration count. |
| 1195 void Interpreter::DoForInNext(compiler::InterpreterAssembler* assembler) { |
| 1196 Node* for_in_state_reg = __ BytecodeOperandReg8(0); |
| 1197 Node* for_in_state = __ LoadRegister(for_in_state_reg); |
| 1198 Node* receiver = __ LoadFixedArrayElement(for_in_state, 0); |
| 1199 Node* cache_array = __ LoadFixedArrayElement(for_in_state, 1); |
| 1200 Node* cache_type = __ LoadFixedArrayElement(for_in_state, 2); |
| 1201 Node* index_reg = __ BytecodeOperandReg8(1); |
| 1202 Node* index = __ LoadRegister(index_reg); |
| 1203 Node* result = __ CallRuntime(Runtime::kForInNext, receiver, cache_array, |
| 1204 cache_type, index); |
| 1205 __ SetAccumulator(result); |
| 1206 __ Dispatch(); |
| 1207 } |
| 1208 |
| 1209 |
| 1210 // ForInDone <for_in_state> |
| 1211 // |
| 1212 // Returns the next key in a for..in loop. The accumulator contains the current |
| 1213 // zero-based iteration count and |for_in_state| is the state returned by an |
| 1214 // earlier invocation of ForInPrepare. |
| 1215 void Interpreter::DoForInDone(compiler::InterpreterAssembler* assembler) { |
| 1216 Node* index = __ GetAccumulator(); |
| 1217 Node* for_in_state_reg = __ BytecodeOperandReg8(0); |
| 1218 Node* for_in_state = __ LoadRegister(for_in_state_reg); |
| 1219 Node* cache_length = __ LoadFixedArrayElement(for_in_state, 3); |
| 1220 Node* result = __ CallRuntime(Runtime::kForInDone, index, cache_length); |
| 1221 __ SetAccumulator(result); |
| 1222 __ Dispatch(); |
| 1223 } |
| 1224 |
| 1225 |
1108 } // namespace interpreter | 1226 } // namespace interpreter |
1109 } // namespace internal | 1227 } // namespace internal |
1110 } // namespace v8 | 1228 } // namespace v8 |
OLD | NEW |