Handlification in ic.cc

R=yangguo@chromium.org

Review URL: https://codereview.chromium.org/235453010

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@20720 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 8eaff70b
...@@ -375,22 +375,22 @@ void IC::UpdateState(Handle<Object> receiver, Handle<Object> name) { ...@@ -375,22 +375,22 @@ void IC::UpdateState(Handle<Object> receiver, Handle<Object> name) {
} }
Failure* IC::TypeError(const char* type, MaybeHandle<Object> IC::TypeError(const char* type,
Handle<Object> object, Handle<Object> object,
Handle<Object> key) { Handle<Object> key) {
HandleScope scope(isolate()); HandleScope scope(isolate());
Handle<Object> args[2] = { key, object }; Handle<Object> args[2] = { key, object };
Handle<Object> error = isolate()->factory()->NewTypeError( Handle<Object> error = isolate()->factory()->NewTypeError(
type, HandleVector(args, 2)); type, HandleVector(args, 2));
return isolate()->Throw(*error); return isolate()->Throw<Object>(error);
} }
Failure* IC::ReferenceError(const char* type, Handle<String> name) { MaybeHandle<Object> IC::ReferenceError(const char* type, Handle<String> name) {
HandleScope scope(isolate()); HandleScope scope(isolate());
Handle<Object> error = isolate()->factory()->NewReferenceError( Handle<Object> error = isolate()->factory()->NewReferenceError(
type, HandleVector(&name, 1)); type, HandleVector(&name, 1));
return isolate()->Throw(*error); return isolate()->Throw<Object>(error);
} }
...@@ -572,8 +572,7 @@ static bool MigrateDeprecated(Handle<Object> object) { ...@@ -572,8 +572,7 @@ static bool MigrateDeprecated(Handle<Object> object) {
} }
MaybeObject* LoadIC::Load(Handle<Object> object, MaybeHandle<Object> LoadIC::Load(Handle<Object> object, Handle<String> name) {
Handle<String> name) {
// If the object is undefined or null it's illegal to try to get any // If the object is undefined or null it's illegal to try to get any
// of its properties; throw a TypeError in that case. // of its properties; throw a TypeError in that case.
if (object->IsUndefined() || object->IsNull()) { if (object->IsUndefined() || object->IsNull()) {
...@@ -599,7 +598,7 @@ MaybeObject* LoadIC::Load(Handle<Object> object, ...@@ -599,7 +598,7 @@ MaybeObject* LoadIC::Load(Handle<Object> object,
set_target(*stub); set_target(*stub);
if (FLAG_trace_ic) PrintF("[LoadIC : +#prototype /function]\n"); if (FLAG_trace_ic) PrintF("[LoadIC : +#prototype /function]\n");
} }
return *Accessors::FunctionGetPrototype(Handle<JSFunction>::cast(object)); return Accessors::FunctionGetPrototype(Handle<JSFunction>::cast(object));
} }
} }
...@@ -610,10 +609,12 @@ MaybeObject* LoadIC::Load(Handle<Object> object, ...@@ -610,10 +609,12 @@ MaybeObject* LoadIC::Load(Handle<Object> object,
// Rewrite to the generic keyed load stub. // Rewrite to the generic keyed load stub.
if (FLAG_use_ic) set_target(*generic_stub()); if (FLAG_use_ic) set_target(*generic_stub());
Handle<Object> result; Handle<Object> result;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION( ASSIGN_RETURN_ON_EXCEPTION(
isolate(), result, isolate(),
Runtime::GetElementOrCharAt(isolate(), object, index)); result,
return *result; Runtime::GetElementOrCharAt(isolate(), object, index),
Object);
return result;
} }
bool use_ic = MigrateDeprecated(object) ? false : FLAG_use_ic; bool use_ic = MigrateDeprecated(object) ? false : FLAG_use_ic;
...@@ -636,16 +637,18 @@ MaybeObject* LoadIC::Load(Handle<Object> object, ...@@ -636,16 +637,18 @@ MaybeObject* LoadIC::Load(Handle<Object> object,
PropertyAttributes attr; PropertyAttributes attr;
// Get the property. // Get the property.
Handle<Object> result; Handle<Object> result;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION( ASSIGN_RETURN_ON_EXCEPTION(
isolate(), result, isolate(),
Object::GetProperty(object, object, &lookup, name, &attr)); result,
Object::GetProperty(object, object, &lookup, name, &attr),
Object);
// If the property is not present, check if we need to throw an exception. // If the property is not present, check if we need to throw an exception.
if ((lookup.IsInterceptor() || lookup.IsHandler()) && if ((lookup.IsInterceptor() || lookup.IsHandler()) &&
attr == ABSENT && IsUndeclaredGlobal(object)) { attr == ABSENT && IsUndeclaredGlobal(object)) {
return ReferenceError("not_defined", name); return ReferenceError("not_defined", name);
} }
return *result; return result;
} }
...@@ -1121,15 +1124,19 @@ Handle<Code> KeyedLoadIC::LoadElementStub(Handle<JSObject> receiver) { ...@@ -1121,15 +1124,19 @@ Handle<Code> KeyedLoadIC::LoadElementStub(Handle<JSObject> receiver) {
} }
MaybeObject* KeyedLoadIC::Load(Handle<Object> object, Handle<Object> key) { MaybeHandle<Object> KeyedLoadIC::Load(Handle<Object> object,
Handle<Object> key) {
if (MigrateDeprecated(object)) { if (MigrateDeprecated(object)) {
Handle<Object> result; Handle<Object> result;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION( ASSIGN_RETURN_ON_EXCEPTION(
isolate(), result, Runtime::GetObjectProperty(isolate(), object, key)); isolate(),
return *result; result,
Runtime::GetObjectProperty(isolate(), object, key),
Object);
return result;
} }
MaybeObject* maybe_object = NULL; Handle<Object> load_handle;
Handle<Code> stub = generic_stub(); Handle<Code> stub = generic_stub();
// Check for non-string values that can be converted into an // Check for non-string values that can be converted into an
...@@ -1137,8 +1144,11 @@ MaybeObject* KeyedLoadIC::Load(Handle<Object> object, Handle<Object> key) { ...@@ -1137,8 +1144,11 @@ MaybeObject* KeyedLoadIC::Load(Handle<Object> object, Handle<Object> key) {
key = TryConvertKey(key, isolate()); key = TryConvertKey(key, isolate());
if (key->IsInternalizedString()) { if (key->IsInternalizedString()) {
maybe_object = LoadIC::Load(object, Handle<String>::cast(key)); ASSIGN_RETURN_ON_EXCEPTION(
if (maybe_object->IsFailure()) return maybe_object; isolate(),
load_handle,
LoadIC::Load(object, Handle<String>::cast(key)),
Object);
} else if (FLAG_use_ic && !object->IsAccessCheckNeeded()) { } else if (FLAG_use_ic && !object->IsAccessCheckNeeded()) {
if (object->IsString() && key->IsNumber()) { if (object->IsString() && key->IsNumber()) {
if (state() == UNINITIALIZED) stub = string_stub(); if (state() == UNINITIALIZED) stub = string_stub();
...@@ -1164,11 +1174,14 @@ MaybeObject* KeyedLoadIC::Load(Handle<Object> object, Handle<Object> key) { ...@@ -1164,11 +1174,14 @@ MaybeObject* KeyedLoadIC::Load(Handle<Object> object, Handle<Object> key) {
TRACE_IC("LoadIC", key); TRACE_IC("LoadIC", key);
} }
if (maybe_object != NULL) return maybe_object; if (!load_handle.is_null()) return load_handle;
Handle<Object> result; Handle<Object> result;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION( ASSIGN_RETURN_ON_EXCEPTION(
isolate(), result, Runtime::GetObjectProperty(isolate(), object, key)); isolate(),
return *result; result,
Runtime::GetObjectProperty(isolate(), object, key),
Object);
return result;
} }
...@@ -1232,17 +1245,19 @@ static bool LookupForWrite(Handle<JSObject> receiver, ...@@ -1232,17 +1245,19 @@ static bool LookupForWrite(Handle<JSObject> receiver,
} }
MaybeObject* StoreIC::Store(Handle<Object> object, MaybeHandle<Object> StoreIC::Store(Handle<Object> object,
Handle<String> name, Handle<String> name,
Handle<Object> value, Handle<Object> value,
JSReceiver::StoreFromKeyed store_mode) { JSReceiver::StoreFromKeyed store_mode) {
if (MigrateDeprecated(object) || object->IsJSProxy()) { if (MigrateDeprecated(object) || object->IsJSProxy()) {
Handle<JSReceiver> receiver = Handle<JSReceiver>::cast(object); Handle<JSReceiver> receiver = Handle<JSReceiver>::cast(object);
Handle<Object> result; Handle<Object> result;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION( ASSIGN_RETURN_ON_EXCEPTION(
isolate(), result, isolate(),
JSReceiver::SetProperty(receiver, name, value, NONE, strict_mode())); result,
return *result; JSReceiver::SetProperty(receiver, name, value, NONE, strict_mode()),
Object);
return result;
} }
// If the object is undefined or null it's illegal to try to set any // If the object is undefined or null it's illegal to try to set any
...@@ -1259,7 +1274,7 @@ MaybeObject* StoreIC::Store(Handle<Object> object, ...@@ -1259,7 +1274,7 @@ MaybeObject* StoreIC::Store(Handle<Object> object,
// Ignore other stores where the receiver is not a JSObject. // Ignore other stores where the receiver is not a JSObject.
// TODO(1475): Must check prototype chains of object wrappers. // TODO(1475): Must check prototype chains of object wrappers.
if (!object->IsJSObject()) return *value; if (!object->IsJSObject()) return value;
Handle<JSObject> receiver = Handle<JSObject>::cast(object); Handle<JSObject> receiver = Handle<JSObject>::cast(object);
...@@ -1267,20 +1282,24 @@ MaybeObject* StoreIC::Store(Handle<Object> object, ...@@ -1267,20 +1282,24 @@ MaybeObject* StoreIC::Store(Handle<Object> object,
uint32_t index; uint32_t index;
if (name->AsArrayIndex(&index)) { if (name->AsArrayIndex(&index)) {
Handle<Object> result; Handle<Object> result;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION( ASSIGN_RETURN_ON_EXCEPTION(
isolate(), result, isolate(),
JSObject::SetElement(receiver, index, value, NONE, strict_mode())); result,
return *value; JSObject::SetElement(receiver, index, value, NONE, strict_mode()),
Object);
return value;
} }
// Observed objects are always modified through the runtime. // Observed objects are always modified through the runtime.
if (receiver->map()->is_observed()) { if (receiver->map()->is_observed()) {
Handle<Object> result; Handle<Object> result;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION( ASSIGN_RETURN_ON_EXCEPTION(
isolate(), result, isolate(),
result,
JSReceiver::SetProperty( JSReceiver::SetProperty(
receiver, name, value, NONE, strict_mode(), store_mode)); receiver, name, value, NONE, strict_mode(), store_mode),
return *result; Object);
return result;
} }
LookupResult lookup(isolate()); LookupResult lookup(isolate());
...@@ -1309,11 +1328,13 @@ MaybeObject* StoreIC::Store(Handle<Object> object, ...@@ -1309,11 +1328,13 @@ MaybeObject* StoreIC::Store(Handle<Object> object,
// Set the property. // Set the property.
Handle<Object> result; Handle<Object> result;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION( ASSIGN_RETURN_ON_EXCEPTION(
isolate(), result, isolate(),
result,
JSReceiver::SetProperty( JSReceiver::SetProperty(
receiver, name, value, NONE, strict_mode(), store_mode)); receiver, name, value, NONE, strict_mode(), store_mode),
return *result; Object);
return result;
} }
...@@ -1704,31 +1725,36 @@ KeyedAccessStoreMode KeyedStoreIC::GetStoreMode(Handle<JSObject> receiver, ...@@ -1704,31 +1725,36 @@ KeyedAccessStoreMode KeyedStoreIC::GetStoreMode(Handle<JSObject> receiver,
} }
MaybeObject* KeyedStoreIC::Store(Handle<Object> object, MaybeHandle<Object> KeyedStoreIC::Store(Handle<Object> object,
Handle<Object> key, Handle<Object> key,
Handle<Object> value) { Handle<Object> value) {
if (MigrateDeprecated(object)) { if (MigrateDeprecated(object)) {
Handle<Object> result; Handle<Object> result;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION( ASSIGN_RETURN_ON_EXCEPTION(
isolate(), result, isolate(),
result,
Runtime::SetObjectProperty( Runtime::SetObjectProperty(
isolate(), object, key, value, NONE, strict_mode())); isolate(), object, key, value, NONE, strict_mode()),
return *result; Object);
return result;
} }
// Check for non-string values that can be converted into an // Check for non-string values that can be converted into an
// internalized string directly or is representable as a smi. // internalized string directly or is representable as a smi.
key = TryConvertKey(key, isolate()); key = TryConvertKey(key, isolate());
MaybeObject* maybe_object = NULL; Handle<Object> store_handle;
Handle<Code> stub = generic_stub(); Handle<Code> stub = generic_stub();
if (key->IsInternalizedString()) { if (key->IsInternalizedString()) {
maybe_object = StoreIC::Store(object, ASSIGN_RETURN_ON_EXCEPTION(
Handle<String>::cast(key), isolate(),
value, store_handle,
JSReceiver::MAY_BE_STORE_FROM_KEYED); StoreIC::Store(object,
if (maybe_object->IsFailure()) return maybe_object; Handle<String>::cast(key),
value,
JSReceiver::MAY_BE_STORE_FROM_KEYED),
Object);
} else { } else {
bool use_ic = FLAG_use_ic && bool use_ic = FLAG_use_ic &&
!object->IsStringWrapper() && !object->IsStringWrapper() &&
...@@ -1780,13 +1806,15 @@ MaybeObject* KeyedStoreIC::Store(Handle<Object> object, ...@@ -1780,13 +1806,15 @@ MaybeObject* KeyedStoreIC::Store(Handle<Object> object,
TRACE_IC("StoreIC", key); TRACE_IC("StoreIC", key);
} }
if (maybe_object) return maybe_object; if (!store_handle.is_null()) return store_handle;
Handle<Object> result; Handle<Object> result;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION( ASSIGN_RETURN_ON_EXCEPTION(
isolate(), result, isolate(),
result,
Runtime::SetObjectProperty( Runtime::SetObjectProperty(
isolate(), object, key, value, NONE, strict_mode())); isolate(), object, key, value, NONE, strict_mode()),
return *result; Object);
return result;
} }
...@@ -1806,7 +1834,9 @@ RUNTIME_FUNCTION(MaybeObject*, LoadIC_Miss) { ...@@ -1806,7 +1834,9 @@ RUNTIME_FUNCTION(MaybeObject*, LoadIC_Miss) {
Handle<Object> receiver = args.at<Object>(0); Handle<Object> receiver = args.at<Object>(0);
Handle<String> key = args.at<String>(1); Handle<String> key = args.at<String>(1);
ic.UpdateState(receiver, key); ic.UpdateState(receiver, key);
return ic.Load(receiver, key); Handle<Object> result;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, ic.Load(receiver, key));
return *result;
} }
...@@ -1818,7 +1848,9 @@ RUNTIME_FUNCTION(MaybeObject*, KeyedLoadIC_Miss) { ...@@ -1818,7 +1848,9 @@ RUNTIME_FUNCTION(MaybeObject*, KeyedLoadIC_Miss) {
Handle<Object> receiver = args.at<Object>(0); Handle<Object> receiver = args.at<Object>(0);
Handle<Object> key = args.at<Object>(1); Handle<Object> key = args.at<Object>(1);
ic.UpdateState(receiver, key); ic.UpdateState(receiver, key);
return ic.Load(receiver, key); Handle<Object> result;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, ic.Load(receiver, key));
return *result;
} }
...@@ -1829,7 +1861,9 @@ RUNTIME_FUNCTION(MaybeObject*, KeyedLoadIC_MissFromStubFailure) { ...@@ -1829,7 +1861,9 @@ RUNTIME_FUNCTION(MaybeObject*, KeyedLoadIC_MissFromStubFailure) {
Handle<Object> receiver = args.at<Object>(0); Handle<Object> receiver = args.at<Object>(0);
Handle<Object> key = args.at<Object>(1); Handle<Object> key = args.at<Object>(1);
ic.UpdateState(receiver, key); ic.UpdateState(receiver, key);
return ic.Load(receiver, key); Handle<Object> result;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, ic.Load(receiver, key));
return *result;
} }
...@@ -1841,7 +1875,12 @@ RUNTIME_FUNCTION(MaybeObject*, StoreIC_Miss) { ...@@ -1841,7 +1875,12 @@ RUNTIME_FUNCTION(MaybeObject*, StoreIC_Miss) {
Handle<Object> receiver = args.at<Object>(0); Handle<Object> receiver = args.at<Object>(0);
Handle<String> key = args.at<String>(1); Handle<String> key = args.at<String>(1);
ic.UpdateState(receiver, key); ic.UpdateState(receiver, key);
return ic.Store(receiver, key, args.at<Object>(2)); Handle<Object> result;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate,
result,
ic.Store(receiver, key, args.at<Object>(2)));
return *result;
} }
...@@ -1852,7 +1891,12 @@ RUNTIME_FUNCTION(MaybeObject*, StoreIC_MissFromStubFailure) { ...@@ -1852,7 +1891,12 @@ RUNTIME_FUNCTION(MaybeObject*, StoreIC_MissFromStubFailure) {
Handle<Object> receiver = args.at<Object>(0); Handle<Object> receiver = args.at<Object>(0);
Handle<String> key = args.at<String>(1); Handle<String> key = args.at<String>(1);
ic.UpdateState(receiver, key); ic.UpdateState(receiver, key);
return ic.Store(receiver, key, args.at<Object>(2)); Handle<Object> result;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate,
result,
ic.Store(receiver, key, args.at<Object>(2)));
return *result;
} }
...@@ -1883,46 +1927,42 @@ RUNTIME_FUNCTION(MaybeObject*, StoreIC_ArrayLength) { ...@@ -1883,46 +1927,42 @@ RUNTIME_FUNCTION(MaybeObject*, StoreIC_ArrayLength) {
// it is necessary to extend the properties array of a // it is necessary to extend the properties array of a
// JSObject. // JSObject.
RUNTIME_FUNCTION(MaybeObject*, SharedStoreIC_ExtendStorage) { RUNTIME_FUNCTION(MaybeObject*, SharedStoreIC_ExtendStorage) {
SealHandleScope shs(isolate); HandleScope shs(isolate);
ASSERT(args.length() == 3); ASSERT(args.length() == 3);
// Convert the parameters // Convert the parameters
JSObject* object = JSObject::cast(args[0]); Handle<JSObject> object = args.at<JSObject>(0);
Map* transition = Map::cast(args[1]); Handle<Map> transition = args.at<Map>(1);
Object* value = args[2]; Handle<Object> value = args.at<Object>(2);
// Check the object has run out out property space. // Check the object has run out out property space.
ASSERT(object->HasFastProperties()); ASSERT(object->HasFastProperties());
ASSERT(object->map()->unused_property_fields() == 0); ASSERT(object->map()->unused_property_fields() == 0);
// Expand the properties array. // Expand the properties array.
FixedArray* old_storage = object->properties(); Handle<FixedArray> old_storage = handle(object->properties(), isolate);
int new_unused = transition->unused_property_fields(); int new_unused = transition->unused_property_fields();
int new_size = old_storage->length() + new_unused + 1; int new_size = old_storage->length() + new_unused + 1;
Object* result;
MaybeObject* maybe_result = old_storage->CopySize(new_size);
if (!maybe_result->ToObject(&result)) return maybe_result;
FixedArray* new_storage = FixedArray::cast(result); Handle<FixedArray> new_storage = isolate->factory()->CopySizeFixedArray(
old_storage, new_size);
Object* to_store = value; Handle<Object> to_store = value;
DescriptorArray* descriptors = transition->instance_descriptors(); PropertyDetails details = transition->instance_descriptors()->GetDetails(
PropertyDetails details = descriptors->GetDetails(transition->LastAdded()); transition->LastAdded());
if (details.representation().IsDouble()) { if (details.representation().IsDouble()) {
MaybeObject* maybe_storage = to_store = isolate->factory()->NewHeapNumber(value->Number());
isolate->heap()->AllocateHeapNumber(value->Number());
if (!maybe_storage->To(&to_store)) return maybe_storage;
} }
new_storage->set(old_storage->length(), to_store); new_storage->set(old_storage->length(), *to_store);
// Set the new property value and do the map transition. // Set the new property value and do the map transition.
object->set_properties(new_storage); object->set_properties(*new_storage);
object->set_map(transition); object->set_map(*transition);
// Return the stored value. // Return the stored value.
return value; return *value;
} }
...@@ -1934,7 +1974,12 @@ RUNTIME_FUNCTION(MaybeObject*, KeyedStoreIC_Miss) { ...@@ -1934,7 +1974,12 @@ RUNTIME_FUNCTION(MaybeObject*, KeyedStoreIC_Miss) {
Handle<Object> receiver = args.at<Object>(0); Handle<Object> receiver = args.at<Object>(0);
Handle<Object> key = args.at<Object>(1); Handle<Object> key = args.at<Object>(1);
ic.UpdateState(receiver, key); ic.UpdateState(receiver, key);
return ic.Store(receiver, key, args.at<Object>(2)); Handle<Object> result;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate,
result,
ic.Store(receiver, key, args.at<Object>(2)));
return *result;
} }
...@@ -1945,7 +1990,12 @@ RUNTIME_FUNCTION(MaybeObject*, KeyedStoreIC_MissFromStubFailure) { ...@@ -1945,7 +1990,12 @@ RUNTIME_FUNCTION(MaybeObject*, KeyedStoreIC_MissFromStubFailure) {
Handle<Object> receiver = args.at<Object>(0); Handle<Object> receiver = args.at<Object>(0);
Handle<Object> key = args.at<Object>(1); Handle<Object> key = args.at<Object>(1);
ic.UpdateState(receiver, key); ic.UpdateState(receiver, key);
return ic.Store(receiver, key, args.at<Object>(2)); Handle<Object> result;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate,
result,
ic.Store(receiver, key, args.at<Object>(2)));
return *result;
} }
...@@ -2425,9 +2475,10 @@ Type* BinaryOpIC::State::KindToType(Kind kind, Zone* zone) { ...@@ -2425,9 +2475,10 @@ Type* BinaryOpIC::State::KindToType(Kind kind, Zone* zone) {
} }
MaybeObject* BinaryOpIC::Transition(Handle<AllocationSite> allocation_site, MaybeHandle<Object> BinaryOpIC::Transition(
Handle<Object> left, Handle<AllocationSite> allocation_site,
Handle<Object> right) { Handle<Object> left,
Handle<Object> right) {
State state(target()->extra_ic_state()); State state(target()->extra_ic_state());
// Compute the actual result using the builtin for the binary operation. // Compute the actual result using the builtin for the binary operation.
...@@ -2435,9 +2486,11 @@ MaybeObject* BinaryOpIC::Transition(Handle<AllocationSite> allocation_site, ...@@ -2435,9 +2486,11 @@ MaybeObject* BinaryOpIC::Transition(Handle<AllocationSite> allocation_site,
TokenToJSBuiltin(state.op())); TokenToJSBuiltin(state.op()));
Handle<JSFunction> function = handle(JSFunction::cast(builtin), isolate()); Handle<JSFunction> function = handle(JSFunction::cast(builtin), isolate());
Handle<Object> result; Handle<Object> result;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION( ASSIGN_RETURN_ON_EXCEPTION(
isolate(), result, isolate(),
Execution::Call(isolate(), function, left, 1, &right)); result,
Execution::Call(isolate(), function, left, 1, &right),
Object);
// Execution::Call can execute arbitrary JavaScript, hence potentially // Execution::Call can execute arbitrary JavaScript, hence potentially
// update the state of this very IC, so we must update the stored state. // update the state of this very IC, so we must update the stored state.
...@@ -2495,7 +2548,7 @@ MaybeObject* BinaryOpIC::Transition(Handle<AllocationSite> allocation_site, ...@@ -2495,7 +2548,7 @@ MaybeObject* BinaryOpIC::Transition(Handle<AllocationSite> allocation_site,
PatchInlinedSmiCode(address(), DISABLE_INLINED_SMI_CHECK); PatchInlinedSmiCode(address(), DISABLE_INLINED_SMI_CHECK);
} }
return *result; return result;
} }
...@@ -2505,7 +2558,12 @@ RUNTIME_FUNCTION(MaybeObject*, BinaryOpIC_Miss) { ...@@ -2505,7 +2558,12 @@ RUNTIME_FUNCTION(MaybeObject*, BinaryOpIC_Miss) {
Handle<Object> left = args.at<Object>(BinaryOpICStub::kLeft); Handle<Object> left = args.at<Object>(BinaryOpICStub::kLeft);
Handle<Object> right = args.at<Object>(BinaryOpICStub::kRight); Handle<Object> right = args.at<Object>(BinaryOpICStub::kRight);
BinaryOpIC ic(isolate); BinaryOpIC ic(isolate);
return ic.Transition(Handle<AllocationSite>::null(), left, right); Handle<Object> result;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate,
result,
ic.Transition(Handle<AllocationSite>::null(), left, right));
return *result;
} }
...@@ -2519,7 +2577,12 @@ RUNTIME_FUNCTION(MaybeObject*, BinaryOpIC_MissWithAllocationSite) { ...@@ -2519,7 +2577,12 @@ RUNTIME_FUNCTION(MaybeObject*, BinaryOpIC_MissWithAllocationSite) {
Handle<Object> right = args.at<Object>( Handle<Object> right = args.at<Object>(
BinaryOpWithAllocationSiteStub::kRight); BinaryOpWithAllocationSiteStub::kRight);
BinaryOpIC ic(isolate); BinaryOpIC ic(isolate);
return ic.Transition(allocation_site, left, right); Handle<Object> result;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate,
result,
ic.Transition(allocation_site, left, right));
return *result;
} }
...@@ -2761,16 +2824,17 @@ void CompareNilIC::Clear(Address address, ...@@ -2761,16 +2824,17 @@ void CompareNilIC::Clear(Address address,
} }
MaybeObject* CompareNilIC::DoCompareNilSlow(NilValue nil, Handle<Object> CompareNilIC::DoCompareNilSlow(Isolate* isolate,
Handle<Object> object) { NilValue nil,
Handle<Object> object) {
if (object->IsNull() || object->IsUndefined()) { if (object->IsNull() || object->IsUndefined()) {
return Smi::FromInt(true); return handle(Smi::FromInt(true), isolate);
} }
return Smi::FromInt(object->IsUndetectableObject()); return handle(Smi::FromInt(object->IsUndetectableObject()), isolate);
} }
MaybeObject* CompareNilIC::CompareNil(Handle<Object> object) { Handle<Object> CompareNilIC::CompareNil(Handle<Object> object) {
ExtraICState extra_ic_state = target()->extra_ic_state(); ExtraICState extra_ic_state = target()->extra_ic_state();
CompareNilICStub stub(extra_ic_state); CompareNilICStub stub(extra_ic_state);
...@@ -2794,7 +2858,7 @@ MaybeObject* CompareNilIC::CompareNil(Handle<Object> object) { ...@@ -2794,7 +2858,7 @@ MaybeObject* CompareNilIC::CompareNil(Handle<Object> object) {
code = stub.GetCode(isolate()); code = stub.GetCode(isolate());
} }
set_target(*code); set_target(*code);
return DoCompareNilSlow(nil, object); return DoCompareNilSlow(isolate(), nil, object);
} }
...@@ -2802,7 +2866,7 @@ RUNTIME_FUNCTION(MaybeObject*, CompareNilIC_Miss) { ...@@ -2802,7 +2866,7 @@ RUNTIME_FUNCTION(MaybeObject*, CompareNilIC_Miss) {
HandleScope scope(isolate); HandleScope scope(isolate);
Handle<Object> object = args.at<Object>(0); Handle<Object> object = args.at<Object>(0);
CompareNilIC ic(isolate); CompareNilIC ic(isolate);
return ic.CompareNil(object); return *ic.CompareNil(object);
} }
...@@ -2854,12 +2918,12 @@ Builtins::JavaScript BinaryOpIC::TokenToJSBuiltin(Token::Value op) { ...@@ -2854,12 +2918,12 @@ Builtins::JavaScript BinaryOpIC::TokenToJSBuiltin(Token::Value op) {
} }
MaybeObject* ToBooleanIC::ToBoolean(Handle<Object> object) { Handle<Object> ToBooleanIC::ToBoolean(Handle<Object> object) {
ToBooleanStub stub(target()->extra_ic_state()); ToBooleanStub stub(target()->extra_ic_state());
bool to_boolean_value = stub.UpdateStatus(object); bool to_boolean_value = stub.UpdateStatus(object);
Handle<Code> code = stub.GetCode(isolate()); Handle<Code> code = stub.GetCode(isolate());
set_target(*code); set_target(*code);
return Smi::FromInt(to_boolean_value ? 1 : 0); return handle(Smi::FromInt(to_boolean_value ? 1 : 0), isolate());
} }
...@@ -2868,7 +2932,7 @@ RUNTIME_FUNCTION(MaybeObject*, ToBooleanIC_Miss) { ...@@ -2868,7 +2932,7 @@ RUNTIME_FUNCTION(MaybeObject*, ToBooleanIC_Miss) {
HandleScope scope(isolate); HandleScope scope(isolate);
Handle<Object> object = args.at<Object>(0); Handle<Object> object = args.at<Object>(0);
ToBooleanIC ic(isolate); ToBooleanIC ic(isolate);
return ic.ToBoolean(object); return *ic.ToBoolean(object);
} }
......
...@@ -196,10 +196,10 @@ class IC { ...@@ -196,10 +196,10 @@ class IC {
void TraceIC(const char* type, Handle<Object> name); void TraceIC(const char* type, Handle<Object> name);
#endif #endif
Failure* TypeError(const char* type, MaybeHandle<Object> TypeError(const char* type,
Handle<Object> object, Handle<Object> object,
Handle<Object> key); Handle<Object> key);
Failure* ReferenceError(const char* type, Handle<String> name); MaybeHandle<Object> ReferenceError(const char* type, Handle<String> name);
// Access the target code for the given IC address. // Access the target code for the given IC address.
static inline Code* GetTargetAtAddress(Address address, static inline Code* GetTargetAtAddress(Address address,
...@@ -397,8 +397,8 @@ class LoadIC: public IC { ...@@ -397,8 +397,8 @@ class LoadIC: public IC {
static Handle<Code> initialize_stub(Isolate* isolate, static Handle<Code> initialize_stub(Isolate* isolate,
ExtraICState extra_state); ExtraICState extra_state);
MUST_USE_RESULT MaybeObject* Load(Handle<Object> object, MUST_USE_RESULT MaybeHandle<Object> Load(Handle<Object> object,
Handle<String> name); Handle<String> name);
protected: protected:
virtual Code::Kind kind() const { return Code::LOAD_IC; } virtual Code::Kind kind() const { return Code::LOAD_IC; }
...@@ -459,8 +459,8 @@ class KeyedLoadIC: public LoadIC { ...@@ -459,8 +459,8 @@ class KeyedLoadIC: public LoadIC {
ASSERT(target()->is_keyed_load_stub()); ASSERT(target()->is_keyed_load_stub());
} }
MUST_USE_RESULT MaybeObject* Load(Handle<Object> object, MUST_USE_RESULT MaybeHandle<Object> Load(Handle<Object> object,
Handle<Object> key); Handle<Object> key);
// Code generator routines. // Code generator routines.
static void GenerateMiss(MacroAssembler* masm); static void GenerateMiss(MacroAssembler* masm);
...@@ -564,7 +564,7 @@ class StoreIC: public IC { ...@@ -564,7 +564,7 @@ class StoreIC: public IC {
static Handle<Code> initialize_stub(Isolate* isolate, static Handle<Code> initialize_stub(Isolate* isolate,
StrictMode strict_mode); StrictMode strict_mode);
MUST_USE_RESULT MaybeObject* Store( MUST_USE_RESULT MaybeHandle<Object> Store(
Handle<Object> object, Handle<Object> object,
Handle<String> name, Handle<String> name,
Handle<Object> value, Handle<Object> value,
...@@ -653,9 +653,9 @@ class KeyedStoreIC: public StoreIC { ...@@ -653,9 +653,9 @@ class KeyedStoreIC: public StoreIC {
ASSERT(target()->is_keyed_store_stub()); ASSERT(target()->is_keyed_store_stub());
} }
MUST_USE_RESULT MaybeObject* Store(Handle<Object> object, MUST_USE_RESULT MaybeHandle<Object> Store(Handle<Object> object,
Handle<Object> name, Handle<Object> name,
Handle<Object> value); Handle<Object> value);
// Code generators for stub routines. Only called once at startup. // Code generators for stub routines. Only called once at startup.
static void GenerateInitialize(MacroAssembler* masm) { GenerateMiss(masm); } static void GenerateInitialize(MacroAssembler* masm) { GenerateMiss(masm); }
...@@ -860,9 +860,9 @@ class BinaryOpIC: public IC { ...@@ -860,9 +860,9 @@ class BinaryOpIC: public IC {
static Builtins::JavaScript TokenToJSBuiltin(Token::Value op); static Builtins::JavaScript TokenToJSBuiltin(Token::Value op);
MaybeObject* Transition(Handle<AllocationSite> allocation_site, MaybeHandle<Object> Transition(Handle<AllocationSite> allocation_site,
Handle<Object> left, Handle<Object> left,
Handle<Object> right) V8_WARN_UNUSED_RESULT; Handle<Object> right) V8_WARN_UNUSED_RESULT;
}; };
...@@ -944,7 +944,7 @@ class CompareNilIC: public IC { ...@@ -944,7 +944,7 @@ class CompareNilIC: public IC {
public: public:
explicit CompareNilIC(Isolate* isolate) : IC(EXTRA_CALL_FRAME, isolate) {} explicit CompareNilIC(Isolate* isolate) : IC(EXTRA_CALL_FRAME, isolate) {}
MUST_USE_RESULT MaybeObject* CompareNil(Handle<Object> object); Handle<Object> CompareNil(Handle<Object> object);
static Handle<Code> GetUninitialized(); static Handle<Code> GetUninitialized();
...@@ -952,8 +952,8 @@ class CompareNilIC: public IC { ...@@ -952,8 +952,8 @@ class CompareNilIC: public IC {
Code* target, Code* target,
ConstantPoolArray* constant_pool); ConstantPoolArray* constant_pool);
static MUST_USE_RESULT MaybeObject* DoCompareNilSlow(NilValue nil, static Handle<Object> DoCompareNilSlow(Isolate* isolate, NilValue nil,
Handle<Object> object); Handle<Object> object);
}; };
...@@ -961,7 +961,7 @@ class ToBooleanIC: public IC { ...@@ -961,7 +961,7 @@ class ToBooleanIC: public IC {
public: public:
explicit ToBooleanIC(Isolate* isolate) : IC(EXTRA_CALL_FRAME, isolate) { } explicit ToBooleanIC(Isolate* isolate) : IC(EXTRA_CALL_FRAME, isolate) { }
MaybeObject* ToBoolean(Handle<Object> object); Handle<Object> ToBoolean(Handle<Object> object);
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment