d3c165d7b5
This is a reland of commit bfc1a44527
Change how the partial specializations for AtomicBitFieldContainer
are written so that Visual Studio properly chooses them instead of
the base BitField template when appropriate.
TEST=Windows ARM64 CI trybots
Original change's description:
> [vm] Improvements in the BitField API.
>
> If no position is specified, then the bitfield starts at bit 0.
>
> The default size for bool BitFields is 1 instead of the remaining
> bits in the container.
>
> If the size of the value type is smaller than the remaining bits
> in the container, then the size of the value type is used as
> the default size instead.
>
> If a signed value is used in a non-sign-extended BitField, only
> the magnitude of the value is stored, not the sign bit. This means
> the actual size of the bitfield may be one less than the requested
> size in this case.
>
> If the requested size of the bitfield is larger than the size of the
> value type, a compile-time error is thrown. (For signed types, the
> requested size is allowed to be the size of the entire value, even if
> only the magnitude bits are stored.)
>
> Rework uses of BitFields to avoid using separate constants for
> bit positions/sizes except for macro-defined bitfields (which now
> are universally bool, and so size 1).
>
> TEST=vm/cc/BitFields_Defaults
>
> Change-Id: I40711c929d2e5165ce40823772beb49e8cfdb820
> Cq-Include-Trybots: luci.dart.try:vm-aot-dwarf-linux-product-x64-try,vm-aot-linux-debug-x64c-try,vm-aot-linux-release-x64-try,vm-aot-mac-release-arm64-try,vm-aot-linux-release-simarm_x64-try
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/381644
> Reviewed-by: Ryan Macnak <rmacnak@google.com>
> Commit-Queue: Tess Strickland <sstrickl@google.com>
Change-Id: I5e3a9e3e2a80d5689a23a0603f8f81fac1576cd3
Cq-Include-Trybots: luci.dart.try:vm-aot-dwarf-linux-product-x64-try,vm-aot-linux-debug-x64c-try,vm-aot-linux-release-x64-try,vm-aot-mac-release-arm64-try,vm-aot-linux-release-simarm_x64-try,vm-win-debug-x64c-try,vm-win-release-x64-try,vm-aot-win-release-x64-try,vm-win-release-arm64-try,vm-aot-win-release-arm64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/382383
Auto-Submit: Tess Strickland <sstrickl@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
80 lines
2.7 KiB
C++
80 lines
2.7 KiB
C++
// Copyright (c) 2014, 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.
|
|
|
|
#ifndef RUNTIME_VM_COMPILER_METHOD_RECOGNIZER_H_
|
|
#define RUNTIME_VM_COMPILER_METHOD_RECOGNIZER_H_
|
|
|
|
#include "vm/allocation.h"
|
|
#include "vm/compiler/recognized_methods_list.h"
|
|
#include "vm/growable_array.h"
|
|
#include "vm/token.h"
|
|
|
|
namespace dart {
|
|
|
|
// Forward declarations.
|
|
class Function;
|
|
class Library;
|
|
class Object;
|
|
class String;
|
|
class Zone;
|
|
|
|
// Class that recognizes the name and owner of a function and returns the
|
|
// corresponding enum. See RECOGNIZED_LIST above for list of recognizable
|
|
// functions.
|
|
class MethodRecognizer : public AllStatic {
|
|
public:
|
|
enum Kind {
|
|
kUnknown,
|
|
#define DEFINE_ENUM_LIST(library, class, function, enum_name, fp) k##enum_name,
|
|
RECOGNIZED_LIST(DEFINE_ENUM_LIST)
|
|
#undef DEFINE_ENUM_LIST
|
|
kNumRecognizedMethods
|
|
};
|
|
static constexpr int kKindBitSize =
|
|
Utils::BitLength(kNumRecognizedMethods - 1);
|
|
|
|
static intptr_t NumArgsCheckedForStaticCall(const Function& function);
|
|
|
|
// Try to find an annotation of the form
|
|
// @pragma("vm:exact-result-type", int)
|
|
// @pragma("vm:exact-result-type", "dart:core#_Smi")
|
|
// and return the exact cid if found or kDynamicCid otherwise.
|
|
//
|
|
// See [result_type_pragma.md].
|
|
static intptr_t ResultCidFromPragma(const Object& function_or_field);
|
|
|
|
static intptr_t MethodKindToReceiverCid(Kind kind);
|
|
static const char* KindToCString(Kind kind);
|
|
static const char* KindToFunctionNameCString(Kind kind);
|
|
|
|
static bool IsMarkedAsRecognized(const Function& function,
|
|
const char* kind = nullptr);
|
|
static void InitializeState();
|
|
};
|
|
|
|
// Recognizes token corresponding to a method name.
|
|
class MethodTokenRecognizer : public AllStatic {
|
|
public:
|
|
static Token::Kind RecognizeTokenKind(const String& name);
|
|
};
|
|
|
|
// Class that recognizes factories and returns corresponding result cid.
|
|
class FactoryRecognizer : public AllStatic {
|
|
public:
|
|
// Return result cid of 'factory' if it is recognized.
|
|
// Return kDynamicCid if factory is not recognized.
|
|
static intptr_t ResultCid(const Function& factory);
|
|
|
|
// Return result cid of 'function' called with 'argument_count' arguments,
|
|
// if function is a recognized list factory constructor.
|
|
// Return kDynamicCid if function is not recognized.
|
|
static intptr_t GetResultCidOfListFactory(Zone* zone,
|
|
const Function& function,
|
|
intptr_t argument_count);
|
|
};
|
|
|
|
} // namespace dart
|
|
|
|
#endif // RUNTIME_VM_COMPILER_METHOD_RECOGNIZER_H_
|