mirror of
https://github.com/dart-lang/sdk
synced 2024-11-05 18:22:09 +00:00
431ed5183f
Previously when building subtype class id ranges for a class in AOT, we looped over the entire class table, even though in most cases, the number of actual subclasses and implementors of the class is a small subset of all loaded classes. Instead, use the same hierarchy information in both JIT and AOT, only falling back to traversing the entire class table in cases where the hierarchy information is missing. Additional changes: * Do not generate unused type argument checks if the subtype class id range to check is empty. * Only generate a nullability check when checking that an instance type argument is a subtype of non-nullable Object in null safe mode. * Fix AbstractType::IsSubtypeOf so _Closure <: Function. Fixes https://github.com/dart-lang/sdk/issues/46936 TEST=vm/cc/HierarchyInfo Cq-Include-Trybots: luci.dart.try:vm-kernel-linux-release-x64-try,vm-kernel-precomp-linux-release-x64-try,vm-kernel-precomp-nnbd-linux-release-x64-try,vm-kernel-nnbd-linux-release-x64-try,vm-kernel-tsan-linux-release-x64-try,vm-kernel-linux-product-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-linux-release-simarm-try,vm-kernel-linux-release-simarm64-try Change-Id: Ic0310208d271ef04e778f070f420ae0abbdd47d3 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/210581 Commit-Queue: Tess Strickland <sstrickl@google.com> Reviewed-by: Alexander Markov <alexmarkov@google.com> Reviewed-by: Martin Kustermann <kustermann@google.com>
69 lines
2.1 KiB
C++
69 lines
2.1 KiB
C++
// Copyright (c) 2012, 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 "platform/assert.h"
|
|
|
|
#include "include/dart_api.h"
|
|
#include "platform/globals.h"
|
|
#include "platform/syslog.h"
|
|
|
|
#if defined(DART_HOST_OS_ANDROID)
|
|
extern "C" __attribute__((weak)) void android_set_abort_message(const char*);
|
|
#endif // defined(DART_HOST_OS_ANDROID)
|
|
|
|
namespace dart {
|
|
|
|
bool Expect::failed_ = false;
|
|
|
|
void DynamicAssertionHelper::Print(const char* format,
|
|
va_list arguments,
|
|
bool will_abort /* = false */) const {
|
|
// Take only the last 1KB of the file name if it is longer.
|
|
const intptr_t file_len = strlen(file_);
|
|
const intptr_t file_offset = (file_len > (1 * KB)) ? file_len - (1 * KB) : 0;
|
|
const char* file = file_ + file_offset;
|
|
|
|
// Print the file and line number into the buffer.
|
|
char buffer[4 * KB];
|
|
MSAN_UNPOISON(buffer, sizeof(buffer));
|
|
intptr_t file_and_line_length =
|
|
snprintf(buffer, sizeof(buffer), "%s: %d: error: ", file, line_);
|
|
|
|
// Print the error message into the buffer.
|
|
vsnprintf(buffer + file_and_line_length,
|
|
sizeof(buffer) - file_and_line_length, format, arguments);
|
|
|
|
// Print the buffer on stderr and/or syslog.
|
|
Syslog::PrintErr("%s\n", buffer);
|
|
#if defined(DART_HOST_OS_ANDROID)
|
|
if (will_abort && (&android_set_abort_message != nullptr)) {
|
|
android_set_abort_message(buffer);
|
|
}
|
|
#endif // defined(DART_HOST_OS_ANDROID)
|
|
}
|
|
|
|
void Assert::Fail(const char* format, ...) const {
|
|
va_list arguments;
|
|
va_start(arguments, format);
|
|
Print(format, arguments, /*will_abort=*/true);
|
|
va_end(arguments);
|
|
|
|
// Abort right away.
|
|
Dart_DumpNativeStackTrace(NULL);
|
|
Dart_PrepareToAbort();
|
|
abort();
|
|
}
|
|
|
|
void Expect::Fail(const char* format, ...) const {
|
|
va_list arguments;
|
|
va_start(arguments, format);
|
|
Print(format, arguments);
|
|
va_end(arguments);
|
|
|
|
// Wait until the program is exiting before producing a non-zero exit
|
|
// code through abort.
|
|
failed_ = true;
|
|
}
|
|
|
|
} // namespace dart
|