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

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: 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
Index: src/interpreter/interpreter-assembler.cc
diff --git a/src/interpreter/interpreter-assembler.cc b/src/interpreter/interpreter-assembler.cc
index 66af04f5f0509c80888e9d1bcc97e609170ad0db..841b4f06f640b6d31e77f14cc56b57f3122c6258 100644
--- a/src/interpreter/interpreter-assembler.cc
+++ b/src/interpreter/interpreter-assembler.cc
@@ -376,6 +376,17 @@ Node* InterpreterAssembler::LoadObjectField(Node* object, int offset) {
IntPtrConstant(offset - kHeapObjectTag));
}
+Node* InterpreterAssembler::LoadObjectFieldInt32(Node* object, int offset) {
+ return Load(MachineType::Int32(), object,
+ IntPtrConstant(offset - kHeapObjectTag));
+}
+
+Node* InterpreterAssembler::StoreObjectField(Node* object, int offset,
+ Node* value) {
+ return Store(MachineRepresentation::kTagged, object,
+ IntPtrConstant(offset - kHeapObjectTag), value);
+}
+
Node* InterpreterAssembler::LoadContextSlot(Node* context, int slot_index) {
return Load(MachineType::AnyTagged(), context,
IntPtrConstant(Context::SlotOffset(slot_index)));
@@ -713,6 +724,74 @@ bool InterpreterAssembler::TargetSupportsUnalignedAccess() {
#endif
}
+Node* InterpreterAssembler::RegisterCount() {
+ Node* bytecode_array = LoadRegister(Register::bytecode_array());
+ Node* frame_size =
+ LoadObjectFieldInt32(bytecode_array, BytecodeArray::kFrameSizeOffset);
+ return Word32Sar(frame_size, Int32Constant(kPointerSizeLog2));
+}
+
+Node* InterpreterAssembler::ExportRegisterFile() {
+ Node* register_count = RegisterCount();
+ Node* array =
+ AllocateUninitializedFixedArray(ChangeInt32ToWord(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::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!
+ Node* value = LoadRegister(ChangeInt32ToWord(reg_index));
+
+ 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
+ array, ChangeInt32ToWord(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::kRegisterFileStartOffset), index);
+ StoreRegister(value, ChangeInt32ToWord(reg_index));
+
+ var_index.Bind(Int32Add(index, Int32Constant(1)));
+ Goto(&loop);
+ }
+ Bind(&done_loop);
+
+ return array;
+}
+
} // namespace interpreter
} // namespace internal
} // namespace v8

Powered by Google App Engine
This is Rietveld 408576698