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 = __ NullConstant(); |
| 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 = __ NullConstant(); |
| 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 = __ UndefinedConstant(); |
| 1035 Node* relative_jump = __ BytecodeOperandImm8(0); |
| 1036 __ JumpIfWordEqual(accumulator, undefined_value, relative_jump); |
| 1037 } |
| 1038 |
| 1039 |
| 1040 // JumpIfUndefinedConstant <idx> |
| 1041 // |
| 1042 // Jump by number of bytes in the Smi in the |idx| entry in the constant pool |
| 1043 // if the object referenced by the accumulator is the undefined constant. |
| 1044 void Interpreter::DoJumpIfUndefinedConstant( |
| 1045 compiler::InterpreterAssembler* assembler) { |
| 1046 Node* accumulator = __ GetAccumulator(); |
| 1047 Node* undefined_value = __ UndefinedConstant(); |
| 1048 Node* index = __ BytecodeOperandIdx8(0); |
| 1049 Node* constant = __ LoadConstantPoolEntry(index); |
| 1050 Node* relative_jump = __ SmiUntag(constant); |
| 1051 __ JumpIfWordEqual(accumulator, undefined_value, relative_jump); |
| 1052 } |
| 1053 |
| 1054 |
990 // CreateRegExpLiteral <idx> <flags_reg> | 1055 // CreateRegExpLiteral <idx> <flags_reg> |
991 // | 1056 // |
992 // Creates a regular expression literal for literal index <idx> with flags held | 1057 // Creates a regular expression literal for literal index <idx> with flags held |
993 // in <flags_reg> and the pattern in the accumulator. | 1058 // in <flags_reg> and the pattern in the accumulator. |
994 void Interpreter::DoCreateRegExpLiteral( | 1059 void Interpreter::DoCreateRegExpLiteral( |
995 compiler::InterpreterAssembler* assembler) { | 1060 compiler::InterpreterAssembler* assembler) { |
996 Node* pattern = __ GetAccumulator(); | 1061 Node* pattern = __ GetAccumulator(); |
997 Node* literal_index_raw = __ BytecodeOperandIdx8(0); | 1062 Node* literal_index_raw = __ BytecodeOperandIdx8(0); |
998 Node* literal_index = __ SmiTag(literal_index_raw); | 1063 Node* literal_index = __ SmiTag(literal_index_raw); |
999 Node* flags_reg = __ BytecodeOperandReg8(1); | 1064 Node* flags_reg = __ BytecodeOperandReg8(1); |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1098 | 1163 |
1099 | 1164 |
1100 // Return | 1165 // Return |
1101 // | 1166 // |
1102 // Return the value in the accumulator. | 1167 // Return the value in the accumulator. |
1103 void Interpreter::DoReturn(compiler::InterpreterAssembler* assembler) { | 1168 void Interpreter::DoReturn(compiler::InterpreterAssembler* assembler) { |
1104 __ Return(); | 1169 __ Return(); |
1105 } | 1170 } |
1106 | 1171 |
1107 | 1172 |
| 1173 // ForInPrepare <receiver> |
| 1174 // |
| 1175 // Returns state for for..in loop execution based on the |receiver| and |
| 1176 // the property names in the accumulator. |
| 1177 void Interpreter::DoForInPrepare(compiler::InterpreterAssembler* assembler) { |
| 1178 Node* receiver_reg = __ BytecodeOperandReg8(0); |
| 1179 Node* receiver = __ LoadRegister(receiver_reg); |
| 1180 Node* property_names = __ GetAccumulator(); |
| 1181 Node* result = __ CallRuntime(Runtime::kInterpreterForInPrepare, receiver, |
| 1182 property_names); |
| 1183 __ SetAccumulator(result); |
| 1184 __ Dispatch(); |
| 1185 } |
| 1186 |
| 1187 |
| 1188 // ForInNext <for_in_state> |
| 1189 // |
| 1190 // Returns the next key in a for..in loop. The accumulator contains the current |
| 1191 // zero-based iteration count and <for_in_state> is the state returned by |
| 1192 // earlier invocation of ForInPrepare. |
| 1193 void Interpreter::DoForInNext(compiler::InterpreterAssembler* assembler) { |
| 1194 Node* index = __ GetAccumulator(); |
| 1195 Node* for_in_state_reg = __ BytecodeOperandReg8(0); |
| 1196 Node* for_in_state = __ LoadRegister(for_in_state_reg); |
| 1197 Node* receiver = __ LoadFixedArrayElement(for_in_state, 0); |
| 1198 Node* cache_array = __ LoadFixedArrayElement(for_in_state, 1); |
| 1199 Node* cache_type = __ LoadFixedArrayElement(for_in_state, 2); |
| 1200 Node* result = __ CallRuntime(Runtime::kForInNext, receiver, cache_array, |
| 1201 cache_type, index); |
| 1202 __ SetAccumulator(result); |
| 1203 __ Dispatch(); |
| 1204 } |
| 1205 |
| 1206 |
| 1207 // ForInDone <for_in_state> |
| 1208 // |
| 1209 // Returns the next key in a for..in loop. The accumulator contains the current |
| 1210 // zero-based iteration count and <for_in_state> is the state returned by |
| 1211 // earlier invocation of ForInPrepare. |
| 1212 void Interpreter::DoForInDone(compiler::InterpreterAssembler* assembler) { |
| 1213 Node* index = __ GetAccumulator(); |
| 1214 Node* for_in_state_reg = __ BytecodeOperandReg8(0); |
| 1215 Node* for_in_state = __ LoadRegister(for_in_state_reg); |
| 1216 Node* cache_length = __ LoadFixedArrayElement(for_in_state, 3); |
| 1217 Node* result = __ CallRuntime(Runtime::kForInDone, index, cache_length); |
| 1218 __ SetAccumulator(result); |
| 1219 __ Dispatch(); |
| 1220 } |
| 1221 |
| 1222 |
1108 } // namespace interpreter | 1223 } // namespace interpreter |
1109 } // namespace internal | 1224 } // namespace internal |
1110 } // namespace v8 | 1225 } // namespace v8 |
OLD | NEW |