Return MaybeHandle from Object::ToSmi.
R=ulan@chromium.org Review URL: https://codereview.chromium.org/260083011 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@21047 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
parent
7b1e830489
commit
99d9712bb0
@ -1848,9 +1848,10 @@ MaybeHandle<Object> ElementsAccessorBase<ElementsAccessorSubclass,
|
||||
Handle<JSArray> array = Handle<JSArray>::cast(obj);
|
||||
|
||||
// Fast case: The new length fits into a Smi.
|
||||
Handle<Object> smi_length = Object::ToSmi(isolate, length);
|
||||
Handle<Object> smi_length;
|
||||
|
||||
if (!smi_length.is_null() && smi_length->IsSmi()) {
|
||||
if (Object::ToSmi(isolate, length).ToHandle(&smi_length) &&
|
||||
smi_length->IsSmi()) {
|
||||
const int value = Handle<Smi>::cast(smi_length)->value();
|
||||
if (value >= 0) {
|
||||
Handle<Object> new_length = ElementsAccessorSubclass::
|
||||
|
@ -1614,9 +1614,8 @@ bool IsOutOfBoundsAccess(Handle<JSObject> receiver,
|
||||
KeyedAccessStoreMode KeyedStoreIC::GetStoreMode(Handle<JSObject> receiver,
|
||||
Handle<Object> key,
|
||||
Handle<Object> value) {
|
||||
Handle<Object> smi_key = Object::ToSmi(isolate(), key);
|
||||
ASSERT(!smi_key.is_null() && smi_key->IsSmi());
|
||||
int index = Handle<Smi>::cast(smi_key)->value();
|
||||
Handle<Smi> smi_key = Object::ToSmi(isolate(), key).ToHandleChecked();
|
||||
int index = smi_key->value();
|
||||
bool oob_access = IsOutOfBoundsAccess(receiver, index);
|
||||
// Don't consider this a growing store if the store would send the receiver to
|
||||
// dictionary mode.
|
||||
|
@ -1037,8 +1037,8 @@ bool Object::IsNaN() {
|
||||
}
|
||||
|
||||
|
||||
Handle<Object> Object::ToSmi(Isolate* isolate, Handle<Object> object) {
|
||||
if (object->IsSmi()) return object;
|
||||
MaybeHandle<Smi> Object::ToSmi(Isolate* isolate, Handle<Object> object) {
|
||||
if (object->IsSmi()) return Handle<Smi>::cast(object);
|
||||
if (object->IsHeapNumber()) {
|
||||
double value = Handle<HeapNumber>::cast(object)->value();
|
||||
int int_value = FastD2I(value);
|
||||
@ -1046,7 +1046,7 @@ Handle<Object> Object::ToSmi(Isolate* isolate, Handle<Object> object) {
|
||||
return handle(Smi::FromInt(int_value), isolate);
|
||||
}
|
||||
}
|
||||
return Handle<Object>();
|
||||
return Handle<Smi>();
|
||||
}
|
||||
|
||||
|
||||
|
@ -1490,9 +1490,8 @@ class Object : public MaybeObject {
|
||||
Handle<Context> context);
|
||||
|
||||
// Converts this to a Smi if possible.
|
||||
// Failure is returned otherwise.
|
||||
static MUST_USE_RESULT inline Handle<Object> ToSmi(Isolate* isolate,
|
||||
Handle<Object> object);
|
||||
static MUST_USE_RESULT inline MaybeHandle<Smi> ToSmi(Isolate* isolate,
|
||||
Handle<Object> object);
|
||||
|
||||
void Lookup(Name* name, LookupResult* result);
|
||||
|
||||
|
@ -1078,7 +1078,7 @@ TEST(CachedHashOverflow) {
|
||||
CHECK_EQ(results[i]->IsUndefined(), result->IsUndefined());
|
||||
CHECK_EQ(results[i]->IsNumber(), result->IsNumber());
|
||||
if (result->IsNumber()) {
|
||||
CHECK_EQ(Handle<Smi>::cast(Object::ToSmi(isolate, results[i]))->value(),
|
||||
CHECK_EQ(Object::ToSmi(isolate, results[i]).ToHandleChecked()->value(),
|
||||
result->ToInt32()->Value());
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user