Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(104)

Unified Diff: src/compiler/machine-operator.h

Issue 1928513002: Implement UnalignedLoad and UnalignedStore in WASM using LoadByte/Shift/Or and StoreByte/Shift/And. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Renamed UnalignedAccessConfig to AlignmentRequirements Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/compiler/machine-operator.h
diff --git a/src/compiler/machine-operator.h b/src/compiler/machine-operator.h
index e3a67606765dabd97d9e5c3c40e21032ed8f3be5..f17e8fa81a24d74aed5c667370b15d1eef5a92d2 100644
--- a/src/compiler/machine-operator.h
+++ b/src/compiler/machine-operator.h
@@ -123,10 +123,73 @@ class MachineOperatorBuilder final : public ZoneObject {
};
typedef base::Flags<Flag, unsigned> Flags;
+ struct AlignmentRequirements {
Benedikt Meurer 2016/05/12 04:12:14 Nit: class
+ public:
+ explicit AlignmentRequirements(bool fullUnalignedAccessSupport,
+ bool noUnalignedAccessSupport)
Jarin 2016/05/12 04:26:13 Nit: Could you make the constructor private now th
+ : fullUnalignedAccessSupport_(fullUnalignedAccessSupport),
+ noUnalignedAccessSupport_(noUnalignedAccessSupport),
+ unalignedLoadSupportedTypes_(NULL, 0),
+ unalignedStoreSupportedTypes_(NULL, 0) {
+ DCHECK(fullUnalignedAccessSupport != noUnalignedAccessSupport);
+ }
+ explicit AlignmentRequirements(
+ Vector<MachineType> unalingedLoadSupportedTypes,
Jarin 2016/05/12 04:26:13 Typo: unalinged -> unaligned
+ Vector<MachineType> unalignedStoreSupportedTypes)
+ : fullUnalignedAccessSupport_(false),
+ noUnalignedAccessSupport_(false),
+ unalignedLoadSupportedTypes_(unalingedLoadSupportedTypes),
+ unalignedStoreSupportedTypes_(unalignedStoreSupportedTypes) {}
+
+ bool IsUnalignedLoadSupported(const MachineType& machineType,
+ uint8_t alignment) const {
+ return IsUnalingedSupported(unalignedLoadSupportedTypes_, machineType,
+ alignment);
+ }
+
+ bool IsUnalignedStoreSupported(const MachineType& machineType,
+ uint8_t alignment) const {
+ return IsUnalingedSupported(unalignedStoreSupportedTypes_, machineType,
+ alignment);
+ }
+
+ static AlignmentRequirements FullUnalignedAccessSupport() {
+ return AlignmentRequirements(true, false);
+ }
+ static AlignmentRequirements NoUnalignedAccessSupport() {
+ return AlignmentRequirements(false, true);
+ }
+
+ private:
+ bool IsUnalingedSupported(const Vector<MachineType>& supported,
Jarin 2016/05/12 04:26:13 Typo: Unalinged -> Unaligned
+ const MachineType& machineType,
+ uint8_t alignment) const {
+ if (fullUnalignedAccessSupport_) {
+ return true;
+ } else if (noUnalignedAccessSupport_) {
+ return false;
+ } else {
+ for (MachineType m : supported) {
+ if (m == machineType) {
+ return true;
+ }
+ }
+ return false;
+ }
+ }
+
+ const bool fullUnalignedAccessSupport_;
Benedikt Meurer 2016/05/12 04:12:14 How about an enum here for this tristate logic? Th
+ const bool noUnalignedAccessSupport_;
+ const Vector<MachineType> unalignedLoadSupportedTypes_;
+ const Vector<MachineType> unalignedStoreSupportedTypes_;
+ };
+
explicit MachineOperatorBuilder(
Zone* zone,
MachineRepresentation word = MachineType::PointerRepresentation(),
- Flags supportedOperators = kNoFlags);
+ Flags supportedOperators = kNoFlags,
+ AlignmentRequirements alignmentConfig =
+ AlignmentRequirements::NoUnalignedAccessSupport());
const Operator* Word32And();
const Operator* Word32Or();
@@ -511,6 +574,16 @@ class MachineOperatorBuilder final : public ZoneObject {
bool Is64() const { return word() == MachineRepresentation::kWord64; }
MachineRepresentation word() const { return word_; }
+ bool UnalignedLoadSupported(const MachineType& machineType,
+ uint8_t alignment) {
+ return alignmentConfig_.IsUnalignedLoadSupported(machineType, alignment);
+ }
+
+ bool UnalignedStoreSupported(const MachineType& machineType,
+ uint8_t alignment) {
+ return alignmentConfig_.IsUnalignedStoreSupported(machineType, alignment);
+ }
+
// Pseudo operators that translate to 32/64-bit operators depending on the
// word-size of the target machine assumed by this builder.
#define PSEUDO_OP_LIST(V) \
@@ -545,6 +618,7 @@ class MachineOperatorBuilder final : public ZoneObject {
MachineOperatorGlobalCache const& cache_;
MachineRepresentation const word_;
Flags const flags_;
+ AlignmentRequirements const alignmentConfig_;
DISALLOW_COPY_AND_ASSIGN(MachineOperatorBuilder);
};

Powered by Google App Engine
This is Rietveld 408576698