| 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-assembler.h" | 5 #include "src/interpreter/interpreter-assembler.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 #include <ostream> | 8 #include <ostream> |
| 9 | 9 |
| 10 #include "src/code-factory.h" | 10 #include "src/code-factory.h" |
| (...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 385 | 385 |
| 386 Node* InterpreterAssembler::LoadConstantPoolEntry(Node* index) { | 386 Node* InterpreterAssembler::LoadConstantPoolEntry(Node* index) { |
| 387 Node* constant_pool = LoadObjectField(BytecodeArrayTaggedPointer(), | 387 Node* constant_pool = LoadObjectField(BytecodeArrayTaggedPointer(), |
| 388 BytecodeArray::kConstantPoolOffset); | 388 BytecodeArray::kConstantPoolOffset); |
| 389 Node* entry_offset = | 389 Node* entry_offset = |
| 390 IntPtrAdd(IntPtrConstant(FixedArray::kHeaderSize - kHeapObjectTag), | 390 IntPtrAdd(IntPtrConstant(FixedArray::kHeaderSize - kHeapObjectTag), |
| 391 WordShl(index, kPointerSizeLog2)); | 391 WordShl(index, kPointerSizeLog2)); |
| 392 return Load(MachineType::AnyTagged(), constant_pool, entry_offset); | 392 return Load(MachineType::AnyTagged(), constant_pool, entry_offset); |
| 393 } | 393 } |
| 394 | 394 |
| 395 Node* InterpreterAssembler::LoadAndUntagConstantPoolEntry(Node* index) { |
| 396 Node* constant_pool = LoadObjectField(BytecodeArrayTaggedPointer(), |
| 397 BytecodeArray::kConstantPoolOffset); |
| 398 int offset = FixedArray::kHeaderSize - kHeapObjectTag; |
| 399 #if V8_TARGET_LITTLE_ENDIAN |
| 400 if (Is64()) { |
| 401 offset += kPointerSize / 2; |
| 402 } |
| 403 #endif |
| 404 Node* entry_offset = |
| 405 IntPtrAdd(IntPtrConstant(offset), WordShl(index, kPointerSizeLog2)); |
| 406 if (Is64()) { |
| 407 return ChangeInt32ToInt64( |
| 408 Load(MachineType::Int32(), constant_pool, entry_offset)); |
| 409 } else { |
| 410 return SmiUntag( |
| 411 Load(MachineType::AnyTagged(), constant_pool, entry_offset)); |
| 412 } |
| 413 } |
| 414 |
| 395 Node* InterpreterAssembler::LoadContextSlot(Node* context, int slot_index) { | 415 Node* InterpreterAssembler::LoadContextSlot(Node* context, int slot_index) { |
| 396 return Load(MachineType::AnyTagged(), context, | 416 return Load(MachineType::AnyTagged(), context, |
| 397 IntPtrConstant(Context::SlotOffset(slot_index))); | 417 IntPtrConstant(Context::SlotOffset(slot_index))); |
| 398 } | 418 } |
| 399 | 419 |
| 400 Node* InterpreterAssembler::LoadContextSlot(Node* context, Node* slot_index) { | 420 Node* InterpreterAssembler::LoadContextSlot(Node* context, Node* slot_index) { |
| 401 Node* offset = | 421 Node* offset = |
| 402 IntPtrAdd(WordShl(slot_index, kPointerSizeLog2), | 422 IntPtrAdd(WordShl(slot_index, kPointerSizeLog2), |
| 403 IntPtrConstant(Context::kHeaderSize - kHeapObjectTag)); | 423 IntPtrConstant(Context::kHeaderSize - kHeapObjectTag)); |
| 404 return Load(MachineType::AnyTagged(), context, offset); | 424 return Load(MachineType::AnyTagged(), context, offset); |
| (...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 920 | 940 |
| 921 Node* InterpreterAssembler::RegisterCount() { | 941 Node* InterpreterAssembler::RegisterCount() { |
| 922 Node* bytecode_array = LoadRegister(Register::bytecode_array()); | 942 Node* bytecode_array = LoadRegister(Register::bytecode_array()); |
| 923 Node* frame_size = LoadObjectField( | 943 Node* frame_size = LoadObjectField( |
| 924 bytecode_array, BytecodeArray::kFrameSizeOffset, MachineType::Int32()); | 944 bytecode_array, BytecodeArray::kFrameSizeOffset, MachineType::Int32()); |
| 925 return Word32Sar(frame_size, Int32Constant(kPointerSizeLog2)); | 945 return Word32Sar(frame_size, Int32Constant(kPointerSizeLog2)); |
| 926 } | 946 } |
| 927 | 947 |
| 928 Node* InterpreterAssembler::ExportRegisterFile(Node* array) { | 948 Node* InterpreterAssembler::ExportRegisterFile(Node* array) { |
| 929 if (FLAG_debug_code) { | 949 if (FLAG_debug_code) { |
| 930 Node* array_size = SmiUntag(LoadFixedArrayBaseLength(array)); | 950 Node* array_size = LoadAndUntagFixedArrayBaseLength(array); |
| 931 AbortIfWordNotEqual( | 951 AbortIfWordNotEqual( |
| 932 array_size, RegisterCount(), kInvalidRegisterFileInGenerator); | 952 array_size, RegisterCount(), kInvalidRegisterFileInGenerator); |
| 933 } | 953 } |
| 934 | 954 |
| 935 Variable var_index(this, MachineRepresentation::kWord32); | 955 Variable var_index(this, MachineRepresentation::kWord32); |
| 936 var_index.Bind(Int32Constant(0)); | 956 var_index.Bind(Int32Constant(0)); |
| 937 | 957 |
| 938 // Iterate over register file and write values into array. | 958 // Iterate over register file and write values into array. |
| 939 // The mapping of register to array index must match that used in | 959 // The mapping of register to array index must match that used in |
| 940 // BytecodeGraphBuilder::VisitResumeGenerator. | 960 // BytecodeGraphBuilder::VisitResumeGenerator. |
| (...skipping 14 matching lines...) Expand all Loading... |
| 955 var_index.Bind(Int32Add(index, Int32Constant(1))); | 975 var_index.Bind(Int32Add(index, Int32Constant(1))); |
| 956 Goto(&loop); | 976 Goto(&loop); |
| 957 } | 977 } |
| 958 Bind(&done_loop); | 978 Bind(&done_loop); |
| 959 | 979 |
| 960 return array; | 980 return array; |
| 961 } | 981 } |
| 962 | 982 |
| 963 Node* InterpreterAssembler::ImportRegisterFile(Node* array) { | 983 Node* InterpreterAssembler::ImportRegisterFile(Node* array) { |
| 964 if (FLAG_debug_code) { | 984 if (FLAG_debug_code) { |
| 965 Node* array_size = SmiUntag(LoadFixedArrayBaseLength(array)); | 985 Node* array_size = LoadAndUntagFixedArrayBaseLength(array); |
| 966 AbortIfWordNotEqual( | 986 AbortIfWordNotEqual( |
| 967 array_size, RegisterCount(), kInvalidRegisterFileInGenerator); | 987 array_size, RegisterCount(), kInvalidRegisterFileInGenerator); |
| 968 } | 988 } |
| 969 | 989 |
| 970 Variable var_index(this, MachineRepresentation::kWord32); | 990 Variable var_index(this, MachineRepresentation::kWord32); |
| 971 var_index.Bind(Int32Constant(0)); | 991 var_index.Bind(Int32Constant(0)); |
| 972 | 992 |
| 973 // Iterate over array and write values into register file. Also erase the | 993 // Iterate over array and write values into register file. Also erase the |
| 974 // array contents to not keep them alive artificially. | 994 // array contents to not keep them alive artificially. |
| 975 Label loop(this, &var_index), done_loop(this); | 995 Label loop(this, &var_index), done_loop(this); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 992 Goto(&loop); | 1012 Goto(&loop); |
| 993 } | 1013 } |
| 994 Bind(&done_loop); | 1014 Bind(&done_loop); |
| 995 | 1015 |
| 996 return array; | 1016 return array; |
| 997 } | 1017 } |
| 998 | 1018 |
| 999 } // namespace interpreter | 1019 } // namespace interpreter |
| 1000 } // namespace internal | 1020 } // namespace internal |
| 1001 } // namespace v8 | 1021 } // namespace v8 |
| OLD | NEW |