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 1044 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1055 void Interpreter::DoToNumber(InterpreterAssembler* assembler) { | 1055 void Interpreter::DoToNumber(InterpreterAssembler* assembler) { |
1056 Node* result = BuildUnaryOp(CodeFactory::ToNumber(isolate_), assembler); | 1056 Node* result = BuildUnaryOp(CodeFactory::ToNumber(isolate_), assembler); |
1057 __ StoreRegister(result, __ BytecodeOperandReg(0)); | 1057 __ StoreRegister(result, __ BytecodeOperandReg(0)); |
1058 __ Dispatch(); | 1058 __ Dispatch(); |
1059 } | 1059 } |
1060 | 1060 |
1061 // ToObject | 1061 // ToObject |
1062 // | 1062 // |
1063 // Cast the object referenced by the accumulator to a JSObject. | 1063 // Cast the object referenced by the accumulator to a JSObject. |
1064 void Interpreter::DoToObject(InterpreterAssembler* assembler) { | 1064 void Interpreter::DoToObject(InterpreterAssembler* assembler) { |
1065 DoUnaryOp(CodeFactory::ToObject(isolate_), assembler); | 1065 Node* result = BuildUnaryOp(CodeFactory::ToObject(isolate_), assembler); |
| 1066 __ StoreRegister(result, __ BytecodeOperandReg(0)); |
| 1067 __ Dispatch(); |
1066 } | 1068 } |
1067 | 1069 |
1068 // Inc | 1070 // Inc |
1069 // | 1071 // |
1070 // Increments value in the accumulator by one. | 1072 // Increments value in the accumulator by one. |
1071 void Interpreter::DoInc(InterpreterAssembler* assembler) { | 1073 void Interpreter::DoInc(InterpreterAssembler* assembler) { |
1072 DoUnaryOp<IncStub>(assembler); | 1074 DoUnaryOp<IncStub>(assembler); |
1073 } | 1075 } |
1074 | 1076 |
1075 // Dec | 1077 // Dec |
(...skipping 829 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1905 __ StoreRegister(cache_length, output_register); | 1907 __ StoreRegister(cache_length, output_register); |
1906 } | 1908 } |
1907 | 1909 |
1908 // ForInPrepare <cache_info_triple> | 1910 // ForInPrepare <cache_info_triple> |
1909 // | 1911 // |
1910 // Returns state for for..in loop execution based on the object in the | 1912 // Returns state for for..in loop execution based on the object in the |
1911 // accumulator. The result is output in registers |cache_info_triple| to | 1913 // accumulator. The result is output in registers |cache_info_triple| to |
1912 // |cache_info_triple + 2|, with the registers holding cache_type, cache_array, | 1914 // |cache_info_triple + 2|, with the registers holding cache_type, cache_array, |
1913 // and cache_length respectively. | 1915 // and cache_length respectively. |
1914 void Interpreter::DoForInPrepare(InterpreterAssembler* assembler) { | 1916 void Interpreter::DoForInPrepare(InterpreterAssembler* assembler) { |
1915 Node* object = __ GetAccumulator(); | 1917 Node* object_reg = __ BytecodeOperandReg(0); |
| 1918 Node* object = __ LoadRegister(object_reg); |
1916 Node* context = __ GetContext(); | 1919 Node* context = __ GetContext(); |
1917 Node* const zero_smi = __ SmiConstant(Smi::FromInt(0)); | 1920 Node* const zero_smi = __ SmiConstant(Smi::FromInt(0)); |
1918 | 1921 |
1919 Label test_if_null(assembler), test_if_undefined(assembler), | 1922 Label test_if_null(assembler), test_if_undefined(assembler), |
1920 nothing_to_iterate(assembler, Label::kDeferred), | 1923 nothing_to_iterate(assembler, Label::kDeferred), |
1921 convert_to_receiver(assembler, Label::kDeferred), | 1924 convert_to_receiver(assembler, Label::kDeferred), |
1922 already_receiver(assembler), check_enum_cache(assembler); | 1925 already_receiver(assembler), check_enum_cache(assembler); |
1923 | 1926 |
1924 Variable receiver(assembler, MachineRepresentation::kTagged); | 1927 Variable receiver(assembler, MachineRepresentation::kTagged); |
1925 | 1928 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1966 // iterated over and use the cache for the iteration. | 1969 // iterated over and use the cache for the iteration. |
1967 Node* cache_type = __ LoadMap(receiver.value()); | 1970 Node* cache_type = __ LoadMap(receiver.value()); |
1968 Node* cache_length = __ EnumLength(cache_type); | 1971 Node* cache_length = __ EnumLength(cache_type); |
1969 __ GotoIf(assembler->WordEqual(cache_length, zero_smi), | 1972 __ GotoIf(assembler->WordEqual(cache_length, zero_smi), |
1970 ¬hing_to_iterate); | 1973 ¬hing_to_iterate); |
1971 Node* descriptors = __ LoadMapDescriptors(cache_type); | 1974 Node* descriptors = __ LoadMapDescriptors(cache_type); |
1972 Node* cache_offset = | 1975 Node* cache_offset = |
1973 __ LoadObjectField(descriptors, DescriptorArray::kEnumCacheOffset); | 1976 __ LoadObjectField(descriptors, DescriptorArray::kEnumCacheOffset); |
1974 Node* cache_array = __ LoadObjectField( | 1977 Node* cache_array = __ LoadObjectField( |
1975 cache_offset, DescriptorArray::kEnumCacheBridgeCacheOffset); | 1978 cache_offset, DescriptorArray::kEnumCacheBridgeCacheOffset); |
1976 Node* output_register = __ BytecodeOperandReg(0); | 1979 Node* output_register = __ BytecodeOperandReg(1); |
1977 BuildForInPrepareResult(output_register, cache_type, cache_array, | 1980 BuildForInPrepareResult(output_register, cache_type, cache_array, |
1978 cache_length, assembler); | 1981 cache_length, assembler); |
1979 __ Dispatch(); | 1982 __ Dispatch(); |
1980 } | 1983 } |
1981 | 1984 |
1982 __ Bind(&use_runtime); | 1985 __ Bind(&use_runtime); |
1983 { | 1986 { |
1984 Node* result_triple = | 1987 Node* result_triple = |
1985 __ CallRuntime(Runtime::kForInPrepare, context, object); | 1988 __ CallRuntime(Runtime::kForInPrepare, context, object); |
1986 Node* cache_type = __ Projection(0, result_triple); | 1989 Node* cache_type = __ Projection(0, result_triple); |
1987 Node* cache_array = __ Projection(1, result_triple); | 1990 Node* cache_array = __ Projection(1, result_triple); |
1988 Node* cache_length = __ Projection(2, result_triple); | 1991 Node* cache_length = __ Projection(2, result_triple); |
1989 Node* output_register = __ BytecodeOperandReg(0); | 1992 Node* output_register = __ BytecodeOperandReg(1); |
1990 BuildForInPrepareResult(output_register, cache_type, cache_array, | 1993 BuildForInPrepareResult(output_register, cache_type, cache_array, |
1991 cache_length, assembler); | 1994 cache_length, assembler); |
1992 __ Dispatch(); | 1995 __ Dispatch(); |
1993 } | 1996 } |
1994 | 1997 |
1995 __ Bind(¬hing_to_iterate); | 1998 __ Bind(¬hing_to_iterate); |
1996 { | 1999 { |
1997 // Receiver is null or undefined or descriptors are zero length. | 2000 // Receiver is null or undefined or descriptors are zero length. |
1998 Node* output_register = __ BytecodeOperandReg(0); | 2001 Node* output_register = __ BytecodeOperandReg(1); |
1999 BuildForInPrepareResult(output_register, zero_smi, zero_smi, zero_smi, | 2002 BuildForInPrepareResult(output_register, zero_smi, zero_smi, zero_smi, |
2000 assembler); | 2003 assembler); |
2001 __ Dispatch(); | 2004 __ Dispatch(); |
2002 } | 2005 } |
2003 } | 2006 } |
2004 | 2007 |
2005 // ForInNext <receiver> <index> <cache_info_pair> | 2008 // ForInNext <receiver> <index> <cache_info_pair> |
2006 // | 2009 // |
2007 // Returns the next enumerable property in the the accumulator. | 2010 // Returns the next enumerable property in the the accumulator. |
2008 void Interpreter::DoForInNext(InterpreterAssembler* assembler) { | 2011 void Interpreter::DoForInNext(InterpreterAssembler* assembler) { |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2174 __ StoreObjectField(generator, JSGeneratorObject::kContinuationOffset, | 2177 __ StoreObjectField(generator, JSGeneratorObject::kContinuationOffset, |
2175 __ SmiTag(new_state)); | 2178 __ SmiTag(new_state)); |
2176 __ SetAccumulator(old_state); | 2179 __ SetAccumulator(old_state); |
2177 | 2180 |
2178 __ Dispatch(); | 2181 __ Dispatch(); |
2179 } | 2182 } |
2180 | 2183 |
2181 } // namespace interpreter | 2184 } // namespace interpreter |
2182 } // namespace internal | 2185 } // namespace internal |
2183 } // namespace v8 | 2186 } // namespace v8 |
OLD | NEW |