OLD | NEW |
---|---|
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
475 case CompileTimeValue::ARRAY_LITERAL: | 475 case CompileTimeValue::ARRAY_LITERAL: |
476 return Runtime::CreateArrayLiteralBoilerplate( | 476 return Runtime::CreateArrayLiteralBoilerplate( |
477 isolate, literals, elements); | 477 isolate, literals, elements); |
478 default: | 478 default: |
479 UNREACHABLE(); | 479 UNREACHABLE(); |
480 return MaybeHandle<Object>(); | 480 return MaybeHandle<Object>(); |
481 } | 481 } |
482 } | 482 } |
483 | 483 |
484 | 484 |
485 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_CreateObjectLiteral) { | 485 RUNTIME_FUNCTION(Object*, RuntimeHidden_CreateObjectLiteral) { |
486 HandleScope scope(isolate); | 486 HandleScope scope(isolate); |
487 ASSERT(args.length() == 4); | 487 ASSERT(args.length() == 4); |
488 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 0); | 488 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 0); |
489 CONVERT_SMI_ARG_CHECKED(literals_index, 1); | 489 CONVERT_SMI_ARG_CHECKED(literals_index, 1); |
490 CONVERT_ARG_HANDLE_CHECKED(FixedArray, constant_properties, 2); | 490 CONVERT_ARG_HANDLE_CHECKED(FixedArray, constant_properties, 2); |
491 CONVERT_SMI_ARG_CHECKED(flags, 3); | 491 CONVERT_SMI_ARG_CHECKED(flags, 3); |
492 bool should_have_fast_elements = (flags & ObjectLiteral::kFastElements) != 0; | 492 bool should_have_fast_elements = (flags & ObjectLiteral::kFastElements) != 0; |
493 bool has_function_literal = (flags & ObjectLiteral::kHasFunction) != 0; | 493 bool has_function_literal = (flags & ObjectLiteral::kHasFunction) != 0; |
494 | 494 |
495 RUNTIME_ASSERT(literals_index >= 0 && literals_index < literals->length()); | 495 RUNTIME_ASSERT(literals_index >= 0 && literals_index < literals->length()); |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
586 JSObject::DeepCopyHints hints = (flags & ArrayLiteral::kShallowElements) == 0 | 586 JSObject::DeepCopyHints hints = (flags & ArrayLiteral::kShallowElements) == 0 |
587 ? JSObject::kNoHints | 587 ? JSObject::kNoHints |
588 : JSObject::kObjectIsShallowArray; | 588 : JSObject::kObjectIsShallowArray; |
589 Handle<JSObject> copy = JSObject::DeepCopy(boilerplate, &usage_context, | 589 Handle<JSObject> copy = JSObject::DeepCopy(boilerplate, &usage_context, |
590 hints); | 590 hints); |
591 usage_context.ExitScope(site, boilerplate); | 591 usage_context.ExitScope(site, boilerplate); |
592 return copy; | 592 return copy; |
593 } | 593 } |
594 | 594 |
595 | 595 |
596 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_CreateArrayLiteral) { | 596 RUNTIME_FUNCTION(Object*, RuntimeHidden_CreateArrayLiteral) { |
597 HandleScope scope(isolate); | 597 HandleScope scope(isolate); |
598 ASSERT(args.length() == 4); | 598 ASSERT(args.length() == 4); |
599 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 0); | 599 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 0); |
600 CONVERT_SMI_ARG_CHECKED(literals_index, 1); | 600 CONVERT_SMI_ARG_CHECKED(literals_index, 1); |
601 CONVERT_ARG_HANDLE_CHECKED(FixedArray, elements, 2); | 601 CONVERT_ARG_HANDLE_CHECKED(FixedArray, elements, 2); |
602 CONVERT_SMI_ARG_CHECKED(flags, 3); | 602 CONVERT_SMI_ARG_CHECKED(flags, 3); |
603 | 603 |
604 Handle<JSObject> result; | 604 Handle<JSObject> result; |
605 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, | 605 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, |
606 CreateArrayLiteralImpl(isolate, literals, literals_index, elements, | 606 CreateArrayLiteralImpl(isolate, literals, literals_index, elements, |
607 flags)); | 607 flags)); |
608 return *result; | 608 return *result; |
609 } | 609 } |
610 | 610 |
611 | 611 |
612 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_CreateArrayLiteralStubBailout) { | 612 RUNTIME_FUNCTION(Object*, RuntimeHidden_CreateArrayLiteralStubBailout) { |
613 HandleScope scope(isolate); | 613 HandleScope scope(isolate); |
614 ASSERT(args.length() == 3); | 614 ASSERT(args.length() == 3); |
615 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 0); | 615 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 0); |
616 CONVERT_SMI_ARG_CHECKED(literals_index, 1); | 616 CONVERT_SMI_ARG_CHECKED(literals_index, 1); |
617 CONVERT_ARG_HANDLE_CHECKED(FixedArray, elements, 2); | 617 CONVERT_ARG_HANDLE_CHECKED(FixedArray, elements, 2); |
618 | 618 |
619 Handle<JSObject> result; | 619 Handle<JSObject> result; |
620 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, | 620 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, |
621 CreateArrayLiteralImpl(isolate, literals, literals_index, elements, | 621 CreateArrayLiteralImpl(isolate, literals, literals_index, elements, |
622 ArrayLiteral::kShallowElements)); | 622 ArrayLiteral::kShallowElements)); |
623 return *result; | 623 return *result; |
624 } | 624 } |
625 | 625 |
626 | 626 |
627 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateSymbol) { | 627 RUNTIME_FUNCTION(Object*, Runtime_CreateSymbol) { |
628 HandleScope scope(isolate); | 628 HandleScope scope(isolate); |
629 ASSERT(args.length() == 1); | 629 ASSERT(args.length() == 1); |
630 CONVERT_ARG_HANDLE_CHECKED(Object, name, 0); | 630 CONVERT_ARG_HANDLE_CHECKED(Object, name, 0); |
631 RUNTIME_ASSERT(name->IsString() || name->IsUndefined()); | 631 RUNTIME_ASSERT(name->IsString() || name->IsUndefined()); |
632 Handle<Symbol> symbol = isolate->factory()->NewSymbol(); | 632 Handle<Symbol> symbol = isolate->factory()->NewSymbol(); |
633 if (name->IsString()) symbol->set_name(*name); | 633 if (name->IsString()) symbol->set_name(*name); |
634 return *symbol; | 634 return *symbol; |
635 } | 635 } |
636 | 636 |
637 | 637 |
638 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreatePrivateSymbol) { | 638 RUNTIME_FUNCTION(Object*, Runtime_CreatePrivateSymbol) { |
639 HandleScope scope(isolate); | 639 HandleScope scope(isolate); |
640 ASSERT(args.length() == 1); | 640 ASSERT(args.length() == 1); |
641 CONVERT_ARG_HANDLE_CHECKED(Object, name, 0); | 641 CONVERT_ARG_HANDLE_CHECKED(Object, name, 0); |
642 RUNTIME_ASSERT(name->IsString() || name->IsUndefined()); | 642 RUNTIME_ASSERT(name->IsString() || name->IsUndefined()); |
643 Handle<Symbol> symbol = isolate->factory()->NewPrivateSymbol(); | 643 Handle<Symbol> symbol = isolate->factory()->NewPrivateSymbol(); |
644 if (name->IsString()) symbol->set_name(*name); | 644 if (name->IsString()) symbol->set_name(*name); |
645 return *symbol; | 645 return *symbol; |
646 } | 646 } |
647 | 647 |
648 | 648 |
649 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateGlobalPrivateSymbol) { | 649 RUNTIME_FUNCTION(Object*, Runtime_CreateGlobalPrivateSymbol) { |
650 HandleScope scope(isolate); | 650 HandleScope scope(isolate); |
651 ASSERT(args.length() == 1); | 651 ASSERT(args.length() == 1); |
652 CONVERT_ARG_HANDLE_CHECKED(String, name, 0); | 652 CONVERT_ARG_HANDLE_CHECKED(String, name, 0); |
653 Handle<JSObject> registry = isolate->GetSymbolRegistry(); | 653 Handle<JSObject> registry = isolate->GetSymbolRegistry(); |
654 Handle<String> part = isolate->factory()->private_intern_string(); | 654 Handle<String> part = isolate->factory()->private_intern_string(); |
655 Handle<Object> privates; | 655 Handle<Object> privates; |
656 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 656 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
657 isolate, privates, Object::GetPropertyOrElement(registry, part)); | 657 isolate, privates, Object::GetPropertyOrElement(registry, part)); |
658 Handle<Object> symbol; | 658 Handle<Object> symbol; |
659 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 659 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
660 isolate, symbol, Object::GetPropertyOrElement(privates, name)); | 660 isolate, symbol, Object::GetPropertyOrElement(privates, name)); |
661 if (!symbol->IsSymbol()) { | 661 if (!symbol->IsSymbol()) { |
662 ASSERT(symbol->IsUndefined()); | 662 ASSERT(symbol->IsUndefined()); |
663 symbol = isolate->factory()->NewPrivateSymbol(); | 663 symbol = isolate->factory()->NewPrivateSymbol(); |
664 Handle<Symbol>::cast(symbol)->set_name(*name); | 664 Handle<Symbol>::cast(symbol)->set_name(*name); |
665 JSObject::SetProperty(Handle<JSObject>::cast(privates), | 665 JSObject::SetProperty(Handle<JSObject>::cast(privates), |
666 name, symbol, NONE, STRICT).Assert(); | 666 name, symbol, NONE, STRICT).Assert(); |
667 } | 667 } |
668 return *symbol; | 668 return *symbol; |
669 } | 669 } |
670 | 670 |
671 | 671 |
672 RUNTIME_FUNCTION(MaybeObject*, Runtime_NewSymbolWrapper) { | 672 RUNTIME_FUNCTION(Object*, Runtime_NewSymbolWrapper) { |
673 HandleScope scope(isolate); | 673 HandleScope scope(isolate); |
674 ASSERT(args.length() == 1); | 674 ASSERT(args.length() == 1); |
675 CONVERT_ARG_HANDLE_CHECKED(Symbol, symbol, 0); | 675 CONVERT_ARG_HANDLE_CHECKED(Symbol, symbol, 0); |
676 return *Object::ToObject(isolate, symbol).ToHandleChecked(); | 676 return *Object::ToObject(isolate, symbol).ToHandleChecked(); |
677 } | 677 } |
678 | 678 |
679 | 679 |
680 RUNTIME_FUNCTION(MaybeObject*, Runtime_SymbolDescription) { | 680 RUNTIME_FUNCTION(Object*, Runtime_SymbolDescription) { |
681 SealHandleScope shs(isolate); | 681 SealHandleScope shs(isolate); |
682 ASSERT(args.length() == 1); | 682 ASSERT(args.length() == 1); |
683 CONVERT_ARG_CHECKED(Symbol, symbol, 0); | 683 CONVERT_ARG_CHECKED(Symbol, symbol, 0); |
684 return symbol->name(); | 684 return symbol->name(); |
685 } | 685 } |
686 | 686 |
687 | 687 |
688 RUNTIME_FUNCTION(MaybeObject*, Runtime_SymbolRegistry) { | 688 RUNTIME_FUNCTION(Object*, Runtime_SymbolRegistry) { |
689 HandleScope scope(isolate); | 689 HandleScope scope(isolate); |
690 ASSERT(args.length() == 0); | 690 ASSERT(args.length() == 0); |
691 return *isolate->GetSymbolRegistry(); | 691 return *isolate->GetSymbolRegistry(); |
692 } | 692 } |
693 | 693 |
694 | 694 |
695 RUNTIME_FUNCTION(MaybeObject*, Runtime_SymbolIsPrivate) { | 695 RUNTIME_FUNCTION(Object*, Runtime_SymbolIsPrivate) { |
696 SealHandleScope shs(isolate); | 696 SealHandleScope shs(isolate); |
697 ASSERT(args.length() == 1); | 697 ASSERT(args.length() == 1); |
698 CONVERT_ARG_CHECKED(Symbol, symbol, 0); | 698 CONVERT_ARG_CHECKED(Symbol, symbol, 0); |
699 return isolate->heap()->ToBoolean(symbol->is_private()); | 699 return isolate->heap()->ToBoolean(symbol->is_private()); |
700 } | 700 } |
701 | 701 |
702 | 702 |
703 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateJSProxy) { | 703 RUNTIME_FUNCTION(Object*, Runtime_CreateJSProxy) { |
704 HandleScope scope(isolate); | 704 HandleScope scope(isolate); |
705 ASSERT(args.length() == 2); | 705 ASSERT(args.length() == 2); |
706 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, handler, 0); | 706 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, handler, 0); |
707 CONVERT_ARG_HANDLE_CHECKED(Object, prototype, 1); | 707 CONVERT_ARG_HANDLE_CHECKED(Object, prototype, 1); |
708 if (!prototype->IsJSReceiver()) prototype = isolate->factory()->null_value(); | 708 if (!prototype->IsJSReceiver()) prototype = isolate->factory()->null_value(); |
709 return *isolate->factory()->NewJSProxy(handler, prototype); | 709 return *isolate->factory()->NewJSProxy(handler, prototype); |
710 } | 710 } |
711 | 711 |
712 | 712 |
713 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateJSFunctionProxy) { | 713 RUNTIME_FUNCTION(Object*, Runtime_CreateJSFunctionProxy) { |
714 HandleScope scope(isolate); | 714 HandleScope scope(isolate); |
715 ASSERT(args.length() == 4); | 715 ASSERT(args.length() == 4); |
716 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, handler, 0); | 716 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, handler, 0); |
717 CONVERT_ARG_HANDLE_CHECKED(Object, call_trap, 1); | 717 CONVERT_ARG_HANDLE_CHECKED(Object, call_trap, 1); |
718 RUNTIME_ASSERT(call_trap->IsJSFunction() || call_trap->IsJSFunctionProxy()); | 718 RUNTIME_ASSERT(call_trap->IsJSFunction() || call_trap->IsJSFunctionProxy()); |
719 CONVERT_ARG_HANDLE_CHECKED(JSFunction, construct_trap, 2); | 719 CONVERT_ARG_HANDLE_CHECKED(JSFunction, construct_trap, 2); |
720 CONVERT_ARG_HANDLE_CHECKED(Object, prototype, 3); | 720 CONVERT_ARG_HANDLE_CHECKED(Object, prototype, 3); |
721 if (!prototype->IsJSReceiver()) prototype = isolate->factory()->null_value(); | 721 if (!prototype->IsJSReceiver()) prototype = isolate->factory()->null_value(); |
722 return *isolate->factory()->NewJSFunctionProxy( | 722 return *isolate->factory()->NewJSFunctionProxy( |
723 handler, call_trap, construct_trap, prototype); | 723 handler, call_trap, construct_trap, prototype); |
724 } | 724 } |
725 | 725 |
726 | 726 |
727 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsJSProxy) { | 727 RUNTIME_FUNCTION(Object*, Runtime_IsJSProxy) { |
728 SealHandleScope shs(isolate); | 728 SealHandleScope shs(isolate); |
729 ASSERT(args.length() == 1); | 729 ASSERT(args.length() == 1); |
730 CONVERT_ARG_HANDLE_CHECKED(Object, obj, 0); | 730 CONVERT_ARG_HANDLE_CHECKED(Object, obj, 0); |
731 return isolate->heap()->ToBoolean(obj->IsJSProxy()); | 731 return isolate->heap()->ToBoolean(obj->IsJSProxy()); |
732 } | 732 } |
733 | 733 |
734 | 734 |
735 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsJSFunctionProxy) { | 735 RUNTIME_FUNCTION(Object*, Runtime_IsJSFunctionProxy) { |
736 SealHandleScope shs(isolate); | 736 SealHandleScope shs(isolate); |
737 ASSERT(args.length() == 1); | 737 ASSERT(args.length() == 1); |
738 CONVERT_ARG_HANDLE_CHECKED(Object, obj, 0); | 738 CONVERT_ARG_HANDLE_CHECKED(Object, obj, 0); |
739 return isolate->heap()->ToBoolean(obj->IsJSFunctionProxy()); | 739 return isolate->heap()->ToBoolean(obj->IsJSFunctionProxy()); |
740 } | 740 } |
741 | 741 |
742 | 742 |
743 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetHandler) { | 743 RUNTIME_FUNCTION(Object*, Runtime_GetHandler) { |
744 SealHandleScope shs(isolate); | 744 SealHandleScope shs(isolate); |
745 ASSERT(args.length() == 1); | 745 ASSERT(args.length() == 1); |
746 CONVERT_ARG_CHECKED(JSProxy, proxy, 0); | 746 CONVERT_ARG_CHECKED(JSProxy, proxy, 0); |
747 return proxy->handler(); | 747 return proxy->handler(); |
748 } | 748 } |
749 | 749 |
750 | 750 |
751 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetCallTrap) { | 751 RUNTIME_FUNCTION(Object*, Runtime_GetCallTrap) { |
752 SealHandleScope shs(isolate); | 752 SealHandleScope shs(isolate); |
753 ASSERT(args.length() == 1); | 753 ASSERT(args.length() == 1); |
754 CONVERT_ARG_CHECKED(JSFunctionProxy, proxy, 0); | 754 CONVERT_ARG_CHECKED(JSFunctionProxy, proxy, 0); |
755 return proxy->call_trap(); | 755 return proxy->call_trap(); |
756 } | 756 } |
757 | 757 |
758 | 758 |
759 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetConstructTrap) { | 759 RUNTIME_FUNCTION(Object*, Runtime_GetConstructTrap) { |
760 SealHandleScope shs(isolate); | 760 SealHandleScope shs(isolate); |
761 ASSERT(args.length() == 1); | 761 ASSERT(args.length() == 1); |
762 CONVERT_ARG_CHECKED(JSFunctionProxy, proxy, 0); | 762 CONVERT_ARG_CHECKED(JSFunctionProxy, proxy, 0); |
763 return proxy->construct_trap(); | 763 return proxy->construct_trap(); |
764 } | 764 } |
765 | 765 |
766 | 766 |
767 RUNTIME_FUNCTION(MaybeObject*, Runtime_Fix) { | 767 RUNTIME_FUNCTION(Object*, Runtime_Fix) { |
768 HandleScope scope(isolate); | 768 HandleScope scope(isolate); |
769 ASSERT(args.length() == 1); | 769 ASSERT(args.length() == 1); |
770 CONVERT_ARG_HANDLE_CHECKED(JSProxy, proxy, 0); | 770 CONVERT_ARG_HANDLE_CHECKED(JSProxy, proxy, 0); |
771 JSProxy::Fix(proxy); | 771 JSProxy::Fix(proxy); |
772 return isolate->heap()->undefined_value(); | 772 return isolate->heap()->undefined_value(); |
773 } | 773 } |
774 | 774 |
775 | 775 |
776 void Runtime::FreeArrayBuffer(Isolate* isolate, | 776 void Runtime::FreeArrayBuffer(Isolate* isolate, |
777 JSArrayBuffer* phantom_array_buffer) { | 777 JSArrayBuffer* phantom_array_buffer) { |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
856 JSDataView::cast(*view)->Neuter(); | 856 JSDataView::cast(*view)->Neuter(); |
857 } else { | 857 } else { |
858 UNREACHABLE(); | 858 UNREACHABLE(); |
859 } | 859 } |
860 view_obj = handle(view->weak_next(), isolate); | 860 view_obj = handle(view->weak_next(), isolate); |
861 } | 861 } |
862 array_buffer->Neuter(); | 862 array_buffer->Neuter(); |
863 } | 863 } |
864 | 864 |
865 | 865 |
866 RUNTIME_FUNCTION(MaybeObject*, Runtime_ArrayBufferInitialize) { | 866 RUNTIME_FUNCTION(Object*, Runtime_ArrayBufferInitialize) { |
867 HandleScope scope(isolate); | 867 HandleScope scope(isolate); |
868 ASSERT(args.length() == 2); | 868 ASSERT(args.length() == 2); |
869 CONVERT_ARG_HANDLE_CHECKED(JSArrayBuffer, holder, 0); | 869 CONVERT_ARG_HANDLE_CHECKED(JSArrayBuffer, holder, 0); |
870 CONVERT_NUMBER_ARG_HANDLE_CHECKED(byteLength, 1); | 870 CONVERT_NUMBER_ARG_HANDLE_CHECKED(byteLength, 1); |
871 size_t allocated_length = 0; | 871 size_t allocated_length = 0; |
872 if (!TryNumberToSize(isolate, *byteLength, &allocated_length)) { | 872 if (!TryNumberToSize(isolate, *byteLength, &allocated_length)) { |
873 return isolate->Throw( | 873 return isolate->Throw( |
874 *isolate->factory()->NewRangeError("invalid_array_buffer_length", | 874 *isolate->factory()->NewRangeError("invalid_array_buffer_length", |
875 HandleVector<Object>(NULL, 0))); | 875 HandleVector<Object>(NULL, 0))); |
876 } | 876 } |
877 if (!Runtime::SetupArrayBufferAllocatingData(isolate, | 877 if (!Runtime::SetupArrayBufferAllocatingData(isolate, |
878 holder, allocated_length)) { | 878 holder, allocated_length)) { |
879 return isolate->Throw( | 879 return isolate->Throw( |
880 *isolate->factory()->NewRangeError("invalid_array_buffer_length", | 880 *isolate->factory()->NewRangeError("invalid_array_buffer_length", |
881 HandleVector<Object>(NULL, 0))); | 881 HandleVector<Object>(NULL, 0))); |
882 } | 882 } |
883 return *holder; | 883 return *holder; |
884 } | 884 } |
885 | 885 |
886 | 886 |
887 RUNTIME_FUNCTION(MaybeObject*, Runtime_ArrayBufferGetByteLength) { | 887 RUNTIME_FUNCTION(Object*, Runtime_ArrayBufferGetByteLength) { |
888 SealHandleScope shs(isolate); | 888 SealHandleScope shs(isolate); |
889 ASSERT(args.length() == 1); | 889 ASSERT(args.length() == 1); |
890 CONVERT_ARG_CHECKED(JSArrayBuffer, holder, 0); | 890 CONVERT_ARG_CHECKED(JSArrayBuffer, holder, 0); |
891 return holder->byte_length(); | 891 return holder->byte_length(); |
892 } | 892 } |
893 | 893 |
894 | 894 |
895 RUNTIME_FUNCTION(MaybeObject*, Runtime_ArrayBufferSliceImpl) { | 895 RUNTIME_FUNCTION(Object*, Runtime_ArrayBufferSliceImpl) { |
896 HandleScope scope(isolate); | 896 HandleScope scope(isolate); |
897 ASSERT(args.length() == 3); | 897 ASSERT(args.length() == 3); |
898 CONVERT_ARG_HANDLE_CHECKED(JSArrayBuffer, source, 0); | 898 CONVERT_ARG_HANDLE_CHECKED(JSArrayBuffer, source, 0); |
899 CONVERT_ARG_HANDLE_CHECKED(JSArrayBuffer, target, 1); | 899 CONVERT_ARG_HANDLE_CHECKED(JSArrayBuffer, target, 1); |
900 CONVERT_NUMBER_ARG_HANDLE_CHECKED(first, 2); | 900 CONVERT_NUMBER_ARG_HANDLE_CHECKED(first, 2); |
901 size_t start = 0; | 901 size_t start = 0; |
902 RUNTIME_ASSERT(TryNumberToSize(isolate, *first, &start)); | 902 RUNTIME_ASSERT(TryNumberToSize(isolate, *first, &start)); |
903 size_t target_length = NumberToSize(isolate, target->byte_length()); | 903 size_t target_length = NumberToSize(isolate, target->byte_length()); |
904 | 904 |
905 if (target_length == 0) return isolate->heap()->undefined_value(); | 905 if (target_length == 0) return isolate->heap()->undefined_value(); |
906 | 906 |
907 size_t source_byte_length = NumberToSize(isolate, source->byte_length()); | 907 size_t source_byte_length = NumberToSize(isolate, source->byte_length()); |
908 RUNTIME_ASSERT(start <= source_byte_length); | 908 RUNTIME_ASSERT(start <= source_byte_length); |
909 RUNTIME_ASSERT(source_byte_length - start >= target_length); | 909 RUNTIME_ASSERT(source_byte_length - start >= target_length); |
910 uint8_t* source_data = reinterpret_cast<uint8_t*>(source->backing_store()); | 910 uint8_t* source_data = reinterpret_cast<uint8_t*>(source->backing_store()); |
911 uint8_t* target_data = reinterpret_cast<uint8_t*>(target->backing_store()); | 911 uint8_t* target_data = reinterpret_cast<uint8_t*>(target->backing_store()); |
912 CopyBytes(target_data, source_data + start, target_length); | 912 CopyBytes(target_data, source_data + start, target_length); |
913 return isolate->heap()->undefined_value(); | 913 return isolate->heap()->undefined_value(); |
914 } | 914 } |
915 | 915 |
916 | 916 |
917 RUNTIME_FUNCTION(MaybeObject*, Runtime_ArrayBufferIsView) { | 917 RUNTIME_FUNCTION(Object*, Runtime_ArrayBufferIsView) { |
918 HandleScope scope(isolate); | 918 HandleScope scope(isolate); |
919 ASSERT(args.length() == 1); | 919 ASSERT(args.length() == 1); |
920 CONVERT_ARG_CHECKED(Object, object, 0); | 920 CONVERT_ARG_CHECKED(Object, object, 0); |
921 return isolate->heap()->ToBoolean(object->IsJSArrayBufferView()); | 921 return isolate->heap()->ToBoolean(object->IsJSArrayBufferView()); |
922 } | 922 } |
923 | 923 |
924 | 924 |
925 RUNTIME_FUNCTION(MaybeObject*, Runtime_ArrayBufferNeuter) { | 925 RUNTIME_FUNCTION(Object*, Runtime_ArrayBufferNeuter) { |
926 HandleScope scope(isolate); | 926 HandleScope scope(isolate); |
927 ASSERT(args.length() == 1); | 927 ASSERT(args.length() == 1); |
928 CONVERT_ARG_HANDLE_CHECKED(JSArrayBuffer, array_buffer, 0); | 928 CONVERT_ARG_HANDLE_CHECKED(JSArrayBuffer, array_buffer, 0); |
929 if (array_buffer->backing_store() == NULL) { | 929 if (array_buffer->backing_store() == NULL) { |
930 CHECK(Smi::FromInt(0) == array_buffer->byte_length()); | 930 CHECK(Smi::FromInt(0) == array_buffer->byte_length()); |
931 return isolate->heap()->undefined_value(); | 931 return isolate->heap()->undefined_value(); |
932 } | 932 } |
933 ASSERT(!array_buffer->is_external()); | 933 ASSERT(!array_buffer->is_external()); |
934 void* backing_store = array_buffer->backing_store(); | 934 void* backing_store = array_buffer->backing_store(); |
935 size_t byte_length = NumberToSize(isolate, array_buffer->byte_length()); | 935 size_t byte_length = NumberToSize(isolate, array_buffer->byte_length()); |
(...skipping 21 matching lines...) Expand all Loading... | |
957 | 957 |
958 TYPED_ARRAYS(ARRAY_ID_CASE) | 958 TYPED_ARRAYS(ARRAY_ID_CASE) |
959 #undef ARRAY_ID_CASE | 959 #undef ARRAY_ID_CASE |
960 | 960 |
961 default: | 961 default: |
962 UNREACHABLE(); | 962 UNREACHABLE(); |
963 } | 963 } |
964 } | 964 } |
965 | 965 |
966 | 966 |
967 RUNTIME_FUNCTION(MaybeObject*, Runtime_TypedArrayInitialize) { | 967 RUNTIME_FUNCTION(Object*, Runtime_TypedArrayInitialize) { |
968 HandleScope scope(isolate); | 968 HandleScope scope(isolate); |
969 ASSERT(args.length() == 5); | 969 ASSERT(args.length() == 5); |
970 CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, holder, 0); | 970 CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, holder, 0); |
971 CONVERT_SMI_ARG_CHECKED(arrayId, 1); | 971 CONVERT_SMI_ARG_CHECKED(arrayId, 1); |
972 CONVERT_ARG_HANDLE_CHECKED(Object, maybe_buffer, 2); | 972 CONVERT_ARG_HANDLE_CHECKED(Object, maybe_buffer, 2); |
973 CONVERT_NUMBER_ARG_HANDLE_CHECKED(byte_offset_object, 3); | 973 CONVERT_NUMBER_ARG_HANDLE_CHECKED(byte_offset_object, 3); |
974 CONVERT_NUMBER_ARG_HANDLE_CHECKED(byte_length_object, 4); | 974 CONVERT_NUMBER_ARG_HANDLE_CHECKED(byte_length_object, 4); |
975 | 975 |
976 ASSERT(holder->GetInternalFieldCount() == | 976 ASSERT(holder->GetInternalFieldCount() == |
977 v8::ArrayBufferView::kInternalFieldCount); | 977 v8::ArrayBufferView::kInternalFieldCount); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1039 } | 1039 } |
1040 return isolate->heap()->undefined_value(); | 1040 return isolate->heap()->undefined_value(); |
1041 } | 1041 } |
1042 | 1042 |
1043 | 1043 |
1044 // Initializes a typed array from an array-like object. | 1044 // Initializes a typed array from an array-like object. |
1045 // If an array-like object happens to be a typed array of the same type, | 1045 // If an array-like object happens to be a typed array of the same type, |
1046 // initializes backing store using memove. | 1046 // initializes backing store using memove. |
1047 // | 1047 // |
1048 // Returns true if backing store was initialized or false otherwise. | 1048 // Returns true if backing store was initialized or false otherwise. |
1049 RUNTIME_FUNCTION(MaybeObject*, Runtime_TypedArrayInitializeFromArrayLike) { | 1049 RUNTIME_FUNCTION(Object*, Runtime_TypedArrayInitializeFromArrayLike) { |
1050 HandleScope scope(isolate); | 1050 HandleScope scope(isolate); |
1051 ASSERT(args.length() == 4); | 1051 ASSERT(args.length() == 4); |
1052 CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, holder, 0); | 1052 CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, holder, 0); |
1053 CONVERT_SMI_ARG_CHECKED(arrayId, 1); | 1053 CONVERT_SMI_ARG_CHECKED(arrayId, 1); |
1054 CONVERT_ARG_HANDLE_CHECKED(Object, source, 2); | 1054 CONVERT_ARG_HANDLE_CHECKED(Object, source, 2); |
1055 CONVERT_ARG_HANDLE_CHECKED(Object, length_obj, 3); | 1055 CONVERT_ARG_HANDLE_CHECKED(Object, length_obj, 3); |
1056 | 1056 |
1057 ASSERT(holder->GetInternalFieldCount() == | 1057 ASSERT(holder->GetInternalFieldCount() == |
1058 v8::ArrayBufferView::kInternalFieldCount); | 1058 v8::ArrayBufferView::kInternalFieldCount); |
1059 for (int i = 0; i < v8::ArrayBufferView::kInternalFieldCount; i++) { | 1059 for (int i = 0; i < v8::ArrayBufferView::kInternalFieldCount; i++) { |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1141 byte_length); | 1141 byte_length); |
1142 return isolate->heap()->true_value(); | 1142 return isolate->heap()->true_value(); |
1143 } | 1143 } |
1144 } | 1144 } |
1145 | 1145 |
1146 return isolate->heap()->false_value(); | 1146 return isolate->heap()->false_value(); |
1147 } | 1147 } |
1148 | 1148 |
1149 | 1149 |
1150 #define BUFFER_VIEW_GETTER(Type, getter, accessor) \ | 1150 #define BUFFER_VIEW_GETTER(Type, getter, accessor) \ |
1151 RUNTIME_FUNCTION(MaybeObject*, Runtime_##Type##Get##getter) { \ | 1151 RUNTIME_FUNCTION(Object*, Runtime_##Type##Get##getter) { \ |
1152 HandleScope scope(isolate); \ | 1152 HandleScope scope(isolate); \ |
1153 ASSERT(args.length() == 1); \ | 1153 ASSERT(args.length() == 1); \ |
1154 CONVERT_ARG_HANDLE_CHECKED(JS##Type, holder, 0); \ | 1154 CONVERT_ARG_HANDLE_CHECKED(JS##Type, holder, 0); \ |
1155 return holder->accessor(); \ | 1155 return holder->accessor(); \ |
1156 } | 1156 } |
1157 | 1157 |
1158 BUFFER_VIEW_GETTER(ArrayBufferView, ByteLength, byte_length) | 1158 BUFFER_VIEW_GETTER(ArrayBufferView, ByteLength, byte_length) |
1159 BUFFER_VIEW_GETTER(ArrayBufferView, ByteOffset, byte_offset) | 1159 BUFFER_VIEW_GETTER(ArrayBufferView, ByteOffset, byte_offset) |
1160 BUFFER_VIEW_GETTER(TypedArray, Length, length) | 1160 BUFFER_VIEW_GETTER(TypedArray, Length, length) |
1161 BUFFER_VIEW_GETTER(DataView, Buffer, buffer) | 1161 BUFFER_VIEW_GETTER(DataView, Buffer, buffer) |
1162 | 1162 |
1163 #undef BUFFER_VIEW_GETTER | 1163 #undef BUFFER_VIEW_GETTER |
1164 | 1164 |
1165 RUNTIME_FUNCTION(MaybeObject*, Runtime_TypedArrayGetBuffer) { | 1165 RUNTIME_FUNCTION(Object*, Runtime_TypedArrayGetBuffer) { |
1166 HandleScope scope(isolate); | 1166 HandleScope scope(isolate); |
1167 ASSERT(args.length() == 1); | 1167 ASSERT(args.length() == 1); |
1168 CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, holder, 0); | 1168 CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, holder, 0); |
1169 return *holder->GetBuffer(); | 1169 return *holder->GetBuffer(); |
1170 } | 1170 } |
1171 | 1171 |
1172 | 1172 |
1173 // Return codes for Runtime_TypedArraySetFastCases. | 1173 // Return codes for Runtime_TypedArraySetFastCases. |
1174 // Should be synchronized with typedarray.js natives. | 1174 // Should be synchronized with typedarray.js natives. |
1175 enum TypedArraySetResultCodes { | 1175 enum TypedArraySetResultCodes { |
1176 // Set from typed array of the same type. | 1176 // Set from typed array of the same type. |
1177 // This is processed by TypedArraySetFastCases | 1177 // This is processed by TypedArraySetFastCases |
1178 TYPED_ARRAY_SET_TYPED_ARRAY_SAME_TYPE = 0, | 1178 TYPED_ARRAY_SET_TYPED_ARRAY_SAME_TYPE = 0, |
1179 // Set from typed array of the different type, overlapping in memory. | 1179 // Set from typed array of the different type, overlapping in memory. |
1180 TYPED_ARRAY_SET_TYPED_ARRAY_OVERLAPPING = 1, | 1180 TYPED_ARRAY_SET_TYPED_ARRAY_OVERLAPPING = 1, |
1181 // Set from typed array of the different type, non-overlapping. | 1181 // Set from typed array of the different type, non-overlapping. |
1182 TYPED_ARRAY_SET_TYPED_ARRAY_NONOVERLAPPING = 2, | 1182 TYPED_ARRAY_SET_TYPED_ARRAY_NONOVERLAPPING = 2, |
1183 // Set from non-typed array. | 1183 // Set from non-typed array. |
1184 TYPED_ARRAY_SET_NON_TYPED_ARRAY = 3 | 1184 TYPED_ARRAY_SET_NON_TYPED_ARRAY = 3 |
1185 }; | 1185 }; |
1186 | 1186 |
1187 | 1187 |
1188 RUNTIME_FUNCTION(MaybeObject*, Runtime_TypedArraySetFastCases) { | 1188 RUNTIME_FUNCTION(Object*, Runtime_TypedArraySetFastCases) { |
1189 HandleScope scope(isolate); | 1189 HandleScope scope(isolate); |
1190 ASSERT(args.length() == 3); | 1190 ASSERT(args.length() == 3); |
1191 CONVERT_ARG_HANDLE_CHECKED(Object, target_obj, 0); | 1191 CONVERT_ARG_HANDLE_CHECKED(Object, target_obj, 0); |
1192 CONVERT_ARG_HANDLE_CHECKED(Object, source_obj, 1); | 1192 CONVERT_ARG_HANDLE_CHECKED(Object, source_obj, 1); |
1193 CONVERT_ARG_HANDLE_CHECKED(Object, offset_obj, 2); | 1193 CONVERT_ARG_HANDLE_CHECKED(Object, offset_obj, 2); |
1194 | 1194 |
1195 if (!target_obj->IsJSTypedArray()) | 1195 if (!target_obj->IsJSTypedArray()) |
1196 return isolate->Throw(*isolate->factory()->NewTypeError( | 1196 return isolate->Throw(*isolate->factory()->NewTypeError( |
1197 "not_typed_array", HandleVector<Object>(NULL, 0))); | 1197 "not_typed_array", HandleVector<Object>(NULL, 0))); |
1198 | 1198 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1237 ASSERT( | 1237 ASSERT( |
1238 target->GetBuffer()->backing_store() == | 1238 target->GetBuffer()->backing_store() == |
1239 source->GetBuffer()->backing_store()); | 1239 source->GetBuffer()->backing_store()); |
1240 return Smi::FromInt(TYPED_ARRAY_SET_TYPED_ARRAY_OVERLAPPING); | 1240 return Smi::FromInt(TYPED_ARRAY_SET_TYPED_ARRAY_OVERLAPPING); |
1241 } else { // Non-overlapping typed arrays | 1241 } else { // Non-overlapping typed arrays |
1242 return Smi::FromInt(TYPED_ARRAY_SET_TYPED_ARRAY_NONOVERLAPPING); | 1242 return Smi::FromInt(TYPED_ARRAY_SET_TYPED_ARRAY_NONOVERLAPPING); |
1243 } | 1243 } |
1244 } | 1244 } |
1245 | 1245 |
1246 | 1246 |
1247 RUNTIME_FUNCTION(MaybeObject*, Runtime_TypedArrayMaxSizeInHeap) { | 1247 RUNTIME_FUNCTION(Object*, Runtime_TypedArrayMaxSizeInHeap) { |
1248 ASSERT(args.length() == 0); | 1248 ASSERT(args.length() == 0); |
1249 ASSERT_OBJECT_SIZE( | 1249 ASSERT_OBJECT_SIZE( |
1250 FLAG_typed_array_max_size_in_heap + FixedTypedArrayBase::kDataOffset); | 1250 FLAG_typed_array_max_size_in_heap + FixedTypedArrayBase::kDataOffset); |
1251 return Smi::FromInt(FLAG_typed_array_max_size_in_heap); | 1251 return Smi::FromInt(FLAG_typed_array_max_size_in_heap); |
1252 } | 1252 } |
1253 | 1253 |
1254 | 1254 |
1255 RUNTIME_FUNCTION(MaybeObject*, Runtime_DataViewInitialize) { | 1255 RUNTIME_FUNCTION(Object*, Runtime_DataViewInitialize) { |
1256 HandleScope scope(isolate); | 1256 HandleScope scope(isolate); |
1257 ASSERT(args.length() == 4); | 1257 ASSERT(args.length() == 4); |
1258 CONVERT_ARG_HANDLE_CHECKED(JSDataView, holder, 0); | 1258 CONVERT_ARG_HANDLE_CHECKED(JSDataView, holder, 0); |
1259 CONVERT_ARG_HANDLE_CHECKED(JSArrayBuffer, buffer, 1); | 1259 CONVERT_ARG_HANDLE_CHECKED(JSArrayBuffer, buffer, 1); |
1260 CONVERT_ARG_HANDLE_CHECKED(Object, byte_offset, 2); | 1260 CONVERT_ARG_HANDLE_CHECKED(Object, byte_offset, 2); |
1261 CONVERT_ARG_HANDLE_CHECKED(Object, byte_length, 3); | 1261 CONVERT_ARG_HANDLE_CHECKED(Object, byte_length, 3); |
1262 | 1262 |
1263 ASSERT(holder->GetInternalFieldCount() == | 1263 ASSERT(holder->GetInternalFieldCount() == |
1264 v8::ArrayBufferView::kInternalFieldCount); | 1264 v8::ArrayBufferView::kInternalFieldCount); |
1265 for (int i = 0; i < v8::ArrayBufferView::kInternalFieldCount; i++) { | 1265 for (int i = 0; i < v8::ArrayBufferView::kInternalFieldCount; i++) { |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1391 if (NeedToFlipBytes(is_little_endian)) { | 1391 if (NeedToFlipBytes(is_little_endian)) { |
1392 FlipBytes<sizeof(T)>(target, value.bytes); | 1392 FlipBytes<sizeof(T)>(target, value.bytes); |
1393 } else { | 1393 } else { |
1394 CopyBytes<sizeof(T)>(target, value.bytes); | 1394 CopyBytes<sizeof(T)>(target, value.bytes); |
1395 } | 1395 } |
1396 return true; | 1396 return true; |
1397 } | 1397 } |
1398 | 1398 |
1399 | 1399 |
1400 #define DATA_VIEW_GETTER(TypeName, Type, Converter) \ | 1400 #define DATA_VIEW_GETTER(TypeName, Type, Converter) \ |
1401 RUNTIME_FUNCTION(MaybeObject*, Runtime_DataViewGet##TypeName) { \ | 1401 RUNTIME_FUNCTION(Object*, Runtime_DataViewGet##TypeName) { \ |
1402 HandleScope scope(isolate); \ | 1402 HandleScope scope(isolate); \ |
1403 ASSERT(args.length() == 3); \ | 1403 ASSERT(args.length() == 3); \ |
1404 CONVERT_ARG_HANDLE_CHECKED(JSDataView, holder, 0); \ | 1404 CONVERT_ARG_HANDLE_CHECKED(JSDataView, holder, 0); \ |
1405 CONVERT_ARG_HANDLE_CHECKED(Object, offset, 1); \ | 1405 CONVERT_ARG_HANDLE_CHECKED(Object, offset, 1); \ |
1406 CONVERT_BOOLEAN_ARG_CHECKED(is_little_endian, 2); \ | 1406 CONVERT_BOOLEAN_ARG_CHECKED(is_little_endian, 2); \ |
1407 Type result; \ | 1407 Type result; \ |
1408 if (DataViewGetValue( \ | 1408 if (DataViewGetValue( \ |
1409 isolate, holder, offset, is_little_endian, &result)) { \ | 1409 isolate, holder, offset, is_little_endian, &result)) { \ |
1410 return *isolate->factory()->Converter(result); \ | 1410 return *isolate->factory()->Converter(result); \ |
1411 } else { \ | 1411 } else { \ |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1473 } | 1473 } |
1474 | 1474 |
1475 | 1475 |
1476 template <> | 1476 template <> |
1477 double DataViewConvertValue<double>(double value) { | 1477 double DataViewConvertValue<double>(double value) { |
1478 return value; | 1478 return value; |
1479 } | 1479 } |
1480 | 1480 |
1481 | 1481 |
1482 #define DATA_VIEW_SETTER(TypeName, Type) \ | 1482 #define DATA_VIEW_SETTER(TypeName, Type) \ |
1483 RUNTIME_FUNCTION(MaybeObject*, Runtime_DataViewSet##TypeName) { \ | 1483 RUNTIME_FUNCTION(Object*, Runtime_DataViewSet##TypeName) { \ |
1484 HandleScope scope(isolate); \ | 1484 HandleScope scope(isolate); \ |
1485 ASSERT(args.length() == 4); \ | 1485 ASSERT(args.length() == 4); \ |
1486 CONVERT_ARG_HANDLE_CHECKED(JSDataView, holder, 0); \ | 1486 CONVERT_ARG_HANDLE_CHECKED(JSDataView, holder, 0); \ |
1487 CONVERT_ARG_HANDLE_CHECKED(Object, offset, 1); \ | 1487 CONVERT_ARG_HANDLE_CHECKED(Object, offset, 1); \ |
1488 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); \ | 1488 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); \ |
1489 CONVERT_BOOLEAN_ARG_CHECKED(is_little_endian, 3); \ | 1489 CONVERT_BOOLEAN_ARG_CHECKED(is_little_endian, 3); \ |
1490 Type v = DataViewConvertValue<Type>(value->Number()); \ | 1490 Type v = DataViewConvertValue<Type>(value->Number()); \ |
1491 if (DataViewSetValue( \ | 1491 if (DataViewSetValue( \ |
1492 isolate, holder, offset, is_little_endian, v)) { \ | 1492 isolate, holder, offset, is_little_endian, v)) { \ |
1493 return isolate->heap()->undefined_value(); \ | 1493 return isolate->heap()->undefined_value(); \ |
1494 } else { \ | 1494 } else { \ |
1495 return isolate->Throw(*isolate->factory()->NewRangeError( \ | 1495 return isolate->Throw(*isolate->factory()->NewRangeError( \ |
1496 "invalid_data_view_accessor_offset", \ | 1496 "invalid_data_view_accessor_offset", \ |
1497 HandleVector<Object>(NULL, 0))); \ | 1497 HandleVector<Object>(NULL, 0))); \ |
1498 } \ | 1498 } \ |
1499 } | 1499 } |
1500 | 1500 |
1501 DATA_VIEW_SETTER(Uint8, uint8_t) | 1501 DATA_VIEW_SETTER(Uint8, uint8_t) |
1502 DATA_VIEW_SETTER(Int8, int8_t) | 1502 DATA_VIEW_SETTER(Int8, int8_t) |
1503 DATA_VIEW_SETTER(Uint16, uint16_t) | 1503 DATA_VIEW_SETTER(Uint16, uint16_t) |
1504 DATA_VIEW_SETTER(Int16, int16_t) | 1504 DATA_VIEW_SETTER(Int16, int16_t) |
1505 DATA_VIEW_SETTER(Uint32, uint32_t) | 1505 DATA_VIEW_SETTER(Uint32, uint32_t) |
1506 DATA_VIEW_SETTER(Int32, int32_t) | 1506 DATA_VIEW_SETTER(Int32, int32_t) |
1507 DATA_VIEW_SETTER(Float32, float) | 1507 DATA_VIEW_SETTER(Float32, float) |
1508 DATA_VIEW_SETTER(Float64, double) | 1508 DATA_VIEW_SETTER(Float64, double) |
1509 | 1509 |
1510 #undef DATA_VIEW_SETTER | 1510 #undef DATA_VIEW_SETTER |
1511 | 1511 |
1512 | 1512 |
1513 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetInitialize) { | 1513 RUNTIME_FUNCTION(Object*, Runtime_SetInitialize) { |
1514 HandleScope scope(isolate); | 1514 HandleScope scope(isolate); |
1515 ASSERT(args.length() == 1); | 1515 ASSERT(args.length() == 1); |
1516 CONVERT_ARG_HANDLE_CHECKED(JSSet, holder, 0); | 1516 CONVERT_ARG_HANDLE_CHECKED(JSSet, holder, 0); |
1517 Handle<OrderedHashSet> table = isolate->factory()->NewOrderedHashSet(); | 1517 Handle<OrderedHashSet> table = isolate->factory()->NewOrderedHashSet(); |
1518 holder->set_table(*table); | 1518 holder->set_table(*table); |
1519 return *holder; | 1519 return *holder; |
1520 } | 1520 } |
1521 | 1521 |
1522 | 1522 |
1523 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetAdd) { | 1523 RUNTIME_FUNCTION(Object*, Runtime_SetAdd) { |
1524 HandleScope scope(isolate); | 1524 HandleScope scope(isolate); |
1525 ASSERT(args.length() == 2); | 1525 ASSERT(args.length() == 2); |
1526 CONVERT_ARG_HANDLE_CHECKED(JSSet, holder, 0); | 1526 CONVERT_ARG_HANDLE_CHECKED(JSSet, holder, 0); |
1527 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); | 1527 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); |
1528 Handle<OrderedHashSet> table(OrderedHashSet::cast(holder->table())); | 1528 Handle<OrderedHashSet> table(OrderedHashSet::cast(holder->table())); |
1529 table = OrderedHashSet::Add(table, key); | 1529 table = OrderedHashSet::Add(table, key); |
1530 holder->set_table(*table); | 1530 holder->set_table(*table); |
1531 return isolate->heap()->undefined_value(); | 1531 return isolate->heap()->undefined_value(); |
1532 } | 1532 } |
1533 | 1533 |
1534 | 1534 |
1535 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetHas) { | 1535 RUNTIME_FUNCTION(Object*, Runtime_SetHas) { |
1536 HandleScope scope(isolate); | 1536 HandleScope scope(isolate); |
1537 ASSERT(args.length() == 2); | 1537 ASSERT(args.length() == 2); |
1538 CONVERT_ARG_HANDLE_CHECKED(JSSet, holder, 0); | 1538 CONVERT_ARG_HANDLE_CHECKED(JSSet, holder, 0); |
1539 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); | 1539 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); |
1540 Handle<OrderedHashSet> table(OrderedHashSet::cast(holder->table())); | 1540 Handle<OrderedHashSet> table(OrderedHashSet::cast(holder->table())); |
1541 return isolate->heap()->ToBoolean(table->Contains(*key)); | 1541 return isolate->heap()->ToBoolean(table->Contains(*key)); |
1542 } | 1542 } |
1543 | 1543 |
1544 | 1544 |
1545 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetDelete) { | 1545 RUNTIME_FUNCTION(Object*, Runtime_SetDelete) { |
1546 HandleScope scope(isolate); | 1546 HandleScope scope(isolate); |
1547 ASSERT(args.length() == 2); | 1547 ASSERT(args.length() == 2); |
1548 CONVERT_ARG_HANDLE_CHECKED(JSSet, holder, 0); | 1548 CONVERT_ARG_HANDLE_CHECKED(JSSet, holder, 0); |
1549 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); | 1549 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); |
1550 Handle<OrderedHashSet> table(OrderedHashSet::cast(holder->table())); | 1550 Handle<OrderedHashSet> table(OrderedHashSet::cast(holder->table())); |
1551 table = OrderedHashSet::Remove(table, key); | 1551 table = OrderedHashSet::Remove(table, key); |
1552 holder->set_table(*table); | 1552 holder->set_table(*table); |
1553 return isolate->heap()->undefined_value(); | 1553 return isolate->heap()->undefined_value(); |
1554 } | 1554 } |
1555 | 1555 |
1556 | 1556 |
1557 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetGetSize) { | 1557 RUNTIME_FUNCTION(Object*, Runtime_SetGetSize) { |
1558 HandleScope scope(isolate); | 1558 HandleScope scope(isolate); |
1559 ASSERT(args.length() == 1); | 1559 ASSERT(args.length() == 1); |
1560 CONVERT_ARG_HANDLE_CHECKED(JSSet, holder, 0); | 1560 CONVERT_ARG_HANDLE_CHECKED(JSSet, holder, 0); |
1561 Handle<OrderedHashSet> table(OrderedHashSet::cast(holder->table())); | 1561 Handle<OrderedHashSet> table(OrderedHashSet::cast(holder->table())); |
1562 return Smi::FromInt(table->NumberOfElements()); | 1562 return Smi::FromInt(table->NumberOfElements()); |
1563 } | 1563 } |
1564 | 1564 |
1565 | 1565 |
1566 RUNTIME_FUNCTION(MaybeObject*, Runtime_MapInitialize) { | 1566 RUNTIME_FUNCTION(Object*, Runtime_MapInitialize) { |
1567 HandleScope scope(isolate); | 1567 HandleScope scope(isolate); |
1568 ASSERT(args.length() == 1); | 1568 ASSERT(args.length() == 1); |
1569 CONVERT_ARG_HANDLE_CHECKED(JSMap, holder, 0); | 1569 CONVERT_ARG_HANDLE_CHECKED(JSMap, holder, 0); |
1570 Handle<OrderedHashMap> table = isolate->factory()->NewOrderedHashMap(); | 1570 Handle<OrderedHashMap> table = isolate->factory()->NewOrderedHashMap(); |
1571 holder->set_table(*table); | 1571 holder->set_table(*table); |
1572 return *holder; | 1572 return *holder; |
1573 } | 1573 } |
1574 | 1574 |
1575 | 1575 |
1576 RUNTIME_FUNCTION(MaybeObject*, Runtime_MapGet) { | 1576 RUNTIME_FUNCTION(Object*, Runtime_MapGet) { |
1577 HandleScope scope(isolate); | 1577 HandleScope scope(isolate); |
1578 ASSERT(args.length() == 2); | 1578 ASSERT(args.length() == 2); |
1579 CONVERT_ARG_HANDLE_CHECKED(JSMap, holder, 0); | 1579 CONVERT_ARG_HANDLE_CHECKED(JSMap, holder, 0); |
1580 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); | 1580 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); |
1581 Handle<OrderedHashMap> table(OrderedHashMap::cast(holder->table())); | 1581 Handle<OrderedHashMap> table(OrderedHashMap::cast(holder->table())); |
1582 Handle<Object> lookup(table->Lookup(*key), isolate); | 1582 Handle<Object> lookup(table->Lookup(*key), isolate); |
1583 return lookup->IsTheHole() ? isolate->heap()->undefined_value() : *lookup; | 1583 return lookup->IsTheHole() ? isolate->heap()->undefined_value() : *lookup; |
1584 } | 1584 } |
1585 | 1585 |
1586 | 1586 |
1587 RUNTIME_FUNCTION(MaybeObject*, Runtime_MapHas) { | 1587 RUNTIME_FUNCTION(Object*, Runtime_MapHas) { |
1588 HandleScope scope(isolate); | 1588 HandleScope scope(isolate); |
1589 ASSERT(args.length() == 2); | 1589 ASSERT(args.length() == 2); |
1590 CONVERT_ARG_HANDLE_CHECKED(JSMap, holder, 0); | 1590 CONVERT_ARG_HANDLE_CHECKED(JSMap, holder, 0); |
1591 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); | 1591 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); |
1592 Handle<OrderedHashMap> table(OrderedHashMap::cast(holder->table())); | 1592 Handle<OrderedHashMap> table(OrderedHashMap::cast(holder->table())); |
1593 Handle<Object> lookup(table->Lookup(*key), isolate); | 1593 Handle<Object> lookup(table->Lookup(*key), isolate); |
1594 return isolate->heap()->ToBoolean(!lookup->IsTheHole()); | 1594 return isolate->heap()->ToBoolean(!lookup->IsTheHole()); |
1595 } | 1595 } |
1596 | 1596 |
1597 | 1597 |
1598 RUNTIME_FUNCTION(MaybeObject*, Runtime_MapDelete) { | 1598 RUNTIME_FUNCTION(Object*, Runtime_MapDelete) { |
1599 HandleScope scope(isolate); | 1599 HandleScope scope(isolate); |
1600 ASSERT(args.length() == 2); | 1600 ASSERT(args.length() == 2); |
1601 CONVERT_ARG_HANDLE_CHECKED(JSMap, holder, 0); | 1601 CONVERT_ARG_HANDLE_CHECKED(JSMap, holder, 0); |
1602 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); | 1602 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); |
1603 Handle<OrderedHashMap> table(OrderedHashMap::cast(holder->table())); | 1603 Handle<OrderedHashMap> table(OrderedHashMap::cast(holder->table())); |
1604 Handle<Object> lookup(table->Lookup(*key), isolate); | 1604 Handle<Object> lookup(table->Lookup(*key), isolate); |
1605 Handle<OrderedHashMap> new_table = | 1605 Handle<OrderedHashMap> new_table = |
1606 OrderedHashMap::Put(table, key, isolate->factory()->the_hole_value()); | 1606 OrderedHashMap::Put(table, key, isolate->factory()->the_hole_value()); |
1607 holder->set_table(*new_table); | 1607 holder->set_table(*new_table); |
1608 return isolate->heap()->ToBoolean(!lookup->IsTheHole()); | 1608 return isolate->heap()->ToBoolean(!lookup->IsTheHole()); |
1609 } | 1609 } |
1610 | 1610 |
1611 | 1611 |
1612 RUNTIME_FUNCTION(MaybeObject*, Runtime_MapSet) { | 1612 RUNTIME_FUNCTION(Object*, Runtime_MapSet) { |
1613 HandleScope scope(isolate); | 1613 HandleScope scope(isolate); |
1614 ASSERT(args.length() == 3); | 1614 ASSERT(args.length() == 3); |
1615 CONVERT_ARG_HANDLE_CHECKED(JSMap, holder, 0); | 1615 CONVERT_ARG_HANDLE_CHECKED(JSMap, holder, 0); |
1616 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); | 1616 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); |
1617 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); | 1617 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); |
1618 Handle<OrderedHashMap> table(OrderedHashMap::cast(holder->table())); | 1618 Handle<OrderedHashMap> table(OrderedHashMap::cast(holder->table())); |
1619 Handle<OrderedHashMap> new_table = OrderedHashMap::Put(table, key, value); | 1619 Handle<OrderedHashMap> new_table = OrderedHashMap::Put(table, key, value); |
1620 holder->set_table(*new_table); | 1620 holder->set_table(*new_table); |
1621 return isolate->heap()->undefined_value(); | 1621 return isolate->heap()->undefined_value(); |
1622 } | 1622 } |
1623 | 1623 |
1624 | 1624 |
1625 RUNTIME_FUNCTION(MaybeObject*, Runtime_MapGetSize) { | 1625 RUNTIME_FUNCTION(Object*, Runtime_MapGetSize) { |
1626 HandleScope scope(isolate); | 1626 HandleScope scope(isolate); |
1627 ASSERT(args.length() == 1); | 1627 ASSERT(args.length() == 1); |
1628 CONVERT_ARG_HANDLE_CHECKED(JSMap, holder, 0); | 1628 CONVERT_ARG_HANDLE_CHECKED(JSMap, holder, 0); |
1629 Handle<OrderedHashMap> table(OrderedHashMap::cast(holder->table())); | 1629 Handle<OrderedHashMap> table(OrderedHashMap::cast(holder->table())); |
1630 return Smi::FromInt(table->NumberOfElements()); | 1630 return Smi::FromInt(table->NumberOfElements()); |
1631 } | 1631 } |
1632 | 1632 |
1633 | 1633 |
1634 static JSWeakCollection* WeakCollectionInitialize(Isolate* isolate, | 1634 static JSWeakCollection* WeakCollectionInitialize(Isolate* isolate, |
1635 Handle<JSWeakCollection> weak_collection) { | 1635 Handle<JSWeakCollection> weak_collection) { |
1636 ASSERT(weak_collection->map()->inobject_properties() == 0); | 1636 ASSERT(weak_collection->map()->inobject_properties() == 0); |
1637 Handle<ObjectHashTable> table = isolate->factory()->NewObjectHashTable(0); | 1637 Handle<ObjectHashTable> table = isolate->factory()->NewObjectHashTable(0); |
1638 weak_collection->set_table(*table); | 1638 weak_collection->set_table(*table); |
1639 weak_collection->set_next(Smi::FromInt(0)); | 1639 weak_collection->set_next(Smi::FromInt(0)); |
1640 return *weak_collection; | 1640 return *weak_collection; |
1641 } | 1641 } |
1642 | 1642 |
1643 | 1643 |
1644 RUNTIME_FUNCTION(MaybeObject*, Runtime_WeakCollectionInitialize) { | 1644 RUNTIME_FUNCTION(Object*, Runtime_WeakCollectionInitialize) { |
1645 HandleScope scope(isolate); | 1645 HandleScope scope(isolate); |
1646 ASSERT(args.length() == 1); | 1646 ASSERT(args.length() == 1); |
1647 CONVERT_ARG_HANDLE_CHECKED(JSWeakCollection, weak_collection, 0); | 1647 CONVERT_ARG_HANDLE_CHECKED(JSWeakCollection, weak_collection, 0); |
1648 return WeakCollectionInitialize(isolate, weak_collection); | 1648 return WeakCollectionInitialize(isolate, weak_collection); |
1649 } | 1649 } |
1650 | 1650 |
1651 | 1651 |
1652 RUNTIME_FUNCTION(MaybeObject*, Runtime_WeakCollectionGet) { | 1652 RUNTIME_FUNCTION(Object*, Runtime_WeakCollectionGet) { |
1653 HandleScope scope(isolate); | 1653 HandleScope scope(isolate); |
1654 ASSERT(args.length() == 2); | 1654 ASSERT(args.length() == 2); |
1655 CONVERT_ARG_HANDLE_CHECKED(JSWeakCollection, weak_collection, 0); | 1655 CONVERT_ARG_HANDLE_CHECKED(JSWeakCollection, weak_collection, 0); |
1656 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); | 1656 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); |
1657 Handle<ObjectHashTable> table( | 1657 Handle<ObjectHashTable> table( |
1658 ObjectHashTable::cast(weak_collection->table())); | 1658 ObjectHashTable::cast(weak_collection->table())); |
1659 Handle<Object> lookup(table->Lookup(*key), isolate); | 1659 Handle<Object> lookup(table->Lookup(*key), isolate); |
1660 return lookup->IsTheHole() ? isolate->heap()->undefined_value() : *lookup; | 1660 return lookup->IsTheHole() ? isolate->heap()->undefined_value() : *lookup; |
1661 } | 1661 } |
1662 | 1662 |
1663 | 1663 |
1664 RUNTIME_FUNCTION(MaybeObject*, Runtime_WeakCollectionHas) { | 1664 RUNTIME_FUNCTION(Object*, Runtime_WeakCollectionHas) { |
1665 HandleScope scope(isolate); | 1665 HandleScope scope(isolate); |
1666 ASSERT(args.length() == 2); | 1666 ASSERT(args.length() == 2); |
1667 CONVERT_ARG_HANDLE_CHECKED(JSWeakCollection, weak_collection, 0); | 1667 CONVERT_ARG_HANDLE_CHECKED(JSWeakCollection, weak_collection, 0); |
1668 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); | 1668 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); |
1669 Handle<ObjectHashTable> table( | 1669 Handle<ObjectHashTable> table( |
1670 ObjectHashTable::cast(weak_collection->table())); | 1670 ObjectHashTable::cast(weak_collection->table())); |
1671 Handle<Object> lookup(table->Lookup(*key), isolate); | 1671 Handle<Object> lookup(table->Lookup(*key), isolate); |
1672 return isolate->heap()->ToBoolean(!lookup->IsTheHole()); | 1672 return isolate->heap()->ToBoolean(!lookup->IsTheHole()); |
1673 } | 1673 } |
1674 | 1674 |
1675 | 1675 |
1676 RUNTIME_FUNCTION(MaybeObject*, Runtime_WeakCollectionDelete) { | 1676 RUNTIME_FUNCTION(Object*, Runtime_WeakCollectionDelete) { |
1677 HandleScope scope(isolate); | 1677 HandleScope scope(isolate); |
1678 ASSERT(args.length() == 2); | 1678 ASSERT(args.length() == 2); |
1679 CONVERT_ARG_HANDLE_CHECKED(JSWeakCollection, weak_collection, 0); | 1679 CONVERT_ARG_HANDLE_CHECKED(JSWeakCollection, weak_collection, 0); |
1680 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); | 1680 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); |
1681 Handle<ObjectHashTable> table(ObjectHashTable::cast( | 1681 Handle<ObjectHashTable> table(ObjectHashTable::cast( |
1682 weak_collection->table())); | 1682 weak_collection->table())); |
1683 Handle<Object> lookup(table->Lookup(*key), isolate); | 1683 Handle<Object> lookup(table->Lookup(*key), isolate); |
1684 Handle<ObjectHashTable> new_table = | 1684 Handle<ObjectHashTable> new_table = |
1685 ObjectHashTable::Put(table, key, isolate->factory()->the_hole_value()); | 1685 ObjectHashTable::Put(table, key, isolate->factory()->the_hole_value()); |
1686 weak_collection->set_table(*new_table); | 1686 weak_collection->set_table(*new_table); |
1687 return isolate->heap()->ToBoolean(!lookup->IsTheHole()); | 1687 return isolate->heap()->ToBoolean(!lookup->IsTheHole()); |
1688 } | 1688 } |
1689 | 1689 |
1690 | 1690 |
1691 RUNTIME_FUNCTION(MaybeObject*, Runtime_WeakCollectionSet) { | 1691 RUNTIME_FUNCTION(Object*, Runtime_WeakCollectionSet) { |
1692 HandleScope scope(isolate); | 1692 HandleScope scope(isolate); |
1693 ASSERT(args.length() == 3); | 1693 ASSERT(args.length() == 3); |
1694 CONVERT_ARG_HANDLE_CHECKED(JSWeakCollection, weak_collection, 0); | 1694 CONVERT_ARG_HANDLE_CHECKED(JSWeakCollection, weak_collection, 0); |
1695 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); | 1695 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); |
1696 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); | 1696 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); |
1697 Handle<ObjectHashTable> table( | 1697 Handle<ObjectHashTable> table( |
1698 ObjectHashTable::cast(weak_collection->table())); | 1698 ObjectHashTable::cast(weak_collection->table())); |
1699 Handle<ObjectHashTable> new_table = ObjectHashTable::Put(table, key, value); | 1699 Handle<ObjectHashTable> new_table = ObjectHashTable::Put(table, key, value); |
1700 weak_collection->set_table(*new_table); | 1700 weak_collection->set_table(*new_table); |
1701 return isolate->heap()->undefined_value(); | 1701 return isolate->heap()->undefined_value(); |
1702 } | 1702 } |
1703 | 1703 |
1704 | 1704 |
1705 RUNTIME_FUNCTION(MaybeObject*, Runtime_ClassOf) { | 1705 RUNTIME_FUNCTION(Object*, Runtime_ClassOf) { |
1706 SealHandleScope shs(isolate); | 1706 SealHandleScope shs(isolate); |
1707 ASSERT(args.length() == 1); | 1707 ASSERT(args.length() == 1); |
1708 CONVERT_ARG_CHECKED(Object, obj, 0); | 1708 CONVERT_ARG_CHECKED(Object, obj, 0); |
1709 if (!obj->IsJSObject()) return isolate->heap()->null_value(); | 1709 if (!obj->IsJSObject()) return isolate->heap()->null_value(); |
1710 return JSObject::cast(obj)->class_name(); | 1710 return JSObject::cast(obj)->class_name(); |
1711 } | 1711 } |
1712 | 1712 |
1713 | 1713 |
1714 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetPrototype) { | 1714 RUNTIME_FUNCTION(Object*, Runtime_GetPrototype) { |
1715 HandleScope scope(isolate); | 1715 HandleScope scope(isolate); |
1716 ASSERT(args.length() == 1); | 1716 ASSERT(args.length() == 1); |
1717 CONVERT_ARG_HANDLE_CHECKED(Object, obj, 0); | 1717 CONVERT_ARG_HANDLE_CHECKED(Object, obj, 0); |
1718 // We don't expect access checks to be needed on JSProxy objects. | 1718 // We don't expect access checks to be needed on JSProxy objects. |
1719 ASSERT(!obj->IsAccessCheckNeeded() || obj->IsJSObject()); | 1719 ASSERT(!obj->IsAccessCheckNeeded() || obj->IsJSObject()); |
1720 do { | 1720 do { |
1721 if (obj->IsAccessCheckNeeded() && | 1721 if (obj->IsAccessCheckNeeded() && |
1722 !isolate->MayNamedAccess(Handle<JSObject>::cast(obj), | 1722 !isolate->MayNamedAccess(Handle<JSObject>::cast(obj), |
1723 isolate->factory()->proto_string(), | 1723 isolate->factory()->proto_string(), |
1724 v8::ACCESS_GET)) { | 1724 v8::ACCESS_GET)) { |
(...skipping 13 matching lines...) Expand all Loading... | |
1738 Isolate* isolate, Handle<Object> receiver) { | 1738 Isolate* isolate, Handle<Object> receiver) { |
1739 Handle<Object> current = Object::GetPrototype(isolate, receiver); | 1739 Handle<Object> current = Object::GetPrototype(isolate, receiver); |
1740 while (current->IsJSObject() && | 1740 while (current->IsJSObject() && |
1741 JSObject::cast(*current)->map()->is_hidden_prototype()) { | 1741 JSObject::cast(*current)->map()->is_hidden_prototype()) { |
1742 current = Object::GetPrototype(isolate, current); | 1742 current = Object::GetPrototype(isolate, current); |
1743 } | 1743 } |
1744 return current; | 1744 return current; |
1745 } | 1745 } |
1746 | 1746 |
1747 | 1747 |
1748 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetPrototype) { | 1748 RUNTIME_FUNCTION(Object*, Runtime_SetPrototype) { |
1749 HandleScope scope(isolate); | 1749 HandleScope scope(isolate); |
1750 ASSERT(args.length() == 2); | 1750 ASSERT(args.length() == 2); |
1751 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); | 1751 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); |
1752 CONVERT_ARG_HANDLE_CHECKED(Object, prototype, 1); | 1752 CONVERT_ARG_HANDLE_CHECKED(Object, prototype, 1); |
1753 if (obj->IsAccessCheckNeeded() && | 1753 if (obj->IsAccessCheckNeeded() && |
1754 !isolate->MayNamedAccess( | 1754 !isolate->MayNamedAccess( |
1755 obj, isolate->factory()->proto_string(), v8::ACCESS_SET)) { | 1755 obj, isolate->factory()->proto_string(), v8::ACCESS_SET)) { |
1756 isolate->ReportFailedAccessCheck(obj, v8::ACCESS_SET); | 1756 isolate->ReportFailedAccessCheck(obj, v8::ACCESS_SET); |
1757 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); | 1757 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); |
1758 return isolate->heap()->undefined_value(); | 1758 return isolate->heap()->undefined_value(); |
(...skipping 11 matching lines...) Expand all Loading... | |
1770 old_value); | 1770 old_value); |
1771 } | 1771 } |
1772 return *result; | 1772 return *result; |
1773 } | 1773 } |
1774 Handle<Object> result = JSObject::SetPrototype(obj, prototype, true); | 1774 Handle<Object> result = JSObject::SetPrototype(obj, prototype, true); |
1775 RETURN_IF_EMPTY_HANDLE(isolate, result); | 1775 RETURN_IF_EMPTY_HANDLE(isolate, result); |
1776 return *result; | 1776 return *result; |
1777 } | 1777 } |
1778 | 1778 |
1779 | 1779 |
1780 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsInPrototypeChain) { | 1780 RUNTIME_FUNCTION(Object*, Runtime_IsInPrototypeChain) { |
1781 HandleScope shs(isolate); | 1781 HandleScope shs(isolate); |
1782 ASSERT(args.length() == 2); | 1782 ASSERT(args.length() == 2); |
1783 // See ECMA-262, section 15.3.5.3, page 88 (steps 5 - 8). | 1783 // See ECMA-262, section 15.3.5.3, page 88 (steps 5 - 8). |
1784 CONVERT_ARG_HANDLE_CHECKED(Object, O, 0); | 1784 CONVERT_ARG_HANDLE_CHECKED(Object, O, 0); |
1785 CONVERT_ARG_HANDLE_CHECKED(Object, V, 1); | 1785 CONVERT_ARG_HANDLE_CHECKED(Object, V, 1); |
1786 while (true) { | 1786 while (true) { |
1787 Handle<Object> prototype = Object::GetPrototype(isolate, V); | 1787 Handle<Object> prototype = Object::GetPrototype(isolate, V); |
1788 if (prototype->IsNull()) return isolate->heap()->false_value(); | 1788 if (prototype->IsNull()) return isolate->heap()->false_value(); |
1789 if (*O == *prototype) return isolate->heap()->true_value(); | 1789 if (*O == *prototype) return isolate->heap()->true_value(); |
1790 V = prototype; | 1790 V = prototype; |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1974 } | 1974 } |
1975 | 1975 |
1976 | 1976 |
1977 // Returns an array with the property description: | 1977 // Returns an array with the property description: |
1978 // if args[1] is not a property on args[0] | 1978 // if args[1] is not a property on args[0] |
1979 // returns undefined | 1979 // returns undefined |
1980 // if args[1] is a data property on args[0] | 1980 // if args[1] is a data property on args[0] |
1981 // [false, value, Writeable, Enumerable, Configurable] | 1981 // [false, value, Writeable, Enumerable, Configurable] |
1982 // if args[1] is an accessor on args[0] | 1982 // if args[1] is an accessor on args[0] |
1983 // [true, GetFunction, SetFunction, Enumerable, Configurable] | 1983 // [true, GetFunction, SetFunction, Enumerable, Configurable] |
1984 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetOwnProperty) { | 1984 RUNTIME_FUNCTION(Object*, Runtime_GetOwnProperty) { |
1985 HandleScope scope(isolate); | 1985 HandleScope scope(isolate); |
1986 ASSERT(args.length() == 2); | 1986 ASSERT(args.length() == 2); |
1987 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); | 1987 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); |
1988 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); | 1988 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); |
1989 Handle<Object> result; | 1989 Handle<Object> result; |
1990 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 1990 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
1991 isolate, result, GetOwnProperty(isolate, obj, name)); | 1991 isolate, result, GetOwnProperty(isolate, obj, name)); |
1992 return *result; | 1992 return *result; |
1993 } | 1993 } |
1994 | 1994 |
1995 | 1995 |
1996 RUNTIME_FUNCTION(MaybeObject*, Runtime_PreventExtensions) { | 1996 RUNTIME_FUNCTION(Object*, Runtime_PreventExtensions) { |
1997 HandleScope scope(isolate); | 1997 HandleScope scope(isolate); |
1998 ASSERT(args.length() == 1); | 1998 ASSERT(args.length() == 1); |
1999 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); | 1999 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); |
2000 Handle<Object> result; | 2000 Handle<Object> result; |
2001 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 2001 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
2002 isolate, result, JSObject::PreventExtensions(obj)); | 2002 isolate, result, JSObject::PreventExtensions(obj)); |
2003 return *result; | 2003 return *result; |
2004 } | 2004 } |
2005 | 2005 |
2006 | 2006 |
2007 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsExtensible) { | 2007 RUNTIME_FUNCTION(Object*, Runtime_IsExtensible) { |
2008 SealHandleScope shs(isolate); | 2008 SealHandleScope shs(isolate); |
2009 ASSERT(args.length() == 1); | 2009 ASSERT(args.length() == 1); |
2010 CONVERT_ARG_CHECKED(JSObject, obj, 0); | 2010 CONVERT_ARG_CHECKED(JSObject, obj, 0); |
2011 if (obj->IsJSGlobalProxy()) { | 2011 if (obj->IsJSGlobalProxy()) { |
2012 Object* proto = obj->GetPrototype(); | 2012 Object* proto = obj->GetPrototype(); |
2013 if (proto->IsNull()) return isolate->heap()->false_value(); | 2013 if (proto->IsNull()) return isolate->heap()->false_value(); |
2014 ASSERT(proto->IsJSGlobalObject()); | 2014 ASSERT(proto->IsJSGlobalObject()); |
2015 obj = JSObject::cast(proto); | 2015 obj = JSObject::cast(proto); |
2016 } | 2016 } |
2017 return isolate->heap()->ToBoolean(obj->map()->is_extensible()); | 2017 return isolate->heap()->ToBoolean(obj->map()->is_extensible()); |
2018 } | 2018 } |
2019 | 2019 |
2020 | 2020 |
2021 RUNTIME_FUNCTION(MaybeObject*, Runtime_RegExpCompile) { | 2021 RUNTIME_FUNCTION(Object*, Runtime_RegExpCompile) { |
2022 HandleScope scope(isolate); | 2022 HandleScope scope(isolate); |
2023 ASSERT(args.length() == 3); | 2023 ASSERT(args.length() == 3); |
2024 CONVERT_ARG_HANDLE_CHECKED(JSRegExp, re, 0); | 2024 CONVERT_ARG_HANDLE_CHECKED(JSRegExp, re, 0); |
2025 CONVERT_ARG_HANDLE_CHECKED(String, pattern, 1); | 2025 CONVERT_ARG_HANDLE_CHECKED(String, pattern, 1); |
2026 CONVERT_ARG_HANDLE_CHECKED(String, flags, 2); | 2026 CONVERT_ARG_HANDLE_CHECKED(String, flags, 2); |
2027 Handle<Object> result; | 2027 Handle<Object> result; |
2028 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 2028 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
2029 isolate, result, RegExpImpl::Compile(re, pattern, flags)); | 2029 isolate, result, RegExpImpl::Compile(re, pattern, flags)); |
2030 return *result; | 2030 return *result; |
2031 } | 2031 } |
2032 | 2032 |
2033 | 2033 |
2034 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateApiFunction) { | 2034 RUNTIME_FUNCTION(Object*, Runtime_CreateApiFunction) { |
2035 HandleScope scope(isolate); | 2035 HandleScope scope(isolate); |
2036 ASSERT(args.length() == 1); | 2036 ASSERT(args.length() == 1); |
2037 CONVERT_ARG_HANDLE_CHECKED(FunctionTemplateInfo, data, 0); | 2037 CONVERT_ARG_HANDLE_CHECKED(FunctionTemplateInfo, data, 0); |
2038 return *isolate->factory()->CreateApiFunction(data); | 2038 return *isolate->factory()->CreateApiFunction(data); |
2039 } | 2039 } |
2040 | 2040 |
2041 | 2041 |
2042 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsTemplate) { | 2042 RUNTIME_FUNCTION(Object*, Runtime_IsTemplate) { |
2043 SealHandleScope shs(isolate); | 2043 SealHandleScope shs(isolate); |
2044 ASSERT(args.length() == 1); | 2044 ASSERT(args.length() == 1); |
2045 CONVERT_ARG_HANDLE_CHECKED(Object, arg, 0); | 2045 CONVERT_ARG_HANDLE_CHECKED(Object, arg, 0); |
2046 bool result = arg->IsObjectTemplateInfo() || arg->IsFunctionTemplateInfo(); | 2046 bool result = arg->IsObjectTemplateInfo() || arg->IsFunctionTemplateInfo(); |
2047 return isolate->heap()->ToBoolean(result); | 2047 return isolate->heap()->ToBoolean(result); |
2048 } | 2048 } |
2049 | 2049 |
2050 | 2050 |
2051 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetTemplateField) { | 2051 RUNTIME_FUNCTION(Object*, Runtime_GetTemplateField) { |
2052 SealHandleScope shs(isolate); | 2052 SealHandleScope shs(isolate); |
2053 ASSERT(args.length() == 2); | 2053 ASSERT(args.length() == 2); |
2054 CONVERT_ARG_CHECKED(HeapObject, templ, 0); | 2054 CONVERT_ARG_CHECKED(HeapObject, templ, 0); |
2055 CONVERT_SMI_ARG_CHECKED(index, 1); | 2055 CONVERT_SMI_ARG_CHECKED(index, 1); |
2056 int offset = index * kPointerSize + HeapObject::kHeaderSize; | 2056 int offset = index * kPointerSize + HeapObject::kHeaderSize; |
2057 InstanceType type = templ->map()->instance_type(); | 2057 InstanceType type = templ->map()->instance_type(); |
2058 RUNTIME_ASSERT(type == FUNCTION_TEMPLATE_INFO_TYPE || | 2058 RUNTIME_ASSERT(type == FUNCTION_TEMPLATE_INFO_TYPE || |
2059 type == OBJECT_TEMPLATE_INFO_TYPE); | 2059 type == OBJECT_TEMPLATE_INFO_TYPE); |
2060 RUNTIME_ASSERT(offset > 0); | 2060 RUNTIME_ASSERT(offset > 0); |
2061 if (type == FUNCTION_TEMPLATE_INFO_TYPE) { | 2061 if (type == FUNCTION_TEMPLATE_INFO_TYPE) { |
2062 RUNTIME_ASSERT(offset < FunctionTemplateInfo::kSize); | 2062 RUNTIME_ASSERT(offset < FunctionTemplateInfo::kSize); |
2063 } else { | 2063 } else { |
2064 RUNTIME_ASSERT(offset < ObjectTemplateInfo::kSize); | 2064 RUNTIME_ASSERT(offset < ObjectTemplateInfo::kSize); |
2065 } | 2065 } |
2066 return *HeapObject::RawField(templ, offset); | 2066 return *HeapObject::RawField(templ, offset); |
2067 } | 2067 } |
2068 | 2068 |
2069 | 2069 |
2070 RUNTIME_FUNCTION(MaybeObject*, Runtime_DisableAccessChecks) { | 2070 RUNTIME_FUNCTION(Object*, Runtime_DisableAccessChecks) { |
2071 HandleScope scope(isolate); | 2071 HandleScope scope(isolate); |
2072 ASSERT(args.length() == 1); | 2072 ASSERT(args.length() == 1); |
2073 CONVERT_ARG_HANDLE_CHECKED(HeapObject, object, 0); | 2073 CONVERT_ARG_HANDLE_CHECKED(HeapObject, object, 0); |
2074 Handle<Map> old_map(object->map()); | 2074 Handle<Map> old_map(object->map()); |
2075 bool needs_access_checks = old_map->is_access_check_needed(); | 2075 bool needs_access_checks = old_map->is_access_check_needed(); |
2076 if (needs_access_checks) { | 2076 if (needs_access_checks) { |
2077 // Copy map so it won't interfere constructor's initial map. | 2077 // Copy map so it won't interfere constructor's initial map. |
2078 Handle<Map> new_map = Map::Copy(old_map); | 2078 Handle<Map> new_map = Map::Copy(old_map); |
2079 new_map->set_is_access_check_needed(false); | 2079 new_map->set_is_access_check_needed(false); |
2080 if (object->IsJSObject()) { | 2080 if (object->IsJSObject()) { |
2081 JSObject::MigrateToMap(Handle<JSObject>::cast(object), new_map); | 2081 JSObject::MigrateToMap(Handle<JSObject>::cast(object), new_map); |
2082 } else { | 2082 } else { |
2083 object->set_map(*new_map); | 2083 object->set_map(*new_map); |
2084 } | 2084 } |
2085 } | 2085 } |
2086 return isolate->heap()->ToBoolean(needs_access_checks); | 2086 return isolate->heap()->ToBoolean(needs_access_checks); |
2087 } | 2087 } |
2088 | 2088 |
2089 | 2089 |
2090 RUNTIME_FUNCTION(MaybeObject*, Runtime_EnableAccessChecks) { | 2090 RUNTIME_FUNCTION(Object*, Runtime_EnableAccessChecks) { |
2091 HandleScope scope(isolate); | 2091 HandleScope scope(isolate); |
2092 ASSERT(args.length() == 1); | 2092 ASSERT(args.length() == 1); |
2093 CONVERT_ARG_HANDLE_CHECKED(HeapObject, object, 0); | 2093 CONVERT_ARG_HANDLE_CHECKED(HeapObject, object, 0); |
2094 Handle<Map> old_map(object->map()); | 2094 Handle<Map> old_map(object->map()); |
2095 if (!old_map->is_access_check_needed()) { | 2095 if (!old_map->is_access_check_needed()) { |
2096 // Copy map so it won't interfere constructor's initial map. | 2096 // Copy map so it won't interfere constructor's initial map. |
2097 Handle<Map> new_map = Map::Copy(old_map); | 2097 Handle<Map> new_map = Map::Copy(old_map); |
2098 new_map->set_is_access_check_needed(true); | 2098 new_map->set_is_access_check_needed(true); |
2099 if (object->IsJSObject()) { | 2099 if (object->IsJSObject()) { |
2100 JSObject::MigrateToMap(Handle<JSObject>::cast(object), new_map); | 2100 JSObject::MigrateToMap(Handle<JSObject>::cast(object), new_map); |
2101 } else { | 2101 } else { |
2102 object->set_map(*new_map); | 2102 object->set_map(*new_map); |
2103 } | 2103 } |
2104 } | 2104 } |
2105 return isolate->heap()->undefined_value(); | 2105 return isolate->heap()->undefined_value(); |
2106 } | 2106 } |
2107 | 2107 |
2108 | 2108 |
2109 // Transform getter or setter into something DefineAccessor can handle. | 2109 // Transform getter or setter into something DefineAccessor can handle. |
2110 static Handle<Object> InstantiateAccessorComponent(Isolate* isolate, | 2110 static Handle<Object> InstantiateAccessorComponent(Isolate* isolate, |
2111 Handle<Object> component) { | 2111 Handle<Object> component) { |
2112 if (component->IsUndefined()) return isolate->factory()->null_value(); | 2112 if (component->IsUndefined()) return isolate->factory()->null_value(); |
2113 Handle<FunctionTemplateInfo> info = | 2113 Handle<FunctionTemplateInfo> info = |
2114 Handle<FunctionTemplateInfo>::cast(component); | 2114 Handle<FunctionTemplateInfo>::cast(component); |
2115 return Utils::OpenHandle(*Utils::ToLocal(info)->GetFunction()); | 2115 return Utils::OpenHandle(*Utils::ToLocal(info)->GetFunction()); |
2116 } | 2116 } |
2117 | 2117 |
2118 | 2118 |
2119 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetAccessorProperty) { | 2119 RUNTIME_FUNCTION(Object*, Runtime_SetAccessorProperty) { |
2120 HandleScope scope(isolate); | 2120 HandleScope scope(isolate); |
2121 ASSERT(args.length() == 6); | 2121 ASSERT(args.length() == 6); |
2122 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); | 2122 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); |
2123 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); | 2123 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); |
2124 CONVERT_ARG_HANDLE_CHECKED(Object, getter, 2); | 2124 CONVERT_ARG_HANDLE_CHECKED(Object, getter, 2); |
2125 CONVERT_ARG_HANDLE_CHECKED(Object, setter, 3); | 2125 CONVERT_ARG_HANDLE_CHECKED(Object, setter, 3); |
2126 CONVERT_SMI_ARG_CHECKED(attribute, 4); | 2126 CONVERT_SMI_ARG_CHECKED(attribute, 4); |
2127 CONVERT_SMI_ARG_CHECKED(access_control, 5); | 2127 CONVERT_SMI_ARG_CHECKED(access_control, 5); |
2128 RUNTIME_ASSERT(getter->IsUndefined() || getter->IsFunctionTemplateInfo()); | 2128 RUNTIME_ASSERT(getter->IsUndefined() || getter->IsFunctionTemplateInfo()); |
2129 RUNTIME_ASSERT(setter->IsUndefined() || setter->IsFunctionTemplateInfo()); | 2129 RUNTIME_ASSERT(setter->IsUndefined() || setter->IsFunctionTemplateInfo()); |
2130 JSObject::DefineAccessor(object, | 2130 JSObject::DefineAccessor(object, |
2131 name, | 2131 name, |
2132 InstantiateAccessorComponent(isolate, getter), | 2132 InstantiateAccessorComponent(isolate, getter), |
2133 InstantiateAccessorComponent(isolate, setter), | 2133 InstantiateAccessorComponent(isolate, setter), |
2134 static_cast<PropertyAttributes>(attribute), | 2134 static_cast<PropertyAttributes>(attribute), |
2135 static_cast<v8::AccessControl>(access_control)); | 2135 static_cast<v8::AccessControl>(access_control)); |
2136 return isolate->heap()->undefined_value(); | 2136 return isolate->heap()->undefined_value(); |
2137 } | 2137 } |
2138 | 2138 |
2139 | 2139 |
2140 static Failure* ThrowRedeclarationError(Isolate* isolate, Handle<String> name) { | 2140 static Object* ThrowRedeclarationError(Isolate* isolate, Handle<String> name) { |
2141 HandleScope scope(isolate); | 2141 HandleScope scope(isolate); |
2142 Handle<Object> args[1] = { name }; | 2142 Handle<Object> args[1] = { name }; |
2143 Handle<Object> error = isolate->factory()->NewTypeError( | 2143 Handle<Object> error = isolate->factory()->NewTypeError( |
2144 "var_redeclaration", HandleVector(args, 1)); | 2144 "var_redeclaration", HandleVector(args, 1)); |
2145 return isolate->Throw(*error); | 2145 return isolate->Throw(*error); |
2146 } | 2146 } |
2147 | 2147 |
2148 | 2148 |
2149 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_DeclareGlobals) { | 2149 RUNTIME_FUNCTION(Object*, RuntimeHidden_DeclareGlobals) { |
2150 HandleScope scope(isolate); | 2150 HandleScope scope(isolate); |
2151 ASSERT(args.length() == 3); | 2151 ASSERT(args.length() == 3); |
2152 Handle<GlobalObject> global = Handle<GlobalObject>( | 2152 Handle<GlobalObject> global = Handle<GlobalObject>( |
2153 isolate->context()->global_object()); | 2153 isolate->context()->global_object()); |
2154 | 2154 |
2155 CONVERT_ARG_HANDLE_CHECKED(Context, context, 0); | 2155 CONVERT_ARG_HANDLE_CHECKED(Context, context, 0); |
2156 CONVERT_ARG_HANDLE_CHECKED(FixedArray, pairs, 1); | 2156 CONVERT_ARG_HANDLE_CHECKED(FixedArray, pairs, 1); |
2157 CONVERT_SMI_ARG_CHECKED(flags, 2); | 2157 CONVERT_SMI_ARG_CHECKED(flags, 2); |
2158 | 2158 |
2159 // Traverse the name/value pairs and set the properties. | 2159 // Traverse the name/value pairs and set the properties. |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2235 global, name, value, static_cast<PropertyAttributes>(attr), | 2235 global, name, value, static_cast<PropertyAttributes>(attr), |
2236 strict_mode)); | 2236 strict_mode)); |
2237 } | 2237 } |
2238 } | 2238 } |
2239 | 2239 |
2240 ASSERT(!isolate->has_pending_exception()); | 2240 ASSERT(!isolate->has_pending_exception()); |
2241 return isolate->heap()->undefined_value(); | 2241 return isolate->heap()->undefined_value(); |
2242 } | 2242 } |
2243 | 2243 |
2244 | 2244 |
2245 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_DeclareContextSlot) { | 2245 RUNTIME_FUNCTION(Object*, RuntimeHidden_DeclareContextSlot) { |
2246 HandleScope scope(isolate); | 2246 HandleScope scope(isolate); |
2247 ASSERT(args.length() == 4); | 2247 ASSERT(args.length() == 4); |
2248 | 2248 |
2249 // Declarations are always made in a function or native context. In the | 2249 // Declarations are always made in a function or native context. In the |
2250 // case of eval code, the context passed is the context of the caller, | 2250 // case of eval code, the context passed is the context of the caller, |
2251 // which may be some nested context and not the declaration context. | 2251 // which may be some nested context and not the declaration context. |
2252 CONVERT_ARG_HANDLE_CHECKED(Context, context_arg, 0); | 2252 CONVERT_ARG_HANDLE_CHECKED(Context, context_arg, 0); |
2253 Handle<Context> context(context_arg->declaration_context()); | 2253 Handle<Context> context(context_arg->declaration_context()); |
2254 CONVERT_ARG_HANDLE_CHECKED(String, name, 1); | 2254 CONVERT_ARG_HANDLE_CHECKED(String, name, 1); |
2255 CONVERT_SMI_ARG_CHECKED(mode_arg, 2); | 2255 CONVERT_SMI_ARG_CHECKED(mode_arg, 2); |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2335 } else { | 2335 } else { |
2336 RETURN_FAILURE_ON_EXCEPTION(isolate, | 2336 RETURN_FAILURE_ON_EXCEPTION(isolate, |
2337 JSReceiver::SetProperty(object, name, value, mode, SLOPPY)); | 2337 JSReceiver::SetProperty(object, name, value, mode, SLOPPY)); |
2338 } | 2338 } |
2339 } | 2339 } |
2340 | 2340 |
2341 return isolate->heap()->undefined_value(); | 2341 return isolate->heap()->undefined_value(); |
2342 } | 2342 } |
2343 | 2343 |
2344 | 2344 |
2345 RUNTIME_FUNCTION(MaybeObject*, Runtime_InitializeVarGlobal) { | 2345 RUNTIME_FUNCTION(Object*, Runtime_InitializeVarGlobal) { |
2346 HandleScope scope(isolate); | 2346 HandleScope scope(isolate); |
2347 // args[0] == name | 2347 // args[0] == name |
2348 // args[1] == language_mode | 2348 // args[1] == language_mode |
2349 // args[2] == value (optional) | 2349 // args[2] == value (optional) |
2350 | 2350 |
2351 // Determine if we need to assign to the variable if it already | 2351 // Determine if we need to assign to the variable if it already |
2352 // exists (based on the number of arguments). | 2352 // exists (based on the number of arguments). |
2353 RUNTIME_ASSERT(args.length() == 2 || args.length() == 3); | 2353 RUNTIME_ASSERT(args.length() == 2 || args.length() == 3); |
2354 bool assign = args.length() == 3; | 2354 bool assign = args.length() == 3; |
2355 | 2355 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2395 Handle<Object> result; | 2395 Handle<Object> result; |
2396 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 2396 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
2397 isolate, result, | 2397 isolate, result, |
2398 JSReceiver::SetProperty(global, name, value, attributes, strict_mode)); | 2398 JSReceiver::SetProperty(global, name, value, attributes, strict_mode)); |
2399 return *result; | 2399 return *result; |
2400 } | 2400 } |
2401 return isolate->heap()->undefined_value(); | 2401 return isolate->heap()->undefined_value(); |
2402 } | 2402 } |
2403 | 2403 |
2404 | 2404 |
2405 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_InitializeConstGlobal) { | 2405 RUNTIME_FUNCTION(Object*, RuntimeHidden_InitializeConstGlobal) { |
2406 SealHandleScope shs(isolate); | 2406 SealHandleScope shs(isolate); |
2407 // All constants are declared with an initial value. The name | 2407 // All constants are declared with an initial value. The name |
2408 // of the constant is the first argument and the initial value | 2408 // of the constant is the first argument and the initial value |
2409 // is the second. | 2409 // is the second. |
2410 RUNTIME_ASSERT(args.length() == 2); | 2410 RUNTIME_ASSERT(args.length() == 2); |
2411 CONVERT_ARG_HANDLE_CHECKED(String, name, 0); | 2411 CONVERT_ARG_HANDLE_CHECKED(String, name, 0); |
2412 CONVERT_ARG_HANDLE_CHECKED(Object, value, 1); | 2412 CONVERT_ARG_HANDLE_CHECKED(Object, value, 1); |
2413 | 2413 |
2414 // Get the current global object from top. | 2414 // Get the current global object from top. |
2415 GlobalObject* global = isolate->context()->global_object(); | 2415 GlobalObject* global = isolate->context()->global_object(); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2472 // Ignore re-initialization of constants that have already been | 2472 // Ignore re-initialization of constants that have already been |
2473 // assigned a constant value. | 2473 // assigned a constant value. |
2474 ASSERT(lookup.IsReadOnly() && lookup.IsConstant()); | 2474 ASSERT(lookup.IsReadOnly() && lookup.IsConstant()); |
2475 } | 2475 } |
2476 | 2476 |
2477 // Use the set value as the result of the operation. | 2477 // Use the set value as the result of the operation. |
2478 return *value; | 2478 return *value; |
2479 } | 2479 } |
2480 | 2480 |
2481 | 2481 |
2482 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_InitializeConstContextSlot) { | 2482 RUNTIME_FUNCTION(Object*, RuntimeHidden_InitializeConstContextSlot) { |
2483 HandleScope scope(isolate); | 2483 HandleScope scope(isolate); |
2484 ASSERT(args.length() == 3); | 2484 ASSERT(args.length() == 3); |
2485 | 2485 |
2486 CONVERT_ARG_HANDLE_CHECKED(Object, value, 0); | 2486 CONVERT_ARG_HANDLE_CHECKED(Object, value, 0); |
2487 ASSERT(!value->IsTheHole()); | 2487 ASSERT(!value->IsTheHole()); |
2488 // Initializations are always done in a function or native context. | 2488 // Initializations are always done in a function or native context. |
2489 CONVERT_ARG_HANDLE_CHECKED(Context, context_arg, 1); | 2489 CONVERT_ARG_HANDLE_CHECKED(Context, context_arg, 1); |
2490 Handle<Context> context(context_arg->declaration_context()); | 2490 Handle<Context> context(context_arg->declaration_context()); |
2491 CONVERT_ARG_HANDLE_CHECKED(String, name, 2); | 2491 CONVERT_ARG_HANDLE_CHECKED(String, name, 2); |
2492 | 2492 |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2568 RETURN_FAILURE_ON_EXCEPTION( | 2568 RETURN_FAILURE_ON_EXCEPTION( |
2569 isolate, | 2569 isolate, |
2570 JSReceiver::SetProperty(object, name, value, attributes, SLOPPY)); | 2570 JSReceiver::SetProperty(object, name, value, attributes, SLOPPY)); |
2571 } | 2571 } |
2572 } | 2572 } |
2573 | 2573 |
2574 return *value; | 2574 return *value; |
2575 } | 2575 } |
2576 | 2576 |
2577 | 2577 |
2578 RUNTIME_FUNCTION(MaybeObject*, | 2578 RUNTIME_FUNCTION(Object*, |
2579 Runtime_OptimizeObjectForAddingMultipleProperties) { | 2579 Runtime_OptimizeObjectForAddingMultipleProperties) { |
Jakob Kummerow
2014/04/17 14:20:12
nit: fits on one line now
| |
2580 HandleScope scope(isolate); | 2580 HandleScope scope(isolate); |
2581 ASSERT(args.length() == 2); | 2581 ASSERT(args.length() == 2); |
2582 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); | 2582 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); |
2583 CONVERT_SMI_ARG_CHECKED(properties, 1); | 2583 CONVERT_SMI_ARG_CHECKED(properties, 1); |
2584 if (object->HasFastProperties() && !object->IsJSGlobalProxy()) { | 2584 if (object->HasFastProperties() && !object->IsJSGlobalProxy()) { |
2585 JSObject::NormalizeProperties(object, KEEP_INOBJECT_PROPERTIES, properties); | 2585 JSObject::NormalizeProperties(object, KEEP_INOBJECT_PROPERTIES, properties); |
2586 } | 2586 } |
2587 return *object; | 2587 return *object; |
2588 } | 2588 } |
2589 | 2589 |
2590 | 2590 |
2591 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_RegExpExec) { | 2591 RUNTIME_FUNCTION(Object*, RuntimeHidden_RegExpExec) { |
2592 HandleScope scope(isolate); | 2592 HandleScope scope(isolate); |
2593 ASSERT(args.length() == 4); | 2593 ASSERT(args.length() == 4); |
2594 CONVERT_ARG_HANDLE_CHECKED(JSRegExp, regexp, 0); | 2594 CONVERT_ARG_HANDLE_CHECKED(JSRegExp, regexp, 0); |
2595 CONVERT_ARG_HANDLE_CHECKED(String, subject, 1); | 2595 CONVERT_ARG_HANDLE_CHECKED(String, subject, 1); |
2596 // Due to the way the JS calls are constructed this must be less than the | 2596 // Due to the way the JS calls are constructed this must be less than the |
2597 // length of a string, i.e. it is always a Smi. We check anyway for security. | 2597 // length of a string, i.e. it is always a Smi. We check anyway for security. |
2598 CONVERT_SMI_ARG_CHECKED(index, 2); | 2598 CONVERT_SMI_ARG_CHECKED(index, 2); |
2599 CONVERT_ARG_HANDLE_CHECKED(JSArray, last_match_info, 3); | 2599 CONVERT_ARG_HANDLE_CHECKED(JSArray, last_match_info, 3); |
2600 RUNTIME_ASSERT(index >= 0); | 2600 RUNTIME_ASSERT(index >= 0); |
2601 RUNTIME_ASSERT(index <= subject->length()); | 2601 RUNTIME_ASSERT(index <= subject->length()); |
2602 isolate->counters()->regexp_entry_runtime()->Increment(); | 2602 isolate->counters()->regexp_entry_runtime()->Increment(); |
2603 Handle<Object> result = RegExpImpl::Exec(regexp, | 2603 Handle<Object> result = RegExpImpl::Exec(regexp, |
2604 subject, | 2604 subject, |
2605 index, | 2605 index, |
2606 last_match_info); | 2606 last_match_info); |
2607 RETURN_IF_EMPTY_HANDLE(isolate, result); | 2607 RETURN_IF_EMPTY_HANDLE(isolate, result); |
2608 return *result; | 2608 return *result; |
2609 } | 2609 } |
2610 | 2610 |
2611 | 2611 |
2612 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_RegExpConstructResult) { | 2612 RUNTIME_FUNCTION(Object*, RuntimeHidden_RegExpConstructResult) { |
2613 HandleScope handle_scope(isolate); | 2613 HandleScope handle_scope(isolate); |
2614 ASSERT(args.length() == 3); | 2614 ASSERT(args.length() == 3); |
2615 CONVERT_SMI_ARG_CHECKED(size, 0); | 2615 CONVERT_SMI_ARG_CHECKED(size, 0); |
2616 RUNTIME_ASSERT(size >= 0 && size <= FixedArray::kMaxLength); | 2616 RUNTIME_ASSERT(size >= 0 && size <= FixedArray::kMaxLength); |
2617 CONVERT_ARG_HANDLE_CHECKED(Object, index, 1); | 2617 CONVERT_ARG_HANDLE_CHECKED(Object, index, 1); |
2618 CONVERT_ARG_HANDLE_CHECKED(Object, input, 2); | 2618 CONVERT_ARG_HANDLE_CHECKED(Object, input, 2); |
2619 Handle<FixedArray> elements = isolate->factory()->NewFixedArray(size); | 2619 Handle<FixedArray> elements = isolate->factory()->NewFixedArray(size); |
2620 Handle<Map> regexp_map(isolate->native_context()->regexp_result_map()); | 2620 Handle<Map> regexp_map(isolate->native_context()->regexp_result_map()); |
2621 Handle<JSObject> object = | 2621 Handle<JSObject> object = |
2622 isolate->factory()->NewJSObjectFromMap(regexp_map, NOT_TENURED, false); | 2622 isolate->factory()->NewJSObjectFromMap(regexp_map, NOT_TENURED, false); |
2623 Handle<JSArray> array = Handle<JSArray>::cast(object); | 2623 Handle<JSArray> array = Handle<JSArray>::cast(object); |
2624 array->set_elements(*elements); | 2624 array->set_elements(*elements); |
2625 array->set_length(Smi::FromInt(size)); | 2625 array->set_length(Smi::FromInt(size)); |
2626 // Write in-object properties after the length of the array. | 2626 // Write in-object properties after the length of the array. |
2627 array->InObjectPropertyAtPut(JSRegExpResult::kIndexIndex, *index); | 2627 array->InObjectPropertyAtPut(JSRegExpResult::kIndexIndex, *index); |
2628 array->InObjectPropertyAtPut(JSRegExpResult::kInputIndex, *input); | 2628 array->InObjectPropertyAtPut(JSRegExpResult::kInputIndex, *input); |
2629 return *array; | 2629 return *array; |
2630 } | 2630 } |
2631 | 2631 |
2632 | 2632 |
2633 RUNTIME_FUNCTION(MaybeObject*, Runtime_RegExpInitializeObject) { | 2633 RUNTIME_FUNCTION(Object*, Runtime_RegExpInitializeObject) { |
2634 HandleScope scope(isolate); | 2634 HandleScope scope(isolate); |
2635 ASSERT(args.length() == 5); | 2635 ASSERT(args.length() == 5); |
2636 CONVERT_ARG_HANDLE_CHECKED(JSRegExp, regexp, 0); | 2636 CONVERT_ARG_HANDLE_CHECKED(JSRegExp, regexp, 0); |
2637 CONVERT_ARG_HANDLE_CHECKED(String, source, 1); | 2637 CONVERT_ARG_HANDLE_CHECKED(String, source, 1); |
2638 // If source is the empty string we set it to "(?:)" instead as | 2638 // If source is the empty string we set it to "(?:)" instead as |
2639 // suggested by ECMA-262, 5th, section 15.10.4.1. | 2639 // suggested by ECMA-262, 5th, section 15.10.4.1. |
2640 if (source->length() == 0) source = isolate->factory()->query_colon_string(); | 2640 if (source->length() == 0) source = isolate->factory()->query_colon_string(); |
2641 | 2641 |
2642 CONVERT_ARG_HANDLE_CHECKED(Object, global, 2); | 2642 CONVERT_ARG_HANDLE_CHECKED(Object, global, 2); |
2643 if (!global->IsTrue()) global = isolate->factory()->false_value(); | 2643 if (!global->IsTrue()) global = isolate->factory()->false_value(); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2681 JSObject::SetLocalPropertyIgnoreAttributes( | 2681 JSObject::SetLocalPropertyIgnoreAttributes( |
2682 regexp, factory->ignore_case_string(), ignoreCase, final).Check(); | 2682 regexp, factory->ignore_case_string(), ignoreCase, final).Check(); |
2683 JSObject::SetLocalPropertyIgnoreAttributes( | 2683 JSObject::SetLocalPropertyIgnoreAttributes( |
2684 regexp, factory->multiline_string(), multiline, final).Check(); | 2684 regexp, factory->multiline_string(), multiline, final).Check(); |
2685 JSObject::SetLocalPropertyIgnoreAttributes( | 2685 JSObject::SetLocalPropertyIgnoreAttributes( |
2686 regexp, factory->last_index_string(), zero, writable).Check(); | 2686 regexp, factory->last_index_string(), zero, writable).Check(); |
2687 return *regexp; | 2687 return *regexp; |
2688 } | 2688 } |
2689 | 2689 |
2690 | 2690 |
2691 RUNTIME_FUNCTION(MaybeObject*, Runtime_FinishArrayPrototypeSetup) { | 2691 RUNTIME_FUNCTION(Object*, Runtime_FinishArrayPrototypeSetup) { |
2692 HandleScope scope(isolate); | 2692 HandleScope scope(isolate); |
2693 ASSERT(args.length() == 1); | 2693 ASSERT(args.length() == 1); |
2694 CONVERT_ARG_HANDLE_CHECKED(JSArray, prototype, 0); | 2694 CONVERT_ARG_HANDLE_CHECKED(JSArray, prototype, 0); |
2695 // This is necessary to enable fast checks for absence of elements | 2695 // This is necessary to enable fast checks for absence of elements |
2696 // on Array.prototype and below. | 2696 // on Array.prototype and below. |
2697 prototype->set_elements(isolate->heap()->empty_fixed_array()); | 2697 prototype->set_elements(isolate->heap()->empty_fixed_array()); |
2698 return Smi::FromInt(0); | 2698 return Smi::FromInt(0); |
2699 } | 2699 } |
2700 | 2700 |
2701 | 2701 |
2702 static Handle<JSFunction> InstallBuiltin(Isolate* isolate, | 2702 static Handle<JSFunction> InstallBuiltin(Isolate* isolate, |
2703 Handle<JSObject> holder, | 2703 Handle<JSObject> holder, |
2704 const char* name, | 2704 const char* name, |
2705 Builtins::Name builtin_name) { | 2705 Builtins::Name builtin_name) { |
2706 Handle<String> key = isolate->factory()->InternalizeUtf8String(name); | 2706 Handle<String> key = isolate->factory()->InternalizeUtf8String(name); |
2707 Handle<Code> code(isolate->builtins()->builtin(builtin_name)); | 2707 Handle<Code> code(isolate->builtins()->builtin(builtin_name)); |
2708 Handle<JSFunction> optimized = | 2708 Handle<JSFunction> optimized = |
2709 isolate->factory()->NewFunction(key, | 2709 isolate->factory()->NewFunction(key, |
2710 JS_OBJECT_TYPE, | 2710 JS_OBJECT_TYPE, |
2711 JSObject::kHeaderSize, | 2711 JSObject::kHeaderSize, |
2712 code, | 2712 code, |
2713 false); | 2713 false); |
2714 optimized->shared()->DontAdaptArguments(); | 2714 optimized->shared()->DontAdaptArguments(); |
2715 JSReceiver::SetProperty(holder, key, optimized, NONE, STRICT).Assert(); | 2715 JSReceiver::SetProperty(holder, key, optimized, NONE, STRICT).Assert(); |
2716 return optimized; | 2716 return optimized; |
2717 } | 2717 } |
2718 | 2718 |
2719 | 2719 |
2720 RUNTIME_FUNCTION(MaybeObject*, Runtime_SpecialArrayFunctions) { | 2720 RUNTIME_FUNCTION(Object*, Runtime_SpecialArrayFunctions) { |
2721 HandleScope scope(isolate); | 2721 HandleScope scope(isolate); |
2722 ASSERT(args.length() == 1); | 2722 ASSERT(args.length() == 1); |
2723 CONVERT_ARG_HANDLE_CHECKED(JSObject, holder, 0); | 2723 CONVERT_ARG_HANDLE_CHECKED(JSObject, holder, 0); |
2724 | 2724 |
2725 InstallBuiltin(isolate, holder, "pop", Builtins::kArrayPop); | 2725 InstallBuiltin(isolate, holder, "pop", Builtins::kArrayPop); |
2726 InstallBuiltin(isolate, holder, "push", Builtins::kArrayPush); | 2726 InstallBuiltin(isolate, holder, "push", Builtins::kArrayPush); |
2727 InstallBuiltin(isolate, holder, "shift", Builtins::kArrayShift); | 2727 InstallBuiltin(isolate, holder, "shift", Builtins::kArrayShift); |
2728 InstallBuiltin(isolate, holder, "unshift", Builtins::kArrayUnshift); | 2728 InstallBuiltin(isolate, holder, "unshift", Builtins::kArrayUnshift); |
2729 InstallBuiltin(isolate, holder, "slice", Builtins::kArraySlice); | 2729 InstallBuiltin(isolate, holder, "slice", Builtins::kArraySlice); |
2730 InstallBuiltin(isolate, holder, "splice", Builtins::kArraySplice); | 2730 InstallBuiltin(isolate, holder, "splice", Builtins::kArraySplice); |
2731 InstallBuiltin(isolate, holder, "concat", Builtins::kArrayConcat); | 2731 InstallBuiltin(isolate, holder, "concat", Builtins::kArrayConcat); |
2732 | 2732 |
2733 return *holder; | 2733 return *holder; |
2734 } | 2734 } |
2735 | 2735 |
2736 | 2736 |
2737 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsSloppyModeFunction) { | 2737 RUNTIME_FUNCTION(Object*, Runtime_IsSloppyModeFunction) { |
2738 SealHandleScope shs(isolate); | 2738 SealHandleScope shs(isolate); |
2739 ASSERT(args.length() == 1); | 2739 ASSERT(args.length() == 1); |
2740 CONVERT_ARG_CHECKED(JSReceiver, callable, 0); | 2740 CONVERT_ARG_CHECKED(JSReceiver, callable, 0); |
2741 if (!callable->IsJSFunction()) { | 2741 if (!callable->IsJSFunction()) { |
2742 HandleScope scope(isolate); | 2742 HandleScope scope(isolate); |
2743 Handle<Object> delegate; | 2743 Handle<Object> delegate; |
2744 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 2744 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
2745 isolate, delegate, | 2745 isolate, delegate, |
2746 Execution::TryGetFunctionDelegate( | 2746 Execution::TryGetFunctionDelegate( |
2747 isolate, Handle<JSReceiver>(callable))); | 2747 isolate, Handle<JSReceiver>(callable))); |
2748 callable = JSFunction::cast(*delegate); | 2748 callable = JSFunction::cast(*delegate); |
2749 } | 2749 } |
2750 JSFunction* function = JSFunction::cast(callable); | 2750 JSFunction* function = JSFunction::cast(callable); |
2751 SharedFunctionInfo* shared = function->shared(); | 2751 SharedFunctionInfo* shared = function->shared(); |
2752 return isolate->heap()->ToBoolean(shared->strict_mode() == SLOPPY); | 2752 return isolate->heap()->ToBoolean(shared->strict_mode() == SLOPPY); |
2753 } | 2753 } |
2754 | 2754 |
2755 | 2755 |
2756 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetDefaultReceiver) { | 2756 RUNTIME_FUNCTION(Object*, Runtime_GetDefaultReceiver) { |
2757 SealHandleScope shs(isolate); | 2757 SealHandleScope shs(isolate); |
2758 ASSERT(args.length() == 1); | 2758 ASSERT(args.length() == 1); |
2759 CONVERT_ARG_CHECKED(JSReceiver, callable, 0); | 2759 CONVERT_ARG_CHECKED(JSReceiver, callable, 0); |
2760 | 2760 |
2761 if (!callable->IsJSFunction()) { | 2761 if (!callable->IsJSFunction()) { |
2762 HandleScope scope(isolate); | 2762 HandleScope scope(isolate); |
2763 Handle<Object> delegate; | 2763 Handle<Object> delegate; |
2764 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 2764 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
2765 isolate, delegate, | 2765 isolate, delegate, |
2766 Execution::TryGetFunctionDelegate( | 2766 Execution::TryGetFunctionDelegate( |
2767 isolate, Handle<JSReceiver>(callable))); | 2767 isolate, Handle<JSReceiver>(callable))); |
2768 callable = JSFunction::cast(*delegate); | 2768 callable = JSFunction::cast(*delegate); |
2769 } | 2769 } |
2770 JSFunction* function = JSFunction::cast(callable); | 2770 JSFunction* function = JSFunction::cast(callable); |
2771 | 2771 |
2772 SharedFunctionInfo* shared = function->shared(); | 2772 SharedFunctionInfo* shared = function->shared(); |
2773 if (shared->native() || shared->strict_mode() == STRICT) { | 2773 if (shared->native() || shared->strict_mode() == STRICT) { |
2774 return isolate->heap()->undefined_value(); | 2774 return isolate->heap()->undefined_value(); |
2775 } | 2775 } |
2776 // Returns undefined for strict or native functions, or | 2776 // Returns undefined for strict or native functions, or |
2777 // the associated global receiver for "normal" functions. | 2777 // the associated global receiver for "normal" functions. |
2778 | 2778 |
2779 Context* native_context = | 2779 Context* native_context = |
2780 function->context()->global_object()->native_context(); | 2780 function->context()->global_object()->native_context(); |
2781 return native_context->global_object()->global_receiver(); | 2781 return native_context->global_object()->global_receiver(); |
2782 } | 2782 } |
2783 | 2783 |
2784 | 2784 |
2785 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_MaterializeRegExpLiteral) { | 2785 RUNTIME_FUNCTION(Object*, RuntimeHidden_MaterializeRegExpLiteral) { |
2786 HandleScope scope(isolate); | 2786 HandleScope scope(isolate); |
2787 ASSERT(args.length() == 4); | 2787 ASSERT(args.length() == 4); |
2788 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 0); | 2788 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 0); |
2789 CONVERT_SMI_ARG_CHECKED(index, 1); | 2789 CONVERT_SMI_ARG_CHECKED(index, 1); |
2790 CONVERT_ARG_HANDLE_CHECKED(String, pattern, 2); | 2790 CONVERT_ARG_HANDLE_CHECKED(String, pattern, 2); |
2791 CONVERT_ARG_HANDLE_CHECKED(String, flags, 3); | 2791 CONVERT_ARG_HANDLE_CHECKED(String, flags, 3); |
2792 | 2792 |
2793 // Get the RegExp function from the context in the literals array. | 2793 // Get the RegExp function from the context in the literals array. |
2794 // This is the RegExp function from the context in which the | 2794 // This is the RegExp function from the context in which the |
2795 // function was created. We do not use the RegExp function from the | 2795 // function was created. We do not use the RegExp function from the |
2796 // current native context because this might be the RegExp function | 2796 // current native context because this might be the RegExp function |
2797 // from another context which we should not have access to. | 2797 // from another context which we should not have access to. |
2798 Handle<JSFunction> constructor = | 2798 Handle<JSFunction> constructor = |
2799 Handle<JSFunction>( | 2799 Handle<JSFunction>( |
2800 JSFunction::NativeContextFromLiterals(*literals)->regexp_function()); | 2800 JSFunction::NativeContextFromLiterals(*literals)->regexp_function()); |
2801 // Compute the regular expression literal. | 2801 // Compute the regular expression literal. |
2802 Handle<Object> regexp; | 2802 Handle<Object> regexp; |
2803 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 2803 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
2804 isolate, regexp, | 2804 isolate, regexp, |
2805 RegExpImpl::CreateRegExpLiteral(constructor, pattern, flags)); | 2805 RegExpImpl::CreateRegExpLiteral(constructor, pattern, flags)); |
2806 literals->set(index, *regexp); | 2806 literals->set(index, *regexp); |
2807 return *regexp; | 2807 return *regexp; |
2808 } | 2808 } |
2809 | 2809 |
2810 | 2810 |
2811 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionGetName) { | 2811 RUNTIME_FUNCTION(Object*, Runtime_FunctionGetName) { |
2812 SealHandleScope shs(isolate); | 2812 SealHandleScope shs(isolate); |
2813 ASSERT(args.length() == 1); | 2813 ASSERT(args.length() == 1); |
2814 | 2814 |
2815 CONVERT_ARG_CHECKED(JSFunction, f, 0); | 2815 CONVERT_ARG_CHECKED(JSFunction, f, 0); |
2816 return f->shared()->name(); | 2816 return f->shared()->name(); |
2817 } | 2817 } |
2818 | 2818 |
2819 | 2819 |
2820 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionSetName) { | 2820 RUNTIME_FUNCTION(Object*, Runtime_FunctionSetName) { |
2821 SealHandleScope shs(isolate); | 2821 SealHandleScope shs(isolate); |
2822 ASSERT(args.length() == 2); | 2822 ASSERT(args.length() == 2); |
2823 | 2823 |
2824 CONVERT_ARG_CHECKED(JSFunction, f, 0); | 2824 CONVERT_ARG_CHECKED(JSFunction, f, 0); |
2825 CONVERT_ARG_CHECKED(String, name, 1); | 2825 CONVERT_ARG_CHECKED(String, name, 1); |
2826 f->shared()->set_name(name); | 2826 f->shared()->set_name(name); |
2827 return isolate->heap()->undefined_value(); | 2827 return isolate->heap()->undefined_value(); |
2828 } | 2828 } |
2829 | 2829 |
2830 | 2830 |
2831 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionNameShouldPrintAsAnonymous) { | 2831 RUNTIME_FUNCTION(Object*, Runtime_FunctionNameShouldPrintAsAnonymous) { |
2832 SealHandleScope shs(isolate); | 2832 SealHandleScope shs(isolate); |
2833 ASSERT(args.length() == 1); | 2833 ASSERT(args.length() == 1); |
2834 CONVERT_ARG_CHECKED(JSFunction, f, 0); | 2834 CONVERT_ARG_CHECKED(JSFunction, f, 0); |
2835 return isolate->heap()->ToBoolean( | 2835 return isolate->heap()->ToBoolean( |
2836 f->shared()->name_should_print_as_anonymous()); | 2836 f->shared()->name_should_print_as_anonymous()); |
2837 } | 2837 } |
2838 | 2838 |
2839 | 2839 |
2840 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionMarkNameShouldPrintAsAnonymous) { | 2840 RUNTIME_FUNCTION(Object*, Runtime_FunctionMarkNameShouldPrintAsAnonymous) { |
2841 SealHandleScope shs(isolate); | 2841 SealHandleScope shs(isolate); |
2842 ASSERT(args.length() == 1); | 2842 ASSERT(args.length() == 1); |
2843 CONVERT_ARG_CHECKED(JSFunction, f, 0); | 2843 CONVERT_ARG_CHECKED(JSFunction, f, 0); |
2844 f->shared()->set_name_should_print_as_anonymous(true); | 2844 f->shared()->set_name_should_print_as_anonymous(true); |
2845 return isolate->heap()->undefined_value(); | 2845 return isolate->heap()->undefined_value(); |
2846 } | 2846 } |
2847 | 2847 |
2848 | 2848 |
2849 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionIsGenerator) { | 2849 RUNTIME_FUNCTION(Object*, Runtime_FunctionIsGenerator) { |
2850 SealHandleScope shs(isolate); | 2850 SealHandleScope shs(isolate); |
2851 ASSERT(args.length() == 1); | 2851 ASSERT(args.length() == 1); |
2852 CONVERT_ARG_CHECKED(JSFunction, f, 0); | 2852 CONVERT_ARG_CHECKED(JSFunction, f, 0); |
2853 return isolate->heap()->ToBoolean(f->shared()->is_generator()); | 2853 return isolate->heap()->ToBoolean(f->shared()->is_generator()); |
2854 } | 2854 } |
2855 | 2855 |
2856 | 2856 |
2857 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionRemovePrototype) { | 2857 RUNTIME_FUNCTION(Object*, Runtime_FunctionRemovePrototype) { |
2858 SealHandleScope shs(isolate); | 2858 SealHandleScope shs(isolate); |
2859 ASSERT(args.length() == 1); | 2859 ASSERT(args.length() == 1); |
2860 | 2860 |
2861 CONVERT_ARG_CHECKED(JSFunction, f, 0); | 2861 CONVERT_ARG_CHECKED(JSFunction, f, 0); |
2862 f->RemovePrototype(); | 2862 f->RemovePrototype(); |
2863 | 2863 |
2864 return isolate->heap()->undefined_value(); | 2864 return isolate->heap()->undefined_value(); |
2865 } | 2865 } |
2866 | 2866 |
2867 | 2867 |
2868 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionGetScript) { | 2868 RUNTIME_FUNCTION(Object*, Runtime_FunctionGetScript) { |
2869 HandleScope scope(isolate); | 2869 HandleScope scope(isolate); |
2870 ASSERT(args.length() == 1); | 2870 ASSERT(args.length() == 1); |
2871 | 2871 |
2872 CONVERT_ARG_CHECKED(JSFunction, fun, 0); | 2872 CONVERT_ARG_CHECKED(JSFunction, fun, 0); |
2873 Handle<Object> script = Handle<Object>(fun->shared()->script(), isolate); | 2873 Handle<Object> script = Handle<Object>(fun->shared()->script(), isolate); |
2874 if (!script->IsScript()) return isolate->heap()->undefined_value(); | 2874 if (!script->IsScript()) return isolate->heap()->undefined_value(); |
2875 | 2875 |
2876 return *Script::GetWrapper(Handle<Script>::cast(script)); | 2876 return *Script::GetWrapper(Handle<Script>::cast(script)); |
2877 } | 2877 } |
2878 | 2878 |
2879 | 2879 |
2880 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionGetSourceCode) { | 2880 RUNTIME_FUNCTION(Object*, Runtime_FunctionGetSourceCode) { |
2881 HandleScope scope(isolate); | 2881 HandleScope scope(isolate); |
2882 ASSERT(args.length() == 1); | 2882 ASSERT(args.length() == 1); |
2883 | 2883 |
2884 CONVERT_ARG_HANDLE_CHECKED(JSFunction, f, 0); | 2884 CONVERT_ARG_HANDLE_CHECKED(JSFunction, f, 0); |
2885 Handle<SharedFunctionInfo> shared(f->shared()); | 2885 Handle<SharedFunctionInfo> shared(f->shared()); |
2886 return *shared->GetSourceCode(); | 2886 return *shared->GetSourceCode(); |
2887 } | 2887 } |
2888 | 2888 |
2889 | 2889 |
2890 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionGetScriptSourcePosition) { | 2890 RUNTIME_FUNCTION(Object*, Runtime_FunctionGetScriptSourcePosition) { |
2891 SealHandleScope shs(isolate); | 2891 SealHandleScope shs(isolate); |
2892 ASSERT(args.length() == 1); | 2892 ASSERT(args.length() == 1); |
2893 | 2893 |
2894 CONVERT_ARG_CHECKED(JSFunction, fun, 0); | 2894 CONVERT_ARG_CHECKED(JSFunction, fun, 0); |
2895 int pos = fun->shared()->start_position(); | 2895 int pos = fun->shared()->start_position(); |
2896 return Smi::FromInt(pos); | 2896 return Smi::FromInt(pos); |
2897 } | 2897 } |
2898 | 2898 |
2899 | 2899 |
2900 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionGetPositionForOffset) { | 2900 RUNTIME_FUNCTION(Object*, Runtime_FunctionGetPositionForOffset) { |
2901 SealHandleScope shs(isolate); | 2901 SealHandleScope shs(isolate); |
2902 ASSERT(args.length() == 2); | 2902 ASSERT(args.length() == 2); |
2903 | 2903 |
2904 CONVERT_ARG_CHECKED(Code, code, 0); | 2904 CONVERT_ARG_CHECKED(Code, code, 0); |
2905 CONVERT_NUMBER_CHECKED(int, offset, Int32, args[1]); | 2905 CONVERT_NUMBER_CHECKED(int, offset, Int32, args[1]); |
2906 | 2906 |
2907 RUNTIME_ASSERT(0 <= offset && offset < code->Size()); | 2907 RUNTIME_ASSERT(0 <= offset && offset < code->Size()); |
2908 | 2908 |
2909 Address pc = code->address() + offset; | 2909 Address pc = code->address() + offset; |
2910 return Smi::FromInt(code->SourcePosition(pc)); | 2910 return Smi::FromInt(code->SourcePosition(pc)); |
2911 } | 2911 } |
2912 | 2912 |
2913 | 2913 |
2914 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionSetInstanceClassName) { | 2914 RUNTIME_FUNCTION(Object*, Runtime_FunctionSetInstanceClassName) { |
2915 SealHandleScope shs(isolate); | 2915 SealHandleScope shs(isolate); |
2916 ASSERT(args.length() == 2); | 2916 ASSERT(args.length() == 2); |
2917 | 2917 |
2918 CONVERT_ARG_CHECKED(JSFunction, fun, 0); | 2918 CONVERT_ARG_CHECKED(JSFunction, fun, 0); |
2919 CONVERT_ARG_CHECKED(String, name, 1); | 2919 CONVERT_ARG_CHECKED(String, name, 1); |
2920 fun->SetInstanceClassName(name); | 2920 fun->SetInstanceClassName(name); |
2921 return isolate->heap()->undefined_value(); | 2921 return isolate->heap()->undefined_value(); |
2922 } | 2922 } |
2923 | 2923 |
2924 | 2924 |
2925 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionSetLength) { | 2925 RUNTIME_FUNCTION(Object*, Runtime_FunctionSetLength) { |
2926 SealHandleScope shs(isolate); | 2926 SealHandleScope shs(isolate); |
2927 ASSERT(args.length() == 2); | 2927 ASSERT(args.length() == 2); |
2928 | 2928 |
2929 CONVERT_ARG_CHECKED(JSFunction, fun, 0); | 2929 CONVERT_ARG_CHECKED(JSFunction, fun, 0); |
2930 CONVERT_SMI_ARG_CHECKED(length, 1); | 2930 CONVERT_SMI_ARG_CHECKED(length, 1); |
2931 fun->shared()->set_length(length); | 2931 fun->shared()->set_length(length); |
2932 return isolate->heap()->undefined_value(); | 2932 return isolate->heap()->undefined_value(); |
2933 } | 2933 } |
2934 | 2934 |
2935 | 2935 |
2936 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionSetPrototype) { | 2936 RUNTIME_FUNCTION(Object*, Runtime_FunctionSetPrototype) { |
2937 HandleScope scope(isolate); | 2937 HandleScope scope(isolate); |
2938 ASSERT(args.length() == 2); | 2938 ASSERT(args.length() == 2); |
2939 | 2939 |
2940 CONVERT_ARG_HANDLE_CHECKED(JSFunction, fun, 0); | 2940 CONVERT_ARG_HANDLE_CHECKED(JSFunction, fun, 0); |
2941 CONVERT_ARG_HANDLE_CHECKED(Object, value, 1); | 2941 CONVERT_ARG_HANDLE_CHECKED(Object, value, 1); |
2942 ASSERT(fun->should_have_prototype()); | 2942 ASSERT(fun->should_have_prototype()); |
2943 Accessors::FunctionSetPrototype(fun, value); | 2943 Accessors::FunctionSetPrototype(fun, value); |
2944 return args[0]; // return TOS | 2944 return args[0]; // return TOS |
2945 } | 2945 } |
2946 | 2946 |
2947 | 2947 |
2948 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionSetReadOnlyPrototype) { | 2948 RUNTIME_FUNCTION(Object*, Runtime_FunctionSetReadOnlyPrototype) { |
2949 HandleScope shs(isolate); | 2949 HandleScope shs(isolate); |
2950 RUNTIME_ASSERT(args.length() == 1); | 2950 RUNTIME_ASSERT(args.length() == 1); |
2951 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 2951 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
2952 | 2952 |
2953 Handle<String> name = isolate->factory()->prototype_string(); | 2953 Handle<String> name = isolate->factory()->prototype_string(); |
2954 | 2954 |
2955 if (function->HasFastProperties()) { | 2955 if (function->HasFastProperties()) { |
2956 // Construct a new field descriptor with updated attributes. | 2956 // Construct a new field descriptor with updated attributes. |
2957 Handle<DescriptorArray> instance_desc = | 2957 Handle<DescriptorArray> instance_desc = |
2958 handle(function->map()->instance_descriptors()); | 2958 handle(function->map()->instance_descriptors()); |
(...skipping 22 matching lines...) Expand all Loading... | |
2981 PropertyDetails new_details( | 2981 PropertyDetails new_details( |
2982 static_cast<PropertyAttributes>(details.attributes() | READ_ONLY), | 2982 static_cast<PropertyAttributes>(details.attributes() | READ_ONLY), |
2983 details.type(), | 2983 details.type(), |
2984 details.dictionary_index()); | 2984 details.dictionary_index()); |
2985 function->property_dictionary()->DetailsAtPut(entry, new_details); | 2985 function->property_dictionary()->DetailsAtPut(entry, new_details); |
2986 } | 2986 } |
2987 return *function; | 2987 return *function; |
2988 } | 2988 } |
2989 | 2989 |
2990 | 2990 |
2991 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionIsAPIFunction) { | 2991 RUNTIME_FUNCTION(Object*, Runtime_FunctionIsAPIFunction) { |
2992 SealHandleScope shs(isolate); | 2992 SealHandleScope shs(isolate); |
2993 ASSERT(args.length() == 1); | 2993 ASSERT(args.length() == 1); |
2994 | 2994 |
2995 CONVERT_ARG_CHECKED(JSFunction, f, 0); | 2995 CONVERT_ARG_CHECKED(JSFunction, f, 0); |
2996 return isolate->heap()->ToBoolean(f->shared()->IsApiFunction()); | 2996 return isolate->heap()->ToBoolean(f->shared()->IsApiFunction()); |
2997 } | 2997 } |
2998 | 2998 |
2999 | 2999 |
3000 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionIsBuiltin) { | 3000 RUNTIME_FUNCTION(Object*, Runtime_FunctionIsBuiltin) { |
3001 SealHandleScope shs(isolate); | 3001 SealHandleScope shs(isolate); |
3002 ASSERT(args.length() == 1); | 3002 ASSERT(args.length() == 1); |
3003 | 3003 |
3004 CONVERT_ARG_CHECKED(JSFunction, f, 0); | 3004 CONVERT_ARG_CHECKED(JSFunction, f, 0); |
3005 return isolate->heap()->ToBoolean(f->IsBuiltin()); | 3005 return isolate->heap()->ToBoolean(f->IsBuiltin()); |
3006 } | 3006 } |
3007 | 3007 |
3008 | 3008 |
3009 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetCode) { | 3009 RUNTIME_FUNCTION(Object*, Runtime_SetCode) { |
3010 HandleScope scope(isolate); | 3010 HandleScope scope(isolate); |
3011 ASSERT(args.length() == 2); | 3011 ASSERT(args.length() == 2); |
3012 | 3012 |
3013 CONVERT_ARG_HANDLE_CHECKED(JSFunction, target, 0); | 3013 CONVERT_ARG_HANDLE_CHECKED(JSFunction, target, 0); |
3014 CONVERT_ARG_HANDLE_CHECKED(Object, code, 1); | 3014 CONVERT_ARG_HANDLE_CHECKED(Object, code, 1); |
3015 | 3015 |
3016 if (code->IsNull()) return *target; | 3016 if (code->IsNull()) return *target; |
3017 RUNTIME_ASSERT(code->IsJSFunction()); | 3017 RUNTIME_ASSERT(code->IsJSFunction()); |
3018 Handle<JSFunction> source = Handle<JSFunction>::cast(code); | 3018 Handle<JSFunction> source = Handle<JSFunction>::cast(code); |
3019 Handle<SharedFunctionInfo> target_shared(target->shared()); | 3019 Handle<SharedFunctionInfo> target_shared(target->shared()); |
3020 Handle<SharedFunctionInfo> source_shared(source->shared()); | 3020 Handle<SharedFunctionInfo> source_shared(source->shared()); |
3021 | 3021 |
3022 if (!Compiler::EnsureCompiled(source, KEEP_EXCEPTION)) { | 3022 if (!Compiler::EnsureCompiled(source, KEEP_EXCEPTION)) { |
3023 return Failure::Exception(); | 3023 return isolate->heap()->exception(); |
3024 } | 3024 } |
3025 | 3025 |
3026 // Mark both, the source and the target, as un-flushable because the | 3026 // Mark both, the source and the target, as un-flushable because the |
3027 // shared unoptimized code makes them impossible to enqueue in a list. | 3027 // shared unoptimized code makes them impossible to enqueue in a list. |
3028 ASSERT(target_shared->code()->gc_metadata() == NULL); | 3028 ASSERT(target_shared->code()->gc_metadata() == NULL); |
3029 ASSERT(source_shared->code()->gc_metadata() == NULL); | 3029 ASSERT(source_shared->code()->gc_metadata() == NULL); |
3030 target_shared->set_dont_flush(true); | 3030 target_shared->set_dont_flush(true); |
3031 source_shared->set_dont_flush(true); | 3031 source_shared->set_dont_flush(true); |
3032 | 3032 |
3033 // Set the code, scope info, formal parameter count, and the length | 3033 // Set the code, scope info, formal parameter count, and the length |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3065 if (isolate->logger()->is_logging_code_events() || | 3065 if (isolate->logger()->is_logging_code_events() || |
3066 isolate->cpu_profiler()->is_profiling()) { | 3066 isolate->cpu_profiler()->is_profiling()) { |
3067 isolate->logger()->LogExistingFunction( | 3067 isolate->logger()->LogExistingFunction( |
3068 source_shared, Handle<Code>(source_shared->code())); | 3068 source_shared, Handle<Code>(source_shared->code())); |
3069 } | 3069 } |
3070 | 3070 |
3071 return *target; | 3071 return *target; |
3072 } | 3072 } |
3073 | 3073 |
3074 | 3074 |
3075 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetExpectedNumberOfProperties) { | 3075 RUNTIME_FUNCTION(Object*, Runtime_SetExpectedNumberOfProperties) { |
3076 HandleScope scope(isolate); | 3076 HandleScope scope(isolate); |
3077 ASSERT(args.length() == 2); | 3077 ASSERT(args.length() == 2); |
3078 CONVERT_ARG_HANDLE_CHECKED(JSFunction, func, 0); | 3078 CONVERT_ARG_HANDLE_CHECKED(JSFunction, func, 0); |
3079 CONVERT_SMI_ARG_CHECKED(num, 1); | 3079 CONVERT_SMI_ARG_CHECKED(num, 1); |
3080 RUNTIME_ASSERT(num >= 0); | 3080 RUNTIME_ASSERT(num >= 0); |
3081 // If objects constructed from this function exist then changing | 3081 // If objects constructed from this function exist then changing |
3082 // 'estimated_nof_properties' is dangerous since the previous value might | 3082 // 'estimated_nof_properties' is dangerous since the previous value might |
3083 // have been compiled into the fast construct stub. Moreover, the inobject | 3083 // have been compiled into the fast construct stub. Moreover, the inobject |
3084 // slack tracking logic might have adjusted the previous value, so even | 3084 // slack tracking logic might have adjusted the previous value, so even |
3085 // passing the same value is risky. | 3085 // passing the same value is risky. |
3086 if (!func->shared()->live_objects_may_exist()) { | 3086 if (!func->shared()->live_objects_may_exist()) { |
3087 func->shared()->set_expected_nof_properties(num); | 3087 func->shared()->set_expected_nof_properties(num); |
3088 if (func->has_initial_map()) { | 3088 if (func->has_initial_map()) { |
3089 Handle<Map> new_initial_map = Map::Copy(handle(func->initial_map())); | 3089 Handle<Map> new_initial_map = Map::Copy(handle(func->initial_map())); |
3090 new_initial_map->set_unused_property_fields(num); | 3090 new_initial_map->set_unused_property_fields(num); |
3091 func->set_initial_map(*new_initial_map); | 3091 func->set_initial_map(*new_initial_map); |
3092 } | 3092 } |
3093 } | 3093 } |
3094 return isolate->heap()->undefined_value(); | 3094 return isolate->heap()->undefined_value(); |
3095 } | 3095 } |
3096 | 3096 |
3097 | 3097 |
3098 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_CreateJSGeneratorObject) { | 3098 RUNTIME_FUNCTION(Object*, RuntimeHidden_CreateJSGeneratorObject) { |
3099 HandleScope scope(isolate); | 3099 HandleScope scope(isolate); |
3100 ASSERT(args.length() == 0); | 3100 ASSERT(args.length() == 0); |
3101 | 3101 |
3102 JavaScriptFrameIterator it(isolate); | 3102 JavaScriptFrameIterator it(isolate); |
3103 JavaScriptFrame* frame = it.frame(); | 3103 JavaScriptFrame* frame = it.frame(); |
3104 Handle<JSFunction> function(frame->function()); | 3104 Handle<JSFunction> function(frame->function()); |
3105 RUNTIME_ASSERT(function->shared()->is_generator()); | 3105 RUNTIME_ASSERT(function->shared()->is_generator()); |
3106 | 3106 |
3107 Handle<JSGeneratorObject> generator; | 3107 Handle<JSGeneratorObject> generator; |
3108 if (frame->IsConstructor()) { | 3108 if (frame->IsConstructor()) { |
3109 generator = handle(JSGeneratorObject::cast(frame->receiver())); | 3109 generator = handle(JSGeneratorObject::cast(frame->receiver())); |
3110 } else { | 3110 } else { |
3111 generator = isolate->factory()->NewJSGeneratorObject(function); | 3111 generator = isolate->factory()->NewJSGeneratorObject(function); |
3112 } | 3112 } |
3113 generator->set_function(*function); | 3113 generator->set_function(*function); |
3114 generator->set_context(Context::cast(frame->context())); | 3114 generator->set_context(Context::cast(frame->context())); |
3115 generator->set_receiver(frame->receiver()); | 3115 generator->set_receiver(frame->receiver()); |
3116 generator->set_continuation(0); | 3116 generator->set_continuation(0); |
3117 generator->set_operand_stack(isolate->heap()->empty_fixed_array()); | 3117 generator->set_operand_stack(isolate->heap()->empty_fixed_array()); |
3118 generator->set_stack_handler_index(-1); | 3118 generator->set_stack_handler_index(-1); |
3119 | 3119 |
3120 return *generator; | 3120 return *generator; |
3121 } | 3121 } |
3122 | 3122 |
3123 | 3123 |
3124 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_SuspendJSGeneratorObject) { | 3124 RUNTIME_FUNCTION(Object*, RuntimeHidden_SuspendJSGeneratorObject) { |
3125 HandleScope handle_scope(isolate); | 3125 HandleScope handle_scope(isolate); |
3126 ASSERT(args.length() == 1); | 3126 ASSERT(args.length() == 1); |
3127 CONVERT_ARG_HANDLE_CHECKED(JSGeneratorObject, generator_object, 0); | 3127 CONVERT_ARG_HANDLE_CHECKED(JSGeneratorObject, generator_object, 0); |
3128 | 3128 |
3129 JavaScriptFrameIterator stack_iterator(isolate); | 3129 JavaScriptFrameIterator stack_iterator(isolate); |
3130 JavaScriptFrame* frame = stack_iterator.frame(); | 3130 JavaScriptFrame* frame = stack_iterator.frame(); |
3131 RUNTIME_ASSERT(frame->function()->shared()->is_generator()); | 3131 RUNTIME_ASSERT(frame->function()->shared()->is_generator()); |
3132 ASSERT_EQ(frame->function(), generator_object->function()); | 3132 ASSERT_EQ(frame->function(), generator_object->function()); |
3133 | 3133 |
3134 // The caller should have saved the context and continuation already. | 3134 // The caller should have saved the context and continuation already. |
(...skipping 29 matching lines...) Expand all Loading... | |
3164 } | 3164 } |
3165 | 3165 |
3166 | 3166 |
3167 // Note that this function is the slow path for resuming generators. It is only | 3167 // Note that this function is the slow path for resuming generators. It is only |
3168 // called if the suspended activation had operands on the stack, stack handlers | 3168 // called if the suspended activation had operands on the stack, stack handlers |
3169 // needing rewinding, or if the resume should throw an exception. The fast path | 3169 // needing rewinding, or if the resume should throw an exception. The fast path |
3170 // is handled directly in FullCodeGenerator::EmitGeneratorResume(), which is | 3170 // is handled directly in FullCodeGenerator::EmitGeneratorResume(), which is |
3171 // inlined into GeneratorNext and GeneratorThrow. EmitGeneratorResumeResume is | 3171 // inlined into GeneratorNext and GeneratorThrow. EmitGeneratorResumeResume is |
3172 // called in any case, as it needs to reconstruct the stack frame and make space | 3172 // called in any case, as it needs to reconstruct the stack frame and make space |
3173 // for arguments and operands. | 3173 // for arguments and operands. |
3174 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_ResumeJSGeneratorObject) { | 3174 RUNTIME_FUNCTION(Object*, RuntimeHidden_ResumeJSGeneratorObject) { |
3175 SealHandleScope shs(isolate); | 3175 SealHandleScope shs(isolate); |
3176 ASSERT(args.length() == 3); | 3176 ASSERT(args.length() == 3); |
3177 CONVERT_ARG_CHECKED(JSGeneratorObject, generator_object, 0); | 3177 CONVERT_ARG_CHECKED(JSGeneratorObject, generator_object, 0); |
3178 CONVERT_ARG_CHECKED(Object, value, 1); | 3178 CONVERT_ARG_CHECKED(Object, value, 1); |
3179 CONVERT_SMI_ARG_CHECKED(resume_mode_int, 2); | 3179 CONVERT_SMI_ARG_CHECKED(resume_mode_int, 2); |
3180 JavaScriptFrameIterator stack_iterator(isolate); | 3180 JavaScriptFrameIterator stack_iterator(isolate); |
3181 JavaScriptFrame* frame = stack_iterator.frame(); | 3181 JavaScriptFrame* frame = stack_iterator.frame(); |
3182 | 3182 |
3183 ASSERT_EQ(frame->function(), generator_object->function()); | 3183 ASSERT_EQ(frame->function(), generator_object->function()); |
3184 ASSERT(frame->function()->is_compiled()); | 3184 ASSERT(frame->function()->is_compiled()); |
(...skipping 27 matching lines...) Expand all Loading... | |
3212 return value; | 3212 return value; |
3213 case JSGeneratorObject::THROW: | 3213 case JSGeneratorObject::THROW: |
3214 return isolate->Throw(value); | 3214 return isolate->Throw(value); |
3215 } | 3215 } |
3216 | 3216 |
3217 UNREACHABLE(); | 3217 UNREACHABLE(); |
3218 return isolate->ThrowIllegalOperation(); | 3218 return isolate->ThrowIllegalOperation(); |
3219 } | 3219 } |
3220 | 3220 |
3221 | 3221 |
3222 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_ThrowGeneratorStateError) { | 3222 RUNTIME_FUNCTION(Object*, RuntimeHidden_ThrowGeneratorStateError) { |
3223 HandleScope scope(isolate); | 3223 HandleScope scope(isolate); |
3224 ASSERT(args.length() == 1); | 3224 ASSERT(args.length() == 1); |
3225 CONVERT_ARG_HANDLE_CHECKED(JSGeneratorObject, generator, 0); | 3225 CONVERT_ARG_HANDLE_CHECKED(JSGeneratorObject, generator, 0); |
3226 int continuation = generator->continuation(); | 3226 int continuation = generator->continuation(); |
3227 const char* message = continuation == JSGeneratorObject::kGeneratorClosed ? | 3227 const char* message = continuation == JSGeneratorObject::kGeneratorClosed ? |
3228 "generator_finished" : "generator_running"; | 3228 "generator_finished" : "generator_running"; |
3229 Vector< Handle<Object> > argv = HandleVector<Object>(NULL, 0); | 3229 Vector< Handle<Object> > argv = HandleVector<Object>(NULL, 0); |
3230 Handle<Object> error = isolate->factory()->NewError(message, argv); | 3230 Handle<Object> error = isolate->factory()->NewError(message, argv); |
3231 return isolate->Throw(*error); | 3231 return isolate->Throw(*error); |
3232 } | 3232 } |
3233 | 3233 |
3234 | 3234 |
3235 RUNTIME_FUNCTION(MaybeObject*, Runtime_ObjectFreeze) { | 3235 RUNTIME_FUNCTION(Object*, Runtime_ObjectFreeze) { |
3236 HandleScope scope(isolate); | 3236 HandleScope scope(isolate); |
3237 ASSERT(args.length() == 1); | 3237 ASSERT(args.length() == 1); |
3238 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); | 3238 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); |
3239 Handle<Object> result; | 3239 Handle<Object> result; |
3240 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, JSObject::Freeze(object)); | 3240 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, JSObject::Freeze(object)); |
3241 return *result; | 3241 return *result; |
3242 } | 3242 } |
3243 | 3243 |
3244 | 3244 |
3245 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_StringCharCodeAt) { | 3245 RUNTIME_FUNCTION(Object*, RuntimeHidden_StringCharCodeAt) { |
3246 HandleScope handle_scope(isolate); | 3246 HandleScope handle_scope(isolate); |
3247 ASSERT(args.length() == 2); | 3247 ASSERT(args.length() == 2); |
3248 | 3248 |
3249 CONVERT_ARG_HANDLE_CHECKED(String, subject, 0); | 3249 CONVERT_ARG_HANDLE_CHECKED(String, subject, 0); |
3250 CONVERT_NUMBER_CHECKED(uint32_t, i, Uint32, args[1]); | 3250 CONVERT_NUMBER_CHECKED(uint32_t, i, Uint32, args[1]); |
3251 | 3251 |
3252 // Flatten the string. If someone wants to get a char at an index | 3252 // Flatten the string. If someone wants to get a char at an index |
3253 // in a cons string, it is likely that more indices will be | 3253 // in a cons string, it is likely that more indices will be |
3254 // accessed. | 3254 // accessed. |
3255 subject = String::Flatten(subject); | 3255 subject = String::Flatten(subject); |
3256 | 3256 |
3257 if (i >= static_cast<uint32_t>(subject->length())) { | 3257 if (i >= static_cast<uint32_t>(subject->length())) { |
3258 return isolate->heap()->nan_value(); | 3258 return isolate->heap()->nan_value(); |
3259 } | 3259 } |
3260 | 3260 |
3261 return Smi::FromInt(subject->Get(i)); | 3261 return Smi::FromInt(subject->Get(i)); |
3262 } | 3262 } |
3263 | 3263 |
3264 | 3264 |
3265 RUNTIME_FUNCTION(MaybeObject*, Runtime_CharFromCode) { | 3265 RUNTIME_FUNCTION(Object*, Runtime_CharFromCode) { |
3266 HandleScope handlescope(isolate); | 3266 HandleScope handlescope(isolate); |
3267 ASSERT(args.length() == 1); | 3267 ASSERT(args.length() == 1); |
3268 if (args[0]->IsNumber()) { | 3268 if (args[0]->IsNumber()) { |
3269 CONVERT_NUMBER_CHECKED(uint32_t, code, Uint32, args[0]); | 3269 CONVERT_NUMBER_CHECKED(uint32_t, code, Uint32, args[0]); |
3270 code &= 0xffff; | 3270 code &= 0xffff; |
3271 return *isolate->factory()->LookupSingleCharacterStringFromCode(code); | 3271 return *isolate->factory()->LookupSingleCharacterStringFromCode(code); |
3272 } | 3272 } |
3273 return isolate->heap()->empty_string(); | 3273 return isolate->heap()->empty_string(); |
3274 } | 3274 } |
3275 | 3275 |
(...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3911 limit, | 3911 limit, |
3912 zone); | 3912 zone); |
3913 } | 3913 } |
3914 } | 3914 } |
3915 } | 3915 } |
3916 } | 3916 } |
3917 } | 3917 } |
3918 | 3918 |
3919 | 3919 |
3920 template<typename ResultSeqString> | 3920 template<typename ResultSeqString> |
3921 MUST_USE_RESULT static MaybeObject* StringReplaceGlobalAtomRegExpWithString( | 3921 MUST_USE_RESULT static Object* StringReplaceGlobalAtomRegExpWithString( |
3922 Isolate* isolate, | 3922 Isolate* isolate, |
3923 Handle<String> subject, | 3923 Handle<String> subject, |
3924 Handle<JSRegExp> pattern_regexp, | 3924 Handle<JSRegExp> pattern_regexp, |
3925 Handle<String> replacement, | 3925 Handle<String> replacement, |
3926 Handle<JSArray> last_match_info) { | 3926 Handle<JSArray> last_match_info) { |
3927 ASSERT(subject->IsFlat()); | 3927 ASSERT(subject->IsFlat()); |
3928 ASSERT(replacement->IsFlat()); | 3928 ASSERT(replacement->IsFlat()); |
3929 | 3929 |
3930 ZoneScope zone_scope(isolate->runtime_zone()); | 3930 ZoneScope zone_scope(isolate->runtime_zone()); |
3931 ZoneList<int> indices(8, zone_scope.zone()); | 3931 ZoneList<int> indices(8, zone_scope.zone()); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3999 } | 3999 } |
4000 | 4000 |
4001 int32_t match_indices[] = { indices.at(matches - 1), | 4001 int32_t match_indices[] = { indices.at(matches - 1), |
4002 indices.at(matches - 1) + pattern_len }; | 4002 indices.at(matches - 1) + pattern_len }; |
4003 RegExpImpl::SetLastMatchInfo(last_match_info, subject, 0, match_indices); | 4003 RegExpImpl::SetLastMatchInfo(last_match_info, subject, 0, match_indices); |
4004 | 4004 |
4005 return *result; | 4005 return *result; |
4006 } | 4006 } |
4007 | 4007 |
4008 | 4008 |
4009 MUST_USE_RESULT static MaybeObject* StringReplaceGlobalRegExpWithString( | 4009 MUST_USE_RESULT static Object* StringReplaceGlobalRegExpWithString( |
4010 Isolate* isolate, | 4010 Isolate* isolate, |
4011 Handle<String> subject, | 4011 Handle<String> subject, |
4012 Handle<JSRegExp> regexp, | 4012 Handle<JSRegExp> regexp, |
4013 Handle<String> replacement, | 4013 Handle<String> replacement, |
4014 Handle<JSArray> last_match_info) { | 4014 Handle<JSArray> last_match_info) { |
4015 ASSERT(subject->IsFlat()); | 4015 ASSERT(subject->IsFlat()); |
4016 ASSERT(replacement->IsFlat()); | 4016 ASSERT(replacement->IsFlat()); |
4017 | 4017 |
4018 int capture_count = regexp->CaptureCount(); | 4018 int capture_count = regexp->CaptureCount(); |
4019 int subject_length = subject->length(); | 4019 int subject_length = subject->length(); |
(...skipping 11 matching lines...) Expand all Loading... | |
4031 replacement->HasOnlyOneByteChars()) { | 4031 replacement->HasOnlyOneByteChars()) { |
4032 return StringReplaceGlobalAtomRegExpWithString<SeqOneByteString>( | 4032 return StringReplaceGlobalAtomRegExpWithString<SeqOneByteString>( |
4033 isolate, subject, regexp, replacement, last_match_info); | 4033 isolate, subject, regexp, replacement, last_match_info); |
4034 } else { | 4034 } else { |
4035 return StringReplaceGlobalAtomRegExpWithString<SeqTwoByteString>( | 4035 return StringReplaceGlobalAtomRegExpWithString<SeqTwoByteString>( |
4036 isolate, subject, regexp, replacement, last_match_info); | 4036 isolate, subject, regexp, replacement, last_match_info); |
4037 } | 4037 } |
4038 } | 4038 } |
4039 | 4039 |
4040 RegExpImpl::GlobalCache global_cache(regexp, subject, true, isolate); | 4040 RegExpImpl::GlobalCache global_cache(regexp, subject, true, isolate); |
4041 if (global_cache.HasException()) return Failure::Exception(); | 4041 if (global_cache.HasException()) return isolate->heap()->exception(); |
4042 | 4042 |
4043 int32_t* current_match = global_cache.FetchNext(); | 4043 int32_t* current_match = global_cache.FetchNext(); |
4044 if (current_match == NULL) { | 4044 if (current_match == NULL) { |
4045 if (global_cache.HasException()) return Failure::Exception(); | 4045 if (global_cache.HasException()) return isolate->heap()->exception(); |
4046 return *subject; | 4046 return *subject; |
4047 } | 4047 } |
4048 | 4048 |
4049 // Guessing the number of parts that the final result string is built | 4049 // Guessing the number of parts that the final result string is built |
4050 // from. Global regexps can match any number of times, so we guess | 4050 // from. Global regexps can match any number of times, so we guess |
4051 // conservatively. | 4051 // conservatively. |
4052 int expected_parts = (compiled_replacement.parts() + 1) * 4 + 1; | 4052 int expected_parts = (compiled_replacement.parts() + 1) * 4 + 1; |
4053 ReplacementStringBuilder builder(isolate->heap(), | 4053 ReplacementStringBuilder builder(isolate->heap(), |
4054 subject, | 4054 subject, |
4055 expected_parts); | 4055 expected_parts); |
(...skipping 21 matching lines...) Expand all Loading... | |
4077 compiled_replacement.Apply(&builder, | 4077 compiled_replacement.Apply(&builder, |
4078 start, | 4078 start, |
4079 end, | 4079 end, |
4080 current_match); | 4080 current_match); |
4081 } | 4081 } |
4082 prev = end; | 4082 prev = end; |
4083 | 4083 |
4084 current_match = global_cache.FetchNext(); | 4084 current_match = global_cache.FetchNext(); |
4085 } while (current_match != NULL); | 4085 } while (current_match != NULL); |
4086 | 4086 |
4087 if (global_cache.HasException()) return Failure::Exception(); | 4087 if (global_cache.HasException()) return isolate->heap()->exception(); |
4088 | 4088 |
4089 if (prev < subject_length) { | 4089 if (prev < subject_length) { |
4090 builder.EnsureCapacity(2); | 4090 builder.EnsureCapacity(2); |
4091 builder.AddSubjectSlice(prev, subject_length); | 4091 builder.AddSubjectSlice(prev, subject_length); |
4092 } | 4092 } |
4093 | 4093 |
4094 RegExpImpl::SetLastMatchInfo(last_match_info, | 4094 RegExpImpl::SetLastMatchInfo(last_match_info, |
4095 subject, | 4095 subject, |
4096 capture_count, | 4096 capture_count, |
4097 global_cache.LastSuccessfulMatch()); | 4097 global_cache.LastSuccessfulMatch()); |
4098 | 4098 |
4099 Handle<String> result; | 4099 Handle<String> result; |
4100 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, builder.ToString()); | 4100 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, builder.ToString()); |
4101 return *result; | 4101 return *result; |
4102 } | 4102 } |
4103 | 4103 |
4104 | 4104 |
4105 template <typename ResultSeqString> | 4105 template <typename ResultSeqString> |
4106 MUST_USE_RESULT static MaybeObject* StringReplaceGlobalRegExpWithEmptyString( | 4106 MUST_USE_RESULT static Object* StringReplaceGlobalRegExpWithEmptyString( |
4107 Isolate* isolate, | 4107 Isolate* isolate, |
4108 Handle<String> subject, | 4108 Handle<String> subject, |
4109 Handle<JSRegExp> regexp, | 4109 Handle<JSRegExp> regexp, |
4110 Handle<JSArray> last_match_info) { | 4110 Handle<JSArray> last_match_info) { |
4111 ASSERT(subject->IsFlat()); | 4111 ASSERT(subject->IsFlat()); |
4112 | 4112 |
4113 // Shortcut for simple non-regexp global replacements | 4113 // Shortcut for simple non-regexp global replacements |
4114 if (regexp->TypeTag() == JSRegExp::ATOM) { | 4114 if (regexp->TypeTag() == JSRegExp::ATOM) { |
4115 Handle<String> empty_string = isolate->factory()->empty_string(); | 4115 Handle<String> empty_string = isolate->factory()->empty_string(); |
4116 if (subject->IsOneByteRepresentation()) { | 4116 if (subject->IsOneByteRepresentation()) { |
4117 return StringReplaceGlobalAtomRegExpWithString<SeqOneByteString>( | 4117 return StringReplaceGlobalAtomRegExpWithString<SeqOneByteString>( |
4118 isolate, subject, regexp, empty_string, last_match_info); | 4118 isolate, subject, regexp, empty_string, last_match_info); |
4119 } else { | 4119 } else { |
4120 return StringReplaceGlobalAtomRegExpWithString<SeqTwoByteString>( | 4120 return StringReplaceGlobalAtomRegExpWithString<SeqTwoByteString>( |
4121 isolate, subject, regexp, empty_string, last_match_info); | 4121 isolate, subject, regexp, empty_string, last_match_info); |
4122 } | 4122 } |
4123 } | 4123 } |
4124 | 4124 |
4125 RegExpImpl::GlobalCache global_cache(regexp, subject, true, isolate); | 4125 RegExpImpl::GlobalCache global_cache(regexp, subject, true, isolate); |
4126 if (global_cache.HasException()) return Failure::Exception(); | 4126 if (global_cache.HasException()) return isolate->heap()->exception(); |
4127 | 4127 |
4128 int32_t* current_match = global_cache.FetchNext(); | 4128 int32_t* current_match = global_cache.FetchNext(); |
4129 if (current_match == NULL) { | 4129 if (current_match == NULL) { |
4130 if (global_cache.HasException()) return Failure::Exception(); | 4130 if (global_cache.HasException()) return isolate->heap()->exception(); |
4131 return *subject; | 4131 return *subject; |
4132 } | 4132 } |
4133 | 4133 |
4134 int start = current_match[0]; | 4134 int start = current_match[0]; |
4135 int end = current_match[1]; | 4135 int end = current_match[1]; |
4136 int capture_count = regexp->CaptureCount(); | 4136 int capture_count = regexp->CaptureCount(); |
4137 int subject_length = subject->length(); | 4137 int subject_length = subject->length(); |
4138 | 4138 |
4139 int new_length = subject_length - (end - start); | 4139 int new_length = subject_length - (end - start); |
4140 if (new_length == 0) return isolate->heap()->empty_string(); | 4140 if (new_length == 0) return isolate->heap()->empty_string(); |
(...skipping 16 matching lines...) Expand all Loading... | |
4157 if (prev < start) { | 4157 if (prev < start) { |
4158 // Add substring subject[prev;start] to answer string. | 4158 // Add substring subject[prev;start] to answer string. |
4159 String::WriteToFlat(*subject, answer->GetChars() + position, prev, start); | 4159 String::WriteToFlat(*subject, answer->GetChars() + position, prev, start); |
4160 position += start - prev; | 4160 position += start - prev; |
4161 } | 4161 } |
4162 prev = end; | 4162 prev = end; |
4163 | 4163 |
4164 current_match = global_cache.FetchNext(); | 4164 current_match = global_cache.FetchNext(); |
4165 } while (current_match != NULL); | 4165 } while (current_match != NULL); |
4166 | 4166 |
4167 if (global_cache.HasException()) return Failure::Exception(); | 4167 if (global_cache.HasException()) return isolate->heap()->exception(); |
4168 | 4168 |
4169 RegExpImpl::SetLastMatchInfo(last_match_info, | 4169 RegExpImpl::SetLastMatchInfo(last_match_info, |
4170 subject, | 4170 subject, |
4171 capture_count, | 4171 capture_count, |
4172 global_cache.LastSuccessfulMatch()); | 4172 global_cache.LastSuccessfulMatch()); |
4173 | 4173 |
4174 if (prev < subject_length) { | 4174 if (prev < subject_length) { |
4175 // Add substring subject[prev;length] to answer string. | 4175 // Add substring subject[prev;length] to answer string. |
4176 String::WriteToFlat( | 4176 String::WriteToFlat( |
4177 *subject, answer->GetChars() + position, prev, subject_length); | 4177 *subject, answer->GetChars() + position, prev, subject_length); |
(...skipping 16 matching lines...) Expand all Loading... | |
4194 // The trimming is performed on a newly allocated object, which is on a | 4194 // The trimming is performed on a newly allocated object, which is on a |
4195 // fresly allocated page or on an already swept page. Hence, the sweeper | 4195 // fresly allocated page or on an already swept page. Hence, the sweeper |
4196 // thread can not get confused with the filler creation. No synchronization | 4196 // thread can not get confused with the filler creation. No synchronization |
4197 // needed. | 4197 // needed. |
4198 heap->CreateFillerObjectAt(end_of_string, delta); | 4198 heap->CreateFillerObjectAt(end_of_string, delta); |
4199 heap->AdjustLiveBytes(answer->address(), -delta, Heap::FROM_MUTATOR); | 4199 heap->AdjustLiveBytes(answer->address(), -delta, Heap::FROM_MUTATOR); |
4200 return *answer; | 4200 return *answer; |
4201 } | 4201 } |
4202 | 4202 |
4203 | 4203 |
4204 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringReplaceGlobalRegExpWithString) { | 4204 RUNTIME_FUNCTION(Object*, Runtime_StringReplaceGlobalRegExpWithString) { |
4205 HandleScope scope(isolate); | 4205 HandleScope scope(isolate); |
4206 ASSERT(args.length() == 4); | 4206 ASSERT(args.length() == 4); |
4207 | 4207 |
4208 CONVERT_ARG_HANDLE_CHECKED(String, subject, 0); | 4208 CONVERT_ARG_HANDLE_CHECKED(String, subject, 0); |
4209 CONVERT_ARG_HANDLE_CHECKED(String, replacement, 2); | 4209 CONVERT_ARG_HANDLE_CHECKED(String, replacement, 2); |
4210 CONVERT_ARG_HANDLE_CHECKED(JSRegExp, regexp, 1); | 4210 CONVERT_ARG_HANDLE_CHECKED(JSRegExp, regexp, 1); |
4211 CONVERT_ARG_HANDLE_CHECKED(JSArray, last_match_info, 3); | 4211 CONVERT_ARG_HANDLE_CHECKED(JSArray, last_match_info, 3); |
4212 | 4212 |
4213 ASSERT(regexp->GetFlags().is_global()); | 4213 ASSERT(regexp->GetFlags().is_global()); |
4214 | 4214 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4272 isolate, cons1, | 4272 isolate, cons1, |
4273 isolate->factory()->NewConsString(first, replace), | 4273 isolate->factory()->NewConsString(first, replace), |
4274 String); | 4274 String); |
4275 Handle<String> second = | 4275 Handle<String> second = |
4276 isolate->factory()->NewSubString(subject, index + 1, subject->length()); | 4276 isolate->factory()->NewSubString(subject, index + 1, subject->length()); |
4277 return isolate->factory()->NewConsString(cons1, second); | 4277 return isolate->factory()->NewConsString(cons1, second); |
4278 } | 4278 } |
4279 } | 4279 } |
4280 | 4280 |
4281 | 4281 |
4282 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringReplaceOneCharWithString) { | 4282 RUNTIME_FUNCTION(Object*, Runtime_StringReplaceOneCharWithString) { |
4283 HandleScope scope(isolate); | 4283 HandleScope scope(isolate); |
4284 ASSERT(args.length() == 3); | 4284 ASSERT(args.length() == 3); |
4285 CONVERT_ARG_HANDLE_CHECKED(String, subject, 0); | 4285 CONVERT_ARG_HANDLE_CHECKED(String, subject, 0); |
4286 CONVERT_ARG_HANDLE_CHECKED(String, search, 1); | 4286 CONVERT_ARG_HANDLE_CHECKED(String, search, 1); |
4287 CONVERT_ARG_HANDLE_CHECKED(String, replace, 2); | 4287 CONVERT_ARG_HANDLE_CHECKED(String, replace, 2); |
4288 | 4288 |
4289 // If the cons string tree is too deep, we simply abort the recursion and | 4289 // If the cons string tree is too deep, we simply abort the recursion and |
4290 // retry with a flattened subject string. | 4290 // retry with a flattened subject string. |
4291 const int kRecursionLimit = 0x1000; | 4291 const int kRecursionLimit = 0x1000; |
4292 bool found = false; | 4292 bool found = false; |
4293 Handle<String> result; | 4293 Handle<String> result; |
4294 if (StringReplaceOneCharWithString( | 4294 if (StringReplaceOneCharWithString( |
4295 isolate, subject, search, replace, &found, kRecursionLimit) | 4295 isolate, subject, search, replace, &found, kRecursionLimit) |
4296 .ToHandle(&result)) { | 4296 .ToHandle(&result)) { |
4297 return *result; | 4297 return *result; |
4298 } | 4298 } |
4299 if (isolate->has_pending_exception()) return Failure::Exception(); | 4299 if (isolate->has_pending_exception()) return isolate->heap()->exception(); |
4300 | 4300 |
4301 subject = String::Flatten(subject); | 4301 subject = String::Flatten(subject); |
4302 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 4302 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
4303 isolate, result, | 4303 isolate, result, |
4304 StringReplaceOneCharWithString( | 4304 StringReplaceOneCharWithString( |
4305 isolate, subject, search, replace, &found, kRecursionLimit)); | 4305 isolate, subject, search, replace, &found, kRecursionLimit)); |
4306 return *result; | 4306 return *result; |
4307 } | 4307 } |
4308 | 4308 |
4309 | 4309 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4352 pat_vector, | 4352 pat_vector, |
4353 start_index); | 4353 start_index); |
4354 } | 4354 } |
4355 return SearchString(isolate, | 4355 return SearchString(isolate, |
4356 seq_sub.ToUC16Vector(), | 4356 seq_sub.ToUC16Vector(), |
4357 pat_vector, | 4357 pat_vector, |
4358 start_index); | 4358 start_index); |
4359 } | 4359 } |
4360 | 4360 |
4361 | 4361 |
4362 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringIndexOf) { | 4362 RUNTIME_FUNCTION(Object*, Runtime_StringIndexOf) { |
4363 HandleScope scope(isolate); | 4363 HandleScope scope(isolate); |
4364 ASSERT(args.length() == 3); | 4364 ASSERT(args.length() == 3); |
4365 | 4365 |
4366 CONVERT_ARG_HANDLE_CHECKED(String, sub, 0); | 4366 CONVERT_ARG_HANDLE_CHECKED(String, sub, 0); |
4367 CONVERT_ARG_HANDLE_CHECKED(String, pat, 1); | 4367 CONVERT_ARG_HANDLE_CHECKED(String, pat, 1); |
4368 CONVERT_ARG_HANDLE_CHECKED(Object, index, 2); | 4368 CONVERT_ARG_HANDLE_CHECKED(Object, index, 2); |
4369 | 4369 |
4370 uint32_t start_index; | 4370 uint32_t start_index; |
4371 if (!index->ToArrayIndex(&start_index)) return Smi::FromInt(-1); | 4371 if (!index->ToArrayIndex(&start_index)) return Smi::FromInt(-1); |
4372 | 4372 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4404 j++; | 4404 j++; |
4405 } | 4405 } |
4406 if (j == pattern_length) { | 4406 if (j == pattern_length) { |
4407 return i; | 4407 return i; |
4408 } | 4408 } |
4409 } | 4409 } |
4410 return -1; | 4410 return -1; |
4411 } | 4411 } |
4412 | 4412 |
4413 | 4413 |
4414 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringLastIndexOf) { | 4414 RUNTIME_FUNCTION(Object*, Runtime_StringLastIndexOf) { |
4415 HandleScope scope(isolate); | 4415 HandleScope scope(isolate); |
4416 ASSERT(args.length() == 3); | 4416 ASSERT(args.length() == 3); |
4417 | 4417 |
4418 CONVERT_ARG_HANDLE_CHECKED(String, sub, 0); | 4418 CONVERT_ARG_HANDLE_CHECKED(String, sub, 0); |
4419 CONVERT_ARG_HANDLE_CHECKED(String, pat, 1); | 4419 CONVERT_ARG_HANDLE_CHECKED(String, pat, 1); |
4420 CONVERT_ARG_HANDLE_CHECKED(Object, index, 2); | 4420 CONVERT_ARG_HANDLE_CHECKED(Object, index, 2); |
4421 | 4421 |
4422 uint32_t start_index; | 4422 uint32_t start_index; |
4423 if (!index->ToArrayIndex(&start_index)) return Smi::FromInt(-1); | 4423 if (!index->ToArrayIndex(&start_index)) return Smi::FromInt(-1); |
4424 | 4424 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4463 position = StringMatchBackwards(sub_content.ToUC16Vector(), | 4463 position = StringMatchBackwards(sub_content.ToUC16Vector(), |
4464 pat_vector, | 4464 pat_vector, |
4465 start_index); | 4465 start_index); |
4466 } | 4466 } |
4467 } | 4467 } |
4468 | 4468 |
4469 return Smi::FromInt(position); | 4469 return Smi::FromInt(position); |
4470 } | 4470 } |
4471 | 4471 |
4472 | 4472 |
4473 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringLocaleCompare) { | 4473 RUNTIME_FUNCTION(Object*, Runtime_StringLocaleCompare) { |
4474 HandleScope handle_scope(isolate); | 4474 HandleScope handle_scope(isolate); |
4475 ASSERT(args.length() == 2); | 4475 ASSERT(args.length() == 2); |
4476 | 4476 |
4477 CONVERT_ARG_HANDLE_CHECKED(String, str1, 0); | 4477 CONVERT_ARG_HANDLE_CHECKED(String, str1, 0); |
4478 CONVERT_ARG_HANDLE_CHECKED(String, str2, 1); | 4478 CONVERT_ARG_HANDLE_CHECKED(String, str2, 1); |
4479 | 4479 |
4480 if (str1.is_identical_to(str2)) return Smi::FromInt(0); // Equal. | 4480 if (str1.is_identical_to(str2)) return Smi::FromInt(0); // Equal. |
4481 int str1_length = str1->length(); | 4481 int str1_length = str1->length(); |
4482 int str2_length = str2->length(); | 4482 int str2_length = str2->length(); |
4483 | 4483 |
(...skipping 23 matching lines...) Expand all Loading... | |
4507 for (int i = 0; i < end; i++) { | 4507 for (int i = 0; i < end; i++) { |
4508 if (flat1.Get(i) != flat2.Get(i)) { | 4508 if (flat1.Get(i) != flat2.Get(i)) { |
4509 return Smi::FromInt(flat1.Get(i) - flat2.Get(i)); | 4509 return Smi::FromInt(flat1.Get(i) - flat2.Get(i)); |
4510 } | 4510 } |
4511 } | 4511 } |
4512 | 4512 |
4513 return Smi::FromInt(str1_length - str2_length); | 4513 return Smi::FromInt(str1_length - str2_length); |
4514 } | 4514 } |
4515 | 4515 |
4516 | 4516 |
4517 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_SubString) { | 4517 RUNTIME_FUNCTION(Object*, RuntimeHidden_SubString) { |
4518 HandleScope scope(isolate); | 4518 HandleScope scope(isolate); |
4519 ASSERT(args.length() == 3); | 4519 ASSERT(args.length() == 3); |
4520 | 4520 |
4521 CONVERT_ARG_HANDLE_CHECKED(String, string, 0); | 4521 CONVERT_ARG_HANDLE_CHECKED(String, string, 0); |
4522 int start, end; | 4522 int start, end; |
4523 // We have a fast integer-only case here to avoid a conversion to double in | 4523 // We have a fast integer-only case here to avoid a conversion to double in |
4524 // the common case where from and to are Smis. | 4524 // the common case where from and to are Smis. |
4525 if (args[1]->IsSmi() && args[2]->IsSmi()) { | 4525 if (args[1]->IsSmi() && args[2]->IsSmi()) { |
4526 CONVERT_SMI_ARG_CHECKED(from_number, 1); | 4526 CONVERT_SMI_ARG_CHECKED(from_number, 1); |
4527 CONVERT_SMI_ARG_CHECKED(to_number, 2); | 4527 CONVERT_SMI_ARG_CHECKED(to_number, 2); |
4528 start = from_number; | 4528 start = from_number; |
4529 end = to_number; | 4529 end = to_number; |
4530 } else { | 4530 } else { |
4531 CONVERT_DOUBLE_ARG_CHECKED(from_number, 1); | 4531 CONVERT_DOUBLE_ARG_CHECKED(from_number, 1); |
4532 CONVERT_DOUBLE_ARG_CHECKED(to_number, 2); | 4532 CONVERT_DOUBLE_ARG_CHECKED(to_number, 2); |
4533 start = FastD2IChecked(from_number); | 4533 start = FastD2IChecked(from_number); |
4534 end = FastD2IChecked(to_number); | 4534 end = FastD2IChecked(to_number); |
4535 } | 4535 } |
4536 RUNTIME_ASSERT(end >= start); | 4536 RUNTIME_ASSERT(end >= start); |
4537 RUNTIME_ASSERT(start >= 0); | 4537 RUNTIME_ASSERT(start >= 0); |
4538 RUNTIME_ASSERT(end <= string->length()); | 4538 RUNTIME_ASSERT(end <= string->length()); |
4539 isolate->counters()->sub_string_runtime()->Increment(); | 4539 isolate->counters()->sub_string_runtime()->Increment(); |
4540 | 4540 |
4541 return *isolate->factory()->NewSubString(string, start, end); | 4541 return *isolate->factory()->NewSubString(string, start, end); |
4542 } | 4542 } |
4543 | 4543 |
4544 | 4544 |
4545 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringMatch) { | 4545 RUNTIME_FUNCTION(Object*, Runtime_StringMatch) { |
4546 HandleScope handles(isolate); | 4546 HandleScope handles(isolate); |
4547 ASSERT(args.length() == 3); | 4547 ASSERT(args.length() == 3); |
4548 | 4548 |
4549 CONVERT_ARG_HANDLE_CHECKED(String, subject, 0); | 4549 CONVERT_ARG_HANDLE_CHECKED(String, subject, 0); |
4550 CONVERT_ARG_HANDLE_CHECKED(JSRegExp, regexp, 1); | 4550 CONVERT_ARG_HANDLE_CHECKED(JSRegExp, regexp, 1); |
4551 CONVERT_ARG_HANDLE_CHECKED(JSArray, regexp_info, 2); | 4551 CONVERT_ARG_HANDLE_CHECKED(JSArray, regexp_info, 2); |
4552 | 4552 |
4553 RegExpImpl::GlobalCache global_cache(regexp, subject, true, isolate); | 4553 RegExpImpl::GlobalCache global_cache(regexp, subject, true, isolate); |
4554 if (global_cache.HasException()) return Failure::Exception(); | 4554 if (global_cache.HasException()) return isolate->heap()->exception(); |
4555 | 4555 |
4556 int capture_count = regexp->CaptureCount(); | 4556 int capture_count = regexp->CaptureCount(); |
4557 | 4557 |
4558 ZoneScope zone_scope(isolate->runtime_zone()); | 4558 ZoneScope zone_scope(isolate->runtime_zone()); |
4559 ZoneList<int> offsets(8, zone_scope.zone()); | 4559 ZoneList<int> offsets(8, zone_scope.zone()); |
4560 | 4560 |
4561 while (true) { | 4561 while (true) { |
4562 int32_t* match = global_cache.FetchNext(); | 4562 int32_t* match = global_cache.FetchNext(); |
4563 if (match == NULL) break; | 4563 if (match == NULL) break; |
4564 offsets.Add(match[0], zone_scope.zone()); // start | 4564 offsets.Add(match[0], zone_scope.zone()); // start |
4565 offsets.Add(match[1], zone_scope.zone()); // end | 4565 offsets.Add(match[1], zone_scope.zone()); // end |
4566 } | 4566 } |
4567 | 4567 |
4568 if (global_cache.HasException()) return Failure::Exception(); | 4568 if (global_cache.HasException()) return isolate->heap()->exception(); |
4569 | 4569 |
4570 if (offsets.length() == 0) { | 4570 if (offsets.length() == 0) { |
4571 // Not a single match. | 4571 // Not a single match. |
4572 return isolate->heap()->null_value(); | 4572 return isolate->heap()->null_value(); |
4573 } | 4573 } |
4574 | 4574 |
4575 RegExpImpl::SetLastMatchInfo(regexp_info, | 4575 RegExpImpl::SetLastMatchInfo(regexp_info, |
4576 subject, | 4576 subject, |
4577 capture_count, | 4577 capture_count, |
4578 global_cache.LastSuccessfulMatch()); | 4578 global_cache.LastSuccessfulMatch()); |
(...skipping 13 matching lines...) Expand all Loading... | |
4592 } | 4592 } |
4593 Handle<JSArray> result = isolate->factory()->NewJSArrayWithElements(elements); | 4593 Handle<JSArray> result = isolate->factory()->NewJSArrayWithElements(elements); |
4594 result->set_length(Smi::FromInt(matches)); | 4594 result->set_length(Smi::FromInt(matches)); |
4595 return *result; | 4595 return *result; |
4596 } | 4596 } |
4597 | 4597 |
4598 | 4598 |
4599 // Only called from Runtime_RegExpExecMultiple so it doesn't need to maintain | 4599 // Only called from Runtime_RegExpExecMultiple so it doesn't need to maintain |
4600 // separate last match info. See comment on that function. | 4600 // separate last match info. See comment on that function. |
4601 template<bool has_capture> | 4601 template<bool has_capture> |
4602 static MaybeObject* SearchRegExpMultiple( | 4602 static Object* SearchRegExpMultiple( |
4603 Isolate* isolate, | 4603 Isolate* isolate, |
4604 Handle<String> subject, | 4604 Handle<String> subject, |
4605 Handle<JSRegExp> regexp, | 4605 Handle<JSRegExp> regexp, |
4606 Handle<JSArray> last_match_array, | 4606 Handle<JSArray> last_match_array, |
4607 Handle<JSArray> result_array) { | 4607 Handle<JSArray> result_array) { |
4608 ASSERT(subject->IsFlat()); | 4608 ASSERT(subject->IsFlat()); |
4609 ASSERT_NE(has_capture, regexp->CaptureCount() == 0); | 4609 ASSERT_NE(has_capture, regexp->CaptureCount() == 0); |
4610 | 4610 |
4611 int capture_count = regexp->CaptureCount(); | 4611 int capture_count = regexp->CaptureCount(); |
4612 int subject_length = subject->length(); | 4612 int subject_length = subject->length(); |
(...skipping 17 matching lines...) Expand all Loading... | |
4630 cached_fixed_array->get(cached_fixed_array->length() - 1); | 4630 cached_fixed_array->get(cached_fixed_array->length() - 1); |
4631 Smi* js_array_length = Smi::cast(cached_fixed_array_last_element); | 4631 Smi* js_array_length = Smi::cast(cached_fixed_array_last_element); |
4632 result_array->set_length(js_array_length); | 4632 result_array->set_length(js_array_length); |
4633 RegExpImpl::SetLastMatchInfo( | 4633 RegExpImpl::SetLastMatchInfo( |
4634 last_match_array, subject, capture_count, NULL); | 4634 last_match_array, subject, capture_count, NULL); |
4635 return *result_array; | 4635 return *result_array; |
4636 } | 4636 } |
4637 } | 4637 } |
4638 | 4638 |
4639 RegExpImpl::GlobalCache global_cache(regexp, subject, true, isolate); | 4639 RegExpImpl::GlobalCache global_cache(regexp, subject, true, isolate); |
4640 if (global_cache.HasException()) return Failure::Exception(); | 4640 if (global_cache.HasException()) return isolate->heap()->exception(); |
4641 | 4641 |
4642 Handle<FixedArray> result_elements; | 4642 Handle<FixedArray> result_elements; |
4643 if (result_array->HasFastObjectElements()) { | 4643 if (result_array->HasFastObjectElements()) { |
4644 result_elements = | 4644 result_elements = |
4645 Handle<FixedArray>(FixedArray::cast(result_array->elements())); | 4645 Handle<FixedArray>(FixedArray::cast(result_array->elements())); |
4646 } | 4646 } |
4647 if (result_elements.is_null() || result_elements->length() < 16) { | 4647 if (result_elements.is_null() || result_elements->length() < 16) { |
4648 result_elements = isolate->factory()->NewFixedArrayWithHoles(16); | 4648 result_elements = isolate->factory()->NewFixedArrayWithHoles(16); |
4649 } | 4649 } |
4650 | 4650 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4706 } | 4706 } |
4707 elements->set(capture_count + 1, Smi::FromInt(match_start)); | 4707 elements->set(capture_count + 1, Smi::FromInt(match_start)); |
4708 elements->set(capture_count + 2, *subject); | 4708 elements->set(capture_count + 2, *subject); |
4709 builder.Add(*isolate->factory()->NewJSArrayWithElements(elements)); | 4709 builder.Add(*isolate->factory()->NewJSArrayWithElements(elements)); |
4710 } else { | 4710 } else { |
4711 builder.Add(*match); | 4711 builder.Add(*match); |
4712 } | 4712 } |
4713 } | 4713 } |
4714 } | 4714 } |
4715 | 4715 |
4716 if (global_cache.HasException()) return Failure::Exception(); | 4716 if (global_cache.HasException()) return isolate->heap()->exception(); |
4717 | 4717 |
4718 if (match_start >= 0) { | 4718 if (match_start >= 0) { |
4719 // Finished matching, with at least one match. | 4719 // Finished matching, with at least one match. |
4720 if (match_end < subject_length) { | 4720 if (match_end < subject_length) { |
4721 ReplacementStringBuilder::AddSubjectSlice(&builder, | 4721 ReplacementStringBuilder::AddSubjectSlice(&builder, |
4722 match_end, | 4722 match_end, |
4723 subject_length); | 4723 subject_length); |
4724 } | 4724 } |
4725 | 4725 |
4726 RegExpImpl::SetLastMatchInfo( | 4726 RegExpImpl::SetLastMatchInfo( |
(...skipping 16 matching lines...) Expand all Loading... | |
4743 return *builder.ToJSArray(result_array); | 4743 return *builder.ToJSArray(result_array); |
4744 } else { | 4744 } else { |
4745 return isolate->heap()->null_value(); // No matches at all. | 4745 return isolate->heap()->null_value(); // No matches at all. |
4746 } | 4746 } |
4747 } | 4747 } |
4748 | 4748 |
4749 | 4749 |
4750 // This is only called for StringReplaceGlobalRegExpWithFunction. This sets | 4750 // This is only called for StringReplaceGlobalRegExpWithFunction. This sets |
4751 // lastMatchInfoOverride to maintain the last match info, so we don't need to | 4751 // lastMatchInfoOverride to maintain the last match info, so we don't need to |
4752 // set any other last match array info. | 4752 // set any other last match array info. |
4753 RUNTIME_FUNCTION(MaybeObject*, Runtime_RegExpExecMultiple) { | 4753 RUNTIME_FUNCTION(Object*, Runtime_RegExpExecMultiple) { |
4754 HandleScope handles(isolate); | 4754 HandleScope handles(isolate); |
4755 ASSERT(args.length() == 4); | 4755 ASSERT(args.length() == 4); |
4756 | 4756 |
4757 CONVERT_ARG_HANDLE_CHECKED(String, subject, 1); | 4757 CONVERT_ARG_HANDLE_CHECKED(String, subject, 1); |
4758 CONVERT_ARG_HANDLE_CHECKED(JSRegExp, regexp, 0); | 4758 CONVERT_ARG_HANDLE_CHECKED(JSRegExp, regexp, 0); |
4759 CONVERT_ARG_HANDLE_CHECKED(JSArray, last_match_info, 2); | 4759 CONVERT_ARG_HANDLE_CHECKED(JSArray, last_match_info, 2); |
4760 CONVERT_ARG_HANDLE_CHECKED(JSArray, result_array, 3); | 4760 CONVERT_ARG_HANDLE_CHECKED(JSArray, result_array, 3); |
4761 | 4761 |
4762 subject = String::Flatten(subject); | 4762 subject = String::Flatten(subject); |
4763 ASSERT(regexp->GetFlags().is_global()); | 4763 ASSERT(regexp->GetFlags().is_global()); |
4764 | 4764 |
4765 if (regexp->CaptureCount() == 0) { | 4765 if (regexp->CaptureCount() == 0) { |
4766 return SearchRegExpMultiple<false>( | 4766 return SearchRegExpMultiple<false>( |
4767 isolate, subject, regexp, last_match_info, result_array); | 4767 isolate, subject, regexp, last_match_info, result_array); |
4768 } else { | 4768 } else { |
4769 return SearchRegExpMultiple<true>( | 4769 return SearchRegExpMultiple<true>( |
4770 isolate, subject, regexp, last_match_info, result_array); | 4770 isolate, subject, regexp, last_match_info, result_array); |
4771 } | 4771 } |
4772 } | 4772 } |
4773 | 4773 |
4774 | 4774 |
4775 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToRadixString) { | 4775 RUNTIME_FUNCTION(Object*, Runtime_NumberToRadixString) { |
4776 HandleScope scope(isolate); | 4776 HandleScope scope(isolate); |
4777 ASSERT(args.length() == 2); | 4777 ASSERT(args.length() == 2); |
4778 CONVERT_SMI_ARG_CHECKED(radix, 1); | 4778 CONVERT_SMI_ARG_CHECKED(radix, 1); |
4779 RUNTIME_ASSERT(2 <= radix && radix <= 36); | 4779 RUNTIME_ASSERT(2 <= radix && radix <= 36); |
4780 | 4780 |
4781 // Fast case where the result is a one character string. | 4781 // Fast case where the result is a one character string. |
4782 if (args[0]->IsSmi()) { | 4782 if (args[0]->IsSmi()) { |
4783 int value = args.smi_at(0); | 4783 int value = args.smi_at(0); |
4784 if (value >= 0 && value < radix) { | 4784 if (value >= 0 && value < radix) { |
4785 // Character array used for conversion. | 4785 // Character array used for conversion. |
(...skipping 14 matching lines...) Expand all Loading... | |
4800 } | 4800 } |
4801 return isolate->heap()->infinity_string(); | 4801 return isolate->heap()->infinity_string(); |
4802 } | 4802 } |
4803 char* str = DoubleToRadixCString(value, radix); | 4803 char* str = DoubleToRadixCString(value, radix); |
4804 Handle<String> result = isolate->factory()->NewStringFromAsciiChecked(str); | 4804 Handle<String> result = isolate->factory()->NewStringFromAsciiChecked(str); |
4805 DeleteArray(str); | 4805 DeleteArray(str); |
4806 return *result; | 4806 return *result; |
4807 } | 4807 } |
4808 | 4808 |
4809 | 4809 |
4810 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToFixed) { | 4810 RUNTIME_FUNCTION(Object*, Runtime_NumberToFixed) { |
4811 HandleScope scope(isolate); | 4811 HandleScope scope(isolate); |
4812 ASSERT(args.length() == 2); | 4812 ASSERT(args.length() == 2); |
4813 | 4813 |
4814 CONVERT_DOUBLE_ARG_CHECKED(value, 0); | 4814 CONVERT_DOUBLE_ARG_CHECKED(value, 0); |
4815 CONVERT_DOUBLE_ARG_CHECKED(f_number, 1); | 4815 CONVERT_DOUBLE_ARG_CHECKED(f_number, 1); |
4816 int f = FastD2IChecked(f_number); | 4816 int f = FastD2IChecked(f_number); |
4817 RUNTIME_ASSERT(f >= 0); | 4817 RUNTIME_ASSERT(f >= 0); |
4818 char* str = DoubleToFixedCString(value, f); | 4818 char* str = DoubleToFixedCString(value, f); |
4819 Handle<String> result = isolate->factory()->NewStringFromAsciiChecked(str); | 4819 Handle<String> result = isolate->factory()->NewStringFromAsciiChecked(str); |
4820 DeleteArray(str); | 4820 DeleteArray(str); |
4821 return *result; | 4821 return *result; |
4822 } | 4822 } |
4823 | 4823 |
4824 | 4824 |
4825 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToExponential) { | 4825 RUNTIME_FUNCTION(Object*, Runtime_NumberToExponential) { |
4826 HandleScope scope(isolate); | 4826 HandleScope scope(isolate); |
4827 ASSERT(args.length() == 2); | 4827 ASSERT(args.length() == 2); |
4828 | 4828 |
4829 CONVERT_DOUBLE_ARG_CHECKED(value, 0); | 4829 CONVERT_DOUBLE_ARG_CHECKED(value, 0); |
4830 CONVERT_DOUBLE_ARG_CHECKED(f_number, 1); | 4830 CONVERT_DOUBLE_ARG_CHECKED(f_number, 1); |
4831 int f = FastD2IChecked(f_number); | 4831 int f = FastD2IChecked(f_number); |
4832 RUNTIME_ASSERT(f >= -1 && f <= 20); | 4832 RUNTIME_ASSERT(f >= -1 && f <= 20); |
4833 char* str = DoubleToExponentialCString(value, f); | 4833 char* str = DoubleToExponentialCString(value, f); |
4834 Handle<String> result = isolate->factory()->NewStringFromAsciiChecked(str); | 4834 Handle<String> result = isolate->factory()->NewStringFromAsciiChecked(str); |
4835 DeleteArray(str); | 4835 DeleteArray(str); |
4836 return *result; | 4836 return *result; |
4837 } | 4837 } |
4838 | 4838 |
4839 | 4839 |
4840 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToPrecision) { | 4840 RUNTIME_FUNCTION(Object*, Runtime_NumberToPrecision) { |
4841 HandleScope scope(isolate); | 4841 HandleScope scope(isolate); |
4842 ASSERT(args.length() == 2); | 4842 ASSERT(args.length() == 2); |
4843 | 4843 |
4844 CONVERT_DOUBLE_ARG_CHECKED(value, 0); | 4844 CONVERT_DOUBLE_ARG_CHECKED(value, 0); |
4845 CONVERT_DOUBLE_ARG_CHECKED(f_number, 1); | 4845 CONVERT_DOUBLE_ARG_CHECKED(f_number, 1); |
4846 int f = FastD2IChecked(f_number); | 4846 int f = FastD2IChecked(f_number); |
4847 RUNTIME_ASSERT(f >= 1 && f <= 21); | 4847 RUNTIME_ASSERT(f >= 1 && f <= 21); |
4848 char* str = DoubleToPrecisionCString(value, f); | 4848 char* str = DoubleToPrecisionCString(value, f); |
4849 Handle<String> result = isolate->factory()->NewStringFromAsciiChecked(str); | 4849 Handle<String> result = isolate->factory()->NewStringFromAsciiChecked(str); |
4850 DeleteArray(str); | 4850 DeleteArray(str); |
4851 return *result; | 4851 return *result; |
4852 } | 4852 } |
4853 | 4853 |
4854 | 4854 |
4855 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsValidSmi) { | 4855 RUNTIME_FUNCTION(Object*, Runtime_IsValidSmi) { |
4856 SealHandleScope shs(isolate); | 4856 SealHandleScope shs(isolate); |
4857 ASSERT(args.length() == 1); | 4857 ASSERT(args.length() == 1); |
4858 | 4858 |
4859 CONVERT_NUMBER_CHECKED(int32_t, number, Int32, args[0]); | 4859 CONVERT_NUMBER_CHECKED(int32_t, number, Int32, args[0]); |
4860 return isolate->heap()->ToBoolean(Smi::IsValid(number)); | 4860 return isolate->heap()->ToBoolean(Smi::IsValid(number)); |
4861 } | 4861 } |
4862 | 4862 |
4863 | 4863 |
4864 // Returns a single character string where first character equals | 4864 // Returns a single character string where first character equals |
4865 // string->Get(index). | 4865 // string->Get(index). |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4953 // Check if the name is trivially convertible to an index and get | 4953 // Check if the name is trivially convertible to an index and get |
4954 // the element if so. | 4954 // the element if so. |
4955 if (name->AsArrayIndex(&index)) { | 4955 if (name->AsArrayIndex(&index)) { |
4956 return GetElementOrCharAt(isolate, object, index); | 4956 return GetElementOrCharAt(isolate, object, index); |
4957 } else { | 4957 } else { |
4958 return Object::GetProperty(object, name); | 4958 return Object::GetProperty(object, name); |
4959 } | 4959 } |
4960 } | 4960 } |
4961 | 4961 |
4962 | 4962 |
4963 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetProperty) { | 4963 RUNTIME_FUNCTION(Object*, Runtime_GetProperty) { |
4964 HandleScope scope(isolate); | 4964 HandleScope scope(isolate); |
4965 ASSERT(args.length() == 2); | 4965 ASSERT(args.length() == 2); |
4966 | 4966 |
4967 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); | 4967 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); |
4968 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); | 4968 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); |
4969 Handle<Object> result; | 4969 Handle<Object> result; |
4970 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 4970 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
4971 isolate, result, | 4971 isolate, result, |
4972 Runtime::GetObjectProperty(isolate, object, key)); | 4972 Runtime::GetObjectProperty(isolate, object, key)); |
4973 return *result; | 4973 return *result; |
4974 } | 4974 } |
4975 | 4975 |
4976 | 4976 |
4977 // KeyedGetProperty is called from KeyedLoadIC::GenerateGeneric. | 4977 // KeyedGetProperty is called from KeyedLoadIC::GenerateGeneric. |
4978 RUNTIME_FUNCTION(MaybeObject*, Runtime_KeyedGetProperty) { | 4978 RUNTIME_FUNCTION(Object*, Runtime_KeyedGetProperty) { |
4979 SealHandleScope shs(isolate); | 4979 SealHandleScope shs(isolate); |
4980 ASSERT(args.length() == 2); | 4980 ASSERT(args.length() == 2); |
4981 | 4981 |
4982 // Fast cases for getting named properties of the receiver JSObject | 4982 // Fast cases for getting named properties of the receiver JSObject |
4983 // itself. | 4983 // itself. |
4984 // | 4984 // |
4985 // The global proxy objects has to be excluded since LocalLookup on | 4985 // The global proxy objects has to be excluded since LocalLookup on |
4986 // the global proxy object can return a valid result even though the | 4986 // the global proxy object can return a valid result even though the |
4987 // global proxy object never has properties. This is the case | 4987 // global proxy object never has properties. This is the case |
4988 // because the global proxy object forwards everything to its hidden | 4988 // because the global proxy object forwards everything to its hidden |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5085 return obj->IsUndefined() || obj->IsSpecFunction() || obj->IsNull(); | 5085 return obj->IsUndefined() || obj->IsSpecFunction() || obj->IsNull(); |
5086 } | 5086 } |
5087 | 5087 |
5088 | 5088 |
5089 // Implements part of 8.12.9 DefineOwnProperty. | 5089 // Implements part of 8.12.9 DefineOwnProperty. |
5090 // There are 3 cases that lead here: | 5090 // There are 3 cases that lead here: |
5091 // Step 4b - define a new accessor property. | 5091 // Step 4b - define a new accessor property. |
5092 // Steps 9c & 12 - replace an existing data property with an accessor property. | 5092 // Steps 9c & 12 - replace an existing data property with an accessor property. |
5093 // Step 12 - update an existing accessor property with an accessor or generic | 5093 // Step 12 - update an existing accessor property with an accessor or generic |
5094 // descriptor. | 5094 // descriptor. |
5095 RUNTIME_FUNCTION(MaybeObject*, Runtime_DefineOrRedefineAccessorProperty) { | 5095 RUNTIME_FUNCTION(Object*, Runtime_DefineOrRedefineAccessorProperty) { |
5096 HandleScope scope(isolate); | 5096 HandleScope scope(isolate); |
5097 ASSERT(args.length() == 5); | 5097 ASSERT(args.length() == 5); |
5098 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); | 5098 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); |
5099 RUNTIME_ASSERT(!obj->IsNull()); | 5099 RUNTIME_ASSERT(!obj->IsNull()); |
5100 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); | 5100 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); |
5101 CONVERT_ARG_HANDLE_CHECKED(Object, getter, 2); | 5101 CONVERT_ARG_HANDLE_CHECKED(Object, getter, 2); |
5102 RUNTIME_ASSERT(IsValidAccessor(getter)); | 5102 RUNTIME_ASSERT(IsValidAccessor(getter)); |
5103 CONVERT_ARG_HANDLE_CHECKED(Object, setter, 3); | 5103 CONVERT_ARG_HANDLE_CHECKED(Object, setter, 3); |
5104 RUNTIME_ASSERT(IsValidAccessor(setter)); | 5104 RUNTIME_ASSERT(IsValidAccessor(setter)); |
5105 CONVERT_SMI_ARG_CHECKED(unchecked, 4); | 5105 CONVERT_SMI_ARG_CHECKED(unchecked, 4); |
5106 RUNTIME_ASSERT((unchecked & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0); | 5106 RUNTIME_ASSERT((unchecked & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0); |
5107 PropertyAttributes attr = static_cast<PropertyAttributes>(unchecked); | 5107 PropertyAttributes attr = static_cast<PropertyAttributes>(unchecked); |
5108 | 5108 |
5109 bool fast = obj->HasFastProperties(); | 5109 bool fast = obj->HasFastProperties(); |
5110 JSObject::DefineAccessor(obj, name, getter, setter, attr); | 5110 JSObject::DefineAccessor(obj, name, getter, setter, attr); |
5111 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); | 5111 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); |
5112 if (fast) JSObject::TransformToFastProperties(obj, 0); | 5112 if (fast) JSObject::TransformToFastProperties(obj, 0); |
5113 return isolate->heap()->undefined_value(); | 5113 return isolate->heap()->undefined_value(); |
5114 } | 5114 } |
5115 | 5115 |
5116 | 5116 |
5117 // Implements part of 8.12.9 DefineOwnProperty. | 5117 // Implements part of 8.12.9 DefineOwnProperty. |
5118 // There are 3 cases that lead here: | 5118 // There are 3 cases that lead here: |
5119 // Step 4a - define a new data property. | 5119 // Step 4a - define a new data property. |
5120 // Steps 9b & 12 - replace an existing accessor property with a data property. | 5120 // Steps 9b & 12 - replace an existing accessor property with a data property. |
5121 // Step 12 - update an existing data property with a data or generic | 5121 // Step 12 - update an existing data property with a data or generic |
5122 // descriptor. | 5122 // descriptor. |
5123 RUNTIME_FUNCTION(MaybeObject*, Runtime_DefineOrRedefineDataProperty) { | 5123 RUNTIME_FUNCTION(Object*, Runtime_DefineOrRedefineDataProperty) { |
5124 HandleScope scope(isolate); | 5124 HandleScope scope(isolate); |
5125 ASSERT(args.length() == 4); | 5125 ASSERT(args.length() == 4); |
5126 CONVERT_ARG_HANDLE_CHECKED(JSObject, js_object, 0); | 5126 CONVERT_ARG_HANDLE_CHECKED(JSObject, js_object, 0); |
5127 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); | 5127 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); |
5128 CONVERT_ARG_HANDLE_CHECKED(Object, obj_value, 2); | 5128 CONVERT_ARG_HANDLE_CHECKED(Object, obj_value, 2); |
5129 CONVERT_SMI_ARG_CHECKED(unchecked, 3); | 5129 CONVERT_SMI_ARG_CHECKED(unchecked, 3); |
5130 RUNTIME_ASSERT((unchecked & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0); | 5130 RUNTIME_ASSERT((unchecked & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0); |
5131 PropertyAttributes attr = static_cast<PropertyAttributes>(unchecked); | 5131 PropertyAttributes attr = static_cast<PropertyAttributes>(unchecked); |
5132 | 5132 |
5133 LookupResult lookup(isolate); | 5133 LookupResult lookup(isolate); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5187 | 5187 |
5188 Handle<Object> result; | 5188 Handle<Object> result; |
5189 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 5189 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
5190 isolate, result, | 5190 isolate, result, |
5191 Runtime::ForceSetObjectProperty(js_object, name, obj_value, attr)); | 5191 Runtime::ForceSetObjectProperty(js_object, name, obj_value, attr)); |
5192 return *result; | 5192 return *result; |
5193 } | 5193 } |
5194 | 5194 |
5195 | 5195 |
5196 // Return property without being observable by accessors or interceptors. | 5196 // Return property without being observable by accessors or interceptors. |
5197 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetDataProperty) { | 5197 RUNTIME_FUNCTION(Object*, Runtime_GetDataProperty) { |
5198 HandleScope scope(isolate); | 5198 HandleScope scope(isolate); |
5199 ASSERT(args.length() == 2); | 5199 ASSERT(args.length() == 2); |
5200 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); | 5200 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); |
5201 CONVERT_ARG_HANDLE_CHECKED(Name, key, 1); | 5201 CONVERT_ARG_HANDLE_CHECKED(Name, key, 1); |
5202 return *JSObject::GetDataProperty(object, key); | 5202 return *JSObject::GetDataProperty(object, key); |
5203 } | 5203 } |
5204 | 5204 |
5205 | 5205 |
5206 MaybeHandle<Object> Runtime::SetObjectProperty(Isolate* isolate, | 5206 MaybeHandle<Object> Runtime::SetObjectProperty(Isolate* isolate, |
5207 Handle<Object> object, | 5207 Handle<Object> object, |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5380 ASSIGN_RETURN_ON_EXCEPTION( | 5380 ASSIGN_RETURN_ON_EXCEPTION( |
5381 isolate, converted, Execution::ToString(isolate, key), Object); | 5381 isolate, converted, Execution::ToString(isolate, key), Object); |
5382 name = Handle<String>::cast(converted); | 5382 name = Handle<String>::cast(converted); |
5383 } | 5383 } |
5384 | 5384 |
5385 if (name->IsString()) name = String::Flatten(Handle<String>::cast(name)); | 5385 if (name->IsString()) name = String::Flatten(Handle<String>::cast(name)); |
5386 return JSReceiver::DeleteProperty(receiver, name, mode); | 5386 return JSReceiver::DeleteProperty(receiver, name, mode); |
5387 } | 5387 } |
5388 | 5388 |
5389 | 5389 |
5390 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetHiddenProperty) { | 5390 RUNTIME_FUNCTION(Object*, Runtime_SetHiddenProperty) { |
5391 HandleScope scope(isolate); | 5391 HandleScope scope(isolate); |
5392 RUNTIME_ASSERT(args.length() == 3); | 5392 RUNTIME_ASSERT(args.length() == 3); |
5393 | 5393 |
5394 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); | 5394 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); |
5395 CONVERT_ARG_HANDLE_CHECKED(String, key, 1); | 5395 CONVERT_ARG_HANDLE_CHECKED(String, key, 1); |
5396 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); | 5396 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); |
5397 return *JSObject::SetHiddenProperty(object, key, value); | 5397 return *JSObject::SetHiddenProperty(object, key, value); |
5398 } | 5398 } |
5399 | 5399 |
5400 | 5400 |
5401 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetProperty) { | 5401 RUNTIME_FUNCTION(Object*, Runtime_SetProperty) { |
5402 HandleScope scope(isolate); | 5402 HandleScope scope(isolate); |
5403 RUNTIME_ASSERT(args.length() == 4 || args.length() == 5); | 5403 RUNTIME_ASSERT(args.length() == 4 || args.length() == 5); |
5404 | 5404 |
5405 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); | 5405 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); |
5406 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); | 5406 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); |
5407 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); | 5407 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); |
5408 CONVERT_SMI_ARG_CHECKED(unchecked_attributes, 3); | 5408 CONVERT_SMI_ARG_CHECKED(unchecked_attributes, 3); |
5409 RUNTIME_ASSERT( | 5409 RUNTIME_ASSERT( |
5410 (unchecked_attributes & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0); | 5410 (unchecked_attributes & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0); |
5411 // Compute attributes. | 5411 // Compute attributes. |
5412 PropertyAttributes attributes = | 5412 PropertyAttributes attributes = |
5413 static_cast<PropertyAttributes>(unchecked_attributes); | 5413 static_cast<PropertyAttributes>(unchecked_attributes); |
5414 | 5414 |
5415 StrictMode strict_mode = SLOPPY; | 5415 StrictMode strict_mode = SLOPPY; |
5416 if (args.length() == 5) { | 5416 if (args.length() == 5) { |
5417 CONVERT_STRICT_MODE_ARG_CHECKED(strict_mode_arg, 4); | 5417 CONVERT_STRICT_MODE_ARG_CHECKED(strict_mode_arg, 4); |
5418 strict_mode = strict_mode_arg; | 5418 strict_mode = strict_mode_arg; |
5419 } | 5419 } |
5420 | 5420 |
5421 Handle<Object> result; | 5421 Handle<Object> result; |
5422 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 5422 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
5423 isolate, result, | 5423 isolate, result, |
5424 Runtime::SetObjectProperty( | 5424 Runtime::SetObjectProperty( |
5425 isolate, object, key, value, attributes, strict_mode)); | 5425 isolate, object, key, value, attributes, strict_mode)); |
5426 return *result; | 5426 return *result; |
5427 } | 5427 } |
5428 | 5428 |
5429 | 5429 |
5430 RUNTIME_FUNCTION(MaybeObject*, Runtime_TransitionElementsKind) { | 5430 RUNTIME_FUNCTION(Object*, Runtime_TransitionElementsKind) { |
5431 HandleScope scope(isolate); | 5431 HandleScope scope(isolate); |
5432 RUNTIME_ASSERT(args.length() == 2); | 5432 RUNTIME_ASSERT(args.length() == 2); |
5433 CONVERT_ARG_HANDLE_CHECKED(JSArray, array, 0); | 5433 CONVERT_ARG_HANDLE_CHECKED(JSArray, array, 0); |
5434 CONVERT_ARG_HANDLE_CHECKED(Map, map, 1); | 5434 CONVERT_ARG_HANDLE_CHECKED(Map, map, 1); |
5435 JSObject::TransitionElementsKind(array, map->elements_kind()); | 5435 JSObject::TransitionElementsKind(array, map->elements_kind()); |
5436 return *array; | 5436 return *array; |
5437 } | 5437 } |
5438 | 5438 |
5439 | 5439 |
5440 // Set the native flag on the function. | 5440 // Set the native flag on the function. |
5441 // This is used to decide if we should transform null and undefined | 5441 // This is used to decide if we should transform null and undefined |
5442 // into the global object when doing call and apply. | 5442 // into the global object when doing call and apply. |
5443 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetNativeFlag) { | 5443 RUNTIME_FUNCTION(Object*, Runtime_SetNativeFlag) { |
5444 SealHandleScope shs(isolate); | 5444 SealHandleScope shs(isolate); |
5445 RUNTIME_ASSERT(args.length() == 1); | 5445 RUNTIME_ASSERT(args.length() == 1); |
5446 | 5446 |
5447 CONVERT_ARG_CHECKED(Object, object, 0); | 5447 CONVERT_ARG_CHECKED(Object, object, 0); |
5448 | 5448 |
5449 if (object->IsJSFunction()) { | 5449 if (object->IsJSFunction()) { |
5450 JSFunction* func = JSFunction::cast(object); | 5450 JSFunction* func = JSFunction::cast(object); |
5451 func->shared()->set_native(true); | 5451 func->shared()->set_native(true); |
5452 } | 5452 } |
5453 return isolate->heap()->undefined_value(); | 5453 return isolate->heap()->undefined_value(); |
5454 } | 5454 } |
5455 | 5455 |
5456 | 5456 |
5457 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetInlineBuiltinFlag) { | 5457 RUNTIME_FUNCTION(Object*, Runtime_SetInlineBuiltinFlag) { |
5458 SealHandleScope shs(isolate); | 5458 SealHandleScope shs(isolate); |
5459 RUNTIME_ASSERT(args.length() == 1); | 5459 RUNTIME_ASSERT(args.length() == 1); |
5460 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); | 5460 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); |
5461 | 5461 |
5462 if (object->IsJSFunction()) { | 5462 if (object->IsJSFunction()) { |
5463 JSFunction* func = JSFunction::cast(*object); | 5463 JSFunction* func = JSFunction::cast(*object); |
5464 func->shared()->set_inline_builtin(true); | 5464 func->shared()->set_inline_builtin(true); |
5465 } | 5465 } |
5466 return isolate->heap()->undefined_value(); | 5466 return isolate->heap()->undefined_value(); |
5467 } | 5467 } |
5468 | 5468 |
5469 | 5469 |
5470 RUNTIME_FUNCTION(MaybeObject*, Runtime_StoreArrayLiteralElement) { | 5470 RUNTIME_FUNCTION(Object*, Runtime_StoreArrayLiteralElement) { |
5471 HandleScope scope(isolate); | 5471 HandleScope scope(isolate); |
5472 RUNTIME_ASSERT(args.length() == 5); | 5472 RUNTIME_ASSERT(args.length() == 5); |
5473 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); | 5473 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); |
5474 CONVERT_SMI_ARG_CHECKED(store_index, 1); | 5474 CONVERT_SMI_ARG_CHECKED(store_index, 1); |
5475 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); | 5475 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); |
5476 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 3); | 5476 CONVERT_ARG_HANDLE_CHECKED(FixedArray, literals, 3); |
5477 CONVERT_SMI_ARG_CHECKED(literal_index, 4); | 5477 CONVERT_SMI_ARG_CHECKED(literal_index, 4); |
5478 | 5478 |
5479 Object* raw_literal_cell = literals->get(literal_index); | 5479 Object* raw_literal_cell = literals->get(literal_index); |
5480 JSArray* boilerplate = NULL; | 5480 JSArray* boilerplate = NULL; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5519 } | 5519 } |
5520 FixedArray* object_array = FixedArray::cast(object->elements()); | 5520 FixedArray* object_array = FixedArray::cast(object->elements()); |
5521 object_array->set(store_index, *value); | 5521 object_array->set(store_index, *value); |
5522 } | 5522 } |
5523 return *object; | 5523 return *object; |
5524 } | 5524 } |
5525 | 5525 |
5526 | 5526 |
5527 // Check whether debugger and is about to step into the callback that is passed | 5527 // Check whether debugger and is about to step into the callback that is passed |
5528 // to a built-in function such as Array.forEach. | 5528 // to a built-in function such as Array.forEach. |
5529 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugCallbackSupportsStepping) { | 5529 RUNTIME_FUNCTION(Object*, Runtime_DebugCallbackSupportsStepping) { |
5530 SealHandleScope shs(isolate); | 5530 SealHandleScope shs(isolate); |
5531 #ifdef ENABLE_DEBUGGER_SUPPORT | 5531 #ifdef ENABLE_DEBUGGER_SUPPORT |
5532 ASSERT(args.length() == 1); | 5532 ASSERT(args.length() == 1); |
5533 if (!isolate->IsDebuggerActive() || !isolate->debug()->StepInActive()) { | 5533 if (!isolate->IsDebuggerActive() || !isolate->debug()->StepInActive()) { |
5534 return isolate->heap()->false_value(); | 5534 return isolate->heap()->false_value(); |
5535 } | 5535 } |
5536 CONVERT_ARG_CHECKED(Object, callback, 0); | 5536 CONVERT_ARG_CHECKED(Object, callback, 0); |
5537 // We do not step into the callback if it's a builtin or not even a function. | 5537 // We do not step into the callback if it's a builtin or not even a function. |
5538 return isolate->heap()->ToBoolean( | 5538 return isolate->heap()->ToBoolean( |
5539 callback->IsJSFunction() && !JSFunction::cast(callback)->IsBuiltin()); | 5539 callback->IsJSFunction() && !JSFunction::cast(callback)->IsBuiltin()); |
5540 #else | 5540 #else |
5541 return isolate->heap()->false_value(); | 5541 return isolate->heap()->false_value(); |
5542 #endif // ENABLE_DEBUGGER_SUPPORT | 5542 #endif // ENABLE_DEBUGGER_SUPPORT |
5543 } | 5543 } |
5544 | 5544 |
5545 | 5545 |
5546 // Set one shot breakpoints for the callback function that is passed to a | 5546 // Set one shot breakpoints for the callback function that is passed to a |
5547 // built-in function such as Array.forEach to enable stepping into the callback. | 5547 // built-in function such as Array.forEach to enable stepping into the callback. |
5548 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugPrepareStepInIfStepping) { | 5548 RUNTIME_FUNCTION(Object*, Runtime_DebugPrepareStepInIfStepping) { |
5549 SealHandleScope shs(isolate); | 5549 SealHandleScope shs(isolate); |
5550 #ifdef ENABLE_DEBUGGER_SUPPORT | 5550 #ifdef ENABLE_DEBUGGER_SUPPORT |
5551 ASSERT(args.length() == 1); | 5551 ASSERT(args.length() == 1); |
5552 Debug* debug = isolate->debug(); | 5552 Debug* debug = isolate->debug(); |
5553 if (!debug->IsStepping()) return isolate->heap()->undefined_value(); | 5553 if (!debug->IsStepping()) return isolate->heap()->undefined_value(); |
5554 CONVERT_ARG_HANDLE_CHECKED(JSFunction, callback, 0); | 5554 CONVERT_ARG_HANDLE_CHECKED(JSFunction, callback, 0); |
5555 HandleScope scope(isolate); | 5555 HandleScope scope(isolate); |
5556 // When leaving the callback, step out has been activated, but not performed | 5556 // When leaving the callback, step out has been activated, but not performed |
5557 // if we do not leave the builtin. To be able to step into the callback | 5557 // if we do not leave the builtin. To be able to step into the callback |
5558 // again, we need to clear the step out at this point. | 5558 // again, we need to clear the step out at this point. |
5559 debug->ClearStepOut(); | 5559 debug->ClearStepOut(); |
5560 debug->FloodWithOneShot(callback); | 5560 debug->FloodWithOneShot(callback); |
5561 #endif // ENABLE_DEBUGGER_SUPPORT | 5561 #endif // ENABLE_DEBUGGER_SUPPORT |
5562 return isolate->heap()->undefined_value(); | 5562 return isolate->heap()->undefined_value(); |
5563 } | 5563 } |
5564 | 5564 |
5565 | 5565 |
5566 // Set a local property, even if it is READ_ONLY. If the property does not | 5566 // Set a local property, even if it is READ_ONLY. If the property does not |
5567 // exist, it will be added with attributes NONE. | 5567 // exist, it will be added with attributes NONE. |
5568 RUNTIME_FUNCTION(MaybeObject*, Runtime_IgnoreAttributesAndSetProperty) { | 5568 RUNTIME_FUNCTION(Object*, Runtime_IgnoreAttributesAndSetProperty) { |
5569 HandleScope scope(isolate); | 5569 HandleScope scope(isolate); |
5570 RUNTIME_ASSERT(args.length() == 3 || args.length() == 4); | 5570 RUNTIME_ASSERT(args.length() == 3 || args.length() == 4); |
5571 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); | 5571 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); |
5572 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); | 5572 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); |
5573 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); | 5573 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); |
5574 // Compute attributes. | 5574 // Compute attributes. |
5575 PropertyAttributes attributes = NONE; | 5575 PropertyAttributes attributes = NONE; |
5576 if (args.length() == 4) { | 5576 if (args.length() == 4) { |
5577 CONVERT_SMI_ARG_CHECKED(unchecked_value, 3); | 5577 CONVERT_SMI_ARG_CHECKED(unchecked_value, 3); |
5578 // Only attribute bits should be set. | 5578 // Only attribute bits should be set. |
5579 RUNTIME_ASSERT( | 5579 RUNTIME_ASSERT( |
5580 (unchecked_value & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0); | 5580 (unchecked_value & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0); |
5581 attributes = static_cast<PropertyAttributes>(unchecked_value); | 5581 attributes = static_cast<PropertyAttributes>(unchecked_value); |
5582 } | 5582 } |
5583 Handle<Object> result; | 5583 Handle<Object> result; |
5584 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 5584 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
5585 isolate, result, | 5585 isolate, result, |
5586 JSObject::SetLocalPropertyIgnoreAttributes( | 5586 JSObject::SetLocalPropertyIgnoreAttributes( |
5587 object, name, value, attributes)); | 5587 object, name, value, attributes)); |
5588 return *result; | 5588 return *result; |
5589 } | 5589 } |
5590 | 5590 |
5591 | 5591 |
5592 RUNTIME_FUNCTION(MaybeObject*, Runtime_DeleteProperty) { | 5592 RUNTIME_FUNCTION(Object*, Runtime_DeleteProperty) { |
5593 HandleScope scope(isolate); | 5593 HandleScope scope(isolate); |
5594 ASSERT(args.length() == 3); | 5594 ASSERT(args.length() == 3); |
5595 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, object, 0); | 5595 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, object, 0); |
5596 CONVERT_ARG_HANDLE_CHECKED(Name, key, 1); | 5596 CONVERT_ARG_HANDLE_CHECKED(Name, key, 1); |
5597 CONVERT_STRICT_MODE_ARG_CHECKED(strict_mode, 2); | 5597 CONVERT_STRICT_MODE_ARG_CHECKED(strict_mode, 2); |
5598 JSReceiver::DeleteMode delete_mode = strict_mode == STRICT | 5598 JSReceiver::DeleteMode delete_mode = strict_mode == STRICT |
5599 ? JSReceiver::STRICT_DELETION : JSReceiver::NORMAL_DELETION; | 5599 ? JSReceiver::STRICT_DELETION : JSReceiver::NORMAL_DELETION; |
5600 Handle<Object> result; | 5600 Handle<Object> result; |
5601 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 5601 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
5602 isolate, result, | 5602 isolate, result, |
5603 JSReceiver::DeleteProperty(object, key, delete_mode)); | 5603 JSReceiver::DeleteProperty(object, key, delete_mode)); |
5604 return *result; | 5604 return *result; |
5605 } | 5605 } |
5606 | 5606 |
5607 | 5607 |
5608 static MaybeObject* HasLocalPropertyImplementation(Isolate* isolate, | 5608 static Object* HasLocalPropertyImplementation(Isolate* isolate, |
5609 Handle<JSObject> object, | 5609 Handle<JSObject> object, |
5610 Handle<Name> key) { | 5610 Handle<Name> key) { |
5611 if (JSReceiver::HasLocalProperty(object, key)) { | 5611 if (JSReceiver::HasLocalProperty(object, key)) { |
5612 return isolate->heap()->true_value(); | 5612 return isolate->heap()->true_value(); |
5613 } | 5613 } |
5614 // Handle hidden prototypes. If there's a hidden prototype above this thing | 5614 // Handle hidden prototypes. If there's a hidden prototype above this thing |
5615 // then we have to check it for properties, because they are supposed to | 5615 // then we have to check it for properties, because they are supposed to |
5616 // look like they are on this object. | 5616 // look like they are on this object. |
5617 Handle<Object> proto(object->GetPrototype(), isolate); | 5617 Handle<Object> proto(object->GetPrototype(), isolate); |
5618 if (proto->IsJSObject() && | 5618 if (proto->IsJSObject() && |
5619 Handle<JSObject>::cast(proto)->map()->is_hidden_prototype()) { | 5619 Handle<JSObject>::cast(proto)->map()->is_hidden_prototype()) { |
5620 return HasLocalPropertyImplementation(isolate, | 5620 return HasLocalPropertyImplementation(isolate, |
5621 Handle<JSObject>::cast(proto), | 5621 Handle<JSObject>::cast(proto), |
5622 key); | 5622 key); |
5623 } | 5623 } |
5624 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); | 5624 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); |
5625 return isolate->heap()->false_value(); | 5625 return isolate->heap()->false_value(); |
5626 } | 5626 } |
5627 | 5627 |
5628 | 5628 |
5629 RUNTIME_FUNCTION(MaybeObject*, Runtime_HasLocalProperty) { | 5629 RUNTIME_FUNCTION(Object*, Runtime_HasLocalProperty) { |
5630 HandleScope scope(isolate); | 5630 HandleScope scope(isolate); |
5631 ASSERT(args.length() == 2); | 5631 ASSERT(args.length() == 2); |
5632 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0) | 5632 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0) |
5633 CONVERT_ARG_HANDLE_CHECKED(Name, key, 1); | 5633 CONVERT_ARG_HANDLE_CHECKED(Name, key, 1); |
5634 | 5634 |
5635 uint32_t index; | 5635 uint32_t index; |
5636 const bool key_is_array_index = key->AsArrayIndex(&index); | 5636 const bool key_is_array_index = key->AsArrayIndex(&index); |
5637 | 5637 |
5638 // Only JS objects can have properties. | 5638 // Only JS objects can have properties. |
5639 if (object->IsJSObject()) { | 5639 if (object->IsJSObject()) { |
(...skipping 21 matching lines...) Expand all Loading... | |
5661 // Well, there is one exception: Handle [] on strings. | 5661 // Well, there is one exception: Handle [] on strings. |
5662 Handle<String> string = Handle<String>::cast(object); | 5662 Handle<String> string = Handle<String>::cast(object); |
5663 if (index < static_cast<uint32_t>(string->length())) { | 5663 if (index < static_cast<uint32_t>(string->length())) { |
5664 return isolate->heap()->true_value(); | 5664 return isolate->heap()->true_value(); |
5665 } | 5665 } |
5666 } | 5666 } |
5667 return isolate->heap()->false_value(); | 5667 return isolate->heap()->false_value(); |
5668 } | 5668 } |
5669 | 5669 |
5670 | 5670 |
5671 RUNTIME_FUNCTION(MaybeObject*, Runtime_HasProperty) { | 5671 RUNTIME_FUNCTION(Object*, Runtime_HasProperty) { |
5672 HandleScope scope(isolate); | 5672 HandleScope scope(isolate); |
5673 ASSERT(args.length() == 2); | 5673 ASSERT(args.length() == 2); |
5674 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, receiver, 0); | 5674 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, receiver, 0); |
5675 CONVERT_ARG_HANDLE_CHECKED(Name, key, 1); | 5675 CONVERT_ARG_HANDLE_CHECKED(Name, key, 1); |
5676 | 5676 |
5677 bool result = JSReceiver::HasProperty(receiver, key); | 5677 bool result = JSReceiver::HasProperty(receiver, key); |
5678 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); | 5678 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); |
5679 if (isolate->has_pending_exception()) return Failure::Exception(); | 5679 if (isolate->has_pending_exception()) return isolate->heap()->exception(); |
5680 return isolate->heap()->ToBoolean(result); | 5680 return isolate->heap()->ToBoolean(result); |
5681 } | 5681 } |
5682 | 5682 |
5683 | 5683 |
5684 RUNTIME_FUNCTION(MaybeObject*, Runtime_HasElement) { | 5684 RUNTIME_FUNCTION(Object*, Runtime_HasElement) { |
5685 HandleScope scope(isolate); | 5685 HandleScope scope(isolate); |
5686 ASSERT(args.length() == 2); | 5686 ASSERT(args.length() == 2); |
5687 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, receiver, 0); | 5687 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, receiver, 0); |
5688 CONVERT_SMI_ARG_CHECKED(index, 1); | 5688 CONVERT_SMI_ARG_CHECKED(index, 1); |
5689 | 5689 |
5690 bool result = JSReceiver::HasElement(receiver, index); | 5690 bool result = JSReceiver::HasElement(receiver, index); |
5691 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); | 5691 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); |
5692 return isolate->heap()->ToBoolean(result); | 5692 return isolate->heap()->ToBoolean(result); |
5693 } | 5693 } |
5694 | 5694 |
5695 | 5695 |
5696 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsPropertyEnumerable) { | 5696 RUNTIME_FUNCTION(Object*, Runtime_IsPropertyEnumerable) { |
5697 HandleScope scope(isolate); | 5697 HandleScope scope(isolate); |
5698 ASSERT(args.length() == 2); | 5698 ASSERT(args.length() == 2); |
5699 | 5699 |
5700 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); | 5700 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); |
5701 CONVERT_ARG_HANDLE_CHECKED(Name, key, 1); | 5701 CONVERT_ARG_HANDLE_CHECKED(Name, key, 1); |
5702 | 5702 |
5703 PropertyAttributes att = JSReceiver::GetLocalPropertyAttribute(object, key); | 5703 PropertyAttributes att = JSReceiver::GetLocalPropertyAttribute(object, key); |
5704 if (att == ABSENT || (att & DONT_ENUM) != 0) { | 5704 if (att == ABSENT || (att & DONT_ENUM) != 0) { |
5705 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); | 5705 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); |
5706 return isolate->heap()->false_value(); | 5706 return isolate->heap()->false_value(); |
5707 } | 5707 } |
5708 ASSERT(!isolate->has_scheduled_exception()); | 5708 ASSERT(!isolate->has_scheduled_exception()); |
5709 return isolate->heap()->true_value(); | 5709 return isolate->heap()->true_value(); |
5710 } | 5710 } |
5711 | 5711 |
5712 | 5712 |
5713 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetPropertyNames) { | 5713 RUNTIME_FUNCTION(Object*, Runtime_GetPropertyNames) { |
5714 HandleScope scope(isolate); | 5714 HandleScope scope(isolate); |
5715 ASSERT(args.length() == 1); | 5715 ASSERT(args.length() == 1); |
5716 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, object, 0); | 5716 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, object, 0); |
5717 Handle<JSArray> result; | 5717 Handle<JSArray> result; |
5718 | 5718 |
5719 isolate->counters()->for_in()->Increment(); | 5719 isolate->counters()->for_in()->Increment(); |
5720 Handle<FixedArray> elements; | 5720 Handle<FixedArray> elements; |
5721 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 5721 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
5722 isolate, elements, | 5722 isolate, elements, |
5723 JSReceiver::GetKeys(object, JSReceiver::INCLUDE_PROTOS)); | 5723 JSReceiver::GetKeys(object, JSReceiver::INCLUDE_PROTOS)); |
5724 return *isolate->factory()->NewJSArrayWithElements(elements); | 5724 return *isolate->factory()->NewJSArrayWithElements(elements); |
5725 } | 5725 } |
5726 | 5726 |
5727 | 5727 |
5728 // Returns either a FixedArray as Runtime_GetPropertyNames, | 5728 // Returns either a FixedArray as Runtime_GetPropertyNames, |
5729 // or, if the given object has an enum cache that contains | 5729 // or, if the given object has an enum cache that contains |
5730 // all enumerable properties of the object and its prototypes | 5730 // all enumerable properties of the object and its prototypes |
5731 // have none, the map of the object. This is used to speed up | 5731 // have none, the map of the object. This is used to speed up |
5732 // the check for deletions during a for-in. | 5732 // the check for deletions during a for-in. |
5733 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetPropertyNamesFast) { | 5733 RUNTIME_FUNCTION(Object*, Runtime_GetPropertyNamesFast) { |
5734 SealHandleScope shs(isolate); | 5734 SealHandleScope shs(isolate); |
5735 ASSERT(args.length() == 1); | 5735 ASSERT(args.length() == 1); |
5736 | 5736 |
5737 CONVERT_ARG_CHECKED(JSReceiver, raw_object, 0); | 5737 CONVERT_ARG_CHECKED(JSReceiver, raw_object, 0); |
5738 | 5738 |
5739 if (raw_object->IsSimpleEnum()) return raw_object->map(); | 5739 if (raw_object->IsSimpleEnum()) return raw_object->map(); |
5740 | 5740 |
5741 HandleScope scope(isolate); | 5741 HandleScope scope(isolate); |
5742 Handle<JSReceiver> object(raw_object); | 5742 Handle<JSReceiver> object(raw_object); |
5743 Handle<FixedArray> content; | 5743 Handle<FixedArray> content; |
(...skipping 19 matching lines...) Expand all Loading... | |
5763 count++; | 5763 count++; |
5764 proto = JSObject::cast(proto)->GetPrototype(); | 5764 proto = JSObject::cast(proto)->GetPrototype(); |
5765 } | 5765 } |
5766 return count; | 5766 return count; |
5767 } | 5767 } |
5768 | 5768 |
5769 | 5769 |
5770 // Return the names of the local named properties. | 5770 // Return the names of the local named properties. |
5771 // args[0]: object | 5771 // args[0]: object |
5772 // args[1]: PropertyAttributes as int | 5772 // args[1]: PropertyAttributes as int |
5773 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetLocalPropertyNames) { | 5773 RUNTIME_FUNCTION(Object*, Runtime_GetLocalPropertyNames) { |
5774 HandleScope scope(isolate); | 5774 HandleScope scope(isolate); |
5775 ASSERT(args.length() == 2); | 5775 ASSERT(args.length() == 2); |
5776 if (!args[0]->IsJSObject()) { | 5776 if (!args[0]->IsJSObject()) { |
5777 return isolate->heap()->undefined_value(); | 5777 return isolate->heap()->undefined_value(); |
5778 } | 5778 } |
5779 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); | 5779 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); |
5780 CONVERT_SMI_ARG_CHECKED(filter_value, 1); | 5780 CONVERT_SMI_ARG_CHECKED(filter_value, 1); |
5781 PropertyAttributes filter = static_cast<PropertyAttributes>(filter_value); | 5781 PropertyAttributes filter = static_cast<PropertyAttributes>(filter_value); |
5782 | 5782 |
5783 // Skip the global proxy as it has no properties and always delegates to the | 5783 // Skip the global proxy as it has no properties and always delegates to the |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5877 } | 5877 } |
5878 ASSERT_EQ(0, hidden_strings); | 5878 ASSERT_EQ(0, hidden_strings); |
5879 } | 5879 } |
5880 | 5880 |
5881 return *isolate->factory()->NewJSArrayWithElements(names); | 5881 return *isolate->factory()->NewJSArrayWithElements(names); |
5882 } | 5882 } |
5883 | 5883 |
5884 | 5884 |
5885 // Return the names of the local indexed properties. | 5885 // Return the names of the local indexed properties. |
5886 // args[0]: object | 5886 // args[0]: object |
5887 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetLocalElementNames) { | 5887 RUNTIME_FUNCTION(Object*, Runtime_GetLocalElementNames) { |
5888 HandleScope scope(isolate); | 5888 HandleScope scope(isolate); |
5889 ASSERT(args.length() == 1); | 5889 ASSERT(args.length() == 1); |
5890 if (!args[0]->IsJSObject()) { | 5890 if (!args[0]->IsJSObject()) { |
5891 return isolate->heap()->undefined_value(); | 5891 return isolate->heap()->undefined_value(); |
5892 } | 5892 } |
5893 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); | 5893 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); |
5894 | 5894 |
5895 int n = obj->NumberOfLocalElements(static_cast<PropertyAttributes>(NONE)); | 5895 int n = obj->NumberOfLocalElements(static_cast<PropertyAttributes>(NONE)); |
5896 Handle<FixedArray> names = isolate->factory()->NewFixedArray(n); | 5896 Handle<FixedArray> names = isolate->factory()->NewFixedArray(n); |
5897 obj->GetLocalElementKeys(*names, static_cast<PropertyAttributes>(NONE)); | 5897 obj->GetLocalElementKeys(*names, static_cast<PropertyAttributes>(NONE)); |
5898 return *isolate->factory()->NewJSArrayWithElements(names); | 5898 return *isolate->factory()->NewJSArrayWithElements(names); |
5899 } | 5899 } |
5900 | 5900 |
5901 | 5901 |
5902 // Return information on whether an object has a named or indexed interceptor. | 5902 // Return information on whether an object has a named or indexed interceptor. |
5903 // args[0]: object | 5903 // args[0]: object |
5904 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetInterceptorInfo) { | 5904 RUNTIME_FUNCTION(Object*, Runtime_GetInterceptorInfo) { |
5905 HandleScope scope(isolate); | 5905 HandleScope scope(isolate); |
5906 ASSERT(args.length() == 1); | 5906 ASSERT(args.length() == 1); |
5907 if (!args[0]->IsJSObject()) { | 5907 if (!args[0]->IsJSObject()) { |
5908 return Smi::FromInt(0); | 5908 return Smi::FromInt(0); |
5909 } | 5909 } |
5910 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); | 5910 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); |
5911 | 5911 |
5912 int result = 0; | 5912 int result = 0; |
5913 if (obj->HasNamedInterceptor()) result |= 2; | 5913 if (obj->HasNamedInterceptor()) result |= 2; |
5914 if (obj->HasIndexedInterceptor()) result |= 1; | 5914 if (obj->HasIndexedInterceptor()) result |= 1; |
5915 | 5915 |
5916 return Smi::FromInt(result); | 5916 return Smi::FromInt(result); |
5917 } | 5917 } |
5918 | 5918 |
5919 | 5919 |
5920 // Return property names from named interceptor. | 5920 // Return property names from named interceptor. |
5921 // args[0]: object | 5921 // args[0]: object |
5922 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetNamedInterceptorPropertyNames) { | 5922 RUNTIME_FUNCTION(Object*, Runtime_GetNamedInterceptorPropertyNames) { |
5923 HandleScope scope(isolate); | 5923 HandleScope scope(isolate); |
5924 ASSERT(args.length() == 1); | 5924 ASSERT(args.length() == 1); |
5925 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); | 5925 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); |
5926 | 5926 |
5927 if (obj->HasNamedInterceptor()) { | 5927 if (obj->HasNamedInterceptor()) { |
5928 Handle<JSArray> result; | 5928 Handle<JSArray> result; |
5929 if (JSObject::GetKeysForNamedInterceptor(obj, obj).ToHandle(&result)) { | 5929 if (JSObject::GetKeysForNamedInterceptor(obj, obj).ToHandle(&result)) { |
5930 return *result; | 5930 return *result; |
5931 } | 5931 } |
5932 } | 5932 } |
5933 return isolate->heap()->undefined_value(); | 5933 return isolate->heap()->undefined_value(); |
5934 } | 5934 } |
5935 | 5935 |
5936 | 5936 |
5937 // Return element names from indexed interceptor. | 5937 // Return element names from indexed interceptor. |
5938 // args[0]: object | 5938 // args[0]: object |
5939 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetIndexedInterceptorElementNames) { | 5939 RUNTIME_FUNCTION(Object*, Runtime_GetIndexedInterceptorElementNames) { |
5940 HandleScope scope(isolate); | 5940 HandleScope scope(isolate); |
5941 ASSERT(args.length() == 1); | 5941 ASSERT(args.length() == 1); |
5942 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); | 5942 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); |
5943 | 5943 |
5944 if (obj->HasIndexedInterceptor()) { | 5944 if (obj->HasIndexedInterceptor()) { |
5945 Handle<JSArray> result; | 5945 Handle<JSArray> result; |
5946 if (JSObject::GetKeysForIndexedInterceptor(obj, obj).ToHandle(&result)) { | 5946 if (JSObject::GetKeysForIndexedInterceptor(obj, obj).ToHandle(&result)) { |
5947 return *result; | 5947 return *result; |
5948 } | 5948 } |
5949 } | 5949 } |
5950 return isolate->heap()->undefined_value(); | 5950 return isolate->heap()->undefined_value(); |
5951 } | 5951 } |
5952 | 5952 |
5953 | 5953 |
5954 RUNTIME_FUNCTION(MaybeObject*, Runtime_LocalKeys) { | 5954 RUNTIME_FUNCTION(Object*, Runtime_LocalKeys) { |
5955 HandleScope scope(isolate); | 5955 HandleScope scope(isolate); |
5956 ASSERT(args.length() == 1); | 5956 ASSERT(args.length() == 1); |
5957 CONVERT_ARG_CHECKED(JSObject, raw_object, 0); | 5957 CONVERT_ARG_CHECKED(JSObject, raw_object, 0); |
5958 Handle<JSObject> object(raw_object); | 5958 Handle<JSObject> object(raw_object); |
5959 | 5959 |
5960 if (object->IsJSGlobalProxy()) { | 5960 if (object->IsJSGlobalProxy()) { |
5961 // Do access checks before going to the global object. | 5961 // Do access checks before going to the global object. |
5962 if (object->IsAccessCheckNeeded() && | 5962 if (object->IsAccessCheckNeeded() && |
5963 !isolate->MayNamedAccess( | 5963 !isolate->MayNamedAccess( |
5964 object, isolate->factory()->undefined_value(), v8::ACCESS_KEYS)) { | 5964 object, isolate->factory()->undefined_value(), v8::ACCESS_KEYS)) { |
(...skipping 28 matching lines...) Expand all Loading... | |
5993 Handle<Object> entry_handle(entry, isolate); | 5993 Handle<Object> entry_handle(entry, isolate); |
5994 Handle<Object> entry_str = | 5994 Handle<Object> entry_str = |
5995 isolate->factory()->NumberToString(entry_handle); | 5995 isolate->factory()->NumberToString(entry_handle); |
5996 copy->set(i, *entry_str); | 5996 copy->set(i, *entry_str); |
5997 } | 5997 } |
5998 } | 5998 } |
5999 return *isolate->factory()->NewJSArrayWithElements(copy); | 5999 return *isolate->factory()->NewJSArrayWithElements(copy); |
6000 } | 6000 } |
6001 | 6001 |
6002 | 6002 |
6003 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetArgumentsProperty) { | 6003 RUNTIME_FUNCTION(Object*, Runtime_GetArgumentsProperty) { |
6004 SealHandleScope shs(isolate); | 6004 SealHandleScope shs(isolate); |
6005 ASSERT(args.length() == 1); | 6005 ASSERT(args.length() == 1); |
6006 CONVERT_ARG_HANDLE_CHECKED(Object, raw_key, 0); | 6006 CONVERT_ARG_HANDLE_CHECKED(Object, raw_key, 0); |
6007 | 6007 |
6008 // Compute the frame holding the arguments. | 6008 // Compute the frame holding the arguments. |
6009 JavaScriptFrameIterator it(isolate); | 6009 JavaScriptFrameIterator it(isolate); |
6010 it.AdvanceToArgumentsFrame(); | 6010 it.AdvanceToArgumentsFrame(); |
6011 JavaScriptFrame* frame = it.frame(); | 6011 JavaScriptFrame* frame = it.frame(); |
6012 | 6012 |
6013 // Get the actual number of provided arguments. | 6013 // Get the actual number of provided arguments. |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6066 | 6066 |
6067 // Lookup in the initial Object.prototype object. | 6067 // Lookup in the initial Object.prototype object. |
6068 Handle<Object> result; | 6068 Handle<Object> result; |
6069 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 6069 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
6070 isolate, result, | 6070 isolate, result, |
6071 Object::GetProperty(isolate->initial_object_prototype(), key)); | 6071 Object::GetProperty(isolate->initial_object_prototype(), key)); |
6072 return *result; | 6072 return *result; |
6073 } | 6073 } |
6074 | 6074 |
6075 | 6075 |
6076 RUNTIME_FUNCTION(MaybeObject*, Runtime_ToFastProperties) { | 6076 RUNTIME_FUNCTION(Object*, Runtime_ToFastProperties) { |
6077 HandleScope scope(isolate); | 6077 HandleScope scope(isolate); |
6078 ASSERT(args.length() == 1); | 6078 ASSERT(args.length() == 1); |
6079 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); | 6079 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); |
6080 if (object->IsJSObject() && !object->IsGlobalObject()) { | 6080 if (object->IsJSObject() && !object->IsGlobalObject()) { |
6081 JSObject::TransformToFastProperties(Handle<JSObject>::cast(object), 0); | 6081 JSObject::TransformToFastProperties(Handle<JSObject>::cast(object), 0); |
6082 } | 6082 } |
6083 return *object; | 6083 return *object; |
6084 } | 6084 } |
6085 | 6085 |
6086 | 6086 |
6087 RUNTIME_FUNCTION(MaybeObject*, Runtime_ToBool) { | 6087 RUNTIME_FUNCTION(Object*, Runtime_ToBool) { |
6088 SealHandleScope shs(isolate); | 6088 SealHandleScope shs(isolate); |
6089 ASSERT(args.length() == 1); | 6089 ASSERT(args.length() == 1); |
6090 CONVERT_ARG_CHECKED(Object, object, 0); | 6090 CONVERT_ARG_CHECKED(Object, object, 0); |
6091 | 6091 |
6092 return isolate->heap()->ToBoolean(object->BooleanValue()); | 6092 return isolate->heap()->ToBoolean(object->BooleanValue()); |
6093 } | 6093 } |
6094 | 6094 |
6095 | 6095 |
6096 // Returns the type string of a value; see ECMA-262, 11.4.3 (p 47). | 6096 // Returns the type string of a value; see ECMA-262, 11.4.3 (p 47). |
6097 // Possible optimizations: put the type string into the oddballs. | 6097 // Possible optimizations: put the type string into the oddballs. |
6098 RUNTIME_FUNCTION(MaybeObject*, Runtime_Typeof) { | 6098 RUNTIME_FUNCTION(Object*, Runtime_Typeof) { |
6099 SealHandleScope shs(isolate); | 6099 SealHandleScope shs(isolate); |
6100 ASSERT(args.length() == 1); | 6100 ASSERT(args.length() == 1); |
6101 CONVERT_ARG_CHECKED(Object, obj, 0); | 6101 CONVERT_ARG_CHECKED(Object, obj, 0); |
6102 if (obj->IsNumber()) return isolate->heap()->number_string(); | 6102 if (obj->IsNumber()) return isolate->heap()->number_string(); |
6103 HeapObject* heap_obj = HeapObject::cast(obj); | 6103 HeapObject* heap_obj = HeapObject::cast(obj); |
6104 | 6104 |
6105 // typeof an undetectable object is 'undefined' | 6105 // typeof an undetectable object is 'undefined' |
6106 if (heap_obj->map()->is_undetectable()) { | 6106 if (heap_obj->map()->is_undetectable()) { |
6107 return isolate->heap()->undefined_string(); | 6107 return isolate->heap()->undefined_string(); |
6108 } | 6108 } |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6152 int d = s[from] - '0'; | 6152 int d = s[from] - '0'; |
6153 | 6153 |
6154 for (int i = from + 1; i < to; i++) { | 6154 for (int i = from + 1; i < to; i++) { |
6155 d = 10 * d + (s[i] - '0'); | 6155 d = 10 * d + (s[i] - '0'); |
6156 } | 6156 } |
6157 | 6157 |
6158 return d; | 6158 return d; |
6159 } | 6159 } |
6160 | 6160 |
6161 | 6161 |
6162 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringToNumber) { | 6162 RUNTIME_FUNCTION(Object*, Runtime_StringToNumber) { |
6163 HandleScope handle_scope(isolate); | 6163 HandleScope handle_scope(isolate); |
6164 ASSERT(args.length() == 1); | 6164 ASSERT(args.length() == 1); |
6165 CONVERT_ARG_HANDLE_CHECKED(String, subject, 0); | 6165 CONVERT_ARG_HANDLE_CHECKED(String, subject, 0); |
6166 subject = String::Flatten(subject); | 6166 subject = String::Flatten(subject); |
6167 | 6167 |
6168 // Fast case: short integer or some sorts of junk values. | 6168 // Fast case: short integer or some sorts of junk values. |
6169 if (subject->IsSeqOneByteString()) { | 6169 if (subject->IsSeqOneByteString()) { |
6170 int len = subject->length(); | 6170 int len = subject->length(); |
6171 if (len == 0) return Smi::FromInt(0); | 6171 if (len == 0) return Smi::FromInt(0); |
6172 | 6172 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6215 // The current spec draft has not updated "ToNumber Applied to the String | 6215 // The current spec draft has not updated "ToNumber Applied to the String |
6216 // Type", https://bugs.ecmascript.org/show_bug.cgi?id=1584 | 6216 // Type", https://bugs.ecmascript.org/show_bug.cgi?id=1584 |
6217 flags |= ALLOW_OCTAL | ALLOW_BINARY; | 6217 flags |= ALLOW_OCTAL | ALLOW_BINARY; |
6218 } | 6218 } |
6219 | 6219 |
6220 return *isolate->factory()->NewNumber(StringToDouble( | 6220 return *isolate->factory()->NewNumber(StringToDouble( |
6221 isolate->unicode_cache(), *subject, flags)); | 6221 isolate->unicode_cache(), *subject, flags)); |
6222 } | 6222 } |
6223 | 6223 |
6224 | 6224 |
6225 RUNTIME_FUNCTION(MaybeObject*, Runtime_NewString) { | 6225 RUNTIME_FUNCTION(Object*, Runtime_NewString) { |
6226 HandleScope scope(isolate); | 6226 HandleScope scope(isolate); |
6227 ASSERT(args.length() == 2); | 6227 ASSERT(args.length() == 2); |
6228 CONVERT_SMI_ARG_CHECKED(length, 0); | 6228 CONVERT_SMI_ARG_CHECKED(length, 0); |
6229 CONVERT_BOOLEAN_ARG_CHECKED(is_one_byte, 1); | 6229 CONVERT_BOOLEAN_ARG_CHECKED(is_one_byte, 1); |
6230 if (length == 0) return isolate->heap()->empty_string(); | 6230 if (length == 0) return isolate->heap()->empty_string(); |
6231 Handle<String> result; | 6231 Handle<String> result; |
6232 if (is_one_byte) { | 6232 if (is_one_byte) { |
6233 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 6233 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
6234 isolate, result, isolate->factory()->NewRawOneByteString(length)); | 6234 isolate, result, isolate->factory()->NewRawOneByteString(length)); |
6235 } else { | 6235 } else { |
6236 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 6236 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
6237 isolate, result, isolate->factory()->NewRawTwoByteString(length)); | 6237 isolate, result, isolate->factory()->NewRawTwoByteString(length)); |
6238 } | 6238 } |
6239 return *result; | 6239 return *result; |
6240 } | 6240 } |
6241 | 6241 |
6242 | 6242 |
6243 RUNTIME_FUNCTION(MaybeObject*, Runtime_TruncateString) { | 6243 RUNTIME_FUNCTION(Object*, Runtime_TruncateString) { |
6244 HandleScope scope(isolate); | 6244 HandleScope scope(isolate); |
6245 ASSERT(args.length() == 2); | 6245 ASSERT(args.length() == 2); |
6246 CONVERT_ARG_HANDLE_CHECKED(SeqString, string, 0); | 6246 CONVERT_ARG_HANDLE_CHECKED(SeqString, string, 0); |
6247 CONVERT_SMI_ARG_CHECKED(new_length, 1); | 6247 CONVERT_SMI_ARG_CHECKED(new_length, 1); |
6248 return *SeqString::Truncate(string, new_length); | 6248 return *SeqString::Truncate(string, new_length); |
6249 } | 6249 } |
6250 | 6250 |
6251 | 6251 |
6252 RUNTIME_FUNCTION(MaybeObject*, Runtime_URIEscape) { | 6252 RUNTIME_FUNCTION(Object*, Runtime_URIEscape) { |
6253 HandleScope scope(isolate); | 6253 HandleScope scope(isolate); |
6254 ASSERT(args.length() == 1); | 6254 ASSERT(args.length() == 1); |
6255 CONVERT_ARG_HANDLE_CHECKED(String, source, 0); | 6255 CONVERT_ARG_HANDLE_CHECKED(String, source, 0); |
6256 Handle<String> string = String::Flatten(source); | 6256 Handle<String> string = String::Flatten(source); |
6257 ASSERT(string->IsFlat()); | 6257 ASSERT(string->IsFlat()); |
6258 Handle<String> result; | 6258 Handle<String> result; |
6259 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 6259 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
6260 isolate, result, | 6260 isolate, result, |
6261 string->IsOneByteRepresentationUnderneath() | 6261 string->IsOneByteRepresentationUnderneath() |
6262 ? URIEscape::Escape<uint8_t>(isolate, source) | 6262 ? URIEscape::Escape<uint8_t>(isolate, source) |
6263 : URIEscape::Escape<uc16>(isolate, source)); | 6263 : URIEscape::Escape<uc16>(isolate, source)); |
6264 return *result; | 6264 return *result; |
6265 } | 6265 } |
6266 | 6266 |
6267 | 6267 |
6268 RUNTIME_FUNCTION(MaybeObject*, Runtime_URIUnescape) { | 6268 RUNTIME_FUNCTION(Object*, Runtime_URIUnescape) { |
6269 HandleScope scope(isolate); | 6269 HandleScope scope(isolate); |
6270 ASSERT(args.length() == 1); | 6270 ASSERT(args.length() == 1); |
6271 CONVERT_ARG_HANDLE_CHECKED(String, source, 0); | 6271 CONVERT_ARG_HANDLE_CHECKED(String, source, 0); |
6272 Handle<String> string = String::Flatten(source); | 6272 Handle<String> string = String::Flatten(source); |
6273 ASSERT(string->IsFlat()); | 6273 ASSERT(string->IsFlat()); |
6274 Handle<String> result; | 6274 Handle<String> result; |
6275 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 6275 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
6276 isolate, result, | 6276 isolate, result, |
6277 string->IsOneByteRepresentationUnderneath() | 6277 string->IsOneByteRepresentationUnderneath() |
6278 ? URIUnescape::Unescape<uint8_t>(isolate, source) | 6278 ? URIUnescape::Unescape<uint8_t>(isolate, source) |
6279 : URIUnescape::Unescape<uc16>(isolate, source)); | 6279 : URIUnescape::Unescape<uc16>(isolate, source)); |
6280 return *result; | 6280 return *result; |
6281 } | 6281 } |
6282 | 6282 |
6283 | 6283 |
6284 RUNTIME_FUNCTION(MaybeObject*, Runtime_QuoteJSONString) { | 6284 RUNTIME_FUNCTION(Object*, Runtime_QuoteJSONString) { |
6285 HandleScope scope(isolate); | 6285 HandleScope scope(isolate); |
6286 CONVERT_ARG_HANDLE_CHECKED(String, string, 0); | 6286 CONVERT_ARG_HANDLE_CHECKED(String, string, 0); |
6287 ASSERT(args.length() == 1); | 6287 ASSERT(args.length() == 1); |
6288 Handle<Object> result; | 6288 Handle<Object> result; |
6289 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 6289 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
6290 isolate, result, BasicJsonStringifier::StringifyString(isolate, string)); | 6290 isolate, result, BasicJsonStringifier::StringifyString(isolate, string)); |
6291 return *result; | 6291 return *result; |
6292 } | 6292 } |
6293 | 6293 |
6294 | 6294 |
6295 RUNTIME_FUNCTION(MaybeObject*, Runtime_BasicJSONStringify) { | 6295 RUNTIME_FUNCTION(Object*, Runtime_BasicJSONStringify) { |
6296 HandleScope scope(isolate); | 6296 HandleScope scope(isolate); |
6297 ASSERT(args.length() == 1); | 6297 ASSERT(args.length() == 1); |
6298 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); | 6298 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); |
6299 BasicJsonStringifier stringifier(isolate); | 6299 BasicJsonStringifier stringifier(isolate); |
6300 Handle<Object> result; | 6300 Handle<Object> result; |
6301 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 6301 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
6302 isolate, result, stringifier.Stringify(object)); | 6302 isolate, result, stringifier.Stringify(object)); |
6303 return *result; | 6303 return *result; |
6304 } | 6304 } |
6305 | 6305 |
6306 | 6306 |
6307 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringParseInt) { | 6307 RUNTIME_FUNCTION(Object*, Runtime_StringParseInt) { |
6308 HandleScope handle_scope(isolate); | 6308 HandleScope handle_scope(isolate); |
6309 ASSERT(args.length() == 2); | 6309 ASSERT(args.length() == 2); |
6310 CONVERT_ARG_HANDLE_CHECKED(String, subject, 0); | 6310 CONVERT_ARG_HANDLE_CHECKED(String, subject, 0); |
6311 CONVERT_NUMBER_CHECKED(int, radix, Int32, args[1]); | 6311 CONVERT_NUMBER_CHECKED(int, radix, Int32, args[1]); |
6312 RUNTIME_ASSERT(radix == 0 || (2 <= radix && radix <= 36)); | 6312 RUNTIME_ASSERT(radix == 0 || (2 <= radix && radix <= 36)); |
6313 | 6313 |
6314 subject = String::Flatten(subject); | 6314 subject = String::Flatten(subject); |
6315 double value; | 6315 double value; |
6316 | 6316 |
6317 { DisallowHeapAllocation no_gc; | 6317 { DisallowHeapAllocation no_gc; |
6318 String::FlatContent flat = subject->GetFlatContent(); | 6318 String::FlatContent flat = subject->GetFlatContent(); |
6319 | 6319 |
6320 // ECMA-262 section 15.1.2.3, empty string is NaN | 6320 // ECMA-262 section 15.1.2.3, empty string is NaN |
6321 if (flat.IsAscii()) { | 6321 if (flat.IsAscii()) { |
6322 value = StringToInt( | 6322 value = StringToInt( |
6323 isolate->unicode_cache(), flat.ToOneByteVector(), radix); | 6323 isolate->unicode_cache(), flat.ToOneByteVector(), radix); |
6324 } else { | 6324 } else { |
6325 value = StringToInt( | 6325 value = StringToInt( |
6326 isolate->unicode_cache(), flat.ToUC16Vector(), radix); | 6326 isolate->unicode_cache(), flat.ToUC16Vector(), radix); |
6327 } | 6327 } |
6328 } | 6328 } |
6329 | 6329 |
6330 return *isolate->factory()->NewNumber(value); | 6330 return *isolate->factory()->NewNumber(value); |
6331 } | 6331 } |
6332 | 6332 |
6333 | 6333 |
6334 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringParseFloat) { | 6334 RUNTIME_FUNCTION(Object*, Runtime_StringParseFloat) { |
6335 HandleScope shs(isolate); | 6335 HandleScope shs(isolate); |
6336 ASSERT(args.length() == 1); | 6336 ASSERT(args.length() == 1); |
6337 CONVERT_ARG_HANDLE_CHECKED(String, subject, 0); | 6337 CONVERT_ARG_HANDLE_CHECKED(String, subject, 0); |
6338 | 6338 |
6339 subject = String::Flatten(subject); | 6339 subject = String::Flatten(subject); |
6340 double value = StringToDouble( | 6340 double value = StringToDouble( |
6341 isolate->unicode_cache(), *subject, ALLOW_TRAILING_JUNK, OS::nan_value()); | 6341 isolate->unicode_cache(), *subject, ALLOW_TRAILING_JUNK, OS::nan_value()); |
6342 | 6342 |
6343 return *isolate->factory()->NewNumber(value); | 6343 return *isolate->factory()->NewNumber(value); |
6344 } | 6344 } |
6345 | 6345 |
6346 | 6346 |
6347 static inline bool ToUpperOverflows(uc32 character) { | 6347 static inline bool ToUpperOverflows(uc32 character) { |
6348 // y with umlauts and the micro sign are the only characters that stop | 6348 // y with umlauts and the micro sign are the only characters that stop |
6349 // fitting into one-byte when converting to uppercase. | 6349 // fitting into one-byte when converting to uppercase. |
6350 static const uc32 yuml_code = 0xff; | 6350 static const uc32 yuml_code = 0xff; |
6351 static const uc32 micro_code = 0xb5; | 6351 static const uc32 micro_code = 0xb5; |
6352 return (character == yuml_code || character == micro_code); | 6352 return (character == yuml_code || character == micro_code); |
6353 } | 6353 } |
6354 | 6354 |
6355 | 6355 |
6356 template <class Converter> | 6356 template <class Converter> |
6357 MUST_USE_RESULT static MaybeObject* ConvertCaseHelper( | 6357 MUST_USE_RESULT static Object* ConvertCaseHelper( |
6358 Isolate* isolate, | 6358 Isolate* isolate, |
6359 String* string, | 6359 String* string, |
6360 SeqString* result, | 6360 SeqString* result, |
6361 int result_length, | 6361 int result_length, |
6362 unibrow::Mapping<Converter, 128>* mapping) { | 6362 unibrow::Mapping<Converter, 128>* mapping) { |
6363 DisallowHeapAllocation no_gc; | 6363 DisallowHeapAllocation no_gc; |
6364 // We try this twice, once with the assumption that the result is no longer | 6364 // We try this twice, once with the assumption that the result is no longer |
6365 // than the input and, if that assumption breaks, again with the exact | 6365 // than the input and, if that assumption breaks, again with the exact |
6366 // length. This may not be pretty, but it is nicer than what was here before | 6366 // length. This may not be pretty, but it is nicer than what was here before |
6367 // and I hereby claim my vaffel-is. | 6367 // and I hereby claim my vaffel-is. |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6570 saved_dst, saved_src, length, changed, Converter::kIsToLower)); | 6570 saved_dst, saved_src, length, changed, Converter::kIsToLower)); |
6571 | 6571 |
6572 *changed_out = changed; | 6572 *changed_out = changed; |
6573 return true; | 6573 return true; |
6574 } | 6574 } |
6575 | 6575 |
6576 } // namespace | 6576 } // namespace |
6577 | 6577 |
6578 | 6578 |
6579 template <class Converter> | 6579 template <class Converter> |
6580 MUST_USE_RESULT static MaybeObject* ConvertCase( | 6580 MUST_USE_RESULT static Object* ConvertCase( |
6581 Handle<String> s, | 6581 Handle<String> s, |
6582 Isolate* isolate, | 6582 Isolate* isolate, |
6583 unibrow::Mapping<Converter, 128>* mapping) { | 6583 unibrow::Mapping<Converter, 128>* mapping) { |
6584 s = String::Flatten(s); | 6584 s = String::Flatten(s); |
6585 int length = s->length(); | 6585 int length = s->length(); |
6586 // Assume that the string is not empty; we need this assumption later | 6586 // Assume that the string is not empty; we need this assumption later |
6587 if (length == 0) return *s; | 6587 if (length == 0) return *s; |
6588 | 6588 |
6589 // Simpler handling of ASCII strings. | 6589 // Simpler handling of ASCII strings. |
6590 // | 6590 // |
(...skipping 18 matching lines...) Expand all Loading... | |
6609 if (is_ascii) return has_changed_character ? *result : *s; | 6609 if (is_ascii) return has_changed_character ? *result : *s; |
6610 } | 6610 } |
6611 | 6611 |
6612 Handle<SeqString> result; // Same length as input. | 6612 Handle<SeqString> result; // Same length as input. |
6613 if (s->IsOneByteRepresentation()) { | 6613 if (s->IsOneByteRepresentation()) { |
6614 result = isolate->factory()->NewRawOneByteString(length).ToHandleChecked(); | 6614 result = isolate->factory()->NewRawOneByteString(length).ToHandleChecked(); |
6615 } else { | 6615 } else { |
6616 result = isolate->factory()->NewRawTwoByteString(length).ToHandleChecked(); | 6616 result = isolate->factory()->NewRawTwoByteString(length).ToHandleChecked(); |
6617 } | 6617 } |
6618 | 6618 |
6619 MaybeObject* maybe = ConvertCaseHelper(isolate, *s, *result, length, mapping); | 6619 Object* answer = ConvertCaseHelper(isolate, *s, *result, length, mapping); |
6620 Object* answer; | 6620 if (answer->IsException() || answer->IsString()) return answer; |
6621 if (!maybe->ToObject(&answer)) return maybe; | |
6622 if (answer->IsString()) return answer; | |
6623 | 6621 |
6624 ASSERT(answer->IsSmi()); | 6622 ASSERT(answer->IsSmi()); |
6625 length = Smi::cast(answer)->value(); | 6623 length = Smi::cast(answer)->value(); |
6626 if (s->IsOneByteRepresentation() && length > 0) { | 6624 if (s->IsOneByteRepresentation() && length > 0) { |
6627 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 6625 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
6628 isolate, result, isolate->factory()->NewRawOneByteString(length)); | 6626 isolate, result, isolate->factory()->NewRawOneByteString(length)); |
6629 } else { | 6627 } else { |
6630 if (length < 0) length = -length; | 6628 if (length < 0) length = -length; |
6631 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 6629 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
6632 isolate, result, isolate->factory()->NewRawTwoByteString(length)); | 6630 isolate, result, isolate->factory()->NewRawTwoByteString(length)); |
6633 } | 6631 } |
6634 return ConvertCaseHelper(isolate, *s, *result, length, mapping); | 6632 return ConvertCaseHelper(isolate, *s, *result, length, mapping); |
6635 } | 6633 } |
6636 | 6634 |
6637 | 6635 |
6638 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringToLowerCase) { | 6636 RUNTIME_FUNCTION(Object*, Runtime_StringToLowerCase) { |
6639 HandleScope scope(isolate); | 6637 HandleScope scope(isolate); |
6640 ASSERT(args.length() == 1); | 6638 ASSERT(args.length() == 1); |
6641 CONVERT_ARG_HANDLE_CHECKED(String, s, 0); | 6639 CONVERT_ARG_HANDLE_CHECKED(String, s, 0); |
6642 return ConvertCase( | 6640 return ConvertCase( |
6643 s, isolate, isolate->runtime_state()->to_lower_mapping()); | 6641 s, isolate, isolate->runtime_state()->to_lower_mapping()); |
6644 } | 6642 } |
6645 | 6643 |
6646 | 6644 |
6647 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringToUpperCase) { | 6645 RUNTIME_FUNCTION(Object*, Runtime_StringToUpperCase) { |
6648 HandleScope scope(isolate); | 6646 HandleScope scope(isolate); |
6649 ASSERT(args.length() == 1); | 6647 ASSERT(args.length() == 1); |
6650 CONVERT_ARG_HANDLE_CHECKED(String, s, 0); | 6648 CONVERT_ARG_HANDLE_CHECKED(String, s, 0); |
6651 return ConvertCase( | 6649 return ConvertCase( |
6652 s, isolate, isolate->runtime_state()->to_upper_mapping()); | 6650 s, isolate, isolate->runtime_state()->to_upper_mapping()); |
6653 } | 6651 } |
6654 | 6652 |
6655 | 6653 |
6656 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringTrim) { | 6654 RUNTIME_FUNCTION(Object*, Runtime_StringTrim) { |
6657 HandleScope scope(isolate); | 6655 HandleScope scope(isolate); |
6658 ASSERT(args.length() == 3); | 6656 ASSERT(args.length() == 3); |
6659 | 6657 |
6660 CONVERT_ARG_HANDLE_CHECKED(String, string, 0); | 6658 CONVERT_ARG_HANDLE_CHECKED(String, string, 0); |
6661 CONVERT_BOOLEAN_ARG_CHECKED(trimLeft, 1); | 6659 CONVERT_BOOLEAN_ARG_CHECKED(trimLeft, 1); |
6662 CONVERT_BOOLEAN_ARG_CHECKED(trimRight, 2); | 6660 CONVERT_BOOLEAN_ARG_CHECKED(trimRight, 2); |
6663 | 6661 |
6664 string = String::Flatten(string); | 6662 string = String::Flatten(string); |
6665 int length = string->length(); | 6663 int length = string->length(); |
6666 | 6664 |
(...skipping 12 matching lines...) Expand all Loading... | |
6679 unicode_cache->IsWhiteSpaceOrLineTerminator( | 6677 unicode_cache->IsWhiteSpaceOrLineTerminator( |
6680 string->Get(right - 1))) { | 6678 string->Get(right - 1))) { |
6681 right--; | 6679 right--; |
6682 } | 6680 } |
6683 } | 6681 } |
6684 | 6682 |
6685 return *isolate->factory()->NewSubString(string, left, right); | 6683 return *isolate->factory()->NewSubString(string, left, right); |
6686 } | 6684 } |
6687 | 6685 |
6688 | 6686 |
6689 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringSplit) { | 6687 RUNTIME_FUNCTION(Object*, Runtime_StringSplit) { |
6690 HandleScope handle_scope(isolate); | 6688 HandleScope handle_scope(isolate); |
6691 ASSERT(args.length() == 3); | 6689 ASSERT(args.length() == 3); |
6692 CONVERT_ARG_HANDLE_CHECKED(String, subject, 0); | 6690 CONVERT_ARG_HANDLE_CHECKED(String, subject, 0); |
6693 CONVERT_ARG_HANDLE_CHECKED(String, pattern, 1); | 6691 CONVERT_ARG_HANDLE_CHECKED(String, pattern, 1); |
6694 CONVERT_NUMBER_CHECKED(uint32_t, limit, Uint32, args[2]); | 6692 CONVERT_NUMBER_CHECKED(uint32_t, limit, Uint32, args[2]); |
6695 | 6693 |
6696 int subject_length = subject->length(); | 6694 int subject_length = subject->length(); |
6697 int pattern_length = pattern->length(); | 6695 int pattern_length = pattern->length(); |
6698 RUNTIME_ASSERT(pattern_length > 0); | 6696 RUNTIME_ASSERT(pattern_length > 0); |
6699 | 6697 |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6804 ASSERT(element == Smi::FromInt(0) || | 6802 ASSERT(element == Smi::FromInt(0) || |
6805 (element->IsString() && String::cast(element)->LooksValid())); | 6803 (element->IsString() && String::cast(element)->LooksValid())); |
6806 } | 6804 } |
6807 #endif | 6805 #endif |
6808 return i; | 6806 return i; |
6809 } | 6807 } |
6810 | 6808 |
6811 | 6809 |
6812 // Converts a String to JSArray. | 6810 // Converts a String to JSArray. |
6813 // For example, "foo" => ["f", "o", "o"]. | 6811 // For example, "foo" => ["f", "o", "o"]. |
6814 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringToArray) { | 6812 RUNTIME_FUNCTION(Object*, Runtime_StringToArray) { |
6815 HandleScope scope(isolate); | 6813 HandleScope scope(isolate); |
6816 ASSERT(args.length() == 2); | 6814 ASSERT(args.length() == 2); |
6817 CONVERT_ARG_HANDLE_CHECKED(String, s, 0); | 6815 CONVERT_ARG_HANDLE_CHECKED(String, s, 0); |
6818 CONVERT_NUMBER_CHECKED(uint32_t, limit, Uint32, args[1]); | 6816 CONVERT_NUMBER_CHECKED(uint32_t, limit, Uint32, args[1]); |
6819 | 6817 |
6820 s = String::Flatten(s); | 6818 s = String::Flatten(s); |
6821 const int length = static_cast<int>(Min<uint32_t>(s->length(), limit)); | 6819 const int length = static_cast<int>(Min<uint32_t>(s->length(), limit)); |
6822 | 6820 |
6823 Handle<FixedArray> elements; | 6821 Handle<FixedArray> elements; |
6824 int position = 0; | 6822 int position = 0; |
(...skipping 28 matching lines...) Expand all Loading... | |
6853 #ifdef DEBUG | 6851 #ifdef DEBUG |
6854 for (int i = 0; i < length; ++i) { | 6852 for (int i = 0; i < length; ++i) { |
6855 ASSERT(String::cast(elements->get(i))->length() == 1); | 6853 ASSERT(String::cast(elements->get(i))->length() == 1); |
6856 } | 6854 } |
6857 #endif | 6855 #endif |
6858 | 6856 |
6859 return *isolate->factory()->NewJSArrayWithElements(elements); | 6857 return *isolate->factory()->NewJSArrayWithElements(elements); |
6860 } | 6858 } |
6861 | 6859 |
6862 | 6860 |
6863 RUNTIME_FUNCTION(MaybeObject*, Runtime_NewStringWrapper) { | 6861 RUNTIME_FUNCTION(Object*, Runtime_NewStringWrapper) { |
6864 HandleScope scope(isolate); | 6862 HandleScope scope(isolate); |
6865 ASSERT(args.length() == 1); | 6863 ASSERT(args.length() == 1); |
6866 CONVERT_ARG_HANDLE_CHECKED(String, value, 0); | 6864 CONVERT_ARG_HANDLE_CHECKED(String, value, 0); |
6867 return *Object::ToObject(isolate, value).ToHandleChecked(); | 6865 return *Object::ToObject(isolate, value).ToHandleChecked(); |
6868 } | 6866 } |
6869 | 6867 |
6870 | 6868 |
6871 bool Runtime::IsUpperCaseChar(RuntimeState* runtime_state, uint16_t ch) { | 6869 bool Runtime::IsUpperCaseChar(RuntimeState* runtime_state, uint16_t ch) { |
6872 unibrow::uchar chars[unibrow::ToUppercase::kMaxWidth]; | 6870 unibrow::uchar chars[unibrow::ToUppercase::kMaxWidth]; |
6873 int char_length = runtime_state->to_upper_mapping()->get(ch, 0, chars); | 6871 int char_length = runtime_state->to_upper_mapping()->get(ch, 0, chars); |
6874 return char_length == 0; | 6872 return char_length == 0; |
6875 } | 6873 } |
6876 | 6874 |
6877 | 6875 |
6878 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_NumberToString) { | 6876 RUNTIME_FUNCTION(Object*, RuntimeHidden_NumberToString) { |
6879 HandleScope scope(isolate); | 6877 HandleScope scope(isolate); |
6880 ASSERT(args.length() == 1); | 6878 ASSERT(args.length() == 1); |
6881 CONVERT_NUMBER_ARG_HANDLE_CHECKED(number, 0); | 6879 CONVERT_NUMBER_ARG_HANDLE_CHECKED(number, 0); |
6882 | 6880 |
6883 return *isolate->factory()->NumberToString(number); | 6881 return *isolate->factory()->NumberToString(number); |
6884 } | 6882 } |
6885 | 6883 |
6886 | 6884 |
6887 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_NumberToStringSkipCache) { | 6885 RUNTIME_FUNCTION(Object*, RuntimeHidden_NumberToStringSkipCache) { |
6888 HandleScope scope(isolate); | 6886 HandleScope scope(isolate); |
6889 ASSERT(args.length() == 1); | 6887 ASSERT(args.length() == 1); |
6890 CONVERT_NUMBER_ARG_HANDLE_CHECKED(number, 0); | 6888 CONVERT_NUMBER_ARG_HANDLE_CHECKED(number, 0); |
6891 | 6889 |
6892 return *isolate->factory()->NumberToString(number, false); | 6890 return *isolate->factory()->NumberToString(number, false); |
6893 } | 6891 } |
6894 | 6892 |
6895 | 6893 |
6896 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToInteger) { | 6894 RUNTIME_FUNCTION(Object*, Runtime_NumberToInteger) { |
6897 HandleScope scope(isolate); | 6895 HandleScope scope(isolate); |
6898 ASSERT(args.length() == 1); | 6896 ASSERT(args.length() == 1); |
6899 | 6897 |
6900 CONVERT_DOUBLE_ARG_CHECKED(number, 0); | 6898 CONVERT_DOUBLE_ARG_CHECKED(number, 0); |
6901 return *isolate->factory()->NewNumber(DoubleToInteger(number)); | 6899 return *isolate->factory()->NewNumber(DoubleToInteger(number)); |
6902 } | 6900 } |
6903 | 6901 |
6904 | 6902 |
6905 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToIntegerMapMinusZero) { | 6903 RUNTIME_FUNCTION(Object*, Runtime_NumberToIntegerMapMinusZero) { |
6906 HandleScope scope(isolate); | 6904 HandleScope scope(isolate); |
6907 ASSERT(args.length() == 1); | 6905 ASSERT(args.length() == 1); |
6908 | 6906 |
6909 CONVERT_DOUBLE_ARG_CHECKED(number, 0); | 6907 CONVERT_DOUBLE_ARG_CHECKED(number, 0); |
6910 double double_value = DoubleToInteger(number); | 6908 double double_value = DoubleToInteger(number); |
6911 // Map both -0 and +0 to +0. | 6909 // Map both -0 and +0 to +0. |
6912 if (double_value == 0) double_value = 0; | 6910 if (double_value == 0) double_value = 0; |
6913 | 6911 |
6914 return *isolate->factory()->NewNumber(double_value); | 6912 return *isolate->factory()->NewNumber(double_value); |
6915 } | 6913 } |
6916 | 6914 |
6917 | 6915 |
6918 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToJSUint32) { | 6916 RUNTIME_FUNCTION(Object*, Runtime_NumberToJSUint32) { |
6919 HandleScope scope(isolate); | 6917 HandleScope scope(isolate); |
6920 ASSERT(args.length() == 1); | 6918 ASSERT(args.length() == 1); |
6921 | 6919 |
6922 CONVERT_NUMBER_CHECKED(int32_t, number, Uint32, args[0]); | 6920 CONVERT_NUMBER_CHECKED(int32_t, number, Uint32, args[0]); |
6923 return *isolate->factory()->NewNumberFromUint(number); | 6921 return *isolate->factory()->NewNumberFromUint(number); |
6924 } | 6922 } |
6925 | 6923 |
6926 | 6924 |
6927 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToJSInt32) { | 6925 RUNTIME_FUNCTION(Object*, Runtime_NumberToJSInt32) { |
6928 HandleScope scope(isolate); | 6926 HandleScope scope(isolate); |
6929 ASSERT(args.length() == 1); | 6927 ASSERT(args.length() == 1); |
6930 | 6928 |
6931 CONVERT_DOUBLE_ARG_CHECKED(number, 0); | 6929 CONVERT_DOUBLE_ARG_CHECKED(number, 0); |
6932 return *isolate->factory()->NewNumberFromInt(DoubleToInt32(number)); | 6930 return *isolate->factory()->NewNumberFromInt(DoubleToInt32(number)); |
6933 } | 6931 } |
6934 | 6932 |
6935 | 6933 |
6936 // Converts a Number to a Smi, if possible. Returns NaN if the number is not | 6934 // Converts a Number to a Smi, if possible. Returns NaN if the number is not |
6937 // a small integer. | 6935 // a small integer. |
6938 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_NumberToSmi) { | 6936 RUNTIME_FUNCTION(Object*, RuntimeHidden_NumberToSmi) { |
6939 SealHandleScope shs(isolate); | 6937 SealHandleScope shs(isolate); |
6940 ASSERT(args.length() == 1); | 6938 ASSERT(args.length() == 1); |
6941 CONVERT_ARG_CHECKED(Object, obj, 0); | 6939 CONVERT_ARG_CHECKED(Object, obj, 0); |
6942 if (obj->IsSmi()) { | 6940 if (obj->IsSmi()) { |
6943 return obj; | 6941 return obj; |
6944 } | 6942 } |
6945 if (obj->IsHeapNumber()) { | 6943 if (obj->IsHeapNumber()) { |
6946 double value = HeapNumber::cast(obj)->value(); | 6944 double value = HeapNumber::cast(obj)->value(); |
6947 int int_value = FastD2I(value); | 6945 int int_value = FastD2I(value); |
6948 if (value == FastI2D(int_value) && Smi::IsValid(int_value)) { | 6946 if (value == FastI2D(int_value) && Smi::IsValid(int_value)) { |
6949 return Smi::FromInt(int_value); | 6947 return Smi::FromInt(int_value); |
6950 } | 6948 } |
6951 } | 6949 } |
6952 return isolate->heap()->nan_value(); | 6950 return isolate->heap()->nan_value(); |
6953 } | 6951 } |
6954 | 6952 |
6955 | 6953 |
6956 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_AllocateHeapNumber) { | 6954 RUNTIME_FUNCTION(Object*, RuntimeHidden_AllocateHeapNumber) { |
6957 HandleScope scope(isolate); | 6955 HandleScope scope(isolate); |
6958 ASSERT(args.length() == 0); | 6956 ASSERT(args.length() == 0); |
6959 return *isolate->factory()->NewHeapNumber(0); | 6957 return *isolate->factory()->NewHeapNumber(0); |
6960 } | 6958 } |
6961 | 6959 |
6962 | 6960 |
6963 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberAdd) { | 6961 RUNTIME_FUNCTION(Object*, Runtime_NumberAdd) { |
6964 HandleScope scope(isolate); | 6962 HandleScope scope(isolate); |
6965 ASSERT(args.length() == 2); | 6963 ASSERT(args.length() == 2); |
6966 | 6964 |
6967 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 6965 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
6968 CONVERT_DOUBLE_ARG_CHECKED(y, 1); | 6966 CONVERT_DOUBLE_ARG_CHECKED(y, 1); |
6969 return *isolate->factory()->NewNumber(x + y); | 6967 return *isolate->factory()->NewNumber(x + y); |
6970 } | 6968 } |
6971 | 6969 |
6972 | 6970 |
6973 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberSub) { | 6971 RUNTIME_FUNCTION(Object*, Runtime_NumberSub) { |
6974 HandleScope scope(isolate); | 6972 HandleScope scope(isolate); |
6975 ASSERT(args.length() == 2); | 6973 ASSERT(args.length() == 2); |
6976 | 6974 |
6977 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 6975 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
6978 CONVERT_DOUBLE_ARG_CHECKED(y, 1); | 6976 CONVERT_DOUBLE_ARG_CHECKED(y, 1); |
6979 return *isolate->factory()->NewNumber(x - y); | 6977 return *isolate->factory()->NewNumber(x - y); |
6980 } | 6978 } |
6981 | 6979 |
6982 | 6980 |
6983 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberMul) { | 6981 RUNTIME_FUNCTION(Object*, Runtime_NumberMul) { |
6984 HandleScope scope(isolate); | 6982 HandleScope scope(isolate); |
6985 ASSERT(args.length() == 2); | 6983 ASSERT(args.length() == 2); |
6986 | 6984 |
6987 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 6985 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
6988 CONVERT_DOUBLE_ARG_CHECKED(y, 1); | 6986 CONVERT_DOUBLE_ARG_CHECKED(y, 1); |
6989 return *isolate->factory()->NewNumber(x * y); | 6987 return *isolate->factory()->NewNumber(x * y); |
6990 } | 6988 } |
6991 | 6989 |
6992 | 6990 |
6993 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberUnaryMinus) { | 6991 RUNTIME_FUNCTION(Object*, Runtime_NumberUnaryMinus) { |
6994 HandleScope scope(isolate); | 6992 HandleScope scope(isolate); |
6995 ASSERT(args.length() == 1); | 6993 ASSERT(args.length() == 1); |
6996 | 6994 |
6997 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 6995 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
6998 return *isolate->factory()->NewNumber(-x); | 6996 return *isolate->factory()->NewNumber(-x); |
6999 } | 6997 } |
7000 | 6998 |
7001 | 6999 |
7002 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberDiv) { | 7000 RUNTIME_FUNCTION(Object*, Runtime_NumberDiv) { |
7003 HandleScope scope(isolate); | 7001 HandleScope scope(isolate); |
7004 ASSERT(args.length() == 2); | 7002 ASSERT(args.length() == 2); |
7005 | 7003 |
7006 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7004 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
7007 CONVERT_DOUBLE_ARG_CHECKED(y, 1); | 7005 CONVERT_DOUBLE_ARG_CHECKED(y, 1); |
7008 return *isolate->factory()->NewNumber(x / y); | 7006 return *isolate->factory()->NewNumber(x / y); |
7009 } | 7007 } |
7010 | 7008 |
7011 | 7009 |
7012 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberMod) { | 7010 RUNTIME_FUNCTION(Object*, Runtime_NumberMod) { |
7013 HandleScope scope(isolate); | 7011 HandleScope scope(isolate); |
7014 ASSERT(args.length() == 2); | 7012 ASSERT(args.length() == 2); |
7015 | 7013 |
7016 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7014 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
7017 CONVERT_DOUBLE_ARG_CHECKED(y, 1); | 7015 CONVERT_DOUBLE_ARG_CHECKED(y, 1); |
7018 return *isolate->factory()->NewNumber(modulo(x, y)); | 7016 return *isolate->factory()->NewNumber(modulo(x, y)); |
7019 } | 7017 } |
7020 | 7018 |
7021 | 7019 |
7022 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberImul) { | 7020 RUNTIME_FUNCTION(Object*, Runtime_NumberImul) { |
7023 HandleScope scope(isolate); | 7021 HandleScope scope(isolate); |
7024 ASSERT(args.length() == 2); | 7022 ASSERT(args.length() == 2); |
7025 | 7023 |
7026 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); | 7024 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); |
7027 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); | 7025 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); |
7028 return *isolate->factory()->NewNumberFromInt(x * y); | 7026 return *isolate->factory()->NewNumberFromInt(x * y); |
7029 } | 7027 } |
7030 | 7028 |
7031 | 7029 |
7032 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_StringAdd) { | 7030 RUNTIME_FUNCTION(Object*, RuntimeHidden_StringAdd) { |
7033 HandleScope scope(isolate); | 7031 HandleScope scope(isolate); |
7034 ASSERT(args.length() == 2); | 7032 ASSERT(args.length() == 2); |
7035 CONVERT_ARG_HANDLE_CHECKED(String, str1, 0); | 7033 CONVERT_ARG_HANDLE_CHECKED(String, str1, 0); |
7036 CONVERT_ARG_HANDLE_CHECKED(String, str2, 1); | 7034 CONVERT_ARG_HANDLE_CHECKED(String, str2, 1); |
7037 isolate->counters()->string_add_runtime()->Increment(); | 7035 isolate->counters()->string_add_runtime()->Increment(); |
7038 Handle<String> result; | 7036 Handle<String> result; |
7039 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 7037 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
7040 isolate, result, isolate->factory()->NewConsString(str1, str2)); | 7038 isolate, result, isolate->factory()->NewConsString(str1, str2)); |
7041 return *result; | 7039 return *result; |
7042 } | 7040 } |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7130 } | 7128 } |
7131 if (increment > String::kMaxLength - position) { | 7129 if (increment > String::kMaxLength - position) { |
7132 return kMaxInt; // Provoke throw on allocation. | 7130 return kMaxInt; // Provoke throw on allocation. |
7133 } | 7131 } |
7134 position += increment; | 7132 position += increment; |
7135 } | 7133 } |
7136 return position; | 7134 return position; |
7137 } | 7135 } |
7138 | 7136 |
7139 | 7137 |
7140 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringBuilderConcat) { | 7138 RUNTIME_FUNCTION(Object*, Runtime_StringBuilderConcat) { |
7141 HandleScope scope(isolate); | 7139 HandleScope scope(isolate); |
7142 ASSERT(args.length() == 3); | 7140 ASSERT(args.length() == 3); |
7143 CONVERT_ARG_HANDLE_CHECKED(JSArray, array, 0); | 7141 CONVERT_ARG_HANDLE_CHECKED(JSArray, array, 0); |
7144 if (!args[1]->IsSmi()) return isolate->ThrowInvalidStringLength(); | 7142 if (!args[1]->IsSmi()) return isolate->ThrowInvalidStringLength(); |
7145 CONVERT_SMI_ARG_CHECKED(array_length, 1); | 7143 CONVERT_SMI_ARG_CHECKED(array_length, 1); |
7146 CONVERT_ARG_HANDLE_CHECKED(String, special, 2); | 7144 CONVERT_ARG_HANDLE_CHECKED(String, special, 2); |
7147 | 7145 |
7148 // This assumption is used by the slice encoding in one or two smis. | 7146 // This assumption is used by the slice encoding in one or two smis. |
7149 ASSERT(Smi::kMaxValue >= String::kMaxLength); | 7147 ASSERT(Smi::kMaxValue >= String::kMaxLength); |
7150 | 7148 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7195 isolate->factory()->NewRawTwoByteString(length)); | 7193 isolate->factory()->NewRawTwoByteString(length)); |
7196 StringBuilderConcatHelper(*special, | 7194 StringBuilderConcatHelper(*special, |
7197 answer->GetChars(), | 7195 answer->GetChars(), |
7198 FixedArray::cast(array->elements()), | 7196 FixedArray::cast(array->elements()), |
7199 array_length); | 7197 array_length); |
7200 return *answer; | 7198 return *answer; |
7201 } | 7199 } |
7202 } | 7200 } |
7203 | 7201 |
7204 | 7202 |
7205 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringBuilderJoin) { | 7203 RUNTIME_FUNCTION(Object*, Runtime_StringBuilderJoin) { |
7206 HandleScope scope(isolate); | 7204 HandleScope scope(isolate); |
7207 ASSERT(args.length() == 3); | 7205 ASSERT(args.length() == 3); |
7208 CONVERT_ARG_HANDLE_CHECKED(JSArray, array, 0); | 7206 CONVERT_ARG_HANDLE_CHECKED(JSArray, array, 0); |
7209 if (!args[1]->IsSmi()) return isolate->ThrowInvalidStringLength(); | 7207 if (!args[1]->IsSmi()) return isolate->ThrowInvalidStringLength(); |
7210 CONVERT_SMI_ARG_CHECKED(array_length, 1); | 7208 CONVERT_SMI_ARG_CHECKED(array_length, 1); |
7211 CONVERT_ARG_HANDLE_CHECKED(String, separator, 2); | 7209 CONVERT_ARG_HANDLE_CHECKED(String, separator, 2); |
7212 RUNTIME_ASSERT(array->HasFastObjectElements()); | 7210 RUNTIME_ASSERT(array->HasFastObjectElements()); |
7213 | 7211 |
7214 Handle<FixedArray> fixed_array(FixedArray::cast(array->elements())); | 7212 Handle<FixedArray> fixed_array(FixedArray::cast(array->elements())); |
7215 if (fixed_array->length() < array_length) { | 7213 if (fixed_array->length() < array_length) { |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7315 String::WriteToFlat<Char>(separator, &buffer[cursor], | 7313 String::WriteToFlat<Char>(separator, &buffer[cursor], |
7316 0, separator_length); | 7314 0, separator_length); |
7317 cursor += separator_length; | 7315 cursor += separator_length; |
7318 previous_separator_position++; | 7316 previous_separator_position++; |
7319 } | 7317 } |
7320 } | 7318 } |
7321 ASSERT(cursor <= buffer.length()); | 7319 ASSERT(cursor <= buffer.length()); |
7322 } | 7320 } |
7323 | 7321 |
7324 | 7322 |
7325 RUNTIME_FUNCTION(MaybeObject*, Runtime_SparseJoinWithSeparator) { | 7323 RUNTIME_FUNCTION(Object*, Runtime_SparseJoinWithSeparator) { |
7326 HandleScope scope(isolate); | 7324 HandleScope scope(isolate); |
7327 ASSERT(args.length() == 3); | 7325 ASSERT(args.length() == 3); |
7328 CONVERT_ARG_HANDLE_CHECKED(JSArray, elements_array, 0); | 7326 CONVERT_ARG_HANDLE_CHECKED(JSArray, elements_array, 0); |
7329 RUNTIME_ASSERT(elements_array->HasFastSmiOrObjectElements()); | 7327 RUNTIME_ASSERT(elements_array->HasFastSmiOrObjectElements()); |
7330 CONVERT_NUMBER_CHECKED(uint32_t, array_length, Uint32, args[1]); | 7328 CONVERT_NUMBER_CHECKED(uint32_t, array_length, Uint32, args[1]); |
7331 CONVERT_ARG_HANDLE_CHECKED(String, separator, 2); | 7329 CONVERT_ARG_HANDLE_CHECKED(String, separator, 2); |
7332 // elements_array is fast-mode JSarray of alternating positions | 7330 // elements_array is fast-mode JSarray of alternating positions |
7333 // (increasing order) and strings. | 7331 // (increasing order) and strings. |
7334 // array_length is length of original array (used to add separators); | 7332 // array_length is length of original array (used to add separators); |
7335 // separator is string to put between elements. Assumed to be non-empty. | 7333 // separator is string to put between elements. Assumed to be non-empty. |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7402 FixedArray::cast(elements_array->elements()), | 7400 FixedArray::cast(elements_array->elements()), |
7403 elements_length, | 7401 elements_length, |
7404 array_length, | 7402 array_length, |
7405 *separator, | 7403 *separator, |
7406 Vector<uc16>(result->GetChars(), string_length)); | 7404 Vector<uc16>(result->GetChars(), string_length)); |
7407 return *result; | 7405 return *result; |
7408 } | 7406 } |
7409 } | 7407 } |
7410 | 7408 |
7411 | 7409 |
7412 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberOr) { | 7410 RUNTIME_FUNCTION(Object*, Runtime_NumberOr) { |
7413 HandleScope scope(isolate); | 7411 HandleScope scope(isolate); |
7414 ASSERT(args.length() == 2); | 7412 ASSERT(args.length() == 2); |
7415 | 7413 |
7416 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); | 7414 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); |
7417 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); | 7415 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); |
7418 return *isolate->factory()->NewNumberFromInt(x | y); | 7416 return *isolate->factory()->NewNumberFromInt(x | y); |
7419 } | 7417 } |
7420 | 7418 |
7421 | 7419 |
7422 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberAnd) { | 7420 RUNTIME_FUNCTION(Object*, Runtime_NumberAnd) { |
7423 HandleScope scope(isolate); | 7421 HandleScope scope(isolate); |
7424 ASSERT(args.length() == 2); | 7422 ASSERT(args.length() == 2); |
7425 | 7423 |
7426 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); | 7424 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); |
7427 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); | 7425 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); |
7428 return *isolate->factory()->NewNumberFromInt(x & y); | 7426 return *isolate->factory()->NewNumberFromInt(x & y); |
7429 } | 7427 } |
7430 | 7428 |
7431 | 7429 |
7432 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberXor) { | 7430 RUNTIME_FUNCTION(Object*, Runtime_NumberXor) { |
7433 HandleScope scope(isolate); | 7431 HandleScope scope(isolate); |
7434 ASSERT(args.length() == 2); | 7432 ASSERT(args.length() == 2); |
7435 | 7433 |
7436 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); | 7434 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); |
7437 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); | 7435 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); |
7438 return *isolate->factory()->NewNumberFromInt(x ^ y); | 7436 return *isolate->factory()->NewNumberFromInt(x ^ y); |
7439 } | 7437 } |
7440 | 7438 |
7441 | 7439 |
7442 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberShl) { | 7440 RUNTIME_FUNCTION(Object*, Runtime_NumberShl) { |
7443 HandleScope scope(isolate); | 7441 HandleScope scope(isolate); |
7444 ASSERT(args.length() == 2); | 7442 ASSERT(args.length() == 2); |
7445 | 7443 |
7446 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); | 7444 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); |
7447 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); | 7445 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); |
7448 return *isolate->factory()->NewNumberFromInt(x << (y & 0x1f)); | 7446 return *isolate->factory()->NewNumberFromInt(x << (y & 0x1f)); |
7449 } | 7447 } |
7450 | 7448 |
7451 | 7449 |
7452 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberShr) { | 7450 RUNTIME_FUNCTION(Object*, Runtime_NumberShr) { |
7453 HandleScope scope(isolate); | 7451 HandleScope scope(isolate); |
7454 ASSERT(args.length() == 2); | 7452 ASSERT(args.length() == 2); |
7455 | 7453 |
7456 CONVERT_NUMBER_CHECKED(uint32_t, x, Uint32, args[0]); | 7454 CONVERT_NUMBER_CHECKED(uint32_t, x, Uint32, args[0]); |
7457 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); | 7455 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); |
7458 return *isolate->factory()->NewNumberFromUint(x >> (y & 0x1f)); | 7456 return *isolate->factory()->NewNumberFromUint(x >> (y & 0x1f)); |
7459 } | 7457 } |
7460 | 7458 |
7461 | 7459 |
7462 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberSar) { | 7460 RUNTIME_FUNCTION(Object*, Runtime_NumberSar) { |
7463 HandleScope scope(isolate); | 7461 HandleScope scope(isolate); |
7464 ASSERT(args.length() == 2); | 7462 ASSERT(args.length() == 2); |
7465 | 7463 |
7466 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); | 7464 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); |
7467 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); | 7465 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); |
7468 return *isolate->factory()->NewNumberFromInt( | 7466 return *isolate->factory()->NewNumberFromInt( |
7469 ArithmeticShiftRight(x, y & 0x1f)); | 7467 ArithmeticShiftRight(x, y & 0x1f)); |
7470 } | 7468 } |
7471 | 7469 |
7472 | 7470 |
7473 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberEquals) { | 7471 RUNTIME_FUNCTION(Object*, Runtime_NumberEquals) { |
7474 SealHandleScope shs(isolate); | 7472 SealHandleScope shs(isolate); |
7475 ASSERT(args.length() == 2); | 7473 ASSERT(args.length() == 2); |
7476 | 7474 |
7477 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7475 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
7478 CONVERT_DOUBLE_ARG_CHECKED(y, 1); | 7476 CONVERT_DOUBLE_ARG_CHECKED(y, 1); |
7479 if (std::isnan(x)) return Smi::FromInt(NOT_EQUAL); | 7477 if (std::isnan(x)) return Smi::FromInt(NOT_EQUAL); |
7480 if (std::isnan(y)) return Smi::FromInt(NOT_EQUAL); | 7478 if (std::isnan(y)) return Smi::FromInt(NOT_EQUAL); |
7481 if (x == y) return Smi::FromInt(EQUAL); | 7479 if (x == y) return Smi::FromInt(EQUAL); |
7482 Object* result; | 7480 Object* result; |
7483 if ((fpclassify(x) == FP_ZERO) && (fpclassify(y) == FP_ZERO)) { | 7481 if ((fpclassify(x) == FP_ZERO) && (fpclassify(y) == FP_ZERO)) { |
7484 result = Smi::FromInt(EQUAL); | 7482 result = Smi::FromInt(EQUAL); |
7485 } else { | 7483 } else { |
7486 result = Smi::FromInt(NOT_EQUAL); | 7484 result = Smi::FromInt(NOT_EQUAL); |
7487 } | 7485 } |
7488 return result; | 7486 return result; |
7489 } | 7487 } |
7490 | 7488 |
7491 | 7489 |
7492 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringEquals) { | 7490 RUNTIME_FUNCTION(Object*, Runtime_StringEquals) { |
7493 HandleScope handle_scope(isolate); | 7491 HandleScope handle_scope(isolate); |
7494 ASSERT(args.length() == 2); | 7492 ASSERT(args.length() == 2); |
7495 | 7493 |
7496 CONVERT_ARG_HANDLE_CHECKED(String, x, 0); | 7494 CONVERT_ARG_HANDLE_CHECKED(String, x, 0); |
7497 CONVERT_ARG_HANDLE_CHECKED(String, y, 1); | 7495 CONVERT_ARG_HANDLE_CHECKED(String, y, 1); |
7498 | 7496 |
7499 bool not_equal = !String::Equals(x, y); | 7497 bool not_equal = !String::Equals(x, y); |
7500 // This is slightly convoluted because the value that signifies | 7498 // This is slightly convoluted because the value that signifies |
7501 // equality is 0 and inequality is 1 so we have to negate the result | 7499 // equality is 0 and inequality is 1 so we have to negate the result |
7502 // from String::Equals. | 7500 // from String::Equals. |
7503 ASSERT(not_equal == 0 || not_equal == 1); | 7501 ASSERT(not_equal == 0 || not_equal == 1); |
7504 STATIC_CHECK(EQUAL == 0); | 7502 STATIC_CHECK(EQUAL == 0); |
7505 STATIC_CHECK(NOT_EQUAL == 1); | 7503 STATIC_CHECK(NOT_EQUAL == 1); |
7506 return Smi::FromInt(not_equal); | 7504 return Smi::FromInt(not_equal); |
7507 } | 7505 } |
7508 | 7506 |
7509 | 7507 |
7510 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberCompare) { | 7508 RUNTIME_FUNCTION(Object*, Runtime_NumberCompare) { |
7511 SealHandleScope shs(isolate); | 7509 SealHandleScope shs(isolate); |
7512 ASSERT(args.length() == 3); | 7510 ASSERT(args.length() == 3); |
7513 | 7511 |
7514 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7512 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
7515 CONVERT_DOUBLE_ARG_CHECKED(y, 1); | 7513 CONVERT_DOUBLE_ARG_CHECKED(y, 1); |
7516 if (std::isnan(x) || std::isnan(y)) return args[2]; | 7514 if (std::isnan(x) || std::isnan(y)) return args[2]; |
7517 if (x == y) return Smi::FromInt(EQUAL); | 7515 if (x == y) return Smi::FromInt(EQUAL); |
7518 if (isless(x, y)) return Smi::FromInt(LESS); | 7516 if (isless(x, y)) return Smi::FromInt(LESS); |
7519 return Smi::FromInt(GREATER); | 7517 return Smi::FromInt(GREATER); |
7520 } | 7518 } |
7521 | 7519 |
7522 | 7520 |
7523 // Compare two Smis as if they were converted to strings and then | 7521 // Compare two Smis as if they were converted to strings and then |
7524 // compared lexicographically. | 7522 // compared lexicographically. |
7525 RUNTIME_FUNCTION(MaybeObject*, Runtime_SmiLexicographicCompare) { | 7523 RUNTIME_FUNCTION(Object*, Runtime_SmiLexicographicCompare) { |
7526 SealHandleScope shs(isolate); | 7524 SealHandleScope shs(isolate); |
7527 ASSERT(args.length() == 2); | 7525 ASSERT(args.length() == 2); |
7528 CONVERT_SMI_ARG_CHECKED(x_value, 0); | 7526 CONVERT_SMI_ARG_CHECKED(x_value, 0); |
7529 CONVERT_SMI_ARG_CHECKED(y_value, 1); | 7527 CONVERT_SMI_ARG_CHECKED(y_value, 1); |
7530 | 7528 |
7531 // If the integers are equal so are the string representations. | 7529 // If the integers are equal so are the string representations. |
7532 if (x_value == y_value) return Smi::FromInt(EQUAL); | 7530 if (x_value == y_value) return Smi::FromInt(EQUAL); |
7533 | 7531 |
7534 // If one of the integers is zero the normal integer order is the | 7532 // If one of the integers is zero the normal integer order is the |
7535 // same as the lexicographic order of the string representations. | 7533 // same as the lexicographic order of the string representations. |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7590 x_scaled /= 10; | 7588 x_scaled /= 10; |
7591 tie = GREATER; | 7589 tie = GREATER; |
7592 } | 7590 } |
7593 | 7591 |
7594 if (x_scaled < y_scaled) return Smi::FromInt(LESS); | 7592 if (x_scaled < y_scaled) return Smi::FromInt(LESS); |
7595 if (x_scaled > y_scaled) return Smi::FromInt(GREATER); | 7593 if (x_scaled > y_scaled) return Smi::FromInt(GREATER); |
7596 return Smi::FromInt(tie); | 7594 return Smi::FromInt(tie); |
7597 } | 7595 } |
7598 | 7596 |
7599 | 7597 |
7600 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_StringCompare) { | 7598 RUNTIME_FUNCTION(Object*, RuntimeHidden_StringCompare) { |
7601 HandleScope handle_scope(isolate); | 7599 HandleScope handle_scope(isolate); |
7602 ASSERT(args.length() == 2); | 7600 ASSERT(args.length() == 2); |
7603 | 7601 |
7604 CONVERT_ARG_HANDLE_CHECKED(String, x, 0); | 7602 CONVERT_ARG_HANDLE_CHECKED(String, x, 0); |
7605 CONVERT_ARG_HANDLE_CHECKED(String, y, 1); | 7603 CONVERT_ARG_HANDLE_CHECKED(String, y, 1); |
7606 | 7604 |
7607 isolate->counters()->string_compare_runtime()->Increment(); | 7605 isolate->counters()->string_compare_runtime()->Increment(); |
7608 | 7606 |
7609 // A few fast case tests before we flatten. | 7607 // A few fast case tests before we flatten. |
7610 if (x.is_identical_to(y)) return Smi::FromInt(EQUAL); | 7608 if (x.is_identical_to(y)) return Smi::FromInt(EQUAL); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7658 if (r == 0) { | 7656 if (r == 0) { |
7659 result = equal_prefix_result; | 7657 result = equal_prefix_result; |
7660 } else { | 7658 } else { |
7661 result = (r < 0) ? Smi::FromInt(LESS) : Smi::FromInt(GREATER); | 7659 result = (r < 0) ? Smi::FromInt(LESS) : Smi::FromInt(GREATER); |
7662 } | 7660 } |
7663 return result; | 7661 return result; |
7664 } | 7662 } |
7665 | 7663 |
7666 | 7664 |
7667 #define RUNTIME_UNARY_MATH(Name, name) \ | 7665 #define RUNTIME_UNARY_MATH(Name, name) \ |
7668 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math##Name) { \ | 7666 RUNTIME_FUNCTION(Object*, Runtime_Math##Name) { \ |
7669 HandleScope scope(isolate); \ | 7667 HandleScope scope(isolate); \ |
7670 ASSERT(args.length() == 1); \ | 7668 ASSERT(args.length() == 1); \ |
7671 isolate->counters()->math_##name()->Increment(); \ | 7669 isolate->counters()->math_##name()->Increment(); \ |
7672 CONVERT_DOUBLE_ARG_CHECKED(x, 0); \ | 7670 CONVERT_DOUBLE_ARG_CHECKED(x, 0); \ |
7673 return *isolate->factory()->NewHeapNumber(std::name(x)); \ | 7671 return *isolate->factory()->NewHeapNumber(std::name(x)); \ |
7674 } | 7672 } |
7675 | 7673 |
7676 RUNTIME_UNARY_MATH(Acos, acos) | 7674 RUNTIME_UNARY_MATH(Acos, acos) |
7677 RUNTIME_UNARY_MATH(Asin, asin) | 7675 RUNTIME_UNARY_MATH(Asin, asin) |
7678 RUNTIME_UNARY_MATH(Atan, atan) | 7676 RUNTIME_UNARY_MATH(Atan, atan) |
7679 RUNTIME_UNARY_MATH(Log, log) | 7677 RUNTIME_UNARY_MATH(Log, log) |
7680 #undef RUNTIME_UNARY_MATH | 7678 #undef RUNTIME_UNARY_MATH |
7681 | 7679 |
7682 | 7680 |
7683 RUNTIME_FUNCTION(MaybeObject*, Runtime_DoubleHi) { | 7681 RUNTIME_FUNCTION(Object*, Runtime_DoubleHi) { |
7684 HandleScope scope(isolate); | 7682 HandleScope scope(isolate); |
7685 ASSERT(args.length() == 1); | 7683 ASSERT(args.length() == 1); |
7686 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7684 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
7687 uint64_t integer = double_to_uint64(x); | 7685 uint64_t integer = double_to_uint64(x); |
7688 integer = (integer >> 32) & 0xFFFFFFFFu; | 7686 integer = (integer >> 32) & 0xFFFFFFFFu; |
7689 return *isolate->factory()->NewNumber(static_cast<int32_t>(integer)); | 7687 return *isolate->factory()->NewNumber(static_cast<int32_t>(integer)); |
7690 } | 7688 } |
7691 | 7689 |
7692 | 7690 |
7693 RUNTIME_FUNCTION(MaybeObject*, Runtime_DoubleLo) { | 7691 RUNTIME_FUNCTION(Object*, Runtime_DoubleLo) { |
7694 HandleScope scope(isolate); | 7692 HandleScope scope(isolate); |
7695 ASSERT(args.length() == 1); | 7693 ASSERT(args.length() == 1); |
7696 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7694 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
7697 return *isolate->factory()->NewNumber( | 7695 return *isolate->factory()->NewNumber( |
7698 static_cast<int32_t>(double_to_uint64(x) & 0xFFFFFFFFu)); | 7696 static_cast<int32_t>(double_to_uint64(x) & 0xFFFFFFFFu)); |
7699 } | 7697 } |
7700 | 7698 |
7701 | 7699 |
7702 RUNTIME_FUNCTION(MaybeObject*, Runtime_ConstructDouble) { | 7700 RUNTIME_FUNCTION(Object*, Runtime_ConstructDouble) { |
7703 HandleScope scope(isolate); | 7701 HandleScope scope(isolate); |
7704 ASSERT(args.length() == 2); | 7702 ASSERT(args.length() == 2); |
7705 CONVERT_NUMBER_CHECKED(uint32_t, hi, Uint32, args[0]); | 7703 CONVERT_NUMBER_CHECKED(uint32_t, hi, Uint32, args[0]); |
7706 CONVERT_NUMBER_CHECKED(uint32_t, lo, Uint32, args[1]); | 7704 CONVERT_NUMBER_CHECKED(uint32_t, lo, Uint32, args[1]); |
7707 uint64_t result = (static_cast<uint64_t>(hi) << 32) | lo; | 7705 uint64_t result = (static_cast<uint64_t>(hi) << 32) | lo; |
7708 return *isolate->factory()->NewNumber(uint64_to_double(result)); | 7706 return *isolate->factory()->NewNumber(uint64_to_double(result)); |
7709 } | 7707 } |
7710 | 7708 |
7711 | 7709 |
7712 static const double kPiDividedBy4 = 0.78539816339744830962; | 7710 static const double kPiDividedBy4 = 0.78539816339744830962; |
7713 | 7711 |
7714 | 7712 |
7715 RUNTIME_FUNCTION(MaybeObject*, Runtime_MathAtan2) { | 7713 RUNTIME_FUNCTION(Object*, Runtime_MathAtan2) { |
7716 HandleScope scope(isolate); | 7714 HandleScope scope(isolate); |
7717 ASSERT(args.length() == 2); | 7715 ASSERT(args.length() == 2); |
7718 isolate->counters()->math_atan2()->Increment(); | 7716 isolate->counters()->math_atan2()->Increment(); |
7719 | 7717 |
7720 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7718 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
7721 CONVERT_DOUBLE_ARG_CHECKED(y, 1); | 7719 CONVERT_DOUBLE_ARG_CHECKED(y, 1); |
7722 double result; | 7720 double result; |
7723 if (std::isinf(x) && std::isinf(y)) { | 7721 if (std::isinf(x) && std::isinf(y)) { |
7724 // Make sure that the result in case of two infinite arguments | 7722 // Make sure that the result in case of two infinite arguments |
7725 // is a multiple of Pi / 4. The sign of the result is determined | 7723 // is a multiple of Pi / 4. The sign of the result is determined |
7726 // by the first argument (x) and the sign of the second argument | 7724 // by the first argument (x) and the sign of the second argument |
7727 // determines the multiplier: one or three. | 7725 // determines the multiplier: one or three. |
7728 int multiplier = (x < 0) ? -1 : 1; | 7726 int multiplier = (x < 0) ? -1 : 1; |
7729 if (y < 0) multiplier *= 3; | 7727 if (y < 0) multiplier *= 3; |
7730 result = multiplier * kPiDividedBy4; | 7728 result = multiplier * kPiDividedBy4; |
7731 } else { | 7729 } else { |
7732 result = std::atan2(x, y); | 7730 result = std::atan2(x, y); |
7733 } | 7731 } |
7734 return *isolate->factory()->NewNumber(result); | 7732 return *isolate->factory()->NewNumber(result); |
7735 } | 7733 } |
7736 | 7734 |
7737 | 7735 |
7738 RUNTIME_FUNCTION(MaybeObject*, Runtime_MathExp) { | 7736 RUNTIME_FUNCTION(Object*, Runtime_MathExp) { |
7739 HandleScope scope(isolate); | 7737 HandleScope scope(isolate); |
7740 ASSERT(args.length() == 1); | 7738 ASSERT(args.length() == 1); |
7741 isolate->counters()->math_exp()->Increment(); | 7739 isolate->counters()->math_exp()->Increment(); |
7742 | 7740 |
7743 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7741 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
7744 lazily_initialize_fast_exp(); | 7742 lazily_initialize_fast_exp(); |
7745 return *isolate->factory()->NewNumber(fast_exp(x)); | 7743 return *isolate->factory()->NewNumber(fast_exp(x)); |
7746 } | 7744 } |
7747 | 7745 |
7748 | 7746 |
7749 RUNTIME_FUNCTION(MaybeObject*, Runtime_MathFloor) { | 7747 RUNTIME_FUNCTION(Object*, Runtime_MathFloor) { |
7750 HandleScope scope(isolate); | 7748 HandleScope scope(isolate); |
7751 ASSERT(args.length() == 1); | 7749 ASSERT(args.length() == 1); |
7752 isolate->counters()->math_floor()->Increment(); | 7750 isolate->counters()->math_floor()->Increment(); |
7753 | 7751 |
7754 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7752 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
7755 return *isolate->factory()->NewNumber(std::floor(x)); | 7753 return *isolate->factory()->NewNumber(std::floor(x)); |
7756 } | 7754 } |
7757 | 7755 |
7758 | 7756 |
7759 // Slow version of Math.pow. We check for fast paths for special cases. | 7757 // Slow version of Math.pow. We check for fast paths for special cases. |
7760 // Used if SSE2/VFP3 is not available. | 7758 // Used if SSE2/VFP3 is not available. |
7761 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_MathPowSlow) { | 7759 RUNTIME_FUNCTION(Object*, RuntimeHidden_MathPowSlow) { |
7762 HandleScope scope(isolate); | 7760 HandleScope scope(isolate); |
7763 ASSERT(args.length() == 2); | 7761 ASSERT(args.length() == 2); |
7764 isolate->counters()->math_pow()->Increment(); | 7762 isolate->counters()->math_pow()->Increment(); |
7765 | 7763 |
7766 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7764 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
7767 | 7765 |
7768 // If the second argument is a smi, it is much faster to call the | 7766 // If the second argument is a smi, it is much faster to call the |
7769 // custom powi() function than the generic pow(). | 7767 // custom powi() function than the generic pow(). |
7770 if (args[1]->IsSmi()) { | 7768 if (args[1]->IsSmi()) { |
7771 int y = args.smi_at(1); | 7769 int y = args.smi_at(1); |
7772 return *isolate->factory()->NewNumber(power_double_int(x, y)); | 7770 return *isolate->factory()->NewNumber(power_double_int(x, y)); |
7773 } | 7771 } |
7774 | 7772 |
7775 CONVERT_DOUBLE_ARG_CHECKED(y, 1); | 7773 CONVERT_DOUBLE_ARG_CHECKED(y, 1); |
7776 double result = power_helper(x, y); | 7774 double result = power_helper(x, y); |
7777 if (std::isnan(result)) return isolate->heap()->nan_value(); | 7775 if (std::isnan(result)) return isolate->heap()->nan_value(); |
7778 return *isolate->factory()->NewNumber(result); | 7776 return *isolate->factory()->NewNumber(result); |
7779 } | 7777 } |
7780 | 7778 |
7781 | 7779 |
7782 // Fast version of Math.pow if we know that y is not an integer and y is not | 7780 // Fast version of Math.pow if we know that y is not an integer and y is not |
7783 // -0.5 or 0.5. Used as slow case from full codegen. | 7781 // -0.5 or 0.5. Used as slow case from full codegen. |
7784 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_MathPow) { | 7782 RUNTIME_FUNCTION(Object*, RuntimeHidden_MathPow) { |
7785 HandleScope scope(isolate); | 7783 HandleScope scope(isolate); |
7786 ASSERT(args.length() == 2); | 7784 ASSERT(args.length() == 2); |
7787 isolate->counters()->math_pow()->Increment(); | 7785 isolate->counters()->math_pow()->Increment(); |
7788 | 7786 |
7789 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7787 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
7790 CONVERT_DOUBLE_ARG_CHECKED(y, 1); | 7788 CONVERT_DOUBLE_ARG_CHECKED(y, 1); |
7791 if (y == 0) { | 7789 if (y == 0) { |
7792 return Smi::FromInt(1); | 7790 return Smi::FromInt(1); |
7793 } else { | 7791 } else { |
7794 double result = power_double_double(x, y); | 7792 double result = power_double_double(x, y); |
7795 if (std::isnan(result)) return isolate->heap()->nan_value(); | 7793 if (std::isnan(result)) return isolate->heap()->nan_value(); |
7796 return *isolate->factory()->NewNumber(result); | 7794 return *isolate->factory()->NewNumber(result); |
7797 } | 7795 } |
7798 } | 7796 } |
7799 | 7797 |
7800 | 7798 |
7801 RUNTIME_FUNCTION(MaybeObject*, Runtime_RoundNumber) { | 7799 RUNTIME_FUNCTION(Object*, Runtime_RoundNumber) { |
7802 HandleScope scope(isolate); | 7800 HandleScope scope(isolate); |
7803 ASSERT(args.length() == 1); | 7801 ASSERT(args.length() == 1); |
7804 isolate->counters()->math_round()->Increment(); | 7802 isolate->counters()->math_round()->Increment(); |
7805 | 7803 |
7806 if (!args[0]->IsHeapNumber()) { | 7804 if (!args[0]->IsHeapNumber()) { |
7807 // Must be smi. Return the argument unchanged for all the other types | 7805 // Must be smi. Return the argument unchanged for all the other types |
7808 // to make fuzz-natives test happy. | 7806 // to make fuzz-natives test happy. |
7809 return args[0]; | 7807 return args[0]; |
7810 } | 7808 } |
7811 | 7809 |
(...skipping 22 matching lines...) Expand all Loading... | |
7834 return number; | 7832 return number; |
7835 } | 7833 } |
7836 | 7834 |
7837 if (sign && value >= -0.5) return isolate->heap()->minus_zero_value(); | 7835 if (sign && value >= -0.5) return isolate->heap()->minus_zero_value(); |
7838 | 7836 |
7839 // Do not call NumberFromDouble() to avoid extra checks. | 7837 // Do not call NumberFromDouble() to avoid extra checks. |
7840 return *isolate->factory()->NewNumber(std::floor(value + 0.5)); | 7838 return *isolate->factory()->NewNumber(std::floor(value + 0.5)); |
7841 } | 7839 } |
7842 | 7840 |
7843 | 7841 |
7844 RUNTIME_FUNCTION(MaybeObject*, Runtime_MathSqrt) { | 7842 RUNTIME_FUNCTION(Object*, Runtime_MathSqrt) { |
7845 HandleScope scope(isolate); | 7843 HandleScope scope(isolate); |
7846 ASSERT(args.length() == 1); | 7844 ASSERT(args.length() == 1); |
7847 isolate->counters()->math_sqrt()->Increment(); | 7845 isolate->counters()->math_sqrt()->Increment(); |
7848 | 7846 |
7849 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7847 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
7850 return *isolate->factory()->NewNumber(fast_sqrt(x)); | 7848 return *isolate->factory()->NewNumber(fast_sqrt(x)); |
7851 } | 7849 } |
7852 | 7850 |
7853 | 7851 |
7854 RUNTIME_FUNCTION(MaybeObject*, Runtime_MathFround) { | 7852 RUNTIME_FUNCTION(Object*, Runtime_MathFround) { |
7855 HandleScope scope(isolate); | 7853 HandleScope scope(isolate); |
7856 ASSERT(args.length() == 1); | 7854 ASSERT(args.length() == 1); |
7857 | 7855 |
7858 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7856 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
7859 float xf = static_cast<float>(x); | 7857 float xf = static_cast<float>(x); |
7860 return *isolate->factory()->NewNumber(xf); | 7858 return *isolate->factory()->NewNumber(xf); |
7861 } | 7859 } |
7862 | 7860 |
7863 | 7861 |
7864 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateMakeDay) { | 7862 RUNTIME_FUNCTION(Object*, Runtime_DateMakeDay) { |
7865 SealHandleScope shs(isolate); | 7863 SealHandleScope shs(isolate); |
7866 ASSERT(args.length() == 2); | 7864 ASSERT(args.length() == 2); |
7867 | 7865 |
7868 CONVERT_SMI_ARG_CHECKED(year, 0); | 7866 CONVERT_SMI_ARG_CHECKED(year, 0); |
7869 CONVERT_SMI_ARG_CHECKED(month, 1); | 7867 CONVERT_SMI_ARG_CHECKED(month, 1); |
7870 | 7868 |
7871 return Smi::FromInt(isolate->date_cache()->DaysFromYearMonth(year, month)); | 7869 return Smi::FromInt(isolate->date_cache()->DaysFromYearMonth(year, month)); |
7872 } | 7870 } |
7873 | 7871 |
7874 | 7872 |
7875 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateSetValue) { | 7873 RUNTIME_FUNCTION(Object*, Runtime_DateSetValue) { |
7876 HandleScope scope(isolate); | 7874 HandleScope scope(isolate); |
7877 ASSERT(args.length() == 3); | 7875 ASSERT(args.length() == 3); |
7878 | 7876 |
7879 CONVERT_ARG_HANDLE_CHECKED(JSDate, date, 0); | 7877 CONVERT_ARG_HANDLE_CHECKED(JSDate, date, 0); |
7880 CONVERT_DOUBLE_ARG_CHECKED(time, 1); | 7878 CONVERT_DOUBLE_ARG_CHECKED(time, 1); |
7881 CONVERT_SMI_ARG_CHECKED(is_utc, 2); | 7879 CONVERT_SMI_ARG_CHECKED(is_utc, 2); |
7882 | 7880 |
7883 DateCache* date_cache = isolate->date_cache(); | 7881 DateCache* date_cache = isolate->date_cache(); |
7884 | 7882 |
7885 Handle<Object> value;; | 7883 Handle<Object> value;; |
(...skipping 14 matching lines...) Expand all Loading... | |
7900 is_value_nan = true; | 7898 is_value_nan = true; |
7901 } else { | 7899 } else { |
7902 value = isolate->factory()->NewNumber(DoubleToInteger(time)); | 7900 value = isolate->factory()->NewNumber(DoubleToInteger(time)); |
7903 } | 7901 } |
7904 } | 7902 } |
7905 date->SetValue(*value, is_value_nan); | 7903 date->SetValue(*value, is_value_nan); |
7906 return *value; | 7904 return *value; |
7907 } | 7905 } |
7908 | 7906 |
7909 | 7907 |
7910 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_NewArgumentsFast) { | 7908 RUNTIME_FUNCTION(Object*, RuntimeHidden_NewArgumentsFast) { |
7911 HandleScope scope(isolate); | 7909 HandleScope scope(isolate); |
7912 ASSERT(args.length() == 3); | 7910 ASSERT(args.length() == 3); |
7913 | 7911 |
7914 CONVERT_ARG_HANDLE_CHECKED(JSFunction, callee, 0); | 7912 CONVERT_ARG_HANDLE_CHECKED(JSFunction, callee, 0); |
7915 Object** parameters = reinterpret_cast<Object**>(args[1]); | 7913 Object** parameters = reinterpret_cast<Object**>(args[1]); |
7916 CONVERT_SMI_ARG_CHECKED(argument_count, 2); | 7914 CONVERT_SMI_ARG_CHECKED(argument_count, 2); |
7917 | 7915 |
7918 Handle<JSObject> result = | 7916 Handle<JSObject> result = |
7919 isolate->factory()->NewArgumentsObject(callee, argument_count); | 7917 isolate->factory()->NewArgumentsObject(callee, argument_count); |
7920 // Allocate the elements if needed. | 7918 // Allocate the elements if needed. |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7994 result->set_elements(*elements); | 7992 result->set_elements(*elements); |
7995 for (int i = 0; i < argument_count; ++i) { | 7993 for (int i = 0; i < argument_count; ++i) { |
7996 elements->set(i, *(parameters - i - 1)); | 7994 elements->set(i, *(parameters - i - 1)); |
7997 } | 7995 } |
7998 } | 7996 } |
7999 } | 7997 } |
8000 return *result; | 7998 return *result; |
8001 } | 7999 } |
8002 | 8000 |
8003 | 8001 |
8004 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_NewStrictArgumentsFast) { | 8002 RUNTIME_FUNCTION(Object*, RuntimeHidden_NewStrictArgumentsFast) { |
8005 HandleScope scope(isolate); | 8003 HandleScope scope(isolate); |
8006 ASSERT(args.length() == 3); | 8004 ASSERT(args.length() == 3); |
8007 CONVERT_ARG_HANDLE_CHECKED(JSFunction, callee, 0) | 8005 CONVERT_ARG_HANDLE_CHECKED(JSFunction, callee, 0) |
8008 Object** parameters = reinterpret_cast<Object**>(args[1]); | 8006 Object** parameters = reinterpret_cast<Object**>(args[1]); |
8009 CONVERT_SMI_ARG_CHECKED(length, 2); | 8007 CONVERT_SMI_ARG_CHECKED(length, 2); |
8010 | 8008 |
8011 Handle<JSObject> result = | 8009 Handle<JSObject> result = |
8012 isolate->factory()->NewArgumentsObject(callee, length); | 8010 isolate->factory()->NewArgumentsObject(callee, length); |
8013 | 8011 |
8014 if (length > 0) { | 8012 if (length > 0) { |
8015 Handle<FixedArray> array = | 8013 Handle<FixedArray> array = |
8016 isolate->factory()->NewUninitializedFixedArray(length); | 8014 isolate->factory()->NewUninitializedFixedArray(length); |
8017 DisallowHeapAllocation no_gc; | 8015 DisallowHeapAllocation no_gc; |
8018 WriteBarrierMode mode = array->GetWriteBarrierMode(no_gc); | 8016 WriteBarrierMode mode = array->GetWriteBarrierMode(no_gc); |
8019 for (int i = 0; i < length; i++) { | 8017 for (int i = 0; i < length; i++) { |
8020 array->set(i, *--parameters, mode); | 8018 array->set(i, *--parameters, mode); |
8021 } | 8019 } |
8022 result->set_elements(*array); | 8020 result->set_elements(*array); |
8023 } | 8021 } |
8024 return *result; | 8022 return *result; |
8025 } | 8023 } |
8026 | 8024 |
8027 | 8025 |
8028 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_NewClosureFromStubFailure) { | 8026 RUNTIME_FUNCTION(Object*, RuntimeHidden_NewClosureFromStubFailure) { |
8029 HandleScope scope(isolate); | 8027 HandleScope scope(isolate); |
8030 ASSERT(args.length() == 1); | 8028 ASSERT(args.length() == 1); |
8031 CONVERT_ARG_HANDLE_CHECKED(SharedFunctionInfo, shared, 0); | 8029 CONVERT_ARG_HANDLE_CHECKED(SharedFunctionInfo, shared, 0); |
8032 Handle<Context> context(isolate->context()); | 8030 Handle<Context> context(isolate->context()); |
8033 PretenureFlag pretenure_flag = NOT_TENURED; | 8031 PretenureFlag pretenure_flag = NOT_TENURED; |
8034 return *isolate->factory()->NewFunctionFromSharedFunctionInfo( | 8032 return *isolate->factory()->NewFunctionFromSharedFunctionInfo( |
8035 shared, context, pretenure_flag); | 8033 shared, context, pretenure_flag); |
8036 } | 8034 } |
8037 | 8035 |
8038 | 8036 |
8039 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_NewClosure) { | 8037 RUNTIME_FUNCTION(Object*, RuntimeHidden_NewClosure) { |
8040 HandleScope scope(isolate); | 8038 HandleScope scope(isolate); |
8041 ASSERT(args.length() == 3); | 8039 ASSERT(args.length() == 3); |
8042 CONVERT_ARG_HANDLE_CHECKED(Context, context, 0); | 8040 CONVERT_ARG_HANDLE_CHECKED(Context, context, 0); |
8043 CONVERT_ARG_HANDLE_CHECKED(SharedFunctionInfo, shared, 1); | 8041 CONVERT_ARG_HANDLE_CHECKED(SharedFunctionInfo, shared, 1); |
8044 CONVERT_BOOLEAN_ARG_CHECKED(pretenure, 2); | 8042 CONVERT_BOOLEAN_ARG_CHECKED(pretenure, 2); |
8045 | 8043 |
8046 // The caller ensures that we pretenure closures that are assigned | 8044 // The caller ensures that we pretenure closures that are assigned |
8047 // directly to properties. | 8045 // directly to properties. |
8048 PretenureFlag pretenure_flag = pretenure ? TENURED : NOT_TENURED; | 8046 PretenureFlag pretenure_flag = pretenure ? TENURED : NOT_TENURED; |
8049 return *isolate->factory()->NewFunctionFromSharedFunctionInfo( | 8047 return *isolate->factory()->NewFunctionFromSharedFunctionInfo( |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8094 NewArray<Handle<Object> >(*total_argc)); | 8092 NewArray<Handle<Object> >(*total_argc)); |
8095 for (int i = 0; i < args_count; i++) { | 8093 for (int i = 0; i < args_count; i++) { |
8096 Handle<Object> val = Handle<Object>(frame->GetParameter(i), isolate); | 8094 Handle<Object> val = Handle<Object>(frame->GetParameter(i), isolate); |
8097 param_data[prefix_argc + i] = val; | 8095 param_data[prefix_argc + i] = val; |
8098 } | 8096 } |
8099 return param_data; | 8097 return param_data; |
8100 } | 8098 } |
8101 } | 8099 } |
8102 | 8100 |
8103 | 8101 |
8104 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionBindArguments) { | 8102 RUNTIME_FUNCTION(Object*, Runtime_FunctionBindArguments) { |
8105 HandleScope scope(isolate); | 8103 HandleScope scope(isolate); |
8106 ASSERT(args.length() == 4); | 8104 ASSERT(args.length() == 4); |
8107 CONVERT_ARG_HANDLE_CHECKED(JSFunction, bound_function, 0); | 8105 CONVERT_ARG_HANDLE_CHECKED(JSFunction, bound_function, 0); |
8108 RUNTIME_ASSERT(args[3]->IsNumber()); | 8106 RUNTIME_ASSERT(args[3]->IsNumber()); |
8109 Handle<Object> bindee = args.at<Object>(1); | 8107 Handle<Object> bindee = args.at<Object>(1); |
8110 | 8108 |
8111 // TODO(lrn): Create bound function in C++ code from premade shared info. | 8109 // TODO(lrn): Create bound function in C++ code from premade shared info. |
8112 bound_function->shared()->set_bound(true); | 8110 bound_function->shared()->set_bound(true); |
8113 // Get all arguments of calling function (Function.prototype.bind). | 8111 // Get all arguments of calling function (Function.prototype.bind). |
8114 int argc = 0; | 8112 int argc = 0; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8155 Handle<String> length_string = isolate->factory()->length_string(); | 8153 Handle<String> length_string = isolate->factory()->length_string(); |
8156 Handle<Object> new_length(args.at<Object>(3)); | 8154 Handle<Object> new_length(args.at<Object>(3)); |
8157 PropertyAttributes attr = | 8155 PropertyAttributes attr = |
8158 static_cast<PropertyAttributes>(DONT_DELETE | DONT_ENUM | READ_ONLY); | 8156 static_cast<PropertyAttributes>(DONT_DELETE | DONT_ENUM | READ_ONLY); |
8159 Runtime::ForceSetObjectProperty( | 8157 Runtime::ForceSetObjectProperty( |
8160 bound_function, length_string, new_length, attr).Assert(); | 8158 bound_function, length_string, new_length, attr).Assert(); |
8161 return *bound_function; | 8159 return *bound_function; |
8162 } | 8160 } |
8163 | 8161 |
8164 | 8162 |
8165 RUNTIME_FUNCTION(MaybeObject*, Runtime_BoundFunctionGetBindings) { | 8163 RUNTIME_FUNCTION(Object*, Runtime_BoundFunctionGetBindings) { |
8166 HandleScope handles(isolate); | 8164 HandleScope handles(isolate); |
8167 ASSERT(args.length() == 1); | 8165 ASSERT(args.length() == 1); |
8168 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, callable, 0); | 8166 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, callable, 0); |
8169 if (callable->IsJSFunction()) { | 8167 if (callable->IsJSFunction()) { |
8170 Handle<JSFunction> function = Handle<JSFunction>::cast(callable); | 8168 Handle<JSFunction> function = Handle<JSFunction>::cast(callable); |
8171 if (function->shared()->bound()) { | 8169 if (function->shared()->bound()) { |
8172 Handle<FixedArray> bindings(function->function_bindings()); | 8170 Handle<FixedArray> bindings(function->function_bindings()); |
8173 ASSERT(bindings->map() == isolate->heap()->fixed_cow_array_map()); | 8171 ASSERT(bindings->map() == isolate->heap()->fixed_cow_array_map()); |
8174 return *isolate->factory()->NewJSArrayWithElements(bindings); | 8172 return *isolate->factory()->NewJSArrayWithElements(bindings); |
8175 } | 8173 } |
8176 } | 8174 } |
8177 return isolate->heap()->undefined_value(); | 8175 return isolate->heap()->undefined_value(); |
8178 } | 8176 } |
8179 | 8177 |
8180 | 8178 |
8181 RUNTIME_FUNCTION(MaybeObject*, Runtime_NewObjectFromBound) { | 8179 RUNTIME_FUNCTION(Object*, Runtime_NewObjectFromBound) { |
8182 HandleScope scope(isolate); | 8180 HandleScope scope(isolate); |
8183 ASSERT(args.length() == 1); | 8181 ASSERT(args.length() == 1); |
8184 // First argument is a function to use as a constructor. | 8182 // First argument is a function to use as a constructor. |
8185 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 8183 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
8186 RUNTIME_ASSERT(function->shared()->bound()); | 8184 RUNTIME_ASSERT(function->shared()->bound()); |
8187 | 8185 |
8188 // The argument is a bound function. Extract its bound arguments | 8186 // The argument is a bound function. Extract its bound arguments |
8189 // and callable. | 8187 // and callable. |
8190 Handle<FixedArray> bound_args = | 8188 Handle<FixedArray> bound_args = |
8191 Handle<FixedArray>(FixedArray::cast(function->function_bindings())); | 8189 Handle<FixedArray>(FixedArray::cast(function->function_bindings())); |
(...skipping 21 matching lines...) Expand all Loading... | |
8213 | 8211 |
8214 Handle<Object> result; | 8212 Handle<Object> result; |
8215 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 8213 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
8216 isolate, result, | 8214 isolate, result, |
8217 Execution::New(Handle<JSFunction>::cast(bound_function), | 8215 Execution::New(Handle<JSFunction>::cast(bound_function), |
8218 total_argc, param_data.get())); | 8216 total_argc, param_data.get())); |
8219 return *result; | 8217 return *result; |
8220 } | 8218 } |
8221 | 8219 |
8222 | 8220 |
8223 static MaybeObject* Runtime_NewObjectHelper(Isolate* isolate, | 8221 static Object* Runtime_NewObjectHelper(Isolate* isolate, |
8224 Handle<Object> constructor, | 8222 Handle<Object> constructor, |
8225 Handle<AllocationSite> site) { | 8223 Handle<AllocationSite> site) { |
8226 // If the constructor isn't a proper function we throw a type error. | 8224 // If the constructor isn't a proper function we throw a type error. |
8227 if (!constructor->IsJSFunction()) { | 8225 if (!constructor->IsJSFunction()) { |
8228 Vector< Handle<Object> > arguments = HandleVector(&constructor, 1); | 8226 Vector< Handle<Object> > arguments = HandleVector(&constructor, 1); |
8229 Handle<Object> type_error = | 8227 Handle<Object> type_error = |
8230 isolate->factory()->NewTypeError("not_constructor", arguments); | 8228 isolate->factory()->NewTypeError("not_constructor", arguments); |
8231 return isolate->Throw(*type_error); | 8229 return isolate->Throw(*type_error); |
8232 } | 8230 } |
8233 | 8231 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8287 result = isolate->factory()->NewJSObjectWithMemento(function, site); | 8285 result = isolate->factory()->NewJSObjectWithMemento(function, site); |
8288 } | 8286 } |
8289 | 8287 |
8290 isolate->counters()->constructed_objects()->Increment(); | 8288 isolate->counters()->constructed_objects()->Increment(); |
8291 isolate->counters()->constructed_objects_runtime()->Increment(); | 8289 isolate->counters()->constructed_objects_runtime()->Increment(); |
8292 | 8290 |
8293 return *result; | 8291 return *result; |
8294 } | 8292 } |
8295 | 8293 |
8296 | 8294 |
8297 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_NewObject) { | 8295 RUNTIME_FUNCTION(Object*, RuntimeHidden_NewObject) { |
8298 HandleScope scope(isolate); | 8296 HandleScope scope(isolate); |
8299 ASSERT(args.length() == 1); | 8297 ASSERT(args.length() == 1); |
8300 CONVERT_ARG_HANDLE_CHECKED(Object, constructor, 0); | 8298 CONVERT_ARG_HANDLE_CHECKED(Object, constructor, 0); |
8301 return Runtime_NewObjectHelper(isolate, | 8299 return Runtime_NewObjectHelper(isolate, |
8302 constructor, | 8300 constructor, |
8303 Handle<AllocationSite>::null()); | 8301 Handle<AllocationSite>::null()); |
8304 } | 8302 } |
8305 | 8303 |
8306 | 8304 |
8307 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_NewObjectWithAllocationSite) { | 8305 RUNTIME_FUNCTION(Object*, RuntimeHidden_NewObjectWithAllocationSite) { |
8308 HandleScope scope(isolate); | 8306 HandleScope scope(isolate); |
8309 ASSERT(args.length() == 2); | 8307 ASSERT(args.length() == 2); |
8310 CONVERT_ARG_HANDLE_CHECKED(Object, constructor, 1); | 8308 CONVERT_ARG_HANDLE_CHECKED(Object, constructor, 1); |
8311 CONVERT_ARG_HANDLE_CHECKED(Object, feedback, 0); | 8309 CONVERT_ARG_HANDLE_CHECKED(Object, feedback, 0); |
8312 Handle<AllocationSite> site; | 8310 Handle<AllocationSite> site; |
8313 if (feedback->IsAllocationSite()) { | 8311 if (feedback->IsAllocationSite()) { |
8314 // The feedback can be an AllocationSite or undefined. | 8312 // The feedback can be an AllocationSite or undefined. |
8315 site = Handle<AllocationSite>::cast(feedback); | 8313 site = Handle<AllocationSite>::cast(feedback); |
8316 } | 8314 } |
8317 return Runtime_NewObjectHelper(isolate, constructor, site); | 8315 return Runtime_NewObjectHelper(isolate, constructor, site); |
8318 } | 8316 } |
8319 | 8317 |
8320 | 8318 |
8321 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_FinalizeInstanceSize) { | 8319 RUNTIME_FUNCTION(Object*, RuntimeHidden_FinalizeInstanceSize) { |
8322 HandleScope scope(isolate); | 8320 HandleScope scope(isolate); |
8323 ASSERT(args.length() == 1); | 8321 ASSERT(args.length() == 1); |
8324 | 8322 |
8325 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 8323 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
8326 function->shared()->CompleteInobjectSlackTracking(); | 8324 function->shared()->CompleteInobjectSlackTracking(); |
8327 | 8325 |
8328 return isolate->heap()->undefined_value(); | 8326 return isolate->heap()->undefined_value(); |
8329 } | 8327 } |
8330 | 8328 |
8331 | 8329 |
8332 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_CompileUnoptimized) { | 8330 RUNTIME_FUNCTION(Object*, RuntimeHidden_CompileUnoptimized) { |
8333 HandleScope scope(isolate); | 8331 HandleScope scope(isolate); |
8334 ASSERT(args.length() == 1); | 8332 ASSERT(args.length() == 1); |
8335 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 8333 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
8336 #ifdef DEBUG | 8334 #ifdef DEBUG |
8337 if (FLAG_trace_lazy && !function->shared()->is_compiled()) { | 8335 if (FLAG_trace_lazy && !function->shared()->is_compiled()) { |
8338 PrintF("[unoptimized: "); | 8336 PrintF("[unoptimized: "); |
8339 function->PrintName(); | 8337 function->PrintName(); |
8340 PrintF("]\n"); | 8338 PrintF("]\n"); |
8341 } | 8339 } |
8342 #endif | 8340 #endif |
8343 | 8341 |
8344 // Compile the target function. | 8342 // Compile the target function. |
8345 ASSERT(function->shared()->allows_lazy_compilation()); | 8343 ASSERT(function->shared()->allows_lazy_compilation()); |
8346 | 8344 |
8347 Handle<Code> code = Compiler::GetUnoptimizedCode(function); | 8345 Handle<Code> code = Compiler::GetUnoptimizedCode(function); |
8348 RETURN_IF_EMPTY_HANDLE(isolate, code); | 8346 RETURN_IF_EMPTY_HANDLE(isolate, code); |
8349 function->ReplaceCode(*code); | 8347 function->ReplaceCode(*code); |
8350 | 8348 |
8351 // All done. Return the compiled code. | 8349 // All done. Return the compiled code. |
8352 ASSERT(function->is_compiled()); | 8350 ASSERT(function->is_compiled()); |
8353 ASSERT(function->code()->kind() == Code::FUNCTION || | 8351 ASSERT(function->code()->kind() == Code::FUNCTION || |
8354 (FLAG_always_opt && | 8352 (FLAG_always_opt && |
8355 function->code()->kind() == Code::OPTIMIZED_FUNCTION)); | 8353 function->code()->kind() == Code::OPTIMIZED_FUNCTION)); |
8356 return *code; | 8354 return *code; |
8357 } | 8355 } |
8358 | 8356 |
8359 | 8357 |
8360 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_CompileOptimized) { | 8358 RUNTIME_FUNCTION(Object*, RuntimeHidden_CompileOptimized) { |
8361 HandleScope scope(isolate); | 8359 HandleScope scope(isolate); |
8362 ASSERT(args.length() == 2); | 8360 ASSERT(args.length() == 2); |
8363 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 8361 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
8364 CONVERT_BOOLEAN_ARG_CHECKED(concurrent, 1); | 8362 CONVERT_BOOLEAN_ARG_CHECKED(concurrent, 1); |
8365 | 8363 |
8366 Handle<Code> unoptimized(function->shared()->code()); | 8364 Handle<Code> unoptimized(function->shared()->code()); |
8367 if (!function->shared()->is_compiled()) { | 8365 if (!function->shared()->is_compiled()) { |
8368 // If the function is not compiled, do not optimize. | 8366 // If the function is not compiled, do not optimize. |
8369 // This can happen if the debugger is activated and | 8367 // This can happen if the debugger is activated and |
8370 // the function is returned to the not compiled state. | 8368 // the function is returned to the not compiled state. |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8413 | 8411 |
8414 void VisitFrames(JavaScriptFrameIterator* it) { | 8412 void VisitFrames(JavaScriptFrameIterator* it) { |
8415 for (; !it->done(); it->Advance()) { | 8413 for (; !it->done(); it->Advance()) { |
8416 JavaScriptFrame* frame = it->frame(); | 8414 JavaScriptFrame* frame = it->frame(); |
8417 if (code_->contains(frame->pc())) has_code_activations_ = true; | 8415 if (code_->contains(frame->pc())) has_code_activations_ = true; |
8418 } | 8416 } |
8419 } | 8417 } |
8420 }; | 8418 }; |
8421 | 8419 |
8422 | 8420 |
8423 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_NotifyStubFailure) { | 8421 RUNTIME_FUNCTION(Object*, RuntimeHidden_NotifyStubFailure) { |
8424 HandleScope scope(isolate); | 8422 HandleScope scope(isolate); |
8425 ASSERT(args.length() == 0); | 8423 ASSERT(args.length() == 0); |
8426 Deoptimizer* deoptimizer = Deoptimizer::Grab(isolate); | 8424 Deoptimizer* deoptimizer = Deoptimizer::Grab(isolate); |
8427 ASSERT(AllowHeapAllocation::IsAllowed()); | 8425 ASSERT(AllowHeapAllocation::IsAllowed()); |
8428 delete deoptimizer; | 8426 delete deoptimizer; |
8429 return isolate->heap()->undefined_value(); | 8427 return isolate->heap()->undefined_value(); |
8430 } | 8428 } |
8431 | 8429 |
8432 | 8430 |
8433 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_NotifyDeoptimized) { | 8431 RUNTIME_FUNCTION(Object*, RuntimeHidden_NotifyDeoptimized) { |
8434 HandleScope scope(isolate); | 8432 HandleScope scope(isolate); |
8435 ASSERT(args.length() == 1); | 8433 ASSERT(args.length() == 1); |
8436 CONVERT_SMI_ARG_CHECKED(type_arg, 0); | 8434 CONVERT_SMI_ARG_CHECKED(type_arg, 0); |
8437 Deoptimizer::BailoutType type = | 8435 Deoptimizer::BailoutType type = |
8438 static_cast<Deoptimizer::BailoutType>(type_arg); | 8436 static_cast<Deoptimizer::BailoutType>(type_arg); |
8439 Deoptimizer* deoptimizer = Deoptimizer::Grab(isolate); | 8437 Deoptimizer* deoptimizer = Deoptimizer::Grab(isolate); |
8440 ASSERT(AllowHeapAllocation::IsAllowed()); | 8438 ASSERT(AllowHeapAllocation::IsAllowed()); |
8441 | 8439 |
8442 Handle<JSFunction> function = deoptimizer->function(); | 8440 Handle<JSFunction> function = deoptimizer->function(); |
8443 Handle<Code> optimized_code = deoptimizer->compiled_code(); | 8441 Handle<Code> optimized_code = deoptimizer->compiled_code(); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8482 // TODO(titzer): we should probably do DeoptimizeCodeList(code) | 8480 // TODO(titzer): we should probably do DeoptimizeCodeList(code) |
8483 // unconditionally if the code is not already marked for deoptimization. | 8481 // unconditionally if the code is not already marked for deoptimization. |
8484 // If there is an index by shared function info, all the better. | 8482 // If there is an index by shared function info, all the better. |
8485 Deoptimizer::DeoptimizeFunction(*function); | 8483 Deoptimizer::DeoptimizeFunction(*function); |
8486 } | 8484 } |
8487 | 8485 |
8488 return isolate->heap()->undefined_value(); | 8486 return isolate->heap()->undefined_value(); |
8489 } | 8487 } |
8490 | 8488 |
8491 | 8489 |
8492 RUNTIME_FUNCTION(MaybeObject*, Runtime_DeoptimizeFunction) { | 8490 RUNTIME_FUNCTION(Object*, Runtime_DeoptimizeFunction) { |
8493 HandleScope scope(isolate); | 8491 HandleScope scope(isolate); |
8494 ASSERT(args.length() == 1); | 8492 ASSERT(args.length() == 1); |
8495 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 8493 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
8496 if (!function->IsOptimized()) return isolate->heap()->undefined_value(); | 8494 if (!function->IsOptimized()) return isolate->heap()->undefined_value(); |
8497 | 8495 |
8498 Deoptimizer::DeoptimizeFunction(*function); | 8496 Deoptimizer::DeoptimizeFunction(*function); |
8499 | 8497 |
8500 return isolate->heap()->undefined_value(); | 8498 return isolate->heap()->undefined_value(); |
8501 } | 8499 } |
8502 | 8500 |
8503 | 8501 |
8504 RUNTIME_FUNCTION(MaybeObject*, Runtime_ClearFunctionTypeFeedback) { | 8502 RUNTIME_FUNCTION(Object*, Runtime_ClearFunctionTypeFeedback) { |
8505 HandleScope scope(isolate); | 8503 HandleScope scope(isolate); |
8506 ASSERT(args.length() == 1); | 8504 ASSERT(args.length() == 1); |
8507 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 8505 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
8508 Code* unoptimized = function->shared()->code(); | 8506 Code* unoptimized = function->shared()->code(); |
8509 if (unoptimized->kind() == Code::FUNCTION) { | 8507 if (unoptimized->kind() == Code::FUNCTION) { |
8510 unoptimized->ClearInlineCaches(); | 8508 unoptimized->ClearInlineCaches(); |
8511 unoptimized->ClearTypeFeedbackInfo(isolate->heap()); | 8509 unoptimized->ClearTypeFeedbackInfo(isolate->heap()); |
8512 } | 8510 } |
8513 return isolate->heap()->undefined_value(); | 8511 return isolate->heap()->undefined_value(); |
8514 } | 8512 } |
8515 | 8513 |
8516 | 8514 |
8517 RUNTIME_FUNCTION(MaybeObject*, Runtime_RunningInSimulator) { | 8515 RUNTIME_FUNCTION(Object*, Runtime_RunningInSimulator) { |
8518 SealHandleScope shs(isolate); | 8516 SealHandleScope shs(isolate); |
8519 ASSERT(args.length() == 0); | 8517 ASSERT(args.length() == 0); |
8520 #if defined(USE_SIMULATOR) | 8518 #if defined(USE_SIMULATOR) |
8521 return isolate->heap()->true_value(); | 8519 return isolate->heap()->true_value(); |
8522 #else | 8520 #else |
8523 return isolate->heap()->false_value(); | 8521 return isolate->heap()->false_value(); |
8524 #endif | 8522 #endif |
8525 } | 8523 } |
8526 | 8524 |
8527 | 8525 |
8528 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsConcurrentRecompilationSupported) { | 8526 RUNTIME_FUNCTION(Object*, Runtime_IsConcurrentRecompilationSupported) { |
8529 SealHandleScope shs(isolate); | 8527 SealHandleScope shs(isolate); |
8530 return isolate->heap()->ToBoolean( | 8528 return isolate->heap()->ToBoolean( |
8531 isolate->concurrent_recompilation_enabled()); | 8529 isolate->concurrent_recompilation_enabled()); |
8532 } | 8530 } |
8533 | 8531 |
8534 | 8532 |
8535 RUNTIME_FUNCTION(MaybeObject*, Runtime_OptimizeFunctionOnNextCall) { | 8533 RUNTIME_FUNCTION(Object*, Runtime_OptimizeFunctionOnNextCall) { |
8536 HandleScope scope(isolate); | 8534 HandleScope scope(isolate); |
8537 RUNTIME_ASSERT(args.length() == 1 || args.length() == 2); | 8535 RUNTIME_ASSERT(args.length() == 1 || args.length() == 2); |
8538 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 8536 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
8539 | 8537 |
8540 if (!function->IsOptimizable() && | 8538 if (!function->IsOptimizable() && |
8541 !function->IsMarkedForConcurrentOptimization() && | 8539 !function->IsMarkedForConcurrentOptimization() && |
8542 !function->IsInOptimizationQueue()) { | 8540 !function->IsInOptimizationQueue()) { |
8543 return isolate->heap()->undefined_value(); | 8541 return isolate->heap()->undefined_value(); |
8544 } | 8542 } |
8545 | 8543 |
(...skipping 14 matching lines...) Expand all Loading... | |
8560 } else if (type->IsOneByteEqualTo(STATIC_ASCII_VECTOR("concurrent")) && | 8558 } else if (type->IsOneByteEqualTo(STATIC_ASCII_VECTOR("concurrent")) && |
8561 isolate->concurrent_recompilation_enabled()) { | 8559 isolate->concurrent_recompilation_enabled()) { |
8562 function->MarkForConcurrentOptimization(); | 8560 function->MarkForConcurrentOptimization(); |
8563 } | 8561 } |
8564 } | 8562 } |
8565 | 8563 |
8566 return isolate->heap()->undefined_value(); | 8564 return isolate->heap()->undefined_value(); |
8567 } | 8565 } |
8568 | 8566 |
8569 | 8567 |
8570 RUNTIME_FUNCTION(MaybeObject*, Runtime_NeverOptimizeFunction) { | 8568 RUNTIME_FUNCTION(Object*, Runtime_NeverOptimizeFunction) { |
8571 HandleScope scope(isolate); | 8569 HandleScope scope(isolate); |
8572 ASSERT(args.length() == 1); | 8570 ASSERT(args.length() == 1); |
8573 CONVERT_ARG_CHECKED(JSFunction, function, 0); | 8571 CONVERT_ARG_CHECKED(JSFunction, function, 0); |
8574 function->shared()->set_optimization_disabled(true); | 8572 function->shared()->set_optimization_disabled(true); |
8575 return isolate->heap()->undefined_value(); | 8573 return isolate->heap()->undefined_value(); |
8576 } | 8574 } |
8577 | 8575 |
8578 | 8576 |
8579 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetOptimizationStatus) { | 8577 RUNTIME_FUNCTION(Object*, Runtime_GetOptimizationStatus) { |
8580 HandleScope scope(isolate); | 8578 HandleScope scope(isolate); |
8581 RUNTIME_ASSERT(args.length() == 1 || args.length() == 2); | 8579 RUNTIME_ASSERT(args.length() == 1 || args.length() == 2); |
8582 if (!isolate->use_crankshaft()) { | 8580 if (!isolate->use_crankshaft()) { |
8583 return Smi::FromInt(4); // 4 == "never". | 8581 return Smi::FromInt(4); // 4 == "never". |
8584 } | 8582 } |
8585 bool sync_with_compiler_thread = true; | 8583 bool sync_with_compiler_thread = true; |
8586 if (args.length() == 2) { | 8584 if (args.length() == 2) { |
8587 CONVERT_ARG_HANDLE_CHECKED(String, sync, 1); | 8585 CONVERT_ARG_HANDLE_CHECKED(String, sync, 1); |
8588 if (sync->IsOneByteEqualTo(STATIC_ASCII_VECTOR("no sync"))) { | 8586 if (sync->IsOneByteEqualTo(STATIC_ASCII_VECTOR("no sync"))) { |
8589 sync_with_compiler_thread = false; | 8587 sync_with_compiler_thread = false; |
(...skipping 14 matching lines...) Expand all Loading... | |
8604 : Smi::FromInt(2); // 2 == "no". | 8602 : Smi::FromInt(2); // 2 == "no". |
8605 } | 8603 } |
8606 if (FLAG_deopt_every_n_times) { | 8604 if (FLAG_deopt_every_n_times) { |
8607 return Smi::FromInt(6); // 6 == "maybe deopted". | 8605 return Smi::FromInt(6); // 6 == "maybe deopted". |
8608 } | 8606 } |
8609 return function->IsOptimized() ? Smi::FromInt(1) // 1 == "yes". | 8607 return function->IsOptimized() ? Smi::FromInt(1) // 1 == "yes". |
8610 : Smi::FromInt(2); // 2 == "no". | 8608 : Smi::FromInt(2); // 2 == "no". |
8611 } | 8609 } |
8612 | 8610 |
8613 | 8611 |
8614 RUNTIME_FUNCTION(MaybeObject*, Runtime_UnblockConcurrentRecompilation) { | 8612 RUNTIME_FUNCTION(Object*, Runtime_UnblockConcurrentRecompilation) { |
8615 ASSERT(args.length() == 0); | 8613 ASSERT(args.length() == 0); |
8616 RUNTIME_ASSERT(FLAG_block_concurrent_recompilation); | 8614 RUNTIME_ASSERT(FLAG_block_concurrent_recompilation); |
8617 RUNTIME_ASSERT(isolate->concurrent_recompilation_enabled()); | 8615 RUNTIME_ASSERT(isolate->concurrent_recompilation_enabled()); |
8618 isolate->optimizing_compiler_thread()->Unblock(); | 8616 isolate->optimizing_compiler_thread()->Unblock(); |
8619 return isolate->heap()->undefined_value(); | 8617 return isolate->heap()->undefined_value(); |
8620 } | 8618 } |
8621 | 8619 |
8622 | 8620 |
8623 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetOptimizationCount) { | 8621 RUNTIME_FUNCTION(Object*, Runtime_GetOptimizationCount) { |
8624 HandleScope scope(isolate); | 8622 HandleScope scope(isolate); |
8625 ASSERT(args.length() == 1); | 8623 ASSERT(args.length() == 1); |
8626 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 8624 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
8627 return Smi::FromInt(function->shared()->opt_count()); | 8625 return Smi::FromInt(function->shared()->opt_count()); |
8628 } | 8626 } |
8629 | 8627 |
8630 | 8628 |
8631 static bool IsSuitableForOnStackReplacement(Isolate* isolate, | 8629 static bool IsSuitableForOnStackReplacement(Isolate* isolate, |
8632 Handle<JSFunction> function, | 8630 Handle<JSFunction> function, |
8633 Handle<Code> current_code) { | 8631 Handle<Code> current_code) { |
8634 // Keep track of whether we've succeeded in optimizing. | 8632 // Keep track of whether we've succeeded in optimizing. |
8635 if (!isolate->use_crankshaft() || !current_code->optimizable()) return false; | 8633 if (!isolate->use_crankshaft() || !current_code->optimizable()) return false; |
8636 // If we are trying to do OSR when there are already optimized | 8634 // If we are trying to do OSR when there are already optimized |
8637 // activations of the function, it means (a) the function is directly or | 8635 // activations of the function, it means (a) the function is directly or |
8638 // indirectly recursive and (b) an optimized invocation has been | 8636 // indirectly recursive and (b) an optimized invocation has been |
8639 // deoptimized so that we are currently in an unoptimized activation. | 8637 // deoptimized so that we are currently in an unoptimized activation. |
8640 // Check for optimized activations of this function. | 8638 // Check for optimized activations of this function. |
8641 for (JavaScriptFrameIterator it(isolate); !it.done(); it.Advance()) { | 8639 for (JavaScriptFrameIterator it(isolate); !it.done(); it.Advance()) { |
8642 JavaScriptFrame* frame = it.frame(); | 8640 JavaScriptFrame* frame = it.frame(); |
8643 if (frame->is_optimized() && frame->function() == *function) return false; | 8641 if (frame->is_optimized() && frame->function() == *function) return false; |
8644 } | 8642 } |
8645 | 8643 |
8646 return true; | 8644 return true; |
8647 } | 8645 } |
8648 | 8646 |
8649 | 8647 |
8650 RUNTIME_FUNCTION(MaybeObject*, Runtime_CompileForOnStackReplacement) { | 8648 RUNTIME_FUNCTION(Object*, Runtime_CompileForOnStackReplacement) { |
8651 HandleScope scope(isolate); | 8649 HandleScope scope(isolate); |
8652 ASSERT(args.length() == 1); | 8650 ASSERT(args.length() == 1); |
8653 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 8651 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
8654 Handle<Code> caller_code(function->shared()->code()); | 8652 Handle<Code> caller_code(function->shared()->code()); |
8655 | 8653 |
8656 // We're not prepared to handle a function with arguments object. | 8654 // We're not prepared to handle a function with arguments object. |
8657 ASSERT(!function->shared()->uses_arguments()); | 8655 ASSERT(!function->shared()->uses_arguments()); |
8658 | 8656 |
8659 // Passing the PC in the javascript frame from the caller directly is | 8657 // Passing the PC in the javascript frame from the caller directly is |
8660 // not GC safe, so we walk the stack to get it. | 8658 // not GC safe, so we walk the stack to get it. |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8753 PrintF(" at AST id %d]\n", ast_id.ToInt()); | 8751 PrintF(" at AST id %d]\n", ast_id.ToInt()); |
8754 } | 8752 } |
8755 | 8753 |
8756 if (!function->IsOptimized()) { | 8754 if (!function->IsOptimized()) { |
8757 function->ReplaceCode(function->shared()->code()); | 8755 function->ReplaceCode(function->shared()->code()); |
8758 } | 8756 } |
8759 return NULL; | 8757 return NULL; |
8760 } | 8758 } |
8761 | 8759 |
8762 | 8760 |
8763 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetAllocationTimeout) { | 8761 RUNTIME_FUNCTION(Object*, Runtime_SetAllocationTimeout) { |
8764 SealHandleScope shs(isolate); | 8762 SealHandleScope shs(isolate); |
8765 ASSERT(args.length() == 2 || args.length() == 3); | 8763 ASSERT(args.length() == 2 || args.length() == 3); |
8766 #ifdef DEBUG | 8764 #ifdef DEBUG |
8767 CONVERT_SMI_ARG_CHECKED(interval, 0); | 8765 CONVERT_SMI_ARG_CHECKED(interval, 0); |
8768 CONVERT_SMI_ARG_CHECKED(timeout, 1); | 8766 CONVERT_SMI_ARG_CHECKED(timeout, 1); |
8769 isolate->heap()->set_allocation_timeout(timeout); | 8767 isolate->heap()->set_allocation_timeout(timeout); |
8770 FLAG_gc_interval = interval; | 8768 FLAG_gc_interval = interval; |
8771 if (args.length() == 3) { | 8769 if (args.length() == 3) { |
8772 // Enable/disable inline allocation if requested. | 8770 // Enable/disable inline allocation if requested. |
8773 CONVERT_BOOLEAN_ARG_CHECKED(inline_allocation, 2); | 8771 CONVERT_BOOLEAN_ARG_CHECKED(inline_allocation, 2); |
8774 if (inline_allocation) { | 8772 if (inline_allocation) { |
8775 isolate->heap()->EnableInlineAllocation(); | 8773 isolate->heap()->EnableInlineAllocation(); |
8776 } else { | 8774 } else { |
8777 isolate->heap()->DisableInlineAllocation(); | 8775 isolate->heap()->DisableInlineAllocation(); |
8778 } | 8776 } |
8779 } | 8777 } |
8780 #endif | 8778 #endif |
8781 return isolate->heap()->undefined_value(); | 8779 return isolate->heap()->undefined_value(); |
8782 } | 8780 } |
8783 | 8781 |
8784 | 8782 |
8785 RUNTIME_FUNCTION(MaybeObject*, Runtime_CheckIsBootstrapping) { | 8783 RUNTIME_FUNCTION(Object*, Runtime_CheckIsBootstrapping) { |
8786 SealHandleScope shs(isolate); | 8784 SealHandleScope shs(isolate); |
8787 ASSERT(args.length() == 0); | 8785 ASSERT(args.length() == 0); |
8788 RUNTIME_ASSERT(isolate->bootstrapper()->IsActive()); | 8786 RUNTIME_ASSERT(isolate->bootstrapper()->IsActive()); |
8789 return isolate->heap()->undefined_value(); | 8787 return isolate->heap()->undefined_value(); |
8790 } | 8788 } |
8791 | 8789 |
8792 | 8790 |
8793 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetRootNaN) { | 8791 RUNTIME_FUNCTION(Object*, Runtime_GetRootNaN) { |
8794 SealHandleScope shs(isolate); | 8792 SealHandleScope shs(isolate); |
8795 ASSERT(args.length() == 0); | 8793 ASSERT(args.length() == 0); |
8796 RUNTIME_ASSERT(isolate->bootstrapper()->IsActive()); | 8794 RUNTIME_ASSERT(isolate->bootstrapper()->IsActive()); |
8797 return isolate->heap()->nan_value(); | 8795 return isolate->heap()->nan_value(); |
8798 } | 8796 } |
8799 | 8797 |
8800 | 8798 |
8801 RUNTIME_FUNCTION(MaybeObject*, Runtime_Call) { | 8799 RUNTIME_FUNCTION(Object*, Runtime_Call) { |
8802 HandleScope scope(isolate); | 8800 HandleScope scope(isolate); |
8803 ASSERT(args.length() >= 2); | 8801 ASSERT(args.length() >= 2); |
8804 int argc = args.length() - 2; | 8802 int argc = args.length() - 2; |
8805 CONVERT_ARG_CHECKED(JSReceiver, fun, argc + 1); | 8803 CONVERT_ARG_CHECKED(JSReceiver, fun, argc + 1); |
8806 Object* receiver = args[0]; | 8804 Object* receiver = args[0]; |
8807 | 8805 |
8808 // If there are too many arguments, allocate argv via malloc. | 8806 // If there are too many arguments, allocate argv via malloc. |
8809 const int argv_small_size = 10; | 8807 const int argv_small_size = 10; |
8810 Handle<Object> argv_small_buffer[argv_small_size]; | 8808 Handle<Object> argv_small_buffer[argv_small_size]; |
8811 SmartArrayPointer<Handle<Object> > argv_large_buffer; | 8809 SmartArrayPointer<Handle<Object> > argv_large_buffer; |
(...skipping 11 matching lines...) Expand all Loading... | |
8823 Handle<JSReceiver> hfun(fun); | 8821 Handle<JSReceiver> hfun(fun); |
8824 Handle<Object> hreceiver(receiver, isolate); | 8822 Handle<Object> hreceiver(receiver, isolate); |
8825 Handle<Object> result; | 8823 Handle<Object> result; |
8826 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 8824 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
8827 isolate, result, | 8825 isolate, result, |
8828 Execution::Call(isolate, hfun, hreceiver, argc, argv, true)); | 8826 Execution::Call(isolate, hfun, hreceiver, argc, argv, true)); |
8829 return *result; | 8827 return *result; |
8830 } | 8828 } |
8831 | 8829 |
8832 | 8830 |
8833 RUNTIME_FUNCTION(MaybeObject*, Runtime_Apply) { | 8831 RUNTIME_FUNCTION(Object*, Runtime_Apply) { |
8834 HandleScope scope(isolate); | 8832 HandleScope scope(isolate); |
8835 ASSERT(args.length() == 5); | 8833 ASSERT(args.length() == 5); |
8836 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, fun, 0); | 8834 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, fun, 0); |
8837 CONVERT_ARG_HANDLE_CHECKED(Object, receiver, 1); | 8835 CONVERT_ARG_HANDLE_CHECKED(Object, receiver, 1); |
8838 CONVERT_ARG_HANDLE_CHECKED(JSObject, arguments, 2); | 8836 CONVERT_ARG_HANDLE_CHECKED(JSObject, arguments, 2); |
8839 CONVERT_SMI_ARG_CHECKED(offset, 3); | 8837 CONVERT_SMI_ARG_CHECKED(offset, 3); |
8840 CONVERT_SMI_ARG_CHECKED(argc, 4); | 8838 CONVERT_SMI_ARG_CHECKED(argc, 4); |
8841 RUNTIME_ASSERT(offset >= 0); | 8839 RUNTIME_ASSERT(offset >= 0); |
8842 RUNTIME_ASSERT(argc >= 0); | 8840 RUNTIME_ASSERT(argc >= 0); |
8843 | 8841 |
(...skipping 15 matching lines...) Expand all Loading... | |
8859 } | 8857 } |
8860 | 8858 |
8861 Handle<Object> result; | 8859 Handle<Object> result; |
8862 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 8860 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
8863 isolate, result, | 8861 isolate, result, |
8864 Execution::Call(isolate, fun, receiver, argc, argv, true)); | 8862 Execution::Call(isolate, fun, receiver, argc, argv, true)); |
8865 return *result; | 8863 return *result; |
8866 } | 8864 } |
8867 | 8865 |
8868 | 8866 |
8869 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetFunctionDelegate) { | 8867 RUNTIME_FUNCTION(Object*, Runtime_GetFunctionDelegate) { |
8870 HandleScope scope(isolate); | 8868 HandleScope scope(isolate); |
8871 ASSERT(args.length() == 1); | 8869 ASSERT(args.length() == 1); |
8872 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); | 8870 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); |
8873 RUNTIME_ASSERT(!object->IsJSFunction()); | 8871 RUNTIME_ASSERT(!object->IsJSFunction()); |
8874 return *Execution::GetFunctionDelegate(isolate, object); | 8872 return *Execution::GetFunctionDelegate(isolate, object); |
8875 } | 8873 } |
8876 | 8874 |
8877 | 8875 |
8878 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetConstructorDelegate) { | 8876 RUNTIME_FUNCTION(Object*, Runtime_GetConstructorDelegate) { |
8879 HandleScope scope(isolate); | 8877 HandleScope scope(isolate); |
8880 ASSERT(args.length() == 1); | 8878 ASSERT(args.length() == 1); |
8881 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); | 8879 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); |
8882 RUNTIME_ASSERT(!object->IsJSFunction()); | 8880 RUNTIME_ASSERT(!object->IsJSFunction()); |
8883 return *Execution::GetConstructorDelegate(isolate, object); | 8881 return *Execution::GetConstructorDelegate(isolate, object); |
8884 } | 8882 } |
8885 | 8883 |
8886 | 8884 |
8887 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_NewGlobalContext) { | 8885 RUNTIME_FUNCTION(Object*, RuntimeHidden_NewGlobalContext) { |
8888 HandleScope scope(isolate); | 8886 HandleScope scope(isolate); |
8889 ASSERT(args.length() == 2); | 8887 ASSERT(args.length() == 2); |
8890 | 8888 |
8891 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 8889 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
8892 CONVERT_ARG_HANDLE_CHECKED(ScopeInfo, scope_info, 1); | 8890 CONVERT_ARG_HANDLE_CHECKED(ScopeInfo, scope_info, 1); |
8893 Handle<Context> result = | 8891 Handle<Context> result = |
8894 isolate->factory()->NewGlobalContext(function, scope_info); | 8892 isolate->factory()->NewGlobalContext(function, scope_info); |
8895 | 8893 |
8896 ASSERT(function->context() == isolate->context()); | 8894 ASSERT(function->context() == isolate->context()); |
8897 ASSERT(function->context()->global_object() == result->global_object()); | 8895 ASSERT(function->context()->global_object() == result->global_object()); |
8898 result->global_object()->set_global_context(*result); | 8896 result->global_object()->set_global_context(*result); |
8899 return *result; | 8897 return *result; |
8900 } | 8898 } |
8901 | 8899 |
8902 | 8900 |
8903 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_NewFunctionContext) { | 8901 RUNTIME_FUNCTION(Object*, RuntimeHidden_NewFunctionContext) { |
8904 HandleScope scope(isolate); | 8902 HandleScope scope(isolate); |
8905 ASSERT(args.length() == 1); | 8903 ASSERT(args.length() == 1); |
8906 | 8904 |
8907 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 8905 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
8908 int length = function->shared()->scope_info()->ContextLength(); | 8906 int length = function->shared()->scope_info()->ContextLength(); |
8909 return *isolate->factory()->NewFunctionContext(length, function); | 8907 return *isolate->factory()->NewFunctionContext(length, function); |
8910 } | 8908 } |
8911 | 8909 |
8912 | 8910 |
8913 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_PushWithContext) { | 8911 RUNTIME_FUNCTION(Object*, RuntimeHidden_PushWithContext) { |
8914 HandleScope scope(isolate); | 8912 HandleScope scope(isolate); |
8915 ASSERT(args.length() == 2); | 8913 ASSERT(args.length() == 2); |
8916 Handle<JSReceiver> extension_object; | 8914 Handle<JSReceiver> extension_object; |
8917 if (args[0]->IsJSReceiver()) { | 8915 if (args[0]->IsJSReceiver()) { |
8918 extension_object = args.at<JSReceiver>(0); | 8916 extension_object = args.at<JSReceiver>(0); |
8919 } else { | 8917 } else { |
8920 // Try to convert the object to a proper JavaScript object. | 8918 // Try to convert the object to a proper JavaScript object. |
8921 MaybeHandle<JSReceiver> maybe_object = | 8919 MaybeHandle<JSReceiver> maybe_object = |
8922 Object::ToObject(isolate, args.at<Object>(0)); | 8920 Object::ToObject(isolate, args.at<Object>(0)); |
8923 if (!maybe_object.ToHandle(&extension_object)) { | 8921 if (!maybe_object.ToHandle(&extension_object)) { |
(...skipping 16 matching lines...) Expand all Loading... | |
8940 } | 8938 } |
8941 | 8939 |
8942 Handle<Context> current(isolate->context()); | 8940 Handle<Context> current(isolate->context()); |
8943 Handle<Context> context = isolate->factory()->NewWithContext( | 8941 Handle<Context> context = isolate->factory()->NewWithContext( |
8944 function, current, extension_object); | 8942 function, current, extension_object); |
8945 isolate->set_context(*context); | 8943 isolate->set_context(*context); |
8946 return *context; | 8944 return *context; |
8947 } | 8945 } |
8948 | 8946 |
8949 | 8947 |
8950 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_PushCatchContext) { | 8948 RUNTIME_FUNCTION(Object*, RuntimeHidden_PushCatchContext) { |
8951 HandleScope scope(isolate); | 8949 HandleScope scope(isolate); |
8952 ASSERT(args.length() == 3); | 8950 ASSERT(args.length() == 3); |
8953 CONVERT_ARG_HANDLE_CHECKED(String, name, 0); | 8951 CONVERT_ARG_HANDLE_CHECKED(String, name, 0); |
8954 CONVERT_ARG_HANDLE_CHECKED(Object, thrown_object, 1); | 8952 CONVERT_ARG_HANDLE_CHECKED(Object, thrown_object, 1); |
8955 Handle<JSFunction> function; | 8953 Handle<JSFunction> function; |
8956 if (args[2]->IsSmi()) { | 8954 if (args[2]->IsSmi()) { |
8957 // A smi sentinel indicates a context nested inside global code rather | 8955 // A smi sentinel indicates a context nested inside global code rather |
8958 // than some function. There is a canonical empty function that can be | 8956 // than some function. There is a canonical empty function that can be |
8959 // gotten from the native context. | 8957 // gotten from the native context. |
8960 function = handle(isolate->context()->native_context()->closure()); | 8958 function = handle(isolate->context()->native_context()->closure()); |
8961 } else { | 8959 } else { |
8962 function = args.at<JSFunction>(2); | 8960 function = args.at<JSFunction>(2); |
8963 } | 8961 } |
8964 Handle<Context> current(isolate->context()); | 8962 Handle<Context> current(isolate->context()); |
8965 Handle<Context> context = isolate->factory()->NewCatchContext( | 8963 Handle<Context> context = isolate->factory()->NewCatchContext( |
8966 function, current, name, thrown_object); | 8964 function, current, name, thrown_object); |
8967 isolate->set_context(*context); | 8965 isolate->set_context(*context); |
8968 return *context; | 8966 return *context; |
8969 } | 8967 } |
8970 | 8968 |
8971 | 8969 |
8972 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_PushBlockContext) { | 8970 RUNTIME_FUNCTION(Object*, RuntimeHidden_PushBlockContext) { |
8973 HandleScope scope(isolate); | 8971 HandleScope scope(isolate); |
8974 ASSERT(args.length() == 2); | 8972 ASSERT(args.length() == 2); |
8975 CONVERT_ARG_HANDLE_CHECKED(ScopeInfo, scope_info, 0); | 8973 CONVERT_ARG_HANDLE_CHECKED(ScopeInfo, scope_info, 0); |
8976 Handle<JSFunction> function; | 8974 Handle<JSFunction> function; |
8977 if (args[1]->IsSmi()) { | 8975 if (args[1]->IsSmi()) { |
8978 // A smi sentinel indicates a context nested inside global code rather | 8976 // A smi sentinel indicates a context nested inside global code rather |
8979 // than some function. There is a canonical empty function that can be | 8977 // than some function. There is a canonical empty function that can be |
8980 // gotten from the native context. | 8978 // gotten from the native context. |
8981 function = handle(isolate->context()->native_context()->closure()); | 8979 function = handle(isolate->context()->native_context()->closure()); |
8982 } else { | 8980 } else { |
8983 function = args.at<JSFunction>(1); | 8981 function = args.at<JSFunction>(1); |
8984 } | 8982 } |
8985 Handle<Context> current(isolate->context()); | 8983 Handle<Context> current(isolate->context()); |
8986 Handle<Context> context = isolate->factory()->NewBlockContext( | 8984 Handle<Context> context = isolate->factory()->NewBlockContext( |
8987 function, current, scope_info); | 8985 function, current, scope_info); |
8988 isolate->set_context(*context); | 8986 isolate->set_context(*context); |
8989 return *context; | 8987 return *context; |
8990 } | 8988 } |
8991 | 8989 |
8992 | 8990 |
8993 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsJSModule) { | 8991 RUNTIME_FUNCTION(Object*, Runtime_IsJSModule) { |
8994 SealHandleScope shs(isolate); | 8992 SealHandleScope shs(isolate); |
8995 ASSERT(args.length() == 1); | 8993 ASSERT(args.length() == 1); |
8996 CONVERT_ARG_CHECKED(Object, obj, 0); | 8994 CONVERT_ARG_CHECKED(Object, obj, 0); |
8997 return isolate->heap()->ToBoolean(obj->IsJSModule()); | 8995 return isolate->heap()->ToBoolean(obj->IsJSModule()); |
8998 } | 8996 } |
8999 | 8997 |
9000 | 8998 |
9001 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_PushModuleContext) { | 8999 RUNTIME_FUNCTION(Object*, RuntimeHidden_PushModuleContext) { |
9002 SealHandleScope shs(isolate); | 9000 SealHandleScope shs(isolate); |
9003 ASSERT(args.length() == 2); | 9001 ASSERT(args.length() == 2); |
9004 CONVERT_SMI_ARG_CHECKED(index, 0); | 9002 CONVERT_SMI_ARG_CHECKED(index, 0); |
9005 | 9003 |
9006 if (!args[1]->IsScopeInfo()) { | 9004 if (!args[1]->IsScopeInfo()) { |
9007 // Module already initialized. Find hosting context and retrieve context. | 9005 // Module already initialized. Find hosting context and retrieve context. |
9008 Context* host = Context::cast(isolate->context())->global_context(); | 9006 Context* host = Context::cast(isolate->context())->global_context(); |
9009 Context* context = Context::cast(host->get(index)); | 9007 Context* context = Context::cast(host->get(index)); |
9010 ASSERT(context->previous() == isolate->context()); | 9008 ASSERT(context->previous() == isolate->context()); |
9011 isolate->set_context(context); | 9009 isolate->set_context(context); |
(...skipping 14 matching lines...) Expand all Loading... | |
9026 context->set_global_object(previous->global_object()); | 9024 context->set_global_object(previous->global_object()); |
9027 isolate->set_context(*context); | 9025 isolate->set_context(*context); |
9028 | 9026 |
9029 // Find hosting scope and initialize internal variable holding module there. | 9027 // Find hosting scope and initialize internal variable holding module there. |
9030 previous->global_context()->set(index, *context); | 9028 previous->global_context()->set(index, *context); |
9031 | 9029 |
9032 return *context; | 9030 return *context; |
9033 } | 9031 } |
9034 | 9032 |
9035 | 9033 |
9036 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_DeclareModules) { | 9034 RUNTIME_FUNCTION(Object*, RuntimeHidden_DeclareModules) { |
9037 HandleScope scope(isolate); | 9035 HandleScope scope(isolate); |
9038 ASSERT(args.length() == 1); | 9036 ASSERT(args.length() == 1); |
9039 CONVERT_ARG_HANDLE_CHECKED(FixedArray, descriptions, 0); | 9037 CONVERT_ARG_HANDLE_CHECKED(FixedArray, descriptions, 0); |
9040 Context* host_context = isolate->context(); | 9038 Context* host_context = isolate->context(); |
9041 | 9039 |
9042 for (int i = 0; i < descriptions->length(); ++i) { | 9040 for (int i = 0; i < descriptions->length(); ++i) { |
9043 Handle<ModuleInfo> description(ModuleInfo::cast(descriptions->get(i))); | 9041 Handle<ModuleInfo> description(ModuleInfo::cast(descriptions->get(i))); |
9044 int host_index = description->host_index(); | 9042 int host_index = description->host_index(); |
9045 Handle<Context> context(Context::cast(host_context->get(host_index))); | 9043 Handle<Context> context(Context::cast(host_context->get(host_index))); |
9046 Handle<JSModule> module(context->module()); | 9044 Handle<JSModule> module(context->module()); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
9080 } | 9078 } |
9081 | 9079 |
9082 JSObject::PreventExtensions(module).Assert(); | 9080 JSObject::PreventExtensions(module).Assert(); |
9083 } | 9081 } |
9084 | 9082 |
9085 ASSERT(!isolate->has_pending_exception()); | 9083 ASSERT(!isolate->has_pending_exception()); |
9086 return isolate->heap()->undefined_value(); | 9084 return isolate->heap()->undefined_value(); |
9087 } | 9085 } |
9088 | 9086 |
9089 | 9087 |
9090 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_DeleteContextSlot) { | 9088 RUNTIME_FUNCTION(Object*, RuntimeHidden_DeleteContextSlot) { |
9091 HandleScope scope(isolate); | 9089 HandleScope scope(isolate); |
9092 ASSERT(args.length() == 2); | 9090 ASSERT(args.length() == 2); |
9093 | 9091 |
9094 CONVERT_ARG_HANDLE_CHECKED(Context, context, 0); | 9092 CONVERT_ARG_HANDLE_CHECKED(Context, context, 0); |
9095 CONVERT_ARG_HANDLE_CHECKED(String, name, 1); | 9093 CONVERT_ARG_HANDLE_CHECKED(String, name, 1); |
9096 | 9094 |
9097 int index; | 9095 int index; |
9098 PropertyAttributes attributes; | 9096 PropertyAttributes attributes; |
9099 ContextLookupFlags flags = FOLLOW_CHAINS; | 9097 ContextLookupFlags flags = FOLLOW_CHAINS; |
9100 BindingFlags binding_flags; | 9098 BindingFlags binding_flags; |
(...skipping 28 matching lines...) Expand all Loading... | |
9129 // A mechanism to return a pair of Object pointers in registers (if possible). | 9127 // A mechanism to return a pair of Object pointers in registers (if possible). |
9130 // How this is achieved is calling convention-dependent. | 9128 // How this is achieved is calling convention-dependent. |
9131 // All currently supported x86 compiles uses calling conventions that are cdecl | 9129 // All currently supported x86 compiles uses calling conventions that are cdecl |
9132 // variants where a 64-bit value is returned in two 32-bit registers | 9130 // variants where a 64-bit value is returned in two 32-bit registers |
9133 // (edx:eax on ia32, r1:r0 on ARM). | 9131 // (edx:eax on ia32, r1:r0 on ARM). |
9134 // In AMD-64 calling convention a struct of two pointers is returned in rdx:rax. | 9132 // In AMD-64 calling convention a struct of two pointers is returned in rdx:rax. |
9135 // In Win64 calling convention, a struct of two pointers is returned in memory, | 9133 // In Win64 calling convention, a struct of two pointers is returned in memory, |
9136 // allocated by the caller, and passed as a pointer in a hidden first parameter. | 9134 // allocated by the caller, and passed as a pointer in a hidden first parameter. |
9137 #ifdef V8_HOST_ARCH_64_BIT | 9135 #ifdef V8_HOST_ARCH_64_BIT |
9138 struct ObjectPair { | 9136 struct ObjectPair { |
9139 MaybeObject* x; | 9137 Object* x; |
9140 MaybeObject* y; | 9138 Object* y; |
9141 }; | 9139 }; |
9142 | 9140 |
9143 | 9141 |
9144 static inline ObjectPair MakePair(MaybeObject* x, MaybeObject* y) { | 9142 static inline ObjectPair MakePair(Object* x, Object* y) { |
9145 ObjectPair result = {x, y}; | 9143 ObjectPair result = {x, y}; |
9146 // Pointers x and y returned in rax and rdx, in AMD-x64-abi. | 9144 // Pointers x and y returned in rax and rdx, in AMD-x64-abi. |
9147 // In Win64 they are assigned to a hidden first argument. | 9145 // In Win64 they are assigned to a hidden first argument. |
9148 return result; | 9146 return result; |
9149 } | 9147 } |
9150 #else | 9148 #else |
9151 typedef uint64_t ObjectPair; | 9149 typedef uint64_t ObjectPair; |
9152 static inline ObjectPair MakePair(MaybeObject* x, MaybeObject* y) { | 9150 static inline ObjectPair MakePair(Object* x, Object* y) { |
9153 #if defined(V8_TARGET_LITTLE_ENDIAN) | 9151 #if defined(V8_TARGET_LITTLE_ENDIAN) |
9154 return reinterpret_cast<uint32_t>(x) | | 9152 return reinterpret_cast<uint32_t>(x) | |
9155 (reinterpret_cast<ObjectPair>(y) << 32); | 9153 (reinterpret_cast<ObjectPair>(y) << 32); |
9156 #elif defined(V8_TARGET_BIG_ENDIAN) | 9154 #elif defined(V8_TARGET_BIG_ENDIAN) |
9157 return reinterpret_cast<uint32_t>(y) | | 9155 return reinterpret_cast<uint32_t>(y) | |
9158 (reinterpret_cast<ObjectPair>(x) << 32); | 9156 (reinterpret_cast<ObjectPair>(x) << 32); |
9159 #else | 9157 #else |
9160 #error Unknown endianness | 9158 #error Unknown endianness |
9161 #endif | 9159 #endif |
9162 } | 9160 } |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
9198 int index; | 9196 int index; |
9199 PropertyAttributes attributes; | 9197 PropertyAttributes attributes; |
9200 ContextLookupFlags flags = FOLLOW_CHAINS; | 9198 ContextLookupFlags flags = FOLLOW_CHAINS; |
9201 BindingFlags binding_flags; | 9199 BindingFlags binding_flags; |
9202 Handle<Object> holder = context->Lookup(name, | 9200 Handle<Object> holder = context->Lookup(name, |
9203 flags, | 9201 flags, |
9204 &index, | 9202 &index, |
9205 &attributes, | 9203 &attributes, |
9206 &binding_flags); | 9204 &binding_flags); |
9207 if (isolate->has_pending_exception()) { | 9205 if (isolate->has_pending_exception()) { |
9208 return MakePair(Failure::Exception(), NULL); | 9206 return MakePair(isolate->heap()->exception(), NULL); |
9209 } | 9207 } |
9210 | 9208 |
9211 // If the index is non-negative, the slot has been found in a context. | 9209 // If the index is non-negative, the slot has been found in a context. |
9212 if (index >= 0) { | 9210 if (index >= 0) { |
9213 ASSERT(holder->IsContext()); | 9211 ASSERT(holder->IsContext()); |
9214 // If the "property" we were looking for is a local variable, the | 9212 // If the "property" we were looking for is a local variable, the |
9215 // receiver is the global object; see ECMA-262, 3rd., 10.1.6 and 10.2.3. | 9213 // receiver is the global object; see ECMA-262, 3rd., 10.1.6 and 10.2.3. |
9216 Handle<Object> receiver = isolate->factory()->undefined_value(); | 9214 Handle<Object> receiver = isolate->factory()->undefined_value(); |
9217 Object* value = Context::cast(*holder)->get(index); | 9215 Object* value = Context::cast(*holder)->get(index); |
9218 // Check for uninitialized bindings. | 9216 // Check for uninitialized bindings. |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
9256 : object->IsJSProxy() ? static_cast<Object*>(*object) | 9254 : object->IsJSProxy() ? static_cast<Object*>(*object) |
9257 : ComputeReceiverForNonGlobal(isolate, JSObject::cast(*object)), | 9255 : ComputeReceiverForNonGlobal(isolate, JSObject::cast(*object)), |
9258 isolate); | 9256 isolate); |
9259 | 9257 |
9260 // No need to unhole the value here. This is taken care of by the | 9258 // No need to unhole the value here. This is taken care of by the |
9261 // GetProperty function. | 9259 // GetProperty function. |
9262 Handle<Object> value; | 9260 Handle<Object> value; |
9263 ASSIGN_RETURN_ON_EXCEPTION_VALUE( | 9261 ASSIGN_RETURN_ON_EXCEPTION_VALUE( |
9264 isolate, value, | 9262 isolate, value, |
9265 Object::GetProperty(object, name), | 9263 Object::GetProperty(object, name), |
9266 MakePair(Failure::Exception(), NULL)); | 9264 MakePair(isolate->heap()->exception(), NULL)); |
9267 return MakePair(*value, *receiver_handle); | 9265 return MakePair(*value, *receiver_handle); |
9268 } | 9266 } |
9269 | 9267 |
9270 if (throw_error) { | 9268 if (throw_error) { |
9271 // The property doesn't exist - throw exception. | 9269 // The property doesn't exist - throw exception. |
9272 Handle<Object> reference_error = | 9270 Handle<Object> reference_error = |
9273 isolate->factory()->NewReferenceError("not_defined", | 9271 isolate->factory()->NewReferenceError("not_defined", |
9274 HandleVector(&name, 1)); | 9272 HandleVector(&name, 1)); |
9275 return MakePair(isolate->Throw(*reference_error), NULL); | 9273 return MakePair(isolate->Throw(*reference_error), NULL); |
9276 } else { | 9274 } else { |
9277 // The property doesn't exist - return undefined. | 9275 // The property doesn't exist - return undefined. |
9278 return MakePair(isolate->heap()->undefined_value(), | 9276 return MakePair(isolate->heap()->undefined_value(), |
9279 isolate->heap()->undefined_value()); | 9277 isolate->heap()->undefined_value()); |
9280 } | 9278 } |
9281 } | 9279 } |
9282 | 9280 |
9283 | 9281 |
9284 RUNTIME_FUNCTION(ObjectPair, RuntimeHidden_LoadContextSlot) { | 9282 RUNTIME_FUNCTION(ObjectPair, RuntimeHidden_LoadContextSlot) { |
9285 return LoadContextSlotHelper(args, isolate, true); | 9283 return LoadContextSlotHelper(args, isolate, true); |
9286 } | 9284 } |
9287 | 9285 |
9288 | 9286 |
9289 RUNTIME_FUNCTION(ObjectPair, RuntimeHidden_LoadContextSlotNoReferenceError) { | 9287 RUNTIME_FUNCTION(ObjectPair, RuntimeHidden_LoadContextSlotNoReferenceError) { |
9290 return LoadContextSlotHelper(args, isolate, false); | 9288 return LoadContextSlotHelper(args, isolate, false); |
9291 } | 9289 } |
9292 | 9290 |
9293 | 9291 |
9294 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_StoreContextSlot) { | 9292 RUNTIME_FUNCTION(Object*, RuntimeHidden_StoreContextSlot) { |
9295 HandleScope scope(isolate); | 9293 HandleScope scope(isolate); |
9296 ASSERT(args.length() == 4); | 9294 ASSERT(args.length() == 4); |
9297 | 9295 |
9298 CONVERT_ARG_HANDLE_CHECKED(Object, value, 0); | 9296 CONVERT_ARG_HANDLE_CHECKED(Object, value, 0); |
9299 CONVERT_ARG_HANDLE_CHECKED(Context, context, 1); | 9297 CONVERT_ARG_HANDLE_CHECKED(Context, context, 1); |
9300 CONVERT_ARG_HANDLE_CHECKED(String, name, 2); | 9298 CONVERT_ARG_HANDLE_CHECKED(String, name, 2); |
9301 CONVERT_STRICT_MODE_ARG_CHECKED(strict_mode, 3); | 9299 CONVERT_STRICT_MODE_ARG_CHECKED(strict_mode, 3); |
9302 | 9300 |
9303 int index; | 9301 int index; |
9304 PropertyAttributes attributes; | 9302 PropertyAttributes attributes; |
9305 ContextLookupFlags flags = FOLLOW_CHAINS; | 9303 ContextLookupFlags flags = FOLLOW_CHAINS; |
9306 BindingFlags binding_flags; | 9304 BindingFlags binding_flags; |
9307 Handle<Object> holder = context->Lookup(name, | 9305 Handle<Object> holder = context->Lookup(name, |
9308 flags, | 9306 flags, |
9309 &index, | 9307 &index, |
9310 &attributes, | 9308 &attributes, |
9311 &binding_flags); | 9309 &binding_flags); |
9312 if (isolate->has_pending_exception()) return Failure::Exception(); | 9310 if (isolate->has_pending_exception()) return isolate->heap()->exception(); |
9313 | 9311 |
9314 if (index >= 0) { | 9312 if (index >= 0) { |
9315 // The property was found in a context slot. | 9313 // The property was found in a context slot. |
9316 Handle<Context> context = Handle<Context>::cast(holder); | 9314 Handle<Context> context = Handle<Context>::cast(holder); |
9317 if (binding_flags == MUTABLE_CHECK_INITIALIZED && | 9315 if (binding_flags == MUTABLE_CHECK_INITIALIZED && |
9318 context->get(index)->IsTheHole()) { | 9316 context->get(index)->IsTheHole()) { |
9319 Handle<Object> error = | 9317 Handle<Object> error = |
9320 isolate->factory()->NewReferenceError("not_defined", | 9318 isolate->factory()->NewReferenceError("not_defined", |
9321 HandleVector(&name, 1)); | 9319 HandleVector(&name, 1)); |
9322 return isolate->Throw(*error); | 9320 return isolate->Throw(*error); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
9369 // Setting read only property in strict mode. | 9367 // Setting read only property in strict mode. |
9370 Handle<Object> error = | 9368 Handle<Object> error = |
9371 isolate->factory()->NewTypeError( | 9369 isolate->factory()->NewTypeError( |
9372 "strict_cannot_assign", HandleVector(&name, 1)); | 9370 "strict_cannot_assign", HandleVector(&name, 1)); |
9373 return isolate->Throw(*error); | 9371 return isolate->Throw(*error); |
9374 } | 9372 } |
9375 return *value; | 9373 return *value; |
9376 } | 9374 } |
9377 | 9375 |
9378 | 9376 |
9379 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_Throw) { | 9377 RUNTIME_FUNCTION(Object*, RuntimeHidden_Throw) { |
9380 HandleScope scope(isolate); | 9378 HandleScope scope(isolate); |
9381 ASSERT(args.length() == 1); | 9379 ASSERT(args.length() == 1); |
9382 | 9380 |
9383 return isolate->Throw(args[0]); | 9381 return isolate->Throw(args[0]); |
9384 } | 9382 } |
9385 | 9383 |
9386 | 9384 |
9387 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_ReThrow) { | 9385 RUNTIME_FUNCTION(Object*, RuntimeHidden_ReThrow) { |
9388 HandleScope scope(isolate); | 9386 HandleScope scope(isolate); |
9389 ASSERT(args.length() == 1); | 9387 ASSERT(args.length() == 1); |
9390 | 9388 |
9391 return isolate->ReThrow(args[0]); | 9389 return isolate->ReThrow(args[0]); |
9392 } | 9390 } |
9393 | 9391 |
9394 | 9392 |
9395 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_PromoteScheduledException) { | 9393 RUNTIME_FUNCTION(Object*, RuntimeHidden_PromoteScheduledException) { |
9396 SealHandleScope shs(isolate); | 9394 SealHandleScope shs(isolate); |
9397 ASSERT(args.length() == 0); | 9395 ASSERT(args.length() == 0); |
9398 return isolate->PromoteScheduledException(); | 9396 return isolate->PromoteScheduledException(); |
9399 } | 9397 } |
9400 | 9398 |
9401 | 9399 |
9402 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_ThrowReferenceError) { | 9400 RUNTIME_FUNCTION(Object*, RuntimeHidden_ThrowReferenceError) { |
9403 HandleScope scope(isolate); | 9401 HandleScope scope(isolate); |
9404 ASSERT(args.length() == 1); | 9402 ASSERT(args.length() == 1); |
9405 CONVERT_ARG_HANDLE_CHECKED(Object, name, 0); | 9403 CONVERT_ARG_HANDLE_CHECKED(Object, name, 0); |
9406 Handle<Object> reference_error = | 9404 Handle<Object> reference_error = |
9407 isolate->factory()->NewReferenceError("not_defined", | 9405 isolate->factory()->NewReferenceError("not_defined", |
9408 HandleVector(&name, 1)); | 9406 HandleVector(&name, 1)); |
9409 return isolate->Throw(*reference_error); | 9407 return isolate->Throw(*reference_error); |
9410 } | 9408 } |
9411 | 9409 |
9412 | 9410 |
9413 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_ThrowNotDateError) { | 9411 RUNTIME_FUNCTION(Object*, RuntimeHidden_ThrowNotDateError) { |
9414 HandleScope scope(isolate); | 9412 HandleScope scope(isolate); |
9415 ASSERT(args.length() == 0); | 9413 ASSERT(args.length() == 0); |
9416 return isolate->Throw(*isolate->factory()->NewTypeError( | 9414 return isolate->Throw(*isolate->factory()->NewTypeError( |
9417 "not_date_object", HandleVector<Object>(NULL, 0))); | 9415 "not_date_object", HandleVector<Object>(NULL, 0))); |
9418 } | 9416 } |
9419 | 9417 |
9420 | 9418 |
9421 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_ThrowMessage) { | 9419 RUNTIME_FUNCTION(Object*, RuntimeHidden_ThrowMessage) { |
9422 HandleScope scope(isolate); | 9420 HandleScope scope(isolate); |
9423 ASSERT(args.length() == 1); | 9421 ASSERT(args.length() == 1); |
9424 CONVERT_SMI_ARG_CHECKED(message_id, 0); | 9422 CONVERT_SMI_ARG_CHECKED(message_id, 0); |
9425 const char* message = GetBailoutReason( | 9423 const char* message = GetBailoutReason( |
9426 static_cast<BailoutReason>(message_id)); | 9424 static_cast<BailoutReason>(message_id)); |
9427 Handle<String> message_handle = | 9425 Handle<String> message_handle = |
9428 isolate->factory()->NewStringFromAsciiChecked(message); | 9426 isolate->factory()->NewStringFromAsciiChecked(message); |
9429 return isolate->Throw(*message_handle); | 9427 return isolate->Throw(*message_handle); |
9430 } | 9428 } |
9431 | 9429 |
9432 | 9430 |
9433 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_StackGuard) { | 9431 RUNTIME_FUNCTION(Object*, RuntimeHidden_StackGuard) { |
9434 SealHandleScope shs(isolate); | 9432 SealHandleScope shs(isolate); |
9435 ASSERT(args.length() == 0); | 9433 ASSERT(args.length() == 0); |
9436 | 9434 |
9437 // First check if this is a real stack overflow. | 9435 // First check if this is a real stack overflow. |
9438 if (isolate->stack_guard()->IsStackOverflow()) { | 9436 if (isolate->stack_guard()->IsStackOverflow()) { |
9439 return isolate->StackOverflow(); | 9437 return isolate->StackOverflow(); |
9440 } | 9438 } |
9441 | 9439 |
9442 return Execution::HandleStackGuardInterrupt(isolate); | 9440 return Execution::HandleStackGuardInterrupt(isolate); |
9443 } | 9441 } |
9444 | 9442 |
9445 | 9443 |
9446 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_TryInstallOptimizedCode) { | 9444 RUNTIME_FUNCTION(Object*, RuntimeHidden_TryInstallOptimizedCode) { |
9447 HandleScope scope(isolate); | 9445 HandleScope scope(isolate); |
9448 ASSERT(args.length() == 1); | 9446 ASSERT(args.length() == 1); |
9449 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 9447 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
9450 | 9448 |
9451 // First check if this is a real stack overflow. | 9449 // First check if this is a real stack overflow. |
9452 if (isolate->stack_guard()->IsStackOverflow()) { | 9450 if (isolate->stack_guard()->IsStackOverflow()) { |
9453 SealHandleScope shs(isolate); | 9451 SealHandleScope shs(isolate); |
9454 return isolate->StackOverflow(); | 9452 return isolate->StackOverflow(); |
9455 } | 9453 } |
9456 | 9454 |
9457 isolate->optimizing_compiler_thread()->InstallOptimizedFunctions(); | 9455 isolate->optimizing_compiler_thread()->InstallOptimizedFunctions(); |
9458 return (function->IsOptimized()) ? function->code() | 9456 return (function->IsOptimized()) ? function->code() |
9459 : function->shared()->code(); | 9457 : function->shared()->code(); |
9460 } | 9458 } |
9461 | 9459 |
9462 | 9460 |
9463 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_Interrupt) { | 9461 RUNTIME_FUNCTION(Object*, RuntimeHidden_Interrupt) { |
9464 SealHandleScope shs(isolate); | 9462 SealHandleScope shs(isolate); |
9465 ASSERT(args.length() == 0); | 9463 ASSERT(args.length() == 0); |
9466 return Execution::HandleStackGuardInterrupt(isolate); | 9464 return Execution::HandleStackGuardInterrupt(isolate); |
9467 } | 9465 } |
9468 | 9466 |
9469 | 9467 |
9470 static int StackSize(Isolate* isolate) { | 9468 static int StackSize(Isolate* isolate) { |
9471 int n = 0; | 9469 int n = 0; |
9472 for (JavaScriptFrameIterator it(isolate); !it.done(); it.Advance()) n++; | 9470 for (JavaScriptFrameIterator it(isolate); !it.done(); it.Advance()) n++; |
9473 return n; | 9471 return n; |
(...skipping 15 matching lines...) Expand all Loading... | |
9489 PrintF(" {\n"); | 9487 PrintF(" {\n"); |
9490 } else { | 9488 } else { |
9491 // function result | 9489 // function result |
9492 PrintF("} -> "); | 9490 PrintF("} -> "); |
9493 result->ShortPrint(); | 9491 result->ShortPrint(); |
9494 PrintF("\n"); | 9492 PrintF("\n"); |
9495 } | 9493 } |
9496 } | 9494 } |
9497 | 9495 |
9498 | 9496 |
9499 RUNTIME_FUNCTION(MaybeObject*, Runtime_TraceEnter) { | 9497 RUNTIME_FUNCTION(Object*, Runtime_TraceEnter) { |
9500 SealHandleScope shs(isolate); | 9498 SealHandleScope shs(isolate); |
9501 ASSERT(args.length() == 0); | 9499 ASSERT(args.length() == 0); |
9502 PrintTransition(isolate, NULL); | 9500 PrintTransition(isolate, NULL); |
9503 return isolate->heap()->undefined_value(); | 9501 return isolate->heap()->undefined_value(); |
9504 } | 9502 } |
9505 | 9503 |
9506 | 9504 |
9507 RUNTIME_FUNCTION(MaybeObject*, Runtime_TraceExit) { | 9505 RUNTIME_FUNCTION(Object*, Runtime_TraceExit) { |
9508 SealHandleScope shs(isolate); | 9506 SealHandleScope shs(isolate); |
9509 ASSERT(args.length() == 1); | 9507 ASSERT(args.length() == 1); |
9510 CONVERT_ARG_CHECKED(Object, obj, 0); | 9508 CONVERT_ARG_CHECKED(Object, obj, 0); |
9511 PrintTransition(isolate, obj); | 9509 PrintTransition(isolate, obj); |
9512 return obj; // return TOS | 9510 return obj; // return TOS |
9513 } | 9511 } |
9514 | 9512 |
9515 | 9513 |
9516 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugPrint) { | 9514 RUNTIME_FUNCTION(Object*, Runtime_DebugPrint) { |
9517 SealHandleScope shs(isolate); | 9515 SealHandleScope shs(isolate); |
9518 ASSERT(args.length() == 1); | 9516 ASSERT(args.length() == 1); |
9519 | 9517 |
9520 #ifdef DEBUG | 9518 #ifdef DEBUG |
9521 if (args[0]->IsString()) { | 9519 if (args[0]->IsString()) { |
9522 // If we have a string, assume it's a code "marker" | 9520 // If we have a string, assume it's a code "marker" |
9523 // and print some interesting cpu debugging info. | 9521 // and print some interesting cpu debugging info. |
9524 JavaScriptFrameIterator it(isolate); | 9522 JavaScriptFrameIterator it(isolate); |
9525 JavaScriptFrame* frame = it.frame(); | 9523 JavaScriptFrame* frame = it.frame(); |
9526 PrintF("fp = %p, sp = %p, caller_sp = %p: ", | 9524 PrintF("fp = %p, sp = %p, caller_sp = %p: ", |
(...skipping 10 matching lines...) Expand all Loading... | |
9537 // ShortPrint is available in release mode. Print is not. | 9535 // ShortPrint is available in release mode. Print is not. |
9538 args[0]->ShortPrint(); | 9536 args[0]->ShortPrint(); |
9539 #endif | 9537 #endif |
9540 PrintF("\n"); | 9538 PrintF("\n"); |
9541 Flush(); | 9539 Flush(); |
9542 | 9540 |
9543 return args[0]; // return TOS | 9541 return args[0]; // return TOS |
9544 } | 9542 } |
9545 | 9543 |
9546 | 9544 |
9547 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugTrace) { | 9545 RUNTIME_FUNCTION(Object*, Runtime_DebugTrace) { |
9548 SealHandleScope shs(isolate); | 9546 SealHandleScope shs(isolate); |
9549 ASSERT(args.length() == 0); | 9547 ASSERT(args.length() == 0); |
9550 isolate->PrintStack(stdout); | 9548 isolate->PrintStack(stdout); |
9551 return isolate->heap()->undefined_value(); | 9549 return isolate->heap()->undefined_value(); |
9552 } | 9550 } |
9553 | 9551 |
9554 | 9552 |
9555 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateCurrentTime) { | 9553 RUNTIME_FUNCTION(Object*, Runtime_DateCurrentTime) { |
9556 HandleScope scope(isolate); | 9554 HandleScope scope(isolate); |
9557 ASSERT(args.length() == 0); | 9555 ASSERT(args.length() == 0); |
9558 | 9556 |
9559 // According to ECMA-262, section 15.9.1, page 117, the precision of | 9557 // According to ECMA-262, section 15.9.1, page 117, the precision of |
9560 // the number in a Date object representing a particular instant in | 9558 // the number in a Date object representing a particular instant in |
9561 // time is milliseconds. Therefore, we floor the result of getting | 9559 // time is milliseconds. Therefore, we floor the result of getting |
9562 // the OS time. | 9560 // the OS time. |
9563 double millis = std::floor(OS::TimeCurrentMillis()); | 9561 double millis = std::floor(OS::TimeCurrentMillis()); |
9564 return *isolate->factory()->NewNumber(millis); | 9562 return *isolate->factory()->NewNumber(millis); |
9565 } | 9563 } |
9566 | 9564 |
9567 | 9565 |
9568 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateParseString) { | 9566 RUNTIME_FUNCTION(Object*, Runtime_DateParseString) { |
9569 HandleScope scope(isolate); | 9567 HandleScope scope(isolate); |
9570 ASSERT(args.length() == 2); | 9568 ASSERT(args.length() == 2); |
9571 CONVERT_ARG_HANDLE_CHECKED(String, str, 0); | 9569 CONVERT_ARG_HANDLE_CHECKED(String, str, 0); |
9572 CONVERT_ARG_HANDLE_CHECKED(JSArray, output, 1); | 9570 CONVERT_ARG_HANDLE_CHECKED(JSArray, output, 1); |
9573 | 9571 |
9574 JSObject::EnsureCanContainHeapObjectElements(output); | 9572 JSObject::EnsureCanContainHeapObjectElements(output); |
9575 RUNTIME_ASSERT(output->HasFastObjectElements()); | 9573 RUNTIME_ASSERT(output->HasFastObjectElements()); |
9576 | 9574 |
9577 str = String::Flatten(str); | 9575 str = String::Flatten(str); |
9578 DisallowHeapAllocation no_gc; | 9576 DisallowHeapAllocation no_gc; |
(...skipping 14 matching lines...) Expand all Loading... | |
9593 } | 9591 } |
9594 | 9592 |
9595 if (result) { | 9593 if (result) { |
9596 return *output; | 9594 return *output; |
9597 } else { | 9595 } else { |
9598 return isolate->heap()->null_value(); | 9596 return isolate->heap()->null_value(); |
9599 } | 9597 } |
9600 } | 9598 } |
9601 | 9599 |
9602 | 9600 |
9603 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateLocalTimezone) { | 9601 RUNTIME_FUNCTION(Object*, Runtime_DateLocalTimezone) { |
9604 HandleScope scope(isolate); | 9602 HandleScope scope(isolate); |
9605 ASSERT(args.length() == 1); | 9603 ASSERT(args.length() == 1); |
9606 | 9604 |
9607 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 9605 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
9608 const char* zone = | 9606 const char* zone = |
9609 isolate->date_cache()->LocalTimezone(static_cast<int64_t>(x)); | 9607 isolate->date_cache()->LocalTimezone(static_cast<int64_t>(x)); |
9610 Handle<String> result = isolate->factory()->NewStringFromUtf8( | 9608 Handle<String> result = isolate->factory()->NewStringFromUtf8( |
9611 CStrVector(zone)).ToHandleChecked(); | 9609 CStrVector(zone)).ToHandleChecked(); |
9612 return *result; | 9610 return *result; |
9613 } | 9611 } |
9614 | 9612 |
9615 | 9613 |
9616 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateToUTC) { | 9614 RUNTIME_FUNCTION(Object*, Runtime_DateToUTC) { |
9617 HandleScope scope(isolate); | 9615 HandleScope scope(isolate); |
9618 ASSERT(args.length() == 1); | 9616 ASSERT(args.length() == 1); |
9619 | 9617 |
9620 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 9618 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
9621 int64_t time = isolate->date_cache()->ToUTC(static_cast<int64_t>(x)); | 9619 int64_t time = isolate->date_cache()->ToUTC(static_cast<int64_t>(x)); |
9622 | 9620 |
9623 return *isolate->factory()->NewNumber(static_cast<double>(time)); | 9621 return *isolate->factory()->NewNumber(static_cast<double>(time)); |
9624 } | 9622 } |
9625 | 9623 |
9626 | 9624 |
9627 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateCacheVersion) { | 9625 RUNTIME_FUNCTION(Object*, Runtime_DateCacheVersion) { |
9628 HandleScope hs(isolate); | 9626 HandleScope hs(isolate); |
9629 ASSERT(args.length() == 0); | 9627 ASSERT(args.length() == 0); |
9630 if (!isolate->eternal_handles()->Exists(EternalHandles::DATE_CACHE_VERSION)) { | 9628 if (!isolate->eternal_handles()->Exists(EternalHandles::DATE_CACHE_VERSION)) { |
9631 Handle<FixedArray> date_cache_version = | 9629 Handle<FixedArray> date_cache_version = |
9632 isolate->factory()->NewFixedArray(1, TENURED); | 9630 isolate->factory()->NewFixedArray(1, TENURED); |
9633 date_cache_version->set(0, Smi::FromInt(0)); | 9631 date_cache_version->set(0, Smi::FromInt(0)); |
9634 isolate->eternal_handles()->CreateSingleton( | 9632 isolate->eternal_handles()->CreateSingleton( |
9635 isolate, *date_cache_version, EternalHandles::DATE_CACHE_VERSION); | 9633 isolate, *date_cache_version, EternalHandles::DATE_CACHE_VERSION); |
9636 } | 9634 } |
9637 Handle<FixedArray> date_cache_version = | 9635 Handle<FixedArray> date_cache_version = |
9638 Handle<FixedArray>::cast(isolate->eternal_handles()->GetSingleton( | 9636 Handle<FixedArray>::cast(isolate->eternal_handles()->GetSingleton( |
9639 EternalHandles::DATE_CACHE_VERSION)); | 9637 EternalHandles::DATE_CACHE_VERSION)); |
9640 // Return result as a JS array. | 9638 // Return result as a JS array. |
9641 Handle<JSObject> result = | 9639 Handle<JSObject> result = |
9642 isolate->factory()->NewJSObject(isolate->array_function()); | 9640 isolate->factory()->NewJSObject(isolate->array_function()); |
9643 JSArray::SetContent(Handle<JSArray>::cast(result), date_cache_version); | 9641 JSArray::SetContent(Handle<JSArray>::cast(result), date_cache_version); |
9644 return *result; | 9642 return *result; |
9645 } | 9643 } |
9646 | 9644 |
9647 | 9645 |
9648 RUNTIME_FUNCTION(MaybeObject*, Runtime_GlobalReceiver) { | 9646 RUNTIME_FUNCTION(Object*, Runtime_GlobalReceiver) { |
9649 SealHandleScope shs(isolate); | 9647 SealHandleScope shs(isolate); |
9650 ASSERT(args.length() == 1); | 9648 ASSERT(args.length() == 1); |
9651 CONVERT_ARG_CHECKED(Object, global, 0); | 9649 CONVERT_ARG_CHECKED(Object, global, 0); |
9652 if (!global->IsJSGlobalObject()) return isolate->heap()->null_value(); | 9650 if (!global->IsJSGlobalObject()) return isolate->heap()->null_value(); |
9653 return JSGlobalObject::cast(global)->global_receiver(); | 9651 return JSGlobalObject::cast(global)->global_receiver(); |
9654 } | 9652 } |
9655 | 9653 |
9656 | 9654 |
9657 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsAttachedGlobal) { | 9655 RUNTIME_FUNCTION(Object*, Runtime_IsAttachedGlobal) { |
9658 SealHandleScope shs(isolate); | 9656 SealHandleScope shs(isolate); |
9659 ASSERT(args.length() == 1); | 9657 ASSERT(args.length() == 1); |
9660 CONVERT_ARG_CHECKED(Object, global, 0); | 9658 CONVERT_ARG_CHECKED(Object, global, 0); |
9661 if (!global->IsJSGlobalObject()) return isolate->heap()->false_value(); | 9659 if (!global->IsJSGlobalObject()) return isolate->heap()->false_value(); |
9662 return isolate->heap()->ToBoolean( | 9660 return isolate->heap()->ToBoolean( |
9663 !JSGlobalObject::cast(global)->IsDetached()); | 9661 !JSGlobalObject::cast(global)->IsDetached()); |
9664 } | 9662 } |
9665 | 9663 |
9666 | 9664 |
9667 RUNTIME_FUNCTION(MaybeObject*, Runtime_ParseJson) { | 9665 RUNTIME_FUNCTION(Object*, Runtime_ParseJson) { |
9668 HandleScope scope(isolate); | 9666 HandleScope scope(isolate); |
9669 ASSERT(args.length() == 1); | 9667 ASSERT(args.length() == 1); |
9670 CONVERT_ARG_HANDLE_CHECKED(String, source, 0); | 9668 CONVERT_ARG_HANDLE_CHECKED(String, source, 0); |
9671 | 9669 |
9672 source = String::Flatten(source); | 9670 source = String::Flatten(source); |
9673 // Optimized fast case where we only have ASCII characters. | 9671 // Optimized fast case where we only have ASCII characters. |
9674 Handle<Object> result; | 9672 Handle<Object> result; |
9675 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 9673 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
9676 isolate, result, | 9674 isolate, result, |
9677 source->IsSeqOneByteString() ? JsonParser<true>::Parse(source) | 9675 source->IsSeqOneByteString() ? JsonParser<true>::Parse(source) |
(...skipping 12 matching lines...) Expand all Loading... | |
9690 // No callback set and code generation disallowed. | 9688 // No callback set and code generation disallowed. |
9691 return false; | 9689 return false; |
9692 } else { | 9690 } else { |
9693 // Callback set. Let it decide if code generation is allowed. | 9691 // Callback set. Let it decide if code generation is allowed. |
9694 VMState<EXTERNAL> state(isolate); | 9692 VMState<EXTERNAL> state(isolate); |
9695 return callback(v8::Utils::ToLocal(context)); | 9693 return callback(v8::Utils::ToLocal(context)); |
9696 } | 9694 } |
9697 } | 9695 } |
9698 | 9696 |
9699 | 9697 |
9700 RUNTIME_FUNCTION(MaybeObject*, Runtime_CompileString) { | 9698 RUNTIME_FUNCTION(Object*, Runtime_CompileString) { |
9701 HandleScope scope(isolate); | 9699 HandleScope scope(isolate); |
9702 ASSERT(args.length() == 2); | 9700 ASSERT(args.length() == 2); |
9703 CONVERT_ARG_HANDLE_CHECKED(String, source, 0); | 9701 CONVERT_ARG_HANDLE_CHECKED(String, source, 0); |
9704 CONVERT_BOOLEAN_ARG_CHECKED(function_literal_only, 1); | 9702 CONVERT_BOOLEAN_ARG_CHECKED(function_literal_only, 1); |
9705 | 9703 |
9706 // Extract native context. | 9704 // Extract native context. |
9707 Handle<Context> context(isolate->context()->native_context()); | 9705 Handle<Context> context(isolate->context()->native_context()); |
9708 | 9706 |
9709 // Check if native context allows code generation from | 9707 // Check if native context allows code generation from |
9710 // strings. Throw an exception if it doesn't. | 9708 // strings. Throw an exception if it doesn't. |
(...skipping 26 matching lines...) Expand all Loading... | |
9737 Handle<Context> native_context = Handle<Context>(context->native_context()); | 9735 Handle<Context> native_context = Handle<Context>(context->native_context()); |
9738 | 9736 |
9739 // Check if native context allows code generation from | 9737 // Check if native context allows code generation from |
9740 // strings. Throw an exception if it doesn't. | 9738 // strings. Throw an exception if it doesn't. |
9741 if (native_context->allow_code_gen_from_strings()->IsFalse() && | 9739 if (native_context->allow_code_gen_from_strings()->IsFalse() && |
9742 !CodeGenerationFromStringsAllowed(isolate, native_context)) { | 9740 !CodeGenerationFromStringsAllowed(isolate, native_context)) { |
9743 Handle<Object> error_message = | 9741 Handle<Object> error_message = |
9744 native_context->ErrorMessageForCodeGenerationFromStrings(); | 9742 native_context->ErrorMessageForCodeGenerationFromStrings(); |
9745 isolate->Throw(*isolate->factory()->NewEvalError( | 9743 isolate->Throw(*isolate->factory()->NewEvalError( |
9746 "code_gen_from_strings", HandleVector<Object>(&error_message, 1))); | 9744 "code_gen_from_strings", HandleVector<Object>(&error_message, 1))); |
9747 return MakePair(Failure::Exception(), NULL); | 9745 return MakePair(isolate->heap()->exception(), NULL); |
9748 } | 9746 } |
9749 | 9747 |
9750 // Deal with a normal eval call with a string argument. Compile it | 9748 // Deal with a normal eval call with a string argument. Compile it |
9751 // and return the compiled function bound in the local context. | 9749 // and return the compiled function bound in the local context. |
9752 static const ParseRestriction restriction = NO_PARSE_RESTRICTION; | 9750 static const ParseRestriction restriction = NO_PARSE_RESTRICTION; |
9753 Handle<JSFunction> compiled; | 9751 Handle<JSFunction> compiled; |
9754 ASSIGN_RETURN_ON_EXCEPTION_VALUE( | 9752 ASSIGN_RETURN_ON_EXCEPTION_VALUE( |
9755 isolate, compiled, | 9753 isolate, compiled, |
9756 Compiler::GetFunctionFromEval( | 9754 Compiler::GetFunctionFromEval( |
9757 source, context, strict_mode, restriction, scope_position), | 9755 source, context, strict_mode, restriction, scope_position), |
9758 MakePair(Failure::Exception(), NULL)); | 9756 MakePair(isolate->heap()->exception(), NULL)); |
9759 return MakePair(*compiled, *receiver); | 9757 return MakePair(*compiled, *receiver); |
9760 } | 9758 } |
9761 | 9759 |
9762 | 9760 |
9763 RUNTIME_FUNCTION(ObjectPair, RuntimeHidden_ResolvePossiblyDirectEval) { | 9761 RUNTIME_FUNCTION(ObjectPair, RuntimeHidden_ResolvePossiblyDirectEval) { |
9764 HandleScope scope(isolate); | 9762 HandleScope scope(isolate); |
9765 ASSERT(args.length() == 5); | 9763 ASSERT(args.length() == 5); |
9766 | 9764 |
9767 Handle<Object> callee = args.at<Object>(0); | 9765 Handle<Object> callee = args.at<Object>(0); |
9768 | 9766 |
(...skipping 12 matching lines...) Expand all Loading... | |
9781 StrictMode strict_mode = static_cast<StrictMode>(args.smi_at(3)); | 9779 StrictMode strict_mode = static_cast<StrictMode>(args.smi_at(3)); |
9782 ASSERT(args[4]->IsSmi()); | 9780 ASSERT(args[4]->IsSmi()); |
9783 return CompileGlobalEval(isolate, | 9781 return CompileGlobalEval(isolate, |
9784 args.at<String>(1), | 9782 args.at<String>(1), |
9785 args.at<Object>(2), | 9783 args.at<Object>(2), |
9786 strict_mode, | 9784 strict_mode, |
9787 args.smi_at(4)); | 9785 args.smi_at(4)); |
9788 } | 9786 } |
9789 | 9787 |
9790 | 9788 |
9791 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_AllocateInNewSpace) { | 9789 RUNTIME_FUNCTION(Object*, RuntimeHidden_AllocateInNewSpace) { |
9792 HandleScope scope(isolate); | 9790 HandleScope scope(isolate); |
9793 ASSERT(args.length() == 1); | 9791 ASSERT(args.length() == 1); |
9794 CONVERT_SMI_ARG_CHECKED(size, 0); | 9792 CONVERT_SMI_ARG_CHECKED(size, 0); |
9795 RUNTIME_ASSERT(IsAligned(size, kPointerSize)); | 9793 RUNTIME_ASSERT(IsAligned(size, kPointerSize)); |
9796 RUNTIME_ASSERT(size > 0); | 9794 RUNTIME_ASSERT(size > 0); |
9797 RUNTIME_ASSERT(size <= Page::kMaxRegularHeapObjectSize); | 9795 RUNTIME_ASSERT(size <= Page::kMaxRegularHeapObjectSize); |
9798 return *isolate->factory()->NewFillerObject(size, false, NEW_SPACE); | 9796 return *isolate->factory()->NewFillerObject(size, false, NEW_SPACE); |
9799 } | 9797 } |
9800 | 9798 |
9801 | 9799 |
9802 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_AllocateInTargetSpace) { | 9800 RUNTIME_FUNCTION(Object*, RuntimeHidden_AllocateInTargetSpace) { |
9803 HandleScope scope(isolate); | 9801 HandleScope scope(isolate); |
9804 ASSERT(args.length() == 2); | 9802 ASSERT(args.length() == 2); |
9805 CONVERT_SMI_ARG_CHECKED(size, 0); | 9803 CONVERT_SMI_ARG_CHECKED(size, 0); |
9806 CONVERT_SMI_ARG_CHECKED(flags, 1); | 9804 CONVERT_SMI_ARG_CHECKED(flags, 1); |
9807 RUNTIME_ASSERT(IsAligned(size, kPointerSize)); | 9805 RUNTIME_ASSERT(IsAligned(size, kPointerSize)); |
9808 RUNTIME_ASSERT(size > 0); | 9806 RUNTIME_ASSERT(size > 0); |
9809 RUNTIME_ASSERT(size <= Page::kMaxRegularHeapObjectSize); | 9807 RUNTIME_ASSERT(size <= Page::kMaxRegularHeapObjectSize); |
9810 bool double_align = AllocateDoubleAlignFlag::decode(flags); | 9808 bool double_align = AllocateDoubleAlignFlag::decode(flags); |
9811 AllocationSpace space = AllocateTargetSpace::decode(flags); | 9809 AllocationSpace space = AllocateTargetSpace::decode(flags); |
9812 return *isolate->factory()->NewFillerObject(size, double_align, space); | 9810 return *isolate->factory()->NewFillerObject(size, double_align, space); |
9813 } | 9811 } |
9814 | 9812 |
9815 | 9813 |
9816 // Push an object unto an array of objects if it is not already in the | 9814 // Push an object unto an array of objects if it is not already in the |
9817 // array. Returns true if the element was pushed on the stack and | 9815 // array. Returns true if the element was pushed on the stack and |
9818 // false otherwise. | 9816 // false otherwise. |
9819 RUNTIME_FUNCTION(MaybeObject*, Runtime_PushIfAbsent) { | 9817 RUNTIME_FUNCTION(Object*, Runtime_PushIfAbsent) { |
9820 HandleScope scope(isolate); | 9818 HandleScope scope(isolate); |
9821 ASSERT(args.length() == 2); | 9819 ASSERT(args.length() == 2); |
9822 CONVERT_ARG_HANDLE_CHECKED(JSArray, array, 0); | 9820 CONVERT_ARG_HANDLE_CHECKED(JSArray, array, 0); |
9823 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, element, 1); | 9821 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, element, 1); |
9824 RUNTIME_ASSERT(array->HasFastSmiOrObjectElements()); | 9822 RUNTIME_ASSERT(array->HasFastSmiOrObjectElements()); |
9825 int length = Smi::cast(array->length())->value(); | 9823 int length = Smi::cast(array->length())->value(); |
9826 FixedArray* elements = FixedArray::cast(array->elements()); | 9824 FixedArray* elements = FixedArray::cast(array->elements()); |
9827 for (int i = 0; i < length; i++) { | 9825 for (int i = 0; i < length; i++) { |
9828 if (elements->get(i) == *element) return isolate->heap()->false_value(); | 9826 if (elements->get(i) == *element) return isolate->heap()->false_value(); |
9829 } | 9827 } |
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
10317 return true; | 10315 return true; |
10318 } | 10316 } |
10319 | 10317 |
10320 | 10318 |
10321 /** | 10319 /** |
10322 * Array::concat implementation. | 10320 * Array::concat implementation. |
10323 * See ECMAScript 262, 15.4.4.4. | 10321 * See ECMAScript 262, 15.4.4.4. |
10324 * TODO(581): Fix non-compliance for very large concatenations and update to | 10322 * TODO(581): Fix non-compliance for very large concatenations and update to |
10325 * following the ECMAScript 5 specification. | 10323 * following the ECMAScript 5 specification. |
10326 */ | 10324 */ |
10327 RUNTIME_FUNCTION(MaybeObject*, Runtime_ArrayConcat) { | 10325 RUNTIME_FUNCTION(Object*, Runtime_ArrayConcat) { |
10328 HandleScope handle_scope(isolate); | 10326 HandleScope handle_scope(isolate); |
10329 ASSERT(args.length() == 1); | 10327 ASSERT(args.length() == 1); |
10330 | 10328 |
10331 CONVERT_ARG_HANDLE_CHECKED(JSArray, arguments, 0); | 10329 CONVERT_ARG_HANDLE_CHECKED(JSArray, arguments, 0); |
10332 int argument_count = static_cast<int>(arguments->length()->Number()); | 10330 int argument_count = static_cast<int>(arguments->length()->Number()); |
10333 RUNTIME_ASSERT(arguments->HasFastObjectElements()); | 10331 RUNTIME_ASSERT(arguments->HasFastObjectElements()); |
10334 Handle<FixedArray> elements(FixedArray::cast(arguments->elements())); | 10332 Handle<FixedArray> elements(FixedArray::cast(arguments->elements())); |
10335 | 10333 |
10336 // Pass 1: estimate the length and number of elements of the result. | 10334 // Pass 1: estimate the length and number of elements of the result. |
10337 // The actual length can be larger if any of the arguments have getters | 10335 // The actual length can be larger if any of the arguments have getters |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
10473 isolate->factory()->NewSeededNumberDictionary(at_least_space_for)); | 10471 isolate->factory()->NewSeededNumberDictionary(at_least_space_for)); |
10474 } | 10472 } |
10475 | 10473 |
10476 ArrayConcatVisitor visitor(isolate, storage, fast_case); | 10474 ArrayConcatVisitor visitor(isolate, storage, fast_case); |
10477 | 10475 |
10478 for (int i = 0; i < argument_count; i++) { | 10476 for (int i = 0; i < argument_count; i++) { |
10479 Handle<Object> obj(elements->get(i), isolate); | 10477 Handle<Object> obj(elements->get(i), isolate); |
10480 if (obj->IsJSArray()) { | 10478 if (obj->IsJSArray()) { |
10481 Handle<JSArray> array = Handle<JSArray>::cast(obj); | 10479 Handle<JSArray> array = Handle<JSArray>::cast(obj); |
10482 if (!IterateElements(isolate, array, &visitor)) { | 10480 if (!IterateElements(isolate, array, &visitor)) { |
10483 return Failure::Exception(); | 10481 return isolate->heap()->exception(); |
10484 } | 10482 } |
10485 } else { | 10483 } else { |
10486 visitor.visit(0, obj); | 10484 visitor.visit(0, obj); |
10487 visitor.increase_index_offset(1); | 10485 visitor.increase_index_offset(1); |
10488 } | 10486 } |
10489 } | 10487 } |
10490 | 10488 |
10491 if (visitor.exceeds_array_limit()) { | 10489 if (visitor.exceeds_array_limit()) { |
10492 return isolate->Throw( | 10490 return isolate->Throw( |
10493 *isolate->factory()->NewRangeError("invalid_array_length", | 10491 *isolate->factory()->NewRangeError("invalid_array_length", |
10494 HandleVector<Object>(NULL, 0))); | 10492 HandleVector<Object>(NULL, 0))); |
10495 } | 10493 } |
10496 return *visitor.ToArray(); | 10494 return *visitor.ToArray(); |
10497 } | 10495 } |
10498 | 10496 |
10499 | 10497 |
10500 // This will not allocate (flatten the string), but it may run | 10498 // This will not allocate (flatten the string), but it may run |
10501 // very slowly for very deeply nested ConsStrings. For debugging use only. | 10499 // very slowly for very deeply nested ConsStrings. For debugging use only. |
10502 RUNTIME_FUNCTION(MaybeObject*, Runtime_GlobalPrint) { | 10500 RUNTIME_FUNCTION(Object*, Runtime_GlobalPrint) { |
10503 SealHandleScope shs(isolate); | 10501 SealHandleScope shs(isolate); |
10504 ASSERT(args.length() == 1); | 10502 ASSERT(args.length() == 1); |
10505 | 10503 |
10506 CONVERT_ARG_CHECKED(String, string, 0); | 10504 CONVERT_ARG_CHECKED(String, string, 0); |
10507 ConsStringIteratorOp op; | 10505 ConsStringIteratorOp op; |
10508 StringCharacterStream stream(string, &op); | 10506 StringCharacterStream stream(string, &op); |
10509 while (stream.HasMore()) { | 10507 while (stream.HasMore()) { |
10510 uint16_t character = stream.GetNext(); | 10508 uint16_t character = stream.GetNext(); |
10511 PrintF("%c", character); | 10509 PrintF("%c", character); |
10512 } | 10510 } |
10513 return string; | 10511 return string; |
10514 } | 10512 } |
10515 | 10513 |
10516 | 10514 |
10517 // Moves all own elements of an object, that are below a limit, to positions | 10515 // Moves all own elements of an object, that are below a limit, to positions |
10518 // starting at zero. All undefined values are placed after non-undefined values, | 10516 // starting at zero. All undefined values are placed after non-undefined values, |
10519 // and are followed by non-existing element. Does not change the length | 10517 // and are followed by non-existing element. Does not change the length |
10520 // property. | 10518 // property. |
10521 // Returns the number of non-undefined elements collected. | 10519 // Returns the number of non-undefined elements collected. |
10522 // Returns -1 if hole removal is not supported by this method. | 10520 // Returns -1 if hole removal is not supported by this method. |
10523 RUNTIME_FUNCTION(MaybeObject*, Runtime_RemoveArrayHoles) { | 10521 RUNTIME_FUNCTION(Object*, Runtime_RemoveArrayHoles) { |
10524 HandleScope scope(isolate); | 10522 HandleScope scope(isolate); |
10525 ASSERT(args.length() == 2); | 10523 ASSERT(args.length() == 2); |
10526 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); | 10524 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); |
10527 CONVERT_NUMBER_CHECKED(uint32_t, limit, Uint32, args[1]); | 10525 CONVERT_NUMBER_CHECKED(uint32_t, limit, Uint32, args[1]); |
10528 return *JSObject::PrepareElementsForSort(object, limit); | 10526 return *JSObject::PrepareElementsForSort(object, limit); |
10529 } | 10527 } |
10530 | 10528 |
10531 | 10529 |
10532 // Move contents of argument 0 (an array) to argument 1 (an array) | 10530 // Move contents of argument 0 (an array) to argument 1 (an array) |
10533 RUNTIME_FUNCTION(MaybeObject*, Runtime_MoveArrayContents) { | 10531 RUNTIME_FUNCTION(Object*, Runtime_MoveArrayContents) { |
10534 HandleScope scope(isolate); | 10532 HandleScope scope(isolate); |
10535 ASSERT(args.length() == 2); | 10533 ASSERT(args.length() == 2); |
10536 CONVERT_ARG_HANDLE_CHECKED(JSArray, from, 0); | 10534 CONVERT_ARG_HANDLE_CHECKED(JSArray, from, 0); |
10537 CONVERT_ARG_HANDLE_CHECKED(JSArray, to, 1); | 10535 CONVERT_ARG_HANDLE_CHECKED(JSArray, to, 1); |
10538 JSObject::ValidateElements(from); | 10536 JSObject::ValidateElements(from); |
10539 JSObject::ValidateElements(to); | 10537 JSObject::ValidateElements(to); |
10540 | 10538 |
10541 Handle<FixedArrayBase> new_elements(from->elements()); | 10539 Handle<FixedArrayBase> new_elements(from->elements()); |
10542 ElementsKind from_kind = from->GetElementsKind(); | 10540 ElementsKind from_kind = from->GetElementsKind(); |
10543 Handle<Map> new_map = JSObject::GetElementsTransitionMap(to, from_kind); | 10541 Handle<Map> new_map = JSObject::GetElementsTransitionMap(to, from_kind); |
10544 JSObject::SetMapAndElements(to, new_map, new_elements); | 10542 JSObject::SetMapAndElements(to, new_map, new_elements); |
10545 to->set_length(from->length()); | 10543 to->set_length(from->length()); |
10546 | 10544 |
10547 JSObject::ResetElements(from); | 10545 JSObject::ResetElements(from); |
10548 from->set_length(Smi::FromInt(0)); | 10546 from->set_length(Smi::FromInt(0)); |
10549 | 10547 |
10550 JSObject::ValidateElements(to); | 10548 JSObject::ValidateElements(to); |
10551 return *to; | 10549 return *to; |
10552 } | 10550 } |
10553 | 10551 |
10554 | 10552 |
10555 // How many elements does this object/array have? | 10553 // How many elements does this object/array have? |
10556 RUNTIME_FUNCTION(MaybeObject*, Runtime_EstimateNumberOfElements) { | 10554 RUNTIME_FUNCTION(Object*, Runtime_EstimateNumberOfElements) { |
10557 SealHandleScope shs(isolate); | 10555 SealHandleScope shs(isolate); |
10558 ASSERT(args.length() == 1); | 10556 ASSERT(args.length() == 1); |
10559 CONVERT_ARG_CHECKED(JSObject, object, 0); | 10557 CONVERT_ARG_CHECKED(JSObject, object, 0); |
10560 HeapObject* elements = object->elements(); | 10558 HeapObject* elements = object->elements(); |
10561 if (elements->IsDictionary()) { | 10559 if (elements->IsDictionary()) { |
10562 int result = SeededNumberDictionary::cast(elements)->NumberOfElements(); | 10560 int result = SeededNumberDictionary::cast(elements)->NumberOfElements(); |
10563 return Smi::FromInt(result); | 10561 return Smi::FromInt(result); |
10564 } else if (object->IsJSArray()) { | 10562 } else if (object->IsJSArray()) { |
10565 return JSArray::cast(object)->length(); | 10563 return JSArray::cast(object)->length(); |
10566 } else { | 10564 } else { |
10567 return Smi::FromInt(FixedArray::cast(elements)->length()); | 10565 return Smi::FromInt(FixedArray::cast(elements)->length()); |
10568 } | 10566 } |
10569 } | 10567 } |
10570 | 10568 |
10571 | 10569 |
10572 // Returns an array that tells you where in the [0, length) interval an array | 10570 // Returns an array that tells you where in the [0, length) interval an array |
10573 // might have elements. Can either return an array of keys (positive integers | 10571 // might have elements. Can either return an array of keys (positive integers |
10574 // or undefined) or a number representing the positive length of an interval | 10572 // or undefined) or a number representing the positive length of an interval |
10575 // starting at index 0. | 10573 // starting at index 0. |
10576 // Intervals can span over some keys that are not in the object. | 10574 // Intervals can span over some keys that are not in the object. |
10577 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetArrayKeys) { | 10575 RUNTIME_FUNCTION(Object*, Runtime_GetArrayKeys) { |
10578 HandleScope scope(isolate); | 10576 HandleScope scope(isolate); |
10579 ASSERT(args.length() == 2); | 10577 ASSERT(args.length() == 2); |
10580 CONVERT_ARG_HANDLE_CHECKED(JSObject, array, 0); | 10578 CONVERT_ARG_HANDLE_CHECKED(JSObject, array, 0); |
10581 CONVERT_NUMBER_CHECKED(uint32_t, length, Uint32, args[1]); | 10579 CONVERT_NUMBER_CHECKED(uint32_t, length, Uint32, args[1]); |
10582 if (array->elements()->IsDictionary()) { | 10580 if (array->elements()->IsDictionary()) { |
10583 Handle<FixedArray> keys = isolate->factory()->empty_fixed_array(); | 10581 Handle<FixedArray> keys = isolate->factory()->empty_fixed_array(); |
10584 for (Handle<Object> p = array; | 10582 for (Handle<Object> p = array; |
10585 !p->IsNull(); | 10583 !p->IsNull(); |
10586 p = Handle<Object>(p->GetPrototype(isolate), isolate)) { | 10584 p = Handle<Object>(p->GetPrototype(isolate), isolate)) { |
10587 if (p->IsJSProxy() || JSObject::cast(*p)->HasIndexedInterceptor()) { | 10585 if (p->IsJSProxy() || JSObject::cast(*p)->HasIndexedInterceptor()) { |
(...skipping 18 matching lines...) Expand all Loading... | |
10606 return *isolate->factory()->NewJSArrayWithElements(keys); | 10604 return *isolate->factory()->NewJSArrayWithElements(keys); |
10607 } else { | 10605 } else { |
10608 ASSERT(array->HasFastSmiOrObjectElements() || | 10606 ASSERT(array->HasFastSmiOrObjectElements() || |
10609 array->HasFastDoubleElements()); | 10607 array->HasFastDoubleElements()); |
10610 uint32_t actual_length = static_cast<uint32_t>(array->elements()->length()); | 10608 uint32_t actual_length = static_cast<uint32_t>(array->elements()->length()); |
10611 return *isolate->factory()->NewNumberFromUint(Min(actual_length, length)); | 10609 return *isolate->factory()->NewNumberFromUint(Min(actual_length, length)); |
10612 } | 10610 } |
10613 } | 10611 } |
10614 | 10612 |
10615 | 10613 |
10616 RUNTIME_FUNCTION(MaybeObject*, Runtime_LookupAccessor) { | 10614 RUNTIME_FUNCTION(Object*, Runtime_LookupAccessor) { |
10617 HandleScope scope(isolate); | 10615 HandleScope scope(isolate); |
10618 ASSERT(args.length() == 3); | 10616 ASSERT(args.length() == 3); |
10619 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, receiver, 0); | 10617 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, receiver, 0); |
10620 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); | 10618 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); |
10621 CONVERT_SMI_ARG_CHECKED(flag, 2); | 10619 CONVERT_SMI_ARG_CHECKED(flag, 2); |
10622 AccessorComponent component = flag == 0 ? ACCESSOR_GETTER : ACCESSOR_SETTER; | 10620 AccessorComponent component = flag == 0 ? ACCESSOR_GETTER : ACCESSOR_SETTER; |
10623 if (!receiver->IsJSObject()) return isolate->heap()->undefined_value(); | 10621 if (!receiver->IsJSObject()) return isolate->heap()->undefined_value(); |
10624 Handle<Object> result; | 10622 Handle<Object> result; |
10625 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 10623 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
10626 isolate, result, | 10624 isolate, result, |
10627 JSObject::GetAccessor(Handle<JSObject>::cast(receiver), name, component)); | 10625 JSObject::GetAccessor(Handle<JSObject>::cast(receiver), name, component)); |
10628 return *result; | 10626 return *result; |
10629 } | 10627 } |
10630 | 10628 |
10631 | 10629 |
10632 #ifdef ENABLE_DEBUGGER_SUPPORT | 10630 #ifdef ENABLE_DEBUGGER_SUPPORT |
10633 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugBreak) { | 10631 RUNTIME_FUNCTION(Object*, Runtime_DebugBreak) { |
10634 SealHandleScope shs(isolate); | 10632 SealHandleScope shs(isolate); |
10635 ASSERT(args.length() == 0); | 10633 ASSERT(args.length() == 0); |
10636 return Execution::DebugBreakHelper(isolate); | 10634 return Execution::DebugBreakHelper(isolate); |
10637 } | 10635 } |
10638 | 10636 |
10639 | 10637 |
10640 // Helper functions for wrapping and unwrapping stack frame ids. | 10638 // Helper functions for wrapping and unwrapping stack frame ids. |
10641 static Smi* WrapFrameId(StackFrame::Id id) { | 10639 static Smi* WrapFrameId(StackFrame::Id id) { |
10642 ASSERT(IsAligned(OffsetFrom(id), static_cast<intptr_t>(4))); | 10640 ASSERT(IsAligned(OffsetFrom(id), static_cast<intptr_t>(4))); |
10643 return Smi::FromInt(id >> 2); | 10641 return Smi::FromInt(id >> 2); |
10644 } | 10642 } |
10645 | 10643 |
10646 | 10644 |
10647 static StackFrame::Id UnwrapFrameId(int wrapped) { | 10645 static StackFrame::Id UnwrapFrameId(int wrapped) { |
10648 return static_cast<StackFrame::Id>(wrapped << 2); | 10646 return static_cast<StackFrame::Id>(wrapped << 2); |
10649 } | 10647 } |
10650 | 10648 |
10651 | 10649 |
10652 // Adds a JavaScript function as a debug event listener. | 10650 // Adds a JavaScript function as a debug event listener. |
10653 // args[0]: debug event listener function to set or null or undefined for | 10651 // args[0]: debug event listener function to set or null or undefined for |
10654 // clearing the event listener function | 10652 // clearing the event listener function |
10655 // args[1]: object supplied during callback | 10653 // args[1]: object supplied during callback |
10656 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetDebugEventListener) { | 10654 RUNTIME_FUNCTION(Object*, Runtime_SetDebugEventListener) { |
10657 SealHandleScope shs(isolate); | 10655 SealHandleScope shs(isolate); |
10658 ASSERT(args.length() == 2); | 10656 ASSERT(args.length() == 2); |
10659 RUNTIME_ASSERT(args[0]->IsJSFunction() || | 10657 RUNTIME_ASSERT(args[0]->IsJSFunction() || |
10660 args[0]->IsUndefined() || | 10658 args[0]->IsUndefined() || |
10661 args[0]->IsNull()); | 10659 args[0]->IsNull()); |
10662 CONVERT_ARG_HANDLE_CHECKED(Object, callback, 0); | 10660 CONVERT_ARG_HANDLE_CHECKED(Object, callback, 0); |
10663 CONVERT_ARG_HANDLE_CHECKED(Object, data, 1); | 10661 CONVERT_ARG_HANDLE_CHECKED(Object, data, 1); |
10664 isolate->debugger()->SetEventListener(callback, data); | 10662 isolate->debugger()->SetEventListener(callback, data); |
10665 | 10663 |
10666 return isolate->heap()->undefined_value(); | 10664 return isolate->heap()->undefined_value(); |
10667 } | 10665 } |
10668 | 10666 |
10669 | 10667 |
10670 RUNTIME_FUNCTION(MaybeObject*, Runtime_Break) { | 10668 RUNTIME_FUNCTION(Object*, Runtime_Break) { |
10671 SealHandleScope shs(isolate); | 10669 SealHandleScope shs(isolate); |
10672 ASSERT(args.length() == 0); | 10670 ASSERT(args.length() == 0); |
10673 isolate->stack_guard()->DebugBreak(); | 10671 isolate->stack_guard()->DebugBreak(); |
10674 return isolate->heap()->undefined_value(); | 10672 return isolate->heap()->undefined_value(); |
10675 } | 10673 } |
10676 | 10674 |
10677 | 10675 |
10678 static Handle<Object> DebugLookupResultValue(Isolate* isolate, | 10676 static Handle<Object> DebugLookupResultValue(Isolate* isolate, |
10679 Handle<Object> receiver, | 10677 Handle<Object> receiver, |
10680 Handle<Name> name, | 10678 Handle<Name> name, |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
10726 // args[1]: name of the property | 10724 // args[1]: name of the property |
10727 // | 10725 // |
10728 // The array returned contains the following information: | 10726 // The array returned contains the following information: |
10729 // 0: Property value | 10727 // 0: Property value |
10730 // 1: Property details | 10728 // 1: Property details |
10731 // 2: Property value is exception | 10729 // 2: Property value is exception |
10732 // 3: Getter function if defined | 10730 // 3: Getter function if defined |
10733 // 4: Setter function if defined | 10731 // 4: Setter function if defined |
10734 // Items 2-4 are only filled if the property has either a getter or a setter | 10732 // Items 2-4 are only filled if the property has either a getter or a setter |
10735 // defined through __defineGetter__ and/or __defineSetter__. | 10733 // defined through __defineGetter__ and/or __defineSetter__. |
10736 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugGetPropertyDetails) { | 10734 RUNTIME_FUNCTION(Object*, Runtime_DebugGetPropertyDetails) { |
10737 HandleScope scope(isolate); | 10735 HandleScope scope(isolate); |
10738 | 10736 |
10739 ASSERT(args.length() == 2); | 10737 ASSERT(args.length() == 2); |
10740 | 10738 |
10741 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); | 10739 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); |
10742 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); | 10740 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); |
10743 | 10741 |
10744 // Make sure to set the current context to the context before the debugger was | 10742 // Make sure to set the current context to the context before the debugger was |
10745 // entered (if the debugger is entered). The reason for switching context here | 10743 // entered (if the debugger is entered). The reason for switching context here |
10746 // is that for some property lookups (accessors and interceptors) callbacks | 10744 // is that for some property lookups (accessors and interceptors) callbacks |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
10816 } | 10814 } |
10817 if (i < length - 1) { | 10815 if (i < length - 1) { |
10818 jsproto = Handle<JSObject>(JSObject::cast(jsproto->GetPrototype())); | 10816 jsproto = Handle<JSObject>(JSObject::cast(jsproto->GetPrototype())); |
10819 } | 10817 } |
10820 } | 10818 } |
10821 | 10819 |
10822 return isolate->heap()->undefined_value(); | 10820 return isolate->heap()->undefined_value(); |
10823 } | 10821 } |
10824 | 10822 |
10825 | 10823 |
10826 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugGetProperty) { | 10824 RUNTIME_FUNCTION(Object*, Runtime_DebugGetProperty) { |
10827 HandleScope scope(isolate); | 10825 HandleScope scope(isolate); |
10828 | 10826 |
10829 ASSERT(args.length() == 2); | 10827 ASSERT(args.length() == 2); |
10830 | 10828 |
10831 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); | 10829 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); |
10832 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); | 10830 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); |
10833 | 10831 |
10834 LookupResult result(isolate); | 10832 LookupResult result(isolate); |
10835 obj->Lookup(*name, &result); | 10833 obj->Lookup(*name, &result); |
10836 return *DebugLookupResultValue(isolate, obj, name, &result); | 10834 return *DebugLookupResultValue(isolate, obj, name, &result); |
10837 } | 10835 } |
10838 | 10836 |
10839 | 10837 |
10840 // Return the property type calculated from the property details. | 10838 // Return the property type calculated from the property details. |
10841 // args[0]: smi with property details. | 10839 // args[0]: smi with property details. |
10842 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugPropertyTypeFromDetails) { | 10840 RUNTIME_FUNCTION(Object*, Runtime_DebugPropertyTypeFromDetails) { |
10843 SealHandleScope shs(isolate); | 10841 SealHandleScope shs(isolate); |
10844 ASSERT(args.length() == 1); | 10842 ASSERT(args.length() == 1); |
10845 CONVERT_PROPERTY_DETAILS_CHECKED(details, 0); | 10843 CONVERT_PROPERTY_DETAILS_CHECKED(details, 0); |
10846 return Smi::FromInt(static_cast<int>(details.type())); | 10844 return Smi::FromInt(static_cast<int>(details.type())); |
10847 } | 10845 } |
10848 | 10846 |
10849 | 10847 |
10850 // Return the property attribute calculated from the property details. | 10848 // Return the property attribute calculated from the property details. |
10851 // args[0]: smi with property details. | 10849 // args[0]: smi with property details. |
10852 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugPropertyAttributesFromDetails) { | 10850 RUNTIME_FUNCTION(Object*, Runtime_DebugPropertyAttributesFromDetails) { |
10853 SealHandleScope shs(isolate); | 10851 SealHandleScope shs(isolate); |
10854 ASSERT(args.length() == 1); | 10852 ASSERT(args.length() == 1); |
10855 CONVERT_PROPERTY_DETAILS_CHECKED(details, 0); | 10853 CONVERT_PROPERTY_DETAILS_CHECKED(details, 0); |
10856 return Smi::FromInt(static_cast<int>(details.attributes())); | 10854 return Smi::FromInt(static_cast<int>(details.attributes())); |
10857 } | 10855 } |
10858 | 10856 |
10859 | 10857 |
10860 // Return the property insertion index calculated from the property details. | 10858 // Return the property insertion index calculated from the property details. |
10861 // args[0]: smi with property details. | 10859 // args[0]: smi with property details. |
10862 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugPropertyIndexFromDetails) { | 10860 RUNTIME_FUNCTION(Object*, Runtime_DebugPropertyIndexFromDetails) { |
10863 SealHandleScope shs(isolate); | 10861 SealHandleScope shs(isolate); |
10864 ASSERT(args.length() == 1); | 10862 ASSERT(args.length() == 1); |
10865 CONVERT_PROPERTY_DETAILS_CHECKED(details, 0); | 10863 CONVERT_PROPERTY_DETAILS_CHECKED(details, 0); |
10866 // TODO(verwaest): Depends on the type of details. | 10864 // TODO(verwaest): Depends on the type of details. |
10867 return Smi::FromInt(details.dictionary_index()); | 10865 return Smi::FromInt(details.dictionary_index()); |
10868 } | 10866 } |
10869 | 10867 |
10870 | 10868 |
10871 // Return property value from named interceptor. | 10869 // Return property value from named interceptor. |
10872 // args[0]: object | 10870 // args[0]: object |
10873 // args[1]: property name | 10871 // args[1]: property name |
10874 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugNamedInterceptorPropertyValue) { | 10872 RUNTIME_FUNCTION(Object*, Runtime_DebugNamedInterceptorPropertyValue) { |
10875 HandleScope scope(isolate); | 10873 HandleScope scope(isolate); |
10876 ASSERT(args.length() == 2); | 10874 ASSERT(args.length() == 2); |
10877 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); | 10875 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); |
10878 RUNTIME_ASSERT(obj->HasNamedInterceptor()); | 10876 RUNTIME_ASSERT(obj->HasNamedInterceptor()); |
10879 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); | 10877 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); |
10880 | 10878 |
10881 PropertyAttributes attributes; | 10879 PropertyAttributes attributes; |
10882 Handle<Object> result; | 10880 Handle<Object> result; |
10883 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 10881 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
10884 isolate, result, | 10882 isolate, result, |
10885 JSObject::GetPropertyWithInterceptor(obj, obj, name, &attributes)); | 10883 JSObject::GetPropertyWithInterceptor(obj, obj, name, &attributes)); |
10886 return *result; | 10884 return *result; |
10887 } | 10885 } |
10888 | 10886 |
10889 | 10887 |
10890 // Return element value from indexed interceptor. | 10888 // Return element value from indexed interceptor. |
10891 // args[0]: object | 10889 // args[0]: object |
10892 // args[1]: index | 10890 // args[1]: index |
10893 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugIndexedInterceptorElementValue) { | 10891 RUNTIME_FUNCTION(Object*, Runtime_DebugIndexedInterceptorElementValue) { |
10894 HandleScope scope(isolate); | 10892 HandleScope scope(isolate); |
10895 ASSERT(args.length() == 2); | 10893 ASSERT(args.length() == 2); |
10896 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); | 10894 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); |
10897 RUNTIME_ASSERT(obj->HasIndexedInterceptor()); | 10895 RUNTIME_ASSERT(obj->HasIndexedInterceptor()); |
10898 CONVERT_NUMBER_CHECKED(uint32_t, index, Uint32, args[1]); | 10896 CONVERT_NUMBER_CHECKED(uint32_t, index, Uint32, args[1]); |
10899 Handle<Object> result; | 10897 Handle<Object> result; |
10900 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 10898 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
10901 isolate, result, JSObject::GetElementWithInterceptor(obj, obj, index)); | 10899 isolate, result, JSObject::GetElementWithInterceptor(obj, obj, index)); |
10902 return *result; | 10900 return *result; |
10903 } | 10901 } |
10904 | 10902 |
10905 | 10903 |
10906 static bool CheckExecutionState(Isolate* isolate, int break_id) { | 10904 static bool CheckExecutionState(Isolate* isolate, int break_id) { |
10907 return (isolate->debug()->break_id() != 0 && | 10905 return (isolate->debug()->break_id() != 0 && |
10908 break_id == isolate->debug()->break_id()); | 10906 break_id == isolate->debug()->break_id()); |
10909 } | 10907 } |
10910 | 10908 |
10911 | 10909 |
10912 RUNTIME_FUNCTION(MaybeObject*, Runtime_CheckExecutionState) { | 10910 RUNTIME_FUNCTION(Object*, Runtime_CheckExecutionState) { |
10913 SealHandleScope shs(isolate); | 10911 SealHandleScope shs(isolate); |
10914 ASSERT(args.length() == 1); | 10912 ASSERT(args.length() == 1); |
10915 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); | 10913 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); |
10916 RUNTIME_ASSERT(CheckExecutionState(isolate, break_id)); | 10914 RUNTIME_ASSERT(CheckExecutionState(isolate, break_id)); |
10917 return isolate->heap()->true_value(); | 10915 return isolate->heap()->true_value(); |
10918 } | 10916 } |
10919 | 10917 |
10920 | 10918 |
10921 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetFrameCount) { | 10919 RUNTIME_FUNCTION(Object*, Runtime_GetFrameCount) { |
10922 HandleScope scope(isolate); | 10920 HandleScope scope(isolate); |
10923 ASSERT(args.length() == 1); | 10921 ASSERT(args.length() == 1); |
10924 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); | 10922 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); |
10925 RUNTIME_ASSERT(CheckExecutionState(isolate, break_id)); | 10923 RUNTIME_ASSERT(CheckExecutionState(isolate, break_id)); |
10926 | 10924 |
10927 // Count all frames which are relevant to debugging stack trace. | 10925 // Count all frames which are relevant to debugging stack trace. |
10928 int n = 0; | 10926 int n = 0; |
10929 StackFrame::Id id = isolate->debug()->break_frame_id(); | 10927 StackFrame::Id id = isolate->debug()->break_frame_id(); |
10930 if (id == StackFrame::NO_ID) { | 10928 if (id == StackFrame::NO_ID) { |
10931 // If there is no JavaScript stack frame count is 0. | 10929 // If there is no JavaScript stack frame count is 0. |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
11049 // 2: Function | 11047 // 2: Function |
11050 // 3: Argument count | 11048 // 3: Argument count |
11051 // 4: Local count | 11049 // 4: Local count |
11052 // 5: Source position | 11050 // 5: Source position |
11053 // 6: Constructor call | 11051 // 6: Constructor call |
11054 // 7: Is at return | 11052 // 7: Is at return |
11055 // 8: Flags | 11053 // 8: Flags |
11056 // Arguments name, value | 11054 // Arguments name, value |
11057 // Locals name, value | 11055 // Locals name, value |
11058 // Return value if any | 11056 // Return value if any |
11059 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetFrameDetails) { | 11057 RUNTIME_FUNCTION(Object*, Runtime_GetFrameDetails) { |
11060 HandleScope scope(isolate); | 11058 HandleScope scope(isolate); |
11061 ASSERT(args.length() == 2); | 11059 ASSERT(args.length() == 2); |
11062 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); | 11060 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); |
11063 RUNTIME_ASSERT(CheckExecutionState(isolate, break_id)); | 11061 RUNTIME_ASSERT(CheckExecutionState(isolate, break_id)); |
11064 | 11062 |
11065 CONVERT_NUMBER_CHECKED(int, index, Int32, args[1]); | 11063 CONVERT_NUMBER_CHECKED(int, index, Int32, args[1]); |
11066 Heap* heap = isolate->heap(); | 11064 Heap* heap = isolate->heap(); |
11067 | 11065 |
11068 // Find the relevant frame with the requested index. | 11066 // Find the relevant frame with the requested index. |
11069 StackFrame::Id id = isolate->debug()->break_frame_id(); | 11067 StackFrame::Id id = isolate->debug()->break_frame_id(); |
(...skipping 1005 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
12075 // Or it could be due to stack overflow. | 12073 // Or it could be due to stack overflow. |
12076 ASSERT(isolate_->has_pending_exception()); | 12074 ASSERT(isolate_->has_pending_exception()); |
12077 failed_ = true; | 12075 failed_ = true; |
12078 } | 12076 } |
12079 } | 12077 } |
12080 | 12078 |
12081 DISALLOW_IMPLICIT_CONSTRUCTORS(ScopeIterator); | 12079 DISALLOW_IMPLICIT_CONSTRUCTORS(ScopeIterator); |
12082 }; | 12080 }; |
12083 | 12081 |
12084 | 12082 |
12085 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetScopeCount) { | 12083 RUNTIME_FUNCTION(Object*, Runtime_GetScopeCount) { |
12086 HandleScope scope(isolate); | 12084 HandleScope scope(isolate); |
12087 ASSERT(args.length() == 2); | 12085 ASSERT(args.length() == 2); |
12088 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); | 12086 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); |
12089 RUNTIME_ASSERT(CheckExecutionState(isolate, break_id)); | 12087 RUNTIME_ASSERT(CheckExecutionState(isolate, break_id)); |
12090 | 12088 |
12091 CONVERT_SMI_ARG_CHECKED(wrapped_id, 1); | 12089 CONVERT_SMI_ARG_CHECKED(wrapped_id, 1); |
12092 | 12090 |
12093 // Get the frame where the debugging is performed. | 12091 // Get the frame where the debugging is performed. |
12094 StackFrame::Id id = UnwrapFrameId(wrapped_id); | 12092 StackFrame::Id id = UnwrapFrameId(wrapped_id); |
12095 JavaScriptFrameIterator it(isolate, id); | 12093 JavaScriptFrameIterator it(isolate, id); |
12096 JavaScriptFrame* frame = it.frame(); | 12094 JavaScriptFrame* frame = it.frame(); |
12097 | 12095 |
12098 // Count the visible scopes. | 12096 // Count the visible scopes. |
12099 int n = 0; | 12097 int n = 0; |
12100 for (ScopeIterator it(isolate, frame, 0); | 12098 for (ScopeIterator it(isolate, frame, 0); |
12101 !it.Done(); | 12099 !it.Done(); |
12102 it.Next()) { | 12100 it.Next()) { |
12103 n++; | 12101 n++; |
12104 } | 12102 } |
12105 | 12103 |
12106 return Smi::FromInt(n); | 12104 return Smi::FromInt(n); |
12107 } | 12105 } |
12108 | 12106 |
12109 | 12107 |
12110 // Returns the list of step-in positions (text offset) in a function of the | 12108 // Returns the list of step-in positions (text offset) in a function of the |
12111 // stack frame in a range from the current debug break position to the end | 12109 // stack frame in a range from the current debug break position to the end |
12112 // of the corresponding statement. | 12110 // of the corresponding statement. |
12113 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetStepInPositions) { | 12111 RUNTIME_FUNCTION(Object*, Runtime_GetStepInPositions) { |
12114 HandleScope scope(isolate); | 12112 HandleScope scope(isolate); |
12115 ASSERT(args.length() == 2); | 12113 ASSERT(args.length() == 2); |
12116 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); | 12114 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); |
12117 RUNTIME_ASSERT(CheckExecutionState(isolate, break_id)); | 12115 RUNTIME_ASSERT(CheckExecutionState(isolate, break_id)); |
12118 | 12116 |
12119 CONVERT_SMI_ARG_CHECKED(wrapped_id, 1); | 12117 CONVERT_SMI_ARG_CHECKED(wrapped_id, 1); |
12120 | 12118 |
12121 // Get the frame where the debugging is performed. | 12119 // Get the frame where the debugging is performed. |
12122 StackFrame::Id id = UnwrapFrameId(wrapped_id); | 12120 StackFrame::Id id = UnwrapFrameId(wrapped_id); |
12123 JavaScriptFrameIterator frame_it(isolate, id); | 12121 JavaScriptFrameIterator frame_it(isolate, id); |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
12210 | 12208 |
12211 // Return an array with scope details | 12209 // Return an array with scope details |
12212 // args[0]: number: break id | 12210 // args[0]: number: break id |
12213 // args[1]: number: frame index | 12211 // args[1]: number: frame index |
12214 // args[2]: number: inlined frame index | 12212 // args[2]: number: inlined frame index |
12215 // args[3]: number: scope index | 12213 // args[3]: number: scope index |
12216 // | 12214 // |
12217 // The array returned contains the following information: | 12215 // The array returned contains the following information: |
12218 // 0: Scope type | 12216 // 0: Scope type |
12219 // 1: Scope object | 12217 // 1: Scope object |
12220 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetScopeDetails) { | 12218 RUNTIME_FUNCTION(Object*, Runtime_GetScopeDetails) { |
12221 HandleScope scope(isolate); | 12219 HandleScope scope(isolate); |
12222 ASSERT(args.length() == 4); | 12220 ASSERT(args.length() == 4); |
12223 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); | 12221 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); |
12224 RUNTIME_ASSERT(CheckExecutionState(isolate, break_id)); | 12222 RUNTIME_ASSERT(CheckExecutionState(isolate, break_id)); |
12225 | 12223 |
12226 CONVERT_SMI_ARG_CHECKED(wrapped_id, 1); | 12224 CONVERT_SMI_ARG_CHECKED(wrapped_id, 1); |
12227 CONVERT_NUMBER_CHECKED(int, inlined_jsframe_index, Int32, args[2]); | 12225 CONVERT_NUMBER_CHECKED(int, inlined_jsframe_index, Int32, args[2]); |
12228 CONVERT_NUMBER_CHECKED(int, index, Int32, args[3]); | 12226 CONVERT_NUMBER_CHECKED(int, index, Int32, args[3]); |
12229 | 12227 |
12230 // Get the frame where the debugging is performed. | 12228 // Get the frame where the debugging is performed. |
(...skipping 19 matching lines...) Expand all Loading... | |
12250 | 12248 |
12251 // Return an array of scope details | 12249 // Return an array of scope details |
12252 // args[0]: number: break id | 12250 // args[0]: number: break id |
12253 // args[1]: number: frame index | 12251 // args[1]: number: frame index |
12254 // args[2]: number: inlined frame index | 12252 // args[2]: number: inlined frame index |
12255 // args[3]: boolean: ignore nested scopes | 12253 // args[3]: boolean: ignore nested scopes |
12256 // | 12254 // |
12257 // The array returned contains arrays with the following information: | 12255 // The array returned contains arrays with the following information: |
12258 // 0: Scope type | 12256 // 0: Scope type |
12259 // 1: Scope object | 12257 // 1: Scope object |
12260 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetAllScopesDetails) { | 12258 RUNTIME_FUNCTION(Object*, Runtime_GetAllScopesDetails) { |
12261 HandleScope scope(isolate); | 12259 HandleScope scope(isolate); |
12262 ASSERT(args.length() == 3 || args.length() == 4); | 12260 ASSERT(args.length() == 3 || args.length() == 4); |
12263 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); | 12261 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); |
12264 RUNTIME_ASSERT(CheckExecutionState(isolate, break_id)); | 12262 RUNTIME_ASSERT(CheckExecutionState(isolate, break_id)); |
12265 | 12263 |
12266 CONVERT_SMI_ARG_CHECKED(wrapped_id, 1); | 12264 CONVERT_SMI_ARG_CHECKED(wrapped_id, 1); |
12267 CONVERT_NUMBER_CHECKED(int, inlined_jsframe_index, Int32, args[2]); | 12265 CONVERT_NUMBER_CHECKED(int, inlined_jsframe_index, Int32, args[2]); |
12268 | 12266 |
12269 bool ignore_nested_scopes = false; | 12267 bool ignore_nested_scopes = false; |
12270 if (args.length() == 4) { | 12268 if (args.length() == 4) { |
(...skipping 16 matching lines...) Expand all Loading... | |
12287 } | 12285 } |
12288 | 12286 |
12289 Handle<FixedArray> array = isolate->factory()->NewFixedArray(result.length()); | 12287 Handle<FixedArray> array = isolate->factory()->NewFixedArray(result.length()); |
12290 for (int i = 0; i < result.length(); ++i) { | 12288 for (int i = 0; i < result.length(); ++i) { |
12291 array->set(i, *result[i]); | 12289 array->set(i, *result[i]); |
12292 } | 12290 } |
12293 return *isolate->factory()->NewJSArrayWithElements(array); | 12291 return *isolate->factory()->NewJSArrayWithElements(array); |
12294 } | 12292 } |
12295 | 12293 |
12296 | 12294 |
12297 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetFunctionScopeCount) { | 12295 RUNTIME_FUNCTION(Object*, Runtime_GetFunctionScopeCount) { |
12298 HandleScope scope(isolate); | 12296 HandleScope scope(isolate); |
12299 ASSERT(args.length() == 1); | 12297 ASSERT(args.length() == 1); |
12300 | 12298 |
12301 // Check arguments. | 12299 // Check arguments. |
12302 CONVERT_ARG_HANDLE_CHECKED(JSFunction, fun, 0); | 12300 CONVERT_ARG_HANDLE_CHECKED(JSFunction, fun, 0); |
12303 | 12301 |
12304 // Count the visible scopes. | 12302 // Count the visible scopes. |
12305 int n = 0; | 12303 int n = 0; |
12306 for (ScopeIterator it(isolate, fun); !it.Done(); it.Next()) { | 12304 for (ScopeIterator it(isolate, fun); !it.Done(); it.Next()) { |
12307 n++; | 12305 n++; |
12308 } | 12306 } |
12309 | 12307 |
12310 return Smi::FromInt(n); | 12308 return Smi::FromInt(n); |
12311 } | 12309 } |
12312 | 12310 |
12313 | 12311 |
12314 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetFunctionScopeDetails) { | 12312 RUNTIME_FUNCTION(Object*, Runtime_GetFunctionScopeDetails) { |
12315 HandleScope scope(isolate); | 12313 HandleScope scope(isolate); |
12316 ASSERT(args.length() == 2); | 12314 ASSERT(args.length() == 2); |
12317 | 12315 |
12318 // Check arguments. | 12316 // Check arguments. |
12319 CONVERT_ARG_HANDLE_CHECKED(JSFunction, fun, 0); | 12317 CONVERT_ARG_HANDLE_CHECKED(JSFunction, fun, 0); |
12320 CONVERT_NUMBER_CHECKED(int, index, Int32, args[1]); | 12318 CONVERT_NUMBER_CHECKED(int, index, Int32, args[1]); |
12321 | 12319 |
12322 // Find the requested scope. | 12320 // Find the requested scope. |
12323 int n = 0; | 12321 int n = 0; |
12324 ScopeIterator it(isolate, fun); | 12322 ScopeIterator it(isolate, fun); |
(...skipping 26 matching lines...) Expand all Loading... | |
12351 | 12349 |
12352 // Change variable value in closure or local scope | 12350 // Change variable value in closure or local scope |
12353 // args[0]: number or JsFunction: break id or function | 12351 // args[0]: number or JsFunction: break id or function |
12354 // args[1]: number: frame index (when arg[0] is break id) | 12352 // args[1]: number: frame index (when arg[0] is break id) |
12355 // args[2]: number: inlined frame index (when arg[0] is break id) | 12353 // args[2]: number: inlined frame index (when arg[0] is break id) |
12356 // args[3]: number: scope index | 12354 // args[3]: number: scope index |
12357 // args[4]: string: variable name | 12355 // args[4]: string: variable name |
12358 // args[5]: object: new value | 12356 // args[5]: object: new value |
12359 // | 12357 // |
12360 // Return true if success and false otherwise | 12358 // Return true if success and false otherwise |
12361 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetScopeVariableValue) { | 12359 RUNTIME_FUNCTION(Object*, Runtime_SetScopeVariableValue) { |
12362 HandleScope scope(isolate); | 12360 HandleScope scope(isolate); |
12363 ASSERT(args.length() == 6); | 12361 ASSERT(args.length() == 6); |
12364 | 12362 |
12365 // Check arguments. | 12363 // Check arguments. |
12366 CONVERT_NUMBER_CHECKED(int, index, Int32, args[3]); | 12364 CONVERT_NUMBER_CHECKED(int, index, Int32, args[3]); |
12367 CONVERT_ARG_HANDLE_CHECKED(String, variable_name, 4); | 12365 CONVERT_ARG_HANDLE_CHECKED(String, variable_name, 4); |
12368 CONVERT_ARG_HANDLE_CHECKED(Object, new_value, 5); | 12366 CONVERT_ARG_HANDLE_CHECKED(Object, new_value, 5); |
12369 | 12367 |
12370 bool res; | 12368 bool res; |
12371 if (args[0]->IsNumber()) { | 12369 if (args[0]->IsNumber()) { |
(...skipping 13 matching lines...) Expand all Loading... | |
12385 } else { | 12383 } else { |
12386 CONVERT_ARG_HANDLE_CHECKED(JSFunction, fun, 0); | 12384 CONVERT_ARG_HANDLE_CHECKED(JSFunction, fun, 0); |
12387 ScopeIterator it(isolate, fun); | 12385 ScopeIterator it(isolate, fun); |
12388 res = SetScopeVariableValue(&it, index, variable_name, new_value); | 12386 res = SetScopeVariableValue(&it, index, variable_name, new_value); |
12389 } | 12387 } |
12390 | 12388 |
12391 return isolate->heap()->ToBoolean(res); | 12389 return isolate->heap()->ToBoolean(res); |
12392 } | 12390 } |
12393 | 12391 |
12394 | 12392 |
12395 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugPrintScopes) { | 12393 RUNTIME_FUNCTION(Object*, Runtime_DebugPrintScopes) { |
12396 HandleScope scope(isolate); | 12394 HandleScope scope(isolate); |
12397 ASSERT(args.length() == 0); | 12395 ASSERT(args.length() == 0); |
12398 | 12396 |
12399 #ifdef DEBUG | 12397 #ifdef DEBUG |
12400 // Print the scopes for the top frame. | 12398 // Print the scopes for the top frame. |
12401 StackFrameLocator locator(isolate); | 12399 StackFrameLocator locator(isolate); |
12402 JavaScriptFrame* frame = locator.FindJavaScriptFrame(0); | 12400 JavaScriptFrame* frame = locator.FindJavaScriptFrame(0); |
12403 for (ScopeIterator it(isolate, frame, 0); | 12401 for (ScopeIterator it(isolate, frame, 0); |
12404 !it.Done(); | 12402 !it.Done(); |
12405 it.Next()) { | 12403 it.Next()) { |
12406 it.DebugPrint(); | 12404 it.DebugPrint(); |
12407 } | 12405 } |
12408 #endif | 12406 #endif |
12409 return isolate->heap()->undefined_value(); | 12407 return isolate->heap()->undefined_value(); |
12410 } | 12408 } |
12411 | 12409 |
12412 | 12410 |
12413 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetThreadCount) { | 12411 RUNTIME_FUNCTION(Object*, Runtime_GetThreadCount) { |
12414 HandleScope scope(isolate); | 12412 HandleScope scope(isolate); |
12415 ASSERT(args.length() == 1); | 12413 ASSERT(args.length() == 1); |
12416 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); | 12414 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); |
12417 RUNTIME_ASSERT(CheckExecutionState(isolate, break_id)); | 12415 RUNTIME_ASSERT(CheckExecutionState(isolate, break_id)); |
12418 | 12416 |
12419 // Count all archived V8 threads. | 12417 // Count all archived V8 threads. |
12420 int n = 0; | 12418 int n = 0; |
12421 for (ThreadState* thread = | 12419 for (ThreadState* thread = |
12422 isolate->thread_manager()->FirstThreadStateInUse(); | 12420 isolate->thread_manager()->FirstThreadStateInUse(); |
12423 thread != NULL; | 12421 thread != NULL; |
(...skipping 10 matching lines...) Expand all Loading... | |
12434 static const int kThreadDetailsThreadIdIndex = 1; | 12432 static const int kThreadDetailsThreadIdIndex = 1; |
12435 static const int kThreadDetailsSize = 2; | 12433 static const int kThreadDetailsSize = 2; |
12436 | 12434 |
12437 // Return an array with thread details | 12435 // Return an array with thread details |
12438 // args[0]: number: break id | 12436 // args[0]: number: break id |
12439 // args[1]: number: thread index | 12437 // args[1]: number: thread index |
12440 // | 12438 // |
12441 // The array returned contains the following information: | 12439 // The array returned contains the following information: |
12442 // 0: Is current thread? | 12440 // 0: Is current thread? |
12443 // 1: Thread id | 12441 // 1: Thread id |
12444 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetThreadDetails) { | 12442 RUNTIME_FUNCTION(Object*, Runtime_GetThreadDetails) { |
12445 HandleScope scope(isolate); | 12443 HandleScope scope(isolate); |
12446 ASSERT(args.length() == 2); | 12444 ASSERT(args.length() == 2); |
12447 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); | 12445 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); |
12448 RUNTIME_ASSERT(CheckExecutionState(isolate, break_id)); | 12446 RUNTIME_ASSERT(CheckExecutionState(isolate, break_id)); |
12449 | 12447 |
12450 CONVERT_NUMBER_CHECKED(int, index, Int32, args[1]); | 12448 CONVERT_NUMBER_CHECKED(int, index, Int32, args[1]); |
12451 | 12449 |
12452 // Allocate array for result. | 12450 // Allocate array for result. |
12453 Handle<FixedArray> details = | 12451 Handle<FixedArray> details = |
12454 isolate->factory()->NewFixedArray(kThreadDetailsSize); | 12452 isolate->factory()->NewFixedArray(kThreadDetailsSize); |
(...skipping 25 matching lines...) Expand all Loading... | |
12480 Smi::FromInt(thread->id().ToInteger())); | 12478 Smi::FromInt(thread->id().ToInteger())); |
12481 } | 12479 } |
12482 | 12480 |
12483 // Convert to JS array and return. | 12481 // Convert to JS array and return. |
12484 return *isolate->factory()->NewJSArrayWithElements(details); | 12482 return *isolate->factory()->NewJSArrayWithElements(details); |
12485 } | 12483 } |
12486 | 12484 |
12487 | 12485 |
12488 // Sets the disable break state | 12486 // Sets the disable break state |
12489 // args[0]: disable break state | 12487 // args[0]: disable break state |
12490 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetDisableBreak) { | 12488 RUNTIME_FUNCTION(Object*, Runtime_SetDisableBreak) { |
12491 HandleScope scope(isolate); | 12489 HandleScope scope(isolate); |
12492 ASSERT(args.length() == 1); | 12490 ASSERT(args.length() == 1); |
12493 CONVERT_BOOLEAN_ARG_CHECKED(disable_break, 0); | 12491 CONVERT_BOOLEAN_ARG_CHECKED(disable_break, 0); |
12494 isolate->debug()->set_disable_break(disable_break); | 12492 isolate->debug()->set_disable_break(disable_break); |
12495 return isolate->heap()->undefined_value(); | 12493 return isolate->heap()->undefined_value(); |
12496 } | 12494 } |
12497 | 12495 |
12498 | 12496 |
12499 static bool IsPositionAlignmentCodeCorrect(int alignment) { | 12497 static bool IsPositionAlignmentCodeCorrect(int alignment) { |
12500 return alignment == STATEMENT_ALIGNED || alignment == BREAK_POSITION_ALIGNED; | 12498 return alignment == STATEMENT_ALIGNED || alignment == BREAK_POSITION_ALIGNED; |
12501 } | 12499 } |
12502 | 12500 |
12503 | 12501 |
12504 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetBreakLocations) { | 12502 RUNTIME_FUNCTION(Object*, Runtime_GetBreakLocations) { |
12505 HandleScope scope(isolate); | 12503 HandleScope scope(isolate); |
12506 ASSERT(args.length() == 2); | 12504 ASSERT(args.length() == 2); |
12507 | 12505 |
12508 CONVERT_ARG_HANDLE_CHECKED(JSFunction, fun, 0); | 12506 CONVERT_ARG_HANDLE_CHECKED(JSFunction, fun, 0); |
12509 CONVERT_NUMBER_CHECKED(int32_t, statement_aligned_code, Int32, args[1]); | 12507 CONVERT_NUMBER_CHECKED(int32_t, statement_aligned_code, Int32, args[1]); |
12510 | 12508 |
12511 if (!IsPositionAlignmentCodeCorrect(statement_aligned_code)) { | 12509 if (!IsPositionAlignmentCodeCorrect(statement_aligned_code)) { |
12512 return isolate->ThrowIllegalOperation(); | 12510 return isolate->ThrowIllegalOperation(); |
12513 } | 12511 } |
12514 BreakPositionAlignment alignment = | 12512 BreakPositionAlignment alignment = |
12515 static_cast<BreakPositionAlignment>(statement_aligned_code); | 12513 static_cast<BreakPositionAlignment>(statement_aligned_code); |
12516 | 12514 |
12517 Handle<SharedFunctionInfo> shared(fun->shared()); | 12515 Handle<SharedFunctionInfo> shared(fun->shared()); |
12518 // Find the number of break points | 12516 // Find the number of break points |
12519 Handle<Object> break_locations = | 12517 Handle<Object> break_locations = |
12520 Debug::GetSourceBreakLocations(shared, alignment); | 12518 Debug::GetSourceBreakLocations(shared, alignment); |
12521 if (break_locations->IsUndefined()) return isolate->heap()->undefined_value(); | 12519 if (break_locations->IsUndefined()) return isolate->heap()->undefined_value(); |
12522 // Return array as JS array | 12520 // Return array as JS array |
12523 return *isolate->factory()->NewJSArrayWithElements( | 12521 return *isolate->factory()->NewJSArrayWithElements( |
12524 Handle<FixedArray>::cast(break_locations)); | 12522 Handle<FixedArray>::cast(break_locations)); |
12525 } | 12523 } |
12526 | 12524 |
12527 | 12525 |
12528 // Set a break point in a function. | 12526 // Set a break point in a function. |
12529 // args[0]: function | 12527 // args[0]: function |
12530 // args[1]: number: break source position (within the function source) | 12528 // args[1]: number: break source position (within the function source) |
12531 // args[2]: number: break point object | 12529 // args[2]: number: break point object |
12532 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetFunctionBreakPoint) { | 12530 RUNTIME_FUNCTION(Object*, Runtime_SetFunctionBreakPoint) { |
12533 HandleScope scope(isolate); | 12531 HandleScope scope(isolate); |
12534 ASSERT(args.length() == 3); | 12532 ASSERT(args.length() == 3); |
12535 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 12533 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
12536 CONVERT_NUMBER_CHECKED(int32_t, source_position, Int32, args[1]); | 12534 CONVERT_NUMBER_CHECKED(int32_t, source_position, Int32, args[1]); |
12537 RUNTIME_ASSERT(source_position >= 0); | 12535 RUNTIME_ASSERT(source_position >= 0); |
12538 CONVERT_ARG_HANDLE_CHECKED(Object, break_point_object_arg, 2); | 12536 CONVERT_ARG_HANDLE_CHECKED(Object, break_point_object_arg, 2); |
12539 | 12537 |
12540 // Set break point. | 12538 // Set break point. |
12541 isolate->debug()->SetBreakPoint(function, break_point_object_arg, | 12539 isolate->debug()->SetBreakPoint(function, break_point_object_arg, |
12542 &source_position); | 12540 &source_position); |
12543 | 12541 |
12544 return Smi::FromInt(source_position); | 12542 return Smi::FromInt(source_position); |
12545 } | 12543 } |
12546 | 12544 |
12547 | 12545 |
12548 // Changes the state of a break point in a script and returns source position | 12546 // Changes the state of a break point in a script and returns source position |
12549 // where break point was set. NOTE: Regarding performance see the NOTE for | 12547 // where break point was set. NOTE: Regarding performance see the NOTE for |
12550 // GetScriptFromScriptData. | 12548 // GetScriptFromScriptData. |
12551 // args[0]: script to set break point in | 12549 // args[0]: script to set break point in |
12552 // args[1]: number: break source position (within the script source) | 12550 // args[1]: number: break source position (within the script source) |
12553 // args[2]: number, breakpoint position alignment | 12551 // args[2]: number, breakpoint position alignment |
12554 // args[3]: number: break point object | 12552 // args[3]: number: break point object |
12555 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetScriptBreakPoint) { | 12553 RUNTIME_FUNCTION(Object*, Runtime_SetScriptBreakPoint) { |
12556 HandleScope scope(isolate); | 12554 HandleScope scope(isolate); |
12557 ASSERT(args.length() == 4); | 12555 ASSERT(args.length() == 4); |
12558 CONVERT_ARG_HANDLE_CHECKED(JSValue, wrapper, 0); | 12556 CONVERT_ARG_HANDLE_CHECKED(JSValue, wrapper, 0); |
12559 CONVERT_NUMBER_CHECKED(int32_t, source_position, Int32, args[1]); | 12557 CONVERT_NUMBER_CHECKED(int32_t, source_position, Int32, args[1]); |
12560 RUNTIME_ASSERT(source_position >= 0); | 12558 RUNTIME_ASSERT(source_position >= 0); |
12561 CONVERT_NUMBER_CHECKED(int32_t, statement_aligned_code, Int32, args[2]); | 12559 CONVERT_NUMBER_CHECKED(int32_t, statement_aligned_code, Int32, args[2]); |
12562 CONVERT_ARG_HANDLE_CHECKED(Object, break_point_object_arg, 3); | 12560 CONVERT_ARG_HANDLE_CHECKED(Object, break_point_object_arg, 3); |
12563 | 12561 |
12564 if (!IsPositionAlignmentCodeCorrect(statement_aligned_code)) { | 12562 if (!IsPositionAlignmentCodeCorrect(statement_aligned_code)) { |
12565 return isolate->ThrowIllegalOperation(); | 12563 return isolate->ThrowIllegalOperation(); |
(...skipping 11 matching lines...) Expand all Loading... | |
12577 alignment)) { | 12575 alignment)) { |
12578 return isolate->heap()->undefined_value(); | 12576 return isolate->heap()->undefined_value(); |
12579 } | 12577 } |
12580 | 12578 |
12581 return Smi::FromInt(source_position); | 12579 return Smi::FromInt(source_position); |
12582 } | 12580 } |
12583 | 12581 |
12584 | 12582 |
12585 // Clear a break point | 12583 // Clear a break point |
12586 // args[0]: number: break point object | 12584 // args[0]: number: break point object |
12587 RUNTIME_FUNCTION(MaybeObject*, Runtime_ClearBreakPoint) { | 12585 RUNTIME_FUNCTION(Object*, Runtime_ClearBreakPoint) { |
12588 HandleScope scope(isolate); | 12586 HandleScope scope(isolate); |
12589 ASSERT(args.length() == 1); | 12587 ASSERT(args.length() == 1); |
12590 CONVERT_ARG_HANDLE_CHECKED(Object, break_point_object_arg, 0); | 12588 CONVERT_ARG_HANDLE_CHECKED(Object, break_point_object_arg, 0); |
12591 | 12589 |
12592 // Clear break point. | 12590 // Clear break point. |
12593 isolate->debug()->ClearBreakPoint(break_point_object_arg); | 12591 isolate->debug()->ClearBreakPoint(break_point_object_arg); |
12594 | 12592 |
12595 return isolate->heap()->undefined_value(); | 12593 return isolate->heap()->undefined_value(); |
12596 } | 12594 } |
12597 | 12595 |
12598 | 12596 |
12599 // Change the state of break on exceptions. | 12597 // Change the state of break on exceptions. |
12600 // args[0]: Enum value indicating whether to affect caught/uncaught exceptions. | 12598 // args[0]: Enum value indicating whether to affect caught/uncaught exceptions. |
12601 // args[1]: Boolean indicating on/off. | 12599 // args[1]: Boolean indicating on/off. |
12602 RUNTIME_FUNCTION(MaybeObject*, Runtime_ChangeBreakOnException) { | 12600 RUNTIME_FUNCTION(Object*, Runtime_ChangeBreakOnException) { |
12603 HandleScope scope(isolate); | 12601 HandleScope scope(isolate); |
12604 ASSERT(args.length() == 2); | 12602 ASSERT(args.length() == 2); |
12605 CONVERT_NUMBER_CHECKED(uint32_t, type_arg, Uint32, args[0]); | 12603 CONVERT_NUMBER_CHECKED(uint32_t, type_arg, Uint32, args[0]); |
12606 CONVERT_BOOLEAN_ARG_CHECKED(enable, 1); | 12604 CONVERT_BOOLEAN_ARG_CHECKED(enable, 1); |
12607 | 12605 |
12608 // If the number doesn't match an enum value, the ChangeBreakOnException | 12606 // If the number doesn't match an enum value, the ChangeBreakOnException |
12609 // function will default to affecting caught exceptions. | 12607 // function will default to affecting caught exceptions. |
12610 ExceptionBreakType type = static_cast<ExceptionBreakType>(type_arg); | 12608 ExceptionBreakType type = static_cast<ExceptionBreakType>(type_arg); |
12611 // Update break point state. | 12609 // Update break point state. |
12612 isolate->debug()->ChangeBreakOnException(type, enable); | 12610 isolate->debug()->ChangeBreakOnException(type, enable); |
12613 return isolate->heap()->undefined_value(); | 12611 return isolate->heap()->undefined_value(); |
12614 } | 12612 } |
12615 | 12613 |
12616 | 12614 |
12617 // Returns the state of break on exceptions | 12615 // Returns the state of break on exceptions |
12618 // args[0]: boolean indicating uncaught exceptions | 12616 // args[0]: boolean indicating uncaught exceptions |
12619 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsBreakOnException) { | 12617 RUNTIME_FUNCTION(Object*, Runtime_IsBreakOnException) { |
12620 HandleScope scope(isolate); | 12618 HandleScope scope(isolate); |
12621 ASSERT(args.length() == 1); | 12619 ASSERT(args.length() == 1); |
12622 CONVERT_NUMBER_CHECKED(uint32_t, type_arg, Uint32, args[0]); | 12620 CONVERT_NUMBER_CHECKED(uint32_t, type_arg, Uint32, args[0]); |
12623 | 12621 |
12624 ExceptionBreakType type = static_cast<ExceptionBreakType>(type_arg); | 12622 ExceptionBreakType type = static_cast<ExceptionBreakType>(type_arg); |
12625 bool result = isolate->debug()->IsBreakOnException(type); | 12623 bool result = isolate->debug()->IsBreakOnException(type); |
12626 return Smi::FromInt(result); | 12624 return Smi::FromInt(result); |
12627 } | 12625 } |
12628 | 12626 |
12629 | 12627 |
12630 // Prepare for stepping | 12628 // Prepare for stepping |
12631 // args[0]: break id for checking execution state | 12629 // args[0]: break id for checking execution state |
12632 // args[1]: step action from the enumeration StepAction | 12630 // args[1]: step action from the enumeration StepAction |
12633 // args[2]: number of times to perform the step, for step out it is the number | 12631 // args[2]: number of times to perform the step, for step out it is the number |
12634 // of frames to step down. | 12632 // of frames to step down. |
12635 RUNTIME_FUNCTION(MaybeObject*, Runtime_PrepareStep) { | 12633 RUNTIME_FUNCTION(Object*, Runtime_PrepareStep) { |
12636 HandleScope scope(isolate); | 12634 HandleScope scope(isolate); |
12637 ASSERT(args.length() == 4); | 12635 ASSERT(args.length() == 4); |
12638 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); | 12636 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); |
12639 RUNTIME_ASSERT(CheckExecutionState(isolate, break_id)); | 12637 RUNTIME_ASSERT(CheckExecutionState(isolate, break_id)); |
12640 | 12638 |
12641 if (!args[1]->IsNumber() || !args[2]->IsNumber()) { | 12639 if (!args[1]->IsNumber() || !args[2]->IsNumber()) { |
12642 return isolate->Throw(isolate->heap()->illegal_argument_string()); | 12640 return isolate->Throw(isolate->heap()->illegal_argument_string()); |
12643 } | 12641 } |
12644 | 12642 |
12645 CONVERT_NUMBER_CHECKED(int, wrapped_frame_id, Int32, args[3]); | 12643 CONVERT_NUMBER_CHECKED(int, wrapped_frame_id, Int32, args[3]); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
12677 | 12675 |
12678 // Prepare step. | 12676 // Prepare step. |
12679 isolate->debug()->PrepareStep(static_cast<StepAction>(step_action), | 12677 isolate->debug()->PrepareStep(static_cast<StepAction>(step_action), |
12680 step_count, | 12678 step_count, |
12681 frame_id); | 12679 frame_id); |
12682 return isolate->heap()->undefined_value(); | 12680 return isolate->heap()->undefined_value(); |
12683 } | 12681 } |
12684 | 12682 |
12685 | 12683 |
12686 // Clear all stepping set by PrepareStep. | 12684 // Clear all stepping set by PrepareStep. |
12687 RUNTIME_FUNCTION(MaybeObject*, Runtime_ClearStepping) { | 12685 RUNTIME_FUNCTION(Object*, Runtime_ClearStepping) { |
12688 HandleScope scope(isolate); | 12686 HandleScope scope(isolate); |
12689 ASSERT(args.length() == 0); | 12687 ASSERT(args.length() == 0); |
12690 isolate->debug()->ClearStepping(); | 12688 isolate->debug()->ClearStepping(); |
12691 return isolate->heap()->undefined_value(); | 12689 return isolate->heap()->undefined_value(); |
12692 } | 12690 } |
12693 | 12691 |
12694 | 12692 |
12695 // Helper function to find or create the arguments object for | 12693 // Helper function to find or create the arguments object for |
12696 // Runtime_DebugEvaluate. | 12694 // Runtime_DebugEvaluate. |
12697 MUST_USE_RESULT static MaybeHandle<JSObject> MaterializeArgumentsObject( | 12695 MUST_USE_RESULT static MaybeHandle<JSObject> MaterializeArgumentsObject( |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
12757 isolate->debug()->ClearStepping(); | 12755 isolate->debug()->ClearStepping(); |
12758 return result; | 12756 return result; |
12759 } | 12757 } |
12760 | 12758 |
12761 | 12759 |
12762 // Evaluate a piece of JavaScript in the context of a stack frame for | 12760 // Evaluate a piece of JavaScript in the context of a stack frame for |
12763 // debugging. Things that need special attention are: | 12761 // debugging. Things that need special attention are: |
12764 // - Parameters and stack-allocated locals need to be materialized. Altered | 12762 // - Parameters and stack-allocated locals need to be materialized. Altered |
12765 // values need to be written back to the stack afterwards. | 12763 // values need to be written back to the stack afterwards. |
12766 // - The arguments object needs to materialized. | 12764 // - The arguments object needs to materialized. |
12767 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugEvaluate) { | 12765 RUNTIME_FUNCTION(Object*, Runtime_DebugEvaluate) { |
12768 HandleScope scope(isolate); | 12766 HandleScope scope(isolate); |
12769 | 12767 |
12770 // Check the execution state and decode arguments frame and source to be | 12768 // Check the execution state and decode arguments frame and source to be |
12771 // evaluated. | 12769 // evaluated. |
12772 ASSERT(args.length() == 6); | 12770 ASSERT(args.length() == 6); |
12773 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); | 12771 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); |
12774 RUNTIME_ASSERT(CheckExecutionState(isolate, break_id)); | 12772 RUNTIME_ASSERT(CheckExecutionState(isolate, break_id)); |
12775 | 12773 |
12776 CONVERT_SMI_ARG_CHECKED(wrapped_id, 1); | 12774 CONVERT_SMI_ARG_CHECKED(wrapped_id, 1); |
12777 CONVERT_NUMBER_CHECKED(int, inlined_jsframe_index, Int32, args[2]); | 12775 CONVERT_NUMBER_CHECKED(int, inlined_jsframe_index, Int32, args[2]); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
12823 DebugEvaluate(isolate, context, context_extension, receiver, source)); | 12821 DebugEvaluate(isolate, context, context_extension, receiver, source)); |
12824 | 12822 |
12825 // Write back potential changes to materialized stack locals to the stack. | 12823 // Write back potential changes to materialized stack locals to the stack. |
12826 UpdateStackLocalsFromMaterializedObject( | 12824 UpdateStackLocalsFromMaterializedObject( |
12827 isolate, materialized, function, frame, inlined_jsframe_index); | 12825 isolate, materialized, function, frame, inlined_jsframe_index); |
12828 | 12826 |
12829 return *result; | 12827 return *result; |
12830 } | 12828 } |
12831 | 12829 |
12832 | 12830 |
12833 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugEvaluateGlobal) { | 12831 RUNTIME_FUNCTION(Object*, Runtime_DebugEvaluateGlobal) { |
12834 HandleScope scope(isolate); | 12832 HandleScope scope(isolate); |
12835 | 12833 |
12836 // Check the execution state and decode arguments frame and source to be | 12834 // Check the execution state and decode arguments frame and source to be |
12837 // evaluated. | 12835 // evaluated. |
12838 ASSERT(args.length() == 4); | 12836 ASSERT(args.length() == 4); |
12839 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); | 12837 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); |
12840 RUNTIME_ASSERT(CheckExecutionState(isolate, break_id)); | 12838 RUNTIME_ASSERT(CheckExecutionState(isolate, break_id)); |
12841 | 12839 |
12842 CONVERT_ARG_HANDLE_CHECKED(String, source, 1); | 12840 CONVERT_ARG_HANDLE_CHECKED(String, source, 1); |
12843 CONVERT_BOOLEAN_ARG_CHECKED(disable_break, 2); | 12841 CONVERT_BOOLEAN_ARG_CHECKED(disable_break, 2); |
(...skipping 17 matching lines...) Expand all Loading... | |
12861 Handle<Context> context = isolate->native_context(); | 12859 Handle<Context> context = isolate->native_context(); |
12862 Handle<Object> receiver = isolate->global_object(); | 12860 Handle<Object> receiver = isolate->global_object(); |
12863 Handle<Object> result; | 12861 Handle<Object> result; |
12864 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 12862 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
12865 isolate, result, | 12863 isolate, result, |
12866 DebugEvaluate(isolate, context, context_extension, receiver, source)); | 12864 DebugEvaluate(isolate, context, context_extension, receiver, source)); |
12867 return *result; | 12865 return *result; |
12868 } | 12866 } |
12869 | 12867 |
12870 | 12868 |
12871 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugGetLoadedScripts) { | 12869 RUNTIME_FUNCTION(Object*, Runtime_DebugGetLoadedScripts) { |
12872 HandleScope scope(isolate); | 12870 HandleScope scope(isolate); |
12873 ASSERT(args.length() == 0); | 12871 ASSERT(args.length() == 0); |
12874 | 12872 |
12875 // Fill the script objects. | 12873 // Fill the script objects. |
12876 Handle<FixedArray> instances = isolate->debug()->GetLoadedScripts(); | 12874 Handle<FixedArray> instances = isolate->debug()->GetLoadedScripts(); |
12877 | 12875 |
12878 // Convert the script objects to proper JS objects. | 12876 // Convert the script objects to proper JS objects. |
12879 for (int i = 0; i < instances->length(); i++) { | 12877 for (int i = 0; i < instances->length(); i++) { |
12880 Handle<Script> script = Handle<Script>(Script::cast(instances->get(i))); | 12878 Handle<Script> script = Handle<Script>(Script::cast(instances->get(i))); |
12881 // Get the script wrapper in a local handle before calling GetScriptWrapper, | 12879 // Get the script wrapper in a local handle before calling GetScriptWrapper, |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
12963 | 12961 |
12964 // Return the number of referencing objects found. | 12962 // Return the number of referencing objects found. |
12965 return count; | 12963 return count; |
12966 } | 12964 } |
12967 | 12965 |
12968 | 12966 |
12969 // Scan the heap for objects with direct references to an object | 12967 // Scan the heap for objects with direct references to an object |
12970 // args[0]: the object to find references to | 12968 // args[0]: the object to find references to |
12971 // args[1]: constructor function for instances to exclude (Mirror) | 12969 // args[1]: constructor function for instances to exclude (Mirror) |
12972 // args[2]: the the maximum number of objects to return | 12970 // args[2]: the the maximum number of objects to return |
12973 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugReferencedBy) { | 12971 RUNTIME_FUNCTION(Object*, Runtime_DebugReferencedBy) { |
12974 HandleScope scope(isolate); | 12972 HandleScope scope(isolate); |
12975 ASSERT(args.length() == 3); | 12973 ASSERT(args.length() == 3); |
12976 | 12974 |
12977 // First perform a full GC in order to avoid references from dead objects. | 12975 // First perform a full GC in order to avoid references from dead objects. |
12978 Heap* heap = isolate->heap(); | 12976 Heap* heap = isolate->heap(); |
12979 heap->CollectAllGarbage(Heap::kMakeHeapIterableMask, "%DebugReferencedBy"); | 12977 heap->CollectAllGarbage(Heap::kMakeHeapIterableMask, "%DebugReferencedBy"); |
12980 // The heap iterator reserves the right to do a GC to make the heap iterable. | 12978 // The heap iterator reserves the right to do a GC to make the heap iterable. |
12981 // Due to the GC above we know it won't need to do that, but it seems cleaner | 12979 // Due to the GC above we know it won't need to do that, but it seems cleaner |
12982 // to get the heap iterator constructed before we start having unprotected | 12980 // to get the heap iterator constructed before we start having unprotected |
12983 // Object* locals that are not protected by handles. | 12981 // Object* locals that are not protected by handles. |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
13053 } | 13051 } |
13054 | 13052 |
13055 // Return the number of referencing objects found. | 13053 // Return the number of referencing objects found. |
13056 return count; | 13054 return count; |
13057 } | 13055 } |
13058 | 13056 |
13059 | 13057 |
13060 // Scan the heap for objects constructed by a specific function. | 13058 // Scan the heap for objects constructed by a specific function. |
13061 // args[0]: the constructor to find instances of | 13059 // args[0]: the constructor to find instances of |
13062 // args[1]: the the maximum number of objects to return | 13060 // args[1]: the the maximum number of objects to return |
13063 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugConstructedBy) { | 13061 RUNTIME_FUNCTION(Object*, Runtime_DebugConstructedBy) { |
13064 HandleScope scope(isolate); | 13062 HandleScope scope(isolate); |
13065 ASSERT(args.length() == 2); | 13063 ASSERT(args.length() == 2); |
13066 | 13064 |
13067 // First perform a full GC in order to avoid dead objects. | 13065 // First perform a full GC in order to avoid dead objects. |
13068 Heap* heap = isolate->heap(); | 13066 Heap* heap = isolate->heap(); |
13069 heap->CollectAllGarbage(Heap::kMakeHeapIterableMask, "%DebugConstructedBy"); | 13067 heap->CollectAllGarbage(Heap::kMakeHeapIterableMask, "%DebugConstructedBy"); |
13070 | 13068 |
13071 // Check parameters. | 13069 // Check parameters. |
13072 CONVERT_ARG_HANDLE_CHECKED(JSFunction, constructor, 0); | 13070 CONVERT_ARG_HANDLE_CHECKED(JSFunction, constructor, 0); |
13073 CONVERT_NUMBER_CHECKED(int32_t, max_references, Int32, args[1]); | 13071 CONVERT_NUMBER_CHECKED(int32_t, max_references, Int32, args[1]); |
(...skipping 24 matching lines...) Expand all Loading... | |
13098 Handle<JSFunction> array_function( | 13096 Handle<JSFunction> array_function( |
13099 isolate->context()->native_context()->array_function()); | 13097 isolate->context()->native_context()->array_function()); |
13100 Handle<JSObject> result = isolate->factory()->NewJSObject(array_function); | 13098 Handle<JSObject> result = isolate->factory()->NewJSObject(array_function); |
13101 JSArray::SetContent(Handle<JSArray>::cast(result), instances); | 13099 JSArray::SetContent(Handle<JSArray>::cast(result), instances); |
13102 return *result; | 13100 return *result; |
13103 } | 13101 } |
13104 | 13102 |
13105 | 13103 |
13106 // Find the effective prototype object as returned by __proto__. | 13104 // Find the effective prototype object as returned by __proto__. |
13107 // args[0]: the object to find the prototype for. | 13105 // args[0]: the object to find the prototype for. |
13108 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugGetPrototype) { | 13106 RUNTIME_FUNCTION(Object*, Runtime_DebugGetPrototype) { |
13109 HandleScope shs(isolate); | 13107 HandleScope shs(isolate); |
13110 ASSERT(args.length() == 1); | 13108 ASSERT(args.length() == 1); |
13111 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); | 13109 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); |
13112 return *GetPrototypeSkipHiddenPrototypes(isolate, obj); | 13110 return *GetPrototypeSkipHiddenPrototypes(isolate, obj); |
13113 } | 13111 } |
13114 | 13112 |
13115 | 13113 |
13116 // Patches script source (should be called upon BeforeCompile event). | 13114 // Patches script source (should be called upon BeforeCompile event). |
13117 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugSetScriptSource) { | 13115 RUNTIME_FUNCTION(Object*, Runtime_DebugSetScriptSource) { |
13118 HandleScope scope(isolate); | 13116 HandleScope scope(isolate); |
13119 ASSERT(args.length() == 2); | 13117 ASSERT(args.length() == 2); |
13120 | 13118 |
13121 CONVERT_ARG_HANDLE_CHECKED(JSValue, script_wrapper, 0); | 13119 CONVERT_ARG_HANDLE_CHECKED(JSValue, script_wrapper, 0); |
13122 CONVERT_ARG_HANDLE_CHECKED(String, source, 1); | 13120 CONVERT_ARG_HANDLE_CHECKED(String, source, 1); |
13123 | 13121 |
13124 RUNTIME_ASSERT(script_wrapper->value()->IsScript()); | 13122 RUNTIME_ASSERT(script_wrapper->value()->IsScript()); |
13125 Handle<Script> script(Script::cast(script_wrapper->value())); | 13123 Handle<Script> script(Script::cast(script_wrapper->value())); |
13126 | 13124 |
13127 int compilation_state = script->compilation_state(); | 13125 int compilation_state = script->compilation_state(); |
13128 RUNTIME_ASSERT(compilation_state == Script::COMPILATION_STATE_INITIAL); | 13126 RUNTIME_ASSERT(compilation_state == Script::COMPILATION_STATE_INITIAL); |
13129 script->set_source(*source); | 13127 script->set_source(*source); |
13130 | 13128 |
13131 return isolate->heap()->undefined_value(); | 13129 return isolate->heap()->undefined_value(); |
13132 } | 13130 } |
13133 | 13131 |
13134 | 13132 |
13135 RUNTIME_FUNCTION(MaybeObject*, Runtime_SystemBreak) { | 13133 RUNTIME_FUNCTION(Object*, Runtime_SystemBreak) { |
13136 SealHandleScope shs(isolate); | 13134 SealHandleScope shs(isolate); |
13137 ASSERT(args.length() == 0); | 13135 ASSERT(args.length() == 0); |
13138 OS::DebugBreak(); | 13136 OS::DebugBreak(); |
13139 return isolate->heap()->undefined_value(); | 13137 return isolate->heap()->undefined_value(); |
13140 } | 13138 } |
13141 | 13139 |
13142 | 13140 |
13143 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugDisassembleFunction) { | 13141 RUNTIME_FUNCTION(Object*, Runtime_DebugDisassembleFunction) { |
13144 HandleScope scope(isolate); | 13142 HandleScope scope(isolate); |
13145 #ifdef DEBUG | 13143 #ifdef DEBUG |
13146 ASSERT(args.length() == 1); | 13144 ASSERT(args.length() == 1); |
13147 // Get the function and make sure it is compiled. | 13145 // Get the function and make sure it is compiled. |
13148 CONVERT_ARG_HANDLE_CHECKED(JSFunction, func, 0); | 13146 CONVERT_ARG_HANDLE_CHECKED(JSFunction, func, 0); |
13149 if (!Compiler::EnsureCompiled(func, KEEP_EXCEPTION)) { | 13147 if (!Compiler::EnsureCompiled(func, KEEP_EXCEPTION)) { |
13150 return Failure::Exception(); | 13148 return isolate->heap()->exception(); |
13151 } | 13149 } |
13152 func->code()->PrintLn(); | 13150 func->code()->PrintLn(); |
13153 #endif // DEBUG | 13151 #endif // DEBUG |
13154 return isolate->heap()->undefined_value(); | 13152 return isolate->heap()->undefined_value(); |
13155 } | 13153 } |
13156 | 13154 |
13157 | 13155 |
13158 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugDisassembleConstructor) { | 13156 RUNTIME_FUNCTION(Object*, Runtime_DebugDisassembleConstructor) { |
13159 HandleScope scope(isolate); | 13157 HandleScope scope(isolate); |
13160 #ifdef DEBUG | 13158 #ifdef DEBUG |
13161 ASSERT(args.length() == 1); | 13159 ASSERT(args.length() == 1); |
13162 // Get the function and make sure it is compiled. | 13160 // Get the function and make sure it is compiled. |
13163 CONVERT_ARG_HANDLE_CHECKED(JSFunction, func, 0); | 13161 CONVERT_ARG_HANDLE_CHECKED(JSFunction, func, 0); |
13164 if (!Compiler::EnsureCompiled(func, KEEP_EXCEPTION)) { | 13162 if (!Compiler::EnsureCompiled(func, KEEP_EXCEPTION)) { |
13165 return Failure::Exception(); | 13163 return isolate->heap()->exception(); |
13166 } | 13164 } |
13167 func->shared()->construct_stub()->PrintLn(); | 13165 func->shared()->construct_stub()->PrintLn(); |
13168 #endif // DEBUG | 13166 #endif // DEBUG |
13169 return isolate->heap()->undefined_value(); | 13167 return isolate->heap()->undefined_value(); |
13170 } | 13168 } |
13171 | 13169 |
13172 | 13170 |
13173 RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionGetInferredName) { | 13171 RUNTIME_FUNCTION(Object*, Runtime_FunctionGetInferredName) { |
13174 SealHandleScope shs(isolate); | 13172 SealHandleScope shs(isolate); |
13175 ASSERT(args.length() == 1); | 13173 ASSERT(args.length() == 1); |
13176 | 13174 |
13177 CONVERT_ARG_CHECKED(JSFunction, f, 0); | 13175 CONVERT_ARG_CHECKED(JSFunction, f, 0); |
13178 return f->shared()->inferred_name(); | 13176 return f->shared()->inferred_name(); |
13179 } | 13177 } |
13180 | 13178 |
13181 | 13179 |
13182 static int FindSharedFunctionInfosForScript(HeapIterator* iterator, | 13180 static int FindSharedFunctionInfosForScript(HeapIterator* iterator, |
13183 Script* script, | 13181 Script* script, |
(...skipping 17 matching lines...) Expand all Loading... | |
13201 } | 13199 } |
13202 counter++; | 13200 counter++; |
13203 } | 13201 } |
13204 return counter; | 13202 return counter; |
13205 } | 13203 } |
13206 | 13204 |
13207 | 13205 |
13208 // For a script finds all SharedFunctionInfo's in the heap that points | 13206 // For a script finds all SharedFunctionInfo's in the heap that points |
13209 // to this script. Returns JSArray of SharedFunctionInfo wrapped | 13207 // to this script. Returns JSArray of SharedFunctionInfo wrapped |
13210 // in OpaqueReferences. | 13208 // in OpaqueReferences. |
13211 RUNTIME_FUNCTION(MaybeObject*, | 13209 RUNTIME_FUNCTION(Object*, Runtime_LiveEditFindSharedFunctionInfosForScript) { |
13212 Runtime_LiveEditFindSharedFunctionInfosForScript) { | |
13213 HandleScope scope(isolate); | 13210 HandleScope scope(isolate); |
13214 CHECK(isolate->debugger()->live_edit_enabled()); | 13211 CHECK(isolate->debugger()->live_edit_enabled()); |
13215 ASSERT(args.length() == 1); | 13212 ASSERT(args.length() == 1); |
13216 CONVERT_ARG_CHECKED(JSValue, script_value, 0); | 13213 CONVERT_ARG_CHECKED(JSValue, script_value, 0); |
13217 | 13214 |
13218 RUNTIME_ASSERT(script_value->value()->IsScript()); | 13215 RUNTIME_ASSERT(script_value->value()->IsScript()); |
13219 Handle<Script> script = Handle<Script>(Script::cast(script_value->value())); | 13216 Handle<Script> script = Handle<Script>(Script::cast(script_value->value())); |
13220 | 13217 |
13221 const int kBufferSize = 32; | 13218 const int kBufferSize = 32; |
13222 | 13219 |
(...skipping 28 matching lines...) Expand all Loading... | |
13251 } | 13248 } |
13252 | 13249 |
13253 | 13250 |
13254 // For a script calculates compilation information about all its functions. | 13251 // For a script calculates compilation information about all its functions. |
13255 // The script source is explicitly specified by the second argument. | 13252 // The script source is explicitly specified by the second argument. |
13256 // The source of the actual script is not used, however it is important that | 13253 // The source of the actual script is not used, however it is important that |
13257 // all generated code keeps references to this particular instance of script. | 13254 // all generated code keeps references to this particular instance of script. |
13258 // Returns a JSArray of compilation infos. The array is ordered so that | 13255 // Returns a JSArray of compilation infos. The array is ordered so that |
13259 // each function with all its descendant is always stored in a continues range | 13256 // each function with all its descendant is always stored in a continues range |
13260 // with the function itself going first. The root function is a script function. | 13257 // with the function itself going first. The root function is a script function. |
13261 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditGatherCompileInfo) { | 13258 RUNTIME_FUNCTION(Object*, Runtime_LiveEditGatherCompileInfo) { |
13262 HandleScope scope(isolate); | 13259 HandleScope scope(isolate); |
13263 CHECK(isolate->debugger()->live_edit_enabled()); | 13260 CHECK(isolate->debugger()->live_edit_enabled()); |
13264 ASSERT(args.length() == 2); | 13261 ASSERT(args.length() == 2); |
13265 CONVERT_ARG_CHECKED(JSValue, script, 0); | 13262 CONVERT_ARG_CHECKED(JSValue, script, 0); |
13266 CONVERT_ARG_HANDLE_CHECKED(String, source, 1); | 13263 CONVERT_ARG_HANDLE_CHECKED(String, source, 1); |
13267 | 13264 |
13268 RUNTIME_ASSERT(script->value()->IsScript()); | 13265 RUNTIME_ASSERT(script->value()->IsScript()); |
13269 Handle<Script> script_handle = Handle<Script>(Script::cast(script->value())); | 13266 Handle<Script> script_handle = Handle<Script>(Script::cast(script->value())); |
13270 | 13267 |
13271 Handle<JSArray> result; | 13268 Handle<JSArray> result; |
13272 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 13269 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
13273 isolate, result, LiveEdit::GatherCompileInfo(script_handle, source)); | 13270 isolate, result, LiveEdit::GatherCompileInfo(script_handle, source)); |
13274 return *result; | 13271 return *result; |
13275 } | 13272 } |
13276 | 13273 |
13277 | 13274 |
13278 // Changes the source of the script to a new_source. | 13275 // Changes the source of the script to a new_source. |
13279 // If old_script_name is provided (i.e. is a String), also creates a copy of | 13276 // If old_script_name is provided (i.e. is a String), also creates a copy of |
13280 // the script with its original source and sends notification to debugger. | 13277 // the script with its original source and sends notification to debugger. |
13281 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditReplaceScript) { | 13278 RUNTIME_FUNCTION(Object*, Runtime_LiveEditReplaceScript) { |
13282 HandleScope scope(isolate); | 13279 HandleScope scope(isolate); |
13283 CHECK(isolate->debugger()->live_edit_enabled()); | 13280 CHECK(isolate->debugger()->live_edit_enabled()); |
13284 ASSERT(args.length() == 3); | 13281 ASSERT(args.length() == 3); |
13285 CONVERT_ARG_CHECKED(JSValue, original_script_value, 0); | 13282 CONVERT_ARG_CHECKED(JSValue, original_script_value, 0); |
13286 CONVERT_ARG_HANDLE_CHECKED(String, new_source, 1); | 13283 CONVERT_ARG_HANDLE_CHECKED(String, new_source, 1); |
13287 CONVERT_ARG_HANDLE_CHECKED(Object, old_script_name, 2); | 13284 CONVERT_ARG_HANDLE_CHECKED(Object, old_script_name, 2); |
13288 | 13285 |
13289 RUNTIME_ASSERT(original_script_value->value()->IsScript()); | 13286 RUNTIME_ASSERT(original_script_value->value()->IsScript()); |
13290 Handle<Script> original_script(Script::cast(original_script_value->value())); | 13287 Handle<Script> original_script(Script::cast(original_script_value->value())); |
13291 | 13288 |
13292 Handle<Object> old_script = LiveEdit::ChangeScriptSource( | 13289 Handle<Object> old_script = LiveEdit::ChangeScriptSource( |
13293 original_script, new_source, old_script_name); | 13290 original_script, new_source, old_script_name); |
13294 | 13291 |
13295 if (old_script->IsScript()) { | 13292 if (old_script->IsScript()) { |
13296 Handle<Script> script_handle = Handle<Script>::cast(old_script); | 13293 Handle<Script> script_handle = Handle<Script>::cast(old_script); |
13297 return *Script::GetWrapper(script_handle); | 13294 return *Script::GetWrapper(script_handle); |
13298 } else { | 13295 } else { |
13299 return isolate->heap()->null_value(); | 13296 return isolate->heap()->null_value(); |
13300 } | 13297 } |
13301 } | 13298 } |
13302 | 13299 |
13303 | 13300 |
13304 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditFunctionSourceUpdated) { | 13301 RUNTIME_FUNCTION(Object*, Runtime_LiveEditFunctionSourceUpdated) { |
13305 HandleScope scope(isolate); | 13302 HandleScope scope(isolate); |
13306 CHECK(isolate->debugger()->live_edit_enabled()); | 13303 CHECK(isolate->debugger()->live_edit_enabled()); |
13307 ASSERT(args.length() == 1); | 13304 ASSERT(args.length() == 1); |
13308 CONVERT_ARG_HANDLE_CHECKED(JSArray, shared_info, 0); | 13305 CONVERT_ARG_HANDLE_CHECKED(JSArray, shared_info, 0); |
13309 RUNTIME_ASSERT(SharedInfoWrapper::IsInstance(shared_info)); | 13306 RUNTIME_ASSERT(SharedInfoWrapper::IsInstance(shared_info)); |
13310 | 13307 |
13311 LiveEdit::FunctionSourceUpdated(shared_info); | 13308 LiveEdit::FunctionSourceUpdated(shared_info); |
13312 return isolate->heap()->undefined_value(); | 13309 return isolate->heap()->undefined_value(); |
13313 } | 13310 } |
13314 | 13311 |
13315 | 13312 |
13316 // Replaces code of SharedFunctionInfo with a new one. | 13313 // Replaces code of SharedFunctionInfo with a new one. |
13317 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditReplaceFunctionCode) { | 13314 RUNTIME_FUNCTION(Object*, Runtime_LiveEditReplaceFunctionCode) { |
13318 HandleScope scope(isolate); | 13315 HandleScope scope(isolate); |
13319 CHECK(isolate->debugger()->live_edit_enabled()); | 13316 CHECK(isolate->debugger()->live_edit_enabled()); |
13320 ASSERT(args.length() == 2); | 13317 ASSERT(args.length() == 2); |
13321 CONVERT_ARG_HANDLE_CHECKED(JSArray, new_compile_info, 0); | 13318 CONVERT_ARG_HANDLE_CHECKED(JSArray, new_compile_info, 0); |
13322 CONVERT_ARG_HANDLE_CHECKED(JSArray, shared_info, 1); | 13319 CONVERT_ARG_HANDLE_CHECKED(JSArray, shared_info, 1); |
13323 RUNTIME_ASSERT(SharedInfoWrapper::IsInstance(shared_info)); | 13320 RUNTIME_ASSERT(SharedInfoWrapper::IsInstance(shared_info)); |
13324 | 13321 |
13325 LiveEdit::ReplaceFunctionCode(new_compile_info, shared_info); | 13322 LiveEdit::ReplaceFunctionCode(new_compile_info, shared_info); |
13326 return isolate->heap()->undefined_value(); | 13323 return isolate->heap()->undefined_value(); |
13327 } | 13324 } |
13328 | 13325 |
13329 | 13326 |
13330 // Connects SharedFunctionInfo to another script. | 13327 // Connects SharedFunctionInfo to another script. |
13331 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditFunctionSetScript) { | 13328 RUNTIME_FUNCTION(Object*, Runtime_LiveEditFunctionSetScript) { |
13332 HandleScope scope(isolate); | 13329 HandleScope scope(isolate); |
13333 CHECK(isolate->debugger()->live_edit_enabled()); | 13330 CHECK(isolate->debugger()->live_edit_enabled()); |
13334 ASSERT(args.length() == 2); | 13331 ASSERT(args.length() == 2); |
13335 CONVERT_ARG_HANDLE_CHECKED(Object, function_object, 0); | 13332 CONVERT_ARG_HANDLE_CHECKED(Object, function_object, 0); |
13336 CONVERT_ARG_HANDLE_CHECKED(Object, script_object, 1); | 13333 CONVERT_ARG_HANDLE_CHECKED(Object, script_object, 1); |
13337 | 13334 |
13338 if (function_object->IsJSValue()) { | 13335 if (function_object->IsJSValue()) { |
13339 Handle<JSValue> function_wrapper = Handle<JSValue>::cast(function_object); | 13336 Handle<JSValue> function_wrapper = Handle<JSValue>::cast(function_object); |
13340 if (script_object->IsJSValue()) { | 13337 if (script_object->IsJSValue()) { |
13341 RUNTIME_ASSERT(JSValue::cast(*script_object)->value()->IsScript()); | 13338 RUNTIME_ASSERT(JSValue::cast(*script_object)->value()->IsScript()); |
13342 Script* script = Script::cast(JSValue::cast(*script_object)->value()); | 13339 Script* script = Script::cast(JSValue::cast(*script_object)->value()); |
13343 script_object = Handle<Object>(script, isolate); | 13340 script_object = Handle<Object>(script, isolate); |
13344 } | 13341 } |
13345 | 13342 |
13346 LiveEdit::SetFunctionScript(function_wrapper, script_object); | 13343 LiveEdit::SetFunctionScript(function_wrapper, script_object); |
13347 } else { | 13344 } else { |
13348 // Just ignore this. We may not have a SharedFunctionInfo for some functions | 13345 // Just ignore this. We may not have a SharedFunctionInfo for some functions |
13349 // and we check it in this function. | 13346 // and we check it in this function. |
13350 } | 13347 } |
13351 | 13348 |
13352 return isolate->heap()->undefined_value(); | 13349 return isolate->heap()->undefined_value(); |
13353 } | 13350 } |
13354 | 13351 |
13355 | 13352 |
13356 // In a code of a parent function replaces original function as embedded object | 13353 // In a code of a parent function replaces original function as embedded object |
13357 // with a substitution one. | 13354 // with a substitution one. |
13358 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditReplaceRefToNestedFunction) { | 13355 RUNTIME_FUNCTION(Object*, Runtime_LiveEditReplaceRefToNestedFunction) { |
13359 HandleScope scope(isolate); | 13356 HandleScope scope(isolate); |
13360 CHECK(isolate->debugger()->live_edit_enabled()); | 13357 CHECK(isolate->debugger()->live_edit_enabled()); |
13361 ASSERT(args.length() == 3); | 13358 ASSERT(args.length() == 3); |
13362 | 13359 |
13363 CONVERT_ARG_HANDLE_CHECKED(JSValue, parent_wrapper, 0); | 13360 CONVERT_ARG_HANDLE_CHECKED(JSValue, parent_wrapper, 0); |
13364 CONVERT_ARG_HANDLE_CHECKED(JSValue, orig_wrapper, 1); | 13361 CONVERT_ARG_HANDLE_CHECKED(JSValue, orig_wrapper, 1); |
13365 CONVERT_ARG_HANDLE_CHECKED(JSValue, subst_wrapper, 2); | 13362 CONVERT_ARG_HANDLE_CHECKED(JSValue, subst_wrapper, 2); |
13366 | 13363 |
13367 LiveEdit::ReplaceRefToNestedFunction( | 13364 LiveEdit::ReplaceRefToNestedFunction( |
13368 parent_wrapper, orig_wrapper, subst_wrapper); | 13365 parent_wrapper, orig_wrapper, subst_wrapper); |
13369 return isolate->heap()->undefined_value(); | 13366 return isolate->heap()->undefined_value(); |
13370 } | 13367 } |
13371 | 13368 |
13372 | 13369 |
13373 // Updates positions of a shared function info (first parameter) according | 13370 // Updates positions of a shared function info (first parameter) according |
13374 // to script source change. Text change is described in second parameter as | 13371 // to script source change. Text change is described in second parameter as |
13375 // array of groups of 3 numbers: | 13372 // array of groups of 3 numbers: |
13376 // (change_begin, change_end, change_end_new_position). | 13373 // (change_begin, change_end, change_end_new_position). |
13377 // Each group describes a change in text; groups are sorted by change_begin. | 13374 // Each group describes a change in text; groups are sorted by change_begin. |
13378 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditPatchFunctionPositions) { | 13375 RUNTIME_FUNCTION(Object*, Runtime_LiveEditPatchFunctionPositions) { |
13379 HandleScope scope(isolate); | 13376 HandleScope scope(isolate); |
13380 CHECK(isolate->debugger()->live_edit_enabled()); | 13377 CHECK(isolate->debugger()->live_edit_enabled()); |
13381 ASSERT(args.length() == 2); | 13378 ASSERT(args.length() == 2); |
13382 CONVERT_ARG_HANDLE_CHECKED(JSArray, shared_array, 0); | 13379 CONVERT_ARG_HANDLE_CHECKED(JSArray, shared_array, 0); |
13383 CONVERT_ARG_HANDLE_CHECKED(JSArray, position_change_array, 1); | 13380 CONVERT_ARG_HANDLE_CHECKED(JSArray, position_change_array, 1); |
13384 RUNTIME_ASSERT(SharedInfoWrapper::IsInstance(shared_array)) | 13381 RUNTIME_ASSERT(SharedInfoWrapper::IsInstance(shared_array)) |
13385 | 13382 |
13386 LiveEdit::PatchFunctionPositions(shared_array, position_change_array); | 13383 LiveEdit::PatchFunctionPositions(shared_array, position_change_array); |
13387 return isolate->heap()->undefined_value(); | 13384 return isolate->heap()->undefined_value(); |
13388 } | 13385 } |
13389 | 13386 |
13390 | 13387 |
13391 // For array of SharedFunctionInfo's (each wrapped in JSValue) | 13388 // For array of SharedFunctionInfo's (each wrapped in JSValue) |
13392 // checks that none of them have activations on stacks (of any thread). | 13389 // checks that none of them have activations on stacks (of any thread). |
13393 // Returns array of the same length with corresponding results of | 13390 // Returns array of the same length with corresponding results of |
13394 // LiveEdit::FunctionPatchabilityStatus type. | 13391 // LiveEdit::FunctionPatchabilityStatus type. |
13395 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditCheckAndDropActivations) { | 13392 RUNTIME_FUNCTION(Object*, Runtime_LiveEditCheckAndDropActivations) { |
13396 HandleScope scope(isolate); | 13393 HandleScope scope(isolate); |
13397 CHECK(isolate->debugger()->live_edit_enabled()); | 13394 CHECK(isolate->debugger()->live_edit_enabled()); |
13398 ASSERT(args.length() == 2); | 13395 ASSERT(args.length() == 2); |
13399 CONVERT_ARG_HANDLE_CHECKED(JSArray, shared_array, 0); | 13396 CONVERT_ARG_HANDLE_CHECKED(JSArray, shared_array, 0); |
13400 CONVERT_BOOLEAN_ARG_CHECKED(do_drop, 1); | 13397 CONVERT_BOOLEAN_ARG_CHECKED(do_drop, 1); |
13401 | 13398 |
13402 return *LiveEdit::CheckAndDropActivations(shared_array, do_drop); | 13399 return *LiveEdit::CheckAndDropActivations(shared_array, do_drop); |
13403 } | 13400 } |
13404 | 13401 |
13405 | 13402 |
13406 // Compares 2 strings line-by-line, then token-wise and returns diff in form | 13403 // Compares 2 strings line-by-line, then token-wise and returns diff in form |
13407 // of JSArray of triplets (pos1, pos1_end, pos2_end) describing list | 13404 // of JSArray of triplets (pos1, pos1_end, pos2_end) describing list |
13408 // of diff chunks. | 13405 // of diff chunks. |
13409 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditCompareStrings) { | 13406 RUNTIME_FUNCTION(Object*, Runtime_LiveEditCompareStrings) { |
13410 HandleScope scope(isolate); | 13407 HandleScope scope(isolate); |
13411 CHECK(isolate->debugger()->live_edit_enabled()); | 13408 CHECK(isolate->debugger()->live_edit_enabled()); |
13412 ASSERT(args.length() == 2); | 13409 ASSERT(args.length() == 2); |
13413 CONVERT_ARG_HANDLE_CHECKED(String, s1, 0); | 13410 CONVERT_ARG_HANDLE_CHECKED(String, s1, 0); |
13414 CONVERT_ARG_HANDLE_CHECKED(String, s2, 1); | 13411 CONVERT_ARG_HANDLE_CHECKED(String, s2, 1); |
13415 | 13412 |
13416 return *LiveEdit::CompareStrings(s1, s2); | 13413 return *LiveEdit::CompareStrings(s1, s2); |
13417 } | 13414 } |
13418 | 13415 |
13419 | 13416 |
13420 // Restarts a call frame and completely drops all frames above. | 13417 // Restarts a call frame and completely drops all frames above. |
13421 // Returns true if successful. Otherwise returns undefined or an error message. | 13418 // Returns true if successful. Otherwise returns undefined or an error message. |
13422 RUNTIME_FUNCTION(MaybeObject*, Runtime_LiveEditRestartFrame) { | 13419 RUNTIME_FUNCTION(Object*, Runtime_LiveEditRestartFrame) { |
13423 HandleScope scope(isolate); | 13420 HandleScope scope(isolate); |
13424 CHECK(isolate->debugger()->live_edit_enabled()); | 13421 CHECK(isolate->debugger()->live_edit_enabled()); |
13425 ASSERT(args.length() == 2); | 13422 ASSERT(args.length() == 2); |
13426 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); | 13423 CONVERT_NUMBER_CHECKED(int, break_id, Int32, args[0]); |
13427 RUNTIME_ASSERT(CheckExecutionState(isolate, break_id)); | 13424 RUNTIME_ASSERT(CheckExecutionState(isolate, break_id)); |
13428 | 13425 |
13429 CONVERT_NUMBER_CHECKED(int, index, Int32, args[1]); | 13426 CONVERT_NUMBER_CHECKED(int, index, Int32, args[1]); |
13430 Heap* heap = isolate->heap(); | 13427 Heap* heap = isolate->heap(); |
13431 | 13428 |
13432 // Find the relevant frame with the requested index. | 13429 // Find the relevant frame with the requested index. |
(...skipping 14 matching lines...) Expand all Loading... | |
13447 const char* error_message = LiveEdit::RestartFrame(it.frame()); | 13444 const char* error_message = LiveEdit::RestartFrame(it.frame()); |
13448 if (error_message) { | 13445 if (error_message) { |
13449 return *(isolate->factory()->InternalizeUtf8String(error_message)); | 13446 return *(isolate->factory()->InternalizeUtf8String(error_message)); |
13450 } | 13447 } |
13451 return heap->true_value(); | 13448 return heap->true_value(); |
13452 } | 13449 } |
13453 | 13450 |
13454 | 13451 |
13455 // A testing entry. Returns statement position which is the closest to | 13452 // A testing entry. Returns statement position which is the closest to |
13456 // source_position. | 13453 // source_position. |
13457 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetFunctionCodePositionFromSource) { | 13454 RUNTIME_FUNCTION(Object*, Runtime_GetFunctionCodePositionFromSource) { |
13458 HandleScope scope(isolate); | 13455 HandleScope scope(isolate); |
13459 CHECK(isolate->debugger()->live_edit_enabled()); | 13456 CHECK(isolate->debugger()->live_edit_enabled()); |
13460 ASSERT(args.length() == 2); | 13457 ASSERT(args.length() == 2); |
13461 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 13458 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
13462 CONVERT_NUMBER_CHECKED(int32_t, source_position, Int32, args[1]); | 13459 CONVERT_NUMBER_CHECKED(int32_t, source_position, Int32, args[1]); |
13463 | 13460 |
13464 Handle<Code> code(function->code(), isolate); | 13461 Handle<Code> code(function->code(), isolate); |
13465 | 13462 |
13466 if (code->kind() != Code::FUNCTION && | 13463 if (code->kind() != Code::FUNCTION && |
13467 code->kind() != Code::OPTIMIZED_FUNCTION) { | 13464 code->kind() != Code::OPTIMIZED_FUNCTION) { |
(...skipping 17 matching lines...) Expand all Loading... | |
13485 it.next(); | 13482 it.next(); |
13486 } | 13483 } |
13487 | 13484 |
13488 return Smi::FromInt(closest_pc); | 13485 return Smi::FromInt(closest_pc); |
13489 } | 13486 } |
13490 | 13487 |
13491 | 13488 |
13492 // Calls specified function with or without entering the debugger. | 13489 // Calls specified function with or without entering the debugger. |
13493 // This is used in unit tests to run code as if debugger is entered or simply | 13490 // This is used in unit tests to run code as if debugger is entered or simply |
13494 // to have a stack with C++ frame in the middle. | 13491 // to have a stack with C++ frame in the middle. |
13495 RUNTIME_FUNCTION(MaybeObject*, Runtime_ExecuteInDebugContext) { | 13492 RUNTIME_FUNCTION(Object*, Runtime_ExecuteInDebugContext) { |
13496 HandleScope scope(isolate); | 13493 HandleScope scope(isolate); |
13497 ASSERT(args.length() == 2); | 13494 ASSERT(args.length() == 2); |
13498 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); | 13495 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
13499 CONVERT_BOOLEAN_ARG_CHECKED(without_debugger, 1); | 13496 CONVERT_BOOLEAN_ARG_CHECKED(without_debugger, 1); |
13500 | 13497 |
13501 MaybeHandle<Object> maybe_result; | 13498 MaybeHandle<Object> maybe_result; |
13502 if (without_debugger) { | 13499 if (without_debugger) { |
13503 maybe_result = Execution::Call(isolate, | 13500 maybe_result = Execution::Call(isolate, |
13504 function, | 13501 function, |
13505 isolate->global_object(), | 13502 isolate->global_object(), |
13506 0, | 13503 0, |
13507 NULL); | 13504 NULL); |
13508 } else { | 13505 } else { |
13509 EnterDebugger enter_debugger(isolate); | 13506 EnterDebugger enter_debugger(isolate); |
13510 maybe_result = Execution::Call(isolate, | 13507 maybe_result = Execution::Call(isolate, |
13511 function, | 13508 function, |
13512 isolate->global_object(), | 13509 isolate->global_object(), |
13513 0, | 13510 0, |
13514 NULL); | 13511 NULL); |
13515 } | 13512 } |
13516 Handle<Object> result; | 13513 Handle<Object> result; |
13517 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, maybe_result); | 13514 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, maybe_result); |
13518 return *result; | 13515 return *result; |
13519 } | 13516 } |
13520 | 13517 |
13521 | 13518 |
13522 // Sets a v8 flag. | 13519 // Sets a v8 flag. |
13523 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetFlags) { | 13520 RUNTIME_FUNCTION(Object*, Runtime_SetFlags) { |
13524 SealHandleScope shs(isolate); | 13521 SealHandleScope shs(isolate); |
13525 ASSERT(args.length() == 1); | 13522 ASSERT(args.length() == 1); |
13526 CONVERT_ARG_CHECKED(String, arg, 0); | 13523 CONVERT_ARG_CHECKED(String, arg, 0); |
13527 SmartArrayPointer<char> flags = | 13524 SmartArrayPointer<char> flags = |
13528 arg->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); | 13525 arg->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL); |
13529 FlagList::SetFlagsFromString(flags.get(), StrLength(flags.get())); | 13526 FlagList::SetFlagsFromString(flags.get(), StrLength(flags.get())); |
13530 return isolate->heap()->undefined_value(); | 13527 return isolate->heap()->undefined_value(); |
13531 } | 13528 } |
13532 | 13529 |
13533 | 13530 |
13534 // Performs a GC. | 13531 // Performs a GC. |
13535 // Presently, it only does a full GC. | 13532 // Presently, it only does a full GC. |
13536 RUNTIME_FUNCTION(MaybeObject*, Runtime_CollectGarbage) { | 13533 RUNTIME_FUNCTION(Object*, Runtime_CollectGarbage) { |
13537 SealHandleScope shs(isolate); | 13534 SealHandleScope shs(isolate); |
13538 ASSERT(args.length() == 1); | 13535 ASSERT(args.length() == 1); |
13539 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, "%CollectGarbage"); | 13536 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, "%CollectGarbage"); |
13540 return isolate->heap()->undefined_value(); | 13537 return isolate->heap()->undefined_value(); |
13541 } | 13538 } |
13542 | 13539 |
13543 | 13540 |
13544 // Gets the current heap usage. | 13541 // Gets the current heap usage. |
13545 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetHeapUsage) { | 13542 RUNTIME_FUNCTION(Object*, Runtime_GetHeapUsage) { |
13546 SealHandleScope shs(isolate); | 13543 SealHandleScope shs(isolate); |
13547 ASSERT(args.length() == 0); | 13544 ASSERT(args.length() == 0); |
13548 int usage = static_cast<int>(isolate->heap()->SizeOfObjects()); | 13545 int usage = static_cast<int>(isolate->heap()->SizeOfObjects()); |
13549 if (!Smi::IsValid(usage)) { | 13546 if (!Smi::IsValid(usage)) { |
13550 return *isolate->factory()->NewNumberFromInt(usage); | 13547 return *isolate->factory()->NewNumberFromInt(usage); |
13551 } | 13548 } |
13552 return Smi::FromInt(usage); | 13549 return Smi::FromInt(usage); |
13553 } | 13550 } |
13554 | 13551 |
13555 #endif // ENABLE_DEBUGGER_SUPPORT | 13552 #endif // ENABLE_DEBUGGER_SUPPORT |
13556 | 13553 |
13557 | 13554 |
13558 #ifdef V8_I18N_SUPPORT | 13555 #ifdef V8_I18N_SUPPORT |
13559 RUNTIME_FUNCTION(MaybeObject*, Runtime_CanonicalizeLanguageTag) { | 13556 RUNTIME_FUNCTION(Object*, Runtime_CanonicalizeLanguageTag) { |
13560 HandleScope scope(isolate); | 13557 HandleScope scope(isolate); |
13561 Factory* factory = isolate->factory(); | 13558 Factory* factory = isolate->factory(); |
13562 | 13559 |
13563 ASSERT(args.length() == 1); | 13560 ASSERT(args.length() == 1); |
13564 CONVERT_ARG_HANDLE_CHECKED(String, locale_id_str, 0); | 13561 CONVERT_ARG_HANDLE_CHECKED(String, locale_id_str, 0); |
13565 | 13562 |
13566 v8::String::Utf8Value locale_id(v8::Utils::ToLocal(locale_id_str)); | 13563 v8::String::Utf8Value locale_id(v8::Utils::ToLocal(locale_id_str)); |
13567 | 13564 |
13568 // Return value which denotes invalid language tag. | 13565 // Return value which denotes invalid language tag. |
13569 const char* const kInvalidTag = "invalid-tag"; | 13566 const char* const kInvalidTag = "invalid-tag"; |
(...skipping 14 matching lines...) Expand all Loading... | |
13584 uloc_toLanguageTag(icu_result, result, ULOC_FULLNAME_CAPACITY, TRUE, &error); | 13581 uloc_toLanguageTag(icu_result, result, ULOC_FULLNAME_CAPACITY, TRUE, &error); |
13585 | 13582 |
13586 if (U_FAILURE(error)) { | 13583 if (U_FAILURE(error)) { |
13587 return *factory->NewStringFromAsciiChecked(kInvalidTag); | 13584 return *factory->NewStringFromAsciiChecked(kInvalidTag); |
13588 } | 13585 } |
13589 | 13586 |
13590 return *factory->NewStringFromAsciiChecked(result); | 13587 return *factory->NewStringFromAsciiChecked(result); |
13591 } | 13588 } |
13592 | 13589 |
13593 | 13590 |
13594 RUNTIME_FUNCTION(MaybeObject*, Runtime_AvailableLocalesOf) { | 13591 RUNTIME_FUNCTION(Object*, Runtime_AvailableLocalesOf) { |
13595 HandleScope scope(isolate); | 13592 HandleScope scope(isolate); |
13596 Factory* factory = isolate->factory(); | 13593 Factory* factory = isolate->factory(); |
13597 | 13594 |
13598 ASSERT(args.length() == 1); | 13595 ASSERT(args.length() == 1); |
13599 CONVERT_ARG_HANDLE_CHECKED(String, service, 0); | 13596 CONVERT_ARG_HANDLE_CHECKED(String, service, 0); |
13600 | 13597 |
13601 const icu::Locale* available_locales = NULL; | 13598 const icu::Locale* available_locales = NULL; |
13602 int32_t count = 0; | 13599 int32_t count = 0; |
13603 | 13600 |
13604 if (service->IsUtf8EqualTo(CStrVector("collator"))) { | 13601 if (service->IsUtf8EqualTo(CStrVector("collator"))) { |
(...skipping 27 matching lines...) Expand all Loading... | |
13632 locales, | 13629 locales, |
13633 factory->NewStringFromAsciiChecked(result), | 13630 factory->NewStringFromAsciiChecked(result), |
13634 factory->NewNumber(i), | 13631 factory->NewNumber(i), |
13635 NONE)); | 13632 NONE)); |
13636 } | 13633 } |
13637 | 13634 |
13638 return *locales; | 13635 return *locales; |
13639 } | 13636 } |
13640 | 13637 |
13641 | 13638 |
13642 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetDefaultICULocale) { | 13639 RUNTIME_FUNCTION(Object*, Runtime_GetDefaultICULocale) { |
13643 HandleScope scope(isolate); | 13640 HandleScope scope(isolate); |
13644 Factory* factory = isolate->factory(); | 13641 Factory* factory = isolate->factory(); |
13645 | 13642 |
13646 ASSERT(args.length() == 0); | 13643 ASSERT(args.length() == 0); |
13647 | 13644 |
13648 icu::Locale default_locale; | 13645 icu::Locale default_locale; |
13649 | 13646 |
13650 // Set the locale | 13647 // Set the locale |
13651 char result[ULOC_FULLNAME_CAPACITY]; | 13648 char result[ULOC_FULLNAME_CAPACITY]; |
13652 UErrorCode status = U_ZERO_ERROR; | 13649 UErrorCode status = U_ZERO_ERROR; |
13653 uloc_toLanguageTag( | 13650 uloc_toLanguageTag( |
13654 default_locale.getName(), result, ULOC_FULLNAME_CAPACITY, FALSE, &status); | 13651 default_locale.getName(), result, ULOC_FULLNAME_CAPACITY, FALSE, &status); |
13655 if (U_SUCCESS(status)) { | 13652 if (U_SUCCESS(status)) { |
13656 return *factory->NewStringFromAsciiChecked(result); | 13653 return *factory->NewStringFromAsciiChecked(result); |
13657 } | 13654 } |
13658 | 13655 |
13659 return *factory->NewStringFromStaticAscii("und"); | 13656 return *factory->NewStringFromStaticAscii("und"); |
13660 } | 13657 } |
13661 | 13658 |
13662 | 13659 |
13663 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetLanguageTagVariants) { | 13660 RUNTIME_FUNCTION(Object*, Runtime_GetLanguageTagVariants) { |
13664 HandleScope scope(isolate); | 13661 HandleScope scope(isolate); |
13665 Factory* factory = isolate->factory(); | 13662 Factory* factory = isolate->factory(); |
13666 | 13663 |
13667 ASSERT(args.length() == 1); | 13664 ASSERT(args.length() == 1); |
13668 | 13665 |
13669 CONVERT_ARG_HANDLE_CHECKED(JSArray, input, 0); | 13666 CONVERT_ARG_HANDLE_CHECKED(JSArray, input, 0); |
13670 | 13667 |
13671 uint32_t length = static_cast<uint32_t>(input->length()->Number()); | 13668 uint32_t length = static_cast<uint32_t>(input->length()->Number()); |
13672 Handle<FixedArray> output = factory->NewFixedArray(length); | 13669 Handle<FixedArray> output = factory->NewFixedArray(length); |
13673 Handle<Name> maximized = factory->NewStringFromStaticAscii("maximized"); | 13670 Handle<Name> maximized = factory->NewStringFromStaticAscii("maximized"); |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
13743 NONE)); | 13740 NONE)); |
13744 output->set(i, *result); | 13741 output->set(i, *result); |
13745 } | 13742 } |
13746 | 13743 |
13747 Handle<JSArray> result = factory->NewJSArrayWithElements(output); | 13744 Handle<JSArray> result = factory->NewJSArrayWithElements(output); |
13748 result->set_length(Smi::FromInt(length)); | 13745 result->set_length(Smi::FromInt(length)); |
13749 return *result; | 13746 return *result; |
13750 } | 13747 } |
13751 | 13748 |
13752 | 13749 |
13753 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsInitializedIntlObject) { | 13750 RUNTIME_FUNCTION(Object*, Runtime_IsInitializedIntlObject) { |
13754 HandleScope scope(isolate); | 13751 HandleScope scope(isolate); |
13755 | 13752 |
13756 ASSERT(args.length() == 1); | 13753 ASSERT(args.length() == 1); |
13757 | 13754 |
13758 CONVERT_ARG_HANDLE_CHECKED(Object, input, 0); | 13755 CONVERT_ARG_HANDLE_CHECKED(Object, input, 0); |
13759 | 13756 |
13760 if (!input->IsJSObject()) return isolate->heap()->false_value(); | 13757 if (!input->IsJSObject()) return isolate->heap()->false_value(); |
13761 Handle<JSObject> obj = Handle<JSObject>::cast(input); | 13758 Handle<JSObject> obj = Handle<JSObject>::cast(input); |
13762 | 13759 |
13763 Handle<String> marker = isolate->factory()->intl_initialized_marker_string(); | 13760 Handle<String> marker = isolate->factory()->intl_initialized_marker_string(); |
13764 Handle<Object> tag(obj->GetHiddenProperty(*marker), isolate); | 13761 Handle<Object> tag(obj->GetHiddenProperty(*marker), isolate); |
13765 return isolate->heap()->ToBoolean(!tag->IsTheHole()); | 13762 return isolate->heap()->ToBoolean(!tag->IsTheHole()); |
13766 } | 13763 } |
13767 | 13764 |
13768 | 13765 |
13769 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsInitializedIntlObjectOfType) { | 13766 RUNTIME_FUNCTION(Object*, Runtime_IsInitializedIntlObjectOfType) { |
13770 HandleScope scope(isolate); | 13767 HandleScope scope(isolate); |
13771 | 13768 |
13772 ASSERT(args.length() == 2); | 13769 ASSERT(args.length() == 2); |
13773 | 13770 |
13774 CONVERT_ARG_HANDLE_CHECKED(Object, input, 0); | 13771 CONVERT_ARG_HANDLE_CHECKED(Object, input, 0); |
13775 CONVERT_ARG_HANDLE_CHECKED(String, expected_type, 1); | 13772 CONVERT_ARG_HANDLE_CHECKED(String, expected_type, 1); |
13776 | 13773 |
13777 if (!input->IsJSObject()) return isolate->heap()->false_value(); | 13774 if (!input->IsJSObject()) return isolate->heap()->false_value(); |
13778 Handle<JSObject> obj = Handle<JSObject>::cast(input); | 13775 Handle<JSObject> obj = Handle<JSObject>::cast(input); |
13779 | 13776 |
13780 Handle<String> marker = isolate->factory()->intl_initialized_marker_string(); | 13777 Handle<String> marker = isolate->factory()->intl_initialized_marker_string(); |
13781 Handle<Object> tag(obj->GetHiddenProperty(*marker), isolate); | 13778 Handle<Object> tag(obj->GetHiddenProperty(*marker), isolate); |
13782 return isolate->heap()->ToBoolean( | 13779 return isolate->heap()->ToBoolean( |
13783 tag->IsString() && String::cast(*tag)->Equals(*expected_type)); | 13780 tag->IsString() && String::cast(*tag)->Equals(*expected_type)); |
13784 } | 13781 } |
13785 | 13782 |
13786 | 13783 |
13787 RUNTIME_FUNCTION(MaybeObject*, Runtime_MarkAsInitializedIntlObjectOfType) { | 13784 RUNTIME_FUNCTION(Object*, Runtime_MarkAsInitializedIntlObjectOfType) { |
13788 HandleScope scope(isolate); | 13785 HandleScope scope(isolate); |
13789 | 13786 |
13790 ASSERT(args.length() == 3); | 13787 ASSERT(args.length() == 3); |
13791 | 13788 |
13792 CONVERT_ARG_HANDLE_CHECKED(JSObject, input, 0); | 13789 CONVERT_ARG_HANDLE_CHECKED(JSObject, input, 0); |
13793 CONVERT_ARG_HANDLE_CHECKED(String, type, 1); | 13790 CONVERT_ARG_HANDLE_CHECKED(String, type, 1); |
13794 CONVERT_ARG_HANDLE_CHECKED(JSObject, impl, 2); | 13791 CONVERT_ARG_HANDLE_CHECKED(JSObject, impl, 2); |
13795 | 13792 |
13796 Handle<String> marker = isolate->factory()->intl_initialized_marker_string(); | 13793 Handle<String> marker = isolate->factory()->intl_initialized_marker_string(); |
13797 JSObject::SetHiddenProperty(input, marker, type); | 13794 JSObject::SetHiddenProperty(input, marker, type); |
13798 | 13795 |
13799 marker = isolate->factory()->intl_impl_object_string(); | 13796 marker = isolate->factory()->intl_impl_object_string(); |
13800 JSObject::SetHiddenProperty(input, marker, impl); | 13797 JSObject::SetHiddenProperty(input, marker, impl); |
13801 | 13798 |
13802 return isolate->heap()->undefined_value(); | 13799 return isolate->heap()->undefined_value(); |
13803 } | 13800 } |
13804 | 13801 |
13805 | 13802 |
13806 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetImplFromInitializedIntlObject) { | 13803 RUNTIME_FUNCTION(Object*, Runtime_GetImplFromInitializedIntlObject) { |
13807 HandleScope scope(isolate); | 13804 HandleScope scope(isolate); |
13808 | 13805 |
13809 ASSERT(args.length() == 1); | 13806 ASSERT(args.length() == 1); |
13810 | 13807 |
13811 CONVERT_ARG_HANDLE_CHECKED(Object, input, 0); | 13808 CONVERT_ARG_HANDLE_CHECKED(Object, input, 0); |
13812 | 13809 |
13813 if (!input->IsJSObject()) { | 13810 if (!input->IsJSObject()) { |
13814 Vector< Handle<Object> > arguments = HandleVector(&input, 1); | 13811 Vector< Handle<Object> > arguments = HandleVector(&input, 1); |
13815 Handle<Object> type_error = | 13812 Handle<Object> type_error = |
13816 isolate->factory()->NewTypeError("not_intl_object", arguments); | 13813 isolate->factory()->NewTypeError("not_intl_object", arguments); |
13817 return isolate->Throw(*type_error); | 13814 return isolate->Throw(*type_error); |
13818 } | 13815 } |
13819 | 13816 |
13820 Handle<JSObject> obj = Handle<JSObject>::cast(input); | 13817 Handle<JSObject> obj = Handle<JSObject>::cast(input); |
13821 | 13818 |
13822 Handle<String> marker = isolate->factory()->intl_impl_object_string(); | 13819 Handle<String> marker = isolate->factory()->intl_impl_object_string(); |
13823 Handle<Object> impl(obj->GetHiddenProperty(*marker), isolate); | 13820 Handle<Object> impl(obj->GetHiddenProperty(*marker), isolate); |
13824 if (impl->IsTheHole()) { | 13821 if (impl->IsTheHole()) { |
13825 Vector< Handle<Object> > arguments = HandleVector(&obj, 1); | 13822 Vector< Handle<Object> > arguments = HandleVector(&obj, 1); |
13826 Handle<Object> type_error = | 13823 Handle<Object> type_error = |
13827 isolate->factory()->NewTypeError("not_intl_object", arguments); | 13824 isolate->factory()->NewTypeError("not_intl_object", arguments); |
13828 return isolate->Throw(*type_error); | 13825 return isolate->Throw(*type_error); |
13829 } | 13826 } |
13830 return *impl; | 13827 return *impl; |
13831 } | 13828 } |
13832 | 13829 |
13833 | 13830 |
13834 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateDateTimeFormat) { | 13831 RUNTIME_FUNCTION(Object*, Runtime_CreateDateTimeFormat) { |
13835 HandleScope scope(isolate); | 13832 HandleScope scope(isolate); |
13836 | 13833 |
13837 ASSERT(args.length() == 3); | 13834 ASSERT(args.length() == 3); |
13838 | 13835 |
13839 CONVERT_ARG_HANDLE_CHECKED(String, locale, 0); | 13836 CONVERT_ARG_HANDLE_CHECKED(String, locale, 0); |
13840 CONVERT_ARG_HANDLE_CHECKED(JSObject, options, 1); | 13837 CONVERT_ARG_HANDLE_CHECKED(JSObject, options, 1); |
13841 CONVERT_ARG_HANDLE_CHECKED(JSObject, resolved, 2); | 13838 CONVERT_ARG_HANDLE_CHECKED(JSObject, resolved, 2); |
13842 | 13839 |
13843 Handle<ObjectTemplateInfo> date_format_template = | 13840 Handle<ObjectTemplateInfo> date_format_template = |
13844 I18N::GetTemplate(isolate); | 13841 I18N::GetTemplate(isolate); |
(...skipping 21 matching lines...) Expand all Loading... | |
13866 | 13863 |
13867 // Make object handle weak so we can delete the data format once GC kicks in. | 13864 // Make object handle weak so we can delete the data format once GC kicks in. |
13868 Handle<Object> wrapper = isolate->global_handles()->Create(*local_object); | 13865 Handle<Object> wrapper = isolate->global_handles()->Create(*local_object); |
13869 GlobalHandles::MakeWeak(wrapper.location(), | 13866 GlobalHandles::MakeWeak(wrapper.location(), |
13870 reinterpret_cast<void*>(wrapper.location()), | 13867 reinterpret_cast<void*>(wrapper.location()), |
13871 DateFormat::DeleteDateFormat); | 13868 DateFormat::DeleteDateFormat); |
13872 return *local_object; | 13869 return *local_object; |
13873 } | 13870 } |
13874 | 13871 |
13875 | 13872 |
13876 RUNTIME_FUNCTION(MaybeObject*, Runtime_InternalDateFormat) { | 13873 RUNTIME_FUNCTION(Object*, Runtime_InternalDateFormat) { |
13877 HandleScope scope(isolate); | 13874 HandleScope scope(isolate); |
13878 | 13875 |
13879 ASSERT(args.length() == 2); | 13876 ASSERT(args.length() == 2); |
13880 | 13877 |
13881 CONVERT_ARG_HANDLE_CHECKED(JSObject, date_format_holder, 0); | 13878 CONVERT_ARG_HANDLE_CHECKED(JSObject, date_format_holder, 0); |
13882 CONVERT_ARG_HANDLE_CHECKED(JSDate, date, 1); | 13879 CONVERT_ARG_HANDLE_CHECKED(JSDate, date, 1); |
13883 | 13880 |
13884 Handle<Object> value; | 13881 Handle<Object> value; |
13885 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 13882 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
13886 isolate, value, Execution::ToNumber(isolate, date)); | 13883 isolate, value, Execution::ToNumber(isolate, date)); |
13887 | 13884 |
13888 icu::SimpleDateFormat* date_format = | 13885 icu::SimpleDateFormat* date_format = |
13889 DateFormat::UnpackDateFormat(isolate, date_format_holder); | 13886 DateFormat::UnpackDateFormat(isolate, date_format_holder); |
13890 if (!date_format) return isolate->ThrowIllegalOperation(); | 13887 if (!date_format) return isolate->ThrowIllegalOperation(); |
13891 | 13888 |
13892 icu::UnicodeString result; | 13889 icu::UnicodeString result; |
13893 date_format->format(value->Number(), result); | 13890 date_format->format(value->Number(), result); |
13894 | 13891 |
13895 Handle<String> result_str; | 13892 Handle<String> result_str; |
13896 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 13893 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
13897 isolate, result_str, | 13894 isolate, result_str, |
13898 isolate->factory()->NewStringFromTwoByte( | 13895 isolate->factory()->NewStringFromTwoByte( |
13899 Vector<const uint16_t>( | 13896 Vector<const uint16_t>( |
13900 reinterpret_cast<const uint16_t*>(result.getBuffer()), | 13897 reinterpret_cast<const uint16_t*>(result.getBuffer()), |
13901 result.length()))); | 13898 result.length()))); |
13902 return *result_str; | 13899 return *result_str; |
13903 } | 13900 } |
13904 | 13901 |
13905 | 13902 |
13906 RUNTIME_FUNCTION(MaybeObject*, Runtime_InternalDateParse) { | 13903 RUNTIME_FUNCTION(Object*, Runtime_InternalDateParse) { |
13907 HandleScope scope(isolate); | 13904 HandleScope scope(isolate); |
13908 | 13905 |
13909 ASSERT(args.length() == 2); | 13906 ASSERT(args.length() == 2); |
13910 | 13907 |
13911 CONVERT_ARG_HANDLE_CHECKED(JSObject, date_format_holder, 0); | 13908 CONVERT_ARG_HANDLE_CHECKED(JSObject, date_format_holder, 0); |
13912 CONVERT_ARG_HANDLE_CHECKED(String, date_string, 1); | 13909 CONVERT_ARG_HANDLE_CHECKED(String, date_string, 1); |
13913 | 13910 |
13914 v8::String::Utf8Value utf8_date(v8::Utils::ToLocal(date_string)); | 13911 v8::String::Utf8Value utf8_date(v8::Utils::ToLocal(date_string)); |
13915 icu::UnicodeString u_date(icu::UnicodeString::fromUTF8(*utf8_date)); | 13912 icu::UnicodeString u_date(icu::UnicodeString::fromUTF8(*utf8_date)); |
13916 icu::SimpleDateFormat* date_format = | 13913 icu::SimpleDateFormat* date_format = |
13917 DateFormat::UnpackDateFormat(isolate, date_format_holder); | 13914 DateFormat::UnpackDateFormat(isolate, date_format_holder); |
13918 if (!date_format) return isolate->ThrowIllegalOperation(); | 13915 if (!date_format) return isolate->ThrowIllegalOperation(); |
13919 | 13916 |
13920 UErrorCode status = U_ZERO_ERROR; | 13917 UErrorCode status = U_ZERO_ERROR; |
13921 UDate date = date_format->parse(u_date, status); | 13918 UDate date = date_format->parse(u_date, status); |
13922 if (U_FAILURE(status)) return isolate->heap()->undefined_value(); | 13919 if (U_FAILURE(status)) return isolate->heap()->undefined_value(); |
13923 | 13920 |
13924 Handle<Object> result; | 13921 Handle<Object> result; |
13925 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 13922 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
13926 isolate, result, | 13923 isolate, result, |
13927 Execution::NewDate(isolate, static_cast<double>(date))); | 13924 Execution::NewDate(isolate, static_cast<double>(date))); |
13928 ASSERT(result->IsJSDate()); | 13925 ASSERT(result->IsJSDate()); |
13929 return *result; | 13926 return *result; |
13930 } | 13927 } |
13931 | 13928 |
13932 | 13929 |
13933 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateNumberFormat) { | 13930 RUNTIME_FUNCTION(Object*, Runtime_CreateNumberFormat) { |
13934 HandleScope scope(isolate); | 13931 HandleScope scope(isolate); |
13935 | 13932 |
13936 ASSERT(args.length() == 3); | 13933 ASSERT(args.length() == 3); |
13937 | 13934 |
13938 CONVERT_ARG_HANDLE_CHECKED(String, locale, 0); | 13935 CONVERT_ARG_HANDLE_CHECKED(String, locale, 0); |
13939 CONVERT_ARG_HANDLE_CHECKED(JSObject, options, 1); | 13936 CONVERT_ARG_HANDLE_CHECKED(JSObject, options, 1); |
13940 CONVERT_ARG_HANDLE_CHECKED(JSObject, resolved, 2); | 13937 CONVERT_ARG_HANDLE_CHECKED(JSObject, resolved, 2); |
13941 | 13938 |
13942 Handle<ObjectTemplateInfo> number_format_template = | 13939 Handle<ObjectTemplateInfo> number_format_template = |
13943 I18N::GetTemplate(isolate); | 13940 I18N::GetTemplate(isolate); |
(...skipping 20 matching lines...) Expand all Loading... | |
13964 NONE)); | 13961 NONE)); |
13965 | 13962 |
13966 Handle<Object> wrapper = isolate->global_handles()->Create(*local_object); | 13963 Handle<Object> wrapper = isolate->global_handles()->Create(*local_object); |
13967 GlobalHandles::MakeWeak(wrapper.location(), | 13964 GlobalHandles::MakeWeak(wrapper.location(), |
13968 reinterpret_cast<void*>(wrapper.location()), | 13965 reinterpret_cast<void*>(wrapper.location()), |
13969 NumberFormat::DeleteNumberFormat); | 13966 NumberFormat::DeleteNumberFormat); |
13970 return *local_object; | 13967 return *local_object; |
13971 } | 13968 } |
13972 | 13969 |
13973 | 13970 |
13974 RUNTIME_FUNCTION(MaybeObject*, Runtime_InternalNumberFormat) { | 13971 RUNTIME_FUNCTION(Object*, Runtime_InternalNumberFormat) { |
13975 HandleScope scope(isolate); | 13972 HandleScope scope(isolate); |
13976 | 13973 |
13977 ASSERT(args.length() == 2); | 13974 ASSERT(args.length() == 2); |
13978 | 13975 |
13979 CONVERT_ARG_HANDLE_CHECKED(JSObject, number_format_holder, 0); | 13976 CONVERT_ARG_HANDLE_CHECKED(JSObject, number_format_holder, 0); |
13980 CONVERT_ARG_HANDLE_CHECKED(Object, number, 1); | 13977 CONVERT_ARG_HANDLE_CHECKED(Object, number, 1); |
13981 | 13978 |
13982 Handle<Object> value; | 13979 Handle<Object> value; |
13983 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 13980 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
13984 isolate, value, Execution::ToNumber(isolate, number)); | 13981 isolate, value, Execution::ToNumber(isolate, number)); |
13985 | 13982 |
13986 icu::DecimalFormat* number_format = | 13983 icu::DecimalFormat* number_format = |
13987 NumberFormat::UnpackNumberFormat(isolate, number_format_holder); | 13984 NumberFormat::UnpackNumberFormat(isolate, number_format_holder); |
13988 if (!number_format) return isolate->ThrowIllegalOperation(); | 13985 if (!number_format) return isolate->ThrowIllegalOperation(); |
13989 | 13986 |
13990 icu::UnicodeString result; | 13987 icu::UnicodeString result; |
13991 number_format->format(value->Number(), result); | 13988 number_format->format(value->Number(), result); |
13992 | 13989 |
13993 Handle<String> result_str; | 13990 Handle<String> result_str; |
13994 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 13991 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
13995 isolate, result_str, | 13992 isolate, result_str, |
13996 isolate->factory()->NewStringFromTwoByte( | 13993 isolate->factory()->NewStringFromTwoByte( |
13997 Vector<const uint16_t>( | 13994 Vector<const uint16_t>( |
13998 reinterpret_cast<const uint16_t*>(result.getBuffer()), | 13995 reinterpret_cast<const uint16_t*>(result.getBuffer()), |
13999 result.length()))); | 13996 result.length()))); |
14000 return *result_str; | 13997 return *result_str; |
14001 } | 13998 } |
14002 | 13999 |
14003 | 14000 |
14004 RUNTIME_FUNCTION(MaybeObject*, Runtime_InternalNumberParse) { | 14001 RUNTIME_FUNCTION(Object*, Runtime_InternalNumberParse) { |
14005 HandleScope scope(isolate); | 14002 HandleScope scope(isolate); |
14006 | 14003 |
14007 ASSERT(args.length() == 2); | 14004 ASSERT(args.length() == 2); |
14008 | 14005 |
14009 CONVERT_ARG_HANDLE_CHECKED(JSObject, number_format_holder, 0); | 14006 CONVERT_ARG_HANDLE_CHECKED(JSObject, number_format_holder, 0); |
14010 CONVERT_ARG_HANDLE_CHECKED(String, number_string, 1); | 14007 CONVERT_ARG_HANDLE_CHECKED(String, number_string, 1); |
14011 | 14008 |
14012 v8::String::Utf8Value utf8_number(v8::Utils::ToLocal(number_string)); | 14009 v8::String::Utf8Value utf8_number(v8::Utils::ToLocal(number_string)); |
14013 icu::UnicodeString u_number(icu::UnicodeString::fromUTF8(*utf8_number)); | 14010 icu::UnicodeString u_number(icu::UnicodeString::fromUTF8(*utf8_number)); |
14014 icu::DecimalFormat* number_format = | 14011 icu::DecimalFormat* number_format = |
(...skipping 18 matching lines...) Expand all Loading... | |
14033 return *isolate->factory()->NewNumberFromInt(result.getLong()); | 14030 return *isolate->factory()->NewNumberFromInt(result.getLong()); |
14034 case icu::Formattable::kInt64: | 14031 case icu::Formattable::kInt64: |
14035 return *isolate->factory()->NewNumber( | 14032 return *isolate->factory()->NewNumber( |
14036 static_cast<double>(result.getInt64())); | 14033 static_cast<double>(result.getInt64())); |
14037 default: | 14034 default: |
14038 return isolate->heap()->undefined_value(); | 14035 return isolate->heap()->undefined_value(); |
14039 } | 14036 } |
14040 } | 14037 } |
14041 | 14038 |
14042 | 14039 |
14043 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateCollator) { | 14040 RUNTIME_FUNCTION(Object*, Runtime_CreateCollator) { |
14044 HandleScope scope(isolate); | 14041 HandleScope scope(isolate); |
14045 | 14042 |
14046 ASSERT(args.length() == 3); | 14043 ASSERT(args.length() == 3); |
14047 | 14044 |
14048 CONVERT_ARG_HANDLE_CHECKED(String, locale, 0); | 14045 CONVERT_ARG_HANDLE_CHECKED(String, locale, 0); |
14049 CONVERT_ARG_HANDLE_CHECKED(JSObject, options, 1); | 14046 CONVERT_ARG_HANDLE_CHECKED(JSObject, options, 1); |
14050 CONVERT_ARG_HANDLE_CHECKED(JSObject, resolved, 2); | 14047 CONVERT_ARG_HANDLE_CHECKED(JSObject, resolved, 2); |
14051 | 14048 |
14052 Handle<ObjectTemplateInfo> collator_template = I18N::GetTemplate(isolate); | 14049 Handle<ObjectTemplateInfo> collator_template = I18N::GetTemplate(isolate); |
14053 | 14050 |
(...skipping 18 matching lines...) Expand all Loading... | |
14072 NONE)); | 14069 NONE)); |
14073 | 14070 |
14074 Handle<Object> wrapper = isolate->global_handles()->Create(*local_object); | 14071 Handle<Object> wrapper = isolate->global_handles()->Create(*local_object); |
14075 GlobalHandles::MakeWeak(wrapper.location(), | 14072 GlobalHandles::MakeWeak(wrapper.location(), |
14076 reinterpret_cast<void*>(wrapper.location()), | 14073 reinterpret_cast<void*>(wrapper.location()), |
14077 Collator::DeleteCollator); | 14074 Collator::DeleteCollator); |
14078 return *local_object; | 14075 return *local_object; |
14079 } | 14076 } |
14080 | 14077 |
14081 | 14078 |
14082 RUNTIME_FUNCTION(MaybeObject*, Runtime_InternalCompare) { | 14079 RUNTIME_FUNCTION(Object*, Runtime_InternalCompare) { |
14083 HandleScope scope(isolate); | 14080 HandleScope scope(isolate); |
14084 | 14081 |
14085 ASSERT(args.length() == 3); | 14082 ASSERT(args.length() == 3); |
14086 | 14083 |
14087 CONVERT_ARG_HANDLE_CHECKED(JSObject, collator_holder, 0); | 14084 CONVERT_ARG_HANDLE_CHECKED(JSObject, collator_holder, 0); |
14088 CONVERT_ARG_HANDLE_CHECKED(String, string1, 1); | 14085 CONVERT_ARG_HANDLE_CHECKED(String, string1, 1); |
14089 CONVERT_ARG_HANDLE_CHECKED(String, string2, 2); | 14086 CONVERT_ARG_HANDLE_CHECKED(String, string2, 2); |
14090 | 14087 |
14091 icu::Collator* collator = Collator::UnpackCollator(isolate, collator_holder); | 14088 icu::Collator* collator = Collator::UnpackCollator(isolate, collator_holder); |
14092 if (!collator) return isolate->ThrowIllegalOperation(); | 14089 if (!collator) return isolate->ThrowIllegalOperation(); |
14093 | 14090 |
14094 v8::String::Value string_value1(v8::Utils::ToLocal(string1)); | 14091 v8::String::Value string_value1(v8::Utils::ToLocal(string1)); |
14095 v8::String::Value string_value2(v8::Utils::ToLocal(string2)); | 14092 v8::String::Value string_value2(v8::Utils::ToLocal(string2)); |
14096 const UChar* u_string1 = reinterpret_cast<const UChar*>(*string_value1); | 14093 const UChar* u_string1 = reinterpret_cast<const UChar*>(*string_value1); |
14097 const UChar* u_string2 = reinterpret_cast<const UChar*>(*string_value2); | 14094 const UChar* u_string2 = reinterpret_cast<const UChar*>(*string_value2); |
14098 UErrorCode status = U_ZERO_ERROR; | 14095 UErrorCode status = U_ZERO_ERROR; |
14099 UCollationResult result = collator->compare(u_string1, | 14096 UCollationResult result = collator->compare(u_string1, |
14100 string_value1.length(), | 14097 string_value1.length(), |
14101 u_string2, | 14098 u_string2, |
14102 string_value2.length(), | 14099 string_value2.length(), |
14103 status); | 14100 status); |
14104 if (U_FAILURE(status)) return isolate->ThrowIllegalOperation(); | 14101 if (U_FAILURE(status)) return isolate->ThrowIllegalOperation(); |
14105 | 14102 |
14106 return *isolate->factory()->NewNumberFromInt(result); | 14103 return *isolate->factory()->NewNumberFromInt(result); |
14107 } | 14104 } |
14108 | 14105 |
14109 | 14106 |
14110 RUNTIME_FUNCTION(MaybeObject*, Runtime_StringNormalize) { | 14107 RUNTIME_FUNCTION(Object*, Runtime_StringNormalize) { |
14111 HandleScope scope(isolate); | 14108 HandleScope scope(isolate); |
14112 static const UNormalizationMode normalizationForms[] = | 14109 static const UNormalizationMode normalizationForms[] = |
14113 { UNORM_NFC, UNORM_NFD, UNORM_NFKC, UNORM_NFKD }; | 14110 { UNORM_NFC, UNORM_NFD, UNORM_NFKC, UNORM_NFKD }; |
14114 | 14111 |
14115 ASSERT(args.length() == 2); | 14112 ASSERT(args.length() == 2); |
14116 | 14113 |
14117 CONVERT_ARG_HANDLE_CHECKED(String, stringValue, 0); | 14114 CONVERT_ARG_HANDLE_CHECKED(String, stringValue, 0); |
14118 CONVERT_NUMBER_CHECKED(int, form_id, Int32, args[1]); | 14115 CONVERT_NUMBER_CHECKED(int, form_id, Int32, args[1]); |
14119 | 14116 |
14120 v8::String::Value string_value(v8::Utils::ToLocal(stringValue)); | 14117 v8::String::Value string_value(v8::Utils::ToLocal(stringValue)); |
(...skipping 12 matching lines...) Expand all Loading... | |
14133 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 14130 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
14134 isolate, result_str, | 14131 isolate, result_str, |
14135 isolate->factory()->NewStringFromTwoByte( | 14132 isolate->factory()->NewStringFromTwoByte( |
14136 Vector<const uint16_t>( | 14133 Vector<const uint16_t>( |
14137 reinterpret_cast<const uint16_t*>(result.getBuffer()), | 14134 reinterpret_cast<const uint16_t*>(result.getBuffer()), |
14138 result.length()))); | 14135 result.length()))); |
14139 return *result_str; | 14136 return *result_str; |
14140 } | 14137 } |
14141 | 14138 |
14142 | 14139 |
14143 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateBreakIterator) { | 14140 RUNTIME_FUNCTION(Object*, Runtime_CreateBreakIterator) { |
14144 HandleScope scope(isolate); | 14141 HandleScope scope(isolate); |
14145 | 14142 |
14146 ASSERT(args.length() == 3); | 14143 ASSERT(args.length() == 3); |
14147 | 14144 |
14148 CONVERT_ARG_HANDLE_CHECKED(String, locale, 0); | 14145 CONVERT_ARG_HANDLE_CHECKED(String, locale, 0); |
14149 CONVERT_ARG_HANDLE_CHECKED(JSObject, options, 1); | 14146 CONVERT_ARG_HANDLE_CHECKED(JSObject, options, 1); |
14150 CONVERT_ARG_HANDLE_CHECKED(JSObject, resolved, 2); | 14147 CONVERT_ARG_HANDLE_CHECKED(JSObject, resolved, 2); |
14151 | 14148 |
14152 Handle<ObjectTemplateInfo> break_iterator_template = | 14149 Handle<ObjectTemplateInfo> break_iterator_template = |
14153 I18N::GetTemplate2(isolate); | 14150 I18N::GetTemplate2(isolate); |
(...skipping 24 matching lines...) Expand all Loading... | |
14178 // Make object handle weak so we can delete the break iterator once GC kicks | 14175 // Make object handle weak so we can delete the break iterator once GC kicks |
14179 // in. | 14176 // in. |
14180 Handle<Object> wrapper = isolate->global_handles()->Create(*local_object); | 14177 Handle<Object> wrapper = isolate->global_handles()->Create(*local_object); |
14181 GlobalHandles::MakeWeak(wrapper.location(), | 14178 GlobalHandles::MakeWeak(wrapper.location(), |
14182 reinterpret_cast<void*>(wrapper.location()), | 14179 reinterpret_cast<void*>(wrapper.location()), |
14183 BreakIterator::DeleteBreakIterator); | 14180 BreakIterator::DeleteBreakIterator); |
14184 return *local_object; | 14181 return *local_object; |
14185 } | 14182 } |
14186 | 14183 |
14187 | 14184 |
14188 RUNTIME_FUNCTION(MaybeObject*, Runtime_BreakIteratorAdoptText) { | 14185 RUNTIME_FUNCTION(Object*, Runtime_BreakIteratorAdoptText) { |
14189 HandleScope scope(isolate); | 14186 HandleScope scope(isolate); |
14190 | 14187 |
14191 ASSERT(args.length() == 2); | 14188 ASSERT(args.length() == 2); |
14192 | 14189 |
14193 CONVERT_ARG_HANDLE_CHECKED(JSObject, break_iterator_holder, 0); | 14190 CONVERT_ARG_HANDLE_CHECKED(JSObject, break_iterator_holder, 0); |
14194 CONVERT_ARG_HANDLE_CHECKED(String, text, 1); | 14191 CONVERT_ARG_HANDLE_CHECKED(String, text, 1); |
14195 | 14192 |
14196 icu::BreakIterator* break_iterator = | 14193 icu::BreakIterator* break_iterator = |
14197 BreakIterator::UnpackBreakIterator(isolate, break_iterator_holder); | 14194 BreakIterator::UnpackBreakIterator(isolate, break_iterator_holder); |
14198 if (!break_iterator) return isolate->ThrowIllegalOperation(); | 14195 if (!break_iterator) return isolate->ThrowIllegalOperation(); |
14199 | 14196 |
14200 icu::UnicodeString* u_text = reinterpret_cast<icu::UnicodeString*>( | 14197 icu::UnicodeString* u_text = reinterpret_cast<icu::UnicodeString*>( |
14201 break_iterator_holder->GetInternalField(1)); | 14198 break_iterator_holder->GetInternalField(1)); |
14202 delete u_text; | 14199 delete u_text; |
14203 | 14200 |
14204 v8::String::Value text_value(v8::Utils::ToLocal(text)); | 14201 v8::String::Value text_value(v8::Utils::ToLocal(text)); |
14205 u_text = new icu::UnicodeString( | 14202 u_text = new icu::UnicodeString( |
14206 reinterpret_cast<const UChar*>(*text_value), text_value.length()); | 14203 reinterpret_cast<const UChar*>(*text_value), text_value.length()); |
14207 break_iterator_holder->SetInternalField(1, reinterpret_cast<Smi*>(u_text)); | 14204 break_iterator_holder->SetInternalField(1, reinterpret_cast<Smi*>(u_text)); |
14208 | 14205 |
14209 break_iterator->setText(*u_text); | 14206 break_iterator->setText(*u_text); |
14210 | 14207 |
14211 return isolate->heap()->undefined_value(); | 14208 return isolate->heap()->undefined_value(); |
14212 } | 14209 } |
14213 | 14210 |
14214 | 14211 |
14215 RUNTIME_FUNCTION(MaybeObject*, Runtime_BreakIteratorFirst) { | 14212 RUNTIME_FUNCTION(Object*, Runtime_BreakIteratorFirst) { |
14216 HandleScope scope(isolate); | 14213 HandleScope scope(isolate); |
14217 | 14214 |
14218 ASSERT(args.length() == 1); | 14215 ASSERT(args.length() == 1); |
14219 | 14216 |
14220 CONVERT_ARG_HANDLE_CHECKED(JSObject, break_iterator_holder, 0); | 14217 CONVERT_ARG_HANDLE_CHECKED(JSObject, break_iterator_holder, 0); |
14221 | 14218 |
14222 icu::BreakIterator* break_iterator = | 14219 icu::BreakIterator* break_iterator = |
14223 BreakIterator::UnpackBreakIterator(isolate, break_iterator_holder); | 14220 BreakIterator::UnpackBreakIterator(isolate, break_iterator_holder); |
14224 if (!break_iterator) return isolate->ThrowIllegalOperation(); | 14221 if (!break_iterator) return isolate->ThrowIllegalOperation(); |
14225 | 14222 |
14226 return *isolate->factory()->NewNumberFromInt(break_iterator->first()); | 14223 return *isolate->factory()->NewNumberFromInt(break_iterator->first()); |
14227 } | 14224 } |
14228 | 14225 |
14229 | 14226 |
14230 RUNTIME_FUNCTION(MaybeObject*, Runtime_BreakIteratorNext) { | 14227 RUNTIME_FUNCTION(Object*, Runtime_BreakIteratorNext) { |
14231 HandleScope scope(isolate); | 14228 HandleScope scope(isolate); |
14232 | 14229 |
14233 ASSERT(args.length() == 1); | 14230 ASSERT(args.length() == 1); |
14234 | 14231 |
14235 CONVERT_ARG_HANDLE_CHECKED(JSObject, break_iterator_holder, 0); | 14232 CONVERT_ARG_HANDLE_CHECKED(JSObject, break_iterator_holder, 0); |
14236 | 14233 |
14237 icu::BreakIterator* break_iterator = | 14234 icu::BreakIterator* break_iterator = |
14238 BreakIterator::UnpackBreakIterator(isolate, break_iterator_holder); | 14235 BreakIterator::UnpackBreakIterator(isolate, break_iterator_holder); |
14239 if (!break_iterator) return isolate->ThrowIllegalOperation(); | 14236 if (!break_iterator) return isolate->ThrowIllegalOperation(); |
14240 | 14237 |
14241 return *isolate->factory()->NewNumberFromInt(break_iterator->next()); | 14238 return *isolate->factory()->NewNumberFromInt(break_iterator->next()); |
14242 } | 14239 } |
14243 | 14240 |
14244 | 14241 |
14245 RUNTIME_FUNCTION(MaybeObject*, Runtime_BreakIteratorCurrent) { | 14242 RUNTIME_FUNCTION(Object*, Runtime_BreakIteratorCurrent) { |
14246 HandleScope scope(isolate); | 14243 HandleScope scope(isolate); |
14247 | 14244 |
14248 ASSERT(args.length() == 1); | 14245 ASSERT(args.length() == 1); |
14249 | 14246 |
14250 CONVERT_ARG_HANDLE_CHECKED(JSObject, break_iterator_holder, 0); | 14247 CONVERT_ARG_HANDLE_CHECKED(JSObject, break_iterator_holder, 0); |
14251 | 14248 |
14252 icu::BreakIterator* break_iterator = | 14249 icu::BreakIterator* break_iterator = |
14253 BreakIterator::UnpackBreakIterator(isolate, break_iterator_holder); | 14250 BreakIterator::UnpackBreakIterator(isolate, break_iterator_holder); |
14254 if (!break_iterator) return isolate->ThrowIllegalOperation(); | 14251 if (!break_iterator) return isolate->ThrowIllegalOperation(); |
14255 | 14252 |
14256 return *isolate->factory()->NewNumberFromInt(break_iterator->current()); | 14253 return *isolate->factory()->NewNumberFromInt(break_iterator->current()); |
14257 } | 14254 } |
14258 | 14255 |
14259 | 14256 |
14260 RUNTIME_FUNCTION(MaybeObject*, Runtime_BreakIteratorBreakType) { | 14257 RUNTIME_FUNCTION(Object*, Runtime_BreakIteratorBreakType) { |
14261 HandleScope scope(isolate); | 14258 HandleScope scope(isolate); |
14262 | 14259 |
14263 ASSERT(args.length() == 1); | 14260 ASSERT(args.length() == 1); |
14264 | 14261 |
14265 CONVERT_ARG_HANDLE_CHECKED(JSObject, break_iterator_holder, 0); | 14262 CONVERT_ARG_HANDLE_CHECKED(JSObject, break_iterator_holder, 0); |
14266 | 14263 |
14267 icu::BreakIterator* break_iterator = | 14264 icu::BreakIterator* break_iterator = |
14268 BreakIterator::UnpackBreakIterator(isolate, break_iterator_holder); | 14265 BreakIterator::UnpackBreakIterator(isolate, break_iterator_holder); |
14269 if (!break_iterator) return isolate->ThrowIllegalOperation(); | 14266 if (!break_iterator) return isolate->ThrowIllegalOperation(); |
14270 | 14267 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
14322 if (script.is_null()) return factory->undefined_value(); | 14319 if (script.is_null()) return factory->undefined_value(); |
14323 | 14320 |
14324 // Return the script found. | 14321 // Return the script found. |
14325 return Script::GetWrapper(script); | 14322 return Script::GetWrapper(script); |
14326 } | 14323 } |
14327 | 14324 |
14328 | 14325 |
14329 // Get the script object from script data. NOTE: Regarding performance | 14326 // Get the script object from script data. NOTE: Regarding performance |
14330 // see the NOTE for GetScriptFromScriptData. | 14327 // see the NOTE for GetScriptFromScriptData. |
14331 // args[0]: script data for the script to find the source for | 14328 // args[0]: script data for the script to find the source for |
14332 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetScript) { | 14329 RUNTIME_FUNCTION(Object*, Runtime_GetScript) { |
14333 HandleScope scope(isolate); | 14330 HandleScope scope(isolate); |
14334 | 14331 |
14335 ASSERT(args.length() == 1); | 14332 ASSERT(args.length() == 1); |
14336 | 14333 |
14337 CONVERT_ARG_CHECKED(String, script_name, 0); | 14334 CONVERT_ARG_CHECKED(String, script_name, 0); |
14338 | 14335 |
14339 // Find the requested script. | 14336 // Find the requested script. |
14340 Handle<Object> result = | 14337 Handle<Object> result = |
14341 Runtime_GetScriptFromScriptName(Handle<String>(script_name)); | 14338 Runtime_GetScriptFromScriptName(Handle<String>(script_name)); |
14342 return *result; | 14339 return *result; |
14343 } | 14340 } |
14344 | 14341 |
14345 | 14342 |
14346 // Collect the raw data for a stack trace. Returns an array of 4 | 14343 // Collect the raw data for a stack trace. Returns an array of 4 |
14347 // element segments each containing a receiver, function, code and | 14344 // element segments each containing a receiver, function, code and |
14348 // native code offset. | 14345 // native code offset. |
14349 RUNTIME_FUNCTION(MaybeObject*, Runtime_CollectStackTrace) { | 14346 RUNTIME_FUNCTION(Object*, Runtime_CollectStackTrace) { |
14350 HandleScope scope(isolate); | 14347 HandleScope scope(isolate); |
14351 ASSERT(args.length() == 3); | 14348 ASSERT(args.length() == 3); |
14352 CONVERT_ARG_HANDLE_CHECKED(JSObject, error_object, 0); | 14349 CONVERT_ARG_HANDLE_CHECKED(JSObject, error_object, 0); |
14353 CONVERT_ARG_HANDLE_CHECKED(Object, caller, 1); | 14350 CONVERT_ARG_HANDLE_CHECKED(Object, caller, 1); |
14354 CONVERT_NUMBER_CHECKED(int32_t, limit, Int32, args[2]); | 14351 CONVERT_NUMBER_CHECKED(int32_t, limit, Int32, args[2]); |
14355 | 14352 |
14356 // Optionally capture a more detailed stack trace for the message. | 14353 // Optionally capture a more detailed stack trace for the message. |
14357 isolate->CaptureAndSetDetailedStackTrace(error_object); | 14354 isolate->CaptureAndSetDetailedStackTrace(error_object); |
14358 // Capture a simple stack trace for the stack property. | 14355 // Capture a simple stack trace for the stack property. |
14359 return *isolate->CaptureSimpleStackTrace(error_object, caller, limit); | 14356 return *isolate->CaptureSimpleStackTrace(error_object, caller, limit); |
14360 } | 14357 } |
14361 | 14358 |
14362 | 14359 |
14363 // Retrieve the stack trace. This is the raw stack trace that yet has to | 14360 // Retrieve the stack trace. This is the raw stack trace that yet has to |
14364 // be formatted. Since we only need this once, clear it afterwards. | 14361 // be formatted. Since we only need this once, clear it afterwards. |
14365 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetAndClearOverflowedStackTrace) { | 14362 RUNTIME_FUNCTION(Object*, Runtime_GetAndClearOverflowedStackTrace) { |
14366 HandleScope scope(isolate); | 14363 HandleScope scope(isolate); |
14367 ASSERT(args.length() == 1); | 14364 ASSERT(args.length() == 1); |
14368 CONVERT_ARG_HANDLE_CHECKED(JSObject, error_object, 0); | 14365 CONVERT_ARG_HANDLE_CHECKED(JSObject, error_object, 0); |
14369 Handle<String> key = isolate->factory()->hidden_stack_trace_string(); | 14366 Handle<String> key = isolate->factory()->hidden_stack_trace_string(); |
14370 Handle<Object> result(error_object->GetHiddenProperty(*key), isolate); | 14367 Handle<Object> result(error_object->GetHiddenProperty(*key), isolate); |
14371 if (result->IsTheHole()) return isolate->heap()->undefined_value(); | 14368 if (result->IsTheHole()) return isolate->heap()->undefined_value(); |
14372 RUNTIME_ASSERT(result->IsJSArray() || result->IsUndefined()); | 14369 RUNTIME_ASSERT(result->IsJSArray() || result->IsUndefined()); |
14373 JSObject::DeleteHiddenProperty(error_object, key); | 14370 JSObject::DeleteHiddenProperty(error_object, key); |
14374 return *result; | 14371 return *result; |
14375 } | 14372 } |
14376 | 14373 |
14377 | 14374 |
14378 // Returns V8 version as a string. | 14375 // Returns V8 version as a string. |
14379 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetV8Version) { | 14376 RUNTIME_FUNCTION(Object*, Runtime_GetV8Version) { |
14380 HandleScope scope(isolate); | 14377 HandleScope scope(isolate); |
14381 ASSERT(args.length() == 0); | 14378 ASSERT(args.length() == 0); |
14382 | 14379 |
14383 const char* version_string = v8::V8::GetVersion(); | 14380 const char* version_string = v8::V8::GetVersion(); |
14384 | 14381 |
14385 return *isolate->factory()->NewStringFromAsciiChecked(version_string); | 14382 return *isolate->factory()->NewStringFromAsciiChecked(version_string); |
14386 } | 14383 } |
14387 | 14384 |
14388 | 14385 |
14389 RUNTIME_FUNCTION(MaybeObject*, Runtime_Abort) { | 14386 RUNTIME_FUNCTION(Object*, Runtime_Abort) { |
14390 SealHandleScope shs(isolate); | 14387 SealHandleScope shs(isolate); |
14391 ASSERT(args.length() == 1); | 14388 ASSERT(args.length() == 1); |
14392 CONVERT_SMI_ARG_CHECKED(message_id, 0); | 14389 CONVERT_SMI_ARG_CHECKED(message_id, 0); |
14393 const char* message = GetBailoutReason( | 14390 const char* message = GetBailoutReason( |
14394 static_cast<BailoutReason>(message_id)); | 14391 static_cast<BailoutReason>(message_id)); |
14395 OS::PrintError("abort: %s\n", message); | 14392 OS::PrintError("abort: %s\n", message); |
14396 isolate->PrintStack(stderr); | 14393 isolate->PrintStack(stderr); |
14397 OS::Abort(); | 14394 OS::Abort(); |
14398 UNREACHABLE(); | 14395 UNREACHABLE(); |
14399 return NULL; | 14396 return NULL; |
14400 } | 14397 } |
14401 | 14398 |
14402 | 14399 |
14403 RUNTIME_FUNCTION(MaybeObject*, Runtime_AbortJS) { | 14400 RUNTIME_FUNCTION(Object*, Runtime_AbortJS) { |
14404 HandleScope scope(isolate); | 14401 HandleScope scope(isolate); |
14405 ASSERT(args.length() == 1); | 14402 ASSERT(args.length() == 1); |
14406 CONVERT_ARG_HANDLE_CHECKED(String, message, 0); | 14403 CONVERT_ARG_HANDLE_CHECKED(String, message, 0); |
14407 OS::PrintError("abort: %s\n", message->ToCString().get()); | 14404 OS::PrintError("abort: %s\n", message->ToCString().get()); |
14408 isolate->PrintStack(stderr); | 14405 isolate->PrintStack(stderr); |
14409 OS::Abort(); | 14406 OS::Abort(); |
14410 UNREACHABLE(); | 14407 UNREACHABLE(); |
14411 return NULL; | 14408 return NULL; |
14412 } | 14409 } |
14413 | 14410 |
14414 | 14411 |
14415 RUNTIME_FUNCTION(MaybeObject*, Runtime_FlattenString) { | 14412 RUNTIME_FUNCTION(Object*, Runtime_FlattenString) { |
14416 HandleScope scope(isolate); | 14413 HandleScope scope(isolate); |
14417 ASSERT(args.length() == 1); | 14414 ASSERT(args.length() == 1); |
14418 CONVERT_ARG_HANDLE_CHECKED(String, str, 0); | 14415 CONVERT_ARG_HANDLE_CHECKED(String, str, 0); |
14419 return *String::Flatten(str); | 14416 return *String::Flatten(str); |
14420 } | 14417 } |
14421 | 14418 |
14422 | 14419 |
14423 RUNTIME_FUNCTION(MaybeObject*, Runtime_NotifyContextDisposed) { | 14420 RUNTIME_FUNCTION(Object*, Runtime_NotifyContextDisposed) { |
14424 HandleScope scope(isolate); | 14421 HandleScope scope(isolate); |
14425 ASSERT(args.length() == 0); | 14422 ASSERT(args.length() == 0); |
14426 isolate->heap()->NotifyContextDisposed(); | 14423 isolate->heap()->NotifyContextDisposed(); |
14427 return isolate->heap()->undefined_value(); | 14424 return isolate->heap()->undefined_value(); |
14428 } | 14425 } |
14429 | 14426 |
14430 | 14427 |
14431 RUNTIME_FUNCTION(MaybeObject*, Runtime_LoadMutableDouble) { | 14428 RUNTIME_FUNCTION(Object*, Runtime_LoadMutableDouble) { |
14432 HandleScope scope(isolate); | 14429 HandleScope scope(isolate); |
14433 ASSERT(args.length() == 2); | 14430 ASSERT(args.length() == 2); |
14434 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); | 14431 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); |
14435 CONVERT_ARG_HANDLE_CHECKED(Smi, index, 1); | 14432 CONVERT_ARG_HANDLE_CHECKED(Smi, index, 1); |
14436 int idx = index->value() >> 1; | 14433 int idx = index->value() >> 1; |
14437 if (idx < 0) { | 14434 if (idx < 0) { |
14438 idx = -idx + object->map()->inobject_properties() - 1; | 14435 idx = -idx + object->map()->inobject_properties() - 1; |
14439 } | 14436 } |
14440 return *JSObject::FastPropertyAt(object, Representation::Double(), idx); | 14437 return *JSObject::FastPropertyAt(object, Representation::Double(), idx); |
14441 } | 14438 } |
14442 | 14439 |
14443 | 14440 |
14444 RUNTIME_FUNCTION(MaybeObject*, Runtime_TryMigrateInstance) { | 14441 RUNTIME_FUNCTION(Object*, Runtime_TryMigrateInstance) { |
14445 HandleScope scope(isolate); | 14442 HandleScope scope(isolate); |
14446 ASSERT(args.length() == 1); | 14443 ASSERT(args.length() == 1); |
14447 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); | 14444 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); |
14448 if (!object->IsJSObject()) return Smi::FromInt(0); | 14445 if (!object->IsJSObject()) return Smi::FromInt(0); |
14449 Handle<JSObject> js_object = Handle<JSObject>::cast(object); | 14446 Handle<JSObject> js_object = Handle<JSObject>::cast(object); |
14450 if (!js_object->map()->is_deprecated()) return Smi::FromInt(0); | 14447 if (!js_object->map()->is_deprecated()) return Smi::FromInt(0); |
14451 // This call must not cause lazy deopts, because it's called from deferred | 14448 // This call must not cause lazy deopts, because it's called from deferred |
14452 // code where we can't handle lazy deopts for lack of a suitable bailout | 14449 // code where we can't handle lazy deopts for lack of a suitable bailout |
14453 // ID. So we just try migration and signal failure if necessary, | 14450 // ID. So we just try migration and signal failure if necessary, |
14454 // which will also trigger a deopt. | 14451 // which will also trigger a deopt. |
14455 Handle<Object> result = JSObject::TryMigrateInstance(js_object); | 14452 Handle<Object> result = JSObject::TryMigrateInstance(js_object); |
14456 if (result.is_null()) return Smi::FromInt(0); | 14453 if (result.is_null()) return Smi::FromInt(0); |
14457 return *object; | 14454 return *object; |
14458 } | 14455 } |
14459 | 14456 |
14460 | 14457 |
14461 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_GetFromCache) { | 14458 RUNTIME_FUNCTION(Object*, RuntimeHidden_GetFromCache) { |
14462 SealHandleScope shs(isolate); | 14459 SealHandleScope shs(isolate); |
14463 // This is only called from codegen, so checks might be more lax. | 14460 // This is only called from codegen, so checks might be more lax. |
14464 CONVERT_ARG_CHECKED(JSFunctionResultCache, cache, 0); | 14461 CONVERT_ARG_CHECKED(JSFunctionResultCache, cache, 0); |
14465 CONVERT_ARG_CHECKED(Object, key, 1); | 14462 CONVERT_ARG_CHECKED(Object, key, 1); |
14466 | 14463 |
14467 { | 14464 { |
14468 DisallowHeapAllocation no_alloc; | 14465 DisallowHeapAllocation no_alloc; |
14469 | 14466 |
14470 int finger_index = cache->finger_index(); | 14467 int finger_index = cache->finger_index(); |
14471 Object* o = cache->get(finger_index); | 14468 Object* o = cache->get(finger_index); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
14549 #ifdef VERIFY_HEAP | 14546 #ifdef VERIFY_HEAP |
14550 if (FLAG_verify_heap) { | 14547 if (FLAG_verify_heap) { |
14551 cache_handle->JSFunctionResultCacheVerify(); | 14548 cache_handle->JSFunctionResultCacheVerify(); |
14552 } | 14549 } |
14553 #endif | 14550 #endif |
14554 | 14551 |
14555 return *value; | 14552 return *value; |
14556 } | 14553 } |
14557 | 14554 |
14558 | 14555 |
14559 RUNTIME_FUNCTION(MaybeObject*, Runtime_MessageGetStartPosition) { | 14556 RUNTIME_FUNCTION(Object*, Runtime_MessageGetStartPosition) { |
14560 SealHandleScope shs(isolate); | 14557 SealHandleScope shs(isolate); |
14561 ASSERT(args.length() == 1); | 14558 ASSERT(args.length() == 1); |
14562 CONVERT_ARG_CHECKED(JSMessageObject, message, 0); | 14559 CONVERT_ARG_CHECKED(JSMessageObject, message, 0); |
14563 return Smi::FromInt(message->start_position()); | 14560 return Smi::FromInt(message->start_position()); |
14564 } | 14561 } |
14565 | 14562 |
14566 | 14563 |
14567 RUNTIME_FUNCTION(MaybeObject*, Runtime_MessageGetScript) { | 14564 RUNTIME_FUNCTION(Object*, Runtime_MessageGetScript) { |
14568 SealHandleScope shs(isolate); | 14565 SealHandleScope shs(isolate); |
14569 ASSERT(args.length() == 1); | 14566 ASSERT(args.length() == 1); |
14570 CONVERT_ARG_CHECKED(JSMessageObject, message, 0); | 14567 CONVERT_ARG_CHECKED(JSMessageObject, message, 0); |
14571 return message->script(); | 14568 return message->script(); |
14572 } | 14569 } |
14573 | 14570 |
14574 | 14571 |
14575 #ifdef DEBUG | 14572 #ifdef DEBUG |
14576 // ListNatives is ONLY used by the fuzz-natives.js in debug mode | 14573 // ListNatives is ONLY used by the fuzz-natives.js in debug mode |
14577 // Exclude the code in release mode. | 14574 // Exclude the code in release mode. |
14578 RUNTIME_FUNCTION(MaybeObject*, Runtime_ListNatives) { | 14575 RUNTIME_FUNCTION(Object*, Runtime_ListNatives) { |
14579 HandleScope scope(isolate); | 14576 HandleScope scope(isolate); |
14580 ASSERT(args.length() == 0); | 14577 ASSERT(args.length() == 0); |
14581 #define COUNT_ENTRY(Name, argc, ressize) + 1 | 14578 #define COUNT_ENTRY(Name, argc, ressize) + 1 |
14582 int entry_count = 0 | 14579 int entry_count = 0 |
14583 RUNTIME_FUNCTION_LIST(COUNT_ENTRY) | 14580 RUNTIME_FUNCTION_LIST(COUNT_ENTRY) |
14584 RUNTIME_HIDDEN_FUNCTION_LIST(COUNT_ENTRY) | 14581 RUNTIME_HIDDEN_FUNCTION_LIST(COUNT_ENTRY) |
14585 INLINE_FUNCTION_LIST(COUNT_ENTRY); | 14582 INLINE_FUNCTION_LIST(COUNT_ENTRY); |
14586 #undef COUNT_ENTRY | 14583 #undef COUNT_ENTRY |
14587 Factory* factory = isolate->factory(); | 14584 Factory* factory = isolate->factory(); |
14588 Handle<FixedArray> elements = factory->NewFixedArray(entry_count); | 14585 Handle<FixedArray> elements = factory->NewFixedArray(entry_count); |
(...skipping 22 matching lines...) Expand all Loading... | |
14611 inline_runtime_functions = true; | 14608 inline_runtime_functions = true; |
14612 INLINE_FUNCTION_LIST(ADD_ENTRY) | 14609 INLINE_FUNCTION_LIST(ADD_ENTRY) |
14613 #undef ADD_ENTRY | 14610 #undef ADD_ENTRY |
14614 ASSERT_EQ(index, entry_count); | 14611 ASSERT_EQ(index, entry_count); |
14615 Handle<JSArray> result = factory->NewJSArrayWithElements(elements); | 14612 Handle<JSArray> result = factory->NewJSArrayWithElements(elements); |
14616 return *result; | 14613 return *result; |
14617 } | 14614 } |
14618 #endif | 14615 #endif |
14619 | 14616 |
14620 | 14617 |
14621 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_Log) { | 14618 RUNTIME_FUNCTION(Object*, RuntimeHidden_Log) { |
14622 HandleScope handle_scope(isolate); | 14619 HandleScope handle_scope(isolate); |
14623 ASSERT(args.length() == 2); | 14620 ASSERT(args.length() == 2); |
14624 CONVERT_ARG_HANDLE_CHECKED(String, format, 0); | 14621 CONVERT_ARG_HANDLE_CHECKED(String, format, 0); |
14625 CONVERT_ARG_HANDLE_CHECKED(JSArray, elms, 1); | 14622 CONVERT_ARG_HANDLE_CHECKED(JSArray, elms, 1); |
14626 | 14623 |
14627 SmartArrayPointer<char> format_chars = format->ToCString(); | 14624 SmartArrayPointer<char> format_chars = format->ToCString(); |
14628 isolate->logger()->LogRuntime( | 14625 isolate->logger()->LogRuntime( |
14629 Vector<const char>(format_chars.get(), format->length()), elms); | 14626 Vector<const char>(format_chars.get(), format->length()), elms); |
14630 return isolate->heap()->undefined_value(); | 14627 return isolate->heap()->undefined_value(); |
14631 } | 14628 } |
14632 | 14629 |
14633 | 14630 |
14634 RUNTIME_FUNCTION(MaybeObject*, Runtime_IS_VAR) { | 14631 RUNTIME_FUNCTION(Object*, Runtime_IS_VAR) { |
14635 UNREACHABLE(); // implemented as macro in the parser | 14632 UNREACHABLE(); // implemented as macro in the parser |
14636 return NULL; | 14633 return NULL; |
14637 } | 14634 } |
14638 | 14635 |
14639 | 14636 |
14640 #define ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(Name) \ | 14637 #define ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(Name) \ |
14641 RUNTIME_FUNCTION(MaybeObject*, Runtime_Has##Name) { \ | 14638 RUNTIME_FUNCTION(Object*, Runtime_Has##Name) { \ |
14642 CONVERT_ARG_CHECKED(JSObject, obj, 0); \ | 14639 CONVERT_ARG_CHECKED(JSObject, obj, 0); \ |
14643 return isolate->heap()->ToBoolean(obj->Has##Name()); \ | 14640 return isolate->heap()->ToBoolean(obj->Has##Name()); \ |
14644 } | 14641 } |
14645 | 14642 |
14646 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(FastSmiElements) | 14643 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(FastSmiElements) |
14647 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(FastObjectElements) | 14644 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(FastObjectElements) |
14648 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(FastSmiOrObjectElements) | 14645 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(FastSmiOrObjectElements) |
14649 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(FastDoubleElements) | 14646 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(FastDoubleElements) |
14650 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(FastHoleyElements) | 14647 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(FastHoleyElements) |
14651 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(DictionaryElements) | 14648 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(DictionaryElements) |
14652 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(SloppyArgumentsElements) | 14649 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(SloppyArgumentsElements) |
14653 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(ExternalArrayElements) | 14650 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(ExternalArrayElements) |
14654 // Properties test sitting with elements tests - not fooling anyone. | 14651 // Properties test sitting with elements tests - not fooling anyone. |
14655 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(FastProperties) | 14652 ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(FastProperties) |
14656 | 14653 |
14657 #undef ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION | 14654 #undef ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION |
14658 | 14655 |
14659 | 14656 |
14660 #define TYPED_ARRAYS_CHECK_RUNTIME_FUNCTION(Type, type, TYPE, ctype, size) \ | 14657 #define TYPED_ARRAYS_CHECK_RUNTIME_FUNCTION(Type, type, TYPE, ctype, size) \ |
14661 RUNTIME_FUNCTION(MaybeObject*, Runtime_HasExternal##Type##Elements) { \ | 14658 RUNTIME_FUNCTION(Object*, Runtime_HasExternal##Type##Elements) { \ |
14662 CONVERT_ARG_CHECKED(JSObject, obj, 0); \ | 14659 CONVERT_ARG_CHECKED(JSObject, obj, 0); \ |
14663 return isolate->heap()->ToBoolean(obj->HasExternal##Type##Elements()); \ | 14660 return isolate->heap()->ToBoolean(obj->HasExternal##Type##Elements()); \ |
14664 } | 14661 } |
14665 | 14662 |
14666 TYPED_ARRAYS(TYPED_ARRAYS_CHECK_RUNTIME_FUNCTION) | 14663 TYPED_ARRAYS(TYPED_ARRAYS_CHECK_RUNTIME_FUNCTION) |
14667 | 14664 |
14668 #undef TYPED_ARRAYS_CHECK_RUNTIME_FUNCTION | 14665 #undef TYPED_ARRAYS_CHECK_RUNTIME_FUNCTION |
14669 | 14666 |
14670 | 14667 |
14671 #define FIXED_TYPED_ARRAYS_CHECK_RUNTIME_FUNCTION(Type, type, TYPE, ctype, s) \ | 14668 #define FIXED_TYPED_ARRAYS_CHECK_RUNTIME_FUNCTION(Type, type, TYPE, ctype, s) \ |
14672 RUNTIME_FUNCTION(MaybeObject*, Runtime_HasFixed##Type##Elements) { \ | 14669 RUNTIME_FUNCTION(Object*, Runtime_HasFixed##Type##Elements) { \ |
14673 CONVERT_ARG_CHECKED(JSObject, obj, 0); \ | 14670 CONVERT_ARG_CHECKED(JSObject, obj, 0); \ |
14674 return isolate->heap()->ToBoolean(obj->HasFixed##Type##Elements()); \ | 14671 return isolate->heap()->ToBoolean(obj->HasFixed##Type##Elements()); \ |
14675 } | 14672 } |
14676 | 14673 |
14677 TYPED_ARRAYS(FIXED_TYPED_ARRAYS_CHECK_RUNTIME_FUNCTION) | 14674 TYPED_ARRAYS(FIXED_TYPED_ARRAYS_CHECK_RUNTIME_FUNCTION) |
14678 | 14675 |
14679 #undef FIXED_TYPED_ARRAYS_CHECK_RUNTIME_FUNCTION | 14676 #undef FIXED_TYPED_ARRAYS_CHECK_RUNTIME_FUNCTION |
14680 | 14677 |
14681 | 14678 |
14682 RUNTIME_FUNCTION(MaybeObject*, Runtime_HaveSameMap) { | 14679 RUNTIME_FUNCTION(Object*, Runtime_HaveSameMap) { |
14683 SealHandleScope shs(isolate); | 14680 SealHandleScope shs(isolate); |
14684 ASSERT(args.length() == 2); | 14681 ASSERT(args.length() == 2); |
14685 CONVERT_ARG_CHECKED(JSObject, obj1, 0); | 14682 CONVERT_ARG_CHECKED(JSObject, obj1, 0); |
14686 CONVERT_ARG_CHECKED(JSObject, obj2, 1); | 14683 CONVERT_ARG_CHECKED(JSObject, obj2, 1); |
14687 return isolate->heap()->ToBoolean(obj1->map() == obj2->map()); | 14684 return isolate->heap()->ToBoolean(obj1->map() == obj2->map()); |
14688 } | 14685 } |
14689 | 14686 |
14690 | 14687 |
14691 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsAccessCheckNeeded) { | 14688 RUNTIME_FUNCTION(Object*, Runtime_IsAccessCheckNeeded) { |
14692 SealHandleScope shs(isolate); | 14689 SealHandleScope shs(isolate); |
14693 ASSERT(args.length() == 1); | 14690 ASSERT(args.length() == 1); |
14694 CONVERT_ARG_CHECKED(HeapObject, obj, 0); | 14691 CONVERT_ARG_CHECKED(HeapObject, obj, 0); |
14695 return isolate->heap()->ToBoolean(obj->IsAccessCheckNeeded()); | 14692 return isolate->heap()->ToBoolean(obj->IsAccessCheckNeeded()); |
14696 } | 14693 } |
14697 | 14694 |
14698 | 14695 |
14699 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsObserved) { | 14696 RUNTIME_FUNCTION(Object*, Runtime_IsObserved) { |
14700 SealHandleScope shs(isolate); | 14697 SealHandleScope shs(isolate); |
14701 ASSERT(args.length() == 1); | 14698 ASSERT(args.length() == 1); |
14702 | 14699 |
14703 if (!args[0]->IsJSReceiver()) return isolate->heap()->false_value(); | 14700 if (!args[0]->IsJSReceiver()) return isolate->heap()->false_value(); |
14704 CONVERT_ARG_CHECKED(JSReceiver, obj, 0); | 14701 CONVERT_ARG_CHECKED(JSReceiver, obj, 0); |
14705 if (obj->IsJSGlobalProxy()) { | 14702 if (obj->IsJSGlobalProxy()) { |
14706 Object* proto = obj->GetPrototype(); | 14703 Object* proto = obj->GetPrototype(); |
14707 if (proto->IsNull()) return isolate->heap()->false_value(); | 14704 if (proto->IsNull()) return isolate->heap()->false_value(); |
14708 ASSERT(proto->IsJSGlobalObject()); | 14705 ASSERT(proto->IsJSGlobalObject()); |
14709 obj = JSReceiver::cast(proto); | 14706 obj = JSReceiver::cast(proto); |
14710 } | 14707 } |
14711 return isolate->heap()->ToBoolean(obj->map()->is_observed()); | 14708 return isolate->heap()->ToBoolean(obj->map()->is_observed()); |
14712 } | 14709 } |
14713 | 14710 |
14714 | 14711 |
14715 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetIsObserved) { | 14712 RUNTIME_FUNCTION(Object*, Runtime_SetIsObserved) { |
14716 HandleScope scope(isolate); | 14713 HandleScope scope(isolate); |
14717 ASSERT(args.length() == 1); | 14714 ASSERT(args.length() == 1); |
14718 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, obj, 0); | 14715 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, obj, 0); |
14719 if (obj->IsJSGlobalProxy()) { | 14716 if (obj->IsJSGlobalProxy()) { |
14720 Object* proto = obj->GetPrototype(); | 14717 Object* proto = obj->GetPrototype(); |
14721 if (proto->IsNull()) return isolate->heap()->undefined_value(); | 14718 if (proto->IsNull()) return isolate->heap()->undefined_value(); |
14722 ASSERT(proto->IsJSGlobalObject()); | 14719 ASSERT(proto->IsJSGlobalObject()); |
14723 obj = handle(JSReceiver::cast(proto)); | 14720 obj = handle(JSReceiver::cast(proto)); |
14724 } | 14721 } |
14725 if (obj->IsJSProxy()) | 14722 if (obj->IsJSProxy()) |
14726 return isolate->heap()->undefined_value(); | 14723 return isolate->heap()->undefined_value(); |
14727 | 14724 |
14728 ASSERT(obj->IsJSObject()); | 14725 ASSERT(obj->IsJSObject()); |
14729 JSObject::SetObserved(Handle<JSObject>::cast(obj)); | 14726 JSObject::SetObserved(Handle<JSObject>::cast(obj)); |
14730 return isolate->heap()->undefined_value(); | 14727 return isolate->heap()->undefined_value(); |
14731 } | 14728 } |
14732 | 14729 |
14733 | 14730 |
14734 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetMicrotaskPending) { | 14731 RUNTIME_FUNCTION(Object*, Runtime_SetMicrotaskPending) { |
14735 SealHandleScope shs(isolate); | 14732 SealHandleScope shs(isolate); |
14736 ASSERT(args.length() == 1); | 14733 ASSERT(args.length() == 1); |
14737 CONVERT_BOOLEAN_ARG_CHECKED(new_state, 0); | 14734 CONVERT_BOOLEAN_ARG_CHECKED(new_state, 0); |
14738 bool old_state = isolate->microtask_pending(); | 14735 bool old_state = isolate->microtask_pending(); |
14739 isolate->set_microtask_pending(new_state); | 14736 isolate->set_microtask_pending(new_state); |
14740 return isolate->heap()->ToBoolean(old_state); | 14737 return isolate->heap()->ToBoolean(old_state); |
14741 } | 14738 } |
14742 | 14739 |
14743 | 14740 |
14744 RUNTIME_FUNCTION(MaybeObject*, Runtime_RunMicrotasks) { | 14741 RUNTIME_FUNCTION(Object*, Runtime_RunMicrotasks) { |
14745 HandleScope scope(isolate); | 14742 HandleScope scope(isolate); |
14746 ASSERT(args.length() == 0); | 14743 ASSERT(args.length() == 0); |
14747 if (isolate->microtask_pending()) Execution::RunMicrotasks(isolate); | 14744 if (isolate->microtask_pending()) Execution::RunMicrotasks(isolate); |
14748 return isolate->heap()->undefined_value(); | 14745 return isolate->heap()->undefined_value(); |
14749 } | 14746 } |
14750 | 14747 |
14751 | 14748 |
14752 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetMicrotaskState) { | 14749 RUNTIME_FUNCTION(Object*, Runtime_GetMicrotaskState) { |
14753 SealHandleScope shs(isolate); | 14750 SealHandleScope shs(isolate); |
14754 ASSERT(args.length() == 0); | 14751 ASSERT(args.length() == 0); |
14755 return isolate->heap()->microtask_state(); | 14752 return isolate->heap()->microtask_state(); |
14756 } | 14753 } |
14757 | 14754 |
14758 | 14755 |
14759 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetObservationState) { | 14756 RUNTIME_FUNCTION(Object*, Runtime_GetObservationState) { |
14760 SealHandleScope shs(isolate); | 14757 SealHandleScope shs(isolate); |
14761 ASSERT(args.length() == 0); | 14758 ASSERT(args.length() == 0); |
14762 return isolate->heap()->observation_state(); | 14759 return isolate->heap()->observation_state(); |
14763 } | 14760 } |
14764 | 14761 |
14765 | 14762 |
14766 RUNTIME_FUNCTION(MaybeObject*, Runtime_ObservationWeakMapCreate) { | 14763 RUNTIME_FUNCTION(Object*, Runtime_ObservationWeakMapCreate) { |
14767 HandleScope scope(isolate); | 14764 HandleScope scope(isolate); |
14768 ASSERT(args.length() == 0); | 14765 ASSERT(args.length() == 0); |
14769 // TODO(adamk): Currently this runtime function is only called three times per | 14766 // TODO(adamk): Currently this runtime function is only called three times per |
14770 // isolate. If it's called more often, the map should be moved into the | 14767 // isolate. If it's called more often, the map should be moved into the |
14771 // strong root list. | 14768 // strong root list. |
14772 Handle<Map> map = | 14769 Handle<Map> map = |
14773 isolate->factory()->NewMap(JS_WEAK_MAP_TYPE, JSWeakMap::kSize); | 14770 isolate->factory()->NewMap(JS_WEAK_MAP_TYPE, JSWeakMap::kSize); |
14774 Handle<JSWeakMap> weakmap = | 14771 Handle<JSWeakMap> weakmap = |
14775 Handle<JSWeakMap>::cast(isolate->factory()->NewJSObjectFromMap(map)); | 14772 Handle<JSWeakMap>::cast(isolate->factory()->NewJSObjectFromMap(map)); |
14776 return WeakCollectionInitialize(isolate, weakmap); | 14773 return WeakCollectionInitialize(isolate, weakmap); |
14777 } | 14774 } |
14778 | 14775 |
14779 | 14776 |
14780 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsAccessAllowedForObserver) { | 14777 RUNTIME_FUNCTION(Object*, Runtime_IsAccessAllowedForObserver) { |
14781 HandleScope scope(isolate); | 14778 HandleScope scope(isolate); |
14782 ASSERT(args.length() == 3); | 14779 ASSERT(args.length() == 3); |
14783 CONVERT_ARG_HANDLE_CHECKED(JSFunction, observer, 0); | 14780 CONVERT_ARG_HANDLE_CHECKED(JSFunction, observer, 0); |
14784 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 1); | 14781 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 1); |
14785 ASSERT(object->map()->is_access_check_needed()); | 14782 ASSERT(object->map()->is_access_check_needed()); |
14786 CONVERT_ARG_HANDLE_CHECKED(Object, key, 2); | 14783 CONVERT_ARG_HANDLE_CHECKED(Object, key, 2); |
14787 SaveContext save(isolate); | 14784 SaveContext save(isolate); |
14788 isolate->set_context(observer->context()); | 14785 isolate->set_context(observer->context()); |
14789 if (!isolate->MayNamedAccess( | 14786 if (!isolate->MayNamedAccess( |
14790 object, isolate->factory()->undefined_value(), v8::ACCESS_KEYS)) { | 14787 object, isolate->factory()->undefined_value(), v8::ACCESS_KEYS)) { |
14791 return isolate->heap()->false_value(); | 14788 return isolate->heap()->false_value(); |
14792 } | 14789 } |
14793 bool access_allowed = false; | 14790 bool access_allowed = false; |
14794 uint32_t index = 0; | 14791 uint32_t index = 0; |
14795 if (key->ToArrayIndex(&index) || | 14792 if (key->ToArrayIndex(&index) || |
14796 (key->IsString() && String::cast(*key)->AsArrayIndex(&index))) { | 14793 (key->IsString() && String::cast(*key)->AsArrayIndex(&index))) { |
14797 access_allowed = | 14794 access_allowed = |
14798 isolate->MayIndexedAccess(object, index, v8::ACCESS_GET) && | 14795 isolate->MayIndexedAccess(object, index, v8::ACCESS_GET) && |
14799 isolate->MayIndexedAccess(object, index, v8::ACCESS_HAS); | 14796 isolate->MayIndexedAccess(object, index, v8::ACCESS_HAS); |
14800 } else { | 14797 } else { |
14801 access_allowed = | 14798 access_allowed = |
14802 isolate->MayNamedAccess(object, key, v8::ACCESS_GET) && | 14799 isolate->MayNamedAccess(object, key, v8::ACCESS_GET) && |
14803 isolate->MayNamedAccess(object, key, v8::ACCESS_HAS); | 14800 isolate->MayNamedAccess(object, key, v8::ACCESS_HAS); |
14804 } | 14801 } |
14805 return isolate->heap()->ToBoolean(access_allowed); | 14802 return isolate->heap()->ToBoolean(access_allowed); |
14806 } | 14803 } |
14807 | 14804 |
14808 | 14805 |
14809 static MaybeObject* ArrayConstructorCommon(Isolate* isolate, | 14806 static Object* ArrayConstructorCommon(Isolate* isolate, |
14810 Handle<JSFunction> constructor, | 14807 Handle<JSFunction> constructor, |
14811 Handle<AllocationSite> site, | 14808 Handle<AllocationSite> site, |
14812 Arguments* caller_args) { | 14809 Arguments* caller_args) { |
14813 Factory* factory = isolate->factory(); | 14810 Factory* factory = isolate->factory(); |
14814 | 14811 |
14815 bool holey = false; | 14812 bool holey = false; |
14816 bool can_use_type_feedback = true; | 14813 bool can_use_type_feedback = true; |
14817 if (caller_args->length() == 1) { | 14814 if (caller_args->length() == 1) { |
14818 Handle<Object> argument_one = caller_args->at<Object>(0); | 14815 Handle<Object> argument_one = caller_args->at<Object>(0); |
14819 if (argument_one->IsSmi()) { | 14816 if (argument_one->IsSmi()) { |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
14878 !can_use_type_feedback)) { | 14875 !can_use_type_feedback)) { |
14879 // The arguments passed in caused a transition. This kind of complexity | 14876 // The arguments passed in caused a transition. This kind of complexity |
14880 // can't be dealt with in the inlined hydrogen array constructor case. | 14877 // can't be dealt with in the inlined hydrogen array constructor case. |
14881 // We must mark the allocationsite as un-inlinable. | 14878 // We must mark the allocationsite as un-inlinable. |
14882 site->SetDoNotInlineCall(); | 14879 site->SetDoNotInlineCall(); |
14883 } | 14880 } |
14884 return *array; | 14881 return *array; |
14885 } | 14882 } |
14886 | 14883 |
14887 | 14884 |
14888 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_ArrayConstructor) { | 14885 RUNTIME_FUNCTION(Object*, RuntimeHidden_ArrayConstructor) { |
14889 HandleScope scope(isolate); | 14886 HandleScope scope(isolate); |
14890 // If we get 2 arguments then they are the stub parameters (constructor, type | 14887 // If we get 2 arguments then they are the stub parameters (constructor, type |
14891 // info). If we get 4, then the first one is a pointer to the arguments | 14888 // info). If we get 4, then the first one is a pointer to the arguments |
14892 // passed by the caller, and the last one is the length of the arguments | 14889 // passed by the caller, and the last one is the length of the arguments |
14893 // passed to the caller (redundant, but useful to check on the deoptimizer | 14890 // passed to the caller (redundant, but useful to check on the deoptimizer |
14894 // with an assert). | 14891 // with an assert). |
14895 Arguments empty_args(0, NULL); | 14892 Arguments empty_args(0, NULL); |
14896 bool no_caller_args = args.length() == 2; | 14893 bool no_caller_args = args.length() == 2; |
14897 ASSERT(no_caller_args || args.length() == 4); | 14894 ASSERT(no_caller_args || args.length() == 4); |
14898 int parameters_start = no_caller_args ? 0 : 1; | 14895 int parameters_start = no_caller_args ? 0 : 1; |
(...skipping 16 matching lines...) Expand all Loading... | |
14915 ASSERT(!site->SitePointsToLiteral()); | 14912 ASSERT(!site->SitePointsToLiteral()); |
14916 } | 14913 } |
14917 | 14914 |
14918 return ArrayConstructorCommon(isolate, | 14915 return ArrayConstructorCommon(isolate, |
14919 constructor, | 14916 constructor, |
14920 site, | 14917 site, |
14921 caller_args); | 14918 caller_args); |
14922 } | 14919 } |
14923 | 14920 |
14924 | 14921 |
14925 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_InternalArrayConstructor) { | 14922 RUNTIME_FUNCTION(Object*, RuntimeHidden_InternalArrayConstructor) { |
14926 HandleScope scope(isolate); | 14923 HandleScope scope(isolate); |
14927 Arguments empty_args(0, NULL); | 14924 Arguments empty_args(0, NULL); |
14928 bool no_caller_args = args.length() == 1; | 14925 bool no_caller_args = args.length() == 1; |
14929 ASSERT(no_caller_args || args.length() == 3); | 14926 ASSERT(no_caller_args || args.length() == 3); |
14930 int parameters_start = no_caller_args ? 0 : 1; | 14927 int parameters_start = no_caller_args ? 0 : 1; |
14931 Arguments* caller_args = no_caller_args | 14928 Arguments* caller_args = no_caller_args |
14932 ? &empty_args | 14929 ? &empty_args |
14933 : reinterpret_cast<Arguments*>(args[0]); | 14930 : reinterpret_cast<Arguments*>(args[0]); |
14934 CONVERT_ARG_HANDLE_CHECKED(JSFunction, constructor, parameters_start); | 14931 CONVERT_ARG_HANDLE_CHECKED(JSFunction, constructor, parameters_start); |
14935 #ifdef DEBUG | 14932 #ifdef DEBUG |
14936 if (!no_caller_args) { | 14933 if (!no_caller_args) { |
14937 CONVERT_SMI_ARG_CHECKED(arg_count, parameters_start + 1); | 14934 CONVERT_SMI_ARG_CHECKED(arg_count, parameters_start + 1); |
14938 ASSERT(arg_count == caller_args->length()); | 14935 ASSERT(arg_count == caller_args->length()); |
14939 } | 14936 } |
14940 #endif | 14937 #endif |
14941 return ArrayConstructorCommon(isolate, | 14938 return ArrayConstructorCommon(isolate, |
14942 constructor, | 14939 constructor, |
14943 Handle<AllocationSite>::null(), | 14940 Handle<AllocationSite>::null(), |
14944 caller_args); | 14941 caller_args); |
14945 } | 14942 } |
14946 | 14943 |
14947 | 14944 |
14948 RUNTIME_FUNCTION(MaybeObject*, Runtime_MaxSmi) { | 14945 RUNTIME_FUNCTION(Object*, Runtime_MaxSmi) { |
14949 ASSERT(args.length() == 0); | 14946 ASSERT(args.length() == 0); |
14950 return Smi::FromInt(Smi::kMaxValue); | 14947 return Smi::FromInt(Smi::kMaxValue); |
14951 } | 14948 } |
14952 | 14949 |
14953 | 14950 |
14954 // ---------------------------------------------------------------------------- | 14951 // ---------------------------------------------------------------------------- |
14955 // Implementation of Runtime | 14952 // Implementation of Runtime |
14956 | 14953 |
14957 #define F(name, number_of_args, result_size) \ | 14954 #define F(name, number_of_args, result_size) \ |
14958 { Runtime::k##name, Runtime::RUNTIME, #name, \ | 14955 { Runtime::k##name, Runtime::RUNTIME, #name, \ |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
15014 return &(kIntrinsicFunctions[function_index]); | 15011 return &(kIntrinsicFunctions[function_index]); |
15015 } | 15012 } |
15016 return NULL; | 15013 return NULL; |
15017 } | 15014 } |
15018 | 15015 |
15019 | 15016 |
15020 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) { | 15017 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) { |
15021 return &(kIntrinsicFunctions[static_cast<int>(id)]); | 15018 return &(kIntrinsicFunctions[static_cast<int>(id)]); |
15022 } | 15019 } |
15023 | 15020 |
15024 | |
15025 void Runtime::PerformGC(Object* result, Isolate* isolate) { | |
15026 Failure* failure = Failure::cast(result); | |
15027 if (failure->IsRetryAfterGC()) { | |
15028 if (isolate->heap()->new_space()->AddFreshPage()) { | |
15029 return; | |
15030 } | |
15031 | |
15032 // Try to do a garbage collection; ignore it if it fails. The C | |
15033 // entry stub will throw an out-of-memory exception in that case. | |
15034 isolate->heap()->CollectGarbage(failure->allocation_space(), | |
15035 "Runtime::PerformGC"); | |
15036 } else { | |
15037 // Handle last resort GC and make sure to allow future allocations | |
15038 // to grow the heap without causing GCs (if possible). | |
15039 isolate->counters()->gc_last_resort_from_js()->Increment(); | |
15040 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, | |
15041 "Runtime::PerformGC"); | |
15042 } | |
15043 } | |
15044 | |
15045 | |
15046 void Runtime::OutOfMemory() { | |
15047 Heap::FatalProcessOutOfMemory("CALL_AND_RETRY_LAST", true); | |
15048 UNREACHABLE(); | |
15049 } | |
15050 | |
15051 } } // namespace v8::internal | 15021 } } // namespace v8::internal |
OLD | NEW |