# HG changeset patch # User Petter .T # Date 1701381755 -3600 # Thu Nov 30 23:02:35 2023 +0100 # Branch bytecode-interpreter # Node ID 2f8f00bc55d9904b830b9600f67b368187e08953 # Parent ed176bb5f7e66bdcd59459c3d5fddda537f16134 Use 32-bit bytecode interpreter stack elements on 32-bit systems Remove always 64-bit type fields in stack element union, to decrease the memory footprint of the stack. Instead use octave_idx_type that is 32-bits on 32-bit systems. * pt-bytecode.h: (stack_element) Remove always 64-bit types. Add octave_idx_type idx field instead. * pt-bytecode-vm.cc: Use idx field where appropiate. diff -r ed176bb5f7e6 -r 2f8f00bc55d9 libinterp/parse-tree/pt-bytecode-vm.cc --- a/libinterp/parse-tree/pt-bytecode-vm.cc Thu Mar 07 21:19:52 2024 -0500 +++ b/libinterp/parse-tree/pt-bytecode-vm.cc Thu Nov 30 23:02:35 2023 +0100 @@ -845,8 +845,8 @@ do {\ for (unsigned i = 0; i < stack_pad; i++)\ {\ - CHECK (m_stack0[i].u == stack_magic_int);\ - CHECK (m_stack0[i + stack_size].u == stack_magic_int);\ + CHECK (m_stack0[i].idx == static_cast (stack_magic_int));\ + CHECK (m_stack0[i + stack_size].idx == static_cast (stack_magic_int));\ }\ CHECK (sp <= m_stack + stack_size);\ CHECK (sp + n <= m_stack + stack_size);\ @@ -3113,10 +3113,10 @@ // Push n to the stack - (*sp++).i = n; + (*sp++).idx = n; // Push a counter to the stack, initialized so that it will // increment to 0. - (*sp++).i = -1; + (*sp++).idx = -1; // For empty rhs just assign it to lhs if (! n && ov_range.is_defined ()) @@ -3162,11 +3162,11 @@ CATCH_EXIT_EXCEPTION // Increase counter - TOP ().i++; // Wraps to zero first iteration + TOP ().idx++; // Wraps to zero first iteration // Check if we done all iterations // n is second element on the stack - if (TOP ().i == SEC ().i) + if (TOP ().idx == SEC ().idx) { // The after address unsigned char b0 = *ip++; @@ -3183,7 +3183,7 @@ int slot = arg0; ip +=2; // Skip the after address - octave_idx_type counter = TOP ().i; + octave_idx_type counter = TOP ().idx; octave_value &ov_range = THIRD_OV (); octave_value &ov_it = bsp[slot].ov; @@ -4009,21 +4009,21 @@ octave_idx_type n = keys.numel (); // Push n to the stack - (*sp++).i = n; + (*sp++).idx = n; // Push a counter to the stack, initialized so that it will // increment to 0. - (*sp++).i = -1; + (*sp++).idx = -1; } DISPATCH (); for_complex_cond: { // Increase counter - TOP ().i++; // Wraps to zero first iteration + TOP ().idx++; // Wraps to zero first iteration // Check if we done all iterations // n is second element on the stack - if (TOP ().i == SEC ().i) + if (TOP ().idx == SEC ().idx) { // The after address unsigned char b0 = arg0; @@ -4039,7 +4039,7 @@ ip++; // Skip 2nd part of afteraddress int slot_key = POP_CODE_USHORT (); int slot_value = POP_CODE_USHORT (); - octave_idx_type counter = TOP ().i; + octave_idx_type counter = TOP ().idx; octave_value &ov_rhs = THIRD_OV (); // This is always a struct octave_value &ov_key = bsp[slot_key].ov; @@ -7531,8 +7531,8 @@ for (unsigned i = 0; i < stack_pad; i++) { - m_stack0[i].u = stack_magic_int; - m_stack0[i + stack_size].u = stack_magic_int; + m_stack0[i].idx = static_cast (stack_magic_int); + m_stack0[i + stack_size].idx = static_cast (stack_magic_int); } m_sp = m_stack = m_stack0 + stack_pad; diff -r ed176bb5f7e6 -r 2f8f00bc55d9 libinterp/parse-tree/pt-bytecode.h --- a/libinterp/parse-tree/pt-bytecode.h Thu Mar 07 21:19:52 2024 -0500 +++ b/libinterp/parse-tree/pt-bytecode.h Thu Nov 30 23:02:35 2023 +0100 @@ -316,9 +316,10 @@ octave_value ov; octave_value_vm ov_vm; octave_base_value *ovb; - uint64_t u; - int64_t i; - double d; + unsigned u; + int i; + + octave_idx_type idx; void *pv; const char *pcc;