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

Side by Side Diff: src/objects.cc

Issue 651323003: Handle exceptions thrown by Array.observe machinery (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 2 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-417709b.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <sstream> 5 #include <sstream>
6 6
7 #include "src/v8.h" 7 #include "src/v8.h"
8 8
9 #include "src/accessors.h" 9 #include "src/accessors.h"
10 #include "src/allocation-site-scopes.h" 10 #include "src/allocation-site-scopes.h"
(...skipping 11129 matching lines...) Expand 10 before | Expand all | Expand 10 after
11140 if (!JSObject::GetOwnElementAccessorPair(object, index).is_null()) { 11140 if (!JSObject::GetOwnElementAccessorPair(object, index).is_null()) {
11141 value = Handle<Object>::cast(isolate->factory()->the_hole_value()); 11141 value = Handle<Object>::cast(isolate->factory()->the_hole_value());
11142 } else { 11142 } else {
11143 value = Object::GetElement(isolate, object, index).ToHandleChecked(); 11143 value = Object::GetElement(isolate, object, index).ToHandleChecked();
11144 } 11144 }
11145 old_values->Add(value); 11145 old_values->Add(value);
11146 indices->Add(index); 11146 indices->Add(index);
11147 return true; 11147 return true;
11148 } 11148 }
11149 11149
11150 static void EnqueueSpliceRecord(Handle<JSArray> object, 11150 MUST_USE_RESULT static MaybeHandle<Object> EnqueueSpliceRecord(
11151 uint32_t index, 11151 Handle<JSArray> object, uint32_t index, Handle<JSArray> deleted,
11152 Handle<JSArray> deleted, 11152 uint32_t add_count) {
11153 uint32_t add_count) {
11154 Isolate* isolate = object->GetIsolate(); 11153 Isolate* isolate = object->GetIsolate();
11155 HandleScope scope(isolate); 11154 HandleScope scope(isolate);
11156 Handle<Object> index_object = isolate->factory()->NewNumberFromUint(index); 11155 Handle<Object> index_object = isolate->factory()->NewNumberFromUint(index);
11157 Handle<Object> add_count_object = 11156 Handle<Object> add_count_object =
11158 isolate->factory()->NewNumberFromUint(add_count); 11157 isolate->factory()->NewNumberFromUint(add_count);
11159 11158
11160 Handle<Object> args[] = 11159 Handle<Object> args[] =
11161 { object, index_object, deleted, add_count_object }; 11160 { object, index_object, deleted, add_count_object };
11162 11161
11163 Execution::Call(isolate, 11162 return Execution::Call(
11164 Handle<JSFunction>(isolate->observers_enqueue_splice()), 11163 isolate, Handle<JSFunction>(isolate->observers_enqueue_splice()),
11165 isolate->factory()->undefined_value(), 11164 isolate->factory()->undefined_value(), arraysize(args), args);
11166 arraysize(args),
11167 args).Assert();
11168 } 11165 }
11169 11166
11170 11167
11171 static void BeginPerformSplice(Handle<JSArray> object) { 11168 MUST_USE_RESULT static MaybeHandle<Object> BeginPerformSplice(
11169 Handle<JSArray> object) {
11172 Isolate* isolate = object->GetIsolate(); 11170 Isolate* isolate = object->GetIsolate();
11173 HandleScope scope(isolate); 11171 HandleScope scope(isolate);
11174 Handle<Object> args[] = { object }; 11172 Handle<Object> args[] = { object };
11175 11173
11176 Execution::Call(isolate, 11174 return Execution::Call(
11177 Handle<JSFunction>(isolate->observers_begin_perform_splice()), 11175 isolate, Handle<JSFunction>(isolate->observers_begin_perform_splice()),
11178 isolate->factory()->undefined_value(), 11176 isolate->factory()->undefined_value(), arraysize(args), args);
11179 arraysize(args),
11180 args).Assert();
11181 } 11177 }
11182 11178
11183 11179
11184 static void EndPerformSplice(Handle<JSArray> object) { 11180 MUST_USE_RESULT static MaybeHandle<Object> EndPerformSplice(
11181 Handle<JSArray> object) {
11185 Isolate* isolate = object->GetIsolate(); 11182 Isolate* isolate = object->GetIsolate();
11186 HandleScope scope(isolate); 11183 HandleScope scope(isolate);
11187 Handle<Object> args[] = { object }; 11184 Handle<Object> args[] = { object };
11188 11185
11189 Execution::Call(isolate, 11186 return Execution::Call(
11190 Handle<JSFunction>(isolate->observers_end_perform_splice()), 11187 isolate, Handle<JSFunction>(isolate->observers_end_perform_splice()),
11191 isolate->factory()->undefined_value(), 11188 isolate->factory()->undefined_value(), arraysize(args), args);
11192 arraysize(args),
11193 args).Assert();
11194 } 11189 }
11195 11190
11196 11191
11197 MaybeHandle<Object> JSArray::SetElementsLength( 11192 MaybeHandle<Object> JSArray::SetElementsLength(
11198 Handle<JSArray> array, 11193 Handle<JSArray> array,
11199 Handle<Object> new_length_handle) { 11194 Handle<Object> new_length_handle) {
11200 if (array->HasFastElements()) { 11195 if (array->HasFastElements()) {
11201 // If the new array won't fit in a some non-trivial fraction of the max old 11196 // If the new array won't fit in a some non-trivial fraction of the max old
11202 // space size, then force it to go dictionary mode. 11197 // space size, then force it to go dictionary mode.
11203 int max_fast_array_size = static_cast<int>( 11198 int max_fast_array_size = static_cast<int>(
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
11247 11242
11248 Handle<Object> hresult; 11243 Handle<Object> hresult;
11249 ASSIGN_RETURN_ON_EXCEPTION( 11244 ASSIGN_RETURN_ON_EXCEPTION(
11250 isolate, hresult, 11245 isolate, hresult,
11251 array->GetElementsAccessor()->SetLength(array, new_length_handle), 11246 array->GetElementsAccessor()->SetLength(array, new_length_handle),
11252 Object); 11247 Object);
11253 11248
11254 CHECK(array->length()->ToArrayIndex(&new_length)); 11249 CHECK(array->length()->ToArrayIndex(&new_length));
11255 if (old_length == new_length) return hresult; 11250 if (old_length == new_length) return hresult;
11256 11251
11257 BeginPerformSplice(array); 11252 RETURN_ON_EXCEPTION(isolate, BeginPerformSplice(array), Object);
11258 11253
11259 for (int i = 0; i < indices.length(); ++i) { 11254 for (int i = 0; i < indices.length(); ++i) {
11260 // For deletions where the property was an accessor, old_values[i] 11255 // For deletions where the property was an accessor, old_values[i]
11261 // will be the hole, which instructs EnqueueChangeRecord to elide 11256 // will be the hole, which instructs EnqueueChangeRecord to elide
11262 // the "oldValue" property. 11257 // the "oldValue" property.
11263 RETURN_ON_EXCEPTION( 11258 RETURN_ON_EXCEPTION(
11264 isolate, 11259 isolate,
11265 JSObject::EnqueueChangeRecord( 11260 JSObject::EnqueueChangeRecord(
11266 array, "delete", isolate->factory()->Uint32ToString(indices[i]), 11261 array, "delete", isolate->factory()->Uint32ToString(indices[i]),
11267 old_values[i]), 11262 old_values[i]),
11268 Object); 11263 Object);
11269 } 11264 }
11270 RETURN_ON_EXCEPTION(isolate, 11265 RETURN_ON_EXCEPTION(isolate,
11271 JSObject::EnqueueChangeRecord( 11266 JSObject::EnqueueChangeRecord(
11272 array, "update", isolate->factory()->length_string(), 11267 array, "update", isolate->factory()->length_string(),
11273 old_length_handle), 11268 old_length_handle),
11274 Object); 11269 Object);
11275 11270
11276 EndPerformSplice(array); 11271 RETURN_ON_EXCEPTION(isolate, EndPerformSplice(array), Object);
11277 11272
11278 uint32_t index = Min(old_length, new_length); 11273 uint32_t index = Min(old_length, new_length);
11279 uint32_t add_count = new_length > old_length ? new_length - old_length : 0; 11274 uint32_t add_count = new_length > old_length ? new_length - old_length : 0;
11280 uint32_t delete_count = new_length < old_length ? old_length - new_length : 0; 11275 uint32_t delete_count = new_length < old_length ? old_length - new_length : 0;
11281 Handle<JSArray> deleted = isolate->factory()->NewJSArray(0); 11276 Handle<JSArray> deleted = isolate->factory()->NewJSArray(0);
11282 if (delete_count > 0) { 11277 if (delete_count > 0) {
11283 for (int i = indices.length() - 1; i >= 0; i--) { 11278 for (int i = indices.length() - 1; i >= 0; i--) {
11284 // Skip deletions where the property was an accessor, leaving holes 11279 // Skip deletions where the property was an accessor, leaving holes
11285 // in the array of old values. 11280 // in the array of old values.
11286 if (old_values[i]->IsTheHole()) continue; 11281 if (old_values[i]->IsTheHole()) continue;
11287 JSObject::SetElement( 11282 JSObject::SetElement(
11288 deleted, indices[i] - index, old_values[i], NONE, SLOPPY).Assert(); 11283 deleted, indices[i] - index, old_values[i], NONE, SLOPPY).Assert();
11289 } 11284 }
11290 11285
11291 SetProperty(deleted, isolate->factory()->length_string(), 11286 SetProperty(deleted, isolate->factory()->length_string(),
11292 isolate->factory()->NewNumberFromUint(delete_count), 11287 isolate->factory()->NewNumberFromUint(delete_count),
11293 STRICT).Assert(); 11288 STRICT).Assert();
11294 } 11289 }
11295 11290
11296 EnqueueSpliceRecord(array, index, deleted, add_count); 11291 RETURN_ON_EXCEPTION(
11292 isolate, EnqueueSpliceRecord(array, index, deleted, add_count), Object);
11297 11293
11298 return hresult; 11294 return hresult;
11299 } 11295 }
11300 11296
11301 11297
11302 Handle<Map> Map::GetPrototypeTransition(Handle<Map> map, 11298 Handle<Map> Map::GetPrototypeTransition(Handle<Map> map,
11303 Handle<Object> prototype) { 11299 Handle<Object> prototype) {
11304 FixedArray* cache = map->GetPrototypeTransitions(); 11300 FixedArray* cache = map->GetPrototypeTransitions();
11305 int number_of_transitions = map->NumberOfProtoTransitions(); 11301 int number_of_transitions = map->NumberOfProtoTransitions();
11306 const int proto_offset = 11302 const int proto_offset =
(...skipping 1164 matching lines...) Expand 10 before | Expand all | Expand 10 after
12471 if (object->IsJSArray() && 12467 if (object->IsJSArray() &&
12472 !old_length_handle->SameValue( 12468 !old_length_handle->SameValue(
12473 Handle<JSArray>::cast(object)->length())) { 12469 Handle<JSArray>::cast(object)->length())) {
12474 new_length_handle = handle(Handle<JSArray>::cast(object)->length(), 12470 new_length_handle = handle(Handle<JSArray>::cast(object)->length(),
12475 isolate); 12471 isolate);
12476 uint32_t old_length = 0; 12472 uint32_t old_length = 0;
12477 uint32_t new_length = 0; 12473 uint32_t new_length = 0;
12478 CHECK(old_length_handle->ToArrayIndex(&old_length)); 12474 CHECK(old_length_handle->ToArrayIndex(&old_length));
12479 CHECK(new_length_handle->ToArrayIndex(&new_length)); 12475 CHECK(new_length_handle->ToArrayIndex(&new_length));
12480 12476
12481 BeginPerformSplice(Handle<JSArray>::cast(object)); 12477 RETURN_ON_EXCEPTION(
12478 isolate, BeginPerformSplice(Handle<JSArray>::cast(object)), Object);
12482 RETURN_ON_EXCEPTION( 12479 RETURN_ON_EXCEPTION(
12483 isolate, EnqueueChangeRecord(object, "add", name, old_value), Object); 12480 isolate, EnqueueChangeRecord(object, "add", name, old_value), Object);
12484 RETURN_ON_EXCEPTION( 12481 RETURN_ON_EXCEPTION(
12485 isolate, EnqueueChangeRecord(object, "update", 12482 isolate, EnqueueChangeRecord(object, "update",
12486 isolate->factory()->length_string(), 12483 isolate->factory()->length_string(),
12487 old_length_handle), 12484 old_length_handle),
12488 Object); 12485 Object);
12489 EndPerformSplice(Handle<JSArray>::cast(object)); 12486 RETURN_ON_EXCEPTION(
12487 isolate, EndPerformSplice(Handle<JSArray>::cast(object)), Object);
12490 Handle<JSArray> deleted = isolate->factory()->NewJSArray(0); 12488 Handle<JSArray> deleted = isolate->factory()->NewJSArray(0);
12491 EnqueueSpliceRecord(Handle<JSArray>::cast(object), old_length, deleted, 12489 RETURN_ON_EXCEPTION(
12492 new_length - old_length); 12490 isolate,
12491 EnqueueSpliceRecord(Handle<JSArray>::cast(object), old_length,
12492 deleted, new_length - old_length),
12493 Object);
12493 } else { 12494 } else {
12494 RETURN_ON_EXCEPTION( 12495 RETURN_ON_EXCEPTION(
12495 isolate, EnqueueChangeRecord(object, "add", name, old_value), Object); 12496 isolate, EnqueueChangeRecord(object, "add", name, old_value), Object);
12496 } 12497 }
12497 } else if (old_value->IsTheHole()) { 12498 } else if (old_value->IsTheHole()) {
12498 RETURN_ON_EXCEPTION( 12499 RETURN_ON_EXCEPTION(
12499 isolate, EnqueueChangeRecord(object, "reconfigure", name, old_value), 12500 isolate, EnqueueChangeRecord(object, "reconfigure", name, old_value),
12500 Object); 12501 Object);
12501 } else { 12502 } else {
12502 Handle<Object> new_value = 12503 Handle<Object> new_value =
(...skipping 3932 matching lines...) Expand 10 before | Expand all | Expand 10 after
16435 Handle<DependentCode> codes = 16436 Handle<DependentCode> codes =
16436 DependentCode::Insert(handle(cell->dependent_code(), info->isolate()), 16437 DependentCode::Insert(handle(cell->dependent_code(), info->isolate()),
16437 DependentCode::kPropertyCellChangedGroup, 16438 DependentCode::kPropertyCellChangedGroup,
16438 info->object_wrapper()); 16439 info->object_wrapper());
16439 if (*codes != cell->dependent_code()) cell->set_dependent_code(*codes); 16440 if (*codes != cell->dependent_code()) cell->set_dependent_code(*codes);
16440 info->dependencies(DependentCode::kPropertyCellChangedGroup)->Add( 16441 info->dependencies(DependentCode::kPropertyCellChangedGroup)->Add(
16441 cell, info->zone()); 16442 cell, info->zone());
16442 } 16443 }
16443 16444
16444 } } // namespace v8::internal 16445 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-417709b.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698