mirror of
https://github.com/dart-lang/sdk
synced 2024-09-05 00:13:50 +00:00
![Alexander Markov](/assets/img/avatar_default.png)
This reverts commitab6aeaa106
. Revert "[vm/compiler] Speed up the compiler part which deals with kernel reading up in DEBUG mode" This reverts commitb316210d94
. Reason for revert: regression of snapshot sizes (DNO-599). Original change's description: > [vm/kernel] Use GC-tracked ExternalTypedData/TypedDataView for kernel buffers > > Until now we often leaked kernel buffers (e.g. hot reload buffers) because various > objects were referencing ExternalTypedData objects pointing into the middle of > c-allocated memory. This made it impossible for the GC to determine when the last > reference is gone. > > This CL ensures that the actual buffers are *always* made available via > ExternalTypedData and any inner pointers into it are created via TypedDataViews. > > The embedder guarantees to the free kernel buffers it has provided to: > - Dart_CreateIsolateFromKernel > - Dart_LoadScriptFromKernel > - Dart_LoadLibraryFromKernel > - Dart_SetDartLibrarySourcesKernel > on isolate shutdown. > > All other kernel buffers will get a finalizer attached, which ensures the > kernel buffers get freed by the GC once they are no longer referenced: > - Kernel blobs for expression evaluation > - Kernel blobs for Hot-Reload > - Kernel blobs for cc tests > > Fixes https://github.com/dart-lang/sdk/issues/33973 > Fixes https://github.com/dart-lang/sdk/issues/36857 > Issue https://github.com/dart-lang/sdk/issues/37030 > > Change-Id: I1cc410c94c0f4b229413e793728a261afcb10aaf > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/103130 > Reviewed-by: Ryan Macnak <rmacnak@google.com> > Commit-Queue: Martin Kustermann <kustermann@google.com> TBR=kustermann@google.com,rmacnak@google.com # Not skipping CQ checks because original CL landed > 1 day ago. Change-Id: I49715d2400f4a5c8806b7d6a2912b7258f671a0a Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/104343 Reviewed-by: Alexander Markov <alexmarkov@google.com> Reviewed-by: Siva Annamalai <asiva@google.com> Auto-Submit: Alexander Markov <alexmarkov@google.com>
33 lines
979 B
C++
33 lines
979 B
C++
// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
#include "vm/base64.h"
|
|
|
|
#include "platform/assert.h"
|
|
#include "vm/unit_test.h"
|
|
|
|
namespace dart {
|
|
|
|
TEST_CASE(Base64Decode) {
|
|
intptr_t decoded_len;
|
|
uint8_t* decoded_bytes =
|
|
DecodeBase64(thread->zone(), "SGVsbG8sIHdvcmxkIQo=", &decoded_len);
|
|
const char expected_bytes[] = "Hello, world!\n";
|
|
intptr_t expected_len = strlen(expected_bytes);
|
|
EXPECT(!memcmp(expected_bytes, decoded_bytes, expected_len));
|
|
EXPECT_EQ(expected_len, decoded_len);
|
|
}
|
|
|
|
TEST_CASE(Base64DecodeMalformed) {
|
|
intptr_t decoded_len;
|
|
EXPECT(DecodeBase64(thread->zone(), "SomethingMalformed", &decoded_len) ==
|
|
nullptr);
|
|
}
|
|
|
|
TEST_CASE(Base64DecodeEmpty) {
|
|
intptr_t decoded_len;
|
|
EXPECT(DecodeBase64(thread->zone(), "", &decoded_len) == nullptr);
|
|
}
|
|
} // namespace dart
|