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) {
}
}
uint32_t LiftoffAssembler::GetTotalFrameSlotCount() const {
return kPointerSize * (num_locals() + kMaxValueStackHeight);
}
#undef __
#undef TRACE
......
......@@ -48,6 +48,10 @@ constexpr ValueType kWasmPtrSizeInt = kPointerSize == 8 ? kWasmI64 : kWasmI32;
class LiftoffAssembler : public TurboAssembler {
public:
// TODO(clemensh): Remove this limitation by allocating more stack space if
// needed.
static constexpr int kMaxValueStackHeight = 8;
class PinnedRegisterScope {
public:
PinnedRegisterScope() : pinned_regs_(0) {}
......@@ -266,6 +270,9 @@ class LiftoffAssembler : public TurboAssembler {
uint32_t num_locals() const { return 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) {
DCHECK_GT(num_locals_, index);
ValueType* locals =
......
......@@ -79,7 +79,7 @@ class LiftoffCompiler {
void CheckStackSizeLimit(Decoder* decoder) {
DCHECK_GE(__ 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");
}
}
......@@ -98,8 +98,7 @@ class LiftoffCompiler {
return;
}
__ EnterFrame(StackFrame::WASM_COMPILED);
__ ReserveStackSpace(kPointerSize *
(__ num_locals() + kMaxValueStackHeight));
__ ReserveStackSpace(__ GetTotalFrameSlotCount());
// Parameter 0 is the wasm context.
uint32_t num_params =
static_cast<uint32_t>(call_desc_->ParameterCount()) - 1;
......@@ -481,10 +480,6 @@ class LiftoffCompiler {
compiler::CallDescriptor* call_desc_;
compiler::ModuleEnv* env_;
bool ok_ = true;
// TODO(clemensh): Remove this limitation by allocating more stack space if
// needed.
static constexpr int kMaxValueStackHeight = 8;
};
} // 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