Skip to content

Commit 5dbe13b

Browse files
sstricklcommit-bot@chromium.org
authored andcommitted
[vm] Add (S)LEB128 encoding/decoding to BaseWriteStream.
Unlike cfc8e6d, this does _not_ replace the default variable length encoding for {Read,Write}Streams, but insteads adds separate {Read,Write}{S,}LEB128 methods to the appropriate classes. If we later find the cause of the issues that led to the revert of cfc8e6d, it'll be easy to switch over then. Note that WriteLEB128 asserts that the value is non-negative if used with a signed type (since negative values suggests that SLEB128 should be used instead for minimal encoding). Also removes the various other encoding and decoding methods for (S)LEB128 across the codebase and changes those clients to use {Read,Write}Streams instead. Other cleanups: * Various constant-related cleanups in datastream.h. * Adds DART_FORCE_INLINE to ReadStream::ReadByte and uses it in the default variable length decoding methods for retrieving bytes from the stream instead of managing current_ by hand. * Creates a canonical empty CompressedStackMaps instance and uses that instead of the null CompressedStackMaps instance in most cases. The only remaining (expected) use of the null CompressedStackMaps instance is for the global table in the object store when no global table exists (e.g., in JIT mode before any snapshotting). * Moves CompressedStackMapsIterator from code_descriptors.h to an Iterator class within CompressedStackMaps in object.h (similar to PcDescriptors::Iterator), to limit friend declarations and because it conceptually makes more sense as part of CompressedStackMaps. * Removed CompressedStackMaps::PayloadByte, since existing clients (CompressedStackMaps::Iterator, StackMapEntry in program_visitor.cc) are better served by just operating on the payload buffer directly (with appropriate NoSafepointScopes). * WriteStreams no longer allocate their initial space on construction, but rather on the first write, so no allocation is performed by constructing a never-used WriteStream. Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-debug-simarm_x64-try,vm-kernel-precomp-mac-release-simarm64-try,vm-kernel-mac-debug-x64-try,vm-kernel-win-debug-x64-try,vm-kernel-win-debug-ia32-try,vm-kernel-precomp-win-release-x64-try,vm-kernel-ubsan-linux-release-x64-try,vm-kernel-tsan-linux-release-x64-try,vm-kernel-precomp-ubsan-linux-release-x64-try,vm-kernel-precomp-tsan-linux-release-x64-try,vm-kernel-precomp-msan-linux-release-x64-try,vm-kernel-precomp-asan-linux-release-x64-try,vm-kernel-msan-linux-release-x64-try,vm-kernel-asan-linux-release-x64-try Change-Id: Ice63321abaa79157fbe9f230a864c8bba0e6dea9 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/166421 Reviewed-by: Ryan Macnak <[email protected]> Commit-Queue: Tess Strickland <[email protected]>
1 parent 71bc516 commit 5dbe13b

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

disassembler.cc

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,8 @@ void Disassembler::DisassembleCodeHelper(const char* function_fullname,
220220
const char* function_info,
221221
const Code& code,
222222
bool optimized) {
223-
Zone* zone = Thread::Current()->zone();
223+
Thread* thread = Thread::Current();
224+
Zone* zone = thread->zone();
224225
LocalVarDescriptors& var_descriptors = LocalVarDescriptors::Handle(zone);
225226
if (FLAG_print_variable_descriptors) {
226227
var_descriptors = code.GetLocalVarDescriptors();
@@ -290,13 +291,16 @@ void Disassembler::DisassembleCodeHelper(const char* function_fullname,
290291
}
291292
#endif // !defined(DART_PRECOMPILED_RUNTIME)
292293

293-
THR_Print("StackMaps for function '%s' {\n", function_fullname);
294-
if (code.compressed_stackmaps() != CompressedStackMaps::null()) {
294+
{
295295
const auto& stackmaps =
296296
CompressedStackMaps::Handle(zone, code.compressed_stackmaps());
297-
THR_Print("%s\n", stackmaps.ToCString());
297+
CompressedStackMaps::Iterator it(thread, stackmaps);
298+
TextBuffer buffer(100);
299+
buffer.Printf("StackMaps for function '%s' {\n", function_fullname);
300+
it.WriteToBuffer(&buffer, "\n");
301+
buffer.AddString("}\n");
302+
THR_Print("%s", buffer.buffer());
298303
}
299-
THR_Print("}\n");
300304

301305
if (FLAG_print_variable_descriptors) {
302306
THR_Print("Variable Descriptors for function '%s' {\n", function_fullname);

0 commit comments

Comments
 (0)