Skip to content

Instantly share code, notes, and snippets.

@smarr

smarr/interp.c Secret

Created July 24, 2021 21:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save smarr/9a628e44e949b2f2149bd360425523ec to your computer and use it in GitHub Desktop.
Save smarr/9a628e44e949b2f2149bd360425523ec to your computer and use it in GitHub Desktop.
RPython and Stack
// stack_ptr = -1
// stack = [None] * max_stack_size
// make_sure_not_resized(stack)
// ...
// while True:
// ...
// elif bytecode == Bytecodes.push_frame_0:
// stack_ptr += 1
// stack[stack_ptr] = read_frame(frame, FRAME_AND_INNER_RCVR_IDX + 0)
case 3L:
OP_INT_ADD(l_stack_ptr_8, 1L, l_stack_ptr_11);
RPyAssert(1, "unexpectedly negative list getitem index");
l_v45265 = l_frame_8->length;
OP_INT_LT(1L, l_v45265, l_v45266);
RPyAssert(l_v45266, "fixed getitem out of bounds");
l_v45268 = RPyItem(l_frame_8, 1L);
l_v45269 = (struct pypy_som_vmobjects_abstract_object_AbstractObject0 *)l_v45268;
l_newitem_9 = (struct pypy_object0 *)l_v45269;
// STEFAN: relevant bits here
OP_INT_LT(l_stack_ptr_11, 0L, l_v45270); // STEFAN: stack_ptr out of bounds is never used, so, not needed
if (l_v45270) { // STEFAN: Ideally, this block wouldn't exist
/* block49: (inlined) */
l_v45279 = l_stack_7->length;
OP_INT_ADD(l_stack_ptr_11, l_v45279, l_index_461);
OP_INT_GE(l_index_461, 0L, l_v45280);
RPyAssert(l_v45280, "negative list setitem index out of bound");
l_index_402 = l_index_461;
goto block46;
}
l_index_402 = l_stack_ptr_11;
goto block46;
block46:
l_v45271 = l_stack_7->length; // STEFAN: ideally, not needed
OP_INT_LT(l_index_402, l_v45271, l_v45272); // STEFAN: ideally, not needed
RPyAssert(l_v45272, "fixed setitem out of bounds"); // STEFAN: ideally, not needed
l_addr_array_108 = (void*)l_stack_7;
OP_ADR_SUB(l_addr_array_108, 0, l_addr_700);
l_v45274 = (struct pypy_header0 *)l_addr_700;
l_v45275 = ((char *)l_v45274)[4] & 1;
OP_INT_IS_TRUE(l_v45275, l_v45276);
if (l_v45276) {
/* block48: (inlined) */
pypy_g_remember_young_pointer_from_array2(l_addr_array_108, l_index_402);
goto block47;
}
goto block47;
block47:
RPyItem(l_stack_7, l_index_402) = l_newitem_9; // STEFAN: Ideally, that's all that's done
l_stack_ptr_50 = l_stack_ptr_11;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment