diff options
author | Martin Neupauer <xmaton@messengeruser.com> | 2023-05-15 16:50:05 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2023-05-15 22:40:45 +0000 |
commit | ba0986ac66e3a22d211ad3707ad037fdc10910af (patch) | |
tree | c8bb00824af7b99e2bc9a3a48a02b6961b36d8a0 /src/mongo/db/exec/sbe/vm/vm.cpp | |
parent | d7b25f8f62727ec1138d5b21fde6e82a1dfa8d97 (diff) | |
download | mongo-ba0986ac66e3a22d211ad3707ad037fdc10910af.tar.gz |
SERVER-76896 Add direct access for two common slot accessors
Diffstat (limited to 'src/mongo/db/exec/sbe/vm/vm.cpp')
-rw-r--r-- | src/mongo/db/exec/sbe/vm/vm.cpp | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/src/mongo/db/exec/sbe/vm/vm.cpp b/src/mongo/db/exec/sbe/vm/vm.cpp index 5bdcc7496a2..2f7c1bee391 100644 --- a/src/mongo/db/exec/sbe/vm/vm.cpp +++ b/src/mongo/db/exec/sbe/vm/vm.cpp @@ -33,6 +33,7 @@ #include "mongo/platform/basic.h" #include "mongo/db/exec/sbe/expressions/expression.h" +#include "mongo/db/exec/sbe/expressions/runtime_environment.h" #include "mongo/db/exec/sbe/vm/vm.h" #include "mongo/db/exec/sbe/vm/vm_printer.h" @@ -77,6 +78,8 @@ namespace vm { int Instruction::stackOffset[Instruction::Tags::lastInstruction] = { 1, // pushConstVal 1, // pushAccessVal + 1, // pushOwnedAccessorVal + 1, // pushEnvAccessorVal 1, // pushMoveVal 1, // pushLocalVal 1, // pushMoveLocalVal @@ -480,8 +483,15 @@ void CodeFragment::appendConstVal(value::TypeTags tag, value::Value val) { void CodeFragment::appendAccessVal(value::SlotAccessor* accessor) { Instruction i; - i.tag = Instruction::pushAccessVal; + i.tag = [](value::SlotAccessor* accessor) { + if (accessor->is<value::OwnedValueAccessor>()) { + return Instruction::pushOwnedAccessorVal; + } else if (accessor->is<RuntimeEnvironment::Accessor>()) { + return Instruction::pushEnvAccessorVal; + } + return Instruction::pushAccessVal; + }(accessor); auto offset = allocateSpace(sizeof(Instruction) + sizeof(accessor)); offset += writeToMemory(offset, i); @@ -7247,6 +7257,24 @@ void ByteCode::runInternal(const CodeFragment* code, int64_t position) { break; } + case Instruction::pushOwnedAccessorVal: { + auto accessor = readFromMemory<value::OwnedValueAccessor*>(pcPointer); + pcPointer += sizeof(accessor); + + auto [tag, val] = accessor->getViewOfValue(); + pushStack(false, tag, val); + + break; + } + case Instruction::pushEnvAccessorVal: { + auto accessor = readFromMemory<RuntimeEnvironment::Accessor*>(pcPointer); + pcPointer += sizeof(accessor); + + auto [tag, val] = accessor->getViewOfValue(); + pushStack(false, tag, val); + + break; + } case Instruction::pushMoveVal: { auto accessor = readFromMemory<value::SlotAccessor*>(pcPointer); pcPointer += sizeof(accessor); |