Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: src/interpreter/interpreter-assembler.cc

Issue 1904933002: Introduce bytecodes for assisting generator suspend and resume. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Nix Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/interpreter/interpreter-assembler.h ('k') | src/runtime/runtime.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 364
365 Node* InterpreterAssembler::LoadConstantPoolEntry(Node* index) { 365 Node* InterpreterAssembler::LoadConstantPoolEntry(Node* index) {
366 Node* constant_pool = LoadObjectField(BytecodeArrayTaggedPointer(), 366 Node* constant_pool = LoadObjectField(BytecodeArrayTaggedPointer(),
367 BytecodeArray::kConstantPoolOffset); 367 BytecodeArray::kConstantPoolOffset);
368 Node* entry_offset = 368 Node* entry_offset =
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) {
375 return Load(MachineType::AnyTagged(), object,
376 IntPtrConstant(offset - kHeapObjectTag));
377 }
378
379 Node* InterpreterAssembler::LoadContextSlot(Node* context, int slot_index) { 374 Node* InterpreterAssembler::LoadContextSlot(Node* context, int slot_index) {
380 return Load(MachineType::AnyTagged(), context, 375 return Load(MachineType::AnyTagged(), context,
381 IntPtrConstant(Context::SlotOffset(slot_index))); 376 IntPtrConstant(Context::SlotOffset(slot_index)));
382 } 377 }
383 378
384 Node* InterpreterAssembler::LoadContextSlot(Node* context, Node* slot_index) { 379 Node* InterpreterAssembler::LoadContextSlot(Node* context, Node* slot_index) {
385 Node* offset = 380 Node* offset =
386 IntPtrAdd(WordShl(slot_index, kPointerSizeLog2), 381 IntPtrAdd(WordShl(slot_index, kPointerSizeLog2),
387 IntPtrConstant(Context::kHeaderSize - kHeapObjectTag)); 382 IntPtrConstant(Context::kHeaderSize - kHeapObjectTag));
388 return Load(MachineType::AnyTagged(), context, offset); 383 return Load(MachineType::AnyTagged(), context, offset);
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
706 #elif V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_PPC 701 #elif V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_PPC
707 return CpuFeatures::IsSupported(UNALIGNED_ACCESSES); 702 return CpuFeatures::IsSupported(UNALIGNED_ACCESSES);
708 #elif V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_X87 || \ 703 #elif V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_X87 || \
709 V8_TARGET_ARCH_S390 704 V8_TARGET_ARCH_S390
710 return true; 705 return true;
711 #else 706 #else
712 #error "Unknown Architecture" 707 #error "Unknown Architecture"
713 #endif 708 #endif
714 } 709 }
715 710
711 Node* InterpreterAssembler::RegisterCount() {
712 Node* bytecode_array = LoadRegister(Register::bytecode_array());
713 Node* frame_size = LoadObjectField(
714 bytecode_array, BytecodeArray::kFrameSizeOffset, MachineType::Int32());
715 return Word32Sar(frame_size, Int32Constant(kPointerSizeLog2));
716 }
717
718 Node* InterpreterAssembler::ExportRegisterFile() {
719 Node* register_count = RegisterCount();
720 Node* array =
721 AllocateUninitializedFixedArray(ChangeInt32ToIntPtr(register_count));
722
723 Variable var_index(this, MachineRepresentation::kWord32);
724 var_index.Bind(Int32Constant(0));
725
726 // Iterate over register file and write values into array.
727 Label loop(this, &var_index), done_loop(this);
728 Goto(&loop);
729 Bind(&loop);
730 {
731 Node* index = var_index.value();
732 Node* condition = Int32LessThan(index, register_count);
733 GotoUnless(condition, &done_loop);
734
735 Node* reg_index =
736 Int32Sub(Int32Constant(Register(0).ToOperand()), index);
737 Node* value = LoadRegister(ChangeInt32ToIntPtr(reg_index));
738
739 // No write barrier needed for writing into freshly allocated object.
740 StoreFixedArrayElementNoWriteBarrier(
741 array, ChangeInt32ToIntPtr(index), value);
742
743 var_index.Bind(Int32Add(index, Int32Constant(1)));
744 Goto(&loop);
745 }
746 Bind(&done_loop);
747
748 return array;
749 }
750
751 Node* InterpreterAssembler::ImportRegisterFile(Node* array) {
752 Node* register_count = RegisterCount();
753
754 Variable var_index(this, MachineRepresentation::kWord32);
755 var_index.Bind(Int32Constant(0));
756
757 // Iterate over array and write values into register file.
758 Label loop(this, &var_index), done_loop(this);
759 Goto(&loop);
760 Bind(&loop);
761 {
762 Node* index = var_index.value();
763 Node* condition = Int32LessThan(index, register_count);
764 GotoUnless(condition, &done_loop);
765
766 Node* value = LoadFixedArrayElementInt32Index(array, index);
767
768 Node* reg_index =
769 Int32Sub(Int32Constant(Register(0).ToOperand()), index);
770 StoreRegister(value, ChangeInt32ToIntPtr(reg_index));
771
772 var_index.Bind(Int32Add(index, Int32Constant(1)));
773 Goto(&loop);
774 }
775 Bind(&done_loop);
776
777 return array;
778 }
779
716 } // namespace interpreter 780 } // namespace interpreter
717 } // namespace internal 781 } // namespace internal
718 } // namespace v8 782 } // namespace v8
OLDNEW
« no previous file with comments | « src/interpreter/interpreter-assembler.h ('k') | src/runtime/runtime.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698