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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/interpreter/interpreter-assembler.h ('k') | src/runtime/runtime.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/interpreter/interpreter-assembler.cc
diff --git a/src/interpreter/interpreter-assembler.cc b/src/interpreter/interpreter-assembler.cc
index 66af04f5f0509c80888e9d1bcc97e609170ad0db..ff935d6ad61bd8f02037085e533e61cb7de01bf6 100644
--- a/src/interpreter/interpreter-assembler.cc
+++ b/src/interpreter/interpreter-assembler.cc
@@ -371,11 +371,6 @@ Node* InterpreterAssembler::LoadConstantPoolEntry(Node* index) {
return Load(MachineType::AnyTagged(), constant_pool, entry_offset);
}
-Node* InterpreterAssembler::LoadObjectField(Node* object, int offset) {
- return Load(MachineType::AnyTagged(), object,
- IntPtrConstant(offset - kHeapObjectTag));
-}
-
Node* InterpreterAssembler::LoadContextSlot(Node* context, int slot_index) {
return Load(MachineType::AnyTagged(), context,
IntPtrConstant(Context::SlotOffset(slot_index)));
@@ -713,6 +708,75 @@ bool InterpreterAssembler::TargetSupportsUnalignedAccess() {
#endif
}
+Node* InterpreterAssembler::RegisterCount() {
+ Node* bytecode_array = LoadRegister(Register::bytecode_array());
+ Node* frame_size = LoadObjectField(
+ bytecode_array, BytecodeArray::kFrameSizeOffset, MachineType::Int32());
+ return Word32Sar(frame_size, Int32Constant(kPointerSizeLog2));
+}
+
+Node* InterpreterAssembler::ExportRegisterFile() {
+ Node* register_count = RegisterCount();
+ Node* array =
+ AllocateUninitializedFixedArray(ChangeInt32ToIntPtr(register_count));
+
+ Variable var_index(this, MachineRepresentation::kWord32);
+ var_index.Bind(Int32Constant(0));
+
+ // Iterate over register file and write values into array.
+ Label loop(this, &var_index), done_loop(this);
+ Goto(&loop);
+ Bind(&loop);
+ {
+ Node* index = var_index.value();
+ Node* condition = Int32LessThan(index, register_count);
+ GotoUnless(condition, &done_loop);
+
+ Node* reg_index =
+ Int32Sub(Int32Constant(Register(0).ToOperand()), index);
+ Node* value = LoadRegister(ChangeInt32ToIntPtr(reg_index));
+
+ // No write barrier needed for writing into freshly allocated object.
+ StoreFixedArrayElementNoWriteBarrier(
+ array, ChangeInt32ToIntPtr(index), value);
+
+ var_index.Bind(Int32Add(index, Int32Constant(1)));
+ Goto(&loop);
+ }
+ Bind(&done_loop);
+
+ return array;
+}
+
+Node* InterpreterAssembler::ImportRegisterFile(Node* array) {
+ Node* register_count = RegisterCount();
+
+ Variable var_index(this, MachineRepresentation::kWord32);
+ var_index.Bind(Int32Constant(0));
+
+ // Iterate over array and write values into register file.
+ Label loop(this, &var_index), done_loop(this);
+ Goto(&loop);
+ Bind(&loop);
+ {
+ Node* index = var_index.value();
+ Node* condition = Int32LessThan(index, register_count);
+ GotoUnless(condition, &done_loop);
+
+ Node* value = LoadFixedArrayElementInt32Index(array, index);
+
+ Node* reg_index =
+ Int32Sub(Int32Constant(Register(0).ToOperand()), index);
+ StoreRegister(value, ChangeInt32ToIntPtr(reg_index));
+
+ var_index.Bind(Int32Add(index, Int32Constant(1)));
+ Goto(&loop);
+ }
+ Bind(&done_loop);
+
+ return array;
+}
+
} // namespace interpreter
} // namespace internal
} // namespace v8
« 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