diff --git a/src/compiler/access-info.cc b/src/compiler/access-info.cc index 1e227d6c97..8232d55da7 100644 --- a/src/compiler/access-info.cc +++ b/src/compiler/access-info.cc @@ -317,7 +317,12 @@ bool AccessInfoFactory::ComputeDataFieldAccessInfo( FieldIndex field_index = FieldIndex::ForPropertyIndex(*map, index, details_representation); Type field_type = Type::NonInternal(); +#ifdef V8_COMPRESS_POINTERS + MachineRepresentation field_representation = + MachineRepresentation::kCompressed; +#else MachineRepresentation field_representation = MachineRepresentation::kTagged; +#endif MaybeHandle field_map; MapRef map_ref(broker(), map); if (details_representation.IsSmi()) { diff --git a/src/compiler/js-native-context-specialization.cc b/src/compiler/js-native-context-specialization.cc index 890ef6790d..cd4cd9bf2d 100644 --- a/src/compiler/js-native-context-specialization.cc +++ b/src/compiler/js-native-context-specialization.cc @@ -2332,6 +2332,9 @@ JSNativeContextSpecialization::BuildPropertyStore( case MachineRepresentation::kTaggedSigned: case MachineRepresentation::kTaggedPointer: case MachineRepresentation::kTagged: + case MachineRepresentation::kCompressedSigned: + case MachineRepresentation::kCompressedPointer: + case MachineRepresentation::kCompressed: if (store_to_constant_field) { DCHECK(!access_info.HasTransitionMap()); // If the field is constant check that the value we are going @@ -2347,13 +2350,16 @@ JSNativeContextSpecialization::BuildPropertyStore( return ValueEffectControl(value, effect, control); } - if (field_representation == MachineRepresentation::kTaggedSigned) { + if (field_representation == MachineRepresentation::kTaggedSigned || + field_representation == MachineRepresentation::kCompressedSigned) { value = effect = graph()->NewNode( simplified()->CheckSmi(VectorSlotPair()), value, effect, control); field_access.write_barrier_kind = kNoWriteBarrier; } else if (field_representation == - MachineRepresentation::kTaggedPointer) { + MachineRepresentation::kTaggedPointer || + field_representation == + MachineRepresentation::kCompressedPointer) { // Ensure that {value} is a HeapObject. value = access_builder.BuildCheckHeapObject(value, &effect, control); Handle field_map; @@ -2367,7 +2373,8 @@ JSNativeContextSpecialization::BuildPropertyStore( field_access.write_barrier_kind = kPointerWriteBarrier; } else { - DCHECK_EQ(MachineRepresentation::kTagged, field_representation); + DCHECK(field_representation == MachineRepresentation::kTagged || + field_representation == MachineRepresentation::kCompressed); } break; case MachineRepresentation::kNone: @@ -2378,10 +2385,6 @@ JSNativeContextSpecialization::BuildPropertyStore( case MachineRepresentation::kWord64: case MachineRepresentation::kFloat32: case MachineRepresentation::kSimd128: - // TODO(solanes): Create the code for the compressed values - case MachineRepresentation::kCompressedSigned: - case MachineRepresentation::kCompressedPointer: - case MachineRepresentation::kCompressed: UNREACHABLE(); break; } diff --git a/src/compiler/representation-change.cc b/src/compiler/representation-change.cc index 1ac000ea84..43e2e09626 100644 --- a/src/compiler/representation-change.cc +++ b/src/compiler/representation-change.cc @@ -650,6 +650,27 @@ Node* RepresentationChanger::GetCompressedRepresentationFor( return jsgraph()->graph()->NewNode( jsgraph()->common()->DeadValue(MachineRepresentation::kCompressed), node); + } else if (output_rep == MachineRepresentation::kBit) { + // TODO(v8:8977): specialize here and below + node = + GetTaggedRepresentationFor(node, output_rep, output_type, truncation); + op = machine()->ChangeTaggedToCompressed(); + } else if (IsWord(output_rep)) { + node = + GetTaggedRepresentationFor(node, output_rep, output_type, truncation); + op = machine()->ChangeTaggedToCompressed(); + } else if (output_rep == MachineRepresentation::kWord64) { + node = + GetTaggedRepresentationFor(node, output_rep, output_type, truncation); + op = machine()->ChangeTaggedToCompressed(); + } else if (output_rep == MachineRepresentation::kFloat32) { + node = + GetTaggedRepresentationFor(node, output_rep, output_type, truncation); + op = machine()->ChangeTaggedToCompressed(); + } else if (output_rep == MachineRepresentation::kFloat64) { + node = + GetTaggedRepresentationFor(node, output_rep, output_type, truncation); + op = machine()->ChangeTaggedToCompressed(); } else if (IsAnyTagged(output_rep)) { op = machine()->ChangeTaggedToCompressed(); } else { @@ -708,6 +729,13 @@ Node* RepresentationChanger::GetFloat32RepresentationFor( node = jsgraph()->graph()->NewNode(op, node); op = machine()->TruncateFloat64ToFloat32(); } + } else if (output_rep == MachineRepresentation::kCompressed) { + // TODO(v8:8977): Specialise here + Node* intermediate_node = + GetTaggedRepresentationFor(node, output_rep, output_type, truncation); + return GetFloat32RepresentationFor(intermediate_node, + MachineRepresentation::kTagged, + output_type, truncation); } else if (output_rep == MachineRepresentation::kFloat64) { op = machine()->TruncateFloat64ToFloat32(); } else if (output_rep == MachineRepresentation::kWord64) { @@ -795,6 +823,13 @@ Node* RepresentationChanger::GetFloat64RepresentationFor( op = simplified()->CheckedTaggedToFloat64( CheckTaggedInputMode::kNumberOrOddball, use_info.feedback()); } + } else if (output_rep == MachineRepresentation::kCompressed) { + // TODO(v8:8977): Specialise here + Node* intermediate_node = GetTaggedRepresentationFor( + node, output_rep, output_type, use_info.truncation()); + return GetFloat64RepresentationFor(intermediate_node, + MachineRepresentation::kTagged, + output_type, use_node, use_info); } else if (output_rep == MachineRepresentation::kFloat32) { op = machine()->ChangeFloat32ToFloat64(); } else if (output_rep == MachineRepresentation::kWord64) { @@ -943,6 +978,13 @@ Node* RepresentationChanger::GetWord32RepresentationFor( return TypeError(node, output_rep, output_type, MachineRepresentation::kWord32); } + } else if (output_rep == MachineRepresentation::kCompressed) { + // TODO(v8:8977): Specialise here + Node* intermediate_node = GetTaggedRepresentationFor( + node, output_rep, output_type, use_info.truncation()); + return GetWord32RepresentationFor(intermediate_node, + MachineRepresentation::kTagged, + output_type, use_node, use_info); } else if (output_rep == MachineRepresentation::kWord32) { // Only the checked case should get here, the non-checked case is // handled in GetRepresentationFor. @@ -1056,6 +1098,12 @@ Node* RepresentationChanger::GetBitRepresentationFor( jsgraph()->IntPtrConstant(0)); return jsgraph()->graph()->NewNode(machine()->Word32Equal(), node, jsgraph()->Int32Constant(0)); + } else if (output_rep == MachineRepresentation::kCompressed) { + // TODO(v8:8977): Specialise here + Node* intermediate_node = GetTaggedRepresentationFor( + node, output_rep, output_type, Truncation::Any()); + return GetBitRepresentationFor(intermediate_node, + MachineRepresentation::kTagged, output_type); } else if (IsWord(output_rep)) { node = jsgraph()->graph()->NewNode(machine()->Word32Equal(), node, jsgraph()->Int32Constant(0)); @@ -1186,6 +1234,13 @@ Node* RepresentationChanger::GetWord64RepresentationFor( return TypeError(node, output_rep, output_type, MachineRepresentation::kWord64); } + } else if (output_rep == MachineRepresentation::kCompressed) { + // TODO(v8:8977): Specialise here + Node* intermediate_node = GetTaggedRepresentationFor( + node, output_rep, output_type, use_info.truncation()); + return GetWord64RepresentationFor(intermediate_node, + MachineRepresentation::kTagged, + output_type, use_node, use_info); } else { return TypeError(node, output_rep, output_type, MachineRepresentation::kWord64); diff --git a/src/compiler/representation-change.h b/src/compiler/representation-change.h index 13094d1cf6..5e682624e8 100644 --- a/src/compiler/representation-change.h +++ b/src/compiler/representation-change.h @@ -186,6 +186,16 @@ class UseInfo { static UseInfo TaggedPointer() { return UseInfo(MachineRepresentation::kTaggedPointer, Truncation::Any()); } + static UseInfo AnyCompressed() { + return UseInfo(MachineRepresentation::kCompressed, Truncation::Any()); + } + static UseInfo CompressedSigned() { + return UseInfo(MachineRepresentation::kCompressedSigned, Truncation::Any()); + } + static UseInfo CompressedPointer() { + return UseInfo(MachineRepresentation::kCompressedPointer, + Truncation::Any()); + } // Possibly deoptimizing conversions. static UseInfo CheckedHeapObjectAsTaggedPointer( diff --git a/src/compiler/simplified-lowering.cc b/src/compiler/simplified-lowering.cc index d39144da5b..1370f5444f 100644 --- a/src/compiler/simplified-lowering.cc +++ b/src/compiler/simplified-lowering.cc @@ -132,6 +132,11 @@ UseInfo TruncatingUseInfoFromRepresentation(MachineRepresentation rep) { case MachineRepresentation::kTaggedPointer: case MachineRepresentation::kTagged: return UseInfo::AnyTagged(); + case MachineRepresentation::kCompressedSigned: + return UseInfo::CompressedSigned(); + case MachineRepresentation::kCompressedPointer: + case MachineRepresentation::kCompressed: + return UseInfo::AnyCompressed(); case MachineRepresentation::kFloat64: return UseInfo::TruncatingFloat64(); case MachineRepresentation::kFloat32: @@ -144,10 +149,6 @@ UseInfo TruncatingUseInfoFromRepresentation(MachineRepresentation rep) { return UseInfo::Word64(); case MachineRepresentation::kBit: return UseInfo::Bool(); - // TODO(solanes): Create the code for the compressed values - case MachineRepresentation::kCompressedSigned: - case MachineRepresentation::kCompressedPointer: - case MachineRepresentation::kCompressed: case MachineRepresentation::kSimd128: case MachineRepresentation::kNone: break;