i::Handle<i::JSObject> self = Utils::OpenHandle(this);
i::Handle<i::Object> value_obj = Utils::OpenHandle(*value);
EXCEPTION_PREAMBLE(isolate);
- i::Handle<i::Object> obj = i::JSObject::SetElement(
- self,
- index,
- value_obj,
- NONE,
- i::SLOPPY);
- has_pending_exception = obj.is_null();
+ has_pending_exception = i::JSObject::SetElement(
+ self, index, value_obj, NONE, i::SLOPPY).is_null();
EXCEPTION_BAILOUT_CHECK(isolate, false);
return true;
}
}
EXCEPTION_PREAMBLE(isolate);
- i::Handle<i::Object> obj = i::ForceDeleteProperty(self, key_obj);
- has_pending_exception = obj.is_null();
+ i::Handle<i::Object> obj;
+ has_pending_exception = !i::Runtime::DeleteObjectProperty(
+ isolate, self, key_obj, i::JSReceiver::FORCE_DELETION).ToHandle(&obj);
EXCEPTION_BAILOUT_CHECK(isolate, false);
return obj->IsTrue();
}
i::Handle<i::JSObject> self = Utils::OpenHandle(this);
i::Handle<i::Object> key_obj = Utils::OpenHandle(*key);
EXCEPTION_PREAMBLE(isolate);
- i::Handle<i::Object> obj = i::DeleteProperty(self, key_obj);
- has_pending_exception = obj.is_null();
+ i::Handle<i::Object> obj;
+ has_pending_exception = !i::Runtime::DeleteObjectProperty(
+ isolate, self, key_obj, i::JSReceiver::NORMAL_DELETION).ToHandle(&obj);
EXCEPTION_BAILOUT_CHECK(isolate, false);
return obj->IsTrue();
}
i::Handle<i::JSReceiver> self = Utils::OpenHandle(this);
i::Handle<i::Object> key_obj = Utils::OpenHandle(*key);
EXCEPTION_PREAMBLE(isolate);
- i::Handle<i::Object> obj = i::HasProperty(self, key_obj);
- has_pending_exception = obj.is_null();
+ i::Handle<i::Object> obj;
+ has_pending_exception = !i::Runtime::HasObjectProperty(
+ isolate, self, key_obj).ToHandle(&obj);
EXCEPTION_BAILOUT_CHECK(isolate, false);
return obj->IsTrue();
}
ENTER_V8(isolate);
HandleScope scope(reinterpret_cast<Isolate*>(isolate));
i::Handle<i::JSObject> self = Utils::OpenHandle(this);
- return i::JSReceiver::DeleteElement(self, index)->IsTrue();
+
+ EXCEPTION_PREAMBLE(isolate);
+ i::Handle<i::Object> obj;
+ has_pending_exception =
+ !i::JSReceiver::DeleteElement(self, index).ToHandle(&obj);
+ EXCEPTION_BAILOUT_CHECK(isolate, false);
+ return obj->IsTrue();
}
} else if (boilerplate_value->IsUninitialized()) {
is_simple = false;
JSObject::SetOwnElement(
- array, i, handle(Smi::FromInt(0), isolate), SLOPPY);
+ array, i, handle(Smi::FromInt(0), isolate), SLOPPY).Assert();
} else {
- JSObject::SetOwnElement(array, i, boilerplate_value, SLOPPY);
+ JSObject::SetOwnElement(array, i, boilerplate_value, SLOPPY).Assert();
}
}
}
-Handle<Object> DeleteProperty(Handle<JSObject> object, Handle<Object> key) {
- Isolate* isolate = object->GetIsolate();
- CALL_HEAP_FUNCTION(isolate,
- Runtime::DeleteObjectProperty(
- isolate, object, key, JSReceiver::NORMAL_DELETION),
- Object);
-}
-
-
-Handle<Object> ForceDeleteProperty(Handle<JSObject> object,
- Handle<Object> key) {
- Isolate* isolate = object->GetIsolate();
- CALL_HEAP_FUNCTION(isolate,
- Runtime::DeleteObjectProperty(
- isolate, object, key, JSReceiver::FORCE_DELETION),
- Object);
-}
-
-
-Handle<Object> HasProperty(Handle<JSReceiver> obj, Handle<Object> key) {
- Isolate* isolate = obj->GetIsolate();
- CALL_HEAP_FUNCTION(isolate,
- Runtime::HasObjectProperty(isolate, obj, key), Object);
-}
-
-
Handle<Object> GetProperty(Handle<JSReceiver> obj,
const char* name) {
Isolate* isolate = obj->GetIsolate();
// string.
Handle<String> FlattenGetString(Handle<String> str);
-Handle<Object> DeleteProperty(Handle<JSObject> object, Handle<Object> key);
-
-Handle<Object> ForceDeleteProperty(Handle<JSObject> object, Handle<Object> key);
-
-Handle<Object> HasProperty(Handle<JSReceiver> obj, Handle<Object> key);
-
Handle<Object> GetProperty(Handle<JSReceiver> obj, const char* name);
// Get the JS object corresponding to the given script; create it
// Check if the given name is an array index.
uint32_t index;
if (name->AsArrayIndex(&index)) {
- Handle<Object> result =
- JSObject::SetElement(receiver, index, value, NONE, strict_mode());
- RETURN_IF_EMPTY_HANDLE(isolate(), result);
+ Handle<Object> result;
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
+ isolate(), result,
+ JSObject::SetElement(receiver, index, value, NONE, strict_mode()));
return *value;
}
Handle<Object> value = ParseJsonValue();
if (value.is_null()) return ReportUnexpectedCharacter();
- JSObject::SetOwnElement(json_object, index, value, SLOPPY);
+ JSObject::SetOwnElement(json_object, index, value, SLOPPY).Assert();
continue;
}
// Not an index, fallback to the slow path.
// Ignore return value from SetElement. It can only be a failure if there
// are element setters causing exceptions and the debugger context has none
// of these.
- Handle<Object> no_failure =
- JSObject::SetElement(object, index, value, NONE, SLOPPY);
- ASSERT(!no_failure.is_null());
- USE(no_failure);
+ JSObject::SetElement(object, index, value, NONE, SLOPPY).Assert();
}
protected:
void SetField(int field_position, Handle<Object> value) {
- Handle<Object> no_failure =
- JSObject::SetElement(array_, field_position, value, NONE, SLOPPY);
- ASSERT(!no_failure.is_null());
- USE(no_failure);
+ JSObject::SetElement(array_, field_position, value, NONE, SLOPPY).Assert();
}
void SetSmiValueField(int field_position, int value) {
if (name->IsSymbol()) return isolate->heap()->undefined_value();
Handle<Object> args[] = { receiver, name };
- Handle<Object> result = CallTrap(
- "get", isolate->derived_get_trap(), ARRAY_SIZE(args), args);
- if (isolate->has_pending_exception()) return Failure::Exception();
-
+ Handle<Object> result;
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
+ isolate, result,
+ CallTrap(handle(this),
+ "get",
+ isolate->derived_get_trap(),
+ ARRAY_SIZE(args),
+ args));
return *result;
}
}
-Handle<Object> JSProxy::SetElementWithHandler(Handle<JSProxy> proxy,
- Handle<JSReceiver> receiver,
- uint32_t index,
- Handle<Object> value,
- StrictMode strict_mode) {
+MaybeHandle<Object> JSProxy::SetElementWithHandler(Handle<JSProxy> proxy,
+ Handle<JSReceiver> receiver,
+ uint32_t index,
+ Handle<Object> value,
+ StrictMode strict_mode) {
Isolate* isolate = proxy->GetIsolate();
Handle<String> name = isolate->factory()->Uint32ToString(index);
return SetPropertyWithHandler(
}
-Handle<Object> JSObject::SetElementWithCallbackSetterInPrototypes(
+MaybeHandle<Object> JSObject::SetElementWithCallbackSetterInPrototypes(
Handle<JSObject> object,
uint32_t index,
Handle<Object> value,
if (name->IsSymbol()) return false;
Handle<Object> args[] = { name };
- Handle<Object> result = proxy->CallTrap(
- "has", isolate->derived_has_trap(), ARRAY_SIZE(args), args);
- if (isolate->has_pending_exception()) return false;
+ Handle<Object> result;
+ ASSIGN_RETURN_ON_EXCEPTION_VALUE(
+ isolate, result,
+ CallTrap(proxy,
+ "has",
+ isolate->derived_has_trap(),
+ ARRAY_SIZE(args),
+ args),
+ false);
return result->BooleanValue();
}
-Handle<Object> JSProxy::SetPropertyWithHandler(Handle<JSProxy> proxy,
- Handle<JSReceiver> receiver,
- Handle<Name> name,
- Handle<Object> value,
- PropertyAttributes attributes,
- StrictMode strict_mode) {
+MaybeHandle<Object> JSProxy::SetPropertyWithHandler(
+ Handle<JSProxy> proxy,
+ Handle<JSReceiver> receiver,
+ Handle<Name> name,
+ Handle<Object> value,
+ PropertyAttributes attributes,
+ StrictMode strict_mode) {
Isolate* isolate = proxy->GetIsolate();
// TODO(rossberg): adjust once there is a story for symbols vs proxies.
if (name->IsSymbol()) return value;
Handle<Object> args[] = { receiver, name, value };
- proxy->CallTrap("set", isolate->derived_set_trap(), ARRAY_SIZE(args), args);
- if (isolate->has_pending_exception()) return Handle<Object>();
+ RETURN_ON_EXCEPTION(
+ isolate,
+ CallTrap(proxy,
+ "set",
+ isolate->derived_set_trap(),
+ ARRAY_SIZE(args),
+ args),
+ Object);
return value;
}
-Handle<Object> JSProxy::SetPropertyViaPrototypesWithHandler(
+MaybeHandle<Object> JSProxy::SetPropertyViaPrototypesWithHandler(
Handle<JSProxy> proxy,
Handle<JSReceiver> receiver,
Handle<Name> name,
*done = true; // except where redefined...
Handle<Object> args[] = { name };
- Handle<Object> result = proxy->CallTrap(
- "getPropertyDescriptor", Handle<Object>(), ARRAY_SIZE(args), args);
- if (isolate->has_pending_exception()) return Handle<Object>();
+ Handle<Object> result;
+ ASSIGN_RETURN_ON_EXCEPTION(
+ isolate, result,
+ CallTrap(proxy,
+ "getPropertyDescriptor",
+ Handle<Object>(),
+ ARRAY_SIZE(args),
+ args),
+ Object);
if (result->IsUndefined()) {
*done = false;
Handle<Object> desc = Execution::Call(
isolate, isolate->to_complete_property_descriptor(), result,
ARRAY_SIZE(argv), argv, &has_pending_exception);
- if (has_pending_exception) return Handle<Object>();
+ if (has_pending_exception) return MaybeHandle<Object>();
// [[GetProperty]] requires to check that all properties are configurable.
Handle<String> configurable_name =
Handle<Object> args[] = { handler, trap, name };
Handle<Object> error = isolate->factory()->NewTypeError(
"proxy_prop_not_configurable", HandleVector(args, ARRAY_SIZE(args)));
- isolate->Throw(*error);
- return Handle<Object>();
+ return isolate->Throw<Object>(error);
}
ASSERT(configurable->IsTrue());
Handle<Object> args[] = { name, receiver };
Handle<Object> error = isolate->factory()->NewTypeError(
"strict_read_only_property", HandleVector(args, ARRAY_SIZE(args)));
- isolate->Throw(*error);
- return Handle<Object>();
+ return isolate->Throw<Object>(error);
}
// We have an AccessorDescriptor.
Handle<Object> args2[] = { name, proxy };
Handle<Object> error = isolate->factory()->NewTypeError(
"no_setter_in_callback", HandleVector(args2, ARRAY_SIZE(args2)));
- isolate->Throw(*error);
- return Handle<Object>();
+ return isolate->Throw<Object>(error);
}
-Handle<Object> JSProxy::DeletePropertyWithHandler(
+MaybeHandle<Object> JSProxy::DeletePropertyWithHandler(
Handle<JSProxy> proxy, Handle<Name> name, DeleteMode mode) {
Isolate* isolate = proxy->GetIsolate();
if (name->IsSymbol()) return isolate->factory()->false_value();
Handle<Object> args[] = { name };
- Handle<Object> result = proxy->CallTrap(
- "delete", Handle<Object>(), ARRAY_SIZE(args), args);
- if (isolate->has_pending_exception()) return Handle<Object>();
+ Handle<Object> result;
+ ASSIGN_RETURN_ON_EXCEPTION(
+ isolate, result,
+ CallTrap(proxy,
+ "delete",
+ Handle<Object>(),
+ ARRAY_SIZE(args),
+ args),
+ Object);
bool result_bool = result->BooleanValue();
if (mode == STRICT_DELETION && !result_bool) {
Handle<Object> args[] = { handler, trap_name };
Handle<Object> error = isolate->factory()->NewTypeError(
"handler_failed", HandleVector(args, ARRAY_SIZE(args)));
- isolate->Throw(*error);
- return Handle<Object>();
+ return isolate->Throw<Object>(error);
}
return isolate->factory()->ToBoolean(result_bool);
}
-Handle<Object> JSProxy::DeleteElementWithHandler(
+MaybeHandle<Object> JSProxy::DeleteElementWithHandler(
Handle<JSProxy> proxy, uint32_t index, DeleteMode mode) {
Isolate* isolate = proxy->GetIsolate();
Handle<String> name = isolate->factory()->Uint32ToString(index);
if (name->IsSymbol()) return ABSENT;
Handle<Object> args[] = { name };
- Handle<Object> result = proxy->CallTrap(
- "getPropertyDescriptor", Handle<Object>(), ARRAY_SIZE(args), args);
- if (isolate->has_pending_exception()) return NONE;
+ Handle<Object> result;
+ ASSIGN_RETURN_ON_EXCEPTION_VALUE(
+ isolate, result,
+ proxy->CallTrap(proxy,
+ "getPropertyDescriptor",
+ Handle<Object>(),
+ ARRAY_SIZE(args),
+ args),
+ NONE);
if (result->IsUndefined()) return ABSENT;
Handle<Object> args[] = { handler, trap, name };
Handle<Object> error = isolate->factory()->NewTypeError(
"proxy_prop_not_configurable", HandleVector(args, ARRAY_SIZE(args)));
- isolate->Throw(*error);
+ isolate->Throw<Object>(error);
return NONE;
}
}
-MUST_USE_RESULT Handle<Object> JSProxy::CallTrap(const char* name,
- Handle<Object> derived,
- int argc,
- Handle<Object> argv[]) {
- Isolate* isolate = GetIsolate();
- Handle<Object> handler(this->handler(), isolate);
+MaybeHandle<Object> JSProxy::CallTrap(Handle<JSProxy> proxy,
+ const char* name,
+ Handle<Object> derived,
+ int argc,
+ Handle<Object> argv[]) {
+ Isolate* isolate = proxy->GetIsolate();
+ Handle<Object> handler(proxy->handler(), isolate);
Handle<String> trap_name = isolate->factory()->InternalizeUtf8String(name);
Handle<Object> trap = Object::GetPropertyOrElement(handler, trap_name);
- RETURN_IF_EMPTY_HANDLE_VALUE(isolate, trap, Handle<Object>());
+ RETURN_IF_EMPTY_HANDLE_VALUE(isolate, trap, MaybeHandle<Object>());
if (trap->IsUndefined()) {
if (derived.is_null()) {
Handle<Object> args[] = { handler, trap_name };
Handle<Object> error = isolate->factory()->NewTypeError(
"handler_trap_missing", HandleVector(args, ARRAY_SIZE(args)));
- isolate->Throw(*error);
- return Handle<Object>();
+ return isolate->Throw<Object>(error);
}
trap = Handle<Object>(derived);
}
}
-Handle<Object> JSReceiver::DeleteElement(Handle<JSReceiver> object,
- uint32_t index,
- DeleteMode mode) {
+MaybeHandle<Object> JSReceiver::DeleteElement(Handle<JSReceiver> object,
+ uint32_t index,
+ DeleteMode mode) {
if (object->IsJSProxy()) {
return JSProxy::DeleteElementWithHandler(
Handle<JSProxy>::cast(object), index, mode);
}
-Handle<Object> JSReceiver::DeleteProperty(Handle<JSReceiver> object,
- Handle<Name> name,
- DeleteMode mode) {
+MaybeHandle<Object> JSReceiver::DeleteProperty(Handle<JSReceiver> object,
+ Handle<Name> name,
+ DeleteMode mode) {
if (object->IsJSProxy()) {
return JSProxy::DeletePropertyWithHandler(
Handle<JSProxy>::cast(object), name, mode);
// Skip deletions where the property was an accessor, leaving holes
// in the array of old values.
if (old_values[i]->IsTheHole()) continue;
- JSObject::SetElement(deleted, indices[i] - index, old_values[i], NONE,
- SLOPPY);
+ JSObject::SetElement(
+ deleted, indices[i] - index, old_values[i], NONE, SLOPPY).Assert();
}
SetProperty(deleted, isolate->factory()->length_string(),
}
-Handle<Object> JSObject::SetElementWithInterceptor(
+MaybeHandle<Object> JSObject::SetElementWithInterceptor(
Handle<JSObject> object,
uint32_t index,
Handle<Object> value,
*object);
v8::Handle<v8::Value> result =
args.Call(setter, index, v8::Utils::ToLocal(value));
- RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object);
+ RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object);
if (!result.IsEmpty()) return value;
}
// Adding n elements in fast case is O(n*n).
// Note: revisit design to have dual undefined values to capture absent
// elements.
-Handle<Object> JSObject::SetFastElement(Handle<JSObject> object,
- uint32_t index,
- Handle<Object> value,
- StrictMode strict_mode,
- bool check_prototype) {
+MaybeHandle<Object> JSObject::SetFastElement(Handle<JSObject> object,
+ uint32_t index,
+ Handle<Object> value,
+ StrictMode strict_mode,
+ bool check_prototype) {
ASSERT(object->HasFastSmiOrObjectElements() ||
object->HasFastArgumentsElements());
if (check_prototype &&
(index >= capacity || backing_store->get(index)->IsTheHole())) {
bool found;
- Handle<Object> result = SetElementWithCallbackSetterInPrototypes(
+ MaybeHandle<Object> result = SetElementWithCallbackSetterInPrototypes(
object, index, value, &found, strict_mode);
if (found) return result;
}
}
-Handle<Object> JSObject::SetDictionaryElement(Handle<JSObject> object,
- uint32_t index,
- Handle<Object> value,
- PropertyAttributes attributes,
- StrictMode strict_mode,
- bool check_prototype,
- SetPropertyMode set_mode) {
+MaybeHandle<Object> JSObject::SetDictionaryElement(
+ Handle<JSObject> object,
+ uint32_t index,
+ Handle<Object> value,
+ PropertyAttributes attributes,
+ StrictMode strict_mode,
+ bool check_prototype,
+ SetPropertyMode set_mode) {
ASSERT(object->HasDictionaryElements() ||
object->HasDictionaryArgumentsElements());
Isolate* isolate = object->GetIsolate();
Handle<Object> error =
isolate->factory()->NewTypeError("strict_read_only_property",
HandleVector(args, 2));
- isolate->Throw(*error);
- return Handle<Object>();
+ return isolate->Throw<Object>(error);
}
}
// Elements of the arguments object in slow mode might be slow aliases.
// Can cause GC!
if (check_prototype) {
bool found;
- Handle<Object> result = SetElementWithCallbackSetterInPrototypes(object,
- index, value, &found, strict_mode);
+ MaybeHandle<Object> result = SetElementWithCallbackSetterInPrototypes(
+ object, index, value, &found, strict_mode);
if (found) return result;
}
Handle<Object> error =
isolate->factory()->NewTypeError("object_not_extensible",
HandleVector(args, 1));
- isolate->Throw(*error);
- return Handle<Object>();
+ return isolate->Throw<Object>(error);
}
}
return value;
}
-Handle<Object> JSObject::SetFastDoubleElement(
+MaybeHandle<Object> JSObject::SetFastDoubleElement(
Handle<JSObject> object,
uint32_t index,
Handle<Object> value,
(index >= elms_length ||
Handle<FixedDoubleArray>::cast(base_elms)->is_the_hole(index))) {
bool found;
- Handle<Object> result = SetElementWithCallbackSetterInPrototypes(object,
- index, value, &found, strict_mode);
+ MaybeHandle<Object> result = SetElementWithCallbackSetterInPrototypes(
+ object, index, value, &found, strict_mode);
if (found) return result;
}
if (!value->IsNumber()) {
SetFastElementsCapacityAndLength(object, elms_length, length,
kDontAllowSmiElements);
- Handle<Object> result = SetFastElement(object, index, value, strict_mode,
- check_prototype);
- RETURN_IF_EMPTY_HANDLE_VALUE(object->GetIsolate(), result,
- Handle<Object>());
+ Handle<Object> result;
+ ASSIGN_RETURN_ON_EXCEPTION(
+ object->GetIsolate(), result,
+ SetFastElement(object, index, value, strict_mode, check_prototype),
+ Object);
JSObject::ValidateElements(object);
return result;
}
}
-Handle<Object> JSReceiver::SetElement(Handle<JSReceiver> object,
- uint32_t index,
- Handle<Object> value,
- PropertyAttributes attributes,
- StrictMode strict_mode) {
+MaybeHandle<Object> JSReceiver::SetElement(Handle<JSReceiver> object,
+ uint32_t index,
+ Handle<Object> value,
+ PropertyAttributes attributes,
+ StrictMode strict_mode) {
if (object->IsJSProxy()) {
return JSProxy::SetElementWithHandler(
Handle<JSProxy>::cast(object), object, index, value, strict_mode);
}
-Handle<Object> JSObject::SetOwnElement(Handle<JSObject> object,
- uint32_t index,
- Handle<Object> value,
- StrictMode strict_mode) {
+MaybeHandle<Object> JSObject::SetOwnElement(Handle<JSObject> object,
+ uint32_t index,
+ Handle<Object> value,
+ StrictMode strict_mode) {
ASSERT(!object->HasExternalArrayElements());
return JSObject::SetElement(object, index, value, NONE, strict_mode, false);
}
-Handle<Object> JSObject::SetElement(Handle<JSObject> object,
- uint32_t index,
- Handle<Object> value,
- PropertyAttributes attributes,
- StrictMode strict_mode,
- bool check_prototype,
- SetPropertyMode set_mode) {
+MaybeHandle<Object> JSObject::SetElement(Handle<JSObject> object,
+ uint32_t index,
+ Handle<Object> value,
+ PropertyAttributes attributes,
+ StrictMode strict_mode,
+ bool check_prototype,
+ SetPropertyMode set_mode) {
Isolate* isolate = object->GetIsolate();
if (object->HasExternalArrayElements() ||
bool has_exception;
Handle<Object> number =
Execution::ToNumber(isolate, value, &has_exception);
- if (has_exception) return Handle<Object>();
+ if (has_exception) return MaybeHandle<Object>();
value = number;
}
}
if (object->IsAccessCheckNeeded()) {
if (!isolate->MayIndexedAccessWrapper(object, index, v8::ACCESS_SET)) {
isolate->ReportFailedAccessCheckWrapper(object, v8::ACCESS_SET);
- RETURN_HANDLE_IF_SCHEDULED_EXCEPTION(isolate, Object);
+ RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object);
return value;
}
}
Handle<Object> args[] = { object, number };
Handle<Object> error = isolate->factory()->NewTypeError(
"redef_external_array_element", HandleVector(args, ARRAY_SIZE(args)));
- isolate->Throw(*error);
- return Handle<Object>();
+ return isolate->Throw<Object>(error);
}
// Normalize the elements to enable attributes on the property.
if (!object->map()->is_observed()) {
return object->HasIndexedInterceptor()
- ? SetElementWithInterceptor(object, index, value, attributes, strict_mode,
- check_prototype,
- set_mode)
+ ? SetElementWithInterceptor(object, index, value, attributes,
+ strict_mode, check_prototype, set_mode)
: SetElementWithoutInterceptor(object, index, value, attributes,
- strict_mode,
- check_prototype,
- set_mode);
+ strict_mode, check_prototype, set_mode);
}
PropertyAttributes old_attributes =
}
// Check for lookup interceptor
- Handle<Object> result = object->HasIndexedInterceptor()
- ? SetElementWithInterceptor(object, index, value, attributes, strict_mode,
- check_prototype,
- set_mode)
- : SetElementWithoutInterceptor(object, index, value, attributes,
- strict_mode,
- check_prototype,
- set_mode);
- RETURN_IF_EMPTY_HANDLE_VALUE(isolate, result, Handle<Object>());
+ Handle<Object> result;
+ ASSIGN_RETURN_ON_EXCEPTION(
+ isolate, result,
+ object->HasIndexedInterceptor()
+ ? SetElementWithInterceptor(
+ object, index, value, attributes,
+ strict_mode, check_prototype, set_mode)
+ : SetElementWithoutInterceptor(
+ object, index, value, attributes,
+ strict_mode, check_prototype, set_mode),
+ Object);
Handle<String> name = isolate->factory()->Uint32ToString(index);
PropertyAttributes new_attributes = GetLocalElementAttribute(object, index);
}
-Handle<Object> JSObject::SetElementWithoutInterceptor(
+MaybeHandle<Object> JSObject::SetElementWithoutInterceptor(
Handle<JSObject> object,
uint32_t index,
Handle<Object> value,
PropertyAttributes attributes,
StrictMode strict_mode,
StoreFromKeyed store_mode = MAY_BE_STORE_FROM_KEYED);
- static Handle<Object> SetElement(Handle<JSReceiver> object,
- uint32_t index,
- Handle<Object> value,
- PropertyAttributes attributes,
- StrictMode strict_mode);
+ MUST_USE_RESULT static MaybeHandle<Object> SetElement(
+ Handle<JSReceiver> object,
+ uint32_t index,
+ Handle<Object> value,
+ PropertyAttributes attributes,
+ StrictMode strict_mode);
// Implementation of [[HasProperty]], ECMA-262 5th edition, section 8.12.6.
static inline bool HasProperty(Handle<JSReceiver> object, Handle<Name> name);
static inline bool HasLocalElement(Handle<JSReceiver> object, uint32_t index);
// Implementation of [[Delete]], ECMA-262 5th edition, section 8.12.7.
- static Handle<Object> DeleteProperty(Handle<JSReceiver> object,
- Handle<Name> name,
- DeleteMode mode = NORMAL_DELETION);
- static Handle<Object> DeleteElement(Handle<JSReceiver> object,
- uint32_t index,
- DeleteMode mode = NORMAL_DELETION);
+ MUST_USE_RESULT static MaybeHandle<Object> DeleteProperty(
+ Handle<JSReceiver> object,
+ Handle<Name> name,
+ DeleteMode mode = NORMAL_DELETION);
+ MUST_USE_RESULT static MaybeHandle<Object> DeleteElement(
+ Handle<JSReceiver> object,
+ uint32_t index,
+ DeleteMode mode = NORMAL_DELETION);
// Tests for the fast common case for property enumeration.
bool IsSimpleEnum();
Handle<JSObject> object,
uint32_t index);
- static Handle<Object> SetFastElement(Handle<JSObject> object, uint32_t index,
- Handle<Object> value,
- StrictMode strict_mode,
- bool check_prototype);
+ MUST_USE_RESULT static MaybeHandle<Object> SetFastElement(
+ Handle<JSObject> object,
+ uint32_t index,
+ Handle<Object> value,
+ StrictMode strict_mode,
+ bool check_prototype);
- static Handle<Object> SetOwnElement(Handle<JSObject> object,
- uint32_t index,
- Handle<Object> value,
- StrictMode strict_mode);
+ MUST_USE_RESULT static MaybeHandle<Object> SetOwnElement(
+ Handle<JSObject> object,
+ uint32_t index,
+ Handle<Object> value,
+ StrictMode strict_mode);
// Empty handle is returned if the element cannot be set to the given value.
- static Handle<Object> SetElement(
+ MUST_USE_RESULT static MaybeHandle<Object> SetElement(
Handle<JSObject> object,
uint32_t index,
Handle<Object> value,
Handle<Object> value,
Handle<JSObject> holder,
StrictMode strict_mode);
- static Handle<Object> SetElementWithInterceptor(
+ MUST_USE_RESULT static MaybeHandle<Object> SetElementWithInterceptor(
Handle<JSObject> object,
uint32_t index,
Handle<Object> value,
StrictMode strict_mode,
bool check_prototype,
SetPropertyMode set_mode);
- static Handle<Object> SetElementWithoutInterceptor(
+ MUST_USE_RESULT static MaybeHandle<Object> SetElementWithoutInterceptor(
Handle<JSObject> object,
uint32_t index,
Handle<Object> value,
StrictMode strict_mode,
bool check_prototype,
SetPropertyMode set_mode);
- static Handle<Object> SetElementWithCallbackSetterInPrototypes(
+ MUST_USE_RESULT
+ static MaybeHandle<Object> SetElementWithCallbackSetterInPrototypes(
Handle<JSObject> object,
uint32_t index,
Handle<Object> value,
bool* found,
StrictMode strict_mode);
- static Handle<Object> SetDictionaryElement(
+ MUST_USE_RESULT static MaybeHandle<Object> SetDictionaryElement(
Handle<JSObject> object,
uint32_t index,
Handle<Object> value,
StrictMode strict_mode,
bool check_prototype,
SetPropertyMode set_mode = SET_PROPERTY);
- static Handle<Object> SetFastDoubleElement(
+ MUST_USE_RESULT static MaybeHandle<Object> SetFastDoubleElement(
Handle<JSObject> object,
uint32_t index,
Handle<Object> value,
// If it defines an accessor property without a setter, or a data property
// that is read-only, throw. In all these cases set '*done' to true,
// otherwise set it to false.
- static Handle<Object> SetPropertyViaPrototypesWithHandler(
+ MUST_USE_RESULT
+ static MaybeHandle<Object> SetPropertyViaPrototypesWithHandler(
Handle<JSProxy> proxy,
Handle<JSReceiver> receiver,
Handle<Name> name,
// Invoke a trap by name. If the trap does not exist on this's handler,
// but derived_trap is non-NULL, invoke that instead. May cause GC.
- Handle<Object> CallTrap(const char* name,
- Handle<Object> derived_trap,
- int argc,
- Handle<Object> args[]);
+ MUST_USE_RESULT static MaybeHandle<Object> CallTrap(
+ Handle<JSProxy> proxy,
+ const char* name,
+ Handle<Object> derived_trap,
+ int argc,
+ Handle<Object> args[]);
// Dispatched behavior.
DECLARE_PRINTER(JSProxy)
private:
friend class JSReceiver;
- static Handle<Object> SetPropertyWithHandler(Handle<JSProxy> proxy,
- Handle<JSReceiver> receiver,
- Handle<Name> name,
- Handle<Object> value,
- PropertyAttributes attributes,
- StrictMode strict_mode);
- static Handle<Object> SetElementWithHandler(Handle<JSProxy> proxy,
- Handle<JSReceiver> receiver,
- uint32_t index,
- Handle<Object> value,
- StrictMode strict_mode);
+ MUST_USE_RESULT static MaybeHandle<Object> SetPropertyWithHandler(
+ Handle<JSProxy> proxy,
+ Handle<JSReceiver> receiver,
+ Handle<Name> name,
+ Handle<Object> value,
+ PropertyAttributes attributes,
+ StrictMode strict_mode);
+ MUST_USE_RESULT static MaybeHandle<Object> SetElementWithHandler(
+ Handle<JSProxy> proxy,
+ Handle<JSReceiver> receiver,
+ uint32_t index,
+ Handle<Object> value,
+ StrictMode strict_mode);
static bool HasPropertyWithHandler(Handle<JSProxy> proxy, Handle<Name> name);
static bool HasElementWithHandler(Handle<JSProxy> proxy, uint32_t index);
- static Handle<Object> DeletePropertyWithHandler(Handle<JSProxy> proxy,
- Handle<Name> name,
- DeleteMode mode);
- static Handle<Object> DeleteElementWithHandler(Handle<JSProxy> proxy,
- uint32_t index,
- DeleteMode mode);
+ MUST_USE_RESULT static MaybeHandle<Object> DeletePropertyWithHandler(
+ Handle<JSProxy> proxy,
+ Handle<Name> name,
+ DeleteMode mode);
+ MUST_USE_RESULT static MaybeHandle<Object> DeleteElementWithHandler(
+ Handle<JSProxy> proxy,
+ uint32_t index,
+ DeleteMode mode);
MUST_USE_RESULT Object* GetIdentityHash();
}
-MaybeObject* Runtime::HasObjectProperty(Isolate* isolate,
- Handle<JSReceiver> object,
- Handle<Object> key) {
- HandleScope scope(isolate);
-
+MaybeHandle<Object> Runtime::HasObjectProperty(Isolate* isolate,
+ Handle<JSReceiver> object,
+ Handle<Object> key) {
// Check if the given key is an array index.
uint32_t index;
if (key->ToArrayIndex(&index)) {
- return isolate->heap()->ToBoolean(JSReceiver::HasElement(object, index));
+ return isolate->factory()->ToBoolean(JSReceiver::HasElement(object, index));
}
// Convert the key to a name - possibly by calling back into JavaScript.
Handle<Name> name = ToName(isolate, key);
- RETURN_IF_EMPTY_HANDLE(isolate, name);
+ RETURN_IF_EMPTY_HANDLE_VALUE(isolate, name, MaybeHandle<Object>());
- return isolate->heap()->ToBoolean(JSReceiver::HasProperty(object, name));
+ return isolate->factory()->ToBoolean(JSReceiver::HasProperty(object, name));
}
bool has_pending_exception = false;
Handle<Object> name_object = key->IsSymbol()
? key : Execution::ToString(isolate, key, &has_pending_exception);
- if (has_pending_exception) return Handle<Object>(); // exception
+ if (has_pending_exception) return MaybeHandle<Object>(); // exception
Handle<Name> name = Handle<Name>::cast(name_object);
return JSReceiver::SetProperty(Handle<JSProxy>::cast(object), name, value,
attr,
bool has_exception;
Handle<Object> number =
Execution::ToNumber(isolate, value, &has_exception);
- if (has_exception) return Handle<Object>(); // exception
+ if (has_exception) return MaybeHandle<Object>(); // exception
value = number;
}
}
- Handle<Object> result = JSObject::SetElement(js_object, index, value, attr,
- strict_mode,
- true,
- set_mode);
+
+ MaybeHandle<Object> result = JSObject::SetElement(
+ js_object, index, value, attr, strict_mode, true, set_mode);
JSObject::ValidateElements(js_object);
+
return result.is_null() ? result : value;
}
bool has_exception;
Handle<Object> number =
Execution::ToNumber(isolate, value, &has_exception);
- if (has_exception) return Handle<Object>(); // exception
+ if (has_exception) return MaybeHandle<Object>(); // exception
value = number;
}
}
- return JSObject::SetElement(js_object, index, value, attr, strict_mode,
- true,
- set_mode);
+ return JSObject::SetElement(js_object, index, value, attr,
+ strict_mode, true, set_mode);
} else {
if (name->IsString()) Handle<String>::cast(name)->TryFlatten();
return JSReceiver::SetProperty(js_object, name, value, attr, strict_mode);
bool has_pending_exception = false;
Handle<Object> converted =
Execution::ToString(isolate, key, &has_pending_exception);
- if (has_pending_exception) return Handle<Object>(); // exception
+ if (has_pending_exception) return MaybeHandle<Object>(); // exception
Handle<String> name = Handle<String>::cast(converted);
if (name->AsArrayIndex(&index)) {
- return JSObject::SetElement(js_object, index, value, attr, strict_mode,
- true,
- set_mode);
+ return JSObject::SetElement(js_object, index, value, attr,
+ strict_mode, true, set_mode);
} else {
return JSReceiver::SetProperty(js_object, name, value, attr, strict_mode);
}
return value;
}
- return JSObject::SetElement(js_object, index, value, attr, SLOPPY,
- false,
- DEFINE_PROPERTY);
+ return JSObject::SetElement(js_object, index, value, attr,
+ SLOPPY, false, DEFINE_PROPERTY);
}
if (key->IsName()) {
Handle<Name> name = Handle<Name>::cast(key);
if (name->AsArrayIndex(&index)) {
- return JSObject::SetElement(js_object, index, value, attr, SLOPPY,
- false,
- DEFINE_PROPERTY);
+ return JSObject::SetElement(js_object, index, value, attr,
+ SLOPPY, false, DEFINE_PROPERTY);
} else {
if (name->IsString()) Handle<String>::cast(name)->TryFlatten();
return JSObject::SetLocalPropertyIgnoreAttributes(js_object, name,
bool has_pending_exception = false;
Handle<Object> converted =
Execution::ToString(isolate, key, &has_pending_exception);
- if (has_pending_exception) return Handle<Object>(); // exception
+ if (has_pending_exception) return MaybeHandle<Object>(); // exception
Handle<String> name = Handle<String>::cast(converted);
if (name->AsArrayIndex(&index)) {
- return JSObject::SetElement(js_object, index, value, attr, SLOPPY,
- false,
- DEFINE_PROPERTY);
+ return JSObject::SetElement(js_object, index, value, attr,
+ SLOPPY, false, DEFINE_PROPERTY);
} else {
return JSObject::SetLocalPropertyIgnoreAttributes(js_object, name, value,
attr);
}
-MaybeObject* Runtime::DeleteObjectProperty(Isolate* isolate,
- Handle<JSReceiver> receiver,
- Handle<Object> key,
- JSReceiver::DeleteMode mode) {
- HandleScope scope(isolate);
-
+MaybeHandle<Object> Runtime::DeleteObjectProperty(Isolate* isolate,
+ Handle<JSReceiver> receiver,
+ Handle<Object> key,
+ JSReceiver::DeleteMode mode) {
// Check if the given key is an array index.
uint32_t index;
if (key->ToArrayIndex(&index)) {
// underlying string does nothing with the deletion, we can ignore
// such deletions.
if (receiver->IsStringObjectWithCharacterAt(index)) {
- return isolate->heap()->true_value();
+ return isolate->factory()->true_value();
}
- Handle<Object> result = JSReceiver::DeleteElement(receiver, index, mode);
- RETURN_IF_EMPTY_HANDLE(isolate, result);
- return *result;
+ return JSReceiver::DeleteElement(receiver, index, mode);
}
Handle<Name> name;
bool has_pending_exception = false;
Handle<Object> converted = Execution::ToString(
isolate, key, &has_pending_exception);
- if (has_pending_exception) return Failure::Exception();
+ if (has_pending_exception) return MaybeHandle<Object>();
name = Handle<String>::cast(converted);
}
if (name->IsString()) Handle<String>::cast(name)->TryFlatten();
- Handle<Object> result = JSReceiver::DeleteProperty(receiver, name, mode);
- RETURN_IF_EMPTY_HANDLE(isolate, result);
- return *result;
+ return JSReceiver::DeleteProperty(receiver, name, mode);
}
CONVERT_STRICT_MODE_ARG_CHECKED(strict_mode, 2);
JSReceiver::DeleteMode delete_mode = strict_mode == STRICT
? JSReceiver::STRICT_DELETION : JSReceiver::NORMAL_DELETION;
- Handle<Object> result = JSReceiver::DeleteProperty(object, key, delete_mode);
- RETURN_IF_EMPTY_HANDLE(isolate, result);
+ Handle<Object> result;
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
+ isolate, result,
+ JSReceiver::DeleteProperty(object, key, delete_mode));
return *result;
}
// the global object, or the subject of a with. Try to delete it
// (respecting DONT_DELETE).
Handle<JSObject> object = Handle<JSObject>::cast(holder);
- Handle<Object> result = JSReceiver::DeleteProperty(object, name);
- RETURN_IF_EMPTY_HANDLE(isolate, result);
+ Handle<Object> result;
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
+ isolate, result,
+ JSReceiver::DeleteProperty(object, name));
return *result;
}
}
// Strict not needed. Used for cycle detection in Array join implementation.
- RETURN_IF_EMPTY_HANDLE(isolate, JSObject::SetFastElement(array, length,
- element,
- SLOPPY,
- true));
+ RETURN_FAILURE_ON_EXCEPTION(
+ isolate,
+ JSObject::SetFastElement(array, length, element, SLOPPY, true));
return isolate->heap()->true_value();
}
if (accept) {
if (break_location_iterator.IsStepInLocation(isolate)) {
Smi* position_value = Smi::FromInt(break_location_iterator.position());
- JSObject::SetElement(array, len,
- Handle<Object>(position_value, isolate),
- NONE, SLOPPY);
+ RETURN_FAILURE_ON_EXCEPTION(
+ isolate,
+ JSObject::SetElement(array, len,
+ Handle<Object>(position_value, isolate),
+ NONE, SLOPPY));
len++;
}
}
Handle<Object> value,
PropertyAttributes attr);
- MUST_USE_RESULT static MaybeObject* DeleteObjectProperty(
+ MUST_USE_RESULT static MaybeHandle<Object> DeleteObjectProperty(
Isolate* isolate,
Handle<JSReceiver> object,
Handle<Object> key,
JSReceiver::DeleteMode mode);
- MUST_USE_RESULT static MaybeObject* HasObjectProperty(
+ MUST_USE_RESULT static MaybeHandle<Object> HasObjectProperty(
Isolate* isolate,
Handle<JSReceiver> object,
Handle<Object> key);
Isolate* isolate = info->isolate();
Factory* factory = isolate->factory();
Handle<JSArray> array = factory->NewJSArray(1);
- USE(JSObject::SetElement(array, 0, var->name(), NONE, STRICT));
+ JSObject::SetElement(array, 0, var->name(), NONE, STRICT).Assert();
Handle<Object> result =
factory->NewSyntaxError("module_type_error", array);
isolate->Throw(*result, &location);
i::Handle<i::Smi> value(i::Smi::FromInt(2),
reinterpret_cast<i::Isolate*>(context->GetIsolate()));
i::Handle<i::Object> no_failure;
- no_failure = i::JSObject::SetElement(jsobj, 1, value, NONE, i::SLOPPY);
+ no_failure = i::JSObject::SetElement(
+ jsobj, 1, value, NONE, i::SLOPPY).ToHandleChecked();
ASSERT(!no_failure.is_null());
i::USE(no_failure);
CheckElementValue(isolate, 2, jsobj, 1);
*value.location() = i::Smi::FromInt(256);
- no_failure = i::JSObject::SetElement(jsobj, 1, value, NONE, i::SLOPPY);
+ no_failure = i::JSObject::SetElement(
+ jsobj, 1, value, NONE, i::SLOPPY).ToHandleChecked();
ASSERT(!no_failure.is_null());
i::USE(no_failure);
CheckElementValue(isolate, 255, jsobj, 1);
*value.location() = i::Smi::FromInt(-1);
- no_failure = i::JSObject::SetElement(jsobj, 1, value, NONE, i::SLOPPY);
+ no_failure = i::JSObject::SetElement(
+ jsobj, 1, value, NONE, i::SLOPPY).ToHandleChecked();
ASSERT(!no_failure.is_null());
i::USE(no_failure);
CheckElementValue(isolate, 0, jsobj, 1);
CHECK(JSReceiver::HasLocalProperty(obj, first));
// delete first
- JSReceiver::DeleteProperty(obj, first, JSReceiver::NORMAL_DELETION);
+ JSReceiver::DeleteProperty(obj, first, JSReceiver::NORMAL_DELETION).Check();
CHECK(!JSReceiver::HasLocalProperty(obj, first));
// add first and then second
CHECK(JSReceiver::HasLocalProperty(obj, second));
// delete first and then second
- JSReceiver::DeleteProperty(obj, first, JSReceiver::NORMAL_DELETION);
+ JSReceiver::DeleteProperty(obj, first, JSReceiver::NORMAL_DELETION).Check();
CHECK(JSReceiver::HasLocalProperty(obj, second));
- JSReceiver::DeleteProperty(obj, second, JSReceiver::NORMAL_DELETION);
+ JSReceiver::DeleteProperty(obj, second, JSReceiver::NORMAL_DELETION).Check();
CHECK(!JSReceiver::HasLocalProperty(obj, first));
CHECK(!JSReceiver::HasLocalProperty(obj, second));
CHECK(JSReceiver::HasLocalProperty(obj, second));
// delete second and then first
- JSReceiver::DeleteProperty(obj, second, JSReceiver::NORMAL_DELETION);
+ JSReceiver::DeleteProperty(obj, second, JSReceiver::NORMAL_DELETION).Check();
CHECK(JSReceiver::HasLocalProperty(obj, first));
- JSReceiver::DeleteProperty(obj, first, JSReceiver::NORMAL_DELETION);
+ JSReceiver::DeleteProperty(obj, first, JSReceiver::NORMAL_DELETION).Check();
CHECK(!JSReceiver::HasLocalProperty(obj, first));
CHECK(!JSReceiver::HasLocalProperty(obj, second));
i::JSArray::SetElement(
args_array, i, v8::Utils::OpenHandle(*v8::String::NewFromUtf8(
CcTest::isolate(), args[i])),
- NONE, i::SLOPPY);
+ NONE, i::SLOPPY).Check();
}
i::Handle<i::JSObject> builtins(isolate->js_builtins_object());
i::Handle<i::Object> format_fun =