Chromium Code Reviews| 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 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 369 IntPtrAdd(IntPtrConstant(FixedArray::kHeaderSize - kHeapObjectTag), | 369 IntPtrAdd(IntPtrConstant(FixedArray::kHeaderSize - kHeapObjectTag), |
| 370 WordShl(index, kPointerSizeLog2)); | 370 WordShl(index, kPointerSizeLog2)); |
| 371 return Load(MachineType::AnyTagged(), constant_pool, entry_offset); | 371 return Load(MachineType::AnyTagged(), constant_pool, entry_offset); |
| 372 } | 372 } |
| 373 | 373 |
| 374 Node* InterpreterAssembler::LoadObjectField(Node* object, int offset) { | 374 Node* InterpreterAssembler::LoadObjectField(Node* object, int offset) { |
| 375 return Load(MachineType::AnyTagged(), object, | 375 return Load(MachineType::AnyTagged(), object, |
| 376 IntPtrConstant(offset - kHeapObjectTag)); | 376 IntPtrConstant(offset - kHeapObjectTag)); |
| 377 } | 377 } |
| 378 | 378 |
| 379 Node* InterpreterAssembler::LoadObjectFieldInt32(Node* object, int offset) { | |
| 380 return Load(MachineType::Int32(), object, | |
| 381 IntPtrConstant(offset - kHeapObjectTag)); | |
| 382 } | |
| 383 | |
| 384 Node* InterpreterAssembler::StoreObjectField(Node* object, int offset, | |
| 385 Node* value) { | |
| 386 return Store(MachineRepresentation::kTagged, object, | |
| 387 IntPtrConstant(offset - kHeapObjectTag), value); | |
| 388 } | |
| 389 | |
| 379 Node* InterpreterAssembler::LoadContextSlot(Node* context, int slot_index) { | 390 Node* InterpreterAssembler::LoadContextSlot(Node* context, int slot_index) { |
| 380 return Load(MachineType::AnyTagged(), context, | 391 return Load(MachineType::AnyTagged(), context, |
| 381 IntPtrConstant(Context::SlotOffset(slot_index))); | 392 IntPtrConstant(Context::SlotOffset(slot_index))); |
| 382 } | 393 } |
| 383 | 394 |
| 384 Node* InterpreterAssembler::LoadContextSlot(Node* context, Node* slot_index) { | 395 Node* InterpreterAssembler::LoadContextSlot(Node* context, Node* slot_index) { |
| 385 Node* offset = | 396 Node* offset = |
| 386 IntPtrAdd(WordShl(slot_index, kPointerSizeLog2), | 397 IntPtrAdd(WordShl(slot_index, kPointerSizeLog2), |
| 387 IntPtrConstant(Context::kHeaderSize - kHeapObjectTag)); | 398 IntPtrConstant(Context::kHeaderSize - kHeapObjectTag)); |
| 388 return Load(MachineType::AnyTagged(), context, offset); | 399 return Load(MachineType::AnyTagged(), context, offset); |
| (...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 706 #elif V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_PPC | 717 #elif V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_PPC |
| 707 return CpuFeatures::IsSupported(UNALIGNED_ACCESSES); | 718 return CpuFeatures::IsSupported(UNALIGNED_ACCESSES); |
| 708 #elif V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_X87 || \ | 719 #elif V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_X87 || \ |
| 709 V8_TARGET_ARCH_S390 | 720 V8_TARGET_ARCH_S390 |
| 710 return true; | 721 return true; |
| 711 #else | 722 #else |
| 712 #error "Unknown Architecture" | 723 #error "Unknown Architecture" |
| 713 #endif | 724 #endif |
| 714 } | 725 } |
| 715 | 726 |
| 727 Node* InterpreterAssembler::RegisterCount() { | |
| 728 Node* bytecode_array = LoadRegister(Register::bytecode_array()); | |
| 729 Node* frame_size = | |
| 730 LoadObjectFieldInt32(bytecode_array, BytecodeArray::kFrameSizeOffset); | |
| 731 return Word32Sar(frame_size, Int32Constant(kPointerSizeLog2)); | |
| 732 } | |
| 733 | |
| 734 Node* InterpreterAssembler::ExportRegisterFile() { | |
| 735 Node* register_count = RegisterCount(); | |
| 736 Node* array = | |
| 737 AllocateUninitializedFixedArray(ChangeInt32ToWord(register_count)); | |
| 738 | |
| 739 Variable var_index(this, MachineRepresentation::kWord32); | |
| 740 var_index.Bind(Int32Constant(0)); | |
| 741 | |
| 742 // Iterate over register file and write values into array. | |
| 743 Label loop(this, &var_index), done_loop(this); | |
| 744 Goto(&loop); | |
| 745 Bind(&loop); | |
| 746 { | |
| 747 Node* index = var_index.value(); | |
| 748 Node* condition = Int32LessThan(index, register_count); | |
| 749 GotoUnless(condition, &done_loop); | |
| 750 | |
| 751 Node* reg_index = | |
| 752 Int32Sub(Int32Constant(Register::kRegisterFileStartOffset), index); | |
|
rmcilroy
2016/04/21 10:21:32
I'd prefer to keep kRegisterFileStartOffset privat
neis
2016/04/21 11:30:15
I don't want to change var_index because it's also
rmcilroy
2016/04/21 13:55:02
Works for me, thanks!
| |
| 753 Node* value = LoadRegister(ChangeInt32ToWord(reg_index)); | |
| 754 | |
| 755 StoreFixedArrayElementNoWriteBarrier( | |
|
rmcilroy
2016/04/21 10:21:32
I'm not sure NoWriteBarrier is correct here. The r
neis
2016/04/21 11:30:15
I was told that it's not needed since we are writi
rmcilroy
2016/04/21 13:55:02
That sounds plausible :). Please add a comment to
| |
| 756 array, ChangeInt32ToWord(index), value); | |
| 757 | |
| 758 var_index.Bind(Int32Add(index, Int32Constant(1))); | |
| 759 Goto(&loop); | |
| 760 } | |
| 761 Bind(&done_loop); | |
| 762 | |
| 763 return array; | |
| 764 } | |
| 765 | |
| 766 Node* InterpreterAssembler::ImportRegisterFile(Node* array) { | |
| 767 Node* register_count = RegisterCount(); | |
| 768 | |
| 769 Variable var_index(this, MachineRepresentation::kWord32); | |
| 770 var_index.Bind(Int32Constant(0)); | |
| 771 | |
| 772 // Iterate over array and write values into register file. | |
| 773 Label loop(this, &var_index), done_loop(this); | |
| 774 Goto(&loop); | |
| 775 Bind(&loop); | |
| 776 { | |
| 777 Node* index = var_index.value(); | |
| 778 Node* condition = Int32LessThan(index, register_count); | |
| 779 GotoUnless(condition, &done_loop); | |
| 780 | |
| 781 Node* value = LoadFixedArrayElementInt32Index(array, index); | |
| 782 | |
| 783 Node* reg_index = | |
| 784 Int32Sub(Int32Constant(Register::kRegisterFileStartOffset), index); | |
| 785 StoreRegister(value, ChangeInt32ToWord(reg_index)); | |
| 786 | |
| 787 var_index.Bind(Int32Add(index, Int32Constant(1))); | |
| 788 Goto(&loop); | |
| 789 } | |
| 790 Bind(&done_loop); | |
| 791 | |
| 792 return array; | |
| 793 } | |
| 794 | |
| 716 } // namespace interpreter | 795 } // namespace interpreter |
| 717 } // namespace internal | 796 } // namespace internal |
| 718 } // namespace v8 | 797 } // namespace v8 |
| OLD | NEW |