Commit b9778819 authored by Mircea Trofin's avatar Mircea Trofin Committed by Commit Bot

[liftoff] API for exposing frame slot count

Factor out slot count calculation, and expose it so it may later be
consumed when JIT-ing to the WasmCodeManager.

Bug: 
Change-Id: I21d673b2e3d7fa4a66ae0ab6303d29cf666d743c
Reviewed-on: https://chromium-review.googlesource.com/782701Reviewed-by: 's avatarClemens Hammacher <clemensh@chromium.org>
Commit-Queue: Mircea Trofin <mtrofin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#49556}
parent b0305738
...@@ -387,6 +387,10 @@ void LiftoffAssembler::set_num_locals(uint32_t num_locals) { ...@@ -387,6 +387,10 @@ void LiftoffAssembler::set_num_locals(uint32_t num_locals) {
} }
} }
uint32_t LiftoffAssembler::GetTotalFrameSlotCount() const {
return kPointerSize * (num_locals() + kMaxValueStackHeight);
}
#undef __ #undef __
#undef TRACE #undef TRACE
......
...@@ -48,6 +48,10 @@ constexpr ValueType kWasmPtrSizeInt = kPointerSize == 8 ? kWasmI64 : kWasmI32; ...@@ -48,6 +48,10 @@ constexpr ValueType kWasmPtrSizeInt = kPointerSize == 8 ? kWasmI64 : kWasmI32;
class LiftoffAssembler : public TurboAssembler { class LiftoffAssembler : public TurboAssembler {
public: public:
// TODO(clemensh): Remove this limitation by allocating more stack space if
// needed.
static constexpr int kMaxValueStackHeight = 8;
class PinnedRegisterScope { class PinnedRegisterScope {
public: public:
PinnedRegisterScope() : pinned_regs_(0) {} PinnedRegisterScope() : pinned_regs_(0) {}
...@@ -266,6 +270,9 @@ class LiftoffAssembler : public TurboAssembler { ...@@ -266,6 +270,9 @@ class LiftoffAssembler : public TurboAssembler {
uint32_t num_locals() const { return num_locals_; } uint32_t num_locals() const { return num_locals_; }
void set_num_locals(uint32_t num_locals); void set_num_locals(uint32_t num_locals);
uint32_t GetTotalFrameSlotCount() const;
size_t GetSafepointTableOffset() const { return 0; }
ValueType local_type(uint32_t index) { ValueType local_type(uint32_t index) {
DCHECK_GT(num_locals_, index); DCHECK_GT(num_locals_, index);
ValueType* locals = ValueType* locals =
......
...@@ -79,7 +79,7 @@ class LiftoffCompiler { ...@@ -79,7 +79,7 @@ class LiftoffCompiler {
void CheckStackSizeLimit(Decoder* decoder) { void CheckStackSizeLimit(Decoder* decoder) {
DCHECK_GE(__ cache_state()->stack_height(), __ num_locals()); DCHECK_GE(__ cache_state()->stack_height(), __ num_locals());
int stack_height = __ cache_state()->stack_height() - __ num_locals(); int stack_height = __ cache_state()->stack_height() - __ num_locals();
if (stack_height > kMaxValueStackHeight) { if (stack_height > LiftoffAssembler::kMaxValueStackHeight) {
unsupported(decoder, "value stack grows too large"); unsupported(decoder, "value stack grows too large");
} }
} }
...@@ -98,8 +98,7 @@ class LiftoffCompiler { ...@@ -98,8 +98,7 @@ class LiftoffCompiler {
return; return;
} }
__ EnterFrame(StackFrame::WASM_COMPILED); __ EnterFrame(StackFrame::WASM_COMPILED);
__ ReserveStackSpace(kPointerSize * __ ReserveStackSpace(__ GetTotalFrameSlotCount());
(__ num_locals() + kMaxValueStackHeight));
// Parameter 0 is the wasm context. // Parameter 0 is the wasm context.
uint32_t num_params = uint32_t num_params =
static_cast<uint32_t>(call_desc_->ParameterCount()) - 1; static_cast<uint32_t>(call_desc_->ParameterCount()) - 1;
...@@ -481,10 +480,6 @@ class LiftoffCompiler { ...@@ -481,10 +480,6 @@ class LiftoffCompiler {
compiler::CallDescriptor* call_desc_; compiler::CallDescriptor* call_desc_;
compiler::ModuleEnv* env_; compiler::ModuleEnv* env_;
bool ok_ = true; bool ok_ = true;
// TODO(clemensh): Remove this limitation by allocating more stack space if
// needed.
static constexpr int kMaxValueStackHeight = 8;
}; };
} // namespace } // namespace
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment