Add Smi::ToInt helper method
This adds a convenience method for the common Smi to int conversion pattern. Bug: Change-Id: I7d7b171c36cfec5f6d10c60f1d9c3e06e3aed0fa Reviewed-on: https://chromium-review.googlesource.com/563205 Commit-Queue: Jakob Gruber <jgruber@chromium.org> Reviewed-by: Benedikt Meurer <bmeurer@chromium.org> Reviewed-by: Michael Lippautz <mlippautz@chromium.org> Reviewed-by: Andreas Rossberg <rossberg@chromium.org> Cr-Commit-Position: refs/heads/master@{#46516}
This commit is contained in:
parent
c42a641846
commit
14e80e5c91
@ -250,7 +250,7 @@ MaybeHandle<JSObject> ConfigureInstance(Isolate* isolate, Handle<JSObject> obj,
|
||||
DCHECK_EQ(kData, details.kind());
|
||||
|
||||
v8::Intrinsic intrinsic =
|
||||
static_cast<v8::Intrinsic>(Smi::cast(properties->get(i++))->value());
|
||||
static_cast<v8::Intrinsic>(Smi::ToInt(properties->get(i++)));
|
||||
auto prop_data = handle(GetIntrinsic(isolate, intrinsic), isolate);
|
||||
|
||||
RETURN_ON_EXCEPTION(isolate, DefineDataProperty(isolate, obj, name,
|
||||
@ -356,7 +356,7 @@ MaybeHandle<JSObject> InstantiateObject(Isolate* isolate,
|
||||
bool is_hidden_prototype,
|
||||
bool is_prototype) {
|
||||
Handle<JSFunction> constructor;
|
||||
int serial_number = Smi::cast(info->serial_number())->value();
|
||||
int serial_number = Smi::ToInt(info->serial_number());
|
||||
if (!new_target.is_null()) {
|
||||
if (IsSimpleInstantiation(isolate, *info, *new_target)) {
|
||||
constructor = Handle<JSFunction>::cast(new_target);
|
||||
@ -446,7 +446,7 @@ MaybeHandle<Object> GetInstancePrototype(Isolate* isolate,
|
||||
MaybeHandle<JSFunction> InstantiateFunction(Isolate* isolate,
|
||||
Handle<FunctionTemplateInfo> data,
|
||||
Handle<Name> name) {
|
||||
int serial_number = Smi::cast(data->serial_number())->value();
|
||||
int serial_number = Smi::ToInt(data->serial_number());
|
||||
if (serial_number) {
|
||||
Handle<JSObject> result;
|
||||
if (ProbeInstantiationsCache(isolate, serial_number,
|
||||
|
36
src/api.cc
36
src/api.cc
@ -2138,7 +2138,7 @@ Location Module::GetModuleRequestLocation(int i) const {
|
||||
i::Handle<i::FixedArray> module_request_positions(
|
||||
self->info()->module_request_positions(), isolate);
|
||||
CHECK_LT(i, module_request_positions->length());
|
||||
int position = i::Smi::cast(module_request_positions->get(i))->value();
|
||||
int position = i::Smi::ToInt(module_request_positions->get(i));
|
||||
i::Handle<i::Script> script(self->script(), isolate);
|
||||
i::Script::PositionInfo info;
|
||||
i::Script::GetPositionInfo(script, position, &info, i::Script::WITH_OFFSET);
|
||||
@ -3634,7 +3634,7 @@ bool Value::IsInt32() const {
|
||||
|
||||
bool Value::IsUint32() const {
|
||||
i::Handle<i::Object> obj = Utils::OpenHandle(this);
|
||||
if (obj->IsSmi()) return i::Smi::cast(*obj)->value() >= 0;
|
||||
if (obj->IsSmi()) return i::Smi::ToInt(*obj) >= 0;
|
||||
if (obj->IsNumber()) {
|
||||
double value = obj->Number();
|
||||
return !i::IsMinusZero(value) &&
|
||||
@ -4112,7 +4112,7 @@ int64_t Value::IntegerValue() const {
|
||||
auto obj = Utils::OpenHandle(this);
|
||||
if (obj->IsNumber()) {
|
||||
if (obj->IsSmi()) {
|
||||
return i::Smi::cast(*obj)->value();
|
||||
return i::Smi::ToInt(*obj);
|
||||
} else {
|
||||
return static_cast<int64_t>(obj->Number());
|
||||
}
|
||||
@ -4130,7 +4130,7 @@ Maybe<int32_t> Value::Int32Value(Local<Context> context) const {
|
||||
i::Handle<i::Object> num;
|
||||
has_pending_exception = !i::Object::ToInt32(isolate, obj).ToHandle(&num);
|
||||
RETURN_ON_FAILED_EXECUTION_PRIMITIVE(int32_t);
|
||||
return Just(num->IsSmi() ? i::Smi::cast(*num)->value()
|
||||
return Just(num->IsSmi() ? i::Smi::ToInt(*num)
|
||||
: static_cast<int32_t>(num->Number()));
|
||||
}
|
||||
|
||||
@ -4151,7 +4151,7 @@ Maybe<uint32_t> Value::Uint32Value(Local<Context> context) const {
|
||||
i::Handle<i::Object> num;
|
||||
has_pending_exception = !i::Object::ToUint32(isolate, obj).ToHandle(&num);
|
||||
RETURN_ON_FAILED_EXECUTION_PRIMITIVE(uint32_t);
|
||||
return Just(num->IsSmi() ? static_cast<uint32_t>(i::Smi::cast(*num)->value())
|
||||
return Just(num->IsSmi() ? static_cast<uint32_t>(i::Smi::ToInt(*num))
|
||||
: static_cast<uint32_t>(num->Number()));
|
||||
}
|
||||
|
||||
@ -4166,7 +4166,7 @@ uint32_t Value::Uint32Value() const {
|
||||
MaybeLocal<Uint32> Value::ToArrayIndex(Local<Context> context) const {
|
||||
auto self = Utils::OpenHandle(this);
|
||||
if (self->IsSmi()) {
|
||||
if (i::Smi::cast(*self)->value() >= 0) return Utils::Uint32ToLocal(self);
|
||||
if (i::Smi::ToInt(*self) >= 0) return Utils::Uint32ToLocal(self);
|
||||
return Local<Uint32>();
|
||||
}
|
||||
PREPARE_FOR_EXECUTION(context, Object, ToArrayIndex, Uint32);
|
||||
@ -4192,7 +4192,7 @@ MaybeLocal<Uint32> Value::ToArrayIndex(Local<Context> context) const {
|
||||
Local<Uint32> Value::ToArrayIndex() const {
|
||||
auto self = Utils::OpenHandle(this);
|
||||
if (self->IsSmi()) {
|
||||
if (i::Smi::cast(*self)->value() >= 0) return Utils::Uint32ToLocal(self);
|
||||
if (i::Smi::ToInt(*self) >= 0) return Utils::Uint32ToLocal(self);
|
||||
return Local<Uint32>();
|
||||
}
|
||||
auto context = ContextFromHeapObject(self);
|
||||
@ -6198,7 +6198,7 @@ bool Boolean::Value() const {
|
||||
int64_t Integer::Value() const {
|
||||
i::Handle<i::Object> obj = Utils::OpenHandle(this);
|
||||
if (obj->IsSmi()) {
|
||||
return i::Smi::cast(*obj)->value();
|
||||
return i::Smi::ToInt(*obj);
|
||||
} else {
|
||||
return static_cast<int64_t>(obj->Number());
|
||||
}
|
||||
@ -6208,7 +6208,7 @@ int64_t Integer::Value() const {
|
||||
int32_t Int32::Value() const {
|
||||
i::Handle<i::Object> obj = Utils::OpenHandle(this);
|
||||
if (obj->IsSmi()) {
|
||||
return i::Smi::cast(*obj)->value();
|
||||
return i::Smi::ToInt(*obj);
|
||||
} else {
|
||||
return static_cast<int32_t>(obj->Number());
|
||||
}
|
||||
@ -6218,7 +6218,7 @@ int32_t Int32::Value() const {
|
||||
uint32_t Uint32::Value() const {
|
||||
i::Handle<i::Object> obj = Utils::OpenHandle(this);
|
||||
if (obj->IsSmi()) {
|
||||
return i::Smi::cast(*obj)->value();
|
||||
return i::Smi::ToInt(*obj);
|
||||
} else {
|
||||
return static_cast<uint32_t>(obj->Number());
|
||||
}
|
||||
@ -7202,8 +7202,7 @@ void v8::Date::DateTimeConfigurationChangeNotification(Isolate* isolate) {
|
||||
DCHECK_EQ(1, date_cache_version->length());
|
||||
CHECK(date_cache_version->get(0)->IsSmi());
|
||||
date_cache_version->set(
|
||||
0,
|
||||
i::Smi::FromInt(i::Smi::cast(date_cache_version->get(0))->value() + 1));
|
||||
0, i::Smi::FromInt(i::Smi::ToInt(date_cache_version->get(0)) + 1));
|
||||
}
|
||||
|
||||
|
||||
@ -7269,7 +7268,7 @@ uint32_t v8::Array::Length() const {
|
||||
i::Handle<i::JSArray> obj = Utils::OpenHandle(this);
|
||||
i::Object* length = obj->length();
|
||||
if (length->IsSmi()) {
|
||||
return i::Smi::cast(length)->value();
|
||||
return i::Smi::ToInt(length);
|
||||
} else {
|
||||
return static_cast<uint32_t>(length->Number());
|
||||
}
|
||||
@ -9309,7 +9308,7 @@ void debug::SetContextId(Local<Context> context, int id) {
|
||||
|
||||
int debug::GetContextId(Local<Context> context) {
|
||||
i::Object* value = Utils::OpenHandle(*context)->debug_context_id();
|
||||
return (value->IsSmi()) ? i::Smi::cast(value)->value() : 0;
|
||||
return (value->IsSmi()) ? i::Smi::ToInt(value) : 0;
|
||||
}
|
||||
|
||||
Local<Context> debug::GetDebugContext(Isolate* isolate) {
|
||||
@ -9489,7 +9488,7 @@ Maybe<int> debug::Script::ContextId() const {
|
||||
i::HandleScope handle_scope(isolate);
|
||||
i::Handle<i::Script> script = Utils::OpenHandle(this);
|
||||
i::Object* value = script->context_data();
|
||||
if (value->IsSmi()) return Just(i::Smi::cast(value)->value());
|
||||
if (value->IsSmi()) return Just(i::Smi::ToInt(value));
|
||||
return Nothing<int>();
|
||||
}
|
||||
|
||||
@ -9513,7 +9512,7 @@ bool debug::Script::IsModule() const {
|
||||
|
||||
namespace {
|
||||
int GetSmiValue(i::Handle<i::FixedArray> array, int index) {
|
||||
return i::Smi::cast(array->get(index))->value();
|
||||
return i::Smi::ToInt(array->get(index));
|
||||
}
|
||||
|
||||
bool CompareBreakLocation(const i::BreakLocation& loc1,
|
||||
@ -9788,15 +9787,14 @@ v8::MaybeLocal<v8::Array> debug::EntriesPreview(Isolate* v8_isolate,
|
||||
*is_key_value = kind == MapAsArrayKind::kEntries;
|
||||
if (!iterator->HasMore()) return v8::Array::New(v8_isolate);
|
||||
return Utils::ToLocal(MapAsArray(isolate, iterator->table(),
|
||||
i::Smi::cast(iterator->index())->value(),
|
||||
kind));
|
||||
i::Smi::ToInt(iterator->index()), kind));
|
||||
}
|
||||
if (object->IsJSSetIterator()) {
|
||||
i::Handle<i::JSSetIterator> it = i::Handle<i::JSSetIterator>::cast(object);
|
||||
*is_key_value = false;
|
||||
if (!it->HasMore()) return v8::Array::New(v8_isolate);
|
||||
return Utils::ToLocal(
|
||||
SetAsArray(isolate, it->table(), i::Smi::cast(it->index())->value()));
|
||||
SetAsArray(isolate, it->table(), i::Smi::ToInt(it->index())));
|
||||
}
|
||||
return v8::MaybeLocal<v8::Array>();
|
||||
}
|
||||
|
@ -50,9 +50,7 @@ class Arguments BASE_EMBEDDED {
|
||||
return Handle<S>(reinterpret_cast<S**>(value));
|
||||
}
|
||||
|
||||
int smi_at(int index) {
|
||||
return Smi::cast((*this)[index])->value();
|
||||
}
|
||||
int smi_at(int index) { return Smi::ToInt((*this)[index]); }
|
||||
|
||||
double number_at(int index) {
|
||||
return (*this)[index]->Number();
|
||||
|
@ -277,7 +277,7 @@ MaybeHandle<Object> AsmJs::InstantiateAsmWasm(Isolate* isolate,
|
||||
ReportInstantiationFailure(script, position, "Requires standard library");
|
||||
return MaybeHandle<Object>();
|
||||
}
|
||||
int member_id = Smi::cast(stdlib_uses->get(i))->value();
|
||||
int member_id = Smi::ToInt(stdlib_uses->get(i));
|
||||
wasm::AsmJsParser::StandardMember member =
|
||||
static_cast<wasm::AsmJsParser::StandardMember>(member_id);
|
||||
if (!IsStdlibMemberValid(isolate, stdlib, member,
|
||||
|
@ -41,7 +41,7 @@ Handle<FixedArray> CompileTimeValue::GetValue(Isolate* isolate,
|
||||
}
|
||||
|
||||
int CompileTimeValue::GetLiteralTypeFlags(Handle<FixedArray> value) {
|
||||
return Smi::cast(value->get(kLiteralTypeSlot))->value();
|
||||
return Smi::ToInt(value->get(kLiteralTypeSlot));
|
||||
}
|
||||
|
||||
Handle<HeapObject> CompileTimeValue::GetElements(Handle<FixedArray> value) {
|
||||
|
@ -550,8 +550,7 @@ void AstPrinter::PrintLiteral(MaybeHandle<Object> maybe_value, bool quote) {
|
||||
if (object->IsJSFunction()) {
|
||||
Print("JS-Function");
|
||||
} else if (object->IsJSArray()) {
|
||||
Print("JS-array[%u]",
|
||||
Smi::cast(JSArray::cast(object)->length())->value());
|
||||
Print("JS-array[%u]", Smi::ToInt(JSArray::cast(object)->length()));
|
||||
} else if (object->IsJSObject()) {
|
||||
Print("JS-Object");
|
||||
} else {
|
||||
|
@ -4328,7 +4328,7 @@ bool Genesis::InstallNatives(GlobalContextType context_type) {
|
||||
// Verification of important array prototype properties.
|
||||
Object* length = proto->length();
|
||||
CHECK(length->IsSmi());
|
||||
CHECK(Smi::cast(length)->value() == 0);
|
||||
CHECK(Smi::ToInt(length) == 0);
|
||||
CHECK(proto->HasSmiOrObjectElements());
|
||||
// This is necessary to enable fast checks for absence of elements
|
||||
// on Array.prototype and below.
|
||||
@ -4892,7 +4892,7 @@ void Genesis::TransferNamedProperties(Handle<JSObject> from,
|
||||
Handle<GlobalDictionary>(from->global_dictionary());
|
||||
Handle<FixedArray> indices = GlobalDictionary::IterationIndices(properties);
|
||||
for (int i = 0; i < indices->length(); i++) {
|
||||
int index = Smi::cast(indices->get(i))->value();
|
||||
int index = Smi::ToInt(indices->get(i));
|
||||
// If the property is already there we skip it.
|
||||
Handle<PropertyCell> cell(properties->CellAt(index));
|
||||
Handle<Name> key(cell->name(), isolate());
|
||||
@ -4913,7 +4913,7 @@ void Genesis::TransferNamedProperties(Handle<JSObject> from,
|
||||
Handle<FixedArray> key_indices =
|
||||
NameDictionary::IterationIndices(properties);
|
||||
for (int i = 0; i < key_indices->length(); i++) {
|
||||
int key_index = Smi::cast(key_indices->get(i))->value();
|
||||
int key_index = Smi::ToInt(key_indices->get(i));
|
||||
Object* raw_key = properties->KeyAt(key_index);
|
||||
DCHECK(properties->IsKey(isolate(), raw_key));
|
||||
DCHECK(raw_key->IsName());
|
||||
@ -5018,7 +5018,7 @@ Genesis::Genesis(
|
||||
// proxy of the correct size.
|
||||
Object* size = isolate->heap()->serialized_global_proxy_sizes()->get(
|
||||
static_cast<int>(context_snapshot_index) - 1);
|
||||
instance_size = Smi::cast(size)->value();
|
||||
instance_size = Smi::ToInt(size);
|
||||
} else {
|
||||
instance_size = JSGlobalProxy::SizeWithEmbedderFields(
|
||||
global_proxy_template.IsEmpty()
|
||||
|
@ -24,7 +24,7 @@ inline bool ClampedToInteger(Isolate* isolate, Object* object, int* out) {
|
||||
// This is an extended version of ECMA-262 7.1.11 handling signed values
|
||||
// Try to convert object to a number and clamp values to [kMinInt, kMaxInt]
|
||||
if (object->IsSmi()) {
|
||||
*out = Smi::cast(object)->value();
|
||||
*out = Smi::ToInt(object);
|
||||
return true;
|
||||
} else if (object->IsHeapNumber()) {
|
||||
double value = HeapNumber::cast(object)->value();
|
||||
@ -60,7 +60,7 @@ inline bool GetSloppyArgumentsLength(Isolate* isolate, Handle<JSObject> object,
|
||||
DCHECK(object->HasFastElements() || object->HasFastArgumentsElements());
|
||||
Object* len_obj = object->InObjectPropertyAt(JSArgumentsObject::kLengthIndex);
|
||||
if (!len_obj->IsSmi()) return false;
|
||||
*out = Max(0, Smi::cast(len_obj)->value());
|
||||
*out = Max(0, Smi::ToInt(len_obj));
|
||||
|
||||
FixedArray* parameters = FixedArray::cast(object->elements());
|
||||
if (object->HasSloppyArgumentsElements()) {
|
||||
@ -173,11 +173,11 @@ BUILTIN(ArrayPush) {
|
||||
// Fast Elements Path
|
||||
int to_add = args.length() - 1;
|
||||
Handle<JSArray> array = Handle<JSArray>::cast(receiver);
|
||||
int len = Smi::cast(array->length())->value();
|
||||
int len = Smi::ToInt(array->length());
|
||||
if (to_add == 0) return Smi::FromInt(len);
|
||||
|
||||
// Currently fixed arrays cannot grow too big, so we should never hit this.
|
||||
DCHECK_LE(to_add, Smi::kMaxValue - Smi::cast(array->length())->value());
|
||||
DCHECK_LE(to_add, Smi::kMaxValue - Smi::ToInt(array->length()));
|
||||
|
||||
if (JSArray::HasReadOnlyLength(array)) {
|
||||
return CallJsIntrinsic(isolate, isolate->array_push(), args);
|
||||
@ -197,7 +197,7 @@ BUILTIN(ArrayPop) {
|
||||
|
||||
Handle<JSArray> array = Handle<JSArray>::cast(receiver);
|
||||
|
||||
uint32_t len = static_cast<uint32_t>(Smi::cast(array->length())->value());
|
||||
uint32_t len = static_cast<uint32_t>(Smi::ToInt(array->length()));
|
||||
if (len == 0) return isolate->heap()->undefined_value();
|
||||
|
||||
if (JSArray::HasReadOnlyLength(array)) {
|
||||
@ -228,7 +228,7 @@ BUILTIN(ArrayShift) {
|
||||
}
|
||||
Handle<JSArray> array = Handle<JSArray>::cast(receiver);
|
||||
|
||||
int len = Smi::cast(array->length())->value();
|
||||
int len = Smi::ToInt(array->length());
|
||||
if (len == 0) return heap->undefined_value();
|
||||
|
||||
if (JSArray::HasReadOnlyLength(array)) {
|
||||
@ -250,7 +250,7 @@ BUILTIN(ArrayUnshift) {
|
||||
if (to_add == 0) return array->length();
|
||||
|
||||
// Currently fixed arrays cannot grow too big, so we should never hit this.
|
||||
DCHECK_LE(to_add, Smi::kMaxValue - Smi::cast(array->length())->value());
|
||||
DCHECK_LE(to_add, Smi::kMaxValue - Smi::ToInt(array->length()));
|
||||
|
||||
if (JSArray::HasReadOnlyLength(array)) {
|
||||
return CallJsIntrinsic(isolate, isolate->array_unshift(), args);
|
||||
@ -279,7 +279,7 @@ BUILTIN(ArraySlice) {
|
||||
AllowHeapAllocation allow_allocation;
|
||||
return CallJsIntrinsic(isolate, isolate->array_slice(), args);
|
||||
}
|
||||
len = Smi::cast(array->length())->value();
|
||||
len = Smi::ToInt(array->length());
|
||||
} else if (receiver->IsJSObject() &&
|
||||
GetSloppyArgumentsLength(isolate, Handle<JSObject>::cast(receiver),
|
||||
&len)) {
|
||||
@ -352,7 +352,7 @@ BUILTIN(ArraySplice) {
|
||||
return CallJsIntrinsic(isolate, isolate->array_splice(), args);
|
||||
}
|
||||
}
|
||||
int len = Smi::cast(array->length())->value();
|
||||
int len = Smi::ToInt(array->length());
|
||||
// clip relative start to [0, len]
|
||||
int actual_start = (relative_start < 0) ? Max(len + relative_start, 0)
|
||||
: Min(relative_start, len);
|
||||
@ -1019,7 +1019,7 @@ Object* Slow_ArrayConcat(BuiltinArguments* args, Handle<Object> species,
|
||||
for (int i = 0; i < argument_count; i++) {
|
||||
Handle<Object> obj((*args)[i], isolate);
|
||||
if (obj->IsSmi()) {
|
||||
double_storage->set(j, Smi::cast(*obj)->value());
|
||||
double_storage->set(j, Smi::ToInt(*obj));
|
||||
j++;
|
||||
} else if (obj->IsNumber()) {
|
||||
double_storage->set(j, obj->Number());
|
||||
@ -1061,7 +1061,7 @@ Object* Slow_ArrayConcat(BuiltinArguments* args, Handle<Object> species,
|
||||
failure = true;
|
||||
break;
|
||||
}
|
||||
int32_t int_value = Smi::cast(element)->value();
|
||||
int32_t int_value = Smi::ToInt(element);
|
||||
double_storage->set(j, int_value);
|
||||
j++;
|
||||
}
|
||||
@ -1180,7 +1180,7 @@ MaybeHandle<JSArray> Fast_ArrayConcat(Isolate* isolate,
|
||||
}
|
||||
// The Array length is guaranted to be <= kHalfOfMaxInt thus we won't
|
||||
// overflow.
|
||||
result_len += Smi::cast(array->length())->value();
|
||||
result_len += Smi::ToInt(array->length());
|
||||
DCHECK(result_len >= 0);
|
||||
// Throw an Error if we overflow the FixedArray limits
|
||||
if (FixedDoubleArray::kMaxLength < result_len ||
|
||||
|
@ -41,7 +41,7 @@ Handle<FrameArray> GetFrameArray(Isolate* isolate, Handle<JSObject> object) {
|
||||
int GetFrameIndex(Isolate* isolate, Handle<JSObject> object) {
|
||||
Handle<Object> frame_index_obj = JSObject::GetDataProperty(
|
||||
object, isolate->factory()->call_site_frame_index_symbol());
|
||||
return Smi::cast(*frame_index_obj)->value();
|
||||
return Smi::ToInt(*frame_index_obj);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
@ -96,8 +96,8 @@ Object* MakeGenericError(Isolate* isolate, BuiltinArguments args,
|
||||
|
||||
RETURN_RESULT_OR_FAILURE(
|
||||
isolate, ErrorUtils::MakeGenericError(isolate, constructor,
|
||||
Smi::cast(*template_index)->value(),
|
||||
arg0, arg1, arg2, SKIP_NONE));
|
||||
Smi::ToInt(*template_index), arg0,
|
||||
arg1, arg2, SKIP_NONE));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
@ -519,7 +519,7 @@ MUST_USE_RESULT static Object* ConvertCase(
|
||||
if (answer->IsException(isolate) || answer->IsString()) return answer;
|
||||
|
||||
DCHECK(answer->IsSmi());
|
||||
length = Smi::cast(answer)->value();
|
||||
length = Smi::ToInt(answer);
|
||||
if (s->IsOneByteRepresentation() && length > 0) {
|
||||
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
|
||||
isolate, result, isolate->factory()->NewRawOneByteString(length));
|
||||
|
@ -27,7 +27,7 @@ namespace {
|
||||
int64_t CapRelativeIndex(Handle<Object> num, int64_t minimum, int64_t maximum) {
|
||||
int64_t relative;
|
||||
if (V8_LIKELY(num->IsSmi())) {
|
||||
relative = Smi::cast(*num)->value();
|
||||
relative = Smi::ToInt(*num);
|
||||
} else {
|
||||
DCHECK(num->IsHeapNumber());
|
||||
double fp = HeapNumber::cast(*num)->value();
|
||||
|
@ -8186,7 +8186,7 @@ Node* CodeStubAssembler::StrictEqual(Node* lhs, Node* rhs,
|
||||
// if (!lhs->IsSmi()) {
|
||||
// if (lhs->IsHeapNumber()) {
|
||||
// if (rhs->IsSmi()) {
|
||||
// return Smi::cast(rhs)->value() == HeapNumber::cast(lhs)->value();
|
||||
// return Smi::ToInt(rhs) == HeapNumber::cast(lhs)->value();
|
||||
// } else if (rhs->IsHeapNumber()) {
|
||||
// return HeapNumber::cast(rhs)->value() ==
|
||||
// HeapNumber::cast(lhs)->value();
|
||||
@ -8213,7 +8213,7 @@ Node* CodeStubAssembler::StrictEqual(Node* lhs, Node* rhs,
|
||||
// return false;
|
||||
// } else {
|
||||
// if (rhs->IsHeapNumber()) {
|
||||
// return Smi::cast(lhs)->value() == HeapNumber::cast(rhs)->value();
|
||||
// return Smi::ToInt(lhs) == HeapNumber::cast(rhs)->value();
|
||||
// } else {
|
||||
// return false;
|
||||
// }
|
||||
|
@ -23,11 +23,7 @@ ScriptContextTable* ScriptContextTable::cast(Object* context) {
|
||||
return reinterpret_cast<ScriptContextTable*>(context);
|
||||
}
|
||||
|
||||
|
||||
int ScriptContextTable::used() const {
|
||||
return Smi::cast(get(kUsedSlot))->value();
|
||||
}
|
||||
|
||||
int ScriptContextTable::used() const { return Smi::ToInt(get(kUsedSlot)); }
|
||||
|
||||
void ScriptContextTable::set_used(int used) {
|
||||
set(kUsedSlot, Smi::FromInt(used));
|
||||
|
@ -153,18 +153,18 @@ bool DoubleToUint32IfEqualToSelf(double value, uint32_t* uint32_value) {
|
||||
}
|
||||
|
||||
int32_t NumberToInt32(Object* number) {
|
||||
if (number->IsSmi()) return Smi::cast(number)->value();
|
||||
if (number->IsSmi()) return Smi::ToInt(number);
|
||||
return DoubleToInt32(number->Number());
|
||||
}
|
||||
|
||||
uint32_t NumberToUint32(Object* number) {
|
||||
if (number->IsSmi()) return Smi::cast(number)->value();
|
||||
if (number->IsSmi()) return Smi::ToInt(number);
|
||||
return DoubleToUint32(number->Number());
|
||||
}
|
||||
|
||||
uint32_t PositiveNumberToUint32(Object* number) {
|
||||
if (number->IsSmi()) {
|
||||
int value = Smi::cast(number)->value();
|
||||
int value = Smi::ToInt(number);
|
||||
if (value <= 0) return 0;
|
||||
return value;
|
||||
}
|
||||
@ -178,7 +178,7 @@ uint32_t PositiveNumberToUint32(Object* number) {
|
||||
}
|
||||
|
||||
int64_t NumberToInt64(Object* number) {
|
||||
if (number->IsSmi()) return Smi::cast(number)->value();
|
||||
if (number->IsSmi()) return Smi::ToInt(number);
|
||||
return static_cast<int64_t>(number->Number());
|
||||
}
|
||||
|
||||
@ -186,7 +186,7 @@ bool TryNumberToSize(Object* number, size_t* result) {
|
||||
// Do not create handles in this function! Don't use SealHandleScope because
|
||||
// the function can be used concurrently.
|
||||
if (number->IsSmi()) {
|
||||
int value = Smi::cast(number)->value();
|
||||
int value = Smi::ToInt(number);
|
||||
DCHECK(static_cast<unsigned>(Smi::kMaxValue) <=
|
||||
std::numeric_limits<size_t>::max());
|
||||
if (value >= 0) {
|
||||
|
@ -2243,9 +2243,8 @@ void Debug::PrintBreakLocation() {
|
||||
int column = Script::GetColumnNumber(script, source_position) -
|
||||
(line == 0 ? script->column_offset() : 0);
|
||||
Handle<FixedArray> line_ends(FixedArray::cast(script->line_ends()));
|
||||
int line_start =
|
||||
line == 0 ? 0 : Smi::cast(line_ends->get(line - 1))->value() + 1;
|
||||
int line_end = Smi::cast(line_ends->get(line))->value();
|
||||
int line_start = line == 0 ? 0 : Smi::ToInt(line_ends->get(line - 1)) + 1;
|
||||
int line_end = Smi::ToInt(line_ends->get(line));
|
||||
DisallowHeapAllocation no_gc;
|
||||
String::FlatContent content = source->GetFlatContent();
|
||||
if (content.IsOneByte()) {
|
||||
|
@ -437,7 +437,7 @@ class LineEndsWrapper {
|
||||
int string_len_;
|
||||
|
||||
int GetPosAfterNewLine(int index) {
|
||||
return Smi::cast(ends_array_->get(index))->value() + 1;
|
||||
return Smi::ToInt(ends_array_->get(index)) + 1;
|
||||
}
|
||||
};
|
||||
|
||||
@ -603,7 +603,7 @@ static Handle<SharedFunctionInfo> UnwrapSharedFunctionInfoFromJSValue(
|
||||
static int GetArrayLength(Handle<JSArray> array) {
|
||||
Object* length = array->length();
|
||||
CHECK(length->IsSmi());
|
||||
return Smi::cast(length)->value();
|
||||
return Smi::ToInt(length);
|
||||
}
|
||||
|
||||
void FunctionInfoWrapper::SetInitialProperties(Handle<String> name,
|
||||
@ -1243,8 +1243,7 @@ class MultipleFunctionTarget {
|
||||
Handle<Object> old_element =
|
||||
JSReceiver::GetElement(isolate, result_, i).ToHandleChecked();
|
||||
if (!old_element->IsSmi() ||
|
||||
Smi::cast(*old_element)->value() ==
|
||||
LiveEdit::FUNCTION_AVAILABLE_FOR_PATCH) {
|
||||
Smi::ToInt(*old_element) == LiveEdit::FUNCTION_AVAILABLE_FOR_PATCH) {
|
||||
SetElementSloppy(result_, i,
|
||||
Handle<Smi>(Smi::FromInt(status), isolate));
|
||||
}
|
||||
|
@ -3766,7 +3766,7 @@ Handle<Object> TranslatedState::MaterializeCapturedObjectAt(
|
||||
CHECK(iterated_string->IsString());
|
||||
object->set_string(String::cast(*iterated_string));
|
||||
CHECK(next_index->IsSmi());
|
||||
object->set_index(Smi::cast(*next_index)->value());
|
||||
object->set_index(Smi::ToInt(*next_index));
|
||||
return object;
|
||||
}
|
||||
case JS_ASYNC_FROM_SYNC_ITERATOR_TYPE: {
|
||||
@ -3830,8 +3830,8 @@ Handle<Object> TranslatedState::MaterializeCapturedObjectAt(
|
||||
object->set_context(Context::cast(*context));
|
||||
object->set_receiver(*receiver);
|
||||
object->set_input_or_debug_pos(*input_or_debug_pos);
|
||||
object->set_resume_mode(Smi::cast(*resume_mode)->value());
|
||||
object->set_continuation(Smi::cast(*continuation_offset)->value());
|
||||
object->set_resume_mode(Smi::ToInt(*resume_mode));
|
||||
object->set_continuation(Smi::ToInt(*continuation_offset));
|
||||
object->set_register_file(FixedArray::cast(*register_file));
|
||||
int in_object_properties = map->GetInObjectProperties();
|
||||
for (int i = 0; i < in_object_properties; ++i) {
|
||||
@ -3853,7 +3853,7 @@ Handle<Object> TranslatedState::MaterializeCapturedObjectAt(
|
||||
Handle<Object> first = materializer.FieldAt(value_index);
|
||||
Handle<Object> second = materializer.FieldAt(value_index);
|
||||
object->set_map(*map);
|
||||
object->set_length(Smi::cast(*string_length)->value());
|
||||
object->set_length(Smi::ToInt(*string_length));
|
||||
object->set_first(String::cast(*first));
|
||||
object->set_second(String::cast(*second));
|
||||
CHECK(hash->IsNumber()); // The {Name::kEmptyHashField} value.
|
||||
|
@ -313,7 +313,7 @@ static void CopySmiToDoubleElements(FixedArrayBase* from_base,
|
||||
if (hole_or_smi == the_hole) {
|
||||
to->set_the_hole(to_start);
|
||||
} else {
|
||||
to->set(to_start, Smi::cast(hole_or_smi)->value());
|
||||
to->set(to_start, Smi::ToInt(hole_or_smi));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -353,7 +353,7 @@ static void CopyPackedSmiToDoubleElements(FixedArrayBase* from_base,
|
||||
from_start < from_end; from_start++, to_start++) {
|
||||
Object* smi = from->get(from_start);
|
||||
DCHECK(!smi->IsTheHole(from->GetIsolate()));
|
||||
to->set(to_start, Smi::cast(smi)->value());
|
||||
to->set(to_start, Smi::ToInt(smi));
|
||||
}
|
||||
}
|
||||
|
||||
@ -555,7 +555,7 @@ class ElementsAccessorBase : public ElementsAccessor {
|
||||
if (holder->IsJSArray()) {
|
||||
Object* length_obj = JSArray::cast(holder)->length();
|
||||
if (length_obj->IsSmi()) {
|
||||
length = Smi::cast(length_obj)->value();
|
||||
length = Smi::ToInt(length_obj);
|
||||
}
|
||||
} else {
|
||||
length = fixed_array_base->length();
|
||||
@ -585,7 +585,7 @@ class ElementsAccessorBase : public ElementsAccessor {
|
||||
static void TryTransitionResultArrayToPacked(Handle<JSArray> array) {
|
||||
if (!IsHoleyOrDictionaryElementsKind(kind())) return;
|
||||
Handle<FixedArrayBase> backing_store(array->elements());
|
||||
int length = Smi::cast(array->length())->value();
|
||||
int length = Smi::ToInt(array->length());
|
||||
if (!Subclass::IsPackedImpl(*array, *backing_store, 0, length)) {
|
||||
return;
|
||||
}
|
||||
@ -806,7 +806,7 @@ class ElementsAccessorBase : public ElementsAccessor {
|
||||
if (receiver->IsJSArray()) {
|
||||
DCHECK(JSArray::cast(receiver)->length()->IsSmi());
|
||||
return static_cast<uint32_t>(
|
||||
Smi::cast(JSArray::cast(receiver)->length())->value());
|
||||
Smi::ToInt(JSArray::cast(receiver)->length()));
|
||||
}
|
||||
return Subclass::GetCapacityImpl(receiver, elements);
|
||||
}
|
||||
@ -845,7 +845,7 @@ class ElementsAccessorBase : public ElementsAccessor {
|
||||
|
||||
int packed_size = kPackedSizeNotKnown;
|
||||
if (IsFastPackedElementsKind(from_kind) && object->IsJSArray()) {
|
||||
packed_size = Smi::cast(JSArray::cast(*object)->length())->value();
|
||||
packed_size = Smi::ToInt(JSArray::cast(*object)->length());
|
||||
}
|
||||
|
||||
Subclass::CopyElementsImpl(*old_elements, src_index, *new_elements,
|
||||
@ -981,8 +981,7 @@ class ElementsAccessorBase : public ElementsAccessor {
|
||||
bool is_packed = IsFastPackedElementsKind(from_kind) &&
|
||||
from_holder->IsJSArray();
|
||||
if (is_packed) {
|
||||
packed_size =
|
||||
Smi::cast(JSArray::cast(from_holder)->length())->value();
|
||||
packed_size = Smi::ToInt(JSArray::cast(from_holder)->length());
|
||||
if (copy_size >= 0 && packed_size > copy_size) {
|
||||
packed_size = copy_size;
|
||||
}
|
||||
@ -1812,7 +1811,7 @@ class DictionaryElementsAccessor
|
||||
if (k->Number() > SeededNumberDictionary::kRequiresSlowElementsLimit) {
|
||||
requires_slow_elements = true;
|
||||
} else {
|
||||
max_key = Max(max_key, Smi::cast(k)->value());
|
||||
max_key = Max(max_key, Smi::ToInt(k));
|
||||
}
|
||||
}
|
||||
if (requires_slow_elements) {
|
||||
@ -2117,7 +2116,7 @@ class FastElementsAccessor : public ElementsAccessorBase<Subclass, KindTraits> {
|
||||
Arguments* args, uint32_t add_count) {
|
||||
Isolate* isolate = receiver->GetIsolate();
|
||||
Heap* heap = isolate->heap();
|
||||
uint32_t length = Smi::cast(receiver->length())->value();
|
||||
uint32_t length = Smi::ToInt(receiver->length());
|
||||
uint32_t new_length = length - delete_count + add_count;
|
||||
|
||||
ElementsKind kind = KindTraits::Kind;
|
||||
@ -2435,8 +2434,7 @@ class FastElementsAccessor : public ElementsAccessorBase<Subclass, KindTraits> {
|
||||
JSObject::EnsureWritableFastElements(receiver);
|
||||
}
|
||||
Handle<FixedArrayBase> backing_store(receiver->elements(), isolate);
|
||||
uint32_t length =
|
||||
static_cast<uint32_t>(Smi::cast(receiver->length())->value());
|
||||
uint32_t length = static_cast<uint32_t>(Smi::ToInt(receiver->length()));
|
||||
DCHECK(length > 0);
|
||||
int new_length = length - 1;
|
||||
int remove_index = remove_position == AT_START ? 0 : new_length;
|
||||
@ -2458,7 +2456,7 @@ class FastElementsAccessor : public ElementsAccessorBase<Subclass, KindTraits> {
|
||||
Handle<FixedArrayBase> backing_store,
|
||||
Arguments* args, uint32_t add_size,
|
||||
Where add_position) {
|
||||
uint32_t length = Smi::cast(receiver->length())->value();
|
||||
uint32_t length = Smi::ToInt(receiver->length());
|
||||
DCHECK(0 < add_size);
|
||||
uint32_t elms_len = backing_store->length();
|
||||
// Check we do not overflow the new_length.
|
||||
@ -2910,7 +2908,7 @@ class TypedElementsAccessor
|
||||
|
||||
ctype value;
|
||||
if (obj_value->IsSmi()) {
|
||||
value = BackingStore::from(Smi::cast(*obj_value)->value());
|
||||
value = BackingStore::from(Smi::ToInt(*obj_value));
|
||||
} else {
|
||||
DCHECK(obj_value->IsHeapNumber());
|
||||
value = BackingStore::from(HeapNumber::cast(*obj_value)->value());
|
||||
@ -3252,7 +3250,7 @@ class TypedElementsAccessor
|
||||
for (uint32_t i = 0; i < length; i++) {
|
||||
Object* elem = source_store->get(i);
|
||||
DCHECK(elem->IsSmi());
|
||||
int int_value = Smi::cast(elem)->value();
|
||||
int int_value = Smi::ToInt(elem);
|
||||
dest->set(i, dest->from(int_value));
|
||||
}
|
||||
return true;
|
||||
@ -3264,7 +3262,7 @@ class TypedElementsAccessor
|
||||
} else {
|
||||
Object* elem = source_store->get(i);
|
||||
DCHECK(elem->IsSmi());
|
||||
int int_value = Smi::cast(elem)->value();
|
||||
int int_value = Smi::ToInt(elem);
|
||||
dest->set(i, dest->from(int_value));
|
||||
}
|
||||
}
|
||||
@ -3382,7 +3380,7 @@ class SloppyArgumentsElementsAccessor
|
||||
Object* probe = elements->get_mapped_entry(entry);
|
||||
DCHECK(!probe->IsTheHole(isolate));
|
||||
Context* context = elements->context();
|
||||
int context_entry = Smi::cast(probe)->value();
|
||||
int context_entry = Smi::ToInt(probe);
|
||||
DCHECK(!context->get(context_entry)->IsTheHole(isolate));
|
||||
return handle(context->get(context_entry), isolate);
|
||||
} else {
|
||||
@ -3418,7 +3416,7 @@ class SloppyArgumentsElementsAccessor
|
||||
Object* probe = elements->get_mapped_entry(entry);
|
||||
DCHECK(!probe->IsTheHole(store->GetIsolate()));
|
||||
Context* context = elements->context();
|
||||
int context_entry = Smi::cast(probe)->value();
|
||||
int context_entry = Smi::ToInt(probe);
|
||||
DCHECK(!context->get(context_entry)->IsTheHole(store->GetIsolate()));
|
||||
context->set(context_entry, value);
|
||||
} else {
|
||||
@ -3770,7 +3768,7 @@ class SlowSloppyArgumentsElementsAccessor
|
||||
Object* probe = elements->get_mapped_entry(entry);
|
||||
DCHECK(!probe->IsTheHole(isolate));
|
||||
Context* context = elements->context();
|
||||
int context_entry = Smi::cast(probe)->value();
|
||||
int context_entry = Smi::ToInt(probe);
|
||||
DCHECK(!context->get(context_entry)->IsTheHole(isolate));
|
||||
context->set(context_entry, *value);
|
||||
|
||||
|
@ -47,7 +47,7 @@ bool FeedbackMetadata::is_empty() const {
|
||||
int FeedbackMetadata::slot_count() const {
|
||||
if (length() == 0) return 0;
|
||||
DCHECK(length() > kReservedIndexCount);
|
||||
return Smi::cast(get(kSlotsCountIndex))->value();
|
||||
return Smi::ToInt(get(kSlotsCountIndex));
|
||||
}
|
||||
|
||||
// static
|
||||
@ -106,7 +106,7 @@ SharedFunctionInfo* FeedbackVector::shared_function_info() const {
|
||||
}
|
||||
|
||||
int FeedbackVector::invocation_count() const {
|
||||
return Smi::cast(get(kInvocationCountIndex))->value();
|
||||
return Smi::ToInt(get(kInvocationCountIndex));
|
||||
}
|
||||
|
||||
void FeedbackVector::clear_invocation_count() {
|
||||
@ -140,7 +140,7 @@ bool FeedbackVector::has_optimization_marker() const {
|
||||
}
|
||||
|
||||
int FeedbackVector::profiler_ticks() const {
|
||||
return Smi::cast(get(kProfilerTicksIndex))->value();
|
||||
return Smi::ToInt(get(kProfilerTicksIndex));
|
||||
}
|
||||
|
||||
void FeedbackVector::set_profiler_ticks(int ticks) {
|
||||
@ -254,7 +254,7 @@ void FeedbackVector::ComputeCounts(int* with_type_info, int* generic,
|
||||
// TODO(mvstanton): Remove code_is_interpreted when full code is retired
|
||||
// from service.
|
||||
if (code_is_interpreted) {
|
||||
int const feedback = Smi::cast(obj)->value();
|
||||
int const feedback = Smi::ToInt(obj);
|
||||
BinaryOperationHint hint = BinaryOperationHintFromFeedback(feedback);
|
||||
if (hint == BinaryOperationHint::kAny) {
|
||||
gen++;
|
||||
@ -271,7 +271,7 @@ void FeedbackVector::ComputeCounts(int* with_type_info, int* generic,
|
||||
// TODO(mvstanton): Remove code_is_interpreted when full code is retired
|
||||
// from service.
|
||||
if (code_is_interpreted) {
|
||||
int const feedback = Smi::cast(obj)->value();
|
||||
int const feedback = Smi::ToInt(obj);
|
||||
CompareOperationHint hint =
|
||||
CompareOperationHintFromFeedback(feedback);
|
||||
if (hint == CompareOperationHint::kAny) {
|
||||
|
@ -37,13 +37,13 @@ std::ostream& operator<<(std::ostream& os, FeedbackSlotKind kind) {
|
||||
|
||||
FeedbackSlotKind FeedbackMetadata::GetKind(FeedbackSlot slot) const {
|
||||
int index = VectorICComputer::index(kReservedIndexCount, slot.ToInt());
|
||||
int data = Smi::cast(get(index))->value();
|
||||
int data = Smi::ToInt(get(index));
|
||||
return VectorICComputer::decode(data, slot.ToInt());
|
||||
}
|
||||
|
||||
void FeedbackMetadata::SetKind(FeedbackSlot slot, FeedbackSlotKind kind) {
|
||||
int index = VectorICComputer::index(kReservedIndexCount, slot.ToInt());
|
||||
int data = Smi::cast(get(index))->value();
|
||||
int data = Smi::ToInt(get(index));
|
||||
int new_data = VectorICComputer::encode(data, slot.ToInt(), kind);
|
||||
set(index, Smi::FromInt(new_data));
|
||||
}
|
||||
@ -631,7 +631,7 @@ InlineCacheState CallICNexus::StateFromFeedback() const {
|
||||
int CallICNexus::ExtractCallCount() {
|
||||
Object* call_count = GetFeedbackExtra();
|
||||
CHECK(call_count->IsSmi());
|
||||
int value = Smi::cast(call_count)->value();
|
||||
int value = Smi::ToInt(call_count);
|
||||
return value;
|
||||
}
|
||||
|
||||
@ -874,7 +874,7 @@ KeyedAccessStoreMode KeyedStoreICNexus::GetKeyedAccessStoreMode() const {
|
||||
IcCheckType KeyedLoadICNexus::GetKeyType() const {
|
||||
Object* feedback = GetFeedback();
|
||||
if (feedback == *FeedbackVector::MegamorphicSentinel(GetIsolate())) {
|
||||
return static_cast<IcCheckType>(Smi::cast(GetFeedbackExtra())->value());
|
||||
return static_cast<IcCheckType>(Smi::ToInt(GetFeedbackExtra()));
|
||||
}
|
||||
return IsPropertyNameFeedback(feedback) ? PROPERTY : ELEMENT;
|
||||
}
|
||||
@ -882,7 +882,7 @@ IcCheckType KeyedLoadICNexus::GetKeyType() const {
|
||||
IcCheckType KeyedStoreICNexus::GetKeyType() const {
|
||||
Object* feedback = GetFeedback();
|
||||
if (feedback == *FeedbackVector::MegamorphicSentinel(GetIsolate())) {
|
||||
return static_cast<IcCheckType>(Smi::cast(GetFeedbackExtra())->value());
|
||||
return static_cast<IcCheckType>(Smi::ToInt(GetFeedbackExtra()));
|
||||
}
|
||||
return IsPropertyNameFeedback(feedback) ? PROPERTY : ELEMENT;
|
||||
}
|
||||
@ -910,12 +910,12 @@ InlineCacheState CompareICNexus::StateFromFeedback() const {
|
||||
}
|
||||
|
||||
BinaryOperationHint BinaryOpICNexus::GetBinaryOperationFeedback() const {
|
||||
int feedback = Smi::cast(GetFeedback())->value();
|
||||
int feedback = Smi::ToInt(GetFeedback());
|
||||
return BinaryOperationHintFromFeedback(feedback);
|
||||
}
|
||||
|
||||
CompareOperationHint CompareICNexus::GetCompareOperationFeedback() const {
|
||||
int feedback = Smi::cast(GetFeedback())->value();
|
||||
int feedback = Smi::ToInt(GetFeedback());
|
||||
return CompareOperationHintFromFeedback(feedback);
|
||||
}
|
||||
|
||||
@ -999,7 +999,7 @@ Handle<JSObject> ConvertToJSObject(Isolate* isolate,
|
||||
Handle<ArrayList> position_specific_types(
|
||||
ArrayList::cast(feedback->get(value_index)));
|
||||
|
||||
int position = Smi::cast(key)->value();
|
||||
int position = Smi::ToInt(key);
|
||||
JSObject::AddDataElement(type_profile, position,
|
||||
isolate->factory()->NewJSArrayWithElements(
|
||||
position_specific_types->Elements()),
|
||||
|
@ -111,7 +111,7 @@ inline Object* BuiltinExitFrame::receiver_slot_object() const {
|
||||
// fp[2 + argc - 1]: receiver.
|
||||
Object* argc_slot = argc_slot_object();
|
||||
DCHECK(argc_slot->IsSmi());
|
||||
int argc = Smi::cast(argc_slot)->value();
|
||||
int argc = Smi::ToInt(argc_slot);
|
||||
|
||||
const int receiverOffset =
|
||||
BuiltinExitFrameConstants::kNewTargetOffset + (argc - 1) * kPointerSize;
|
||||
|
@ -694,7 +694,7 @@ int BuiltinExitFrame::ComputeParametersCount() const {
|
||||
DCHECK(argc_slot->IsSmi());
|
||||
// Argc also counts the receiver, target, new target, and argc itself as args,
|
||||
// therefore the real argument count is argc - 4.
|
||||
int argc = Smi::cast(argc_slot)->value() - 4;
|
||||
int argc = Smi::ToInt(argc_slot) - 4;
|
||||
DCHECK(argc >= 0);
|
||||
return argc;
|
||||
}
|
||||
@ -1159,7 +1159,7 @@ int JavaScriptFrame::ComputeParametersCount() const {
|
||||
int JavaScriptBuiltinContinuationFrame::ComputeParametersCount() const {
|
||||
Object* argc_object =
|
||||
Memory::Object_at(fp() + BuiltinContinuationFrameConstants::kArgCOffset);
|
||||
return Smi::cast(argc_object)->value();
|
||||
return Smi::ToInt(argc_object);
|
||||
}
|
||||
|
||||
namespace {
|
||||
@ -1275,7 +1275,7 @@ uint32_t FrameSummary::WasmCompiledFrameSummary::function_index() const {
|
||||
FixedArray* deopt_data = code()->deoptimization_data();
|
||||
DCHECK_EQ(2, deopt_data->length());
|
||||
DCHECK(deopt_data->get(1)->IsSmi());
|
||||
int val = Smi::cast(deopt_data->get(1))->value();
|
||||
int val = Smi::ToInt(deopt_data->get(1));
|
||||
DCHECK_LE(0, val);
|
||||
return static_cast<uint32_t>(val);
|
||||
}
|
||||
@ -1598,7 +1598,7 @@ int InterpretedFrame::GetBytecodeOffset() const {
|
||||
DCHECK_EQ(
|
||||
InterpreterFrameConstants::kBytecodeOffsetFromFp,
|
||||
InterpreterFrameConstants::kExpressionsOffset - index * kPointerSize);
|
||||
int raw_offset = Smi::cast(GetExpression(index))->value();
|
||||
int raw_offset = Smi::ToInt(GetExpression(index));
|
||||
return raw_offset - BytecodeArray::kHeaderSize + kHeapObjectTag;
|
||||
}
|
||||
|
||||
@ -1609,7 +1609,7 @@ int InterpretedFrame::GetBytecodeOffset(Address fp) {
|
||||
InterpreterFrameConstants::kBytecodeOffsetFromFp,
|
||||
InterpreterFrameConstants::kExpressionsOffset - index * kPointerSize);
|
||||
Address expression_offset = fp + offset - index * kPointerSize;
|
||||
int raw_offset = Smi::cast(Memory::Object_at(expression_offset))->value();
|
||||
int raw_offset = Smi::ToInt(Memory::Object_at(expression_offset));
|
||||
return raw_offset - BytecodeArray::kHeaderSize + kHeapObjectTag;
|
||||
}
|
||||
|
||||
@ -1667,12 +1667,12 @@ void InterpretedFrame::Summarize(List<FrameSummary>* functions,
|
||||
}
|
||||
|
||||
int ArgumentsAdaptorFrame::GetNumberOfIncomingArguments() const {
|
||||
return Smi::cast(GetExpression(0))->value();
|
||||
return Smi::ToInt(GetExpression(0));
|
||||
}
|
||||
|
||||
int ArgumentsAdaptorFrame::GetLength(Address fp) {
|
||||
const int offset = ArgumentsAdaptorFrameConstants::kLengthOffset;
|
||||
return Smi::cast(Memory::Object_at(fp + offset))->value();
|
||||
return Smi::ToInt(Memory::Object_at(fp + offset));
|
||||
}
|
||||
|
||||
Code* ArgumentsAdaptorFrame::unchecked_code() const {
|
||||
@ -1681,7 +1681,7 @@ Code* ArgumentsAdaptorFrame::unchecked_code() const {
|
||||
}
|
||||
|
||||
int BuiltinFrame::GetNumberOfIncomingArguments() const {
|
||||
return Smi::cast(GetExpression(0))->value();
|
||||
return Smi::ToInt(GetExpression(0));
|
||||
}
|
||||
|
||||
void BuiltinFrame::PrintFrameKind(StringStream* accumulator) const {
|
||||
|
@ -535,7 +535,7 @@ void FullCodeGenerator::TestContext::Plug(Handle<Object> lit) const {
|
||||
if (true_label_ != fall_through_) __ b(true_label_);
|
||||
}
|
||||
} else if (lit->IsSmi()) {
|
||||
if (Smi::cast(*lit)->value() == 0) {
|
||||
if (Smi::ToInt(*lit) == 0) {
|
||||
if (false_label_ != fall_through_) __ b(false_label_);
|
||||
} else {
|
||||
if (true_label_ != fall_through_) __ b(true_label_);
|
||||
|
@ -525,7 +525,7 @@ void FullCodeGenerator::TestContext::Plug(Handle<Object> lit) const {
|
||||
if (true_label_ != fall_through_) __ B(true_label_);
|
||||
}
|
||||
} else if (lit->IsSmi()) {
|
||||
if (Smi::cast(*lit)->value() == 0) {
|
||||
if (Smi::ToInt(*lit) == 0) {
|
||||
if (false_label_ != fall_through_) __ B(false_label_);
|
||||
} else {
|
||||
if (true_label_ != fall_through_) __ B(true_label_);
|
||||
|
@ -472,7 +472,7 @@ void FullCodeGenerator::TestContext::Plug(Handle<Object> lit) const {
|
||||
if (true_label_ != fall_through_) __ jmp(true_label_);
|
||||
}
|
||||
} else if (lit->IsSmi()) {
|
||||
if (Smi::cast(*lit)->value() == 0) {
|
||||
if (Smi::ToInt(*lit) == 0) {
|
||||
if (false_label_ != fall_through_) __ jmp(false_label_);
|
||||
} else {
|
||||
if (true_label_ != fall_through_) __ jmp(true_label_);
|
||||
|
@ -512,7 +512,7 @@ void FullCodeGenerator::TestContext::Plug(Handle<Object> lit) const {
|
||||
if (true_label_ != fall_through_) __ Branch(true_label_);
|
||||
}
|
||||
} else if (lit->IsSmi()) {
|
||||
if (Smi::cast(*lit)->value() == 0) {
|
||||
if (Smi::ToInt(*lit) == 0) {
|
||||
if (false_label_ != fall_through_) __ Branch(false_label_);
|
||||
} else {
|
||||
if (true_label_ != fall_through_) __ Branch(true_label_);
|
||||
|
@ -512,7 +512,7 @@ void FullCodeGenerator::TestContext::Plug(Handle<Object> lit) const {
|
||||
if (true_label_ != fall_through_) __ Branch(true_label_);
|
||||
}
|
||||
} else if (lit->IsSmi()) {
|
||||
if (Smi::cast(*lit)->value() == 0) {
|
||||
if (Smi::ToInt(*lit) == 0) {
|
||||
if (false_label_ != fall_through_) __ Branch(false_label_);
|
||||
} else {
|
||||
if (true_label_ != fall_through_) __ Branch(true_label_);
|
||||
|
@ -504,7 +504,7 @@ void FullCodeGenerator::TestContext::Plug(Handle<Object> lit) const {
|
||||
if (true_label_ != fall_through_) __ b(true_label_);
|
||||
}
|
||||
} else if (lit->IsSmi()) {
|
||||
if (Smi::cast(*lit)->value() == 0) {
|
||||
if (Smi::ToInt(*lit) == 0) {
|
||||
if (false_label_ != fall_through_) __ b(false_label_);
|
||||
} else {
|
||||
if (true_label_ != fall_through_) __ b(true_label_);
|
||||
|
@ -495,7 +495,7 @@ void FullCodeGenerator::TestContext::Plug(Handle<Object> lit) const {
|
||||
if (true_label_ != fall_through_) __ b(true_label_);
|
||||
}
|
||||
} else if (lit->IsSmi()) {
|
||||
if (Smi::cast(*lit)->value() == 0) {
|
||||
if (Smi::ToInt(*lit) == 0) {
|
||||
if (false_label_ != fall_through_) __ b(false_label_);
|
||||
} else {
|
||||
if (true_label_ != fall_through_) __ b(true_label_);
|
||||
|
@ -485,7 +485,7 @@ void FullCodeGenerator::TestContext::Plug(Handle<Object> lit) const {
|
||||
if (true_label_ != fall_through_) __ jmp(true_label_);
|
||||
}
|
||||
} else if (lit->IsSmi()) {
|
||||
if (Smi::cast(*lit)->value() == 0) {
|
||||
if (Smi::ToInt(*lit) == 0) {
|
||||
if (false_label_ != fall_through_) __ jmp(false_label_);
|
||||
} else {
|
||||
if (true_label_ != fall_through_) __ jmp(true_label_);
|
||||
|
@ -467,7 +467,7 @@ void FullCodeGenerator::TestContext::Plug(Handle<Object> lit) const {
|
||||
if (true_label_ != fall_through_) __ jmp(true_label_);
|
||||
}
|
||||
} else if (lit->IsSmi()) {
|
||||
if (Smi::cast(*lit)->value() == 0) {
|
||||
if (Smi::ToInt(*lit) == 0) {
|
||||
if (false_label_ != fall_through_) __ jmp(false_label_);
|
||||
} else {
|
||||
if (true_label_ != fall_through_) __ jmp(true_label_);
|
||||
|
@ -32,7 +32,7 @@ namespace internal {
|
||||
|
||||
AllocationSpace AllocationResult::RetrySpace() {
|
||||
DCHECK(IsRetry());
|
||||
return static_cast<AllocationSpace>(Smi::cast(object_)->value());
|
||||
return static_cast<AllocationSpace>(Smi::ToInt(object_));
|
||||
}
|
||||
|
||||
HeapObject* AllocationResult::ToObjectChecked() {
|
||||
|
@ -815,7 +815,7 @@ void Heap::PreprocessStackTraces() {
|
||||
// a stack trace that has already been preprocessed. Guard against this.
|
||||
if (!maybe_code->IsAbstractCode()) break;
|
||||
AbstractCode* abstract_code = AbstractCode::cast(maybe_code);
|
||||
int offset = Smi::cast(elements->get(j + 3))->value();
|
||||
int offset = Smi::ToInt(elements->get(j + 3));
|
||||
int pos = abstract_code->SourcePosition(offset);
|
||||
elements->set(j + 2, Smi::FromInt(pos));
|
||||
}
|
||||
|
@ -727,7 +727,7 @@ void IncrementalMarking::RetainMaps() {
|
||||
DCHECK(retained_maps->Get(i)->IsWeakCell());
|
||||
WeakCell* cell = WeakCell::cast(retained_maps->Get(i));
|
||||
if (cell->cleared()) continue;
|
||||
int age = Smi::cast(retained_maps->Get(i + 1))->value();
|
||||
int age = Smi::ToInt(retained_maps->Get(i + 1));
|
||||
int new_age;
|
||||
Map* map = Map::cast(cell->value());
|
||||
if (i >= number_of_disposed_maps && !map_retaining_is_disabled &&
|
||||
|
@ -2290,9 +2290,9 @@ MaybeHandle<Object> KeyedStoreIC::Store(Handle<Object> object,
|
||||
old_receiver_map = handle(receiver->map(), isolate());
|
||||
is_arguments = receiver->IsJSArgumentsObject();
|
||||
if (!is_arguments) {
|
||||
key_is_valid_index = key->IsSmi() && Smi::cast(*key)->value() >= 0;
|
||||
key_is_valid_index = key->IsSmi() && Smi::ToInt(*key) >= 0;
|
||||
if (key_is_valid_index) {
|
||||
uint32_t index = static_cast<uint32_t>(Smi::cast(*key)->value());
|
||||
uint32_t index = static_cast<uint32_t>(Smi::ToInt(*key));
|
||||
store_mode = GetStoreMode(receiver, index, value);
|
||||
}
|
||||
}
|
||||
|
@ -260,7 +260,7 @@ JumpTableTargetOffsets::iterator::iterator(
|
||||
JumpTableTargetOffset JumpTableTargetOffsets::iterator::operator*() {
|
||||
DCHECK_LT(table_offset_, table_end_);
|
||||
DCHECK(current_->IsSmi());
|
||||
return {index_, accessor_->GetAbsoluteOffset(Smi::cast(*current_)->value())};
|
||||
return {index_, accessor_->GetAbsoluteOffset(Smi::ToInt(*current_))};
|
||||
}
|
||||
|
||||
JumpTableTargetOffsets::iterator& JumpTableTargetOffsets::iterator::
|
||||
|
@ -130,7 +130,7 @@ bool Isolate::IsArraySpeciesLookupChainIntact() {
|
||||
|
||||
PropertyCell* species_cell = heap()->species_protector();
|
||||
return species_cell->value()->IsSmi() &&
|
||||
Smi::cast(species_cell->value())->value() == kProtectorValid;
|
||||
Smi::ToInt(species_cell->value()) == kProtectorValid;
|
||||
}
|
||||
|
||||
bool Isolate::IsStringLengthOverflowIntact() {
|
||||
|
@ -1213,7 +1213,7 @@ Object* Isolate::UnwindAndFindHandler() {
|
||||
// Gather information from the handler.
|
||||
Code* code = frame->LookupCode();
|
||||
return FoundHandler(
|
||||
nullptr, code, Smi::cast(code->handler_table()->get(0))->value(),
|
||||
nullptr, code, Smi::ToInt(code->handler_table()->get(0)),
|
||||
handler->address() + StackHandlerConstants::kSize, 0);
|
||||
}
|
||||
|
||||
@ -3050,7 +3050,7 @@ bool Isolate::IsFastArrayConstructorPrototypeChainIntact() {
|
||||
PropertyCell* no_elements_cell = heap()->array_protector();
|
||||
bool cell_reports_intact =
|
||||
no_elements_cell->value()->IsSmi() &&
|
||||
Smi::cast(no_elements_cell->value())->value() == kProtectorValid;
|
||||
Smi::ToInt(no_elements_cell->value()) == kProtectorValid;
|
||||
|
||||
#ifdef DEBUG
|
||||
Map* root_array_map =
|
||||
@ -3108,8 +3108,7 @@ bool Isolate::IsFastArrayConstructorPrototypeChainIntact() {
|
||||
bool Isolate::IsIsConcatSpreadableLookupChainIntact() {
|
||||
Cell* is_concat_spreadable_cell = heap()->is_concat_spreadable_protector();
|
||||
bool is_is_concat_spreadable_set =
|
||||
Smi::cast(is_concat_spreadable_cell->value())->value() ==
|
||||
kProtectorInvalid;
|
||||
Smi::ToInt(is_concat_spreadable_cell->value()) == kProtectorInvalid;
|
||||
#ifdef DEBUG
|
||||
Map* root_array_map = get_initial_js_array_map(GetInitialFastElementsKind());
|
||||
if (root_array_map == NULL) {
|
||||
@ -3674,7 +3673,7 @@ void Isolate::CheckDetachedContextsAfterGC() {
|
||||
if (length == 0) return;
|
||||
int new_length = 0;
|
||||
for (int i = 0; i < length; i += 2) {
|
||||
int mark_sweeps = Smi::cast(detached_contexts->get(i))->value();
|
||||
int mark_sweeps = Smi::ToInt(detached_contexts->get(i));
|
||||
DCHECK(detached_contexts->get(i + 1)->IsWeakCell());
|
||||
WeakCell* cell = WeakCell::cast(detached_contexts->get(i + 1));
|
||||
if (!cell->cleared()) {
|
||||
@ -3688,7 +3687,7 @@ void Isolate::CheckDetachedContextsAfterGC() {
|
||||
PrintF("%d detached contexts are collected out of %d\n",
|
||||
length - new_length, length);
|
||||
for (int i = 0; i < new_length; i += 2) {
|
||||
int mark_sweeps = Smi::cast(detached_contexts->get(i))->value();
|
||||
int mark_sweeps = Smi::ToInt(detached_contexts->get(i));
|
||||
DCHECK(detached_contexts->get(i + 1)->IsWeakCell());
|
||||
WeakCell* cell = WeakCell::cast(detached_contexts->get(i + 1));
|
||||
if (mark_sweeps > 3) {
|
||||
|
@ -216,7 +216,7 @@ MaybeHandle<Object> JsonStringifier::ApplyReplacerFunction(
|
||||
|
||||
Handle<JSReceiver> JsonStringifier::CurrentHolder(
|
||||
Handle<Object> value, Handle<Object> initial_holder) {
|
||||
int length = Smi::cast(stack_->length())->value();
|
||||
int length = Smi::ToInt(stack_->length());
|
||||
if (length == 0) {
|
||||
Handle<JSObject> holder =
|
||||
factory()->NewJSObject(isolate_->object_function());
|
||||
@ -237,7 +237,7 @@ JsonStringifier::Result JsonStringifier::StackPush(Handle<Object> object) {
|
||||
return EXCEPTION;
|
||||
}
|
||||
|
||||
int length = Smi::cast(stack_->length())->value();
|
||||
int length = Smi::ToInt(stack_->length());
|
||||
{
|
||||
DisallowHeapAllocation no_allocation;
|
||||
FixedArray* elements = FixedArray::cast(stack_->elements());
|
||||
@ -257,7 +257,7 @@ JsonStringifier::Result JsonStringifier::StackPush(Handle<Object> object) {
|
||||
}
|
||||
|
||||
void JsonStringifier::StackPop() {
|
||||
int length = Smi::cast(stack_->length())->value();
|
||||
int length = Smi::ToInt(stack_->length());
|
||||
stack_->set_length(Smi::FromInt(length - 1));
|
||||
}
|
||||
|
||||
|
@ -83,7 +83,7 @@ LayoutDescriptor* LayoutDescriptor::SetTagged(int field_index, bool tagged) {
|
||||
set_layout_word(layout_word_index, value);
|
||||
return this;
|
||||
} else {
|
||||
uint32_t value = static_cast<uint32_t>(Smi::cast(this)->value());
|
||||
uint32_t value = static_cast<uint32_t>(Smi::ToInt(this));
|
||||
if (tagged) {
|
||||
value &= ~layout_mask;
|
||||
} else {
|
||||
@ -110,7 +110,7 @@ bool LayoutDescriptor::IsTagged(int field_index) {
|
||||
uint32_t value = get_layout_word(layout_word_index);
|
||||
return (value & layout_mask) == 0;
|
||||
} else {
|
||||
uint32_t value = static_cast<uint32_t>(Smi::cast(this)->value());
|
||||
uint32_t value = static_cast<uint32_t>(Smi::ToInt(this));
|
||||
return (value & layout_mask) == 0;
|
||||
}
|
||||
}
|
||||
|
@ -113,8 +113,7 @@ Handle<LayoutDescriptor> LayoutDescriptor::EnsureCapacity(
|
||||
return new_layout_descriptor;
|
||||
} else {
|
||||
// Fast layout.
|
||||
uint32_t value =
|
||||
static_cast<uint32_t>(Smi::cast(*layout_descriptor)->value());
|
||||
uint32_t value = static_cast<uint32_t>(Smi::ToInt(*layout_descriptor));
|
||||
new_layout_descriptor->set_layout_word(0, value);
|
||||
return new_layout_descriptor;
|
||||
}
|
||||
@ -139,9 +138,8 @@ bool LayoutDescriptor::IsTagged(int field_index, int max_sequence_length,
|
||||
}
|
||||
uint32_t layout_mask = static_cast<uint32_t>(1) << layout_bit_index;
|
||||
|
||||
uint32_t value = IsSlowLayout()
|
||||
? get_layout_word(layout_word_index)
|
||||
: static_cast<uint32_t>(Smi::cast(this)->value());
|
||||
uint32_t value = IsSlowLayout() ? get_layout_word(layout_word_index)
|
||||
: static_cast<uint32_t>(Smi::ToInt(this));
|
||||
|
||||
bool is_tagged = (value & layout_mask) == 0;
|
||||
if (!is_tagged) value = ~value; // Count set bits instead of cleared bits.
|
||||
|
@ -1349,7 +1349,7 @@ void Logger::ICEvent(const char* type, bool keyed, const Address pc, int line,
|
||||
msg.AppendAddress(reinterpret_cast<Address>(map));
|
||||
msg.Append(",");
|
||||
if (key->IsSmi()) {
|
||||
msg.Append("%d", Smi::cast(key)->value());
|
||||
msg.Append("%d", Smi::ToInt(key));
|
||||
} else if (key->IsNumber()) {
|
||||
msg.Append("%lf", key->Number());
|
||||
} else if (key->IsString()) {
|
||||
|
@ -148,7 +148,7 @@ void MessageHandler::ReportMessageNoExceptions(
|
||||
FixedArray* listener = FixedArray::cast(global_listeners->get(i));
|
||||
Foreign* callback_obj = Foreign::cast(listener->get(0));
|
||||
int32_t message_levels =
|
||||
static_cast<int32_t>(Smi::cast(listener->get(2))->value());
|
||||
static_cast<int32_t>(Smi::ToInt(listener->get(2)));
|
||||
if (!(message_levels & error_level)) {
|
||||
continue;
|
||||
}
|
||||
|
@ -547,7 +547,7 @@ void SloppyArgumentsElements::SloppyArgumentsElementsVerify(
|
||||
CHECK(accessor->HasElement(holder, i, arg_elements));
|
||||
continue;
|
||||
}
|
||||
int mappedIndex = Smi::cast(mapped)->value();
|
||||
int mappedIndex = Smi::ToInt(mapped);
|
||||
nofMappedParameters++;
|
||||
CHECK_LE(maxMappedIndex, mappedIndex);
|
||||
maxMappedIndex = mappedIndex;
|
||||
@ -608,32 +608,32 @@ void JSDate::JSDateVerify() {
|
||||
cache_stamp()->IsNaN());
|
||||
|
||||
if (month()->IsSmi()) {
|
||||
int month = Smi::cast(this->month())->value();
|
||||
int month = Smi::ToInt(this->month());
|
||||
CHECK(0 <= month && month <= 11);
|
||||
}
|
||||
if (day()->IsSmi()) {
|
||||
int day = Smi::cast(this->day())->value();
|
||||
int day = Smi::ToInt(this->day());
|
||||
CHECK(1 <= day && day <= 31);
|
||||
}
|
||||
if (hour()->IsSmi()) {
|
||||
int hour = Smi::cast(this->hour())->value();
|
||||
int hour = Smi::ToInt(this->hour());
|
||||
CHECK(0 <= hour && hour <= 23);
|
||||
}
|
||||
if (min()->IsSmi()) {
|
||||
int min = Smi::cast(this->min())->value();
|
||||
int min = Smi::ToInt(this->min());
|
||||
CHECK(0 <= min && min <= 59);
|
||||
}
|
||||
if (sec()->IsSmi()) {
|
||||
int sec = Smi::cast(this->sec())->value();
|
||||
int sec = Smi::ToInt(this->sec());
|
||||
CHECK(0 <= sec && sec <= 59);
|
||||
}
|
||||
if (weekday()->IsSmi()) {
|
||||
int weekday = Smi::cast(this->weekday())->value();
|
||||
int weekday = Smi::ToInt(this->weekday());
|
||||
CHECK(0 <= weekday && weekday <= 6);
|
||||
}
|
||||
if (cache_stamp()->IsSmi()) {
|
||||
CHECK(Smi::cast(cache_stamp())->value() <=
|
||||
Smi::cast(isolate->date_cache()->stamp())->value());
|
||||
CHECK(Smi::ToInt(cache_stamp()) <=
|
||||
Smi::ToInt(isolate->date_cache()->stamp()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -784,7 +784,7 @@ void Oddball::OddballVerify() {
|
||||
number == heap->hole_nan_value());
|
||||
} else {
|
||||
CHECK(number->IsSmi());
|
||||
int value = Smi::cast(number)->value();
|
||||
int value = Smi::ToInt(number);
|
||||
// Hidden oddballs have negative smis.
|
||||
const int kLeastHiddenOddballNumber = -7;
|
||||
CHECK_LE(value, 1);
|
||||
@ -907,7 +907,7 @@ void JSArray::JSArrayVerify() {
|
||||
if (!length()->IsNumber()) return;
|
||||
// Verify that the length and the elements backing store are in sync.
|
||||
if (length()->IsSmi() && HasFastElements()) {
|
||||
int size = Smi::cast(length())->value();
|
||||
int size = Smi::ToInt(length());
|
||||
// Holey / Packed backing stores might have slack or might have not been
|
||||
// properly initialized yet.
|
||||
CHECK(size <= elements()->length() ||
|
||||
@ -1103,12 +1103,12 @@ void JSRegExp::JSRegExpVerify() {
|
||||
// Smi : Not compiled yet (-1).
|
||||
// Code/ByteArray: Compiled code.
|
||||
CHECK(
|
||||
(one_byte_data->IsSmi() && Smi::cast(one_byte_data)->value() ==
|
||||
JSRegExp::kUninitializedValue) ||
|
||||
(one_byte_data->IsSmi() &&
|
||||
Smi::ToInt(one_byte_data) == JSRegExp::kUninitializedValue) ||
|
||||
(is_native ? one_byte_data->IsCode() : one_byte_data->IsByteArray()));
|
||||
Object* uc16_data = arr->get(JSRegExp::kIrregexpUC16CodeIndex);
|
||||
CHECK((uc16_data->IsSmi() &&
|
||||
Smi::cast(uc16_data)->value() == JSRegExp::kUninitializedValue) ||
|
||||
Smi::ToInt(uc16_data) == JSRegExp::kUninitializedValue) ||
|
||||
(is_native ? uc16_data->IsCode() : uc16_data->IsByteArray()));
|
||||
|
||||
CHECK(arr->get(JSRegExp::kIrregexpCaptureCountIndex)->IsSmi());
|
||||
|
@ -735,7 +735,7 @@ bool Object::FitsRepresentation(Representation representation) {
|
||||
|
||||
bool Object::ToUint32(uint32_t* value) const {
|
||||
if (IsSmi()) {
|
||||
int num = Smi::cast(this)->value();
|
||||
int num = Smi::ToInt(this);
|
||||
if (num < 0) return false;
|
||||
*value = static_cast<uint32_t>(num);
|
||||
return true;
|
||||
@ -809,7 +809,7 @@ MaybeHandle<String> Object::ToString(Isolate* isolate, Handle<Object> input) {
|
||||
// static
|
||||
MaybeHandle<Object> Object::ToLength(Isolate* isolate, Handle<Object> input) {
|
||||
if (input->IsSmi()) {
|
||||
int value = std::max(Smi::cast(*input)->value(), 0);
|
||||
int value = std::max(Smi::ToInt(*input), 0);
|
||||
return handle(Smi::FromInt(value), isolate);
|
||||
}
|
||||
return ConvertToLength(isolate, input);
|
||||
@ -818,7 +818,7 @@ MaybeHandle<Object> Object::ToLength(Isolate* isolate, Handle<Object> input) {
|
||||
// static
|
||||
MaybeHandle<Object> Object::ToIndex(Isolate* isolate, Handle<Object> input,
|
||||
MessageTemplate::Template error_index) {
|
||||
if (input->IsSmi() && Smi::cast(*input)->value() >= 0) return input;
|
||||
if (input->IsSmi() && Smi::ToInt(*input) >= 0) return input;
|
||||
return ConvertToIndex(isolate, input, error_index);
|
||||
}
|
||||
|
||||
@ -917,6 +917,7 @@ Object** HeapObject::RawField(HeapObject* obj, int byte_offset) {
|
||||
return reinterpret_cast<Object**>(FIELD_ADDR(obj, byte_offset));
|
||||
}
|
||||
|
||||
int Smi::ToInt(const Object* object) { return Smi::cast(object)->value(); }
|
||||
|
||||
MapWord MapWord::FromMap(const Map* map) {
|
||||
return MapWord(reinterpret_cast<uintptr_t>(map));
|
||||
@ -1389,11 +1390,7 @@ ACCESSORS(Oddball, to_string, String, kToStringOffset)
|
||||
ACCESSORS(Oddball, to_number, Object, kToNumberOffset)
|
||||
ACCESSORS(Oddball, type_of, String, kTypeOfOffset)
|
||||
|
||||
|
||||
byte Oddball::kind() const {
|
||||
return Smi::cast(READ_FIELD(this, kKindOffset))->value();
|
||||
}
|
||||
|
||||
byte Oddball::kind() const { return Smi::ToInt(READ_FIELD(this, kKindOffset)); }
|
||||
|
||||
void Oddball::set_kind(byte value) {
|
||||
WRITE_FIELD(this, kKindOffset, Smi::FromInt(value));
|
||||
@ -1603,7 +1600,7 @@ void JSObject::WriteToField(int descriptor, PropertyDetails details,
|
||||
// and stores to the stack silently clear the signalling bit).
|
||||
uint64_t bits;
|
||||
if (value->IsSmi()) {
|
||||
bits = bit_cast<uint64_t>(static_cast<double>(Smi::cast(value)->value()));
|
||||
bits = bit_cast<uint64_t>(static_cast<double>(Smi::ToInt(value)));
|
||||
} else {
|
||||
DCHECK(value->IsHeapNumber());
|
||||
bits = HeapNumber::cast(value)->value_as_bits();
|
||||
@ -1848,7 +1845,7 @@ int WeakFixedArray::Length() const {
|
||||
|
||||
|
||||
int WeakFixedArray::last_used_index() const {
|
||||
return Smi::cast(FixedArray::cast(this)->get(kLastUsedIndexIndex))->value();
|
||||
return Smi::ToInt(FixedArray::cast(this)->get(kLastUsedIndexIndex));
|
||||
}
|
||||
|
||||
|
||||
@ -1873,7 +1870,7 @@ T* WeakFixedArray::Iterator::Next() {
|
||||
|
||||
int ArrayList::Length() const {
|
||||
if (FixedArray::cast(this)->length() == 0) return 0;
|
||||
return Smi::cast(FixedArray::cast(this)->get(kLengthIndex))->value();
|
||||
return Smi::ToInt(FixedArray::cast(this)->get(kLengthIndex));
|
||||
}
|
||||
|
||||
|
||||
@ -1904,7 +1901,7 @@ void ArrayList::Clear(int index, Object* undefined) {
|
||||
int RegExpMatchInfo::NumberOfCaptureRegisters() {
|
||||
DCHECK_GE(length(), kLastMatchOverhead);
|
||||
Object* obj = get(kNumberOfCapturesIndex);
|
||||
return Smi::cast(obj)->value();
|
||||
return Smi::ToInt(obj);
|
||||
}
|
||||
|
||||
void RegExpMatchInfo::SetNumberOfCaptureRegisters(int value) {
|
||||
@ -1936,7 +1933,7 @@ void RegExpMatchInfo::SetLastInput(Object* value) {
|
||||
int RegExpMatchInfo::Capture(int i) {
|
||||
DCHECK_LT(i, NumberOfCaptureRegisters());
|
||||
Object* obj = get(kFirstCaptureIndex + i);
|
||||
return Smi::cast(obj)->value();
|
||||
return Smi::ToInt(obj);
|
||||
}
|
||||
|
||||
void RegExpMatchInfo::SetCapture(int i, int value) {
|
||||
@ -2034,7 +2031,7 @@ bool DescriptorArray::IsEmpty() {
|
||||
int DescriptorArray::number_of_descriptors() {
|
||||
DCHECK(length() >= kFirstIndex || IsEmpty());
|
||||
int len = length();
|
||||
return len == 0 ? 0 : Smi::cast(get(kDescriptorLengthIndex))->value();
|
||||
return len == 0 ? 0 : Smi::ToInt(get(kDescriptorLengthIndex));
|
||||
}
|
||||
|
||||
|
||||
@ -2392,17 +2389,14 @@ void DescriptorArray::SwapSortedKeys(int first, int second) {
|
||||
}
|
||||
|
||||
int HashTableBase::NumberOfElements() const {
|
||||
return Smi::cast(get(kNumberOfElementsIndex))->value();
|
||||
return Smi::ToInt(get(kNumberOfElementsIndex));
|
||||
}
|
||||
|
||||
int HashTableBase::NumberOfDeletedElements() const {
|
||||
return Smi::cast(get(kNumberOfDeletedElementsIndex))->value();
|
||||
}
|
||||
|
||||
int HashTableBase::Capacity() const {
|
||||
return Smi::cast(get(kCapacityIndex))->value();
|
||||
return Smi::ToInt(get(kNumberOfDeletedElementsIndex));
|
||||
}
|
||||
|
||||
int HashTableBase::Capacity() const { return Smi::ToInt(get(kCapacityIndex)); }
|
||||
|
||||
void HashTableBase::ElementAdded() {
|
||||
SetNumberOfElements(NumberOfElements() + 1);
|
||||
@ -2486,7 +2480,7 @@ bool ObjectHashSet::Has(Isolate* isolate, Handle<Object> key, int32_t hash) {
|
||||
bool ObjectHashSet::Has(Isolate* isolate, Handle<Object> key) {
|
||||
Object* hash = key->GetHash();
|
||||
if (!hash->IsSmi()) return false;
|
||||
return FindEntry(isolate, key, Smi::cast(hash)->value()) != kNotFound;
|
||||
return FindEntry(isolate, key, Smi::ToInt(hash)) != kNotFound;
|
||||
}
|
||||
|
||||
bool StringSetShape::IsMatch(String* key, Object* value) {
|
||||
@ -2522,8 +2516,7 @@ uint32_t StringTableShape::HashForObject(Isolate* isolate, Object* object) {
|
||||
bool SeededNumberDictionary::requires_slow_elements() {
|
||||
Object* max_index_object = get(kMaxNumberKeyIndex);
|
||||
if (!max_index_object->IsSmi()) return false;
|
||||
return 0 !=
|
||||
(Smi::cast(max_index_object)->value() & kRequiresSlowElementsMask);
|
||||
return 0 != (Smi::ToInt(max_index_object) & kRequiresSlowElementsMask);
|
||||
}
|
||||
|
||||
|
||||
@ -2531,7 +2524,7 @@ uint32_t SeededNumberDictionary::max_number_key() {
|
||||
DCHECK(!requires_slow_elements());
|
||||
Object* max_index_object = get(kMaxNumberKeyIndex);
|
||||
if (!max_index_object->IsSmi()) return 0;
|
||||
uint32_t value = static_cast<uint32_t>(Smi::cast(max_index_object)->value());
|
||||
uint32_t value = static_cast<uint32_t>(Smi::ToInt(max_index_object));
|
||||
return value >> kRequiresSlowElementsTagSize;
|
||||
}
|
||||
|
||||
@ -2613,20 +2606,20 @@ int DeoptimizationInputData::DeoptCount() {
|
||||
|
||||
|
||||
int HandlerTable::GetRangeStart(int index) const {
|
||||
return Smi::cast(get(index * kRangeEntrySize + kRangeStartIndex))->value();
|
||||
return Smi::ToInt(get(index * kRangeEntrySize + kRangeStartIndex));
|
||||
}
|
||||
|
||||
int HandlerTable::GetRangeEnd(int index) const {
|
||||
return Smi::cast(get(index * kRangeEntrySize + kRangeEndIndex))->value();
|
||||
return Smi::ToInt(get(index * kRangeEntrySize + kRangeEndIndex));
|
||||
}
|
||||
|
||||
int HandlerTable::GetRangeHandler(int index) const {
|
||||
return HandlerOffsetField::decode(
|
||||
Smi::cast(get(index * kRangeEntrySize + kRangeHandlerIndex))->value());
|
||||
Smi::ToInt(get(index * kRangeEntrySize + kRangeHandlerIndex)));
|
||||
}
|
||||
|
||||
int HandlerTable::GetRangeData(int index) const {
|
||||
return Smi::cast(get(index * kRangeEntrySize + kRangeDataIndex))->value();
|
||||
return Smi::ToInt(get(index * kRangeEntrySize + kRangeDataIndex));
|
||||
}
|
||||
|
||||
void HandlerTable::SetRangeStart(int index, int value) {
|
||||
@ -3040,7 +3033,7 @@ template <class Traits>
|
||||
void FixedTypedArray<Traits>::SetValue(uint32_t index, Object* value) {
|
||||
ElementType cast_value = Traits::defaultValue();
|
||||
if (value->IsSmi()) {
|
||||
int int_value = Smi::cast(value)->value();
|
||||
int int_value = Smi::ToInt(value);
|
||||
cast_value = from(int_value);
|
||||
} else if (value->IsHeapNumber()) {
|
||||
double double_value = HeapNumber::cast(value)->value();
|
||||
@ -3575,9 +3568,7 @@ void DependentCode::set_next_link(DependentCode* next) {
|
||||
set(kNextLinkIndex, next);
|
||||
}
|
||||
|
||||
|
||||
int DependentCode::flags() { return Smi::cast(get(kFlagsIndex))->value(); }
|
||||
|
||||
int DependentCode::flags() { return Smi::ToInt(get(kFlagsIndex)); }
|
||||
|
||||
void DependentCode::set_flags(int flags) {
|
||||
set(kFlagsIndex, Smi::FromInt(flags));
|
||||
@ -4487,27 +4478,27 @@ ACCESSORS(ObjectTemplateInfo, data, Object, kDataOffset)
|
||||
int ObjectTemplateInfo::embedder_field_count() const {
|
||||
Object* value = data();
|
||||
DCHECK(value->IsSmi());
|
||||
return EmbedderFieldCount::decode(Smi::cast(value)->value());
|
||||
return EmbedderFieldCount::decode(Smi::ToInt(value));
|
||||
}
|
||||
|
||||
void ObjectTemplateInfo::set_embedder_field_count(int count) {
|
||||
return set_data(Smi::FromInt(
|
||||
EmbedderFieldCount::update(Smi::cast(data())->value(), count)));
|
||||
return set_data(
|
||||
Smi::FromInt(EmbedderFieldCount::update(Smi::ToInt(data()), count)));
|
||||
}
|
||||
|
||||
bool ObjectTemplateInfo::immutable_proto() const {
|
||||
Object* value = data();
|
||||
DCHECK(value->IsSmi());
|
||||
return IsImmutablePrototype::decode(Smi::cast(value)->value());
|
||||
return IsImmutablePrototype::decode(Smi::ToInt(value));
|
||||
}
|
||||
|
||||
void ObjectTemplateInfo::set_immutable_proto(bool immutable) {
|
||||
return set_data(Smi::FromInt(
|
||||
IsImmutablePrototype::update(Smi::cast(data())->value(), immutable)));
|
||||
IsImmutablePrototype::update(Smi::ToInt(data()), immutable)));
|
||||
}
|
||||
|
||||
int TemplateList::length() const {
|
||||
return Smi::cast(FixedArray::cast(this)->get(kLengthIndex))->value();
|
||||
return Smi::ToInt(FixedArray::cast(this)->get(kLengthIndex));
|
||||
}
|
||||
|
||||
Object* TemplateList::get(int index) const {
|
||||
@ -5290,7 +5281,7 @@ int JSRegExp::CaptureCount() {
|
||||
case ATOM:
|
||||
return 0;
|
||||
case IRREGEXP:
|
||||
return Smi::cast(DataAt(kIrregexpCaptureCountIndex))->value();
|
||||
return Smi::ToInt(DataAt(kIrregexpCaptureCountIndex));
|
||||
default:
|
||||
UNREACHABLE();
|
||||
}
|
||||
@ -5952,11 +5943,11 @@ bool ObjectHashTableShape::IsMatch(Handle<Object> key, Object* other) {
|
||||
}
|
||||
|
||||
uint32_t ObjectHashTableShape::Hash(Isolate* isolate, Handle<Object> key) {
|
||||
return Smi::cast(key->GetHash())->value();
|
||||
return Smi::ToInt(key->GetHash());
|
||||
}
|
||||
|
||||
uint32_t ObjectHashTableShape::HashForObject(Isolate* isolate, Object* other) {
|
||||
return Smi::cast(other->GetHash())->value();
|
||||
return Smi::ToInt(other->GetHash());
|
||||
}
|
||||
|
||||
|
||||
@ -6076,13 +6067,13 @@ bool JSArray::HasArrayPrototype(Isolate* isolate) {
|
||||
|
||||
|
||||
int TypeFeedbackInfo::ic_total_count() {
|
||||
int current = Smi::cast(READ_FIELD(this, kStorage1Offset))->value();
|
||||
int current = Smi::ToInt(READ_FIELD(this, kStorage1Offset));
|
||||
return ICTotalCountField::decode(current);
|
||||
}
|
||||
|
||||
|
||||
void TypeFeedbackInfo::set_ic_total_count(int count) {
|
||||
int value = Smi::cast(READ_FIELD(this, kStorage1Offset))->value();
|
||||
int value = Smi::ToInt(READ_FIELD(this, kStorage1Offset));
|
||||
value = ICTotalCountField::update(value,
|
||||
ICTotalCountField::decode(count));
|
||||
WRITE_FIELD(this, kStorage1Offset, Smi::FromInt(value));
|
||||
@ -6090,14 +6081,14 @@ void TypeFeedbackInfo::set_ic_total_count(int count) {
|
||||
|
||||
|
||||
int TypeFeedbackInfo::ic_with_type_info_count() {
|
||||
int current = Smi::cast(READ_FIELD(this, kStorage2Offset))->value();
|
||||
int current = Smi::ToInt(READ_FIELD(this, kStorage2Offset));
|
||||
return ICsWithTypeInfoCountField::decode(current);
|
||||
}
|
||||
|
||||
|
||||
void TypeFeedbackInfo::change_ic_with_type_info_count(int delta) {
|
||||
if (delta == 0) return;
|
||||
int value = Smi::cast(READ_FIELD(this, kStorage2Offset))->value();
|
||||
int value = Smi::ToInt(READ_FIELD(this, kStorage2Offset));
|
||||
int new_count = ICsWithTypeInfoCountField::decode(value) + delta;
|
||||
// We can get negative count here when the type-feedback info is
|
||||
// shared between two code objects. The can only happen when
|
||||
@ -6113,7 +6104,7 @@ void TypeFeedbackInfo::change_ic_with_type_info_count(int delta) {
|
||||
|
||||
|
||||
int TypeFeedbackInfo::ic_generic_count() {
|
||||
return Smi::cast(READ_FIELD(this, kStorage3Offset))->value();
|
||||
return Smi::ToInt(READ_FIELD(this, kStorage3Offset));
|
||||
}
|
||||
|
||||
|
||||
@ -6135,7 +6126,7 @@ void TypeFeedbackInfo::initialize_storage() {
|
||||
|
||||
|
||||
void TypeFeedbackInfo::change_own_type_change_checksum() {
|
||||
int value = Smi::cast(READ_FIELD(this, kStorage1Offset))->value();
|
||||
int value = Smi::ToInt(READ_FIELD(this, kStorage1Offset));
|
||||
int checksum = OwnTypeChangeChecksum::decode(value);
|
||||
checksum = (checksum + 1) % (1 << kTypeChangeChecksumBits);
|
||||
value = OwnTypeChangeChecksum::update(value, checksum);
|
||||
@ -6147,7 +6138,7 @@ void TypeFeedbackInfo::change_own_type_change_checksum() {
|
||||
|
||||
|
||||
void TypeFeedbackInfo::set_inlined_type_change_checksum(int checksum) {
|
||||
int value = Smi::cast(READ_FIELD(this, kStorage2Offset))->value();
|
||||
int value = Smi::ToInt(READ_FIELD(this, kStorage2Offset));
|
||||
int mask = (1 << kTypeChangeChecksumBits) - 1;
|
||||
value = InlinedTypeChangeChecksum::update(value, checksum & mask);
|
||||
// Ensure packed bit field is in Smi range.
|
||||
@ -6158,13 +6149,13 @@ void TypeFeedbackInfo::set_inlined_type_change_checksum(int checksum) {
|
||||
|
||||
|
||||
int TypeFeedbackInfo::own_type_change_checksum() {
|
||||
int value = Smi::cast(READ_FIELD(this, kStorage1Offset))->value();
|
||||
int value = Smi::ToInt(READ_FIELD(this, kStorage1Offset));
|
||||
return OwnTypeChangeChecksum::decode(value);
|
||||
}
|
||||
|
||||
|
||||
bool TypeFeedbackInfo::matches_inlined_type_change_checksum(int checksum) {
|
||||
int value = Smi::cast(READ_FIELD(this, kStorage2Offset))->value();
|
||||
int value = Smi::ToInt(READ_FIELD(this, kStorage2Offset));
|
||||
int mask = (1 << kTypeChangeChecksumBits) - 1;
|
||||
return InlinedTypeChangeChecksum::decode(value) == (checksum & mask);
|
||||
}
|
||||
@ -6185,7 +6176,7 @@ Relocatable::~Relocatable() {
|
||||
template<class Derived, class TableType>
|
||||
Object* OrderedHashTableIterator<Derived, TableType>::CurrentKey() {
|
||||
TableType* table(TableType::cast(this->table()));
|
||||
int index = Smi::cast(this->index())->value();
|
||||
int index = Smi::ToInt(this->index());
|
||||
Object* key = table->KeyAt(index);
|
||||
DCHECK(!key->IsTheHole(table->GetIsolate()));
|
||||
return key;
|
||||
@ -6194,7 +6185,7 @@ Object* OrderedHashTableIterator<Derived, TableType>::CurrentKey() {
|
||||
|
||||
Object* JSMapIterator::CurrentValue() {
|
||||
OrderedHashMap* table(OrderedHashMap::cast(this->table()));
|
||||
int index = Smi::cast(this->index())->value();
|
||||
int index = Smi::ToInt(this->index());
|
||||
Object* value = table->ValueAt(index);
|
||||
DCHECK(!value->IsTheHole(table->GetIsolate()));
|
||||
return value;
|
||||
|
@ -30,8 +30,8 @@ void Object::Print() {
|
||||
|
||||
void Object::Print(std::ostream& os) { // NOLINT
|
||||
if (IsSmi()) {
|
||||
os << "Smi: " << std::hex << "0x" << Smi::cast(this)->value();
|
||||
os << std::dec << " (" << Smi::cast(this)->value() << ")\n";
|
||||
os << "Smi: " << std::hex << "0x" << Smi::ToInt(this);
|
||||
os << std::dec << " (" << Smi::ToInt(this) << ")\n";
|
||||
} else {
|
||||
HeapObject::cast(this)->HeapObjectPrint(os);
|
||||
}
|
||||
@ -891,15 +891,14 @@ void JSDate::JSDatePrint(std::ostream& os) { // NOLINT
|
||||
} else {
|
||||
// TODO(svenpanne) Add some basic formatting to our streams.
|
||||
ScopedVector<char> buf(100);
|
||||
SNPrintF(
|
||||
buf, "\n - time = %s %04d/%02d/%02d %02d:%02d:%02d\n",
|
||||
weekdays[weekday()->IsSmi() ? Smi::cast(weekday())->value() + 1 : 0],
|
||||
year()->IsSmi() ? Smi::cast(year())->value() : -1,
|
||||
month()->IsSmi() ? Smi::cast(month())->value() : -1,
|
||||
day()->IsSmi() ? Smi::cast(day())->value() : -1,
|
||||
hour()->IsSmi() ? Smi::cast(hour())->value() : -1,
|
||||
min()->IsSmi() ? Smi::cast(min())->value() : -1,
|
||||
sec()->IsSmi() ? Smi::cast(sec())->value() : -1);
|
||||
SNPrintF(buf, "\n - time = %s %04d/%02d/%02d %02d:%02d:%02d\n",
|
||||
weekdays[weekday()->IsSmi() ? Smi::ToInt(weekday()) + 1 : 0],
|
||||
year()->IsSmi() ? Smi::ToInt(year()) : -1,
|
||||
month()->IsSmi() ? Smi::ToInt(month()) : -1,
|
||||
day()->IsSmi() ? Smi::ToInt(day()) : -1,
|
||||
hour()->IsSmi() ? Smi::ToInt(hour()) : -1,
|
||||
min()->IsSmi() ? Smi::ToInt(min()) : -1,
|
||||
sec()->IsSmi() ? Smi::ToInt(sec()) : -1);
|
||||
os << buf.start();
|
||||
}
|
||||
JSObjectPrintBody(os, this);
|
||||
@ -1551,7 +1550,7 @@ void LayoutDescriptor::Print(std::ostream& os) { // NOLINT
|
||||
os << "<all tagged>";
|
||||
} else if (IsSmi()) {
|
||||
os << "fast";
|
||||
PrintBitMask(os, static_cast<uint32_t>(Smi::cast(this)->value()));
|
||||
PrintBitMask(os, static_cast<uint32_t>(Smi::ToInt(this)));
|
||||
} else if (IsOddball() &&
|
||||
IsUninitialized(HeapObject::cast(this)->GetIsolate())) {
|
||||
os << "<uninitialized>";
|
||||
|
103
src/objects.cc
103
src/objects.cc
@ -422,7 +422,7 @@ MaybeHandle<Object> Object::ConvertToLength(Isolate* isolate,
|
||||
Handle<Object> input) {
|
||||
ASSIGN_RETURN_ON_EXCEPTION(isolate, input, ToNumber(input), Object);
|
||||
if (input->IsSmi()) {
|
||||
int value = std::max(Smi::cast(*input)->value(), 0);
|
||||
int value = std::max(Smi::ToInt(*input), 0);
|
||||
return handle(Smi::FromInt(value), isolate);
|
||||
}
|
||||
double len = DoubleToInteger(input->Number());
|
||||
@ -440,7 +440,7 @@ MaybeHandle<Object> Object::ConvertToIndex(
|
||||
MessageTemplate::Template error_index) {
|
||||
if (input->IsUndefined(isolate)) return handle(Smi::kZero, isolate);
|
||||
ASSIGN_RETURN_ON_EXCEPTION(isolate, input, ToNumber(input), Object);
|
||||
if (input->IsSmi() && Smi::cast(*input)->value() >= 0) return input;
|
||||
if (input->IsSmi() && Smi::ToInt(*input) >= 0) return input;
|
||||
double len = DoubleToInteger(input->Number()) + 0.0;
|
||||
auto js_len = isolate->factory()->NewNumber(len);
|
||||
if (len < 0.0 || len > kMaxSafeInteger) {
|
||||
@ -450,7 +450,7 @@ MaybeHandle<Object> Object::ConvertToIndex(
|
||||
}
|
||||
|
||||
bool Object::BooleanValue() {
|
||||
if (IsSmi()) return Smi::cast(this)->value() != 0;
|
||||
if (IsSmi()) return Smi::ToInt(this) != 0;
|
||||
DCHECK(IsHeapObject());
|
||||
Isolate* isolate = HeapObject::cast(this)->GetIsolate();
|
||||
if (IsBoolean()) return IsTrue(isolate);
|
||||
@ -1158,7 +1158,7 @@ Handle<Object> JSReceiver::GetDataProperty(LookupIterator* it) {
|
||||
|
||||
bool Object::ToInt32(int32_t* value) {
|
||||
if (IsSmi()) {
|
||||
*value = Smi::cast(this)->value();
|
||||
*value = Smi::ToInt(this);
|
||||
return true;
|
||||
}
|
||||
if (IsHeapNumber()) {
|
||||
@ -2260,7 +2260,7 @@ Object* GetSimpleHash(Object* object) {
|
||||
// The object is either a Smi, a HeapNumber, a name, an odd-ball, a real JS
|
||||
// object, or a Harmony proxy.
|
||||
if (object->IsSmi()) {
|
||||
uint32_t hash = ComputeIntegerHash(Smi::cast(object)->value());
|
||||
uint32_t hash = ComputeIntegerHash(Smi::ToInt(object));
|
||||
return Smi::FromInt(hash & Smi::kMaxValue);
|
||||
}
|
||||
if (object->IsHeapNumber()) {
|
||||
@ -5991,7 +5991,7 @@ void JSObject::MigrateSlowToFast(Handle<JSObject> object,
|
||||
|
||||
// Compute the length of the instance descriptor.
|
||||
for (int i = 0; i < instance_descriptor_length; i++) {
|
||||
int index = Smi::cast(iteration_order->get(i))->value();
|
||||
int index = Smi::ToInt(iteration_order->get(i));
|
||||
DCHECK(dictionary->IsKey(isolate, dictionary->KeyAt(index)));
|
||||
|
||||
PropertyKind kind = dictionary->DetailsAt(index).kind();
|
||||
@ -6056,7 +6056,7 @@ void JSObject::MigrateSlowToFast(Handle<JSObject> object,
|
||||
// Fill in the instance descriptor and the fields.
|
||||
int current_offset = 0;
|
||||
for (int i = 0; i < instance_descriptor_length; i++) {
|
||||
int index = Smi::cast(iteration_order->get(i))->value();
|
||||
int index = Smi::ToInt(iteration_order->get(i));
|
||||
Name* k = dictionary->NameAt(index);
|
||||
// Dictionary keys are internalized upon insertion.
|
||||
// TODO(jkummerow): Turn this into a DCHECK if it's not hit in the wild.
|
||||
@ -7543,9 +7543,8 @@ bool JSObject::ReferencesObjectFromElements(FixedArray* elements,
|
||||
Object* object) {
|
||||
Isolate* isolate = elements->GetIsolate();
|
||||
if (IsObjectElementsKind(kind) || kind == FAST_STRING_WRAPPER_ELEMENTS) {
|
||||
int length = IsJSArray()
|
||||
? Smi::cast(JSArray::cast(this)->length())->value()
|
||||
: elements->length();
|
||||
int length = IsJSArray() ? Smi::ToInt(JSArray::cast(this)->length())
|
||||
: elements->length();
|
||||
for (int i = 0; i < length; ++i) {
|
||||
Object* element = elements->get(i);
|
||||
if (!element->IsTheHole(isolate) && element == object) return true;
|
||||
@ -8125,10 +8124,9 @@ Maybe<bool> JSObject::PreventExtensionsWithTransition(
|
||||
if (!object->HasFixedTypedArrayElements() &&
|
||||
!object->HasDictionaryElements() &&
|
||||
!object->HasSlowStringWrapperElements()) {
|
||||
int length =
|
||||
object->IsJSArray()
|
||||
? Smi::cast(Handle<JSArray>::cast(object)->length())->value()
|
||||
: object->elements()->length();
|
||||
int length = object->IsJSArray()
|
||||
? Smi::ToInt(Handle<JSArray>::cast(object)->length())
|
||||
: object->elements()->length();
|
||||
new_element_dictionary =
|
||||
length == 0 ? isolate->factory()->empty_slow_element_dictionary()
|
||||
: object->GetElementsAccessor()->Normalize(object);
|
||||
@ -8304,7 +8302,7 @@ bool JSObject::HasEnumerableElements() {
|
||||
case PACKED_ELEMENTS:
|
||||
case PACKED_DOUBLE_ELEMENTS: {
|
||||
int length = object->IsJSArray()
|
||||
? Smi::cast(JSArray::cast(object)->length())->value()
|
||||
? Smi::ToInt(JSArray::cast(object)->length())
|
||||
: object->elements()->length();
|
||||
return length > 0;
|
||||
}
|
||||
@ -8312,7 +8310,7 @@ bool JSObject::HasEnumerableElements() {
|
||||
case HOLEY_ELEMENTS: {
|
||||
FixedArray* elements = FixedArray::cast(object->elements());
|
||||
int length = object->IsJSArray()
|
||||
? Smi::cast(JSArray::cast(object)->length())->value()
|
||||
? Smi::ToInt(JSArray::cast(object)->length())
|
||||
: elements->length();
|
||||
Isolate* isolate = GetIsolate();
|
||||
for (int i = 0; i < length; i++) {
|
||||
@ -8322,7 +8320,7 @@ bool JSObject::HasEnumerableElements() {
|
||||
}
|
||||
case HOLEY_DOUBLE_ELEMENTS: {
|
||||
int length = object->IsJSArray()
|
||||
? Smi::cast(JSArray::cast(object)->length())->value()
|
||||
? Smi::ToInt(JSArray::cast(object)->length())
|
||||
: object->elements()->length();
|
||||
// Zero-length arrays would use the empty FixedArray...
|
||||
if (length == 0) return false;
|
||||
@ -9860,7 +9858,7 @@ class CodeCache : public AllStatic {
|
||||
|
||||
static inline int GetLinearUsage(FixedArray* linear_cache) {
|
||||
DCHECK_GT(linear_cache->length(), kEntrySize);
|
||||
return Smi::cast(linear_cache->get(kLinearUsageIndex))->value();
|
||||
return Smi::ToInt(linear_cache->get(kLinearUsageIndex));
|
||||
}
|
||||
};
|
||||
|
||||
@ -10372,12 +10370,12 @@ int HandlerTable::LookupRange(int pc_offset, int* data_out,
|
||||
int innermost_end = std::numeric_limits<int>::max();
|
||||
#endif
|
||||
for (int i = 0; i < length(); i += kRangeEntrySize) {
|
||||
int start_offset = Smi::cast(get(i + kRangeStartIndex))->value();
|
||||
int end_offset = Smi::cast(get(i + kRangeEndIndex))->value();
|
||||
int handler_field = Smi::cast(get(i + kRangeHandlerIndex))->value();
|
||||
int start_offset = Smi::ToInt(get(i + kRangeStartIndex));
|
||||
int end_offset = Smi::ToInt(get(i + kRangeEndIndex));
|
||||
int handler_field = Smi::ToInt(get(i + kRangeHandlerIndex));
|
||||
int handler_offset = HandlerOffsetField::decode(handler_field);
|
||||
CatchPrediction prediction = HandlerPredictionField::decode(handler_field);
|
||||
int handler_data = Smi::cast(get(i + kRangeDataIndex))->value();
|
||||
int handler_data = Smi::ToInt(get(i + kRangeDataIndex));
|
||||
if (pc_offset >= start_offset && pc_offset < end_offset) {
|
||||
DCHECK_GE(start_offset, innermost_start);
|
||||
DCHECK_LT(end_offset, innermost_end);
|
||||
@ -10397,8 +10395,8 @@ int HandlerTable::LookupRange(int pc_offset, int* data_out,
|
||||
// TODO(turbofan): Make sure table is sorted and use binary search.
|
||||
int HandlerTable::LookupReturn(int pc_offset) {
|
||||
for (int i = 0; i < length(); i += kReturnEntrySize) {
|
||||
int return_offset = Smi::cast(get(i + kReturnOffsetIndex))->value();
|
||||
int handler_field = Smi::cast(get(i + kReturnHandlerIndex))->value();
|
||||
int return_offset = Smi::ToInt(get(i + kReturnOffsetIndex));
|
||||
int handler_field = Smi::ToInt(get(i + kReturnHandlerIndex));
|
||||
if (pc_offset == return_offset) {
|
||||
return HandlerOffsetField::decode(handler_field);
|
||||
}
|
||||
@ -12872,7 +12870,7 @@ MaybeHandle<Map> JSFunction::GetDerivedMap(Isolate* isolate,
|
||||
DCHECK(context->IsNativeContext());
|
||||
Handle<Object> maybe_index = JSReceiver::GetDataProperty(
|
||||
constructor, isolate->factory()->native_context_index_symbol());
|
||||
int index = maybe_index->IsSmi() ? Smi::cast(*maybe_index)->value()
|
||||
int index = maybe_index->IsSmi() ? Smi::ToInt(*maybe_index)
|
||||
: Context::OBJECT_FUNCTION_INDEX;
|
||||
Handle<JSFunction> realm_constructor(JSFunction::cast(context->get(index)));
|
||||
prototype = handle(realm_constructor->prototype(), isolate);
|
||||
@ -13131,7 +13129,7 @@ bool GetPositionInfoSlow(const Script* script, int position,
|
||||
}
|
||||
} // namespace
|
||||
|
||||
#define SMI_VALUE(x) (Smi::cast(x)->value())
|
||||
#define SMI_VALUE(x) (Smi::ToInt(x))
|
||||
bool Script::GetPositionInfo(int position, PositionInfo* info,
|
||||
OffsetFlag offset_flag) const {
|
||||
DisallowHeapAllocation no_allocation;
|
||||
@ -13431,7 +13429,7 @@ DebugInfo* SharedFunctionInfo::GetDebugInfo() const {
|
||||
|
||||
int SharedFunctionInfo::debugger_hints() const {
|
||||
if (HasDebugInfo()) return GetDebugInfo()->debugger_hints();
|
||||
return Smi::cast(debug_info())->value();
|
||||
return Smi::ToInt(debug_info());
|
||||
}
|
||||
|
||||
void SharedFunctionInfo::set_debugger_hints(int value) {
|
||||
@ -14525,12 +14523,12 @@ void DeoptimizationInputData::DeoptimizationInputDataPrint(
|
||||
void HandlerTable::HandlerTableRangePrint(std::ostream& os) {
|
||||
os << " from to hdlr\n";
|
||||
for (int i = 0; i < length(); i += kRangeEntrySize) {
|
||||
int pc_start = Smi::cast(get(i + kRangeStartIndex))->value();
|
||||
int pc_end = Smi::cast(get(i + kRangeEndIndex))->value();
|
||||
int handler_field = Smi::cast(get(i + kRangeHandlerIndex))->value();
|
||||
int pc_start = Smi::ToInt(get(i + kRangeStartIndex));
|
||||
int pc_end = Smi::ToInt(get(i + kRangeEndIndex));
|
||||
int handler_field = Smi::ToInt(get(i + kRangeHandlerIndex));
|
||||
int handler_offset = HandlerOffsetField::decode(handler_field);
|
||||
CatchPrediction prediction = HandlerPredictionField::decode(handler_field);
|
||||
int data = Smi::cast(get(i + kRangeDataIndex))->value();
|
||||
int data = Smi::ToInt(get(i + kRangeDataIndex));
|
||||
os << " (" << std::setw(4) << pc_start << "," << std::setw(4) << pc_end
|
||||
<< ") -> " << std::setw(4) << handler_offset
|
||||
<< " (prediction=" << prediction << ", data=" << data << ")\n";
|
||||
@ -14541,8 +14539,8 @@ void HandlerTable::HandlerTableRangePrint(std::ostream& os) {
|
||||
void HandlerTable::HandlerTableReturnPrint(std::ostream& os) {
|
||||
os << " off hdlr (c)\n";
|
||||
for (int i = 0; i < length(); i += kReturnEntrySize) {
|
||||
int pc_offset = Smi::cast(get(i + kReturnOffsetIndex))->value();
|
||||
int handler_field = Smi::cast(get(i + kReturnHandlerIndex))->value();
|
||||
int pc_offset = Smi::ToInt(get(i + kReturnOffsetIndex));
|
||||
int handler_field = Smi::ToInt(get(i + kReturnHandlerIndex));
|
||||
int handler_offset = HandlerOffsetField::decode(handler_field);
|
||||
CatchPrediction prediction = HandlerPredictionField::decode(handler_field);
|
||||
os << " " << std::setw(4) << pc_offset << " -> " << std::setw(4)
|
||||
@ -15424,7 +15422,7 @@ static bool ShouldConvertToFastElements(JSObject* object,
|
||||
if (object->IsJSArray()) {
|
||||
Object* length = JSArray::cast(object)->length();
|
||||
if (!length->IsSmi()) return false;
|
||||
*new_capacity = static_cast<uint32_t>(Smi::cast(length)->value());
|
||||
*new_capacity = static_cast<uint32_t>(Smi::ToInt(length));
|
||||
} else if (object->IsJSSloppyArgumentsObject()) {
|
||||
return false;
|
||||
} else {
|
||||
@ -15731,9 +15729,8 @@ bool JSArray::WouldChangeReadOnlyLength(Handle<JSArray> array,
|
||||
template <typename BackingStore>
|
||||
static int HoleyElementsUsage(JSObject* object, BackingStore* store) {
|
||||
Isolate* isolate = store->GetIsolate();
|
||||
int limit = object->IsJSArray()
|
||||
? Smi::cast(JSArray::cast(object)->length())->value()
|
||||
: store->length();
|
||||
int limit = object->IsJSArray() ? Smi::ToInt(JSArray::cast(object)->length())
|
||||
: store->length();
|
||||
int used = 0;
|
||||
for (int i = 0; i < limit; ++i) {
|
||||
if (!store->is_the_hole(isolate, i)) ++used;
|
||||
@ -15747,7 +15744,7 @@ int JSObject::GetFastElementsUsage() {
|
||||
case PACKED_SMI_ELEMENTS:
|
||||
case PACKED_DOUBLE_ELEMENTS:
|
||||
case PACKED_ELEMENTS:
|
||||
return IsJSArray() ? Smi::cast(JSArray::cast(this)->length())->value()
|
||||
return IsJSArray() ? Smi::ToInt(JSArray::cast(this)->length())
|
||||
: store->length();
|
||||
case FAST_SLOPPY_ARGUMENTS_ELEMENTS:
|
||||
store = SloppyArgumentsElements::cast(store)->arguments();
|
||||
@ -15931,11 +15928,11 @@ class StringSharedKey : public HashTableKey {
|
||||
FixedArray* other_array = FixedArray::cast(other);
|
||||
SharedFunctionInfo* shared = SharedFunctionInfo::cast(other_array->get(0));
|
||||
if (shared != *shared_) return false;
|
||||
int language_unchecked = Smi::cast(other_array->get(2))->value();
|
||||
int language_unchecked = Smi::ToInt(other_array->get(2));
|
||||
DCHECK(is_valid_language_mode(language_unchecked));
|
||||
LanguageMode language_mode = static_cast<LanguageMode>(language_unchecked);
|
||||
if (language_mode != language_mode_) return false;
|
||||
int position = Smi::cast(other_array->get(3))->value();
|
||||
int position = Smi::ToInt(other_array->get(3));
|
||||
if (position != position_) return false;
|
||||
String* source = String::cast(other_array->get(1));
|
||||
return source->Equals(*source_);
|
||||
@ -17565,7 +17562,7 @@ Handle<Derived> BaseNameDictionary<Derived, Shape>::EnsureCapacity(
|
||||
// Iterate over the dictionary using the enumeration order and update
|
||||
// the dictionary with new enumeration indices.
|
||||
for (int i = 0; i < length; i++) {
|
||||
int index = Smi::cast(iteration_order->get(i))->value();
|
||||
int index = Smi::ToInt(iteration_order->get(i));
|
||||
DCHECK(dictionary->IsKey(dictionary->GetIsolate(),
|
||||
dictionary->KeyAt(index)));
|
||||
|
||||
@ -17790,7 +17787,7 @@ void BaseNameDictionary<Derived, Shape>::CopyEnumKeysTo(
|
||||
storage->GetFirstElementAddress());
|
||||
std::sort(start, start + length, cmp);
|
||||
for (int i = 0; i < length; i++) {
|
||||
int index = Smi::cast(raw_storage->get(i))->value();
|
||||
int index = Smi::ToInt(raw_storage->get(i));
|
||||
raw_storage->set(i, raw_dictionary->NameAt(index));
|
||||
}
|
||||
}
|
||||
@ -17867,7 +17864,7 @@ void BaseNameDictionary<Derived, Shape>::CollectKeysTo(
|
||||
|
||||
bool has_seen_symbol = false;
|
||||
for (int i = 0; i < array_size; i++) {
|
||||
int index = Smi::cast(array->get(i))->value();
|
||||
int index = Smi::ToInt(array->get(i));
|
||||
Object* key = dictionary->NameAt(index);
|
||||
if (key->IsSymbol()) {
|
||||
has_seen_symbol = true;
|
||||
@ -17877,7 +17874,7 @@ void BaseNameDictionary<Derived, Shape>::CollectKeysTo(
|
||||
}
|
||||
if (has_seen_symbol) {
|
||||
for (int i = 0; i < array_size; i++) {
|
||||
int index = Smi::cast(array->get(i))->value();
|
||||
int index = Smi::ToInt(array->get(i));
|
||||
Object* key = dictionary->NameAt(index);
|
||||
if (!key->IsSymbol()) continue;
|
||||
keys->AddKey(key, DO_NOT_CONVERT);
|
||||
@ -17923,7 +17920,7 @@ Object* ObjectHashTable::Lookup(Handle<Object> key) {
|
||||
if (hash->IsUndefined(isolate)) {
|
||||
return isolate->heap()->the_hole_value();
|
||||
}
|
||||
return Lookup(isolate, key, Smi::cast(hash)->value());
|
||||
return Lookup(isolate, key, Smi::ToInt(hash));
|
||||
}
|
||||
|
||||
Object* ObjectHashTable::ValueAt(int entry) {
|
||||
@ -18003,7 +18000,7 @@ Handle<ObjectHashTable> ObjectHashTable::Remove(Handle<ObjectHashTable> table,
|
||||
return table;
|
||||
}
|
||||
|
||||
return Remove(table, key, was_present, Smi::cast(hash)->value());
|
||||
return Remove(table, key, was_present, Smi::ToInt(hash));
|
||||
}
|
||||
|
||||
|
||||
@ -18237,7 +18234,7 @@ Handle<Derived> OrderedHashTable<Derived, entrysize>::Rehash(
|
||||
}
|
||||
|
||||
Object* hash = key->GetHash();
|
||||
int bucket = Smi::cast(hash)->value() & (new_buckets - 1);
|
||||
int bucket = Smi::ToInt(hash) & (new_buckets - 1);
|
||||
Object* chain_entry = new_table->get(kHashTableStartIndex + bucket);
|
||||
new_table->set(kHashTableStartIndex + bucket, Smi::FromInt(new_entry));
|
||||
int new_index = new_table->EntryToIndex(new_entry);
|
||||
@ -18492,7 +18489,7 @@ bool SmallOrderedHashTable<Derived>::HasKey(Isolate* isolate,
|
||||
Object* hash = key->GetHash();
|
||||
|
||||
if (hash->IsUndefined(isolate)) return false;
|
||||
int entry = HashToFirstEntry(Smi::cast(hash)->value());
|
||||
int entry = HashToFirstEntry(Smi::ToInt(hash));
|
||||
|
||||
// Walk the chain in the bucket to find the key.
|
||||
while (entry != kNotFound) {
|
||||
@ -18522,7 +18519,7 @@ Handle<Derived> SmallOrderedHashTable<Derived>::Rehash(Handle<Derived> table,
|
||||
Object* key = table->KeyAt(old_entry);
|
||||
if (key->IsTheHole(isolate)) continue;
|
||||
|
||||
int hash = Smi::cast(key->GetHash())->value();
|
||||
int hash = Smi::ToInt(key->GetHash());
|
||||
int bucket = new_table->HashToBucket(hash);
|
||||
int chain = new_table->GetFirstEntry(bucket);
|
||||
|
||||
@ -18591,7 +18588,7 @@ void OrderedHashTableIterator<Derived, TableType>::Transition() {
|
||||
TableType* table = TableType::cast(this->table());
|
||||
if (!table->IsObsolete()) return;
|
||||
|
||||
int index = Smi::cast(this->index())->value();
|
||||
int index = Smi::ToInt(this->index());
|
||||
while (table->IsObsolete()) {
|
||||
TableType* next_table = table->NextTable();
|
||||
|
||||
@ -18627,7 +18624,7 @@ bool OrderedHashTableIterator<Derived, TableType>::HasMore() {
|
||||
Transition();
|
||||
|
||||
TableType* table = TableType::cast(this->table());
|
||||
int index = Smi::cast(this->index())->value();
|
||||
int index = Smi::ToInt(this->index());
|
||||
int used_capacity = table->UsedCapacity();
|
||||
|
||||
while (index < used_capacity && table->KeyAt(index)->IsTheHole(isolate)) {
|
||||
@ -19316,9 +19313,9 @@ int JSGeneratorObject::source_position() const {
|
||||
const JSAsyncGeneratorObject* async =
|
||||
IsJSAsyncGeneratorObject() ? JSAsyncGeneratorObject::cast(this) : nullptr;
|
||||
if (async != nullptr && async->awaited_promise()->IsJSPromise()) {
|
||||
code_offset = Smi::cast(async->await_input_or_debug_pos())->value();
|
||||
code_offset = Smi::ToInt(async->await_input_or_debug_pos());
|
||||
} else {
|
||||
code_offset = Smi::cast(input_or_debug_pos())->value();
|
||||
code_offset = Smi::ToInt(input_or_debug_pos());
|
||||
}
|
||||
|
||||
// The stored bytecode offset is relative to a different base than what
|
||||
|
@ -1606,6 +1606,9 @@ class Smi: public Object {
|
||||
return Smi::FromInt(static_cast<uint32_t>(value()));
|
||||
}
|
||||
|
||||
// Convert a Smi object to an int.
|
||||
static inline int ToInt(const Object* object);
|
||||
|
||||
// Convert a value to a Smi object.
|
||||
static inline Smi* FromInt(int value) {
|
||||
DCHECK(Smi::IsValid(value));
|
||||
|
@ -48,10 +48,10 @@ uint32_t CompilationCacheShape::HashForObject(Isolate* isolate,
|
||||
DCHECK_EQ(4, val->length());
|
||||
SharedFunctionInfo* shared = SharedFunctionInfo::cast(val->get(0));
|
||||
String* source = String::cast(val->get(1));
|
||||
int language_unchecked = Smi::cast(val->get(2))->value();
|
||||
int language_unchecked = Smi::ToInt(val->get(2));
|
||||
DCHECK(is_valid_language_mode(language_unchecked));
|
||||
LanguageMode language_mode = static_cast<LanguageMode>(language_unchecked);
|
||||
int position = Smi::cast(val->get(3))->value();
|
||||
int position = Smi::ToInt(val->get(3));
|
||||
return StringSharedHash(source, shared, language_mode, position);
|
||||
}
|
||||
DCHECK_LT(2, val->length());
|
||||
|
@ -292,21 +292,21 @@ int CoverageInfo::StartSourcePosition(int slot_index) const {
|
||||
DCHECK(FLAG_block_coverage);
|
||||
DCHECK_LT(slot_index, SlotCount());
|
||||
const int slot_start = CoverageInfo::FirstIndexForSlot(slot_index);
|
||||
return Smi::cast(get(slot_start + kSlotStartSourcePositionIndex))->value();
|
||||
return Smi::ToInt(get(slot_start + kSlotStartSourcePositionIndex));
|
||||
}
|
||||
|
||||
int CoverageInfo::EndSourcePosition(int slot_index) const {
|
||||
DCHECK(FLAG_block_coverage);
|
||||
DCHECK_LT(slot_index, SlotCount());
|
||||
const int slot_start = CoverageInfo::FirstIndexForSlot(slot_index);
|
||||
return Smi::cast(get(slot_start + kSlotEndSourcePositionIndex))->value();
|
||||
return Smi::ToInt(get(slot_start + kSlotEndSourcePositionIndex));
|
||||
}
|
||||
|
||||
int CoverageInfo::BlockCount(int slot_index) const {
|
||||
DCHECK(FLAG_block_coverage);
|
||||
DCHECK_LT(slot_index, SlotCount());
|
||||
const int slot_start = CoverageInfo::FirstIndexForSlot(slot_index);
|
||||
return Smi::cast(get(slot_start + kSlotBlockCountIndex))->value();
|
||||
return Smi::ToInt(get(slot_start + kSlotBlockCountIndex));
|
||||
}
|
||||
|
||||
void CoverageInfo::InitializeSlot(int slot_index, int from_pos, int to_pos) {
|
||||
|
@ -134,7 +134,7 @@ class BaseNameDictionary : public Dictionary<Derived, Shape> {
|
||||
}
|
||||
|
||||
int NextEnumerationIndex() {
|
||||
return Smi::cast(this->get(kNextEnumerationIndexIndex))->value();
|
||||
return Smi::ToInt(this->get(kNextEnumerationIndexIndex));
|
||||
}
|
||||
|
||||
// Creates a new dictionary.
|
||||
|
@ -44,7 +44,7 @@ bool FrameArray::IsAsmJsWasmFrame(int frame_ix) const {
|
||||
}
|
||||
|
||||
int FrameArray::FrameCount() const {
|
||||
const int frame_count = Smi::cast(get(kFrameCountIndex))->value();
|
||||
const int frame_count = Smi::ToInt(get(kFrameCountIndex));
|
||||
DCHECK_LE(0, frame_count);
|
||||
return frame_count;
|
||||
}
|
||||
|
@ -402,21 +402,17 @@ class OrderedHashTable : public FixedArray {
|
||||
// the key has been deleted. This does not shrink the table.
|
||||
static bool Delete(Isolate* isolate, Derived* table, Object* key);
|
||||
|
||||
int NumberOfElements() {
|
||||
return Smi::cast(get(kNumberOfElementsIndex))->value();
|
||||
}
|
||||
int NumberOfElements() { return Smi::ToInt(get(kNumberOfElementsIndex)); }
|
||||
|
||||
int NumberOfDeletedElements() {
|
||||
return Smi::cast(get(kNumberOfDeletedElementsIndex))->value();
|
||||
return Smi::ToInt(get(kNumberOfDeletedElementsIndex));
|
||||
}
|
||||
|
||||
// Returns the number of contiguous entries in the data table, starting at 0,
|
||||
// that either are real entries or have been deleted.
|
||||
int UsedCapacity() { return NumberOfElements() + NumberOfDeletedElements(); }
|
||||
|
||||
int NumberOfBuckets() {
|
||||
return Smi::cast(get(kNumberOfBucketsIndex))->value();
|
||||
}
|
||||
int NumberOfBuckets() { return Smi::ToInt(get(kNumberOfBucketsIndex)); }
|
||||
|
||||
// Returns an index into |this| for the given entry.
|
||||
int EntryToIndex(int entry) {
|
||||
@ -428,21 +424,21 @@ class OrderedHashTable : public FixedArray {
|
||||
int HashToEntry(int hash) {
|
||||
int bucket = HashToBucket(hash);
|
||||
Object* entry = this->get(kHashTableStartIndex + bucket);
|
||||
return Smi::cast(entry)->value();
|
||||
return Smi::ToInt(entry);
|
||||
}
|
||||
|
||||
int KeyToFirstEntry(Isolate* isolate, Object* key) {
|
||||
// This special cases for Smi, so that we avoid the HandleScope
|
||||
// creation below.
|
||||
if (key->IsSmi()) {
|
||||
uint32_t hash = ComputeIntegerHash(Smi::cast(key)->value());
|
||||
uint32_t hash = ComputeIntegerHash(Smi::ToInt(key));
|
||||
return HashToEntry(hash & Smi::kMaxValue);
|
||||
}
|
||||
HandleScope scope(isolate);
|
||||
Object* hash = key->GetHash();
|
||||
// If the object does not have an identity hash, it was never used as a key
|
||||
if (hash->IsUndefined(isolate)) return kNotFound;
|
||||
return HashToEntry(Smi::cast(hash)->value());
|
||||
return HashToEntry(Smi::ToInt(hash));
|
||||
}
|
||||
|
||||
int FindEntry(Isolate* isolate, Object* key) {
|
||||
@ -459,7 +455,7 @@ class OrderedHashTable : public FixedArray {
|
||||
|
||||
int NextChainEntry(int entry) {
|
||||
Object* next_entry = get(EntryToIndex(entry) + kChainOffset);
|
||||
return Smi::cast(next_entry)->value();
|
||||
return Smi::ToInt(next_entry);
|
||||
}
|
||||
|
||||
// use KeyAt(i)->IsTheHole(isolate) to determine if this is a deleted entry.
|
||||
@ -475,7 +471,7 @@ class OrderedHashTable : public FixedArray {
|
||||
|
||||
// When the table is obsolete we store the indexes of the removed holes.
|
||||
int RemovedIndexAt(int index) {
|
||||
return Smi::cast(get(kRemovedHolesIndex + index))->value();
|
||||
return Smi::ToInt(get(kRemovedHolesIndex + index));
|
||||
}
|
||||
|
||||
static const int kNotFound = -1;
|
||||
@ -869,7 +865,7 @@ class OrderedHashTableIterator : public JSObject {
|
||||
bool HasMore();
|
||||
|
||||
// Move the index forward one.
|
||||
void MoveNext() { set_index(Smi::FromInt(Smi::cast(index())->value() + 1)); }
|
||||
void MoveNext() { set_index(Smi::FromInt(Smi::ToInt(index()) + 1)); }
|
||||
|
||||
// Returns the current key of the iterator. This should only be called when
|
||||
// |HasMore| returns true.
|
||||
|
@ -31,7 +31,7 @@ int BoilerplateDescription::size() const {
|
||||
int BoilerplateDescription::backing_store_size() const {
|
||||
if (has_number_of_properties()) {
|
||||
// If present, the last entry contains the number of properties.
|
||||
return Smi::cast(this->get(length() - 1))->value();
|
||||
return Smi::ToInt(this->get(length() - 1));
|
||||
}
|
||||
// If the number is not given explicitly, we assume there are no
|
||||
// properties with computed names.
|
||||
|
@ -65,7 +65,7 @@
|
||||
int holder::name() const { \
|
||||
DCHECK(condition); \
|
||||
Object* value = READ_FIELD(this, offset); \
|
||||
return Smi::cast(value)->value(); \
|
||||
return Smi::ToInt(value); \
|
||||
} \
|
||||
void holder::set_##name(int value) { \
|
||||
DCHECK(condition); \
|
||||
@ -78,7 +78,7 @@
|
||||
#define SYNCHRONIZED_SMI_ACCESSORS(holder, name, offset) \
|
||||
int holder::synchronized_##name() const { \
|
||||
Object* value = ACQUIRE_READ_FIELD(this, offset); \
|
||||
return Smi::cast(value)->value(); \
|
||||
return Smi::ToInt(value); \
|
||||
} \
|
||||
void holder::synchronized_set_##name(int value) { \
|
||||
RELEASE_WRITE_FIELD(this, offset, Smi::FromInt(value)); \
|
||||
@ -87,7 +87,7 @@
|
||||
#define RELAXED_SMI_ACCESSORS(holder, name, offset) \
|
||||
int holder::relaxed_read_##name() const { \
|
||||
Object* value = RELAXED_READ_FIELD(this, offset); \
|
||||
return Smi::cast(value)->value(); \
|
||||
return Smi::ToInt(value); \
|
||||
} \
|
||||
void holder::relaxed_write_##name(int value) { \
|
||||
RELAXED_WRITE_FIELD(this, offset, Smi::FromInt(value)); \
|
||||
|
@ -543,7 +543,7 @@ String* ScopeInfo::StackLocalName(int var) {
|
||||
int ScopeInfo::StackLocalIndex(int var) {
|
||||
DCHECK_LE(0, var);
|
||||
DCHECK_LT(var, StackLocalCount());
|
||||
int first_slot_index = Smi::cast(get(StackLocalFirstSlotIndex()))->value();
|
||||
int first_slot_index = Smi::ToInt(get(StackLocalFirstSlotIndex()));
|
||||
return first_slot_index + var;
|
||||
}
|
||||
|
||||
@ -558,7 +558,7 @@ VariableMode ScopeInfo::ContextLocalMode(int var) {
|
||||
DCHECK_LE(0, var);
|
||||
DCHECK_LT(var, ContextLocalCount());
|
||||
int info_index = ContextLocalInfosIndex() + var;
|
||||
int value = Smi::cast(get(info_index))->value();
|
||||
int value = Smi::ToInt(get(info_index));
|
||||
return VariableModeField::decode(value);
|
||||
}
|
||||
|
||||
@ -566,7 +566,7 @@ InitializationFlag ScopeInfo::ContextLocalInitFlag(int var) {
|
||||
DCHECK_LE(0, var);
|
||||
DCHECK_LT(var, ContextLocalCount());
|
||||
int info_index = ContextLocalInfosIndex() + var;
|
||||
int value = Smi::cast(get(info_index))->value();
|
||||
int value = Smi::ToInt(get(info_index));
|
||||
return InitFlagField::decode(value);
|
||||
}
|
||||
|
||||
@ -574,7 +574,7 @@ MaybeAssignedFlag ScopeInfo::ContextLocalMaybeAssignedFlag(int var) {
|
||||
DCHECK_LE(0, var);
|
||||
DCHECK_LT(var, ContextLocalCount());
|
||||
int info_index = ContextLocalInfosIndex() + var;
|
||||
int value = Smi::cast(get(info_index))->value();
|
||||
int value = Smi::ToInt(get(info_index));
|
||||
return MaybeAssignedFlagField::decode(value);
|
||||
}
|
||||
|
||||
@ -590,7 +590,7 @@ bool ScopeInfo::VariableIsSynthetic(String* name) {
|
||||
int ScopeInfo::StackSlotIndex(String* name) {
|
||||
DCHECK(name->IsInternalizedString());
|
||||
if (length() > 0) {
|
||||
int first_slot_index = Smi::cast(get(StackLocalFirstSlotIndex()))->value();
|
||||
int first_slot_index = Smi::ToInt(get(StackLocalFirstSlotIndex()));
|
||||
int start = StackLocalNamesIndex();
|
||||
int end = start + StackLocalCount();
|
||||
for (int i = start; i < end; ++i) {
|
||||
@ -610,7 +610,7 @@ int ScopeInfo::ModuleIndex(Handle<String> name, VariableMode* mode,
|
||||
DCHECK_NOT_NULL(init_flag);
|
||||
DCHECK_NOT_NULL(maybe_assigned_flag);
|
||||
|
||||
int module_vars_count = Smi::cast(get(ModuleVariableCountIndex()))->value();
|
||||
int module_vars_count = Smi::ToInt(get(ModuleVariableCountIndex()));
|
||||
int entry = ModuleVariablesIndex();
|
||||
for (int i = 0; i < module_vars_count; ++i) {
|
||||
String* var_name = String::cast(get(entry + kModuleVariableNameOffset));
|
||||
@ -689,7 +689,7 @@ int ScopeInfo::ParameterIndex(String* name) {
|
||||
|
||||
int ScopeInfo::ReceiverContextSlotIndex() {
|
||||
if (length() > 0 && ReceiverVariableField::decode(Flags()) == CONTEXT)
|
||||
return Smi::cast(get(ReceiverInfoIndex()))->value();
|
||||
return Smi::ToInt(get(ReceiverInfoIndex()));
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -698,7 +698,7 @@ int ScopeInfo::FunctionContextSlotIndex(String* name) {
|
||||
if (length() > 0) {
|
||||
if (FunctionVariableField::decode(Flags()) == CONTEXT &&
|
||||
FunctionName() == name) {
|
||||
return Smi::cast(get(FunctionNameInfoIndex() + 1))->value();
|
||||
return Smi::ToInt(get(FunctionNameInfoIndex() + 1));
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
@ -752,17 +752,16 @@ void ScopeInfo::ModuleVariable(int i, String** name, int* index,
|
||||
InitializationFlag* init_flag,
|
||||
MaybeAssignedFlag* maybe_assigned_flag) {
|
||||
DCHECK_LE(0, i);
|
||||
DCHECK_LT(i, Smi::cast(get(ModuleVariableCountIndex()))->value());
|
||||
DCHECK_LT(i, Smi::ToInt(get(ModuleVariableCountIndex())));
|
||||
|
||||
int entry = ModuleVariablesIndex() + i * kModuleVariableEntryLength;
|
||||
int properties =
|
||||
Smi::cast(get(entry + kModuleVariablePropertiesOffset))->value();
|
||||
int properties = Smi::ToInt(get(entry + kModuleVariablePropertiesOffset));
|
||||
|
||||
if (name != nullptr) {
|
||||
*name = String::cast(get(entry + kModuleVariableNameOffset));
|
||||
}
|
||||
if (index != nullptr) {
|
||||
*index = Smi::cast(get(entry + kModuleVariableIndexOffset))->value();
|
||||
*index = Smi::ToInt(get(entry + kModuleVariableIndexOffset));
|
||||
DCHECK_NE(*index, 0);
|
||||
}
|
||||
if (mode != nullptr) {
|
||||
|
@ -214,7 +214,7 @@ class ScopeInfo : public FixedArray {
|
||||
inline void Set##name(int value) { set(k##name, Smi::FromInt(value)); } \
|
||||
inline int name() { \
|
||||
if (length() > 0) { \
|
||||
return Smi::cast(get(k##name))->value(); \
|
||||
return Smi::ToInt(get(k##name)); \
|
||||
} else { \
|
||||
return 0; \
|
||||
} \
|
||||
|
@ -317,8 +317,7 @@ bool SharedFunctionInfo::HasBuiltinFunctionId() {
|
||||
|
||||
BuiltinFunctionId SharedFunctionInfo::builtin_function_id() {
|
||||
DCHECK(HasBuiltinFunctionId());
|
||||
return static_cast<BuiltinFunctionId>(
|
||||
Smi::cast(function_identifier())->value());
|
||||
return static_cast<BuiltinFunctionId>(Smi::ToInt(function_identifier()));
|
||||
}
|
||||
|
||||
void SharedFunctionInfo::set_builtin_function_id(BuiltinFunctionId id) {
|
||||
|
@ -1623,9 +1623,9 @@ void V8HeapExplorer::ExtractElementReferences(JSObject* js_obj, int entry) {
|
||||
Isolate* isolate = js_obj->GetIsolate();
|
||||
if (js_obj->HasObjectElements()) {
|
||||
FixedArray* elements = FixedArray::cast(js_obj->elements());
|
||||
int length = js_obj->IsJSArray() ?
|
||||
Smi::cast(JSArray::cast(js_obj)->length())->value() :
|
||||
elements->length();
|
||||
int length = js_obj->IsJSArray()
|
||||
? Smi::ToInt(JSArray::cast(js_obj)->length())
|
||||
: elements->length();
|
||||
for (int i = 0; i < length; ++i) {
|
||||
if (!elements->get(i)->IsTheHole(isolate)) {
|
||||
SetElementReference(js_obj, entry, i, elements->get(i));
|
||||
|
@ -335,7 +335,7 @@ bool RegExpImpl::CompileIrregexp(Handle<JSRegExp> re,
|
||||
// When arriving here entry can only be a smi representing an uncompiled
|
||||
// regexp.
|
||||
DCHECK(entry->IsSmi());
|
||||
int entry_value = Smi::cast(entry)->value();
|
||||
int entry_value = Smi::ToInt(entry);
|
||||
DCHECK_EQ(JSRegExp::kUninitializedValue, entry_value);
|
||||
#endif
|
||||
|
||||
@ -395,12 +395,12 @@ void RegExpImpl::SetIrregexpCaptureNameMap(FixedArray* re,
|
||||
}
|
||||
|
||||
int RegExpImpl::IrregexpNumberOfCaptures(FixedArray* re) {
|
||||
return Smi::cast(re->get(JSRegExp::kIrregexpCaptureCountIndex))->value();
|
||||
return Smi::ToInt(re->get(JSRegExp::kIrregexpCaptureCountIndex));
|
||||
}
|
||||
|
||||
|
||||
int RegExpImpl::IrregexpNumberOfRegisters(FixedArray* re) {
|
||||
return Smi::cast(re->get(JSRegExp::kIrregexpMaxRegisterCountIndex))->value();
|
||||
return Smi::ToInt(re->get(JSRegExp::kIrregexpMaxRegisterCountIndex));
|
||||
}
|
||||
|
||||
|
||||
|
@ -152,7 +152,7 @@ bool RegExpUtils::IsUnmodifiedRegExp(Isolate* isolate, Handle<Object> obj) {
|
||||
// The smi check is required to omit ToLength(lastIndex) calls with possible
|
||||
// user-code execution on the fast path.
|
||||
Object* last_index = JSRegExp::cast(recv)->LastIndex();
|
||||
return last_index->IsSmi() && Smi::cast(last_index)->value() >= 0;
|
||||
return last_index->IsSmi() && Smi::ToInt(last_index) >= 0;
|
||||
}
|
||||
|
||||
int RegExpUtils::AdvanceStringIndex(Isolate* isolate, Handle<String> string,
|
||||
|
@ -632,7 +632,7 @@ RUNTIME_FUNCTION(Runtime_ArrayIncludes_Slow) {
|
||||
Object::ToInteger(isolate, from_index));
|
||||
|
||||
if (V8_LIKELY(from_index->IsSmi())) {
|
||||
int start_from = Smi::cast(*from_index)->value();
|
||||
int start_from = Smi::ToInt(*from_index);
|
||||
if (start_from < 0) {
|
||||
index = std::max<int64_t>(len + start_from, 0);
|
||||
} else {
|
||||
|
@ -82,7 +82,7 @@ RUNTIME_FUNCTION(Runtime_SetIteratorClone) {
|
||||
return *isolate->factory()->NewJSSetIterator(
|
||||
handle(holder->map(), isolate),
|
||||
handle(OrderedHashSet::cast(holder->table()), isolate),
|
||||
Smi::cast(holder->index())->value());
|
||||
Smi::ToInt(holder->index()));
|
||||
}
|
||||
|
||||
|
||||
@ -122,7 +122,7 @@ RUNTIME_FUNCTION(Runtime_MapIteratorClone) {
|
||||
return *isolate->factory()->NewJSMapIterator(
|
||||
handle(holder->map(), isolate),
|
||||
handle(OrderedHashMap::cast(holder->table()), isolate),
|
||||
Smi::cast(holder->index())->value());
|
||||
Smi::ToInt(holder->index()));
|
||||
}
|
||||
|
||||
RUNTIME_FUNCTION(Runtime_GetWeakMapEntries) {
|
||||
|
@ -1557,7 +1557,7 @@ int ScriptLinePosition(Handle<Script> script, int line) {
|
||||
if (line == 0) return 0;
|
||||
// If line == line_count, we return the first position beyond the last line.
|
||||
if (line > line_count) return -1;
|
||||
return Smi::cast(line_ends_array->get(line - 1))->value() + 1;
|
||||
return Smi::ToInt(line_ends_array->get(line - 1)) + 1;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
@ -1792,8 +1792,8 @@ RUNTIME_FUNCTION(Runtime_ScriptSourceLine) {
|
||||
}
|
||||
|
||||
const int start =
|
||||
(line == 0) ? 0 : Smi::cast(line_ends_array->get(line - 1))->value() + 1;
|
||||
const int end = Smi::cast(line_ends_array->get(line))->value();
|
||||
(line == 0) ? 0 : Smi::ToInt(line_ends_array->get(line - 1)) + 1;
|
||||
const int end = Smi::ToInt(line_ends_array->get(line));
|
||||
|
||||
Handle<String> source =
|
||||
handle(String::cast(script_handle->source()), isolate);
|
||||
|
@ -49,7 +49,7 @@ RUNTIME_FUNCTION(Runtime_InstallToContext) {
|
||||
CHECK(isolate->bootstrapper()->IsActive());
|
||||
Handle<Context> native_context = isolate->native_context();
|
||||
Handle<FixedArray> fixed_array(FixedArray::cast(array->elements()));
|
||||
int length = Smi::cast(array->length())->value();
|
||||
int length = Smi::ToInt(array->length());
|
||||
for (int i = 0; i < length; i += 2) {
|
||||
CHECK(fixed_array->get(i)->IsString());
|
||||
Handle<String> name(String::cast(fixed_array->get(i)));
|
||||
|
@ -223,7 +223,7 @@ RUNTIME_FUNCTION(Runtime_LiveEditCheckAndDropActivations) {
|
||||
CHECK(new_shared_array->length() == old_shared_array->length());
|
||||
CHECK(old_shared_array->HasFastElements());
|
||||
CHECK(new_shared_array->HasFastElements());
|
||||
int array_length = Smi::cast(old_shared_array->length())->value();
|
||||
int array_length = Smi::ToInt(old_shared_array->length());
|
||||
for (int i = 0; i < array_length; i++) {
|
||||
Handle<Object> old_element;
|
||||
Handle<Object> new_element;
|
||||
|
@ -99,7 +99,7 @@ static MaybeHandle<Object> KeyedGetObjectProperty(Isolate* isolate,
|
||||
Handle<JSObject> js_object = Handle<JSObject>::cast(receiver_obj);
|
||||
ElementsKind elements_kind = js_object->GetElementsKind();
|
||||
if (IsDoubleElementsKind(elements_kind)) {
|
||||
if (Smi::cast(*key_obj)->value() >= js_object->elements()->length()) {
|
||||
if (Smi::ToInt(*key_obj) >= js_object->elements()->length()) {
|
||||
elements_kind = IsHoleyElementsKind(elements_kind) ? HOLEY_ELEMENTS
|
||||
: PACKED_ELEMENTS;
|
||||
JSObject::TransitionElementsKind(js_object, elements_kind);
|
||||
|
@ -39,7 +39,7 @@ int LookupNamedCapture(std::function<bool(String*)> name_matches,
|
||||
String* capture_name = String::cast(capture_name_map->get(name_ix));
|
||||
if (!name_matches(capture_name)) continue;
|
||||
|
||||
maybe_capture_index = Smi::cast(capture_name_map->get(index_ix))->value();
|
||||
maybe_capture_index = Smi::ToInt(capture_name_map->get(index_ix));
|
||||
break;
|
||||
}
|
||||
|
||||
@ -1140,7 +1140,7 @@ Handle<JSObject> ConstructNamedCaptureGroupsObject(
|
||||
const int index_ix = i * 2 + 1;
|
||||
|
||||
Handle<String> capture_name(String::cast(capture_map->get(name_ix)));
|
||||
const int capture_ix = Smi::cast(capture_map->get(index_ix))->value();
|
||||
const int capture_ix = Smi::ToInt(capture_map->get(index_ix));
|
||||
DCHECK(1 <= capture_ix && capture_ix <= capture_count);
|
||||
|
||||
Handle<Object> capture_value(f_get_capture(capture_ix), isolate);
|
||||
@ -1177,7 +1177,7 @@ static Object* SearchRegExpMultiple(Isolate* isolate, Handle<String> subject,
|
||||
int capture_registers = (capture_count + 1) * 2;
|
||||
int32_t* last_match = NewArray<int32_t>(capture_registers);
|
||||
for (int i = 0; i < capture_registers; i++) {
|
||||
last_match[i] = Smi::cast(last_match_cache->get(i))->value();
|
||||
last_match[i] = Smi::ToInt(last_match_cache->get(i));
|
||||
}
|
||||
Handle<FixedArray> cached_fixed_array =
|
||||
Handle<FixedArray>(FixedArray::cast(cached_answer));
|
||||
|
@ -139,7 +139,7 @@ Object* DeclareGlobals(Isolate* isolate, Handle<FixedArray> declarations,
|
||||
int length = declarations->length();
|
||||
FOR_WITH_HANDLE_SCOPE(isolate, int, i = 0, i, i < length, i += 4, {
|
||||
Handle<String> name(String::cast(declarations->get(i)), isolate);
|
||||
FeedbackSlot slot(Smi::cast(declarations->get(i + 1))->value());
|
||||
FeedbackSlot slot(Smi::ToInt(declarations->get(i + 1)));
|
||||
Handle<Object> possibly_literal_slot(declarations->get(i + 2), isolate);
|
||||
Handle<Object> initial_value(declarations->get(i + 3), isolate);
|
||||
|
||||
@ -153,7 +153,7 @@ Object* DeclareGlobals(Isolate* isolate, Handle<FixedArray> declarations,
|
||||
// Copy the function and update its context. Use it as value.
|
||||
Handle<SharedFunctionInfo> shared =
|
||||
Handle<SharedFunctionInfo>::cast(initial_value);
|
||||
FeedbackSlot literals_slot(Smi::cast(*possibly_literal_slot)->value());
|
||||
FeedbackSlot literals_slot(Smi::ToInt(*possibly_literal_slot));
|
||||
Handle<Cell> literals(Cell::cast(feedback_vector->Get(literals_slot)),
|
||||
isolate);
|
||||
Handle<JSFunction> function =
|
||||
|
@ -35,7 +35,7 @@ static inline void StringBuilderConcatHelper(String* special, sinkchar* sink,
|
||||
Object* element = fixed_array->get(i);
|
||||
if (element->IsSmi()) {
|
||||
// Smi encoding of position and length.
|
||||
int encoded_slice = Smi::cast(element)->value();
|
||||
int encoded_slice = Smi::ToInt(element);
|
||||
int pos;
|
||||
int len;
|
||||
if (encoded_slice > 0) {
|
||||
@ -46,7 +46,7 @@ static inline void StringBuilderConcatHelper(String* special, sinkchar* sink,
|
||||
// Position and length encoded in two smis.
|
||||
Object* obj = fixed_array->get(++i);
|
||||
DCHECK(obj->IsSmi());
|
||||
pos = Smi::cast(obj)->value();
|
||||
pos = Smi::ToInt(obj);
|
||||
len = -encoded_slice;
|
||||
}
|
||||
String::WriteToFlat(special, sink + position, pos, pos + len);
|
||||
@ -73,7 +73,7 @@ static inline int StringBuilderConcatLength(int special_length,
|
||||
Object* elt = fixed_array->get(i);
|
||||
if (elt->IsSmi()) {
|
||||
// Smi encoding of position and length.
|
||||
int smi_value = Smi::cast(elt)->value();
|
||||
int smi_value = Smi::ToInt(elt);
|
||||
int pos;
|
||||
int len;
|
||||
if (smi_value > 0) {
|
||||
@ -88,7 +88,7 @@ static inline int StringBuilderConcatLength(int special_length,
|
||||
if (i >= array_length) return -1;
|
||||
Object* next_smi = fixed_array->get(i);
|
||||
if (!next_smi->IsSmi()) return -1;
|
||||
pos = Smi::cast(next_smi)->value();
|
||||
pos = Smi::ToInt(next_smi);
|
||||
if (pos < 0) return -1;
|
||||
}
|
||||
DCHECK(pos >= 0);
|
||||
|
@ -112,7 +112,7 @@ class TransitionArray: public FixedArray {
|
||||
static int NumberOfPrototypeTransitions(FixedArray* proto_transitions) {
|
||||
if (proto_transitions->length() == 0) return 0;
|
||||
Object* raw = proto_transitions->get(kProtoTransitionNumberOfEntriesOffset);
|
||||
return Smi::cast(raw)->value();
|
||||
return Smi::ToInt(raw);
|
||||
}
|
||||
static int NumberOfPrototypeTransitionsForTest(Map* map);
|
||||
|
||||
@ -267,7 +267,7 @@ class TransitionArray: public FixedArray {
|
||||
|
||||
int number_of_transitions() {
|
||||
if (length() < kFirstIndex) return 0;
|
||||
return Smi::cast(get(kTransitionLengthIndex))->value();
|
||||
return Smi::ToInt(get(kTransitionLengthIndex));
|
||||
}
|
||||
|
||||
static inline PropertyDetails GetSimpleTargetDetails(Map* transition) {
|
||||
|
@ -461,8 +461,7 @@ Handle<Code> EnsureExportedLazyDeoptData(Isolate* isolate,
|
||||
DCHECK_IMPLIES(!instance.is_null(),
|
||||
WeakCell::cast(code->deoptimization_data()->get(0))->value() ==
|
||||
*instance);
|
||||
DCHECK_EQ(func_index,
|
||||
Smi::cast(code->deoptimization_data()->get(1))->value());
|
||||
DCHECK_EQ(func_index, Smi::ToInt(code->deoptimization_data()->get(1)));
|
||||
return code;
|
||||
}
|
||||
|
||||
@ -1004,7 +1003,7 @@ MaybeHandle<WasmInstanceObject> InstanceBuilder::Build() {
|
||||
int deopt_len = code->deoptimization_data()->length();
|
||||
if (deopt_len == 0) continue;
|
||||
DCHECK_LE(2, deopt_len);
|
||||
DCHECK_EQ(i, Smi::cast(code->deoptimization_data()->get(1))->value());
|
||||
DCHECK_EQ(i, Smi::ToInt(code->deoptimization_data()->get(1)));
|
||||
code->deoptimization_data()->set(0, *weak_link);
|
||||
// Entries [2, deopt_len) encode information about table exports of this
|
||||
// function. This is rebuilt in {LoadTableSegments}, so reset it here.
|
||||
|
@ -45,7 +45,7 @@ class PatchDirectCallsHelper {
|
||||
FixedArray* deopt_data = code->deoptimization_data();
|
||||
DCHECK_EQ(2, deopt_data->length());
|
||||
WasmCompiledModule* comp_mod = instance->compiled_module();
|
||||
int func_index = Smi::cast(deopt_data->get(1))->value();
|
||||
int func_index = Smi::ToInt(deopt_data->get(1));
|
||||
func_bytes = comp_mod->module_bytes()->GetChars() +
|
||||
comp_mod->module()->functions[func_index].code.offset();
|
||||
}
|
||||
|
@ -1077,7 +1077,7 @@ class CodeMap {
|
||||
imported_functions_ =
|
||||
isolate->global_handles()->Create(*new_imported_functions);
|
||||
}
|
||||
int this_idx = Smi::cast(imported_functions_->get(0))->value() + 1;
|
||||
int this_idx = Smi::ToInt(imported_functions_->get(0)) + 1;
|
||||
if (this_idx == imported_functions_->length()) {
|
||||
Handle<FixedArray> new_imported_functions =
|
||||
isolate->factory()->CopyFixedArrayAndGrow(imported_functions_,
|
||||
@ -2144,7 +2144,7 @@ class ThreadImpl {
|
||||
// TODO(wasm): Implement calling functions of other instances/modules.
|
||||
UNIMPLEMENTED();
|
||||
}
|
||||
int target_func_idx = Smi::cast(deopt_data->get(1))->value();
|
||||
int target_func_idx = Smi::ToInt(deopt_data->get(1));
|
||||
DCHECK_LE(0, target_func_idx);
|
||||
return {ExternalCallResult::INTERNAL,
|
||||
codemap()->GetCode(target_func_idx)};
|
||||
@ -2264,8 +2264,7 @@ class ThreadImpl {
|
||||
if (entry_index >= static_cast<uint32_t>(sig_table->length())) {
|
||||
return {ExternalCallResult::INVALID_FUNC};
|
||||
}
|
||||
int found_sig =
|
||||
Smi::cast(sig_table->get(static_cast<int>(entry_index)))->value();
|
||||
int found_sig = Smi::ToInt(sig_table->get(static_cast<int>(entry_index)));
|
||||
if (static_cast<uint32_t>(found_sig) != canonical_sig_index) {
|
||||
return {ExternalCallResult::SIGNATURE_MISMATCH};
|
||||
}
|
||||
|
@ -375,7 +375,7 @@ void wasm::UpdateDispatchTables(Isolate* isolate,
|
||||
WasmFunction* function, Handle<Code> code) {
|
||||
DCHECK_EQ(0, dispatch_tables->length() % 4);
|
||||
for (int i = 0; i < dispatch_tables->length(); i += 4) {
|
||||
int table_index = Smi::cast(dispatch_tables->get(i + 1))->value();
|
||||
int table_index = Smi::ToInt(dispatch_tables->get(i + 1));
|
||||
Handle<FixedArray> function_table(
|
||||
FixedArray::cast(dispatch_tables->get(i + 2)), isolate);
|
||||
Handle<FixedArray> signature_table(
|
||||
@ -893,7 +893,7 @@ Handle<Code> wasm::CompileLazy(Isolate* isolate) {
|
||||
exp_deopt_data = handle(lazy_compile_code->deoptimization_data(), isolate);
|
||||
auto* weak_cell = WeakCell::cast(exp_deopt_data->get(0));
|
||||
instance = handle(WasmInstanceObject::cast(weak_cell->value()), isolate);
|
||||
func_index = Smi::cast(exp_deopt_data->get(1))->value();
|
||||
func_index = Smi::ToInt(exp_deopt_data->get(1));
|
||||
}
|
||||
it.Advance();
|
||||
// Third frame: The calling wasm code or js-to-wasm wrapper.
|
||||
@ -928,7 +928,7 @@ Handle<Code> wasm::CompileLazy(Isolate* isolate) {
|
||||
for (int idx = 2, end = exp_deopt_data->length(); idx < end; idx += 2) {
|
||||
if (exp_deopt_data->get(idx)->IsUndefined(isolate)) break;
|
||||
FixedArray* exp_table = FixedArray::cast(exp_deopt_data->get(idx));
|
||||
int exp_index = Smi::cast(exp_deopt_data->get(idx + 1))->value();
|
||||
int exp_index = Smi::ToInt(exp_deopt_data->get(idx + 1));
|
||||
DCHECK(exp_table->get(exp_index) == *lazy_compile_code);
|
||||
exp_table->set(exp_index, *compiled_code);
|
||||
}
|
||||
@ -1056,8 +1056,7 @@ Handle<Code> LazyCompilationOrchestrator::CompileLazy(
|
||||
SourcePositionTableIterator source_pos_iterator(
|
||||
caller->SourcePositionTable());
|
||||
DCHECK_EQ(2, caller->deoptimization_data()->length());
|
||||
int caller_func_index =
|
||||
Smi::cast(caller->deoptimization_data()->get(1))->value();
|
||||
int caller_func_index = Smi::ToInt(caller->deoptimization_data()->get(1));
|
||||
const byte* func_bytes =
|
||||
module_bytes->GetChars() +
|
||||
compiled_module->module()->functions[caller_func_index].code.offset();
|
||||
@ -1098,10 +1097,9 @@ Handle<Code> LazyCompilationOrchestrator::CompileLazy(
|
||||
DCHECK_GT(non_compiled_functions.size(), idx);
|
||||
int called_func_index = non_compiled_functions[idx].func_index;
|
||||
// Check that the callee agrees with our assumed called_func_index.
|
||||
DCHECK_IMPLIES(
|
||||
callee->deoptimization_data()->length() > 0,
|
||||
Smi::cast(callee->deoptimization_data()->get(1))->value() ==
|
||||
called_func_index);
|
||||
DCHECK_IMPLIES(callee->deoptimization_data()->length() > 0,
|
||||
Smi::ToInt(callee->deoptimization_data()->get(1)) ==
|
||||
called_func_index);
|
||||
if (is_js_to_wasm) {
|
||||
DCHECK_EQ(func_to_return_idx, called_func_index);
|
||||
} else {
|
||||
|
@ -347,13 +347,11 @@ class WasmCompiledModule : public FixedArray {
|
||||
#define WCM_WASM_OBJECT(TYPE, NAME) \
|
||||
WCM_OBJECT_OR_WEAK(TYPE, NAME, kID_##NAME, TYPE::Is##TYPE(obj), private)
|
||||
|
||||
#define WCM_SMALL_CONST_NUMBER(TYPE, NAME) \
|
||||
public: \
|
||||
TYPE NAME() const { \
|
||||
return static_cast<TYPE>(Smi::cast(get(kID_##NAME))->value()); \
|
||||
} \
|
||||
\
|
||||
private: \
|
||||
#define WCM_SMALL_CONST_NUMBER(TYPE, NAME) \
|
||||
public: \
|
||||
TYPE NAME() const { return static_cast<TYPE>(Smi::ToInt(get(kID_##NAME))); } \
|
||||
\
|
||||
private: \
|
||||
void set_##NAME(TYPE value) { set(kID_##NAME, Smi::FromInt(value)); }
|
||||
|
||||
#define WCM_WEAK_LINK(TYPE, NAME) \
|
||||
|
@ -550,13 +550,13 @@ TEST(GotoIfExceptionMultiple) {
|
||||
result = ft.Call(isolate->factory()->to_string_tag_symbol(),
|
||||
isolate->factory()->undefined_value())
|
||||
.ToHandleChecked();
|
||||
CHECK_EQ(7, Smi::cast(*result)->value());
|
||||
CHECK_EQ(7, Smi::ToInt(*result));
|
||||
|
||||
// First handler throws, second handler returns a number.
|
||||
result = ft.Call(isolate->factory()->to_string_tag_symbol(),
|
||||
isolate->factory()->to_primitive_symbol())
|
||||
.ToHandleChecked();
|
||||
CHECK_EQ(7 & ~2, Smi::cast(*result)->value());
|
||||
CHECK_EQ(7 & ~2, Smi::ToInt(*result));
|
||||
|
||||
// First handler throws, second handler throws, third handler returns thrown
|
||||
// value.
|
||||
|
@ -67,7 +67,7 @@ TEST(RunStringLengthStub) {
|
||||
Handle<Object> vector = ft.Val(0.0);
|
||||
Handle<Object> result =
|
||||
ft.Call(receiverArg, nameArg, slot, vector).ToHandleChecked();
|
||||
CHECK_EQ(static_cast<int>(strlen(testString)), Smi::cast(*result)->value());
|
||||
CHECK_EQ(static_cast<int>(strlen(testString)), Smi::ToInt(*result));
|
||||
}
|
||||
|
||||
|
||||
|
@ -5198,7 +5198,7 @@ TEST(PreprocessStackTrace) {
|
||||
CHECK(pos->IsSmi());
|
||||
|
||||
Handle<JSArray> stack_trace_array = Handle<JSArray>::cast(stack_trace);
|
||||
int array_length = Smi::cast(stack_trace_array->length())->value();
|
||||
int array_length = Smi::ToInt(stack_trace_array->length());
|
||||
for (int i = 0; i < array_length; i++) {
|
||||
Handle<Object> element =
|
||||
Object::GetElement(isolate, stack_trace, i).ToHandleChecked();
|
||||
|
@ -1477,7 +1477,7 @@ TEST(InterpreterJumps) {
|
||||
InterpreterTester tester(isolate, bytecode_array, metadata);
|
||||
auto callable = tester.GetCallable<>();
|
||||
Handle<Object> return_value = callable().ToHandleChecked();
|
||||
CHECK_EQ(Smi::cast(*return_value)->value(), 7);
|
||||
CHECK_EQ(Smi::ToInt(*return_value), 7);
|
||||
}
|
||||
|
||||
TEST(InterpreterConditionalJumps) {
|
||||
@ -1526,7 +1526,7 @@ TEST(InterpreterConditionalJumps) {
|
||||
InterpreterTester tester(isolate, bytecode_array, metadata);
|
||||
auto callable = tester.GetCallable<>();
|
||||
Handle<Object> return_value = callable().ToHandleChecked();
|
||||
CHECK_EQ(Smi::cast(*return_value)->value(), 7);
|
||||
CHECK_EQ(Smi::ToInt(*return_value), 7);
|
||||
}
|
||||
|
||||
TEST(InterpreterConditionalJumps2) {
|
||||
@ -1576,7 +1576,7 @@ TEST(InterpreterConditionalJumps2) {
|
||||
InterpreterTester tester(isolate, bytecode_array, metadata);
|
||||
auto callable = tester.GetCallable<>();
|
||||
Handle<Object> return_value = callable().ToHandleChecked();
|
||||
CHECK_EQ(Smi::cast(*return_value)->value(), 7);
|
||||
CHECK_EQ(Smi::ToInt(*return_value), 7);
|
||||
}
|
||||
|
||||
TEST(InterpreterJumpConstantWith16BitOperand) {
|
||||
|
@ -2860,7 +2860,7 @@ void GlobalProxyIdentityHash(bool set_in_js) {
|
||||
CompileRun("var m = new Set(); m.add(global);");
|
||||
i::Object* original_hash = i_global_proxy->GetHash();
|
||||
CHECK(original_hash->IsSmi());
|
||||
hash1 = i::Smi::cast(original_hash)->value();
|
||||
hash1 = i::Smi::ToInt(original_hash);
|
||||
} else {
|
||||
hash1 = i::Object::GetOrCreateHash(i_isolate, i_global_proxy)->value();
|
||||
}
|
||||
@ -16166,7 +16166,7 @@ static void CheckElementValue(i::Isolate* isolate,
|
||||
int offset) {
|
||||
i::Object* element =
|
||||
*i::Object::GetElement(isolate, obj, offset).ToHandleChecked();
|
||||
CHECK_EQ(expected, i::Smi::cast(element)->value());
|
||||
CHECK_EQ(expected, i::Smi::ToInt(element));
|
||||
}
|
||||
|
||||
|
||||
|
@ -30,20 +30,20 @@ TEST(ArrayList) {
|
||||
CHECK_EQ(0, array->Length());
|
||||
array = ArrayList::Add(array, handle(Smi::FromInt(100), isolate));
|
||||
CHECK_EQ(1, array->Length());
|
||||
CHECK_EQ(100, Smi::cast(array->Get(0))->value());
|
||||
CHECK_EQ(100, Smi::ToInt(array->Get(0)));
|
||||
array = ArrayList::Add(array, handle(Smi::FromInt(200), isolate),
|
||||
handle(Smi::FromInt(300), isolate));
|
||||
CHECK_EQ(3, array->Length());
|
||||
CHECK_EQ(100, Smi::cast(array->Get(0))->value());
|
||||
CHECK_EQ(200, Smi::cast(array->Get(1))->value());
|
||||
CHECK_EQ(300, Smi::cast(array->Get(2))->value());
|
||||
CHECK_EQ(100, Smi::ToInt(array->Get(0)));
|
||||
CHECK_EQ(200, Smi::ToInt(array->Get(1)));
|
||||
CHECK_EQ(300, Smi::ToInt(array->Get(2)));
|
||||
array->Set(2, Smi::FromInt(400));
|
||||
CHECK_EQ(400, Smi::cast(array->Get(2))->value());
|
||||
CHECK_EQ(400, Smi::ToInt(array->Get(2)));
|
||||
array->Clear(2, isolate->heap()->undefined_value());
|
||||
array->SetLength(2);
|
||||
CHECK_EQ(2, array->Length());
|
||||
CHECK_EQ(100, Smi::cast(array->Get(0))->value());
|
||||
CHECK_EQ(200, Smi::cast(array->Get(1))->value());
|
||||
CHECK_EQ(100, Smi::ToInt(array->Get(0)));
|
||||
CHECK_EQ(200, Smi::ToInt(array->Get(1)));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
@ -501,7 +501,7 @@ void TestEntryToIndex() {
|
||||
entry = entry * 1.01 + 1) {
|
||||
Handle<Object> result =
|
||||
ft.Call(handle(Smi::FromInt(entry), isolate)).ToHandleChecked();
|
||||
CHECK_EQ(Dictionary::EntryToIndex(entry), Smi::cast(*result)->value());
|
||||
CHECK_EQ(Dictionary::EntryToIndex(entry), Smi::ToInt(*result));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1826,7 +1826,7 @@ class AppendJSArrayCodeStubAssembler : public CodeStubAssembler {
|
||||
|
||||
CHECK_EQ(kind_, array->GetElementsKind());
|
||||
CHECK_EQ(result_size, Handle<Smi>::cast(result)->value());
|
||||
CHECK_EQ(result_size, Smi::cast(array->length())->value());
|
||||
CHECK_EQ(result_size, Smi::ToInt(array->length()));
|
||||
Object* obj = *JSObject::GetElement(isolate, array, 2).ToHandleChecked();
|
||||
CHECK_EQ(result_size < 3 ? isolate->heap()->undefined_value() : o1, obj);
|
||||
obj = *JSObject::GetElement(isolate, array, 3).ToHandleChecked();
|
||||
|
@ -4919,7 +4919,7 @@ TEST(DebugScriptLineEndsAreAscending) {
|
||||
|
||||
int prev_end = -1;
|
||||
for (int j = 0; j < ends->length(); j++) {
|
||||
const int curr_end = v8::internal::Smi::cast(ends->get(j))->value();
|
||||
const int curr_end = v8::internal::Smi::ToInt(ends->get(j));
|
||||
CHECK_GT(curr_end, prev_end);
|
||||
prev_end = curr_end;
|
||||
}
|
||||
|
@ -193,7 +193,7 @@ class ObjectHashTableTest: public ObjectHashTable {
|
||||
|
||||
int lookup(int key) {
|
||||
Handle<Object> key_obj(Smi::FromInt(key), GetIsolate());
|
||||
return Smi::cast(Lookup(key_obj))->value();
|
||||
return Smi::ToInt(Lookup(key_obj));
|
||||
}
|
||||
|
||||
int capacity() {
|
||||
|
@ -207,7 +207,7 @@ TEST(JSArrayAddingProperties) {
|
||||
CHECK_EQ(PACKED_SMI_ELEMENTS, previous_map->elements_kind());
|
||||
CHECK(EQUALS(array->properties(), empty_fixed_array));
|
||||
CHECK(EQUALS(array->elements(), empty_fixed_array));
|
||||
CHECK_EQ(0, Smi::cast(array->length())->value());
|
||||
CHECK_EQ(0, Smi::ToInt(array->length()));
|
||||
|
||||
// for the default constructor function no in-object properties are reserved
|
||||
// hence adding a single property will initialize the property-array
|
||||
@ -219,7 +219,7 @@ TEST(JSArrayAddingProperties) {
|
||||
CHECK_EQ(PACKED_SMI_ELEMENTS, array->map()->elements_kind());
|
||||
CHECK_LE(1, array->properties()->length());
|
||||
CHECK(EQUALS(array->elements(), empty_fixed_array));
|
||||
CHECK_EQ(0, Smi::cast(array->length())->value());
|
||||
CHECK_EQ(0, Smi::ToInt(array->length()));
|
||||
}
|
||||
|
||||
|
||||
@ -239,7 +239,7 @@ TEST(JSArrayAddingElements) {
|
||||
CHECK_EQ(PACKED_SMI_ELEMENTS, previous_map->elements_kind());
|
||||
CHECK(EQUALS(array->properties(), empty_fixed_array));
|
||||
CHECK(EQUALS(array->elements(), empty_fixed_array));
|
||||
CHECK_EQ(0, Smi::cast(array->length())->value());
|
||||
CHECK_EQ(0, Smi::ToInt(array->length()));
|
||||
|
||||
// Adding an indexed element initializes the elements array
|
||||
name = MakeString("0");
|
||||
@ -250,7 +250,7 @@ TEST(JSArrayAddingElements) {
|
||||
CHECK_EQ(PACKED_SMI_ELEMENTS, array->map()->elements_kind());
|
||||
CHECK(EQUALS(array->properties(), empty_fixed_array));
|
||||
CHECK_LE(1, array->elements()->length());
|
||||
CHECK_EQ(1, Smi::cast(array->length())->value());
|
||||
CHECK_EQ(1, Smi::ToInt(array->length()));
|
||||
|
||||
// Adding more consecutive elements without a change in the backing store
|
||||
int non_dict_backing_store_limit = 100;
|
||||
@ -264,7 +264,7 @@ TEST(JSArrayAddingElements) {
|
||||
CHECK_EQ(PACKED_SMI_ELEMENTS, array->map()->elements_kind());
|
||||
CHECK(EQUALS(array->properties(), empty_fixed_array));
|
||||
CHECK_LE(non_dict_backing_store_limit, array->elements()->length());
|
||||
CHECK_EQ(non_dict_backing_store_limit, Smi::cast(array->length())->value());
|
||||
CHECK_EQ(non_dict_backing_store_limit, Smi::ToInt(array->length()));
|
||||
|
||||
// Adding an element at an very large index causes a change to
|
||||
// DICTIONARY_ELEMENTS
|
||||
@ -278,7 +278,7 @@ TEST(JSArrayAddingElements) {
|
||||
CHECK(EQUALS(array->properties(), empty_fixed_array));
|
||||
CHECK_LE(non_dict_backing_store_limit, array->elements()->length());
|
||||
CHECK_LE(array->elements()->length(), index);
|
||||
CHECK_EQ(index + 1, Smi::cast(array->length())->value());
|
||||
CHECK_EQ(index + 1, Smi::ToInt(array->length()));
|
||||
}
|
||||
|
||||
|
||||
@ -297,7 +297,7 @@ TEST(JSArrayAddingElementsGeneralizingiFastSmiElements) {
|
||||
factory->NewJSArray(ElementsKind::PACKED_SMI_ELEMENTS, 0, 0);
|
||||
Handle<Map> previous_map(array->map());
|
||||
CHECK_EQ(PACKED_SMI_ELEMENTS, previous_map->elements_kind());
|
||||
CHECK_EQ(0, Smi::cast(array->length())->value());
|
||||
CHECK_EQ(0, Smi::ToInt(array->length()));
|
||||
|
||||
// `array[0] = smi_value` doesn't change the elements_kind
|
||||
name = MakeString("0");
|
||||
@ -307,14 +307,14 @@ TEST(JSArrayAddingElementsGeneralizingiFastSmiElements) {
|
||||
// no change in elements_kind => no map transition
|
||||
CHECK_EQ(array->map(), *previous_map);
|
||||
CHECK_EQ(PACKED_SMI_ELEMENTS, array->map()->elements_kind());
|
||||
CHECK_EQ(1, Smi::cast(array->length())->value());
|
||||
CHECK_EQ(1, Smi::ToInt(array->length()));
|
||||
|
||||
// `delete array[0]` does not alter length, but changes the elments_kind
|
||||
name = MakeString("0");
|
||||
CHECK(JSReceiver::DeletePropertyOrElement(array, name).FromMaybe(false));
|
||||
CHECK_NE(array->map(), *previous_map);
|
||||
CHECK_EQ(HOLEY_SMI_ELEMENTS, array->map()->elements_kind());
|
||||
CHECK_EQ(1, Smi::cast(array->length())->value());
|
||||
CHECK_EQ(1, Smi::ToInt(array->length()));
|
||||
previous_map = handle(array->map());
|
||||
|
||||
// add a couple of elements again
|
||||
@ -328,7 +328,7 @@ TEST(JSArrayAddingElementsGeneralizingiFastSmiElements) {
|
||||
.Check();
|
||||
CHECK_EQ(array->map(), *previous_map);
|
||||
CHECK_EQ(HOLEY_SMI_ELEMENTS, array->map()->elements_kind());
|
||||
CHECK_EQ(2, Smi::cast(array->length())->value());
|
||||
CHECK_EQ(2, Smi::ToInt(array->length()));
|
||||
|
||||
// Adding a string to the array changes from FAST_HOLEY_SMI to FAST_HOLEY
|
||||
name = MakeString("0");
|
||||
@ -337,7 +337,7 @@ TEST(JSArrayAddingElementsGeneralizingiFastSmiElements) {
|
||||
.Check();
|
||||
CHECK_NE(array->map(), *previous_map);
|
||||
CHECK_EQ(HOLEY_ELEMENTS, array->map()->elements_kind());
|
||||
CHECK_EQ(2, Smi::cast(array->length())->value());
|
||||
CHECK_EQ(2, Smi::ToInt(array->length()));
|
||||
previous_map = handle(array->map());
|
||||
|
||||
// We don't transition back to FAST_SMI even if we remove the string
|
||||
@ -370,7 +370,7 @@ TEST(JSArrayAddingElementsGeneralizingFastElements) {
|
||||
factory->NewJSArray(ElementsKind::PACKED_ELEMENTS, 0, 0);
|
||||
Handle<Map> previous_map(array->map());
|
||||
CHECK_EQ(PACKED_ELEMENTS, previous_map->elements_kind());
|
||||
CHECK_EQ(0, Smi::cast(array->length())->value());
|
||||
CHECK_EQ(0, Smi::ToInt(array->length()));
|
||||
|
||||
// `array[0] = smi_value` doesn't change the elements_kind
|
||||
name = MakeString("0");
|
||||
@ -380,14 +380,14 @@ TEST(JSArrayAddingElementsGeneralizingFastElements) {
|
||||
// no change in elements_kind => no map transition
|
||||
CHECK_EQ(array->map(), *previous_map);
|
||||
CHECK_EQ(PACKED_ELEMENTS, array->map()->elements_kind());
|
||||
CHECK_EQ(1, Smi::cast(array->length())->value());
|
||||
CHECK_EQ(1, Smi::ToInt(array->length()));
|
||||
|
||||
// `delete array[0]` does not alter length, but changes the elments_kind
|
||||
name = MakeString("0");
|
||||
CHECK(JSReceiver::DeletePropertyOrElement(array, name).FromMaybe(false));
|
||||
CHECK_NE(array->map(), *previous_map);
|
||||
CHECK_EQ(HOLEY_ELEMENTS, array->map()->elements_kind());
|
||||
CHECK_EQ(1, Smi::cast(array->length())->value());
|
||||
CHECK_EQ(1, Smi::ToInt(array->length()));
|
||||
previous_map = handle(array->map());
|
||||
|
||||
// add a couple of elements, elements_kind stays HOLEY
|
||||
@ -401,7 +401,7 @@ TEST(JSArrayAddingElementsGeneralizingFastElements) {
|
||||
.Check();
|
||||
CHECK_EQ(array->map(), *previous_map);
|
||||
CHECK_EQ(HOLEY_ELEMENTS, array->map()->elements_kind());
|
||||
CHECK_EQ(2, Smi::cast(array->length())->value());
|
||||
CHECK_EQ(2, Smi::ToInt(array->length()));
|
||||
}
|
||||
|
||||
|
||||
@ -427,7 +427,7 @@ TEST(JSArrayAddingElementsGeneralizingiFastDoubleElements) {
|
||||
.Check();
|
||||
CHECK_NE(array->map(), *previous_map);
|
||||
CHECK_EQ(PACKED_DOUBLE_ELEMENTS, array->map()->elements_kind());
|
||||
CHECK_EQ(1, Smi::cast(array->length())->value());
|
||||
CHECK_EQ(1, Smi::ToInt(array->length()));
|
||||
previous_map = handle(array->map());
|
||||
|
||||
// `array[1] = value_smi` doesn't alter the |elements_kind|
|
||||
@ -437,14 +437,14 @@ TEST(JSArrayAddingElementsGeneralizingiFastDoubleElements) {
|
||||
.Check();
|
||||
CHECK_EQ(array->map(), *previous_map);
|
||||
CHECK_EQ(PACKED_DOUBLE_ELEMENTS, array->map()->elements_kind());
|
||||
CHECK_EQ(2, Smi::cast(array->length())->value());
|
||||
CHECK_EQ(2, Smi::ToInt(array->length()));
|
||||
|
||||
// `delete array[0]` does not alter length, but changes the elments_kind
|
||||
name = MakeString("0");
|
||||
CHECK(JSReceiver::DeletePropertyOrElement(array, name).FromMaybe(false));
|
||||
CHECK_NE(array->map(), *previous_map);
|
||||
CHECK_EQ(HOLEY_DOUBLE_ELEMENTS, array->map()->elements_kind());
|
||||
CHECK_EQ(2, Smi::cast(array->length())->value());
|
||||
CHECK_EQ(2, Smi::ToInt(array->length()));
|
||||
previous_map = handle(array->map());
|
||||
|
||||
// filling the hole `array[0] = value_smi` again doesn't transition back
|
||||
@ -454,7 +454,7 @@ TEST(JSArrayAddingElementsGeneralizingiFastDoubleElements) {
|
||||
.Check();
|
||||
CHECK_EQ(array->map(), *previous_map);
|
||||
CHECK_EQ(HOLEY_DOUBLE_ELEMENTS, array->map()->elements_kind());
|
||||
CHECK_EQ(2, Smi::cast(array->length())->value());
|
||||
CHECK_EQ(2, Smi::ToInt(array->length()));
|
||||
|
||||
// Adding a string to the array changes to elements_kind PACKED_ELEMENTS
|
||||
name = MakeString("1");
|
||||
@ -463,7 +463,7 @@ TEST(JSArrayAddingElementsGeneralizingiFastDoubleElements) {
|
||||
.Check();
|
||||
CHECK_NE(array->map(), *previous_map);
|
||||
CHECK_EQ(HOLEY_ELEMENTS, array->map()->elements_kind());
|
||||
CHECK_EQ(2, Smi::cast(array->length())->value());
|
||||
CHECK_EQ(2, Smi::ToInt(array->length()));
|
||||
previous_map = handle(array->map());
|
||||
|
||||
// Adding a double doesn't change the map
|
||||
|
@ -555,7 +555,7 @@ TEST(ReconfigureAccessorToNonExistingDataFieldHeavy) {
|
||||
FieldIndex index = FieldIndex::ForDescriptor(obj->map(), 0);
|
||||
Object* the_value = obj->RawFastPropertyAt(index);
|
||||
CHECK(the_value->IsSmi());
|
||||
CHECK_EQ(42, Smi::cast(the_value)->value());
|
||||
CHECK_EQ(42, Smi::ToInt(the_value));
|
||||
}
|
||||
|
||||
|
||||
|
@ -149,7 +149,7 @@ class IdentityMapTester : public HandleAndZoneScope {
|
||||
void SimulateGCByIncrementingSmisBy(int shift) {
|
||||
for (int i = 0; i < map.capacity_; i++) {
|
||||
if (map.keys_[i]->IsSmi()) {
|
||||
map.keys_[i] = Smi::FromInt(Smi::cast(map.keys_[i])->value() + shift);
|
||||
map.keys_[i] = Smi::FromInt(Smi::ToInt(map.keys_[i]) + shift);
|
||||
}
|
||||
}
|
||||
map.gc_counter_ = -1;
|
||||
|
@ -80,7 +80,7 @@ void EXPECT_CALL(double expected, Handle<JSFunction> jsfunc,
|
||||
CHECK(!retval.is_null());
|
||||
Handle<Object> result = retval.ToHandleChecked();
|
||||
if (result->IsSmi()) {
|
||||
CHECK_EQ(expected, Smi::cast(*result)->value());
|
||||
CHECK_EQ(expected, Smi::ToInt(*result));
|
||||
} else {
|
||||
CHECK(result->IsHeapNumber());
|
||||
CheckFloatEq(expected, HeapNumber::cast(*result)->value());
|
||||
|
@ -141,7 +141,7 @@ int32_t CallWasmFunctionForTesting(Isolate* isolate, Handle<JSObject> instance,
|
||||
}
|
||||
Handle<Object> result = retval.ToHandleChecked();
|
||||
if (result->IsSmi()) {
|
||||
return Smi::cast(*result)->value();
|
||||
return Smi::ToInt(*result);
|
||||
}
|
||||
if (result->IsHeapNumber()) {
|
||||
return static_cast<int32_t>(HeapNumber::cast(*result)->value());
|
||||
|
Loading…
Reference in New Issue
Block a user