OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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/runtime/runtime-utils.h" | 5 #include "src/runtime/runtime-utils.h" |
6 | 6 |
7 #include "src/arguments.h" | 7 #include "src/arguments.h" |
8 #include "src/base/macros.h" | 8 #include "src/base/macros.h" |
9 #include "src/base/platform/mutex.h" | 9 #include "src/base/platform/mutex.h" |
10 #include "src/conversions-inl.h" | 10 #include "src/conversions-inl.h" |
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
437 RUNTIME_FUNCTION(Runtime_AtomicsCompareExchange) { | 437 RUNTIME_FUNCTION(Runtime_AtomicsCompareExchange) { |
438 HandleScope scope(isolate); | 438 HandleScope scope(isolate); |
439 DCHECK(args.length() == 4); | 439 DCHECK(args.length() == 4); |
440 CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, sta, 0); | 440 CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, sta, 0); |
441 CONVERT_SIZE_ARG_CHECKED(index, 1); | 441 CONVERT_SIZE_ARG_CHECKED(index, 1); |
442 CONVERT_NUMBER_ARG_HANDLE_CHECKED(oldobj, 2); | 442 CONVERT_NUMBER_ARG_HANDLE_CHECKED(oldobj, 2); |
443 CONVERT_NUMBER_ARG_HANDLE_CHECKED(newobj, 3); | 443 CONVERT_NUMBER_ARG_HANDLE_CHECKED(newobj, 3); |
444 RUNTIME_ASSERT(sta->GetBuffer()->is_shared()); | 444 RUNTIME_ASSERT(sta->GetBuffer()->is_shared()); |
445 RUNTIME_ASSERT(index < NumberToSize(isolate, sta->length())); | 445 RUNTIME_ASSERT(index < NumberToSize(isolate, sta->length())); |
446 | 446 |
447 void* buffer = sta->GetBuffer()->backing_store(); | 447 uint8_t* source = static_cast<uint8_t*>(sta->GetBuffer()->backing_store()) + |
| 448 NumberToSize(isolate, sta->byte_offset()); |
448 | 449 |
449 switch (sta->type()) { | 450 switch (sta->type()) { |
450 #define TYPED_ARRAY_CASE(Type, typeName, TYPE, ctype, size) \ | 451 #define TYPED_ARRAY_CASE(Type, typeName, TYPE, ctype, size) \ |
451 case kExternal##Type##Array: \ | 452 case kExternal##Type##Array: \ |
452 return DoCompareExchange<ctype>(isolate, buffer, index, oldobj, newobj); | 453 return DoCompareExchange<ctype>(isolate, source, index, oldobj, newobj); |
453 | 454 |
454 INTEGER_TYPED_ARRAYS(TYPED_ARRAY_CASE) | 455 INTEGER_TYPED_ARRAYS(TYPED_ARRAY_CASE) |
455 #undef TYPED_ARRAY_CASE | 456 #undef TYPED_ARRAY_CASE |
456 | 457 |
457 case kExternalUint8ClampedArray: | 458 case kExternalUint8ClampedArray: |
458 return DoCompareExchangeUint8Clamped(isolate, buffer, index, oldobj, | 459 return DoCompareExchangeUint8Clamped(isolate, source, index, oldobj, |
459 newobj); | 460 newobj); |
460 | 461 |
461 default: | 462 default: |
462 break; | 463 break; |
463 } | 464 } |
464 | 465 |
465 UNREACHABLE(); | 466 UNREACHABLE(); |
466 return isolate->heap()->undefined_value(); | 467 return isolate->heap()->undefined_value(); |
467 } | 468 } |
468 | 469 |
469 | 470 |
470 RUNTIME_FUNCTION(Runtime_AtomicsLoad) { | 471 RUNTIME_FUNCTION(Runtime_AtomicsLoad) { |
471 HandleScope scope(isolate); | 472 HandleScope scope(isolate); |
472 DCHECK(args.length() == 2); | 473 DCHECK(args.length() == 2); |
473 CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, sta, 0); | 474 CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, sta, 0); |
474 CONVERT_SIZE_ARG_CHECKED(index, 1); | 475 CONVERT_SIZE_ARG_CHECKED(index, 1); |
475 RUNTIME_ASSERT(sta->GetBuffer()->is_shared()); | 476 RUNTIME_ASSERT(sta->GetBuffer()->is_shared()); |
476 RUNTIME_ASSERT(index < NumberToSize(isolate, sta->length())); | 477 RUNTIME_ASSERT(index < NumberToSize(isolate, sta->length())); |
477 | 478 |
478 void* buffer = sta->GetBuffer()->backing_store(); | 479 uint8_t* source = static_cast<uint8_t*>(sta->GetBuffer()->backing_store()) + |
| 480 NumberToSize(isolate, sta->byte_offset()); |
479 | 481 |
480 switch (sta->type()) { | 482 switch (sta->type()) { |
481 #define TYPED_ARRAY_CASE(Type, typeName, TYPE, ctype, size) \ | 483 #define TYPED_ARRAY_CASE(Type, typeName, TYPE, ctype, size) \ |
482 case kExternal##Type##Array: \ | 484 case kExternal##Type##Array: \ |
483 return DoLoad<ctype>(isolate, buffer, index); | 485 return DoLoad<ctype>(isolate, source, index); |
484 | 486 |
485 INTEGER_TYPED_ARRAYS(TYPED_ARRAY_CASE) | 487 INTEGER_TYPED_ARRAYS(TYPED_ARRAY_CASE) |
486 #undef TYPED_ARRAY_CASE | 488 #undef TYPED_ARRAY_CASE |
487 | 489 |
488 case kExternalUint8ClampedArray: | 490 case kExternalUint8ClampedArray: |
489 return DoLoad<uint8_t>(isolate, buffer, index); | 491 return DoLoad<uint8_t>(isolate, source, index); |
490 | 492 |
491 default: | 493 default: |
492 break; | 494 break; |
493 } | 495 } |
494 | 496 |
495 UNREACHABLE(); | 497 UNREACHABLE(); |
496 return isolate->heap()->undefined_value(); | 498 return isolate->heap()->undefined_value(); |
497 } | 499 } |
498 | 500 |
499 | 501 |
500 RUNTIME_FUNCTION(Runtime_AtomicsStore) { | 502 RUNTIME_FUNCTION(Runtime_AtomicsStore) { |
501 HandleScope scope(isolate); | 503 HandleScope scope(isolate); |
502 DCHECK(args.length() == 3); | 504 DCHECK(args.length() == 3); |
503 CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, sta, 0); | 505 CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, sta, 0); |
504 CONVERT_SIZE_ARG_CHECKED(index, 1); | 506 CONVERT_SIZE_ARG_CHECKED(index, 1); |
505 CONVERT_NUMBER_ARG_HANDLE_CHECKED(value, 2); | 507 CONVERT_NUMBER_ARG_HANDLE_CHECKED(value, 2); |
506 RUNTIME_ASSERT(sta->GetBuffer()->is_shared()); | 508 RUNTIME_ASSERT(sta->GetBuffer()->is_shared()); |
507 RUNTIME_ASSERT(index < NumberToSize(isolate, sta->length())); | 509 RUNTIME_ASSERT(index < NumberToSize(isolate, sta->length())); |
508 | 510 |
509 void* buffer = sta->GetBuffer()->backing_store(); | 511 uint8_t* source = static_cast<uint8_t*>(sta->GetBuffer()->backing_store()) + |
| 512 NumberToSize(isolate, sta->byte_offset()); |
510 | 513 |
511 switch (sta->type()) { | 514 switch (sta->type()) { |
512 #define TYPED_ARRAY_CASE(Type, typeName, TYPE, ctype, size) \ | 515 #define TYPED_ARRAY_CASE(Type, typeName, TYPE, ctype, size) \ |
513 case kExternal##Type##Array: \ | 516 case kExternal##Type##Array: \ |
514 return DoStore<ctype>(isolate, buffer, index, value); | 517 return DoStore<ctype>(isolate, source, index, value); |
515 | 518 |
516 INTEGER_TYPED_ARRAYS(TYPED_ARRAY_CASE) | 519 INTEGER_TYPED_ARRAYS(TYPED_ARRAY_CASE) |
517 #undef TYPED_ARRAY_CASE | 520 #undef TYPED_ARRAY_CASE |
518 | 521 |
519 case kExternalUint8ClampedArray: | 522 case kExternalUint8ClampedArray: |
520 return DoStoreUint8Clamped(isolate, buffer, index, value); | 523 return DoStoreUint8Clamped(isolate, source, index, value); |
521 | 524 |
522 default: | 525 default: |
523 break; | 526 break; |
524 } | 527 } |
525 | 528 |
526 UNREACHABLE(); | 529 UNREACHABLE(); |
527 return isolate->heap()->undefined_value(); | 530 return isolate->heap()->undefined_value(); |
528 } | 531 } |
529 | 532 |
530 | 533 |
531 RUNTIME_FUNCTION(Runtime_AtomicsAdd) { | 534 RUNTIME_FUNCTION(Runtime_AtomicsAdd) { |
532 HandleScope scope(isolate); | 535 HandleScope scope(isolate); |
533 DCHECK(args.length() == 3); | 536 DCHECK(args.length() == 3); |
534 CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, sta, 0); | 537 CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, sta, 0); |
535 CONVERT_SIZE_ARG_CHECKED(index, 1); | 538 CONVERT_SIZE_ARG_CHECKED(index, 1); |
536 CONVERT_NUMBER_ARG_HANDLE_CHECKED(value, 2); | 539 CONVERT_NUMBER_ARG_HANDLE_CHECKED(value, 2); |
537 RUNTIME_ASSERT(sta->GetBuffer()->is_shared()); | 540 RUNTIME_ASSERT(sta->GetBuffer()->is_shared()); |
538 RUNTIME_ASSERT(index < NumberToSize(isolate, sta->length())); | 541 RUNTIME_ASSERT(index < NumberToSize(isolate, sta->length())); |
539 | 542 |
540 void* buffer = sta->GetBuffer()->backing_store(); | 543 uint8_t* source = static_cast<uint8_t*>(sta->GetBuffer()->backing_store()) + |
| 544 NumberToSize(isolate, sta->byte_offset()); |
541 | 545 |
542 switch (sta->type()) { | 546 switch (sta->type()) { |
543 #define TYPED_ARRAY_CASE(Type, typeName, TYPE, ctype, size) \ | 547 #define TYPED_ARRAY_CASE(Type, typeName, TYPE, ctype, size) \ |
544 case kExternal##Type##Array: \ | 548 case kExternal##Type##Array: \ |
545 return DoAdd<ctype>(isolate, buffer, index, value); | 549 return DoAdd<ctype>(isolate, source, index, value); |
546 | 550 |
547 INTEGER_TYPED_ARRAYS(TYPED_ARRAY_CASE) | 551 INTEGER_TYPED_ARRAYS(TYPED_ARRAY_CASE) |
548 #undef TYPED_ARRAY_CASE | 552 #undef TYPED_ARRAY_CASE |
549 | 553 |
550 case kExternalUint8ClampedArray: | 554 case kExternalUint8ClampedArray: |
551 return DoAddUint8Clamped(isolate, buffer, index, value); | 555 return DoAddUint8Clamped(isolate, source, index, value); |
552 | 556 |
553 default: | 557 default: |
554 break; | 558 break; |
555 } | 559 } |
556 | 560 |
557 UNREACHABLE(); | 561 UNREACHABLE(); |
558 return isolate->heap()->undefined_value(); | 562 return isolate->heap()->undefined_value(); |
559 } | 563 } |
560 | 564 |
561 | 565 |
562 RUNTIME_FUNCTION(Runtime_AtomicsSub) { | 566 RUNTIME_FUNCTION(Runtime_AtomicsSub) { |
563 HandleScope scope(isolate); | 567 HandleScope scope(isolate); |
564 DCHECK(args.length() == 3); | 568 DCHECK(args.length() == 3); |
565 CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, sta, 0); | 569 CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, sta, 0); |
566 CONVERT_SIZE_ARG_CHECKED(index, 1); | 570 CONVERT_SIZE_ARG_CHECKED(index, 1); |
567 CONVERT_NUMBER_ARG_HANDLE_CHECKED(value, 2); | 571 CONVERT_NUMBER_ARG_HANDLE_CHECKED(value, 2); |
568 RUNTIME_ASSERT(sta->GetBuffer()->is_shared()); | 572 RUNTIME_ASSERT(sta->GetBuffer()->is_shared()); |
569 RUNTIME_ASSERT(index < NumberToSize(isolate, sta->length())); | 573 RUNTIME_ASSERT(index < NumberToSize(isolate, sta->length())); |
570 | 574 |
571 void* buffer = sta->GetBuffer()->backing_store(); | 575 uint8_t* source = static_cast<uint8_t*>(sta->GetBuffer()->backing_store()) + |
| 576 NumberToSize(isolate, sta->byte_offset()); |
572 | 577 |
573 switch (sta->type()) { | 578 switch (sta->type()) { |
574 #define TYPED_ARRAY_CASE(Type, typeName, TYPE, ctype, size) \ | 579 #define TYPED_ARRAY_CASE(Type, typeName, TYPE, ctype, size) \ |
575 case kExternal##Type##Array: \ | 580 case kExternal##Type##Array: \ |
576 return DoSub<ctype>(isolate, buffer, index, value); | 581 return DoSub<ctype>(isolate, source, index, value); |
577 | 582 |
578 INTEGER_TYPED_ARRAYS(TYPED_ARRAY_CASE) | 583 INTEGER_TYPED_ARRAYS(TYPED_ARRAY_CASE) |
579 #undef TYPED_ARRAY_CASE | 584 #undef TYPED_ARRAY_CASE |
580 | 585 |
581 case kExternalUint8ClampedArray: | 586 case kExternalUint8ClampedArray: |
582 return DoSubUint8Clamped(isolate, buffer, index, value); | 587 return DoSubUint8Clamped(isolate, source, index, value); |
583 | 588 |
584 default: | 589 default: |
585 break; | 590 break; |
586 } | 591 } |
587 | 592 |
588 UNREACHABLE(); | 593 UNREACHABLE(); |
589 return isolate->heap()->undefined_value(); | 594 return isolate->heap()->undefined_value(); |
590 } | 595 } |
591 | 596 |
592 | 597 |
593 RUNTIME_FUNCTION(Runtime_AtomicsAnd) { | 598 RUNTIME_FUNCTION(Runtime_AtomicsAnd) { |
594 HandleScope scope(isolate); | 599 HandleScope scope(isolate); |
595 DCHECK(args.length() == 3); | 600 DCHECK(args.length() == 3); |
596 CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, sta, 0); | 601 CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, sta, 0); |
597 CONVERT_SIZE_ARG_CHECKED(index, 1); | 602 CONVERT_SIZE_ARG_CHECKED(index, 1); |
598 CONVERT_NUMBER_ARG_HANDLE_CHECKED(value, 2); | 603 CONVERT_NUMBER_ARG_HANDLE_CHECKED(value, 2); |
599 RUNTIME_ASSERT(sta->GetBuffer()->is_shared()); | 604 RUNTIME_ASSERT(sta->GetBuffer()->is_shared()); |
600 RUNTIME_ASSERT(index < NumberToSize(isolate, sta->length())); | 605 RUNTIME_ASSERT(index < NumberToSize(isolate, sta->length())); |
601 | 606 |
602 void* buffer = sta->GetBuffer()->backing_store(); | 607 uint8_t* source = static_cast<uint8_t*>(sta->GetBuffer()->backing_store()) + |
| 608 NumberToSize(isolate, sta->byte_offset()); |
603 | 609 |
604 switch (sta->type()) { | 610 switch (sta->type()) { |
605 #define TYPED_ARRAY_CASE(Type, typeName, TYPE, ctype, size) \ | 611 #define TYPED_ARRAY_CASE(Type, typeName, TYPE, ctype, size) \ |
606 case kExternal##Type##Array: \ | 612 case kExternal##Type##Array: \ |
607 return DoAnd<ctype>(isolate, buffer, index, value); | 613 return DoAnd<ctype>(isolate, source, index, value); |
608 | 614 |
609 INTEGER_TYPED_ARRAYS(TYPED_ARRAY_CASE) | 615 INTEGER_TYPED_ARRAYS(TYPED_ARRAY_CASE) |
610 #undef TYPED_ARRAY_CASE | 616 #undef TYPED_ARRAY_CASE |
611 | 617 |
612 case kExternalUint8ClampedArray: | 618 case kExternalUint8ClampedArray: |
613 return DoAndUint8Clamped(isolate, buffer, index, value); | 619 return DoAndUint8Clamped(isolate, source, index, value); |
614 | 620 |
615 default: | 621 default: |
616 break; | 622 break; |
617 } | 623 } |
618 | 624 |
619 UNREACHABLE(); | 625 UNREACHABLE(); |
620 return isolate->heap()->undefined_value(); | 626 return isolate->heap()->undefined_value(); |
621 } | 627 } |
622 | 628 |
623 | 629 |
624 RUNTIME_FUNCTION(Runtime_AtomicsOr) { | 630 RUNTIME_FUNCTION(Runtime_AtomicsOr) { |
625 HandleScope scope(isolate); | 631 HandleScope scope(isolate); |
626 DCHECK(args.length() == 3); | 632 DCHECK(args.length() == 3); |
627 CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, sta, 0); | 633 CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, sta, 0); |
628 CONVERT_SIZE_ARG_CHECKED(index, 1); | 634 CONVERT_SIZE_ARG_CHECKED(index, 1); |
629 CONVERT_NUMBER_ARG_HANDLE_CHECKED(value, 2); | 635 CONVERT_NUMBER_ARG_HANDLE_CHECKED(value, 2); |
630 RUNTIME_ASSERT(sta->GetBuffer()->is_shared()); | 636 RUNTIME_ASSERT(sta->GetBuffer()->is_shared()); |
631 RUNTIME_ASSERT(index < NumberToSize(isolate, sta->length())); | 637 RUNTIME_ASSERT(index < NumberToSize(isolate, sta->length())); |
632 | 638 |
633 void* buffer = sta->GetBuffer()->backing_store(); | 639 uint8_t* source = static_cast<uint8_t*>(sta->GetBuffer()->backing_store()) + |
| 640 NumberToSize(isolate, sta->byte_offset()); |
634 | 641 |
635 switch (sta->type()) { | 642 switch (sta->type()) { |
636 #define TYPED_ARRAY_CASE(Type, typeName, TYPE, ctype, size) \ | 643 #define TYPED_ARRAY_CASE(Type, typeName, TYPE, ctype, size) \ |
637 case kExternal##Type##Array: \ | 644 case kExternal##Type##Array: \ |
638 return DoOr<ctype>(isolate, buffer, index, value); | 645 return DoOr<ctype>(isolate, source, index, value); |
639 | 646 |
640 INTEGER_TYPED_ARRAYS(TYPED_ARRAY_CASE) | 647 INTEGER_TYPED_ARRAYS(TYPED_ARRAY_CASE) |
641 #undef TYPED_ARRAY_CASE | 648 #undef TYPED_ARRAY_CASE |
642 | 649 |
643 case kExternalUint8ClampedArray: | 650 case kExternalUint8ClampedArray: |
644 return DoOrUint8Clamped(isolate, buffer, index, value); | 651 return DoOrUint8Clamped(isolate, source, index, value); |
645 | 652 |
646 default: | 653 default: |
647 break; | 654 break; |
648 } | 655 } |
649 | 656 |
650 UNREACHABLE(); | 657 UNREACHABLE(); |
651 return isolate->heap()->undefined_value(); | 658 return isolate->heap()->undefined_value(); |
652 } | 659 } |
653 | 660 |
654 | 661 |
655 RUNTIME_FUNCTION(Runtime_AtomicsXor) { | 662 RUNTIME_FUNCTION(Runtime_AtomicsXor) { |
656 HandleScope scope(isolate); | 663 HandleScope scope(isolate); |
657 DCHECK(args.length() == 3); | 664 DCHECK(args.length() == 3); |
658 CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, sta, 0); | 665 CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, sta, 0); |
659 CONVERT_SIZE_ARG_CHECKED(index, 1); | 666 CONVERT_SIZE_ARG_CHECKED(index, 1); |
660 CONVERT_NUMBER_ARG_HANDLE_CHECKED(value, 2); | 667 CONVERT_NUMBER_ARG_HANDLE_CHECKED(value, 2); |
661 RUNTIME_ASSERT(sta->GetBuffer()->is_shared()); | 668 RUNTIME_ASSERT(sta->GetBuffer()->is_shared()); |
662 RUNTIME_ASSERT(index < NumberToSize(isolate, sta->length())); | 669 RUNTIME_ASSERT(index < NumberToSize(isolate, sta->length())); |
663 | 670 |
664 void* buffer = sta->GetBuffer()->backing_store(); | 671 uint8_t* source = static_cast<uint8_t*>(sta->GetBuffer()->backing_store()) + |
| 672 NumberToSize(isolate, sta->byte_offset()); |
665 | 673 |
666 switch (sta->type()) { | 674 switch (sta->type()) { |
667 #define TYPED_ARRAY_CASE(Type, typeName, TYPE, ctype, size) \ | 675 #define TYPED_ARRAY_CASE(Type, typeName, TYPE, ctype, size) \ |
668 case kExternal##Type##Array: \ | 676 case kExternal##Type##Array: \ |
669 return DoXor<ctype>(isolate, buffer, index, value); | 677 return DoXor<ctype>(isolate, source, index, value); |
670 | 678 |
671 INTEGER_TYPED_ARRAYS(TYPED_ARRAY_CASE) | 679 INTEGER_TYPED_ARRAYS(TYPED_ARRAY_CASE) |
672 #undef TYPED_ARRAY_CASE | 680 #undef TYPED_ARRAY_CASE |
673 | 681 |
674 case kExternalUint8ClampedArray: | 682 case kExternalUint8ClampedArray: |
675 return DoXorUint8Clamped(isolate, buffer, index, value); | 683 return DoXorUint8Clamped(isolate, source, index, value); |
676 | 684 |
677 default: | 685 default: |
678 break; | 686 break; |
679 } | 687 } |
680 | 688 |
681 UNREACHABLE(); | 689 UNREACHABLE(); |
682 return isolate->heap()->undefined_value(); | 690 return isolate->heap()->undefined_value(); |
683 } | 691 } |
684 | 692 |
685 | 693 |
686 RUNTIME_FUNCTION(Runtime_AtomicsExchange) { | 694 RUNTIME_FUNCTION(Runtime_AtomicsExchange) { |
687 HandleScope scope(isolate); | 695 HandleScope scope(isolate); |
688 DCHECK(args.length() == 3); | 696 DCHECK(args.length() == 3); |
689 CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, sta, 0); | 697 CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, sta, 0); |
690 CONVERT_SIZE_ARG_CHECKED(index, 1); | 698 CONVERT_SIZE_ARG_CHECKED(index, 1); |
691 CONVERT_NUMBER_ARG_HANDLE_CHECKED(value, 2); | 699 CONVERT_NUMBER_ARG_HANDLE_CHECKED(value, 2); |
692 RUNTIME_ASSERT(sta->GetBuffer()->is_shared()); | 700 RUNTIME_ASSERT(sta->GetBuffer()->is_shared()); |
693 RUNTIME_ASSERT(index < NumberToSize(isolate, sta->length())); | 701 RUNTIME_ASSERT(index < NumberToSize(isolate, sta->length())); |
694 | 702 |
695 void* buffer = sta->GetBuffer()->backing_store(); | 703 uint8_t* source = static_cast<uint8_t*>(sta->GetBuffer()->backing_store()) + |
| 704 NumberToSize(isolate, sta->byte_offset()); |
696 | 705 |
697 switch (sta->type()) { | 706 switch (sta->type()) { |
698 #define TYPED_ARRAY_CASE(Type, typeName, TYPE, ctype, size) \ | 707 #define TYPED_ARRAY_CASE(Type, typeName, TYPE, ctype, size) \ |
699 case kExternal##Type##Array: \ | 708 case kExternal##Type##Array: \ |
700 return DoExchange<ctype>(isolate, buffer, index, value); | 709 return DoExchange<ctype>(isolate, source, index, value); |
701 | 710 |
702 INTEGER_TYPED_ARRAYS(TYPED_ARRAY_CASE) | 711 INTEGER_TYPED_ARRAYS(TYPED_ARRAY_CASE) |
703 #undef TYPED_ARRAY_CASE | 712 #undef TYPED_ARRAY_CASE |
704 | 713 |
705 case kExternalUint8ClampedArray: | 714 case kExternalUint8ClampedArray: |
706 return DoExchangeUint8Clamped(isolate, buffer, index, value); | 715 return DoExchangeUint8Clamped(isolate, source, index, value); |
707 | 716 |
708 default: | 717 default: |
709 break; | 718 break; |
710 } | 719 } |
711 | 720 |
712 UNREACHABLE(); | 721 UNREACHABLE(); |
713 return isolate->heap()->undefined_value(); | 722 return isolate->heap()->undefined_value(); |
714 } | 723 } |
715 | 724 |
716 | 725 |
717 RUNTIME_FUNCTION(Runtime_AtomicsIsLockFree) { | 726 RUNTIME_FUNCTION(Runtime_AtomicsIsLockFree) { |
718 HandleScope scope(isolate); | 727 HandleScope scope(isolate); |
719 DCHECK(args.length() == 1); | 728 DCHECK(args.length() == 1); |
720 CONVERT_NUMBER_ARG_HANDLE_CHECKED(size, 0); | 729 CONVERT_NUMBER_ARG_HANDLE_CHECKED(size, 0); |
721 uint32_t usize = NumberToUint32(*size); | 730 uint32_t usize = NumberToUint32(*size); |
722 return isolate->heap()->ToBoolean(AtomicIsLockFree(usize)); | 731 return isolate->heap()->ToBoolean(AtomicIsLockFree(usize)); |
723 } | 732 } |
724 } // namespace internal | 733 } // namespace internal |
725 } // namespace v8 | 734 } // namespace v8 |
OLD | NEW |