[Bf-blender-cvs] [c251ddeafc8] functions: simplify execution stack management
Jacques Lucke
noreply at git.blender.org
Sat Apr 6 18:47:31 CEST 2019
Commit: c251ddeafc8d621f480175745cd6892afcb0c0f3
Author: Jacques Lucke
Date: Sat Apr 6 18:46:42 2019 +0200
Branches: functions
https://developer.blender.org/rBc251ddeafc8d621f480175745cd6892afcb0c0f3
simplify execution stack management
===================================================================
M source/blender/blenlib/BLI_small_stack.hpp
M source/blender/functions/backends/llvm/ir_for_tuple_call.cpp
M source/blender/functions/backends/tuple_call/execution_context.hpp
M source/blender/functions/backends/tuple_call/fgraph_tuple_call.cpp
M source/blender/functions/backends/tuple_call/tuple_call-c.cpp
M source/blender/functions/backends/tuple_call/tuple_call.hpp
M source/blender/functions/functions/auto_vectorization.cpp
===================================================================
diff --git a/source/blender/blenlib/BLI_small_stack.hpp b/source/blender/blenlib/BLI_small_stack.hpp
index a36f39389cd..882f9b634bf 100644
--- a/source/blender/blenlib/BLI_small_stack.hpp
+++ b/source/blender/blenlib/BLI_small_stack.hpp
@@ -4,10 +4,10 @@
namespace BLI {
- template<typename T>
+ template<typename T, uint N = 4>
class SmallStack {
private:
- SmallVector<T> m_elements;
+ SmallVector<T, N> m_elements;
public:
SmallStack() = default;
diff --git a/source/blender/functions/backends/llvm/ir_for_tuple_call.cpp b/source/blender/functions/backends/llvm/ir_for_tuple_call.cpp
index fe268108b18..18823626a8b 100644
--- a/source/blender/functions/backends/llvm/ir_for_tuple_call.cpp
+++ b/source/blender/functions/backends/llvm/ir_for_tuple_call.cpp
@@ -18,9 +18,7 @@ namespace FN {
fn_in.set_all_initialized();
TextStackFrame frame("IR for Tuple Call Wrapper");
- ctx->stack().push(&frame);
- body->call(fn_in, fn_out, *ctx);
- ctx->stack().pop();
+ body->call__setup_stack(fn_in, fn_out, *ctx, frame);
/* This way the data is not freed with the tuples. */
fn_out.set_all_uninitialized();
diff --git a/source/blender/functions/backends/tuple_call/execution_context.hpp b/source/blender/functions/backends/tuple_call/execution_context.hpp
index a1934097ebe..b00ebcf3794 100644
--- a/source/blender/functions/backends/tuple_call/execution_context.hpp
+++ b/source/blender/functions/backends/tuple_call/execution_context.hpp
@@ -47,7 +47,7 @@ namespace FN {
class ExecutionStack {
private:
- SmallStack<StackFrame *> m_stack;
+ SmallStack<StackFrame *, 10> m_stack;
public:
ExecutionStack() = default;
diff --git a/source/blender/functions/backends/tuple_call/fgraph_tuple_call.cpp b/source/blender/functions/backends/tuple_call/fgraph_tuple_call.cpp
index ada61e5867a..a05f8646243 100644
--- a/source/blender/functions/backends/tuple_call/fgraph_tuple_call.cpp
+++ b/source/blender/functions/backends/tuple_call/fgraph_tuple_call.cpp
@@ -301,7 +301,7 @@ namespace FN {
{
Tuple &fn_in = this->get_tuple(buffer, task.data.call.index_in);
Tuple &fn_out = this->get_tuple(buffer, task.data.call.index_out);
- task.data.call.body->call(fn_in, fn_out, ctx);
+ task.data.call.body->call__setup_stack(fn_in, fn_out, ctx);
break;
}
case OpCode::GetInput:
@@ -401,12 +401,7 @@ namespace FN {
}
SourceInfoStackFrame node_frame(node->source());
- TextStackFrame function_frame(fn->name().c_str());
- ctx.stack().push(&node_frame);
- ctx.stack().push(&function_frame);
- body->call(tmp_in, tmp_out, ctx);
- ctx.stack().pop();
- ctx.stack().pop();
+ body->call__setup_stack(tmp_in, tmp_out, ctx, node_frame);
Tuple::copy_element(tmp_out, socket.index(), out, out_index);
}
@@ -549,7 +544,7 @@ namespace FN {
fn_in, input_index);
}
- body->call(fn_in, fn_out, ctx);
+ body->call__setup_stack(fn_in, fn_out, ctx);
BLI_assert(fn_out.all_initialized());
for (uint output_index = 0; output_index < node->output_amount(); output_index++) {
diff --git a/source/blender/functions/backends/tuple_call/tuple_call-c.cpp b/source/blender/functions/backends/tuple_call/tuple_call-c.cpp
index a31e036df26..cacea156627 100644
--- a/source/blender/functions/backends/tuple_call/tuple_call-c.cpp
+++ b/source/blender/functions/backends/tuple_call/tuple_call-c.cpp
@@ -17,11 +17,9 @@ void FN_tuple_call_invoke(
ExecutionStack stack;
TextStackFrame caller_frame(caller_info);
stack.push(&caller_frame);
- TextStackFrame function_frame(body_->owner()->name().c_str());
- stack.push(&function_frame);
ExecutionContext ctx(stack);
- body_->call(fn_in_, fn_out_, ctx);
+ body_->call__setup_stack(fn_in_, fn_out_, ctx);
BLI_assert(fn_out_.all_initialized());
}
diff --git a/source/blender/functions/backends/tuple_call/tuple_call.hpp b/source/blender/functions/backends/tuple_call/tuple_call.hpp
index 357417097c9..5e466fbd18c 100644
--- a/source/blender/functions/backends/tuple_call/tuple_call.hpp
+++ b/source/blender/functions/backends/tuple_call/tuple_call.hpp
@@ -41,6 +41,13 @@ namespace FN {
ctx.stack().pop();
}
+ inline void call__setup_stack(Tuple &fn_in, Tuple &fn_out, ExecutionContext &ctx, StackFrame &extra_frame)
+ {
+ ctx.stack().push(&extra_frame);
+ this->call__setup_stack(fn_in, fn_out, ctx);
+ ctx.stack().pop();
+ }
+
virtual void call(Tuple &fn_in, Tuple &fn_out, ExecutionContext &ctx) const = 0;
};
diff --git a/source/blender/functions/functions/auto_vectorization.cpp b/source/blender/functions/functions/auto_vectorization.cpp
index 86df424a4ad..616d1e42ac9 100644
--- a/source/blender/functions/functions/auto_vectorization.cpp
+++ b/source/blender/functions/functions/auto_vectorization.cpp
@@ -80,7 +80,7 @@ namespace FN { namespace Functions {
}
}
- m_main_body->call(main_in, main_out, ctx);
+ m_main_body->call__setup_stack(main_in, main_out, ctx);
for (uint i = 0; i < m_main->signature().outputs().size(); i++) {
this->append_to_output(main_out, fn_out, i, ctx);
More information about the Bf-blender-cvs
mailing list