Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(867)

Unified Diff: src/objects.cc

Issue 247013002: Replaced empty handle checks with MaybeHandles (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Removed unnecessary assert. Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/objects.h ('k') | src/runtime.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index 2a5e86b916b4b01e1f585ac9a5e14b3e616dee5d..ca1d133e3fd886aae4615376f261670636a2aa43 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -5861,13 +5861,14 @@ class JSObjectWalkVisitor {
copying_(copying),
hints_(hints) {}
- Handle<JSObject> StructureWalk(Handle<JSObject> object);
+ MUST_USE_RESULT MaybeHandle<JSObject> StructureWalk(Handle<JSObject> object);
protected:
- inline Handle<JSObject> VisitElementOrProperty(Handle<JSObject> object,
- Handle<JSObject> value) {
+ MUST_USE_RESULT inline MaybeHandle<JSObject> VisitElementOrProperty(
+ Handle<JSObject> object,
+ Handle<JSObject> value) {
Handle<AllocationSite> current_site = site_context()->EnterNewScope();
- Handle<JSObject> copy_of_value = StructureWalk(value);
+ MaybeHandle<JSObject> copy_of_value = StructureWalk(value);
site_context()->ExitScope(current_site, value);
return copy_of_value;
}
@@ -5885,7 +5886,7 @@ class JSObjectWalkVisitor {
template <class ContextObject>
-Handle<JSObject> JSObjectWalkVisitor<ContextObject>::StructureWalk(
+MaybeHandle<JSObject> JSObjectWalkVisitor<ContextObject>::StructureWalk(
Handle<JSObject> object) {
Isolate* isolate = this->isolate();
bool copying = this->copying();
@@ -5896,7 +5897,7 @@ Handle<JSObject> JSObjectWalkVisitor<ContextObject>::StructureWalk(
if (check.HasOverflowed()) {
isolate->StackOverflow();
- return Handle<JSObject>::null();
+ return MaybeHandle<JSObject>();
}
}
@@ -5937,8 +5938,10 @@ Handle<JSObject> JSObjectWalkVisitor<ContextObject>::StructureWalk(
int index = descriptors->GetFieldIndex(i);
Handle<Object> value(object->RawFastPropertyAt(index), isolate);
if (value->IsJSObject()) {
- value = VisitElementOrProperty(copy, Handle<JSObject>::cast(value));
- RETURN_IF_EMPTY_HANDLE_VALUE(isolate, value, Handle<JSObject>());
+ ASSIGN_RETURN_ON_EXCEPTION(
+ isolate, value,
+ VisitElementOrProperty(copy, Handle<JSObject>::cast(value)),
+ JSObject);
} else {
Representation representation = details.representation();
value = Object::NewStorageFor(isolate, value, representation);
@@ -5963,9 +5966,11 @@ Handle<JSObject> JSObjectWalkVisitor<ContextObject>::StructureWalk(
Handle<Object> value =
Object::GetProperty(copy, key_string).ToHandleChecked();
if (value->IsJSObject()) {
- Handle<JSObject> result = VisitElementOrProperty(
- copy, Handle<JSObject>::cast(value));
- RETURN_IF_EMPTY_HANDLE_VALUE(isolate, result, Handle<JSObject>());
+ Handle<JSObject> result;
+ ASSIGN_RETURN_ON_EXCEPTION(
+ isolate, result,
+ VisitElementOrProperty(copy, Handle<JSObject>::cast(value)),
+ JSObject);
if (copying) {
// Creating object copy for literals. No strict mode needed.
JSObject::SetProperty(
@@ -5997,9 +6002,11 @@ Handle<JSObject> JSObjectWalkVisitor<ContextObject>::StructureWalk(
value->IsTheHole() ||
(IsFastObjectElementsKind(copy->GetElementsKind())));
if (value->IsJSObject()) {
- Handle<JSObject> result = VisitElementOrProperty(
- copy, Handle<JSObject>::cast(value));
- RETURN_IF_EMPTY_HANDLE_VALUE(isolate, result, Handle<JSObject>());
+ Handle<JSObject> result;
+ ASSIGN_RETURN_ON_EXCEPTION(
+ isolate, result,
+ VisitElementOrProperty(copy, Handle<JSObject>::cast(value)),
+ JSObject);
if (copying) {
elements->set(i, *result);
}
@@ -6017,9 +6024,11 @@ Handle<JSObject> JSObjectWalkVisitor<ContextObject>::StructureWalk(
if (element_dictionary->IsKey(k)) {
Handle<Object> value(element_dictionary->ValueAt(i), isolate);
if (value->IsJSObject()) {
- Handle<JSObject> result = VisitElementOrProperty(
- copy, Handle<JSObject>::cast(value));
- RETURN_IF_EMPTY_HANDLE_VALUE(isolate, result, Handle<JSObject>());
+ Handle<JSObject> result;
+ ASSIGN_RETURN_ON_EXCEPTION(
+ isolate, result,
+ VisitElementOrProperty(copy, Handle<JSObject>::cast(value)),
+ JSObject);
if (copying) {
element_dictionary->ValueAtPut(i, *result);
}
@@ -6051,23 +6060,26 @@ Handle<JSObject> JSObjectWalkVisitor<ContextObject>::StructureWalk(
}
-Handle<JSObject> JSObject::DeepWalk(
+MaybeHandle<JSObject> JSObject::DeepWalk(
Handle<JSObject> object,
AllocationSiteCreationContext* site_context) {
JSObjectWalkVisitor<AllocationSiteCreationContext> v(site_context, false,
kNoHints);
- Handle<JSObject> result = v.StructureWalk(object);
- ASSERT(result.is_null() || result.is_identical_to(object));
+ MaybeHandle<JSObject> result = v.StructureWalk(object);
+ Handle<JSObject> for_assert;
+ ASSERT(!result.ToHandle(&for_assert) || for_assert.is_identical_to(object));
return result;
}
-Handle<JSObject> JSObject::DeepCopy(Handle<JSObject> object,
- AllocationSiteUsageContext* site_context,
- DeepCopyHints hints) {
+MaybeHandle<JSObject> JSObject::DeepCopy(
+ Handle<JSObject> object,
+ AllocationSiteUsageContext* site_context,
+ DeepCopyHints hints) {
JSObjectWalkVisitor<AllocationSiteUsageContext> v(site_context, true, hints);
- Handle<JSObject> copy = v.StructureWalk(object);
- ASSERT(!copy.is_identical_to(object));
+ MaybeHandle<JSObject> copy = v.StructureWalk(object);
+ Handle<JSObject> for_assert;
+ ASSERT(!copy.ToHandle(&for_assert) || !for_assert.is_identical_to(object));
return copy;
}
@@ -12397,9 +12409,9 @@ Handle<Map> Map::TransitionToPrototype(Handle<Map> map,
}
-Handle<Object> JSObject::SetPrototype(Handle<JSObject> object,
- Handle<Object> value,
- bool skip_hidden_prototypes) {
+MaybeHandle<Object> JSObject::SetPrototype(Handle<JSObject> object,
+ Handle<Object> value,
+ bool skip_hidden_prototypes) {
#ifdef DEBUG
int size = object->Size();
#endif
@@ -12422,8 +12434,7 @@ Handle<Object> JSObject::SetPrototype(Handle<JSObject> object,
Handle<Object> args[] = { object };
Handle<Object> error = isolate->factory()->NewTypeError(
"non_extensible_proto", HandleVector(args, ARRAY_SIZE(args)));
- isolate->Throw(*error);
- return Handle<Object>();
+ return isolate->Throw<Object>(error);
}
// Before we can set the prototype we need to be sure
@@ -12437,8 +12448,7 @@ Handle<Object> JSObject::SetPrototype(Handle<JSObject> object,
// Cycle detected.
Handle<Object> error = isolate->factory()->NewError(
"cyclic_proto", HandleVector<Object>(NULL, 0));
- isolate->Throw(*error);
- return Handle<Object>();
+ return isolate->Throw<Object>(error);
}
}
« no previous file with comments | « src/objects.h ('k') | src/runtime.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698