@@ -59,9 +59,6 @@ class Stack
5959// / from the stack itself.
6060class OperandStack
6161{
62- // / The size of the pre-allocated internal storage: 128 bytes.
63- static constexpr auto small_storage_size = 128 / sizeof (Value);
64-
6562 // / The pointer to the top item of the operand stack,
6663 // / or below the stack bottom if stack is empty.
6764 // /
@@ -77,12 +74,6 @@ class OperandStack
7774 // / The pointer to the bottom of the operand stack.
7875 Value* m_bottom;
7976
80- // / The pre-allocated internal storage.
81- Value m_small_storage[small_storage_size];
82-
83- // / The unbounded storage for items.
84- std::unique_ptr<Value[]> m_large_storage;
85-
8677public:
8778 // / Default constructor.
8879 // /
@@ -97,26 +88,16 @@ class OperandStack
9788 // / space after the arguments.
9889 // / @param max_stack_height The maximum operand stack height in the function. This
9990 // / excludes @a args and @a num_local_variables.
100- OperandStack (
101- const Value* args, size_t num_args, size_t num_local_variables, size_t max_stack_height)
91+ OperandStack (const Value* args, size_t num_args, size_t num_local_variables, Value* stack_space)
10292 {
10393 const auto num_locals = num_args + num_local_variables;
10494 // To avoid potential UB when there are no locals and the stack pointer is set to
10595 // m_bottom - 1 (i.e. before storage array), we allocate one additional unused stack item.
106- const auto num_locals_adjusted = num_locals + (num_locals == 0 ); // Bump to 1 if 0.
107- const auto storage_size_required = num_locals_adjusted + max_stack_height;
108-
109- if (storage_size_required <= small_storage_size)
110- {
111- m_locals = &m_small_storage[0 ];
112- }
113- else
114- {
115- m_large_storage = std::make_unique<Value[]>(storage_size_required);
116- m_locals = &m_large_storage[0 ];
117- }
118-
119- m_bottom = m_locals + num_locals_adjusted;
96+ // const auto num_locals_adjusted = num_locals + (num_locals == 0); // Bump to 1 if 0.
97+ // const auto storage_size_required = num_locals_adjusted + max_stack_height;
98+
99+ m_locals = stack_space;
100+ m_bottom = m_locals + num_locals;
120101 m_top = m_bottom - 1 ;
121102
122103 const auto local_variables = std::copy_n (args, num_args, m_locals);
0 commit comments