Reviewers: Yang,
Description:
Handle exceptions thrown by Array.observe machinery
BUG=chromium:417709
LOG=N
Please review this at https://codereview.chromium.org/651323003/
Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files (+30, -29 lines):
M src/objects.cc
A + test/mjsunit/regress/regress-417709b.js
Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index
4f23ea58b9f1e0ef70d7f6b38fcb5ba2e6be085a..2ab215c635a8f3aa2867c95f929792e27fb62b36
100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -11147,10 +11147,9 @@ static bool GetOldValue(Isolate* isolate,
return true;
}
-static void EnqueueSpliceRecord(Handle<JSArray> object,
- uint32_t index,
- Handle<JSArray> deleted,
- uint32_t add_count) {
+MUST_USE_RESULT static MaybeHandle<Object> EnqueueSpliceRecord(
+ Handle<JSArray> object, uint32_t index, Handle<JSArray> deleted,
+ uint32_t add_count) {
Isolate* isolate = object->GetIsolate();
HandleScope scope(isolate);
Handle<Object> index_object =
isolate->factory()->NewNumberFromUint(index);
@@ -11160,37 +11159,33 @@ static void EnqueueSpliceRecord(Handle<JSArray>
object,
Handle<Object> args[] =
{ object, index_object, deleted, add_count_object };
- Execution::Call(isolate,
- Handle<JSFunction>(isolate->observers_enqueue_splice()),
- isolate->factory()->undefined_value(),
- arraysize(args),
- args).Assert();
+ return Execution::Call(
+ isolate, Handle<JSFunction>(isolate->observers_enqueue_splice()),
+ isolate->factory()->undefined_value(), arraysize(args), args);
}
-static void BeginPerformSplice(Handle<JSArray> object) {
+MUST_USE_RESULT static MaybeHandle<Object> BeginPerformSplice(
+ Handle<JSArray> object) {
Isolate* isolate = object->GetIsolate();
HandleScope scope(isolate);
Handle<Object> args[] = { object };
- Execution::Call(isolate,
-
Handle<JSFunction>(isolate->observers_begin_perform_splice()),
- isolate->factory()->undefined_value(),
- arraysize(args),
- args).Assert();
+ return Execution::Call(
+ isolate,
Handle<JSFunction>(isolate->observers_begin_perform_splice()),
+ isolate->factory()->undefined_value(), arraysize(args), args);
}
-static void EndPerformSplice(Handle<JSArray> object) {
+MUST_USE_RESULT static MaybeHandle<Object> EndPerformSplice(
+ Handle<JSArray> object) {
Isolate* isolate = object->GetIsolate();
HandleScope scope(isolate);
Handle<Object> args[] = { object };
- Execution::Call(isolate,
-
Handle<JSFunction>(isolate->observers_end_perform_splice()),
- isolate->factory()->undefined_value(),
- arraysize(args),
- args).Assert();
+ return Execution::Call(
+ isolate, Handle<JSFunction>(isolate->observers_end_perform_splice()),
+ isolate->factory()->undefined_value(), arraysize(args), args);
}
@@ -11254,7 +11249,7 @@ MaybeHandle<Object> JSArray::SetElementsLength(
CHECK(array->length()->ToArrayIndex(&new_length));
if (old_length == new_length) return hresult;
- BeginPerformSplice(array);
+ RETURN_ON_EXCEPTION(isolate, BeginPerformSplice(array), Object);
for (int i = 0; i < indices.length(); ++i) {
// For deletions where the property was an accessor, old_values[i]
@@ -11273,7 +11268,7 @@ MaybeHandle<Object> JSArray::SetElementsLength(
old_length_handle),
Object);
- EndPerformSplice(array);
+ RETURN_ON_EXCEPTION(isolate, EndPerformSplice(array), Object);
uint32_t index = Min(old_length, new_length);
uint32_t add_count = new_length > old_length ? new_length - old_length :
0;
@@ -11293,7 +11288,8 @@ MaybeHandle<Object> JSArray::SetElementsLength(
STRICT).Assert();
}
- EnqueueSpliceRecord(array, index, deleted, add_count);
+ RETURN_ON_EXCEPTION(
+ isolate, EnqueueSpliceRecord(array, index, deleted, add_count),
Object);
return hresult;
}
@@ -12478,7 +12474,8 @@ MaybeHandle<Object>
JSObject::SetElement(Handle<JSObject> object,
CHECK(old_length_handle->ToArrayIndex(&old_length));
CHECK(new_length_handle->ToArrayIndex(&new_length));
- BeginPerformSplice(Handle<JSArray>::cast(object));
+ RETURN_ON_EXCEPTION(
+ isolate, BeginPerformSplice(Handle<JSArray>::cast(object)),
Object);
RETURN_ON_EXCEPTION(
isolate, EnqueueChangeRecord(object, "add", name, old_value),
Object);
RETURN_ON_EXCEPTION(
@@ -12486,10 +12483,14 @@ MaybeHandle<Object>
JSObject::SetElement(Handle<JSObject> object,
isolate->factory()->length_string(),
old_length_handle),
Object);
- EndPerformSplice(Handle<JSArray>::cast(object));
+ RETURN_ON_EXCEPTION(
+ isolate, EndPerformSplice(Handle<JSArray>::cast(object)),
Object);
Handle<JSArray> deleted = isolate->factory()->NewJSArray(0);
- EnqueueSpliceRecord(Handle<JSArray>::cast(object), old_length,
deleted,
- new_length - old_length);
+ RETURN_ON_EXCEPTION(
+ isolate,
+ EnqueueSpliceRecord(Handle<JSArray>::cast(object), old_length,
+ deleted, new_length - old_length),
+ Object);
} else {
RETURN_ON_EXCEPTION(
isolate, EnqueueChangeRecord(object, "add", name, old_value),
Object);
Index: test/mjsunit/regress/regress-417709b.js
diff --git a/test/mjsunit/regress/regress-417709a.js
b/test/mjsunit/regress/regress-417709b.js
similarity index 90%
copy from test/mjsunit/regress/regress-417709a.js
copy to test/mjsunit/regress/regress-417709b.js
index
d210c10429ad2a49d8df3436f054dca82d7583bd..76805435d3d806758ffb8f51ebc25bb71aa059ef
100644
--- a/test/mjsunit/regress/regress-417709a.js
+++ b/test/mjsunit/regress/regress-417709b.js
@@ -6,7 +6,7 @@
var a = [];
-Object.observe(a, function() {});
+Array.observe(a, function() {});
function f(a, x) {
a.length = x;
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.