| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 "src/builtins.h" | 5 #include "src/builtins.h" |
| 6 | 6 |
| 7 #include "src/api.h" | 7 #include "src/api.h" |
| 8 #include "src/api-natives.h" | 8 #include "src/api-natives.h" |
| 9 #include "src/arguments.h" | 9 #include "src/arguments.h" |
| 10 #include "src/base/once.h" | 10 #include "src/base/once.h" |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 isolate->is_initial_array_prototype(JSArray::cast(prototype)) && | 231 isolate->is_initial_array_prototype(JSArray::cast(prototype)) && |
| 232 isolate->IsFastArrayConstructorPrototypeChainIntact()) { | 232 isolate->IsFastArrayConstructorPrototypeChainIntact()) { |
| 233 return true; | 233 return true; |
| 234 } | 234 } |
| 235 | 235 |
| 236 // Slow case. | 236 // Slow case. |
| 237 PrototypeIterator iter(isolate, receiver); | 237 PrototypeIterator iter(isolate, receiver); |
| 238 return PrototypeHasNoElements(&iter); | 238 return PrototypeHasNoElements(&iter); |
| 239 } | 239 } |
| 240 | 240 |
| 241 | 241 // Returns |false| if not applicable. |
| 242 // Returns empty handle if not applicable. | |
| 243 MUST_USE_RESULT | 242 MUST_USE_RESULT |
| 244 inline MaybeHandle<FixedArrayBase> EnsureJSArrayWithWritableFastElements( | 243 inline bool EnsureJSArrayWithWritableFastElements(Isolate* isolate, |
| 245 Isolate* isolate, Handle<Object> receiver, Arguments* args, | 244 Handle<Object> receiver, |
| 246 int first_added_arg) { | 245 Arguments* args, |
| 247 // We explicitly add a HandleScope to avoid creating several copies of the | 246 int first_added_arg) { |
| 248 // same handle which would otherwise cause issue when left-trimming later-on. | 247 if (!receiver->IsJSArray()) return false; |
| 249 HandleScope scope(isolate); | |
| 250 if (!receiver->IsJSArray()) return MaybeHandle<FixedArrayBase>(); | |
| 251 Handle<JSArray> array = Handle<JSArray>::cast(receiver); | 248 Handle<JSArray> array = Handle<JSArray>::cast(receiver); |
| 252 // If there may be elements accessors in the prototype chain, the fast path | 249 // If there may be elements accessors in the prototype chain, the fast path |
| 253 // cannot be used if there arguments to add to the array. | 250 // cannot be used if there arguments to add to the array. |
| 254 Heap* heap = isolate->heap(); | 251 Heap* heap = isolate->heap(); |
| 255 if (args != NULL && !IsJSArrayFastElementMovingAllowed(isolate, *array)) { | 252 if (args != NULL && !IsJSArrayFastElementMovingAllowed(isolate, *array)) { |
| 256 return MaybeHandle<FixedArrayBase>(); | 253 return false; |
| 257 } | 254 } |
| 258 if (array->map()->is_observed()) return MaybeHandle<FixedArrayBase>(); | 255 if (array->map()->is_observed()) return false; |
| 259 if (!array->map()->is_extensible()) return MaybeHandle<FixedArrayBase>(); | 256 if (!array->map()->is_extensible()) return false; |
| 260 Handle<FixedArrayBase> elms(array->elements(), isolate); | 257 Map* map = array->elements()->map(); |
| 261 Map* map = elms->map(); | |
| 262 if (map == heap->fixed_array_map()) { | 258 if (map == heap->fixed_array_map()) { |
| 263 if (args == NULL || array->HasFastObjectElements()) { | 259 if (args == NULL || array->HasFastObjectElements()) { |
| 264 return scope.CloseAndEscape(elms); | 260 return true; |
| 265 } | 261 } |
| 266 } else if (map == heap->fixed_cow_array_map()) { | 262 } else if (map == heap->fixed_cow_array_map()) { |
| 267 elms = JSObject::EnsureWritableFastElements(array); | 263 // Use a short-lived HandleScope to avoid creating several copies of the |
| 264 // elements handle which would cause issues when left-trimming later-on. |
| 265 HandleScope scope(isolate); |
| 266 // TODO(jkummerow/verwaest): Move this call (or this entire function?) |
| 267 // into the ElementsAccessor so it's only done when needed (e.g. ArrayPush |
| 268 // can skip it because it must grow the backing store anyway). |
| 269 JSObject::EnsureWritableFastElements(array); |
| 268 if (args == NULL || array->HasFastObjectElements()) { | 270 if (args == NULL || array->HasFastObjectElements()) { |
| 269 return scope.CloseAndEscape(elms); | 271 return true; |
| 270 } | 272 } |
| 271 } else if (map == heap->fixed_double_array_map()) { | 273 } else if (map == heap->fixed_double_array_map()) { |
| 272 if (args == NULL) { | 274 if (args == NULL) { |
| 273 return scope.CloseAndEscape(elms); | 275 return true; |
| 274 } | 276 } |
| 275 } else { | 277 } else { |
| 276 return MaybeHandle<FixedArrayBase>(); | 278 return false; |
| 277 } | 279 } |
| 278 | 280 |
| 279 // Adding elements to the array prototype would break code that makes sure | 281 // Adding elements to the array prototype would break code that makes sure |
| 280 // it has no elements. Handle that elsewhere. | 282 // it has no elements. Handle that elsewhere. |
| 281 if (isolate->IsAnyInitialArrayPrototype(array)) { | 283 if (isolate->IsAnyInitialArrayPrototype(array)) { |
| 282 return MaybeHandle<FixedArrayBase>(); | 284 return false; |
| 283 } | 285 } |
| 284 | 286 |
| 285 // Need to ensure that the arguments passed in args can be contained in | 287 // Need to ensure that the arguments passed in args can be contained in |
| 286 // the array. | 288 // the array. |
| 287 int args_length = args->length(); | 289 int args_length = args->length(); |
| 288 if (first_added_arg >= args_length) { | 290 if (first_added_arg >= args_length) { |
| 289 return scope.CloseAndEscape(elms); | 291 return true; |
| 290 } | 292 } |
| 291 | 293 |
| 292 ElementsKind origin_kind = array->map()->elements_kind(); | 294 ElementsKind origin_kind = array->map()->elements_kind(); |
| 293 DCHECK(!IsFastObjectElementsKind(origin_kind)); | 295 DCHECK(!IsFastObjectElementsKind(origin_kind)); |
| 294 ElementsKind target_kind = origin_kind; | 296 ElementsKind target_kind = origin_kind; |
| 295 { | 297 { |
| 296 DisallowHeapAllocation no_gc; | 298 DisallowHeapAllocation no_gc; |
| 297 int arg_count = args_length - first_added_arg; | 299 int arg_count = args_length - first_added_arg; |
| 298 Object** arguments = args->arguments() - first_added_arg - (arg_count - 1); | 300 Object** arguments = args->arguments() - first_added_arg - (arg_count - 1); |
| 299 for (int i = 0; i < arg_count; i++) { | 301 for (int i = 0; i < arg_count; i++) { |
| 300 Object* arg = arguments[i]; | 302 Object* arg = arguments[i]; |
| 301 if (arg->IsHeapObject()) { | 303 if (arg->IsHeapObject()) { |
| 302 if (arg->IsHeapNumber()) { | 304 if (arg->IsHeapNumber()) { |
| 303 target_kind = FAST_DOUBLE_ELEMENTS; | 305 target_kind = FAST_DOUBLE_ELEMENTS; |
| 304 } else { | 306 } else { |
| 305 target_kind = FAST_ELEMENTS; | 307 target_kind = FAST_ELEMENTS; |
| 306 break; | 308 break; |
| 307 } | 309 } |
| 308 } | 310 } |
| 309 } | 311 } |
| 310 } | 312 } |
| 311 if (target_kind != origin_kind) { | 313 if (target_kind != origin_kind) { |
| 314 // Use a short-lived HandleScope to avoid creating several copies of the |
| 315 // elements handle which would cause issues when left-trimming later-on. |
| 316 HandleScope scope(isolate); |
| 312 JSObject::TransitionElementsKind(array, target_kind); | 317 JSObject::TransitionElementsKind(array, target_kind); |
| 313 elms = handle(array->elements(), isolate); | |
| 314 } | 318 } |
| 315 return scope.CloseAndEscape(elms); | 319 return true; |
| 316 } | 320 } |
| 317 | 321 |
| 318 | 322 |
| 319 MUST_USE_RESULT static Object* CallJsIntrinsic( | 323 MUST_USE_RESULT static Object* CallJsIntrinsic( |
| 320 Isolate* isolate, Handle<JSFunction> function, | 324 Isolate* isolate, Handle<JSFunction> function, |
| 321 BuiltinArguments<BuiltinExtraArguments::kNone> args) { | 325 BuiltinArguments<BuiltinExtraArguments::kNone> args) { |
| 322 HandleScope handleScope(isolate); | 326 HandleScope handleScope(isolate); |
| 323 int argc = args.length() - 1; | 327 int argc = args.length() - 1; |
| 324 ScopedVector<Handle<Object> > argv(argc); | 328 ScopedVector<Handle<Object> > argv(argc); |
| 325 for (int i = 0; i < argc; ++i) { | 329 for (int i = 0; i < argc; ++i) { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 345 return isolate->heap()->undefined_value(); // Make compiler happy. | 349 return isolate->heap()->undefined_value(); // Make compiler happy. |
| 346 } | 350 } |
| 347 | 351 |
| 348 | 352 |
| 349 BUILTIN(EmptyFunction) { return isolate->heap()->undefined_value(); } | 353 BUILTIN(EmptyFunction) { return isolate->heap()->undefined_value(); } |
| 350 | 354 |
| 351 | 355 |
| 352 BUILTIN(ArrayPush) { | 356 BUILTIN(ArrayPush) { |
| 353 HandleScope scope(isolate); | 357 HandleScope scope(isolate); |
| 354 Handle<Object> receiver = args.receiver(); | 358 Handle<Object> receiver = args.receiver(); |
| 355 MaybeHandle<FixedArrayBase> maybe_elms_obj = | 359 if (!EnsureJSArrayWithWritableFastElements(isolate, receiver, &args, 1)) { |
| 356 EnsureJSArrayWithWritableFastElements(isolate, receiver, &args, 1); | |
| 357 Handle<FixedArrayBase> elms_obj; | |
| 358 if (!maybe_elms_obj.ToHandle(&elms_obj)) { | |
| 359 return CallJsIntrinsic(isolate, isolate->array_push(), args); | 360 return CallJsIntrinsic(isolate, isolate->array_push(), args); |
| 360 } | 361 } |
| 361 // Fast Elements Path | 362 // Fast Elements Path |
| 362 int push_size = args.length() - 1; | 363 int push_size = args.length() - 1; |
| 363 Handle<JSArray> array = Handle<JSArray>::cast(receiver); | 364 Handle<JSArray> array = Handle<JSArray>::cast(receiver); |
| 364 int len = Smi::cast(array->length())->value(); | 365 int len = Smi::cast(array->length())->value(); |
| 365 if (push_size == 0) { | 366 if (push_size == 0) { |
| 366 return Smi::FromInt(len); | 367 return Smi::FromInt(len); |
| 367 } | 368 } |
| 368 if (push_size > 0 && | 369 DCHECK(push_size > 0); |
| 369 JSArray::WouldChangeReadOnlyLength(array, len + push_size)) { | 370 if (JSArray::HasReadOnlyLength(array)) { |
| 370 return CallJsIntrinsic(isolate, isolate->array_push(), args); | 371 return CallJsIntrinsic(isolate, isolate->array_push(), args); |
| 371 } | 372 } |
| 372 DCHECK(!array->map()->is_observed()); | 373 DCHECK(!array->map()->is_observed()); |
| 373 ElementsAccessor* accessor = array->GetElementsAccessor(); | 374 ElementsAccessor* accessor = array->GetElementsAccessor(); |
| 374 int new_length = accessor->Push(array, elms_obj, &args, push_size); | 375 int new_length = accessor->Push(array, handle(array->elements(), isolate), |
| 376 &args, push_size); |
| 375 return Smi::FromInt(new_length); | 377 return Smi::FromInt(new_length); |
| 376 } | 378 } |
| 377 | 379 |
| 378 | 380 |
| 379 BUILTIN(ArrayPop) { | 381 BUILTIN(ArrayPop) { |
| 380 HandleScope scope(isolate); | 382 HandleScope scope(isolate); |
| 381 Handle<Object> receiver = args.receiver(); | 383 Handle<Object> receiver = args.receiver(); |
| 382 MaybeHandle<FixedArrayBase> maybe_elms_obj = | 384 if (!EnsureJSArrayWithWritableFastElements(isolate, receiver, NULL, 0)) { |
| 383 EnsureJSArrayWithWritableFastElements(isolate, receiver, NULL, 0); | |
| 384 Handle<FixedArrayBase> elms_obj; | |
| 385 if (!maybe_elms_obj.ToHandle(&elms_obj)) { | |
| 386 return CallJsIntrinsic(isolate, isolate->array_pop(), args); | 385 return CallJsIntrinsic(isolate, isolate->array_pop(), args); |
| 387 } | 386 } |
| 388 | 387 |
| 389 Handle<JSArray> array = Handle<JSArray>::cast(receiver); | 388 Handle<JSArray> array = Handle<JSArray>::cast(receiver); |
| 390 DCHECK(!array->map()->is_observed()); | 389 DCHECK(!array->map()->is_observed()); |
| 391 | 390 |
| 392 uint32_t len = static_cast<uint32_t>(Smi::cast(array->length())->value()); | 391 uint32_t len = static_cast<uint32_t>(Smi::cast(array->length())->value()); |
| 393 if (len == 0) return isolate->heap()->undefined_value(); | 392 if (len == 0) return isolate->heap()->undefined_value(); |
| 394 | 393 |
| 395 if (JSArray::HasReadOnlyLength(array)) { | 394 if (JSArray::HasReadOnlyLength(array)) { |
| 396 return CallJsIntrinsic(isolate, isolate->array_pop(), args); | 395 return CallJsIntrinsic(isolate, isolate->array_pop(), args); |
| 397 } | 396 } |
| 398 | 397 |
| 399 Handle<Object> result; | 398 Handle<Object> result; |
| 400 if (IsJSArrayFastElementMovingAllowed(isolate, JSArray::cast(*receiver))) { | 399 if (IsJSArrayFastElementMovingAllowed(isolate, JSArray::cast(*receiver))) { |
| 401 // Fast Elements Path | 400 // Fast Elements Path |
| 402 result = array->GetElementsAccessor()->Pop(array, elms_obj); | 401 result = array->GetElementsAccessor()->Pop( |
| 402 array, handle(array->elements(), isolate)); |
| 403 } else { | 403 } else { |
| 404 // Use Slow Lookup otherwise | 404 // Use Slow Lookup otherwise |
| 405 uint32_t new_length = len - 1; | 405 uint32_t new_length = len - 1; |
| 406 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 406 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 407 isolate, result, Object::GetElement(isolate, array, new_length)); | 407 isolate, result, Object::GetElement(isolate, array, new_length)); |
| 408 JSArray::SetLength(array, new_length); | 408 JSArray::SetLength(array, new_length); |
| 409 } | 409 } |
| 410 return *result; | 410 return *result; |
| 411 } | 411 } |
| 412 | 412 |
| 413 | 413 |
| 414 BUILTIN(ArrayShift) { | 414 BUILTIN(ArrayShift) { |
| 415 HandleScope scope(isolate); | 415 HandleScope scope(isolate); |
| 416 Heap* heap = isolate->heap(); | 416 Heap* heap = isolate->heap(); |
| 417 Handle<Object> receiver = args.receiver(); | 417 Handle<Object> receiver = args.receiver(); |
| 418 MaybeHandle<FixedArrayBase> maybe_elms_obj = | 418 if (!EnsureJSArrayWithWritableFastElements(isolate, receiver, NULL, 0) || |
| 419 EnsureJSArrayWithWritableFastElements(isolate, receiver, NULL, 0); | |
| 420 Handle<FixedArrayBase> elms_obj; | |
| 421 if (!maybe_elms_obj.ToHandle(&elms_obj) || | |
| 422 !IsJSArrayFastElementMovingAllowed(isolate, JSArray::cast(*receiver))) { | 419 !IsJSArrayFastElementMovingAllowed(isolate, JSArray::cast(*receiver))) { |
| 423 return CallJsIntrinsic(isolate, isolate->array_shift(), args); | 420 return CallJsIntrinsic(isolate, isolate->array_shift(), args); |
| 424 } | 421 } |
| 425 Handle<JSArray> array = Handle<JSArray>::cast(receiver); | 422 Handle<JSArray> array = Handle<JSArray>::cast(receiver); |
| 426 DCHECK(!array->map()->is_observed()); | 423 DCHECK(!array->map()->is_observed()); |
| 427 | 424 |
| 428 int len = Smi::cast(array->length())->value(); | 425 int len = Smi::cast(array->length())->value(); |
| 429 if (len == 0) return heap->undefined_value(); | 426 if (len == 0) return heap->undefined_value(); |
| 430 | 427 |
| 431 if (JSArray::HasReadOnlyLength(array)) { | 428 if (JSArray::HasReadOnlyLength(array)) { |
| 432 return CallJsIntrinsic(isolate, isolate->array_shift(), args); | 429 return CallJsIntrinsic(isolate, isolate->array_shift(), args); |
| 433 } | 430 } |
| 434 | 431 |
| 435 Handle<Object> first = array->GetElementsAccessor()->Shift(array, elms_obj); | 432 Handle<Object> first = array->GetElementsAccessor()->Shift( |
| 433 array, handle(array->elements(), isolate)); |
| 436 return *first; | 434 return *first; |
| 437 } | 435 } |
| 438 | 436 |
| 439 | 437 |
| 440 BUILTIN(ArrayUnshift) { | 438 BUILTIN(ArrayUnshift) { |
| 441 HandleScope scope(isolate); | 439 HandleScope scope(isolate); |
| 442 Handle<Object> receiver = args.receiver(); | 440 Handle<Object> receiver = args.receiver(); |
| 443 MaybeHandle<FixedArrayBase> maybe_elms_obj = | 441 if (!EnsureJSArrayWithWritableFastElements(isolate, receiver, &args, 1)) { |
| 444 EnsureJSArrayWithWritableFastElements(isolate, receiver, &args, 1); | |
| 445 Handle<FixedArrayBase> elms_obj; | |
| 446 if (!maybe_elms_obj.ToHandle(&elms_obj)) { | |
| 447 return CallJsIntrinsic(isolate, isolate->array_unshift(), args); | 442 return CallJsIntrinsic(isolate, isolate->array_unshift(), args); |
| 448 } | 443 } |
| 449 Handle<JSArray> array = Handle<JSArray>::cast(receiver); | 444 Handle<JSArray> array = Handle<JSArray>::cast(receiver); |
| 450 DCHECK(!array->map()->is_observed()); | 445 DCHECK(!array->map()->is_observed()); |
| 451 int to_add = args.length() - 1; | 446 int to_add = args.length() - 1; |
| 452 if (to_add == 0) { | 447 if (to_add == 0) { |
| 453 return array->length(); | 448 return array->length(); |
| 454 } | 449 } |
| 455 // Currently fixed arrays cannot grow too big, so | 450 // Currently fixed arrays cannot grow too big, so |
| 456 // we should never hit this case. | 451 // we should never hit this case. |
| 457 DCHECK(to_add <= (Smi::kMaxValue - Smi::cast(array->length())->value())); | 452 DCHECK(to_add <= (Smi::kMaxValue - Smi::cast(array->length())->value())); |
| 458 | 453 |
| 459 if (to_add > 0 && JSArray::HasReadOnlyLength(array)) { | 454 if (to_add > 0 && JSArray::HasReadOnlyLength(array)) { |
| 460 return CallJsIntrinsic(isolate, isolate->array_unshift(), args); | 455 return CallJsIntrinsic(isolate, isolate->array_unshift(), args); |
| 461 } | 456 } |
| 462 | 457 |
| 463 ElementsAccessor* accessor = array->GetElementsAccessor(); | 458 ElementsAccessor* accessor = array->GetElementsAccessor(); |
| 464 int new_length = accessor->Unshift(array, elms_obj, &args, to_add); | 459 int new_length = accessor->Unshift(array, handle(array->elements(), isolate), |
| 460 &args, to_add); |
| 465 return Smi::FromInt(new_length); | 461 return Smi::FromInt(new_length); |
| 466 } | 462 } |
| 467 | 463 |
| 468 | 464 |
| 469 BUILTIN(ArraySlice) { | 465 BUILTIN(ArraySlice) { |
| 470 HandleScope scope(isolate); | 466 HandleScope scope(isolate); |
| 471 Handle<Object> receiver = args.receiver(); | 467 Handle<Object> receiver = args.receiver(); |
| 472 Handle<JSObject> object; | 468 Handle<JSObject> object; |
| 473 Handle<FixedArrayBase> elms_obj; | 469 Handle<FixedArrayBase> elms_obj; |
| 474 int len = -1; | 470 int len = -1; |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 551 } | 547 } |
| 552 Handle<JSArray> result_array = | 548 Handle<JSArray> result_array = |
| 553 accessor->Slice(object, elms_obj, actual_start, actual_end); | 549 accessor->Slice(object, elms_obj, actual_start, actual_end); |
| 554 return *result_array; | 550 return *result_array; |
| 555 } | 551 } |
| 556 | 552 |
| 557 | 553 |
| 558 BUILTIN(ArraySplice) { | 554 BUILTIN(ArraySplice) { |
| 559 HandleScope scope(isolate); | 555 HandleScope scope(isolate); |
| 560 Handle<Object> receiver = args.receiver(); | 556 Handle<Object> receiver = args.receiver(); |
| 561 MaybeHandle<FixedArrayBase> maybe_elms_obj = | 557 if (!EnsureJSArrayWithWritableFastElements(isolate, receiver, &args, 3) || |
| 562 EnsureJSArrayWithWritableFastElements(isolate, receiver, &args, 3); | 558 // If this is a subclass of Array, then call out to JS. |
| 563 Handle<FixedArrayBase> elms_obj; | |
| 564 if (!maybe_elms_obj.ToHandle(&elms_obj) || | |
| 565 // If this is a subclass of Array, then call out to JS | |
| 566 !JSArray::cast(*receiver)->map()->new_target_is_base() || | 559 !JSArray::cast(*receiver)->map()->new_target_is_base() || |
| 567 // If anything with @@species has been messed with, call out to JS | 560 // If anything with @@species has been messed with, call out to JS. |
| 568 !isolate->IsArraySpeciesLookupChainIntact()) { | 561 !isolate->IsArraySpeciesLookupChainIntact()) { |
| 569 return CallJsIntrinsic(isolate, isolate->array_splice(), args); | 562 return CallJsIntrinsic(isolate, isolate->array_splice(), args); |
| 570 } | 563 } |
| 571 Handle<JSArray> array = Handle<JSArray>::cast(receiver); | 564 Handle<JSArray> array = Handle<JSArray>::cast(receiver); |
| 572 DCHECK(!array->map()->is_observed()); | 565 DCHECK(!array->map()->is_observed()); |
| 573 | 566 |
| 574 int argument_count = args.length() - 1; | 567 int argument_count = args.length() - 1; |
| 575 int relative_start = 0; | 568 int relative_start = 0; |
| 576 if (argument_count > 0) { | 569 if (argument_count > 0) { |
| 577 DisallowHeapAllocation no_gc; | 570 DisallowHeapAllocation no_gc; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 606 } | 599 } |
| 607 | 600 |
| 608 int add_count = (argument_count > 1) ? (argument_count - 2) : 0; | 601 int add_count = (argument_count > 1) ? (argument_count - 2) : 0; |
| 609 int new_length = len - actual_delete_count + add_count; | 602 int new_length = len - actual_delete_count + add_count; |
| 610 | 603 |
| 611 if (new_length != len && JSArray::HasReadOnlyLength(array)) { | 604 if (new_length != len && JSArray::HasReadOnlyLength(array)) { |
| 612 AllowHeapAllocation allow_allocation; | 605 AllowHeapAllocation allow_allocation; |
| 613 return CallJsIntrinsic(isolate, isolate->array_splice(), args); | 606 return CallJsIntrinsic(isolate, isolate->array_splice(), args); |
| 614 } | 607 } |
| 615 ElementsAccessor* accessor = array->GetElementsAccessor(); | 608 ElementsAccessor* accessor = array->GetElementsAccessor(); |
| 616 Handle<JSArray> result_array = accessor->Splice( | 609 Handle<JSArray> result_array = |
| 617 array, elms_obj, actual_start, actual_delete_count, &args, add_count); | 610 accessor->Splice(array, handle(array->elements(), isolate), actual_start, |
| 611 actual_delete_count, &args, add_count); |
| 618 return *result_array; | 612 return *result_array; |
| 619 } | 613 } |
| 620 | 614 |
| 621 | 615 |
| 622 // Array Concat ------------------------------------------------------------- | 616 // Array Concat ------------------------------------------------------------- |
| 623 | 617 |
| 624 namespace { | 618 namespace { |
| 625 | 619 |
| 626 /** | 620 /** |
| 627 * A simple visitor visits every element of Array's. | 621 * A simple visitor visits every element of Array's. |
| (...skipping 3822 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4450 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C) | 4444 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C) |
| 4451 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A) | 4445 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A) |
| 4452 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) | 4446 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) |
| 4453 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) | 4447 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) |
| 4454 #undef DEFINE_BUILTIN_ACCESSOR_C | 4448 #undef DEFINE_BUILTIN_ACCESSOR_C |
| 4455 #undef DEFINE_BUILTIN_ACCESSOR_A | 4449 #undef DEFINE_BUILTIN_ACCESSOR_A |
| 4456 | 4450 |
| 4457 | 4451 |
| 4458 } // namespace internal | 4452 } // namespace internal |
| 4459 } // namespace v8 | 4453 } // namespace v8 |
| OLD | NEW |