diff --git a/runtime/lib/date.cc b/runtime/lib/date.cc index 118461f9b5e7..8484092d56e0 100644 --- a/runtime/lib/date.cc +++ b/runtime/lib/date.cc @@ -17,7 +17,7 @@ static int64_t kMaxAllowedSeconds = kMaxInt32; DEFINE_NATIVE_ENTRY(DateTime_timeZoneName, 0, 1) { GET_NON_NULL_NATIVE_ARGUMENT(Integer, dart_seconds, arguments->NativeArgAt(0)); - int64_t seconds = dart_seconds.AsInt64Value(); + int64_t seconds = dart_seconds.Value(); if (llabs(seconds) > kMaxAllowedSeconds) { Exceptions::ThrowArgumentError(dart_seconds); } @@ -28,7 +28,7 @@ DEFINE_NATIVE_ENTRY(DateTime_timeZoneName, 0, 1) { DEFINE_NATIVE_ENTRY(DateTime_timeZoneOffsetInSeconds, 0, 1) { GET_NON_NULL_NATIVE_ARGUMENT(Integer, dart_seconds, arguments->NativeArgAt(0)); - int64_t seconds = dart_seconds.AsInt64Value(); + int64_t seconds = dart_seconds.Value(); if (llabs(seconds) > kMaxAllowedSeconds) { Exceptions::ThrowArgumentError(dart_seconds); } diff --git a/runtime/lib/developer.cc b/runtime/lib/developer.cc index f9d649e1d8dc..7574c73e48de 100644 --- a/runtime/lib/developer.cc +++ b/runtime/lib/developer.cc @@ -58,9 +58,9 @@ DEFINE_NATIVE_ENTRY(Developer_log, 0, 8) { GET_NATIVE_ARGUMENT(Instance, dart_zone, arguments->NativeArgAt(5)); GET_NATIVE_ARGUMENT(Instance, error, arguments->NativeArgAt(6)); GET_NATIVE_ARGUMENT(Instance, stack_trace, arguments->NativeArgAt(7)); - Service::SendLogEvent(isolate, sequence.AsInt64Value(), - timestamp.AsInt64Value(), level.Value(), name, message, - dart_zone, error, stack_trace); + Service::SendLogEvent(isolate, sequence.Value(), timestamp.Value(), + level.Value(), name, message, dart_zone, error, + stack_trace); return Object::null(); #endif // PRODUCT } diff --git a/runtime/lib/double.cc b/runtime/lib/double.cc index c747e2682213..a4027d530894 100644 --- a/runtime/lib/double.cc +++ b/runtime/lib/double.cc @@ -26,7 +26,7 @@ DEFINE_NATIVE_ENTRY(Double_doubleFromInteger, 0, 2) { if (FLAG_trace_intrinsified_natives) { OS::PrintErr("Double_doubleFromInteger %s\n", value.ToCString()); } - return Double::New(value.AsDoubleValue()); + return Double::New(value.ToDouble()); } DEFINE_NATIVE_ENTRY(Double_add, 0, 2) { @@ -83,7 +83,7 @@ DEFINE_NATIVE_ENTRY(Double_greaterThan, 0, 2) { DEFINE_NATIVE_ENTRY(Double_greaterThanFromInteger, 0, 2) { const Double& right = Double::CheckedHandle(zone, arguments->NativeArgAt(0)); GET_NON_NULL_NATIVE_ARGUMENT(Integer, left, arguments->NativeArgAt(1)); - return Bool::Get(left.AsDoubleValue() > right.value()).ptr(); + return Bool::Get(left.ToDouble() > right.value()).ptr(); } DEFINE_NATIVE_ENTRY(Double_equal, 0, 2) { @@ -100,7 +100,7 @@ DEFINE_NATIVE_ENTRY(Double_equal, 0, 2) { DEFINE_NATIVE_ENTRY(Double_equalToInteger, 0, 2) { const Double& left = Double::CheckedHandle(zone, arguments->NativeArgAt(0)); GET_NON_NULL_NATIVE_ARGUMENT(Integer, right, arguments->NativeArgAt(1)); - return Bool::Get(left.value() == right.AsDoubleValue()).ptr(); + return Bool::Get(left.value() == right.ToDouble()).ptr(); } #if defined(DART_HOST_OS_MACOS) @@ -110,11 +110,11 @@ DEFINE_NATIVE_ENTRY(Double_equalToInteger, 0, 2) { DEFINE_NATIVE_ENTRY(Double_parse, 0, 3) { GET_NON_NULL_NATIVE_ARGUMENT(String, value, arguments->NativeArgAt(0)); - GET_NON_NULL_NATIVE_ARGUMENT(Integer, startValue, arguments->NativeArgAt(1)); - GET_NON_NULL_NATIVE_ARGUMENT(Integer, endValue, arguments->NativeArgAt(2)); + GET_NON_NULL_NATIVE_ARGUMENT(Smi, startValue, arguments->NativeArgAt(1)); + GET_NON_NULL_NATIVE_ARGUMENT(Smi, endValue, arguments->NativeArgAt(2)); - const intptr_t start = startValue.AsTruncatedUint32Value(); - const intptr_t end = endValue.AsTruncatedUint32Value(); + const intptr_t start = startValue.Value(); + const intptr_t end = endValue.Value(); const intptr_t len = value.Length(); // Indices should be inside the string, and 0 <= start < end <= len. diff --git a/runtime/lib/ffi.cc b/runtime/lib/ffi.cc index 0d06325ee1e4..ac1ede8e1c9e 100644 --- a/runtime/lib/ffi.cc +++ b/runtime/lib/ffi.cc @@ -54,7 +54,7 @@ DEFINE_NATIVE_ENTRY(Ffi_deleteNativeCallable, 1, 1) { DEFINE_NATIVE_ENTRY(Ffi_updateNativeCallableKeepIsolateAliveCounter, 1, 1) { const int64_t delta = - Integer::CheckedHandle(zone, arguments->NativeArg0()).AsInt64Value(); + Integer::CheckedHandle(zone, arguments->NativeArg0()).Value(); isolate->UpdateNativeCallableKeepIsolateAliveCounter(delta); return Object::null(); } diff --git a/runtime/lib/integers.cc b/runtime/lib/integers.cc index b033b14c2ee1..8df26e4fa940 100644 --- a/runtime/lib/integers.cc +++ b/runtime/lib/integers.cc @@ -24,7 +24,7 @@ namespace dart { static bool CheckInteger(const Integer& i) { if (i.IsMint()) { const Mint& mint = Mint::Cast(i); - return !Smi::IsValid(mint.value()); + return !Smi::IsValid(mint.Value()); } return true; } @@ -113,7 +113,7 @@ DEFINE_NATIVE_ENTRY(Integer_truncDivFromInteger, 0, 2) { GET_NON_NULL_NATIVE_ARGUMENT(Integer, left_int, arguments->NativeArgAt(1)); ASSERT(CheckInteger(right_int)); ASSERT(CheckInteger(left_int)); - ASSERT(!right_int.IsZero()); + ASSERT(right_int.Value() != 0); return left_int.ArithmeticOp(Token::kTRUNCDIV, right_int); } @@ -127,7 +127,7 @@ DEFINE_NATIVE_ENTRY(Integer_moduloFromInteger, 0, 2) { OS::PrintErr("Integer_moduloFromInteger %s mod %s\n", left_int.ToCString(), right_int.ToCString()); } - if (right_int.IsZero()) { + if (right_int.Value() == 0) { // Should have been caught before calling into runtime. UNIMPLEMENTED(); } @@ -206,7 +206,7 @@ DEFINE_NATIVE_ENTRY(Integer_fromEnvironment, 0, 3) { static IntegerPtr ShiftOperationHelper(Token::Kind kind, const Integer& value, const Integer& amount) { - if (amount.AsInt64Value() < 0) { + if (amount.Value() < 0) { Exceptions::ThrowArgumentError(amount); } return value.ShiftOp(kind, amount, Heap::kNew); @@ -266,7 +266,7 @@ DEFINE_NATIVE_ENTRY(Smi_bitLength, 0, 1) { if (FLAG_trace_intrinsified_natives) { OS::PrintErr("Smi_bitLength: %s\n", operand.ToCString()); } - int64_t value = operand.AsInt64Value(); + int64_t value = operand.Value(); intptr_t result = Utils::BitLength(value); ASSERT(Smi::IsValid(result)); return Smi::New(result); @@ -309,7 +309,7 @@ DEFINE_NATIVE_ENTRY(Mint_bitNegate, 0, 1) { if (FLAG_trace_intrinsified_natives) { OS::PrintErr("Mint_bitNegate: %s\n", operand.ToCString()); } - int64_t result = ~operand.value(); + int64_t result = ~operand.Value(); return Integer::New(result); } @@ -319,7 +319,7 @@ DEFINE_NATIVE_ENTRY(Mint_bitLength, 0, 1) { if (FLAG_trace_intrinsified_natives) { OS::PrintErr("Mint_bitLength: %s\n", operand.ToCString()); } - int64_t value = operand.AsInt64Value(); + int64_t value = operand.Value(); intptr_t result = Utils::BitLength(value); ASSERT(Smi::IsValid(result)); return Smi::New(result); diff --git a/runtime/lib/simd128.cc b/runtime/lib/simd128.cc index fe50909e72b0..b62016c52715 100644 --- a/runtime/lib/simd128.cc +++ b/runtime/lib/simd128.cc @@ -265,7 +265,7 @@ DEFINE_NATIVE_ENTRY(Int32x4_getSignMask, 0, 1) { DEFINE_NATIVE_ENTRY(Float32x4_shuffle, 0, 2) { GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, self, arguments->NativeArgAt(0)); GET_NON_NULL_NATIVE_ARGUMENT(Integer, mask, arguments->NativeArgAt(1)); - int64_t m = mask.AsInt64Value(); + int64_t m = mask.Value(); ThrowMaskRangeException(m); float data[4] = {self.x(), self.y(), self.z(), self.w()}; float _x = data[m & 0x3]; @@ -279,7 +279,7 @@ DEFINE_NATIVE_ENTRY(Float32x4_shuffleMix, 0, 3) { GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, self, arguments->NativeArgAt(0)); GET_NON_NULL_NATIVE_ARGUMENT(Float32x4, other, arguments->NativeArgAt(1)); GET_NON_NULL_NATIVE_ARGUMENT(Integer, mask, arguments->NativeArgAt(2)); - int64_t m = mask.AsInt64Value(); + int64_t m = mask.Value(); ThrowMaskRangeException(m); float data[4] = {self.x(), self.y(), self.z(), self.w()}; float other_data[4] = {other.x(), other.y(), other.z(), other.w()}; @@ -382,10 +382,10 @@ DEFINE_NATIVE_ENTRY(Int32x4_fromInts, 0, 4) { GET_NON_NULL_NATIVE_ARGUMENT(Integer, y, arguments->NativeArgAt(1)); GET_NON_NULL_NATIVE_ARGUMENT(Integer, z, arguments->NativeArgAt(2)); GET_NON_NULL_NATIVE_ARGUMENT(Integer, w, arguments->NativeArgAt(3)); - int32_t _x = static_cast(x.AsTruncatedUint32Value()); - int32_t _y = static_cast(y.AsTruncatedUint32Value()); - int32_t _z = static_cast(z.AsTruncatedUint32Value()); - int32_t _w = static_cast(w.AsTruncatedUint32Value()); + int32_t _x = static_cast(x.Value() & 0xFFFFFFFF); + int32_t _y = static_cast(y.Value() & 0xFFFFFFFF); + int32_t _z = static_cast(z.Value() & 0xFFFFFFFF); + int32_t _w = static_cast(w.Value() & 0xFFFFFFFF); return Int32x4::New(_x, _y, _z, _w); } @@ -483,7 +483,7 @@ DEFINE_NATIVE_ENTRY(Int32x4_getW, 0, 1) { DEFINE_NATIVE_ENTRY(Int32x4_shuffle, 0, 2) { GET_NON_NULL_NATIVE_ARGUMENT(Int32x4, self, arguments->NativeArgAt(0)); GET_NON_NULL_NATIVE_ARGUMENT(Integer, mask, arguments->NativeArgAt(1)); - int64_t m = mask.AsInt64Value(); + int64_t m = mask.Value(); ThrowMaskRangeException(m); int32_t data[4] = {self.x(), self.y(), self.z(), self.w()}; int32_t _x = data[m & 0x3]; @@ -497,7 +497,7 @@ DEFINE_NATIVE_ENTRY(Int32x4_shuffleMix, 0, 3) { GET_NON_NULL_NATIVE_ARGUMENT(Int32x4, self, arguments->NativeArgAt(0)); GET_NON_NULL_NATIVE_ARGUMENT(Int32x4, zw, arguments->NativeArgAt(1)); GET_NON_NULL_NATIVE_ARGUMENT(Integer, mask, arguments->NativeArgAt(2)); - int64_t m = mask.AsInt64Value(); + int64_t m = mask.Value(); ThrowMaskRangeException(m); int32_t data[4] = {self.x(), self.y(), self.z(), self.w()}; int32_t zw_data[4] = {zw.x(), zw.y(), zw.z(), zw.w()}; @@ -511,7 +511,7 @@ DEFINE_NATIVE_ENTRY(Int32x4_shuffleMix, 0, 3) { DEFINE_NATIVE_ENTRY(Int32x4_setX, 0, 2) { GET_NON_NULL_NATIVE_ARGUMENT(Int32x4, self, arguments->NativeArgAt(0)); GET_NON_NULL_NATIVE_ARGUMENT(Integer, x, arguments->NativeArgAt(1)); - int32_t _x = static_cast(x.AsInt64Value() & 0xFFFFFFFF); + int32_t _x = static_cast(x.Value() & 0xFFFFFFFF); int32_t _y = self.y(); int32_t _z = self.z(); int32_t _w = self.w(); @@ -522,7 +522,7 @@ DEFINE_NATIVE_ENTRY(Int32x4_setY, 0, 2) { GET_NON_NULL_NATIVE_ARGUMENT(Int32x4, self, arguments->NativeArgAt(0)); GET_NON_NULL_NATIVE_ARGUMENT(Integer, y, arguments->NativeArgAt(1)); int32_t _x = self.x(); - int32_t _y = static_cast(y.AsInt64Value() & 0xFFFFFFFF); + int32_t _y = static_cast(y.Value() & 0xFFFFFFFF); int32_t _z = self.z(); int32_t _w = self.w(); return Int32x4::New(_x, _y, _z, _w); @@ -533,7 +533,7 @@ DEFINE_NATIVE_ENTRY(Int32x4_setZ, 0, 2) { GET_NON_NULL_NATIVE_ARGUMENT(Integer, z, arguments->NativeArgAt(1)); int32_t _x = self.x(); int32_t _y = self.y(); - int32_t _z = static_cast(z.AsInt64Value() & 0xFFFFFFFF); + int32_t _z = static_cast(z.Value() & 0xFFFFFFFF); int32_t _w = self.w(); return Int32x4::New(_x, _y, _z, _w); } @@ -544,7 +544,7 @@ DEFINE_NATIVE_ENTRY(Int32x4_setW, 0, 2) { int32_t _x = self.x(); int32_t _y = self.y(); int32_t _z = self.z(); - int32_t _w = static_cast(w.AsInt64Value() & 0xFFFFFFFF); + int32_t _w = static_cast(w.Value() & 0xFFFFFFFF); return Int32x4::New(_x, _y, _z, _w); } diff --git a/runtime/lib/string.cc b/runtime/lib/string.cc index 71f7c65e523d..e2da443eef06 100644 --- a/runtime/lib/string.cc +++ b/runtime/lib/string.cc @@ -259,7 +259,7 @@ DEFINE_NATIVE_ENTRY(OneByteString_substringUnchecked, 0, 3) { DEFINE_NATIVE_ENTRY(Internal_allocateOneByteString, 0, 1) { GET_NON_NULL_NATIVE_ARGUMENT(Integer, length_obj, arguments->NativeArgAt(0)); - const int64_t length = length_obj.AsInt64Value(); + const int64_t length = length_obj.Value(); if ((length < 0) || (length > OneByteString::kMaxElements)) { // Assume that negative lengths are the result of wrapping in code in // string_patch.dart. @@ -273,7 +273,7 @@ DEFINE_NATIVE_ENTRY(Internal_allocateOneByteString, 0, 1) { DEFINE_NATIVE_ENTRY(Internal_allocateTwoByteString, 0, 1) { GET_NON_NULL_NATIVE_ARGUMENT(Integer, length_obj, arguments->NativeArgAt(0)); - const int64_t length = length_obj.AsInt64Value(); + const int64_t length = length_obj.Value(); if ((length < 0) || (length > TwoByteString::kMaxElements)) { // Assume that negative lengths are the result of wrapping in code in // string_patch.dart. diff --git a/runtime/lib/timeline.cc b/runtime/lib/timeline.cc index 4592e50aba04..d22312da598f 100644 --- a/runtime/lib/timeline.cc +++ b/runtime/lib/timeline.cc @@ -56,15 +56,14 @@ DEFINE_NATIVE_ENTRY(Timeline_reportTaskEvent, 0, 5) { } std::unique_ptr flow_ids; - if (flow_id.AsInt64Value() != TimelineEvent::kNoFlowId) { + if (flow_id.Value() != TimelineEvent::kNoFlowId) { int64_t* flow_ids_internal = new int64_t[1]; - flow_ids_internal[0] = flow_id.AsInt64Value(); + flow_ids_internal[0] = flow_id.Value(); flow_ids = std::unique_ptr(flow_ids_internal); } - intptr_t flow_id_count = - flow_id.AsInt64Value() == TimelineEvent::kNoFlowId ? 0 : 1; + intptr_t flow_id_count = flow_id.Value() == TimelineEvent::kNoFlowId ? 0 : 1; DartTimelineEventHelpers::ReportTaskEvent( - event, id.AsInt64Value(), flow_id_count, flow_ids, type.Value(), + event, id.Value(), flow_id_count, flow_ids, type.Value(), name.ToMallocCString(), args.ToMallocCString()); #endif // SUPPORT_TIMELINE return Object::null(); diff --git a/runtime/vm/compiler/aot/aot_call_specializer.cc b/runtime/vm/compiler/aot/aot_call_specializer.cc index ba64939f8a18..3758ee1b1447 100644 --- a/runtime/vm/compiler/aot/aot_call_specializer.cc +++ b/runtime/vm/compiler/aot/aot_call_specializer.cc @@ -419,7 +419,7 @@ Definition* AotCallSpecializer::TryOptimizeDivisionOperation( } const Object& rhs = right_value->BoundConstant(); - const int64_t value = Integer::Cast(rhs).AsInt64Value(); // smi and mint + const int64_t value = Integer::Cast(rhs).Value(); // smi and mint if (value == kMinInt64) { return nullptr; // The absolute value can't be held in an int64_t. diff --git a/runtime/vm/compiler/backend/constant_propagator.cc b/runtime/vm/compiler/backend/constant_propagator.cc index f1c80aa103d5..0adf29220d22 100644 --- a/runtime/vm/compiler/backend/constant_propagator.cc +++ b/runtime/vm/compiler/backend/constant_propagator.cc @@ -1285,7 +1285,7 @@ static bool IsIntegerOrDouble(const Object& value) { } static double ToDouble(const Object& value) { - return value.IsInteger() ? Integer::Cast(value).AsDoubleValue() + return value.IsInteger() ? Integer::Cast(value).ToDouble() : Double::Cast(value).value(); } @@ -1311,8 +1311,8 @@ void ConstantPropagator::VisitSmiToDouble(SmiToDoubleInstr* instr) { } if (value.IsInteger()) { SetValue(instr, - Double::Handle(Z, Double::New(Integer::Cast(value).AsDoubleValue(), - Heap::kOld))); + Double::Handle( + Z, Double::New(Integer::Cast(value).ToDouble(), Heap::kOld))); } else { SetValue(instr, non_constant_); } @@ -1325,8 +1325,8 @@ void ConstantPropagator::VisitInt64ToDouble(Int64ToDoubleInstr* instr) { } if (value.IsInteger()) { SetValue(instr, - Double::Handle(Z, Double::New(Integer::Cast(value).AsDoubleValue(), - Heap::kOld))); + Double::Handle( + Z, Double::New(Integer::Cast(value).ToDouble(), Heap::kOld))); } else { SetValue(instr, non_constant_); } @@ -1339,8 +1339,8 @@ void ConstantPropagator::VisitInt32ToDouble(Int32ToDoubleInstr* instr) { } if (value.IsInteger()) { SetValue(instr, - Double::Handle(Z, Double::New(Integer::Cast(value).AsDoubleValue(), - Heap::kOld))); + Double::Handle( + Z, Double::New(Integer::Cast(value).ToDouble(), Heap::kOld))); } else { SetValue(instr, non_constant_); } @@ -1464,7 +1464,7 @@ void ConstantPropagator::VisitDoubleTestOp(DoubleTestOpInstr* instr) { result = false; break; case MethodRecognizer::kDouble_getIsNegative: { - result = Integer::Cast(value).IsNegative(); + result = Integer::Cast(value).Value() < 0; break; } default: diff --git a/runtime/vm/compiler/backend/constant_propagator_test.cc b/runtime/vm/compiler/backend/constant_propagator_test.cc index eac043e2a138..c0736b506f4d 100644 --- a/runtime/vm/compiler/backend/constant_propagator_test.cc +++ b/runtime/vm/compiler/backend/constant_propagator_test.cc @@ -214,7 +214,7 @@ static void ConstantPropagatorUnboxedOpTest( EXPECT_PROPERTY(ret_val, it.IsConstant() && it.representation() == kTagged); EXPECT_EQ(expected.result, - Integer::Cast(ret_val->AsConstant()->value()).AsInt64Value()); + Integer::Cast(ret_val->AsConstant()->value()).Value()); } else { EXPECT_PROPERTY(ret_val, it.IsBoxInteger() && it.RequiredInputRepresentation(0) == diff --git a/runtime/vm/compiler/backend/evaluator.cc b/runtime/vm/compiler/backend/evaluator.cc index de4a310bc759..6bd7c3b8ddd4 100644 --- a/runtime/vm/compiler/backend/evaluator.cc +++ b/runtime/vm/compiler/backend/evaluator.cc @@ -14,7 +14,7 @@ static IntegerPtr BinaryIntegerEvaluateRaw(const Integer& left, FALL_THROUGH; case Token::kMOD: // Check right value for zero. - if (right.AsInt64Value() == 0) { + if (right.Value() == 0) { break; // Will throw. } FALL_THROUGH; @@ -29,7 +29,7 @@ static IntegerPtr BinaryIntegerEvaluateRaw(const Integer& left, case Token::kSHR: FALL_THROUGH; case Token::kUSHR: - if (right.AsInt64Value() >= 0) { + if (right.Value() >= 0) { return left.ShiftOp(token_kind, right, Heap::kOld); } break; @@ -56,10 +56,8 @@ static IntegerPtr UnaryIntegerEvaluateRaw(const Integer& value, return value.ArithmeticOp(Token::kMUL, Smi::Handle(zone, Smi::New(-1)), Heap::kOld); case Token::kBIT_NOT: - if (value.IsSmi()) { - return Integer::New(~Smi::Cast(value).Value(), Heap::kOld); - } else if (value.IsMint()) { - return Integer::New(~Mint::Cast(value).value(), Heap::kOld); + if (value.IsInteger()) { + return Integer::New(~value.Value(), Heap::kOld); } break; default: @@ -69,11 +67,8 @@ static IntegerPtr UnaryIntegerEvaluateRaw(const Integer& value, } static IntegerPtr BitLengthEvaluateRaw(const Integer& value, Zone* zone) { - if (value.IsSmi()) { - return Integer::New(Utils::BitLength(Smi::Cast(value).Value()), Heap::kOld); - } else if (value.IsMint()) { - return Integer::New(Utils::BitLength(Mint::Cast(value).value()), - Heap::kOld); + if (value.IsInteger()) { + return Integer::New(Utils::BitLength(value.Value()), Heap::kOld); } return Integer::null(); } @@ -113,8 +108,7 @@ IntegerPtr Evaluator::BinaryIntegerEvaluate(const Object& left, if (!result.IsNull()) { if (is_truncating) { - const int64_t truncated = - TruncateTo(result.AsTruncatedInt64Value(), representation); + const int64_t truncated = TruncateTo(result.Value(), representation); result = Integer::New(truncated, Heap::kOld); ASSERT(FlowGraph::IsConstantRepresentable( result, representation, /*tagged_value_must_be_smi=*/true)); @@ -306,11 +300,8 @@ bool Evaluator::ToIntegerConstant(Value* value, int64_t* result) { const Double& double_constant = Double::Cast(constant); *result = Utils::SafeDoubleToInt(double_constant.value()); return (static_cast(*result) == double_constant.value()); - } else if (constant.IsSmi()) { - *result = Smi::Cast(constant).Value(); - return true; - } else if (constant.IsMint()) { - *result = Mint::Cast(constant).value(); + } else if (constant.IsInteger()) { + *result = Integer::Cast(constant).Value(); return true; } return false; diff --git a/runtime/vm/compiler/backend/flow_graph.cc b/runtime/vm/compiler/backend/flow_graph.cc index cec073201f32..b41237e680ee 100644 --- a/runtime/vm/compiler/backend/flow_graph.cc +++ b/runtime/vm/compiler/backend/flow_graph.cc @@ -211,13 +211,13 @@ bool FlowGraph::IsConstantRepresentable(const Object& value, case kUnboxedInt32: if (value.IsInteger()) { - return Utils::IsInt(32, Integer::Cast(value).AsInt64Value()); + return Utils::IsInt(32, Integer::Cast(value).Value()); } return false; case kUnboxedUint32: if (value.IsInteger()) { - return Utils::IsUint(32, Integer::Cast(value).AsInt64Value()); + return Utils::IsUint(32, Integer::Cast(value).Value()); } return false; @@ -247,9 +247,9 @@ Definition* FlowGraph::TryCreateConstantReplacementFor(Definition* op, (representation == kUnboxedDouble)) && value.IsInteger()) { // Convert the boxed constant from int to float/double. - return GetConstant(Double::Handle(Double::NewCanonical( - Integer::Cast(value).AsDoubleValue())), - representation); + return GetConstant( + Double::Handle(Double::NewCanonical(Integer::Cast(value).ToDouble())), + representation); } return GetConstant(value, representation); diff --git a/runtime/vm/compiler/backend/flow_graph_checker.cc b/runtime/vm/compiler/backend/flow_graph_checker.cc index 1f39a381a8f7..47a134c27ac5 100644 --- a/runtime/vm/compiler/backend/flow_graph_checker.cc +++ b/runtime/vm/compiler/backend/flow_graph_checker.cc @@ -480,7 +480,7 @@ void FlowGraphChecker::VisitConstant(ConstantInstr* constant) { // Range check on smi. const Object& value = constant->value(); if (value.IsSmi()) { - const int64_t smi_value = Integer::Cast(value).AsInt64Value(); + const int64_t smi_value = Integer::Cast(value).Value(); ASSERT(compiler::target::kSmiMin <= smi_value); ASSERT(smi_value <= compiler::target::kSmiMax); } diff --git a/runtime/vm/compiler/backend/il.cc b/runtime/vm/compiler/backend/il.cc index 498734fb2ccc..e3bd002d19ac 100644 --- a/runtime/vm/compiler/backend/il.cc +++ b/runtime/vm/compiler/backend/il.cc @@ -1133,7 +1133,7 @@ ConstantInstr::ConstantInstr(const Object& value, const InstructionSource& source) : TemplateDefinition(source), value_(value), token_pos_(source.token_pos) { // Check that the value is not an incorrect Integer representation. - ASSERT(!value.IsMint() || !Smi::IsValid(Mint::Cast(value).AsInt64Value())); + ASSERT(!value.IsMint() || !Smi::IsValid(Mint::Cast(value).Value())); // Check that clones of fields are not stored as constants. ASSERT(!value.IsField() || Field::Cast(value).IsOriginal()); // Check that all non-Smi objects are heap allocated and in old space. @@ -2117,7 +2117,7 @@ bool BinaryIntegerOpInstr::RightIsNonZero() const { if (right()->BindsToConstant()) { const auto& constant = right()->BoundConstant(); if (!constant.IsInteger()) return false; - return Integer::Cast(constant).AsInt64Value() != 0; + return Integer::Cast(constant).Value() != 0; } return !RangeUtils::CanBeZero(right()->definition()->range()); } @@ -3271,7 +3271,7 @@ Definition* BoxIntegerInstr::Canonicalize(FlowGraph* flow_graph) { // is an integer representation and [v] is representable in [from]. if (auto* const constant = value_defn->AsUnboxedConstant()) { if (RepresentationUtils::IsUnboxedInteger(constant->representation())) { - const int64_t intval = Integer::Cast(constant->value()).AsInt64Value(); + const int64_t intval = Integer::Cast(constant->value()).Value(); if (RepresentationUtils::IsRepresentable(from_representation(), intval)) { return flow_graph->GetConstant(constant->value()); } @@ -3356,7 +3356,7 @@ Definition* UnboxInstr::Canonicalize(FlowGraph* flow_graph) { if (val.IsInteger()) { const Double& double_val = Double::ZoneHandle( flow_graph->zone(), - Double::NewCanonical(Integer::Cast(val).AsDoubleValue())); + Double::NewCanonical(Integer::Cast(val).ToDouble())); return flow_graph->GetConstant(double_val, kUnboxedDouble); } else if (val.IsDouble()) { return flow_graph->GetConstant(val, kUnboxedDouble); @@ -3366,8 +3366,7 @@ Definition* UnboxInstr::Canonicalize(FlowGraph* flow_graph) { if (representation() == kUnboxedFloat && value()->BindsToConstant()) { const Object& val = value()->BoundConstant(); if (val.IsInteger()) { - double narrowed_val = - static_cast(Integer::Cast(val).AsDoubleValue()); + double narrowed_val = static_cast(Integer::Cast(val).ToDouble()); return flow_graph->GetConstant( Double::ZoneHandle(Double::NewCanonical(narrowed_val)), kUnboxedFloat); @@ -3436,7 +3435,7 @@ Definition* UnboxIntegerInstr::Canonicalize(FlowGraph* flow_graph) { if (representation() == kUnboxedInt64) { return flow_graph->GetConstant(obj, representation()); } - const int64_t intval = Integer::Cast(obj).AsInt64Value(); + const int64_t intval = Integer::Cast(obj).Value(); if (RepresentationUtils::IsRepresentable(representation(), intval)) { return flow_graph->GetConstant(obj, representation()); } @@ -3460,7 +3459,7 @@ Definition* IntConverterInstr::Canonicalize(FlowGraph* flow_graph) { if (auto constant = value()->definition()->AsConstant()) { if (from() != kUntagged && to() != kUntagged && constant->representation() == from() && constant->value().IsInteger()) { - const int64_t value = Integer::Cast(constant->value()).AsInt64Value(); + const int64_t value = Integer::Cast(constant->value()).Value(); const int64_t result = Evaluator::TruncateTo(Evaluator::TruncateTo(value, from()), to()); if (is_truncating() || (value == result)) { @@ -7018,8 +7017,7 @@ void MemoryCopyInstr::EmitNativeCode(FlowGraphCompiler* compiler) { const bool constant_length = length_loc.IsConstant(); const Register length_reg = constant_length ? kNoRegister : length_loc.reg(); const intptr_t num_elements = - constant_length ? Integer::Cast(length_loc.constant()).AsInt64Value() - : -1; + constant_length ? Integer::Cast(length_loc.constant()).Value() : -1; // The zero constant case should be handled via canonicalization. ASSERT(!constant_length || num_elements > 0); @@ -8506,9 +8504,8 @@ Definition* SimdOpInstr::Canonicalize(FlowGraph* flow_graph) { const Object& w = InputAt(3)->BoundConstant(); if (x.IsInteger() && y.IsInteger() && z.IsInteger() && w.IsInteger()) { Int32x4& result = Int32x4::Handle(Int32x4::New( - Integer::Cast(x).AsInt64Value(), Integer::Cast(y).AsInt64Value(), - Integer::Cast(z).AsInt64Value(), Integer::Cast(w).AsInt64Value(), - Heap::kOld)); + Integer::Cast(x).Value(), Integer::Cast(y).Value(), + Integer::Cast(z).Value(), Integer::Cast(w).Value(), Heap::kOld)); result ^= result.Canonicalize(Thread::Current()); return flow_graph->GetConstant(result, kUnboxedInt32x4); } @@ -8729,7 +8726,7 @@ void MakePairInstr::EmitNativeCode(FlowGraphCompiler* compiler) { } int64_t TestIntInstr::ComputeImmediateMask() { - int64_t mask = Integer::Cast(locs()->in(1).constant()).AsInt64Value(); + int64_t mask = Integer::Cast(locs()->in(1).constant()).Value(); switch (representation_) { case kTagged: diff --git a/runtime/vm/compiler/backend/il_arm.cc b/runtime/vm/compiler/backend/il_arm.cc index 9a8794e6f4c6..cef4275d39a5 100644 --- a/runtime/vm/compiler/backend/il_arm.cc +++ b/runtime/vm/compiler/backend/il_arm.cc @@ -432,7 +432,7 @@ void MemoryCopyInstr::EmitComputeStartPointer(FlowGraphCompiler* compiler, if (start_loc.IsConstant()) { const auto& constant = start_loc.constant(); ASSERT(constant.IsInteger()); - const int64_t start_value = Integer::Cast(constant).AsInt64Value(); + const int64_t start_value = Integer::Cast(constant).Value(); const intptr_t add_value = Utils::AddWithWrapAround( Utils::MulWithWrapAround(start_value, element_size_), offset); __ AddImmediate(payload_reg, array_reg, add_value); @@ -1281,12 +1281,12 @@ static Condition EmitWordComparisonOp(FlowGraphCompiler* compiler, if (left.IsConstant()) { __ CompareImmediate( right.reg(), - static_cast(Integer::Cast(left.constant()).AsInt64Value())); + static_cast(Integer::Cast(left.constant()).Value())); true_condition = FlipCondition(true_condition); } else if (right.IsConstant()) { __ CompareImmediate( left.reg(), - static_cast(Integer::Cast(right.constant()).AsInt64Value())); + static_cast(Integer::Cast(right.constant()).Value())); } else { __ cmp(left.reg(), compiler::Operand(right.reg())); } @@ -6507,7 +6507,7 @@ static void EmitShiftInt64ByConstant(FlowGraphCompiler* compiler, Register left_lo, Register left_hi, const Object& right) { - const int64_t shift = Integer::Cast(right).AsInt64Value(); + const int64_t shift = Integer::Cast(right).Value(); ASSERT(shift >= 0); switch (op_kind) { @@ -6610,7 +6610,7 @@ static void EmitShiftUint32ByConstant(FlowGraphCompiler* compiler, Register out, Register left, const Object& right) { - const int64_t shift = Integer::Cast(right).AsInt64Value(); + const int64_t shift = Integer::Cast(right).Value(); ASSERT(shift >= 0); if (shift >= 32) { __ LoadImmediate(out, 0); diff --git a/runtime/vm/compiler/backend/il_arm64.cc b/runtime/vm/compiler/backend/il_arm64.cc index 071541edc7c6..92dd19d12253 100644 --- a/runtime/vm/compiler/backend/il_arm64.cc +++ b/runtime/vm/compiler/backend/il_arm64.cc @@ -347,7 +347,7 @@ void MemoryCopyInstr::EmitComputeStartPointer(FlowGraphCompiler* compiler, if (start_loc.IsConstant()) { const auto& constant = start_loc.constant(); ASSERT(constant.IsInteger()); - const int64_t start_value = Integer::Cast(constant).AsInt64Value(); + const int64_t start_value = Integer::Cast(constant).Value(); const intptr_t add_value = Utils::AddWithWrapAround( Utils::MulWithWrapAround(start_value, element_size_), offset); __ AddImmediate(payload_reg, array_reg, add_value); @@ -727,7 +727,7 @@ void ConstantInstr::EmitMoveToLocation(FlowGraphCompiler* compiler, if (representation() == kUnboxedInt32 || representation() == kUnboxedUint32 || representation() == kUnboxedInt64) { - const int64_t value = Integer::Cast(value_).AsInt64Value(); + const int64_t value = Integer::Cast(value_).Value(); __ LoadImmediate(destination.reg(), value); } else { ASSERT(representation() == kTagged); @@ -782,7 +782,7 @@ void ConstantInstr::EmitMoveToLocation(FlowGraphCompiler* compiler, if (representation() == kUnboxedInt32 || representation() == kUnboxedUint32 || representation() == kUnboxedInt64) { - const int64_t value = Integer::Cast(value_).AsInt64Value(); + const int64_t value = Integer::Cast(value_).Value(); if (value == 0) { tmp = ZR; } else { @@ -1276,7 +1276,7 @@ static bool IsSingleBitMask(Location mask, intptr_t* bit) { } uint64_t mask_value = - static_cast(Integer::Cast(mask.constant()).AsInt64Value()); + static_cast(Integer::Cast(mask.constant()).Value()); if (!Utils::IsPowerOfTwo(mask_value)) { return false; } @@ -5488,7 +5488,7 @@ static void EmitInt64ModTruncDiv(FlowGraphCompiler* compiler, // We only consider magic operations under O3. } else if (auto c = instruction->right()->definition()->AsConstant()) { if (c->value().IsInteger()) { - const int64_t divisor = Integer::Cast(c->value()).AsInt64Value(); + const int64_t divisor = Integer::Cast(c->value()).Value(); if (divisor <= -2 || divisor >= 2) { // For x DIV c or x MOD c: use magic operations. compiler::Label pos; @@ -5670,7 +5670,7 @@ static void EmitShiftInt64ByConstant(FlowGraphCompiler* compiler, Register out, Register left, const Object& right) { - const int64_t shift = Integer::Cast(right).AsInt64Value(); + const int64_t shift = Integer::Cast(right).Value(); ASSERT(shift >= 0); switch (op_kind) { case Token::kSHR: { @@ -5721,7 +5721,7 @@ static void EmitShiftUint32ByConstant(FlowGraphCompiler* compiler, Register out, Register left, const Object& right) { - const int64_t shift = Integer::Cast(right).AsInt64Value(); + const int64_t shift = Integer::Cast(right).Value(); ASSERT(shift >= 0); if (shift >= 32) { __ LoadImmediate(out, 0); diff --git a/runtime/vm/compiler/backend/il_ia32.cc b/runtime/vm/compiler/backend/il_ia32.cc index fbe2aca4b268..4eb619e6ec02 100644 --- a/runtime/vm/compiler/backend/il_ia32.cc +++ b/runtime/vm/compiler/backend/il_ia32.cc @@ -225,7 +225,7 @@ void MemoryCopyInstr::EmitComputeStartPointer(FlowGraphCompiler* compiler, if (start_loc.IsConstant()) { const auto& constant = start_loc.constant(); ASSERT(constant.IsInteger()); - const int64_t start_value = Integer::Cast(constant).AsInt64Value(); + const int64_t start_value = Integer::Cast(constant).Value(); const intptr_t add_value = Utils::AddWithWrapAround( Utils::MulWithWrapAround(start_value, element_size_), offset); __ leal(payload_reg, compiler::Address(array_reg, add_value)); @@ -805,12 +805,12 @@ static Condition EmitWordComparisonOp(FlowGraphCompiler* compiler, if (left.IsConstant()) { __ CompareImmediate( right.reg(), - static_cast(Integer::Cast(left.constant()).AsInt64Value())); + static_cast(Integer::Cast(left.constant()).Value())); true_condition = FlipCondition(true_condition); } else if (right.IsConstant()) { __ CompareImmediate( left.reg(), - static_cast(Integer::Cast(right.constant()).AsInt64Value())); + static_cast(Integer::Cast(right.constant()).Value())); } else if (right.IsStackSlot()) { __ cmpl(left.reg(), LocationToStackSlotAddress(right)); } else { @@ -5597,7 +5597,7 @@ static void EmitShiftInt64ByConstant(FlowGraphCompiler* compiler, Register left_lo, Register left_hi, const Object& right) { - const int64_t shift = Integer::Cast(right).AsInt64Value(); + const int64_t shift = Integer::Cast(right).Value(); ASSERT(shift >= 0); switch (op_kind) { case Token::kSHR: { @@ -5709,7 +5709,7 @@ static void EmitShiftUint32ByConstant(FlowGraphCompiler* compiler, Token::Kind op_kind, Register left, const Object& right) { - const int64_t shift = Integer::Cast(right).AsInt64Value(); + const int64_t shift = Integer::Cast(right).Value(); if (shift >= 32) { __ xorl(left, left); } else { diff --git a/runtime/vm/compiler/backend/il_printer.cc b/runtime/vm/compiler/backend/il_printer.cc index f5d2b0d004ce..daa337163490 100644 --- a/runtime/vm/compiler/backend/il_printer.cc +++ b/runtime/vm/compiler/backend/il_printer.cc @@ -252,7 +252,7 @@ class IlTestPrinter : public AllStatic { } else if (obj->IsBool()) { writer_->PrintValueBool(Bool::Cast(*obj).value()); } else if (obj->IsInteger()) { - auto value = Integer::Cast(*obj).AsInt64Value(); + auto value = Integer::Cast(*obj).Value(); // PrintValue64 and PrintValue will check if integer is representable // as a JS number, which is too strict. We don't actually need // such checks because we only load resulting JSON in Dart. diff --git a/runtime/vm/compiler/backend/il_riscv.cc b/runtime/vm/compiler/backend/il_riscv.cc index 2529e6db979e..c703322e721e 100644 --- a/runtime/vm/compiler/backend/il_riscv.cc +++ b/runtime/vm/compiler/backend/il_riscv.cc @@ -424,7 +424,7 @@ void MemoryCopyInstr::EmitComputeStartPointer(FlowGraphCompiler* compiler, if (start_loc.IsConstant()) { const auto& constant = start_loc.constant(); ASSERT(constant.IsInteger()); - const int64_t start_value = Integer::Cast(constant).AsInt64Value(); + const int64_t start_value = Integer::Cast(constant).Value(); const intx_t add_value = Utils::AddWithWrapAround( Utils::MulWithWrapAround(start_value, element_size_), offset); __ AddImmediate(payload_reg, array_reg, add_value); @@ -825,7 +825,7 @@ void ConstantInstr::EmitMoveToLocation(FlowGraphCompiler* compiler, const intptr_t dest_offset = destination.ToStackSlotOffset(); compiler::OperandSize operand_size = compiler::kWordBytes; if (RepresentationUtils::IsUnboxedInteger(representation())) { - int64_t val = Integer::Cast(value_).AsInt64Value(); + int64_t val = Integer::Cast(value_).Value(); #if XLEN == 32 val = pair_index == 0 ? Utils::Low32Bits(val) : Utils::High32Bits(val); #else @@ -1082,7 +1082,7 @@ static Condition EmitWordComparisonOp(FlowGraphCompiler* compiler, } __ CompareImmediate( left.reg(), - static_cast(Integer::Cast(right.constant()).AsInt64Value())); + static_cast(Integer::Cast(right.constant()).Value())); } else { __ CompareRegisters(left.reg(), right.reg()); } @@ -5811,7 +5811,7 @@ static void EmitShiftInt64ByConstant(FlowGraphCompiler* compiler, Register left_lo, Register left_hi, const Object& right) { - const int64_t shift = Integer::Cast(right).AsInt64Value(); + const int64_t shift = Integer::Cast(right).Value(); ASSERT(shift >= 0); switch (op_kind) { @@ -5878,7 +5878,7 @@ static void EmitShiftInt64ByConstant(FlowGraphCompiler* compiler, Register out, Register left, const Object& right) { - const int64_t shift = Integer::Cast(right).AsInt64Value(); + const int64_t shift = Integer::Cast(right).Value(); ASSERT(shift >= 0); switch (op_kind) { case Token::kSHR: { @@ -6011,7 +6011,7 @@ static void EmitShiftUint32ByConstant(FlowGraphCompiler* compiler, Register out, Register left, const Object& right) { - const int64_t shift = Integer::Cast(right).AsInt64Value(); + const int64_t shift = Integer::Cast(right).Value(); ASSERT(shift >= 0); if (shift >= 32) { __ li(out, 0); diff --git a/runtime/vm/compiler/backend/il_serializer.cc b/runtime/vm/compiler/backend/il_serializer.cc index ab6216fd9893..465247fe0f17 100644 --- a/runtime/vm/compiler/backend/il_serializer.cc +++ b/runtime/vm/compiler/backend/il_serializer.cc @@ -1653,7 +1653,7 @@ void FlowGraphSerializer::WriteObjectImpl(const Object& x, } case kMintCid: ASSERT(x.IsCanonical()); - Write(Integer::Cast(x).AsInt64Value()); + Write(Integer::Cast(x).Value()); break; case kNullCid: break; diff --git a/runtime/vm/compiler/backend/il_test.cc b/runtime/vm/compiler/backend/il_test.cc index 4fbc2522cea4..dea44d654fa9 100644 --- a/runtime/vm/compiler/backend/il_test.cc +++ b/runtime/vm/compiler/backend/il_test.cc @@ -757,7 +757,7 @@ ISOLATE_UNIT_TEST_CASE(IRTest_LoadThread) { // Ensure we can successfully invoke the function. invoke_result ^= Invoke(root_library, "myFunction"); - intptr_t result_int = Integer::Cast(invoke_result).AsInt64Value(); + intptr_t result_int = Integer::Cast(invoke_result).Value(); EXPECT_EQ(reinterpret_cast(thread), result_int); } diff --git a/runtime/vm/compiler/backend/il_x64.cc b/runtime/vm/compiler/backend/il_x64.cc index ce7831d4f18d..a3c532db3a70 100644 --- a/runtime/vm/compiler/backend/il_x64.cc +++ b/runtime/vm/compiler/backend/il_x64.cc @@ -321,7 +321,7 @@ void MemoryCopyInstr::EmitComputeStartPointer(FlowGraphCompiler* compiler, if (start_loc.IsConstant()) { const auto& constant = start_loc.constant(); ASSERT(constant.IsInteger()); - const int64_t start_value = Integer::Cast(constant).AsInt64Value(); + const int64_t start_value = Integer::Cast(constant).Value(); const intptr_t add_value = Utils::AddWithWrapAround( Utils::MulWithWrapAround(start_value, element_size_), offset); __ leaq(payload_reg, compiler::Address(array_reg, add_value)); @@ -648,7 +648,7 @@ void ConstantInstr::EmitMoveToLocation(FlowGraphCompiler* compiler, ASSERT(pair_index == 0); // No pair representation needed on 64-bit. if (destination.IsRegister()) { if (RepresentationUtils::IsUnboxedInteger(representation())) { - const int64_t value = Integer::Cast(value_).AsInt64Value(); + const int64_t value = Integer::Cast(value_).Value(); if (value == 0) { __ xorl(destination.reg(), destination.reg()); } else { @@ -702,7 +702,7 @@ void ConstantInstr::EmitMoveToLocation(FlowGraphCompiler* compiler, } else { ASSERT(destination.IsStackSlot()); if (RepresentationUtils::IsUnboxedInteger(representation())) { - const int64_t value = Integer::Cast(value_).AsInt64Value(); + const int64_t value = Integer::Cast(value_).Value(); __ movq(LocationToStackSlotAddress(destination), compiler::Immediate(value)); } else if (representation() == kUnboxedFloat) { @@ -5752,7 +5752,7 @@ static void EmitInt64ModTruncDiv(FlowGraphCompiler* compiler, // to implement the exception. if (auto c = instruction->right()->definition()->AsConstant()) { if (c->value().IsInteger()) { - const int64_t divisor = Integer::Cast(c->value()).AsInt64Value(); + const int64_t divisor = Integer::Cast(c->value()).Value(); if (divisor <= -2 || divisor >= 2) { // For x DIV c or x MOD c: use magic operations. compiler::Label pos; @@ -5986,7 +5986,7 @@ static void EmitShiftInt64ByConstant(FlowGraphCompiler* compiler, Token::Kind op_kind, Register left, const Object& right) { - const int64_t shift = Integer::Cast(right).AsInt64Value(); + const int64_t shift = Integer::Cast(right).Value(); ASSERT(shift >= 0); switch (op_kind) { case Token::kSHR: @@ -6032,7 +6032,7 @@ static void EmitShiftUint32ByConstant(FlowGraphCompiler* compiler, Token::Kind op_kind, Register left, const Object& right) { - const int64_t shift = Integer::Cast(right).AsInt64Value(); + const int64_t shift = Integer::Cast(right).Value(); ASSERT(shift >= 0); if (shift >= 32) { __ xorl(left, left); diff --git a/runtime/vm/compiler/backend/loops.cc b/runtime/vm/compiler/backend/loops.cc index ede12737b248..fcc3cee41736 100644 --- a/runtime/vm/compiler/backend/loops.cc +++ b/runtime/vm/compiler/backend/loops.cc @@ -124,7 +124,7 @@ static bool IsConstant(Definition* def, int64_t* val) { if (def->IsConstant()) { const Object& value = def->AsConstant()->value(); if (value.IsInteger()) { - *val = Integer::Cast(value).AsInt64Value(); // smi and mint + *val = Integer::Cast(value).Value(); // smi and mint return true; } } diff --git a/runtime/vm/compiler/backend/range_analysis.cc b/runtime/vm/compiler/backend/range_analysis.cc index c8886c0db187..591332f3e84c 100644 --- a/runtime/vm/compiler/backend/range_analysis.cc +++ b/runtime/vm/compiler/backend/range_analysis.cc @@ -2791,16 +2791,12 @@ void PhiInstr::InferRange(RangeAnalysis* analysis, Range* range) { } void ConstantInstr::InferRange(RangeAnalysis* analysis, Range* range) { - if (value_.IsSmi()) { - int64_t value = Smi::Cast(value_).Value(); - *range = Range(RangeBoundary::FromConstant(value), - RangeBoundary::FromConstant(value)); - } else if (value_.IsMint()) { - int64_t value = Mint::Cast(value_).value(); + if (value_.IsInteger()) { + int64_t value = Integer::Cast(value_).Value(); *range = Range(RangeBoundary::FromConstant(value), RangeBoundary::FromConstant(value)); } else { - // Only Smi and Mint supported. + // Only integer constants supported. FATAL("Unexpected constant: %s\n", value_.ToCString()); } } diff --git a/runtime/vm/compiler/ffi/native_type.cc b/runtime/vm/compiler/ffi/native_type.cc index b0c86f9bbcbf..c632313bb1c3 100644 --- a/runtime/vm/compiler/ffi/native_type.cc +++ b/runtime/vm/compiler/ffi/native_type.cc @@ -463,7 +463,7 @@ static const NativeType* CompoundFromPragma(Zone* zone, const auto& packed_value = Integer::Handle( zone, Integer::RawCast(struct_layout.GetField(packed_field))); const intptr_t member_packing = - packed_value.IsNull() ? kMaxInt32 : packed_value.AsInt64Value(); + packed_value.IsNull() ? kMaxInt32 : packed_value.Value(); auto& field_instance = Instance::Handle(zone); auto& field_type = AbstractType::Handle(zone); @@ -506,7 +506,7 @@ static const NativeType* CompoundFromPragma(Zone* zone, return nullptr; } const auto field_native_type = - new (zone) NativeArrayType(*element_type, length.AsInt64Value()); + new (zone) NativeArrayType(*element_type, length.Value()); field_native_types.Add(field_native_type); } } diff --git a/runtime/vm/compiler/frontend/kernel_binary_flowgraph.cc b/runtime/vm/compiler/frontend/kernel_binary_flowgraph.cc index 46c46cd1e1f6..6e6713ee9f22 100644 --- a/runtime/vm/compiler/frontend/kernel_binary_flowgraph.cc +++ b/runtime/vm/compiler/frontend/kernel_binary_flowgraph.cc @@ -5255,8 +5255,8 @@ Fragment StreamingFlowGraphBuilder::BuildBinarySearchSwitch( Fragment lower_branch_instructions(then_entry); Fragment upper_branch_instructions(otherwise_entry); - if (next_expression.integer().AsInt64Value() > - middle_expression.integer().AsInt64Value() + 1) { + if (next_expression.integer().Value() > + middle_expression.integer().Value() + 1) { // The upper branch is not contiguous with the lower branch. // Before continuing in the upper branch we add a bound check. @@ -5347,7 +5347,7 @@ Fragment StreamingFlowGraphBuilder::BuildJumpTableSwitch(SwitchHelper* helper) { current_instructions += LoadLocal(scopes()->switch_variable); - if (!expression_min.IsZero()) { + if (expression_min.Value() != 0) { // Adjust for the range of the jump table, which starts at 0. current_instructions += Constant(expression_min); current_instructions += @@ -5374,7 +5374,7 @@ Fragment StreamingFlowGraphBuilder::BuildJumpTableSwitch(SwitchHelper* helper) { const SwitchExpression& expression = helper->expressions().At(expression_index++); const intptr_t table_offset = - expression.integer().AsInt64Value() - expression_min.AsInt64Value(); + expression.integer().Value() - expression_min.Value(); IndirectEntryInstr* indirect_entry = B->BuildIndirectEntry(table_offset, CurrentTryIndex()); diff --git a/runtime/vm/compiler/frontend/kernel_binary_flowgraph_test.cc b/runtime/vm/compiler/frontend/kernel_binary_flowgraph_test.cc index 1ca391ca360a..81a6e3903a1d 100644 --- a/runtime/vm/compiler/frontend/kernel_binary_flowgraph_test.cc +++ b/runtime/vm/compiler/frontend/kernel_binary_flowgraph_test.cc @@ -98,14 +98,14 @@ ISOLATE_UNIT_TEST_CASE(StreamingFlowGraphBuilder_FlattenNestedStringInterp) { // StoreIndexed(tmp_array, 0, s) EXPECT(store1->index()->BindsToConstant()); EXPECT(store1->index()->BoundConstant().IsInteger()); - EXPECT(Integer::Cast(store1->index()->BoundConstant()).AsInt64Value() == 0); + EXPECT(Integer::Cast(store1->index()->BoundConstant()).Value() == 0); EXPECT(!store1->value()->BindsToConstant()); // StoreIndexed(tmp_array, 1, "de") EXPECT(store2->index()->BindsToConstant()); EXPECT(store2->index()->BoundConstant().IsInteger()); - EXPECT(Integer::Cast(store2->index()->BoundConstant()).AsInt64Value() == 1); + EXPECT(Integer::Cast(store2->index()->BoundConstant()).Value() == 1); EXPECT(store2->value()->BindsToConstant()); EXPECT(store2->value()->BoundConstant().IsString()); @@ -158,7 +158,7 @@ ISOLATE_UNIT_TEST_CASE(StreamingFlowGraphBuilder_DropEmptyStringInterp) { // StoreIndexed(tmp_array, 0, "ab") EXPECT(store1->index()->BindsToConstant()); EXPECT(store1->index()->BoundConstant().IsInteger()); - EXPECT(Integer::Cast(store1->index()->BoundConstant()).AsInt64Value() == 0); + EXPECT(Integer::Cast(store1->index()->BoundConstant()).Value() == 0); EXPECT(store1->value()->BindsToConstant()); EXPECT(store1->value()->BoundConstant().IsString()); @@ -167,14 +167,14 @@ ISOLATE_UNIT_TEST_CASE(StreamingFlowGraphBuilder_DropEmptyStringInterp) { // StoreIndexed(tmp_array, 1, s) EXPECT(store2->index()->BindsToConstant()); EXPECT(store2->index()->BoundConstant().IsInteger()); - EXPECT(Integer::Cast(store2->index()->BoundConstant()).AsInt64Value() == 1); + EXPECT(Integer::Cast(store2->index()->BoundConstant()).Value() == 1); EXPECT(!store2->value()->BindsToConstant()); // StoreIndexed(tmp_array, 2, "b") EXPECT(store3->index()->BindsToConstant()); EXPECT(store3->index()->BoundConstant().IsInteger()); - EXPECT(Integer::Cast(store3->index()->BoundConstant()).AsInt64Value() == 2); + EXPECT(Integer::Cast(store3->index()->BoundConstant()).Value() == 2); EXPECT(store3->value()->BindsToConstant()); EXPECT(store3->value()->BoundConstant().IsString()); @@ -227,7 +227,7 @@ ISOLATE_UNIT_TEST_CASE(StreamingFlowGraphBuilder_ConcatStringLits) { // StoreIndexed(tmp_array, 0, "ab") EXPECT(store1->index()->BindsToConstant()); EXPECT(store1->index()->BoundConstant().IsInteger()); - EXPECT(Integer::Cast(store1->index()->BoundConstant()).AsInt64Value() == 0); + EXPECT(Integer::Cast(store1->index()->BoundConstant()).Value() == 0); EXPECT(store1->value()->BindsToConstant()); EXPECT(store1->value()->BoundConstant().IsString()); @@ -236,14 +236,14 @@ ISOLATE_UNIT_TEST_CASE(StreamingFlowGraphBuilder_ConcatStringLits) { // StoreIndexed(tmp_array, 1, s) EXPECT(store2->index()->BindsToConstant()); EXPECT(store2->index()->BoundConstant().IsInteger()); - EXPECT(Integer::Cast(store2->index()->BoundConstant()).AsInt64Value() == 1); + EXPECT(Integer::Cast(store2->index()->BoundConstant()).Value() == 1); EXPECT(!store2->value()->BindsToConstant()); // StoreIndexed(tmp_array, 2, "cd") EXPECT(store3->index()->BindsToConstant()); EXPECT(store3->index()->BoundConstant().IsInteger()); - EXPECT(Integer::Cast(store3->index()->BoundConstant()).AsInt64Value() == 2); + EXPECT(Integer::Cast(store3->index()->BoundConstant()).Value() == 2); EXPECT(store3->value()->BindsToConstant()); EXPECT(store3->value()->BoundConstant().IsString()); @@ -387,7 +387,7 @@ ISOLATE_UNIT_TEST_CASE( return_instr->value()->definition()->AsConstant(); EXPECT(const_value != nullptr); EXPECT(const_value->value().IsInteger()); - EXPECT_EQ(0xFEEDFEED, Integer::Cast(const_value->value()).AsInt64Value()); + EXPECT_EQ(0xFEEDFEED, Integer::Cast(const_value->value()).Value()); } } // namespace dart diff --git a/runtime/vm/compiler/frontend/kernel_to_il.cc b/runtime/vm/compiler/frontend/kernel_to_il.cc index 87956ccfd71b..80f2ff625cd7 100644 --- a/runtime/vm/compiler/frontend/kernel_to_il.cc +++ b/runtime/vm/compiler/frontend/kernel_to_il.cc @@ -5862,8 +5862,8 @@ SwitchHelper::SwitchHelper(Zone* zone, } int64_t SwitchHelper::ExpressionRange() const { - const int64_t min = expression_min().AsInt64Value(); - const int64_t max = expression_max().AsInt64Value(); + const int64_t min = expression_min().Value(); + const int64_t max = expression_max().Value(); ASSERT(min <= max); const uint64_t diff = static_cast(max) - static_cast(min); // Saturate to avoid overflow. @@ -5875,7 +5875,7 @@ int64_t SwitchHelper::ExpressionRange() const { bool SwitchHelper::RequiresLowerBoundCheck() const { if (is_enum_switch()) { - if (expression_min().IsZero()) { + if (expression_min().Value() == 0) { // Enum indexes are always positive. return false; } @@ -5972,14 +5972,14 @@ SwitchDispatch SwitchHelper::SelectDispatchStrategy() { // If the range starts at zero it directly maps to the jump table // and we don't need to adjust the switch variable before the // jump table. - if (expression_min().AsInt64Value() > 0) { + if (expression_min().Value() > 0) { const intptr_t holes_budget = Utils::Minimum( // Holes still available. max_holes - holes, // Entries left in the jump table. kJumpTableMaxSize - range); - const int64_t required_holes = expression_min().AsInt64Value(); + const int64_t required_holes = expression_min().Value(); if (required_holes <= holes_budget) { expression_min_ = &Object::smi_zero(); } diff --git a/runtime/vm/compiler/runtime_api.cc b/runtime/vm/compiler/runtime_api.cc index 4122bb3dd81c..c5c0c3684f99 100644 --- a/runtime/vm/compiler/runtime_api.cc +++ b/runtime/vm/compiler/runtime_api.cc @@ -238,7 +238,7 @@ const String& AllocateString(const char* buffer) { bool HasIntegerValue(const dart::Object& object, int64_t* value) { if (object.IsInteger()) { - *value = Integer::Cast(object).AsInt64Value(); + *value = Integer::Cast(object).Value(); return true; } return false; diff --git a/runtime/vm/compiler_test.cc b/runtime/vm/compiler_test.cc index 63d57dc36b2d..26f62a4425da 100644 --- a/runtime/vm/compiler_test.cc +++ b/runtime/vm/compiler_test.cc @@ -248,7 +248,7 @@ ISOLATE_UNIT_TEST_CASE(EvalExpressionWithLazyCompile) { EXPECT(!val.IsNull()); EXPECT(!val.IsError()); EXPECT(val.IsInteger()); - EXPECT_EQ(7, Integer::Cast(val).AsInt64Value()); + EXPECT_EQ(7, Integer::Cast(val).Value()); } ISOLATE_UNIT_TEST_CASE(EvalExpressionExhaustCIDs) { @@ -267,7 +267,7 @@ ISOLATE_UNIT_TEST_CASE(EvalExpressionExhaustCIDs) { EXPECT(!val.IsNull()); EXPECT(!val.IsError()); EXPECT(val.IsInteger()); - EXPECT_EQ(7, Integer::Cast(val).AsInt64Value()); + EXPECT_EQ(7, Integer::Cast(val).Value()); auto class_table = IsolateGroup::Current()->class_table(); @@ -280,7 +280,7 @@ ISOLATE_UNIT_TEST_CASE(EvalExpressionExhaustCIDs) { EXPECT(!val.IsNull()); EXPECT(!val.IsError()); EXPECT(val.IsInteger()); - EXPECT_EQ(7, Integer::Cast(val).AsInt64Value()); + EXPECT_EQ(7, Integer::Cast(val).Value()); intptr_t final_class_table_size = class_table->NumCids(); // Eval should not eat into this non-renewable resource. diff --git a/runtime/vm/dart_api_impl.cc b/runtime/vm/dart_api_impl.cc index 79a25b965c33..e39f93b73a53 100644 --- a/runtime/vm/dart_api_impl.cc +++ b/runtime/vm/dart_api_impl.cc @@ -2628,7 +2628,7 @@ DART_EXPORT Dart_Handle Dart_IntegerFitsIntoUint64(Dart_Handle integer, RETURN_TYPE_ERROR(Z, integer, Integer); } ASSERT(int_obj.IsMint()); - *fits = !int_obj.IsNegative(); + *fits = (int_obj.Value() >= 0); return Api::Success(); } @@ -2684,7 +2684,7 @@ DART_EXPORT Dart_Handle Dart_IntegerToInt64(Dart_Handle integer, RETURN_TYPE_ERROR(Z, integer, Integer); } ASSERT(int_obj.IsMint()); - *value = int_obj.AsInt64Value(); + *value = int_obj.Value(); return Api::Success(); } @@ -2708,11 +2708,12 @@ DART_EXPORT Dart_Handle Dart_IntegerToUint64(Dart_Handle integer, RETURN_TYPE_ERROR(Z, integer, Integer); } if (int_obj.IsSmi()) { - ASSERT(int_obj.IsNegative()); + ASSERT(int_obj.Value() < 0); } else { ASSERT(int_obj.IsMint()); - if (!int_obj.IsNegative()) { - *value = int_obj.AsInt64Value(); + const int64_t v = int_obj.Value(); + if (v >= 0) { + *value = v; return Api::Success(); } } @@ -3171,7 +3172,7 @@ DART_EXPORT Dart_Handle Dart_ListLength(Dart_Handle list, intptr_t* len) { *len = Smi::Cast(retval).Value(); return Api::Success(); } else if (retval.IsMint()) { - int64_t mint_value = Mint::Cast(retval).value(); + int64_t mint_value = Mint::Cast(retval).Value(); if (mint_value >= kIntptrMin && mint_value <= kIntptrMax) { *len = static_cast(mint_value); return Api::Success(); @@ -3391,8 +3392,8 @@ static ObjectPtr ThrowArgumentError(const char* exception_message) { T, ThrowArgumentError("List contains non-int elements")); \ } \ const Integer& integer = Integer::Cast(element); \ - native_array[i] = static_cast(integer.AsInt64Value() & 0xff); \ - ASSERT(integer.AsInt64Value() <= 0xff); \ + native_array[i] = static_cast(integer.Value() & 0xff); \ + ASSERT(integer.Value() <= 0xff); \ } \ return Api::Success(); \ } \ @@ -3453,11 +3454,10 @@ DART_EXPORT Dart_Handle Dart_ListGetAsBytes(Dart_Handle list, CURRENT_FUNC); } const Integer& integer_result = Integer::Cast(result); - ASSERT(integer_result.AsInt64Value() <= 0xff); + ASSERT(integer_result.Value() <= 0xff); // TODO(hpayer): value should always be smaller then 0xff. Add error // handling. - native_array[i] = - static_cast(integer_result.AsInt64Value() & 0xff); + native_array[i] = static_cast(integer_result.Value() & 0xff); } return Api::Success(); } diff --git a/runtime/vm/debugger_api_impl_test.cc b/runtime/vm/debugger_api_impl_test.cc index e4fd09869fd5..3bdbdddc5417 100644 --- a/runtime/vm/debugger_api_impl_test.cc +++ b/runtime/vm/debugger_api_impl_test.cc @@ -163,7 +163,7 @@ Dart_Handle Dart_RemoveBreakpoint(Dart_Handle breakpoint_id_in) { Isolate* I = T->isolate(); CHECK_DEBUGGER(I); UNWRAP_AND_CHECK_PARAM(Integer, breakpoint_id, breakpoint_id_in); - I->debugger()->RemoveBreakpoint(breakpoint_id.AsInt64Value()); + I->debugger()->RemoveBreakpoint(breakpoint_id.Value()); return Api::Success(); } diff --git a/runtime/vm/deferred_objects.cc b/runtime/vm/deferred_objects.cc index 2eebb6fe5ee1..94c9dbab3382 100644 --- a/runtime/vm/deferred_objects.cc +++ b/runtime/vm/deferred_objects.cc @@ -356,15 +356,15 @@ void DeferredObject::Fill() { const int kDataIndex = 0; const int kTypeArgIndex = 1; ASSERT(field_count_ == 2); - ASSERT(Smi::Cast(Object::Handle(zone, GetFieldOffset(kDataIndex))) - .AsInt64Value() == PointerBase::data_offset()); + ASSERT( + Smi::Cast(Object::Handle(zone, GetFieldOffset(kDataIndex))).Value() == + PointerBase::data_offset()); ASSERT(Smi::Cast(Object::Handle(zone, GetFieldOffset(kTypeArgIndex))) - .AsInt64Value() == Pointer::type_arguments_offset()); + .Value() == Pointer::type_arguments_offset()); const auto& pointer = Pointer::Cast(*object_); const size_t address = - Integer::Cast(Object::Handle(zone, GetValue(kDataIndex))) - .AsInt64Value(); + Integer::Cast(Object::Handle(zone, GetValue(kDataIndex))).Value(); pointer.SetNativeAddress(address); const auto& type_args = TypeArguments::Handle( zone, IsolateGroup::Current()->object_store()->type_argument_never()); @@ -407,42 +407,41 @@ void DeferredObject::Fill() { case kTypedDataInt8ArrayCid: typed_data.SetInt8( element_offset, - static_cast(Integer::Cast(value).AsInt64Value())); + static_cast(Integer::Cast(value).Value())); break; case kTypedDataUint8ArrayCid: case kTypedDataUint8ClampedArrayCid: typed_data.SetUint8( element_offset, - static_cast(Integer::Cast(value).AsInt64Value())); + static_cast(Integer::Cast(value).Value())); break; case kTypedDataInt16ArrayCid: typed_data.SetInt16( element_offset, - static_cast(Integer::Cast(value).AsInt64Value())); + static_cast(Integer::Cast(value).Value())); break; case kTypedDataUint16ArrayCid: typed_data.SetUint16( element_offset, - static_cast(Integer::Cast(value).AsInt64Value())); + static_cast(Integer::Cast(value).Value())); break; case kTypedDataInt32ArrayCid: typed_data.SetInt32( element_offset, - static_cast(Integer::Cast(value).AsInt64Value())); + static_cast(Integer::Cast(value).Value())); break; case kTypedDataUint32ArrayCid: typed_data.SetUint32( element_offset, - static_cast(Integer::Cast(value).AsInt64Value())); + static_cast(Integer::Cast(value).Value())); break; case kTypedDataInt64ArrayCid: - typed_data.SetInt64(element_offset, - Integer::Cast(value).AsInt64Value()); + typed_data.SetInt64(element_offset, Integer::Cast(value).Value()); break; case kTypedDataUint64ArrayCid: typed_data.SetUint64( element_offset, - static_cast(Integer::Cast(value).AsInt64Value())); + static_cast(Integer::Cast(value).Value())); break; case kTypedDataFloat32ArrayCid: typed_data.SetFloat32( diff --git a/runtime/vm/interpreter.cc b/runtime/vm/interpreter.cc index 551abb11163b..bad840186ab3 100644 --- a/runtime/vm/interpreter.cc +++ b/runtime/vm/interpreter.cc @@ -1007,7 +1007,7 @@ DART_FORCE_INLINE bool Interpreter::InstanceCall(Thread* thread, SP[0] = selector.ptr(); \ goto ThrowNullError; \ } \ - value = Integer::GetInt64Value(Integer::RawCast(obj)); \ + value = Integer::Value(Integer::RawCast(obj)); \ } \ } @@ -1017,7 +1017,7 @@ DART_FORCE_INLINE bool Interpreter::InstanceCall(Thread* thread, } else if (!AllocateMint(thread, result, pc, FP, SP)) { \ HANDLE_EXCEPTION; \ } \ - ASSERT(Integer::GetInt64Value(Integer::RawCast(SP[0])) == result); + ASSERT(Integer::Value(Integer::RawCast(SP[0])) == result); #define UNBOX_DOUBLE(value, obj, selector) \ double value; \ @@ -2204,7 +2204,7 @@ ObjectPtr Interpreter::Call(FunctionPtr function, break; } default: { - int64_t raw_value = Integer::GetInt64Value(Integer::RawCast(value)); + int64_t raw_value = Integer::Value(Integer::RawCast(value)); *reinterpret_cast( reinterpret_cast(instance->untag()) + offset_in_words) = raw_value; @@ -2742,8 +2742,8 @@ ObjectPtr Interpreter::Call(FunctionPtr function, (SP[0] == null_value) || (SP[1] == null_value)) { SP[0] = false_value; } else { - int64_t a = Integer::GetInt64Value(Integer::RawCast(SP[0])); - int64_t b = Integer::GetInt64Value(Integer::RawCast(SP[1])); + int64_t a = Integer::Value(Integer::RawCast(SP[0])); + int64_t b = Integer::Value(Integer::RawCast(SP[1])); SP[0] = (a == b) ? true_value : false_value; } DISPATCH(); diff --git a/runtime/vm/json_stream.cc b/runtime/vm/json_stream.cc index 93df64abbdc4..29a9f1dbfa7a 100644 --- a/runtime/vm/json_stream.cc +++ b/runtime/vm/json_stream.cc @@ -206,7 +206,7 @@ void JSONStream::PostReply() { PrintProperty("id", str.ToCString()); } else if (seq_->IsInteger()) { const Integer& integer = Integer::Cast(*seq_); - PrintProperty64("id", integer.AsInt64Value()); + PrintProperty64("id", integer.Value()); } else if (seq_->IsDouble()) { const Double& dbl = Double::Cast(*seq_); PrintProperty("id", dbl.value()); diff --git a/runtime/vm/message_snapshot.cc b/runtime/vm/message_snapshot.cc index ca5aeaae01fe..61b2e273c954 100644 --- a/runtime/vm/message_snapshot.cc +++ b/runtime/vm/message_snapshot.cc @@ -890,7 +890,7 @@ class MintMessageSerializationCluster : public MessageSerializationCluster { for (intptr_t i = 0; i < count; i++) { Mint* mint = static_cast(objects_[i]); s->AssignRef(mint); - s->Write(mint->value()); + s->Write(mint->Value()); } } diff --git a/runtime/vm/native_entry_test.cc b/runtime/vm/native_entry_test.cc index b3e0b1932163..94a6e3492af5 100644 --- a/runtime/vm/native_entry_test.cc +++ b/runtime/vm/native_entry_test.cc @@ -70,7 +70,7 @@ void TestNonNullSmiSum(Dart_NativeArguments args) { "to be non-null."); } else { EXPECT_VALID(Dart_IntegerToInt64(arg, &arg_value)); - EXPECT_EQ(arg_value, argument.AsInt64Value()); + EXPECT_EQ(arg_value, argument.Value()); // Ignoring overflow in the addition below. result += arg_value; } diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc index 6a6a3ac7b243..bc86018a2188 100644 --- a/runtime/vm/object.cc +++ b/runtime/vm/object.cc @@ -21027,7 +21027,7 @@ void Instance::SetField(const Field& field, const Object& value) const { break; default: StoreNonPointer(reinterpret_cast(FieldAddr(field)), - Integer::Cast(value).AsInt64Value()); + Integer::Cast(value).Value()); break; } } else { @@ -21054,7 +21054,7 @@ void Instance::SetFieldWithoutFieldGuard(const Field& field, break; default: StoreNonPointer(reinterpret_cast(FieldAddr(field)), - Integer::Cast(value).AsInt64Value()); + Integer::Cast(value).Value()); break; } } else { @@ -23587,69 +23587,25 @@ bool Integer::Equals(const Instance& other) const { return false; } -bool Integer::IsZero() const { - // Integer is an abstract class. - UNREACHABLE(); - return false; -} - -bool Integer::IsNegative() const { - // Integer is an abstract class. - UNREACHABLE(); - return false; -} - -double Integer::AsDoubleValue() const { - // Integer is an abstract class. - UNREACHABLE(); - return 0.0; -} - -int64_t Integer::AsInt64Value() const { - // Integer is an abstract class. - UNREACHABLE(); - return 0; -} - -uint32_t Integer::AsTruncatedUint32Value() const { - // Integer is an abstract class. - UNREACHABLE(); - return 0; -} - -bool Integer::FitsIntoSmi() const { - // Integer is an abstract class. - UNREACHABLE(); - return false; -} - int Integer::CompareWith(const Integer& other) const { - // Integer is an abstract class. - UNREACHABLE(); - return 0; + int64_t a = Value(); + int64_t b = other.Value(); + if (a < b) { + return -1; + } else if (a > b) { + return 1; + } else { + return 0; + } } uint32_t Integer::CanonicalizeHash() const { - return Multiply64Hash(AsInt64Value()); -} - -IntegerPtr Integer::AsValidInteger() const { - if (IsSmi()) return ptr(); - if (IsMint()) { - Mint& mint = Mint::Handle(); - mint ^= ptr(); - if (Smi::IsValid(mint.value())) { - return Smi::New(static_cast(mint.value())); - } else { - return ptr(); - } - } - return ptr(); + return Multiply64Hash(Value()); } const char* Integer::ToHexCString(Zone* zone) const { ASSERT(IsSmi() || IsMint()); - int64_t value = AsInt64Value(); + int64_t value = Value(); if (value < 0) { return OS::SCreate(zone, "-0x%" PX64, -static_cast(value)); } else { @@ -23694,8 +23650,8 @@ IntegerPtr Integer::ArithmeticOp(Token::Kind operation, UNIMPLEMENTED(); } } - const int64_t left_value = AsInt64Value(); - const int64_t right_value = other.AsInt64Value(); + const int64_t left_value = Value(); + const int64_t right_value = other.Value(); switch (operation) { case Token::kADD: return Integer::New(Utils::AddWithWrapAround(left_value, right_value), @@ -23762,8 +23718,8 @@ IntegerPtr Integer::BitOp(Token::Kind kind, ASSERT(Smi::IsValid(result)); return Smi::New(result); } else { - int64_t a = AsInt64Value(); - int64_t b = other.AsInt64Value(); + int64_t a = Value(); + int64_t b = other.Value(); switch (kind) { case Token::kBIT_AND: return Integer::New(a & b, space); @@ -23781,8 +23737,8 @@ IntegerPtr Integer::BitOp(Token::Kind kind, IntegerPtr Integer::ShiftOp(Token::Kind kind, const Integer& other, Heap::Space space) const { - int64_t a = AsInt64Value(); - int64_t b = other.AsInt64Value(); + int64_t a = Value(); + int64_t b = other.Value(); ASSERT(b >= 0); switch (kind) { case Token::kSHL: @@ -23805,40 +23761,6 @@ bool Smi::Equals(const Instance& other) const { return (this->Value() == Smi::Cast(other).Value()); } -double Smi::AsDoubleValue() const { - return static_cast(this->Value()); -} - -int64_t Smi::AsInt64Value() const { - return this->Value(); -} - -uint32_t Smi::AsTruncatedUint32Value() const { - return this->Value() & 0xFFFFFFFF; -} - -int Smi::CompareWith(const Integer& other) const { - if (other.IsSmi()) { - const Smi& other_smi = Smi::Cast(other); - if (this->Value() < other_smi.Value()) { - return -1; - } else if (this->Value() > other_smi.Value()) { - return 1; - } else { - return 0; - } - } - ASSERT(!other.FitsIntoSmi()); - if (other.IsMint()) { - if (this->IsNegative() == other.IsNegative()) { - return this->IsNegative() ? 1 : -1; - } - return this->IsNegative() ? -1 : 1; - } - UNREACHABLE(); - return 0; -} - const char* Smi::ToCString() const { return OS::SCreate(Thread::Current()->zone(), "%" Pd "", Value()); } @@ -23876,41 +23798,11 @@ bool Mint::Equals(const Instance& other) const { if (!other.IsMint() || other.IsNull()) { return false; } - return value() == Mint::Cast(other).value(); -} - -double Mint::AsDoubleValue() const { - return static_cast(this->value()); -} - -int64_t Mint::AsInt64Value() const { - return this->value(); -} - -uint32_t Mint::AsTruncatedUint32Value() const { - return this->value() & 0xFFFFFFFF; -} - -bool Mint::FitsIntoSmi() const { - return Smi::IsValid(AsInt64Value()); -} - -int Mint::CompareWith(const Integer& other) const { - ASSERT(!FitsIntoSmi()); - ASSERT(other.IsMint() || other.IsSmi()); - int64_t a = AsInt64Value(); - int64_t b = other.AsInt64Value(); - if (a < b) { - return -1; - } else if (a > b) { - return 1; - } else { - return 0; - } + return Value() == Mint::Cast(other).Value(); } const char* Mint::ToCString() const { - return OS::SCreate(Thread::Current()->zone(), "%" Pd64 "", value()); + return OS::SCreate(Thread::Current()->zone(), "%" Pd64 "", Value()); } void Double::set_value(double value) const { @@ -25619,18 +25511,12 @@ class DefaultHashTraits { if (obj.IsNull()) { return 0; } - // TODO(koda): Ensure VM classes only produce Smi hash codes, and remove - // non-Smi cases once Dart-side implementation is complete. Thread* thread = Thread::Current(); REUSABLE_INSTANCE_HANDLESCOPE(thread); Instance& hash_code = thread->InstanceHandle(); hash_code ^= Instance::Cast(obj).HashCode(); - if (hash_code.IsSmi()) { - // May waste some bits on 64-bit, to ensure consistency with non-Smi case. - return static_cast(Smi::Cast(hash_code).AsTruncatedUint32Value()); - } else if (hash_code.IsInteger()) { - return static_cast( - Integer::Cast(hash_code).AsTruncatedUint32Value()); + if (hash_code.IsInteger()) { + return static_cast(Integer::Cast(hash_code).Value() & 0xFFFFFFFF); } else { return 0; } @@ -26477,14 +26363,15 @@ uword Closure::ComputeHash() const { Instance::Handle(zone, GetImplicitClosureReceiver()); const Integer& receiverHash = Integer::Handle(zone, receiver.IdentityHashCode(thread)); - result = CombineHashes(result, receiverHash.AsTruncatedUint32Value()); + result = + CombineHashes(result, static_cast(receiverHash.Value())); } } else { // Non-implicit closures of non-generic functions are unique, // so identityHashCode of closure object is good enough. const Integer& identityHash = Integer::Handle(zone, this->IdentityHashCode(thread)); - result = identityHash.AsTruncatedUint32Value(); + result = static_cast(identityHash.Value()); } return FinalizeHash(result, String::kHashBits); } diff --git a/runtime/vm/object.h b/runtime/vm/object.h index 23999eb4b256..9e600cb9c4af 100644 --- a/runtime/vm/object.h +++ b/runtime/vm/object.h @@ -10121,25 +10121,17 @@ class Integer : public Number { virtual ObjectPtr HashCode() const { return ptr(); } - virtual bool IsZero() const; - virtual bool IsNegative() const; + int64_t Value() const { return Value(ptr()); } + static int64_t Value(IntegerPtr obj); - virtual double AsDoubleValue() const; - virtual int64_t AsInt64Value() const; - virtual int64_t AsTruncatedInt64Value() const { return AsInt64Value(); } - virtual uint32_t AsTruncatedUint32Value() const; - - virtual bool FitsIntoSmi() const; + double ToDouble() const { return static_cast(Value()); } // Returns 0, -1 or 1. - virtual int CompareWith(const Integer& other) const; + int CompareWith(const Integer& other) const; // Converts integer to hex string. const char* ToHexCString(Zone* zone) const; - // Return the most compact presentation of an integer. - IntegerPtr AsValidInteger() const; - // Returns null to indicate that a bigint operation is required. IntegerPtr ArithmeticOp(Token::Kind operation, const Integer& other, @@ -10151,15 +10143,6 @@ class Integer : public Number { const Integer& other, Heap::Space space = Heap::kNew) const; - static int64_t GetInt64Value(const IntegerPtr obj) { - if (obj->IsSmi()) { - return RawSmiValue(static_cast(obj)); - } else { - ASSERT(obj->IsMint()); - return static_cast(obj)->untag()->value_; - } - } - private: OBJECT_IMPLEMENTATION(Integer, Number); friend class Class; @@ -10174,16 +10157,6 @@ class Smi : public Integer { intptr_t Value() const { return RawSmiValue(ptr()); } virtual bool Equals(const Instance& other) const; - virtual bool IsZero() const { return Value() == 0; } - virtual bool IsNegative() const { return Value() < 0; } - - virtual double AsDoubleValue() const; - virtual int64_t AsInt64Value() const; - virtual uint32_t AsTruncatedUint32Value() const; - - virtual bool FitsIntoSmi() const { return true; } - - virtual int CompareWith(const Integer& other) const; static intptr_t InstanceSize() { return 0; } @@ -10254,23 +10227,13 @@ class Mint : public Integer { static constexpr int64_t kMinValue = static_cast(DART_2PART_UINT64_C(0x80000000, 00000000)); - int64_t value() const { return untag()->value_; } static intptr_t value_offset() { return OFFSET_OF(UntaggedMint, value_); } - static int64_t Value(MintPtr mint) { return mint->untag()->value_; } - virtual bool IsZero() const { return value() == 0; } - virtual bool IsNegative() const { return value() < 0; } + int64_t Value() const { return untag()->value_; } + static int64_t Value(MintPtr mint) { return mint->untag()->value_; } virtual bool Equals(const Instance& other) const; - virtual double AsDoubleValue() const; - virtual int64_t AsInt64Value() const; - virtual uint32_t AsTruncatedUint32Value() const; - - virtual bool FitsIntoSmi() const; - - virtual int CompareWith(const Integer& other) const; - static intptr_t InstanceSize() { return RoundedAllocationSize(sizeof(UntaggedMint)); } @@ -10292,6 +10255,14 @@ class Mint : public Integer { friend class Number; }; +inline int64_t Integer::Value(IntegerPtr obj) { + if (obj->IsSmi()) { + return Smi::Value(Smi::RawCast(obj)); + } else { + return Mint::Value(Mint::RawCast(obj)); + } +} + // Class Double represents class Double in corelib_impl, which implements // abstract class double in corelib. class Double : public Number { diff --git a/runtime/vm/object_test.cc b/runtime/vm/object_test.cc index ec27ee82ca20..ec19a6b96216 100644 --- a/runtime/vm/object_test.cc +++ b/runtime/vm/object_test.cc @@ -398,9 +398,9 @@ ISOLATE_UNIT_TEST_CASE(Smi) { EXPECT(!Smi::IsValid(0xFFFFFFFFu)); #endif - EXPECT_EQ(5, smi.AsInt64Value()); - EXPECT_EQ(5.0, smi.AsDoubleValue()); - EXPECT_EQ(5, Integer::GetInt64Value(smi.ptr())); + EXPECT_EQ(5, smi.Value()); + EXPECT_EQ(5.0, smi.ToDouble()); + EXPECT_EQ(5, Integer::Value(smi.ptr())); Smi& a = Smi::Handle(Smi::New(5)); Smi& b = Smi::Handle(Smi::New(3)); @@ -522,36 +522,35 @@ ISOLATE_UNIT_TEST_CASE(Mint) { EXPECT(med.IsNull()); int64_t v = DART_2PART_UINT64_C(1, 0); med ^= Integer::New(v); - EXPECT_EQ(v, med.value()); + EXPECT_EQ(v, med.Value()); + EXPECT_EQ(v, Integer::Value(med.ptr())); const String& smi_str = String::Handle(String::New("1")); const String& mint1_str = String::Handle(String::New("2147419168")); const String& mint2_str = String::Handle(String::New("-2147419168")); Integer& i = Integer::Handle(Integer::NewCanonical(smi_str)); EXPECT(i.IsSmi()); + EXPECT_EQ(1, i.Value()); i = Integer::NewCanonical(mint1_str); EXPECT(i.IsMint()); - EXPECT(!i.IsZero()); - EXPECT(!i.IsNegative()); + EXPECT_EQ(2147419168, i.Value()); i = Integer::NewCanonical(mint2_str); EXPECT(i.IsMint()); - EXPECT(!i.IsZero()); - EXPECT(i.IsNegative()); + EXPECT_EQ(-2147419168, i.Value()); } Integer& i = Integer::Handle(Integer::New(DART_2PART_UINT64_C(1, 0))); EXPECT(i.IsMint()); EXPECT(i.ptr()->IsMint()); EXPECT(!i.IsSmi()); EXPECT(!i.ptr()->IsSmi()); - EXPECT(!i.IsZero()); - EXPECT(!i.IsNegative()); + EXPECT(i.Value() != 0); Integer& i1 = Integer::Handle(Integer::New(DART_2PART_UINT64_C(1010, 0))); Mint& i2 = Mint::Handle(); i2 ^= Integer::New(DART_2PART_UINT64_C(1010, 0)); EXPECT(i1.Equals(i2)); EXPECT(!i.Equals(i1)); int64_t test = DART_2PART_UINT64_C(1010, 0); - EXPECT_EQ(test, i2.value()); - EXPECT_EQ(test, Integer::GetInt64Value(i2.ptr())); + EXPECT_EQ(test, i2.Value()); + EXPECT_EQ(test, Integer::Value(i2.ptr())); Mint& a = Mint::Handle(); a ^= Integer::New(DART_2PART_UINT64_C(5, 0)); @@ -576,8 +575,8 @@ ISOLATE_UNIT_TEST_CASE(Mint) { mint1 ^= Integer::NewCanonical(mint_string); Mint& mint2 = Mint::Handle(); mint2 ^= Integer::NewCanonical(mint_string); - EXPECT_EQ(mint1.value(), mint_value); - EXPECT_EQ(mint2.value(), mint_value); + EXPECT_EQ(mint1.Value(), mint_value); + EXPECT_EQ(mint2.Value(), mint_value); EXPECT_EQ(mint1.ptr(), mint2.ptr()); #endif } @@ -5735,7 +5734,7 @@ class ToggleBreakpointTask : public ThreadPool::Task { TransitionNativeToVM transition(t); Integer& breakpoint_id_handle = Integer::Handle(); breakpoint_id_handle ^= Api::UnwrapHandle(result); - breakpoint_id = breakpoint_id_handle.AsInt64Value(); + breakpoint_id = breakpoint_id_handle.Value(); } result = Dart_RemoveBreakpoint(Dart_NewInteger(breakpoint_id)); EXPECT_VALID(result); @@ -6478,11 +6477,11 @@ static bool HashCodeEqualsCanonicalizeHash( if (check_hashcode) { hashcode_dart = Integer::Cast(Object::Handle(Api::UnwrapHandle(hashcode_result))) - .AsInt64Value(); + .Value(); } const int64_t identity_hashcode_dart = Integer::Cast(Object::Handle(Api::UnwrapHandle(identity_hashcode_result))) - .AsInt64Value(); + .Value(); if (hashcode_canonicalize_vm == 0) { hashcode_canonicalize_vm = Instance::Cast(value_dart).CanonicalizeHash(); } diff --git a/runtime/vm/runtime_entry.cc b/runtime/vm/runtime_entry.cc index d9f521e31d18..630c2d92e15f 100644 --- a/runtime/vm/runtime_entry.cc +++ b/runtime/vm/runtime_entry.cc @@ -395,7 +395,7 @@ DEFINE_RUNTIME_ENTRY(AllocateArray, 2) { args.SetAt(2, String::Handle(zone, String::New("is not an integer"))); Exceptions::ThrowByType(Exceptions::kArgumentValue, args); } - const int64_t len = Integer::Cast(length).AsInt64Value(); + const int64_t len = Integer::Cast(length).Value(); if (len < 0) { // Throw: new RangeError.range(length, 0, Array::kMaxElements, "length"); Exceptions::ThrowRangeError("length", Integer::Cast(length), 0, @@ -498,7 +498,7 @@ DEFINE_RUNTIME_ENTRY(AllocateTypedData, 2) { args.SetAt(0, length); Exceptions::ThrowByType(Exceptions::kArgument, args); } - const int64_t len = Integer::Cast(length).AsInt64Value(); + const int64_t len = Integer::Cast(length).Value(); const intptr_t max = TypedData::MaxElements(cid); if (len < 0) { Exceptions::ThrowRangeError("length", Integer::Cast(length), 0, max);