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 1924 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1935 // TestInstanceOf <src> | 1935 // TestInstanceOf <src> |
1936 // | 1936 // |
1937 // Test if the object referenced by the <src> register is an an instance of type | 1937 // Test if the object referenced by the <src> register is an an instance of type |
1938 // referenced by the accumulator. | 1938 // referenced by the accumulator. |
1939 void Interpreter::DoTestInstanceOf(InterpreterAssembler* assembler) { | 1939 void Interpreter::DoTestInstanceOf(InterpreterAssembler* assembler) { |
1940 DoCompareOp(Token::INSTANCEOF, assembler); | 1940 DoCompareOp(Token::INSTANCEOF, assembler); |
1941 } | 1941 } |
1942 | 1942 |
1943 // TestUndetectable <src> | 1943 // TestUndetectable <src> |
1944 // | 1944 // |
1945 // Test if the value in the <src> register equals to Null/Undefined. This is | 1945 // Test if the value in the <src> register equals to null/undefined. This is |
1946 // done by checking undetectable bit on the map of the object. | 1946 // done by checking undetectable bit on the map of the object. |
1947 void Interpreter::DoTestUndetectable(InterpreterAssembler* assembler) { | 1947 void Interpreter::DoTestUndetectable(InterpreterAssembler* assembler) { |
1948 Node* reg_index = __ BytecodeOperandReg(0); | 1948 Node* reg_index = __ BytecodeOperandReg(0); |
1949 Node* object = __ LoadRegister(reg_index); | 1949 Node* object = __ LoadRegister(reg_index); |
1950 | 1950 |
1951 Label not_equal(assembler), end(assembler); | 1951 Label not_equal(assembler), end(assembler); |
1952 // If the object is an Smi then return false. | 1952 // If the object is an Smi then return false. |
1953 __ GotoIf(__ TaggedIsSmi(object), ¬_equal); | 1953 __ GotoIf(__ TaggedIsSmi(object), ¬_equal); |
1954 | 1954 |
1955 // If it is a HeapObject, load the map and check for undetectable bit. | 1955 // If it is a HeapObject, load the map and check for undetectable bit. |
1956 Node* map = __ LoadMap(object); | 1956 Node* map = __ LoadMap(object); |
1957 Node* map_bitfield = __ LoadMapBitField(map); | 1957 Node* map_bitfield = __ LoadMapBitField(map); |
1958 Node* map_undetectable = | 1958 Node* map_undetectable = |
1959 __ Word32And(map_bitfield, __ Int32Constant(1 << Map::kIsUndetectable)); | 1959 __ Word32And(map_bitfield, __ Int32Constant(1 << Map::kIsUndetectable)); |
1960 __ GotoIf(__ Word32Equal(map_undetectable, __ Int32Constant(0)), ¬_equal); | 1960 __ GotoIf(__ Word32Equal(map_undetectable, __ Int32Constant(0)), ¬_equal); |
1961 | 1961 |
1962 __ SetAccumulator(__ BooleanConstant(true)); | 1962 __ SetAccumulator(__ BooleanConstant(true)); |
1963 __ Goto(&end); | 1963 __ Goto(&end); |
1964 | 1964 |
1965 __ Bind(¬_equal); | 1965 __ Bind(¬_equal); |
1966 { | 1966 { |
1967 __ SetAccumulator(__ BooleanConstant(false)); | 1967 __ SetAccumulator(__ BooleanConstant(false)); |
1968 __ Goto(&end); | 1968 __ Goto(&end); |
1969 } | 1969 } |
1970 | 1970 |
1971 __ Bind(&end); | 1971 __ Bind(&end); |
1972 __ Dispatch(); | 1972 __ Dispatch(); |
1973 } | 1973 } |
1974 | 1974 |
| 1975 // TestNull <src> |
| 1976 // |
| 1977 // Test if the value in the <src> register is strictly equal to null. |
| 1978 void Interpreter::DoTestNull(InterpreterAssembler* assembler) { |
| 1979 Node* reg_index = __ BytecodeOperandReg(0); |
| 1980 Node* object = __ LoadRegister(reg_index); |
| 1981 Node* null_value = __ HeapConstant(isolate_->factory()->null_value()); |
| 1982 |
| 1983 Label equal(assembler), end(assembler); |
| 1984 __ GotoIf(__ WordEqual(object, null_value), &equal); |
| 1985 __ SetAccumulator(__ BooleanConstant(false)); |
| 1986 __ Goto(&end); |
| 1987 |
| 1988 __ Bind(&equal); |
| 1989 { |
| 1990 __ SetAccumulator(__ BooleanConstant(true)); |
| 1991 __ Goto(&end); |
| 1992 } |
| 1993 |
| 1994 __ Bind(&end); |
| 1995 __ Dispatch(); |
| 1996 } |
| 1997 |
| 1998 // TestUndefined <src> |
| 1999 // |
| 2000 // Test if the value in the <src> register is strictly equal to undefined. |
| 2001 void Interpreter::DoTestUndefined(InterpreterAssembler* assembler) { |
| 2002 Node* reg_index = __ BytecodeOperandReg(0); |
| 2003 Node* object = __ LoadRegister(reg_index); |
| 2004 Node* undefined_value = |
| 2005 __ HeapConstant(isolate_->factory()->undefined_value()); |
| 2006 |
| 2007 Label equal(assembler), end(assembler); |
| 2008 __ GotoIf(__ WordEqual(object, undefined_value), &equal); |
| 2009 __ SetAccumulator(__ BooleanConstant(false)); |
| 2010 __ Goto(&end); |
| 2011 |
| 2012 __ Bind(&equal); |
| 2013 { |
| 2014 __ SetAccumulator(__ BooleanConstant(true)); |
| 2015 __ Goto(&end); |
| 2016 } |
| 2017 |
| 2018 __ Bind(&end); |
| 2019 __ Dispatch(); |
| 2020 } |
| 2021 |
1975 // Jump <imm> | 2022 // Jump <imm> |
1976 // | 2023 // |
1977 // Jump by number of bytes represented by the immediate operand |imm|. | 2024 // Jump by number of bytes represented by the immediate operand |imm|. |
1978 void Interpreter::DoJump(InterpreterAssembler* assembler) { | 2025 void Interpreter::DoJump(InterpreterAssembler* assembler) { |
1979 Node* relative_jump = __ BytecodeOperandImmIntPtr(0); | 2026 Node* relative_jump = __ BytecodeOperandImmIntPtr(0); |
1980 __ Jump(relative_jump); | 2027 __ Jump(relative_jump); |
1981 } | 2028 } |
1982 | 2029 |
1983 // JumpConstant <idx> | 2030 // JumpConstant <idx> |
1984 // | 2031 // |
(...skipping 875 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2860 __ StoreObjectField(generator, JSGeneratorObject::kContinuationOffset, | 2907 __ StoreObjectField(generator, JSGeneratorObject::kContinuationOffset, |
2861 __ SmiTag(new_state)); | 2908 __ SmiTag(new_state)); |
2862 __ SetAccumulator(old_state); | 2909 __ SetAccumulator(old_state); |
2863 | 2910 |
2864 __ Dispatch(); | 2911 __ Dispatch(); |
2865 } | 2912 } |
2866 | 2913 |
2867 } // namespace interpreter | 2914 } // namespace interpreter |
2868 } // namespace internal | 2915 } // namespace internal |
2869 } // namespace v8 | 2916 } // namespace v8 |
OLD | NEW |