[sparkplug] Add missing SaveAccumulatorScopes

Some baseline implementations of non-accumulator-writing bytecodes
would call builtins without saving the accumulator. This clobbers the
accumulator. This was particularly observable with IncBlockCounter.

Bug: v8:11420
Change-Id: I1e8a06526ea6ed018da0d6213775cce130c72aee
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2786847
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Auto-Submit: Leszek Swirski <leszeks@chromium.org>
Reviewed-by: Victor Gomes <victorgomes@chromium.org>
Cr-Commit-Position: refs/heads/master@{#73664}
This commit is contained in:
Leszek Swirski 2021-03-25 14:16:36 +01:00 committed by Commit Bot
parent bb3794c711
commit 8f5f5c6828

View File

@ -13,6 +13,7 @@
#include <type_traits>
#include "src/baseline/baseline-assembler-inl.h"
#include "src/baseline/baseline-assembler.h"
#include "src/builtins/builtins-constructor.h"
#include "src/builtins/builtins-descriptors.h"
#include "src/builtins/builtins.h"
@ -956,6 +957,7 @@ void BaselineCompiler::VisitStaDataPropertyInLiteral() {
}
void BaselineCompiler::VisitCollectTypeProfile() {
SaveAccumulatorScope accumulator_scope(&basm_);
CallRuntime(Runtime::kCollectTypeProfile,
IntAsSmi(0), // position
kInterpreterAccumulatorRegister, // value
@ -1241,6 +1243,7 @@ void BaselineCompiler::VisitCallRuntime() {
}
void BaselineCompiler::VisitCallRuntimeForPair() {
SaveAccumulatorScope accumulator_scope(&basm_);
CallRuntime(iterator().GetRuntimeIdOperand(0),
iterator().GetRegisterListOperand(1));
StoreRegisterPair(3, kReturnRegister0, kReturnRegister1);
@ -2330,10 +2333,12 @@ void BaselineCompiler::VisitGetIterator() {
}
void BaselineCompiler::VisitDebugger() {
SaveAccumulatorScope accumulator_scope(&basm_);
CallBuiltin(Builtins::kHandleDebuggerStatement);
}
void BaselineCompiler::VisitIncBlockCounter() {
SaveAccumulatorScope accumulator_scope(&basm_);
CallBuiltin(Builtins::kIncBlockCounter, __ FunctionOperand(),
IndexAsSmi(0)); // coverage array slot
}